From 392b87f625b6f9f8e3bc70c1445f4f81f1767285 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Thu, 24 Aug 2023 20:57:47 +0000 Subject: [PATCH 1/3] fix: simplify logic for HTTP/1.1 REST fallback option For the `fallback` parameter, all values considered as `true` in Boolean context will enable HTTP/1.1 REST fallback, since the other fallback transport, proto over HTTP, is removed from `google-gax` v4. PiperOrigin-RevId: 559812260 Source-Link: https://github.com/googleapis/googleapis/commit/6a6fd29a79fe2846001d90d93e79a19fcc303b85 Source-Link: https://github.com/googleapis/googleapis-gen/commit/56c16657e7a59122b1da94771a9ef40989c282c0 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW5ldHdvcmtzZWN1cml0eS8uT3dsQm90LnlhbWwiLCJoIjoiNTZjMTY2NTdlN2E1OTEyMmIxZGE5NDc3MWE5ZWY0MDk4OWMyODJjMCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW5vdGVib29rcy8uT3dsQm90LnlhbWwiLCJoIjoiNTZjMTY2NTdlN2E1OTEyMmIxZGE5NDc3MWE5ZWY0MDk4OWMyODJjMCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW9wdGltaXphdGlvbi8uT3dsQm90LnlhbWwiLCJoIjoiNTZjMTY2NTdlN2E1OTEyMmIxZGE5NDc3MWE5ZWY0MDk4OWMyODJjMCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW9yY2hlc3RyYXRpb24tYWlyZmxvdy1zZXJ2aWNlLy5Pd2xCb3QueWFtbCIsImgiOiI1NmMxNjY1N2U3YTU5MTIyYjFkYTk0NzcxYTllZjQwOTg5YzI4MmMwIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW9yZ3BvbGljeS8uT3dsQm90LnlhbWwiLCJoIjoiNTZjMTY2NTdlN2E1OTEyMmIxZGE5NDc3MWE5ZWY0MDk4OWMyODJjMCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW9zY29uZmlnLy5Pd2xCb3QueWFtbCIsImgiOiI1NmMxNjY1N2U3YTU5MTIyYjFkYTk0NzcxYTllZjQwOTg5YzI4MmMwIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW9zbG9naW4vLk93bEJvdC55YW1sIiwiaCI6IjU2YzE2NjU3ZTdhNTkxMjJiMWRhOTQ3NzFhOWVmNDA5ODljMjgyYzAifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXBoaXNoaW5ncHJvdGVjdGlvbi8uT3dsQm90LnlhbWwiLCJoIjoiNTZjMTY2NTdlN2E1OTEyMmIxZGE5NDc3MWE5ZWY0MDk4OWMyODJjMCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXBvbGljeXRyb3VibGVzaG9vdGVyLWlhbS8uT3dsQm90LnlhbWwiLCJoIjoiNTZjMTY2NTdlN2E1OTEyMmIxZGE5NDc3MWE5ZWY0MDk4OWMyODJjMCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXBvbGljeXRyb3VibGVzaG9vdGVyLy5Pd2xCb3QueWFtbCIsImgiOiI1NmMxNjY1N2U3YTU5MTIyYjFkYTk0NzcxYTllZjQwOTg5YzI4MmMwIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXByaXZhdGVjYXRhbG9nLy5Pd2xCb3QueWFtbCIsImgiOiI1NmMxNjY1N2U3YTU5MTIyYjFkYTk0NzcxYTllZjQwOTg5YzI4MmMwIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJhcGlkbWlncmF0aW9uYXNzZXNzbWVudC8uT3dsQm90LnlhbWwiLCJoIjoiNTZjMTY2NTdlN2E1OTEyMmIxZGE5NDc3MWE5ZWY0MDk4OWMyODJjMCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlY2FwdGNoYWVudGVycHJpc2UvLk93bEJvdC55YW1sIiwiaCI6IjU2YzE2NjU3ZTdhNTkxMjJiMWRhOTQ3NzFhOWVmNDA5ODljMjgyYzAifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlY29tbWVuZGVyLy5Pd2xCb3QueWFtbCIsImgiOiI1NmMxNjY1N2U3YTU5MTIyYjFkYTk0NzcxYTllZjQwOTg5YzI4MmMwIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlZGlzLy5Pd2xCb3QueWFtbCIsImgiOiI1NmMxNjY1N2U3YTU5MTIyYjFkYTk0NzcxYTllZjQwOTg5YzI4MmMwIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlc291cmNlbWFuYWdlci8uT3dsQm90LnlhbWwiLCJoIjoiNTZjMTY2NTdlN2E1OTEyMmIxZGE5NDc3MWE5ZWY0MDk4OWMyODJjMCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlc291cmNlc2V0dGluZ3MvLk93bEJvdC55YW1sIiwiaCI6IjU2YzE2NjU3ZTdhNTkxMjJiMWRhOTQ3NzFhOWVmNDA5ODljMjgyYzAifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJldGFpbC8uT3dsQm90LnlhbWwiLCJoIjoiNTZjMTY2NTdlN2E1OTEyMmIxZGE5NDc3MWE5ZWY0MDk4OWMyODJjMCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJ1bi8uT3dsQm90LnlhbWwiLCJoIjoiNTZjMTY2NTdlN2E1OTEyMmIxZGE5NDc3MWE5ZWY0MDk4OWMyODJjMCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNjaGVkdWxlci8uT3dsQm90LnlhbWwiLCJoIjoiNTZjMTY2NTdlN2E1OTEyMmIxZGE5NDc3MWE5ZWY0MDk4OWMyODJjMCJ9 --- .../v1/.eslintignore | 7 + .../v1/.eslintrc.json | 3 + .../v1/.gitignore | 14 + .../google-cloud-networksecurity/v1/.jsdoc.js | 55 + .../v1/.mocharc.js | 33 + .../v1/.prettierrc.js | 22 + .../google-cloud-networksecurity/v1/README.md | 1 + .../v1/package.json | 58 + .../v1/authorization_policy.proto | 249 + .../v1/client_tls_policy.proto | 160 + .../cloud/networksecurity/v1/common.proto | 55 + .../networksecurity/v1/network_security.proto | 201 + .../v1/server_tls_policy.proto | 181 + .../google/cloud/networksecurity/v1/tls.proto | 78 + ...rk_security.create_authorization_policy.js | 76 + ...twork_security.create_client_tls_policy.js | 75 + ...twork_security.create_server_tls_policy.js | 75 + ...rk_security.delete_authorization_policy.js | 63 + ...twork_security.delete_client_tls_policy.js | 63 + ...twork_security.delete_server_tls_policy.js | 63 + ...twork_security.get_authorization_policy.js | 62 + .../network_security.get_client_tls_policy.js | 62 + .../network_security.get_server_tls_policy.js | 62 + ...rk_security.list_authorization_policies.js | 76 + ...twork_security.list_client_tls_policies.js | 75 + ...twork_security.list_server_tls_policies.js | 75 + ...rk_security.update_authorization_policy.js | 70 + ...twork_security.update_client_tls_policy.js | 71 + ...twork_security.update_server_tls_policy.js | 71 + ...adata_google.cloud.networksecurity.v1.json | 675 ++ .../v1/src/index.ts | 25 + .../v1/src/v1/gapic_metadata.json | 185 + .../v1/src/v1/index.ts | 19 + .../v1/src/v1/network_security_client.ts | 2592 +++++++ .../v1/network_security_client_config.json | 101 + .../src/v1/network_security_proto_list.json | 8 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1/system-test/install.ts | 49 + .../v1/test/gapic_network_security_v1.ts | 3508 +++++++++ .../v1/tsconfig.json | 19 + .../v1/webpack.config.js | 64 + .../v1beta1/.eslintignore | 7 + .../v1beta1/.eslintrc.json | 3 + .../v1beta1/.gitignore | 14 + .../v1beta1/.jsdoc.js | 55 + .../v1beta1/.mocharc.js | 33 + .../v1beta1/.prettierrc.js | 22 + .../v1beta1/README.md | 1 + .../v1beta1/package.json | 58 + .../v1beta1/authorization_policy.proto | 259 + .../v1beta1/client_tls_policy.proto | 169 + .../networksecurity/v1beta1/common.proto | 58 + .../v1beta1/network_security.proto | 201 + .../v1beta1/server_tls_policy.proto | 187 + .../cloud/networksecurity/v1beta1/tls.proto | 78 + ...rk_security.create_authorization_policy.js | 76 + ...twork_security.create_client_tls_policy.js | 76 + ...twork_security.create_server_tls_policy.js | 76 + ...rk_security.delete_authorization_policy.js | 63 + ...twork_security.delete_client_tls_policy.js | 63 + ...twork_security.delete_server_tls_policy.js | 63 + ...twork_security.get_authorization_policy.js | 62 + .../network_security.get_client_tls_policy.js | 62 + .../network_security.get_server_tls_policy.js | 62 + ...rk_security.list_authorization_policies.js | 76 + ...twork_security.list_client_tls_policies.js | 75 + ...twork_security.list_server_tls_policies.js | 75 + ...rk_security.update_authorization_policy.js | 70 + ...twork_security.update_client_tls_policy.js | 71 + ...twork_security.update_server_tls_policy.js | 71 + ..._google.cloud.networksecurity.v1beta1.json | 675 ++ .../v1beta1/src/index.ts | 25 + .../v1beta1/src/v1beta1/gapic_metadata.json | 185 + .../v1beta1/src/v1beta1/index.ts | 19 + .../src/v1beta1/network_security_client.ts | 2594 +++++++ .../network_security_client_config.json | 101 + .../v1beta1/network_security_proto_list.json | 8 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1beta1/system-test/install.ts | 49 + .../test/gapic_network_security_v1beta1.ts | 3508 +++++++++ .../v1beta1/tsconfig.json | 19 + .../v1beta1/webpack.config.js | 64 + .../google-cloud-notebooks/v1/.eslintignore | 7 + .../google-cloud-notebooks/v1/.eslintrc.json | 3 + .../google-cloud-notebooks/v1/.gitignore | 14 + .../google-cloud-notebooks/v1/.jsdoc.js | 55 + .../google-cloud-notebooks/v1/.mocharc.js | 33 + .../google-cloud-notebooks/v1/.prettierrc.js | 22 + .../google-cloud-notebooks/v1/README.md | 1 + .../google-cloud-notebooks/v1/package.json | 59 + .../notebooks/v1/diagnostic_config.proto | 60 + .../cloud/notebooks/v1/environment.proto | 96 + .../google/cloud/notebooks/v1/event.proto | 61 + .../google/cloud/notebooks/v1/execution.proto | 350 + .../google/cloud/notebooks/v1/instance.proto | 541 ++ .../cloud/notebooks/v1/instance_config.proto | 35 + .../cloud/notebooks/v1/managed_service.proto | 439 ++ .../google/cloud/notebooks/v1/runtime.proto | 611 ++ .../google/cloud/notebooks/v1/schedule.proto | 107 + .../google/cloud/notebooks/v1/service.proto | 1017 +++ ...managed_notebook_service.create_runtime.js | 77 + ...managed_notebook_service.delete_runtime.js | 67 + ...naged_notebook_service.diagnose_runtime.js | 68 + .../managed_notebook_service.get_runtime.js | 62 + .../managed_notebook_service.list_runtimes.js | 73 + ..._service.refresh_runtime_token_internal.js | 68 + ...d_notebook_service.report_runtime_event.js | 74 + .../managed_notebook_service.reset_runtime.js | 67 + .../managed_notebook_service.start_runtime.js | 67 + .../managed_notebook_service.stop_runtime.js | 67 + ...managed_notebook_service.switch_runtime.js | 75 + ...managed_notebook_service.update_runtime.js | 90 + ...anaged_notebook_service.upgrade_runtime.js | 67 + .../v1/notebook_service.create_environment.js | 75 + .../v1/notebook_service.create_execution.js | 73 + .../v1/notebook_service.create_instance.js | 73 + .../v1/notebook_service.create_schedule.js | 73 + .../v1/notebook_service.delete_environment.js | 63 + .../v1/notebook_service.delete_execution.js | 63 + .../v1/notebook_service.delete_instance.js | 63 + .../v1/notebook_service.delete_schedule.js | 63 + .../v1/notebook_service.diagnose_instance.js | 68 + .../v1/notebook_service.get_environment.js | 62 + .../v1/notebook_service.get_execution.js | 62 + .../v1/notebook_service.get_instance.js | 62 + .../notebook_service.get_instance_health.js | 62 + .../v1/notebook_service.get_schedule.js | 62 + ...otebook_service.is_instance_upgradeable.js | 67 + .../v1/notebook_service.list_environments.js | 72 + .../v1/notebook_service.list_executions.js | 83 + .../v1/notebook_service.list_instances.js | 73 + .../v1/notebook_service.list_schedules.js | 81 + .../v1/notebook_service.register_instance.js | 71 + .../notebook_service.report_instance_info.js | 74 + .../v1/notebook_service.reset_instance.js | 63 + .../v1/notebook_service.rollback_instance.js | 69 + ...tebook_service.set_instance_accelerator.js | 76 + .../notebook_service.set_instance_labels.js | 68 + ...ebook_service.set_instance_machine_type.js | 69 + .../v1/notebook_service.start_instance.js | 63 + .../v1/notebook_service.stop_instance.js | 63 + .../v1/notebook_service.trigger_schedule.js | 63 + ...notebook_service.update_instance_config.js | 67 + ..._service.update_instance_metadata_items.js | 66 + ...service.update_shielded_instance_config.js | 67 + .../v1/notebook_service.upgrade_instance.js | 68 + ...ebook_service.upgrade_instance_internal.js | 74 + ...et_metadata_google.cloud.notebooks.v1.json | 2115 ++++++ .../google-cloud-notebooks/v1/src/index.ts | 27 + .../v1/src/v1/gapic_metadata.json | 527 ++ .../google-cloud-notebooks/v1/src/v1/index.ts | 20 + .../src/v1/managed_notebook_service_client.ts | 2414 +++++++ ...anaged_notebook_service_client_config.json | 94 + .../managed_notebook_service_proto_list.json | 12 + .../v1/src/v1/notebook_service_client.ts | 4544 ++++++++++++ .../v1/notebook_service_client_config.json | 199 + .../src/v1/notebook_service_proto_list.json | 12 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + .../v1/system-test/install.ts | 49 + .../test/gapic_managed_notebook_service_v1.ts | 3200 ++++++++ .../v1/test/gapic_notebook_service_v1.ts | 6405 +++++++++++++++++ .../google-cloud-notebooks/v1/tsconfig.json | 19 + .../v1/webpack.config.js | 64 + .../v1beta1/.eslintignore | 7 + .../v1beta1/.eslintrc.json | 3 + .../google-cloud-notebooks/v1beta1/.gitignore | 14 + .../google-cloud-notebooks/v1beta1/.jsdoc.js | 55 + .../v1beta1/.mocharc.js | 33 + .../v1beta1/.prettierrc.js | 22 + .../google-cloud-notebooks/v1beta1/README.md | 1 + .../v1beta1/package.json | 58 + .../cloud/notebooks/v1beta1/environment.proto | 96 + .../cloud/notebooks/v1beta1/instance.proto | 333 + .../cloud/notebooks/v1beta1/service.proto | 524 ++ .../notebook_service.create_environment.js | 75 + .../notebook_service.create_instance.js | 73 + .../notebook_service.delete_environment.js | 63 + .../notebook_service.delete_instance.js | 63 + .../notebook_service.get_environment.js | 62 + .../v1beta1/notebook_service.get_instance.js | 62 + ...otebook_service.is_instance_upgradeable.js | 62 + .../notebook_service.list_environments.js | 72 + .../notebook_service.list_instances.js | 73 + .../notebook_service.register_instance.js | 71 + .../notebook_service.report_instance_info.js | 74 + .../notebook_service.reset_instance.js | 63 + ...tebook_service.set_instance_accelerator.js | 76 + .../notebook_service.set_instance_labels.js | 68 + ...ebook_service.set_instance_machine_type.js | 69 + .../notebook_service.start_instance.js | 63 + .../v1beta1/notebook_service.stop_instance.js | 63 + .../notebook_service.upgrade_instance.js | 63 + ...ebook_service.upgrade_instance_internal.js | 69 + ...tadata_google.cloud.notebooks.v1beta1.json | 839 +++ .../v1beta1/src/index.ts | 25 + .../v1beta1/src/v1beta1/gapic_metadata.json | 221 + .../v1beta1/src/v1beta1/index.ts | 19 + .../src/v1beta1/notebook_service_client.ts | 2818 ++++++++ .../notebook_service_client_config.json | 121 + .../v1beta1/notebook_service_proto_list.json | 5 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1beta1/system-test/install.ts | 49 + .../test/gapic_notebook_service_v1beta1.ts | 3991 ++++++++++ .../v1beta1/tsconfig.json | 19 + .../v1beta1/webpack.config.js | 64 + .../google-cloud-notebooks/v2/.eslintignore | 7 + .../google-cloud-notebooks/v2/.eslintrc.json | 3 + .../google-cloud-notebooks/v2/.gitignore | 14 + .../google-cloud-notebooks/v2/.jsdoc.js | 55 + .../google-cloud-notebooks/v2/.mocharc.js | 33 + .../google-cloud-notebooks/v2/.prettierrc.js | 22 + .../google-cloud-notebooks/v2/README.md | 1 + .../google-cloud-notebooks/v2/package.json | 58 + .../notebooks/v2/diagnostic_config.proto | 61 + .../google/cloud/notebooks/v2/event.proto | 70 + .../google/cloud/notebooks/v2/gce_setup.proto | 340 + .../google/cloud/notebooks/v2/instance.proto | 231 + .../google/cloud/notebooks/v2/service.proto | 413 ++ ...ok_service.check_instance_upgradability.js | 62 + .../v2/notebook_service.create_instance.js | 77 + .../v2/notebook_service.delete_instance.js | 67 + .../v2/notebook_service.diagnose_instance.js | 72 + .../v2/notebook_service.get_instance.js | 62 + .../v2/notebook_service.list_instances.js | 82 + .../v2/notebook_service.reset_instance.js | 63 + .../v2/notebook_service.rollback_instance.js | 74 + .../v2/notebook_service.start_instance.js | 63 + .../v2/notebook_service.stop_instance.js | 63 + .../v2/notebook_service.update_instance.js | 71 + .../v2/notebook_service.upgrade_instance.js | 63 + ...et_metadata_google.cloud.notebooks.v2.json | 551 ++ .../google-cloud-notebooks/v2/src/index.ts | 25 + .../v2/src/v2/gapic_metadata.json | 147 + .../google-cloud-notebooks/v2/src/v2/index.ts | 19 + .../v2/src/v2/notebook_service_client.ts | 2099 ++++++ .../v2/notebook_service_client_config.json | 89 + .../src/v2/notebook_service_proto_list.json | 7 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v2/system-test/install.ts | 49 + .../v2/test/gapic_notebook_service_v2.ts | 2878 ++++++++ .../google-cloud-notebooks/v2/tsconfig.json | 19 + .../v2/webpack.config.js | 64 + .../v1/.eslintignore | 7 + .../v1/.eslintrc.json | 3 + .../google-cloud-optimization/v1/.gitignore | 14 + .../google-cloud-optimization/v1/.jsdoc.js | 55 + .../google-cloud-optimization/v1/.mocharc.js | 33 + .../v1/.prettierrc.js | 22 + .../google-cloud-optimization/v1/README.md | 1 + .../google-cloud-optimization/v1/package.json | 58 + .../cloud/optimization/v1/async_model.proto | 110 + .../cloud/optimization/v1/fleet_routing.proto | 2750 +++++++ .../v1/fleet_routing.batch_optimize_tours.js | 70 + .../v1/fleet_routing.optimize_tours.js | 254 + ...metadata_google.cloud.optimization.v1.json | 167 + .../google-cloud-optimization/v1/src/index.ts | 25 + .../v1/src/v1/fleet_routing_client.ts | 901 +++ .../src/v1/fleet_routing_client_config.json | 48 + .../v1/src/v1/fleet_routing_proto_list.json | 4 + .../v1/src/v1/gapic_metadata.json | 43 + .../v1/src/v1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1/system-test/install.ts | 49 + .../v1/test/gapic_fleet_routing_v1.ts | 703 ++ .../v1/tsconfig.json | 19 + .../v1/webpack.config.js | 64 + .../v1/.eslintignore | 7 + .../v1/.eslintrc.json | 3 + .../v1/.gitignore | 14 + .../v1/.jsdoc.js | 55 + .../v1/.mocharc.js | 33 + .../v1/.prettierrc.js | 22 + .../v1/README.md | 1 + .../v1/package.json | 59 + .../airflow/service/v1/environments.proto | 1392 ++++ .../airflow/service/v1/image_versions.proto | 90 + .../airflow/service/v1/operations.proto | 97 + .../v1/environments.create_environment.js | 66 + .../v1/environments.database_failover.js | 62 + .../v1/environments.delete_environment.js | 62 + .../environments.execute_airflow_command.js | 76 + .../environments.fetch_database_properties.js | 62 + .../v1/environments.get_environment.js | 61 + .../v1/environments.list_environments.js | 71 + .../v1/environments.load_snapshot.js | 87 + .../v1/environments.poll_airflow_command.js | 77 + .../v1/environments.save_snapshot.js | 67 + .../v1/environments.stop_airflow_command.js | 78 + .../v1/environments.update_environment.js | 184 + .../v1/image_versions.list_image_versions.js | 75 + ...loud.orchestration.airflow.service.v1.json | 635 ++ .../v1/src/index.ts | 27 + .../v1/src/v1/environments_client.ts | 1867 +++++ .../v1/src/v1/environments_client_config.json | 74 + .../v1/src/v1/environments_proto_list.json | 5 + .../v1/src/v1/gapic_metadata.json | 175 + .../v1/src/v1/image_versions_client.ts | 556 ++ .../src/v1/image_versions_client_config.json | 30 + .../v1/src/v1/image_versions_proto_list.json | 5 + .../v1/src/v1/index.ts | 20 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + .../v1/system-test/install.ts | 49 + .../v1/test/gapic_environments_v1.ts | 2226 ++++++ .../v1/test/gapic_image_versions_v1.ts | 491 ++ .../v1/tsconfig.json | 19 + .../v1/webpack.config.js | 64 + .../v1beta1/.eslintignore | 7 + .../v1beta1/.eslintrc.json | 3 + .../v1beta1/.gitignore | 14 + .../v1beta1/.jsdoc.js | 55 + .../v1beta1/.mocharc.js | 33 + .../v1beta1/.prettierrc.js | 22 + .../v1beta1/README.md | 1 + .../v1beta1/package.json | 59 + .../service/v1beta1/environments.proto | 1530 ++++ .../service/v1beta1/image_versions.proto | 90 + .../airflow/service/v1beta1/operations.proto | 93 + .../v1beta1/environments.check_upgrade.js | 86 + .../environments.create_environment.js | 66 + .../v1beta1/environments.database_failover.js | 62 + .../environments.delete_environment.js | 62 + .../environments.execute_airflow_command.js | 76 + .../environments.fetch_database_properties.js | 62 + .../v1beta1/environments.get_environment.js | 61 + .../v1beta1/environments.list_environments.js | 71 + .../v1beta1/environments.load_snapshot.js | 87 + .../environments.poll_airflow_command.js | 77 + .../environments.restart_web_server.js | 63 + .../v1beta1/environments.save_snapshot.js | 67 + .../environments.stop_airflow_command.js | 78 + .../environments.update_environment.js | 206 + .../image_versions.list_image_versions.js | 75 + ...orchestration.airflow.service.v1beta1.json | 719 ++ .../v1beta1/src/index.ts | 27 + .../src/v1beta1/environments_client.ts | 2113 ++++++ .../v1beta1/environments_client_config.json | 82 + .../src/v1beta1/environments_proto_list.json | 5 + .../v1beta1/src/v1beta1/gapic_metadata.json | 195 + .../src/v1beta1/image_versions_client.ts | 556 ++ .../v1beta1/image_versions_client_config.json | 30 + .../v1beta1/image_versions_proto_list.json | 5 + .../v1beta1/src/v1beta1/index.ts | 20 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + .../v1beta1/system-test/install.ts | 49 + .../test/gapic_environments_v1beta1.ts | 2534 +++++++ .../test/gapic_image_versions_v1beta1.ts | 491 ++ .../v1beta1/tsconfig.json | 19 + .../v1beta1/webpack.config.js | 64 + .../google-cloud-orgpolicy/v2/.eslintignore | 7 + .../google-cloud-orgpolicy/v2/.eslintrc.json | 3 + .../google-cloud-orgpolicy/v2/.gitignore | 14 + .../google-cloud-orgpolicy/v2/.jsdoc.js | 55 + .../google-cloud-orgpolicy/v2/.mocharc.js | 33 + .../google-cloud-orgpolicy/v2/.prettierrc.js | 22 + .../google-cloud-orgpolicy/v2/README.md | 1 + .../google-cloud-orgpolicy/v2/package.json | 58 + .../cloud/orgpolicy/v2/constraint.proto | 126 + .../google/cloud/orgpolicy/v2/orgpolicy.proto | 478 ++ .../generated/v2/org_policy.create_policy.js | 71 + .../generated/v2/org_policy.delete_policy.js | 62 + .../v2/org_policy.get_effective_policy.js | 61 + .../generated/v2/org_policy.get_policy.js | 62 + .../v2/org_policy.list_constraints.js | 79 + .../generated/v2/org_policy.list_policies.js | 80 + .../generated/v2/org_policy.update_policy.js | 67 + ...et_metadata_google.cloud.orgpolicy.v2.json | 319 + .../google-cloud-orgpolicy/v2/src/index.ts | 25 + .../v2/src/v2/gapic_metadata.json | 101 + .../google-cloud-orgpolicy/v2/src/v2/index.ts | 19 + .../v2/src/v2/org_policy_client.ts | 1385 ++++ .../v2/src/v2/org_policy_client_config.json | 70 + .../v2/src/v2/org_policy_proto_list.json | 4 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v2/system-test/install.ts | 49 + .../v2/test/gapic_org_policy_v2.ts | 1492 ++++ .../google-cloud-orgpolicy/v2/tsconfig.json | 19 + .../v2/webpack.config.js | 64 + .../google-cloud-osconfig/v1/.eslintignore | 7 + .../google-cloud-osconfig/v1/.eslintrc.json | 3 + .../google-cloud-osconfig/v1/.gitignore | 14 + .../google-cloud-osconfig/v1/.jsdoc.js | 55 + .../google-cloud-osconfig/v1/.mocharc.js | 33 + .../google-cloud-osconfig/v1/.prettierrc.js | 22 + .../google-cloud-osconfig/v1/README.md | 1 + .../google-cloud-osconfig/v1/package.json | 59 + .../google/cloud/osconfig/v1/inventory.proto | 384 + .../google/cloud/osconfig/v1/os_policy.proto | 548 ++ .../v1/os_policy_assignment_reports.proto | 296 + .../osconfig/v1/os_policy_assignments.proto | 386 + .../cloud/osconfig/v1/osconfig_common.proto | 38 + .../cloud/osconfig/v1/osconfig_service.proto | 158 + .../osconfig/v1/osconfig_zonal_service.proto | 202 + .../cloud/osconfig/v1/patch_deployments.proto | 339 + .../google/cloud/osconfig/v1/patch_jobs.proto | 742 ++ .../cloud/osconfig/v1/vulnerability.proto | 365 + .../v1/os_config_service.cancel_patch_job.js | 61 + ..._config_service.create_patch_deployment.js | 78 + ..._config_service.delete_patch_deployment.js | 62 + .../v1/os_config_service.execute_patch_job.js | 95 + .../os_config_service.get_patch_deployment.js | 62 + .../v1/os_config_service.get_patch_job.js | 61 + ...s_config_service.list_patch_deployments.js | 74 + ...service.list_patch_job_instance_details.js | 79 + .../v1/os_config_service.list_patch_jobs.js | 78 + ...s_config_service.pause_patch_deployment.js | 62 + ..._config_service.resume_patch_deployment.js | 62 + ..._config_service.update_patch_deployment.js | 66 + ...al_service.create_o_s_policy_assignment.js | 79 + ...al_service.delete_o_s_policy_assignment.js | 62 + .../os_config_zonal_service.get_inventory.js | 71 + ...zonal_service.get_o_s_policy_assignment.js | 63 + ...ervice.get_o_s_policy_assignment_report.js | 67 + ..._zonal_service.get_vulnerability_report.js | 66 + ...s_config_zonal_service.list_inventories.js | 85 + ...vice.list_o_s_policy_assignment_reports.js | 95 + ...ce.list_o_s_policy_assignment_revisions.js | 73 + ...nal_service.list_o_s_policy_assignments.js | 73 + ...onal_service.list_vulnerability_reports.js | 80 + ...al_service.update_o_s_policy_assignment.js | 67 + ...pet_metadata_google.cloud.osconfig.v1.json | 1119 +++ .../google-cloud-osconfig/v1/src/index.ts | 27 + .../v1/src/v1/gapic_metadata.json | 309 + .../google-cloud-osconfig/v1/src/v1/index.ts | 20 + .../v1/src/v1/os_config_service_client.ts | 1854 +++++ .../v1/os_config_service_client_config.json | 98 + .../src/v1/os_config_service_proto_list.json | 12 + .../src/v1/os_config_zonal_service_client.ts | 2306 ++++++ ...os_config_zonal_service_client_config.json | 98 + .../os_config_zonal_service_proto_list.json | 12 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + .../v1/system-test/install.ts | 49 + .../v1/test/gapic_os_config_service_v1.ts | 2179 ++++++ .../test/gapic_os_config_zonal_service_v1.ts | 2607 +++++++ .../google-cloud-osconfig/v1/tsconfig.json | 19 + .../v1/webpack.config.js | 64 + .../v1alpha/.eslintignore | 7 + .../v1alpha/.eslintrc.json | 3 + .../google-cloud-osconfig/v1alpha/.gitignore | 14 + .../google-cloud-osconfig/v1alpha/.jsdoc.js | 55 + .../google-cloud-osconfig/v1alpha/.mocharc.js | 33 + .../v1alpha/.prettierrc.js | 22 + .../google-cloud-osconfig/v1alpha/README.md | 1 + .../v1alpha/package.json | 58 + .../osconfig/v1alpha/config_common.proto | 133 + .../instance_os_policies_compliance.proto | 182 + .../cloud/osconfig/v1alpha/inventory.proto | 383 + .../cloud/osconfig/v1alpha/os_policy.proto | 565 ++ .../os_policy_assignment_reports.proto | 296 + .../v1alpha/os_policy_assignments.proto | 383 + .../osconfig/v1alpha/osconfig_common.proto | 40 + .../v1alpha/osconfig_zonal_service.proto | 215 + .../osconfig/v1alpha/vulnerability.proto | 365 + ...al_service.create_o_s_policy_assignment.js | 79 + ...al_service.delete_o_s_policy_assignment.js | 62 + ...ce.get_instance_o_s_policies_compliance.js | 67 + .../os_config_zonal_service.get_inventory.js | 71 + ...zonal_service.get_o_s_policy_assignment.js | 63 + ...ervice.get_o_s_policy_assignment_report.js | 67 + ..._zonal_service.get_vulnerability_report.js | 66 + ....list_instance_o_s_policies_compliances.js | 81 + ...s_config_zonal_service.list_inventories.js | 85 + ...vice.list_o_s_policy_assignment_reports.js | 95 + ...ce.list_o_s_policy_assignment_revisions.js | 73 + ...nal_service.list_o_s_policy_assignments.js | 73 + ...onal_service.list_vulnerability_reports.js | 80 + ...al_service.update_o_s_policy_assignment.js | 66 + ...etadata_google.cloud.osconfig.v1alpha.json | 659 ++ .../v1alpha/src/index.ts | 25 + .../v1alpha/src/v1alpha/gapic_metadata.json | 187 + .../v1alpha/src/v1alpha/index.ts | 19 + .../v1alpha/os_config_zonal_service_client.ts | 2569 +++++++ ...os_config_zonal_service_client_config.json | 108 + .../os_config_zonal_service_proto_list.json | 11 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1alpha/system-test/install.ts | 49 + .../gapic_os_config_zonal_service_v1alpha.ts | 2952 ++++++++ .../v1alpha/tsconfig.json | 19 + .../v1alpha/webpack.config.js | 64 + .../v1beta/.eslintignore | 7 + .../v1beta/.eslintrc.json | 3 + .../google-cloud-osconfig/v1beta/.gitignore | 14 + .../google-cloud-osconfig/v1beta/.jsdoc.js | 55 + .../google-cloud-osconfig/v1beta/.mocharc.js | 33 + .../v1beta/.prettierrc.js | 22 + .../google-cloud-osconfig/v1beta/README.md | 1 + .../google-cloud-osconfig/v1beta/package.json | 58 + .../osconfig/v1beta/guest_policies.proto | 772 ++ .../osconfig/v1beta/osconfig_common.proto | 36 + .../osconfig/v1beta/osconfig_service.proto | 186 + .../osconfig/v1beta/patch_deployments.proto | 295 + .../cloud/osconfig/v1beta/patch_jobs.proto | 702 ++ .../os_config_service.cancel_patch_job.js | 61 + .../os_config_service.create_guest_policy.js | 78 + ..._config_service.create_patch_deployment.js | 77 + .../os_config_service.delete_guest_policy.js | 62 + ..._config_service.delete_patch_deployment.js | 62 + .../os_config_service.execute_patch_job.js | 95 + .../os_config_service.get_guest_policy.js | 62 + .../os_config_service.get_patch_deployment.js | 62 + .../v1beta/os_config_service.get_patch_job.js | 61 + .../os_config_service.list_guest_policies.js | 73 + ...s_config_service.list_patch_deployments.js | 72 + ...service.list_patch_job_instance_details.js | 78 + .../os_config_service.list_patch_jobs.js | 78 + ...g_service.lookup_effective_guest_policy.js | 79 + ...s_config_service.pause_patch_deployment.js | 62 + ..._config_service.resume_patch_deployment.js | 62 + .../os_config_service.update_guest_policy.js | 66 + ..._config_service.update_patch_deployment.js | 66 + ...metadata_google.cloud.osconfig.v1beta.json | 839 +++ .../google-cloud-osconfig/v1beta/src/index.ts | 25 + .../v1beta/src/v1beta/gapic_metadata.json | 219 + .../v1beta/src/v1beta/index.ts | 19 + .../src/v1beta/os_config_service_client.ts | 2220 ++++++ .../os_config_service_client_config.json | 128 + .../v1beta/os_config_service_proto_list.json | 7 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1beta/system-test/install.ts | 49 + .../test/gapic_os_config_service_v1beta.ts | 2814 ++++++++ .../v1beta/tsconfig.json | 19 + .../v1beta/webpack.config.js | 64 + .../google-cloud-oslogin/v1/.eslintignore | 7 + .../google-cloud-oslogin/v1/.eslintrc.json | 3 + .../google-cloud-oslogin/v1/.gitignore | 14 + .../google-cloud-oslogin/v1/.jsdoc.js | 55 + .../google-cloud-oslogin/v1/.mocharc.js | 33 + .../google-cloud-oslogin/v1/.prettierrc.js | 22 + .../google-cloud-oslogin/v1/README.md | 1 + .../google-cloud-oslogin/v1/package.json | 58 + .../google/cloud/oslogin/common/common.proto | 108 + .../google/cloud/oslogin/v1/oslogin.proto | 248 + .../os_login_service.create_ssh_public_key.js | 66 + .../os_login_service.delete_posix_account.js | 63 + .../os_login_service.delete_ssh_public_key.js | 63 + .../v1/os_login_service.get_login_profile.js | 69 + .../v1/os_login_service.get_ssh_public_key.js | 63 + .../os_login_service.import_ssh_public_key.js | 69 + .../os_login_service.update_ssh_public_key.js | 72 + ...ppet_metadata_google.cloud.oslogin.v1.json | 323 + .../google-cloud-oslogin/v1/src/index.ts | 25 + .../v1/src/v1/gapic_metadata.json | 93 + .../google-cloud-oslogin/v1/src/v1/index.ts | 19 + .../v1/src/v1/os_login_service_client.ts | 942 +++ .../v1/os_login_service_client_config.json | 60 + .../src/v1/os_login_service_proto_list.json | 4 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1/system-test/install.ts | 49 + .../v1/test/gapic_os_login_service_v1.ts | 1015 +++ .../google-cloud-oslogin/v1/tsconfig.json | 19 + .../google-cloud-oslogin/v1/webpack.config.js | 64 + .../google-cloud-oslogin/v1beta/.eslintignore | 7 + .../v1beta/.eslintrc.json | 3 + .../google-cloud-oslogin/v1beta/.gitignore | 14 + .../google-cloud-oslogin/v1beta/.jsdoc.js | 55 + .../google-cloud-oslogin/v1beta/.mocharc.js | 33 + .../v1beta/.prettierrc.js | 22 + .../google-cloud-oslogin/v1beta/README.md | 1 + .../google-cloud-oslogin/v1beta/package.json | 58 + .../google/cloud/oslogin/common/common.proto | 108 + .../google/cloud/oslogin/v1beta/oslogin.proto | 321 + .../os_login_service.create_ssh_public_key.js | 66 + .../os_login_service.delete_posix_account.js | 63 + .../os_login_service.delete_ssh_public_key.js | 63 + .../os_login_service.get_login_profile.js | 73 + .../os_login_service.get_ssh_public_key.js | 63 + .../os_login_service.import_ssh_public_key.js | 73 + .../os_login_service.sign_ssh_public_key.js | 67 + .../os_login_service.update_ssh_public_key.js | 72 + ..._metadata_google.cloud.oslogin.v1beta.json | 375 + .../google-cloud-oslogin/v1beta/src/index.ts | 25 + .../v1beta/src/v1beta/gapic_metadata.json | 103 + .../v1beta/src/v1beta/index.ts | 19 + .../src/v1beta/os_login_service_client.ts | 1021 +++ .../os_login_service_client_config.json | 64 + .../v1beta/os_login_service_proto_list.json | 4 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1beta/system-test/install.ts | 49 + .../test/gapic_os_login_service_v1beta.ts | 1123 +++ .../google-cloud-oslogin/v1beta/tsconfig.json | 19 + .../v1beta/webpack.config.js | 64 + .../v1beta1/.eslintignore | 7 + .../v1beta1/.eslintrc.json | 3 + .../v1beta1/.gitignore | 14 + .../v1beta1/.jsdoc.js | 55 + .../v1beta1/.mocharc.js | 33 + .../v1beta1/.prettierrc.js | 22 + .../v1beta1/README.md | 1 + .../v1beta1/package.json | 58 + .../v1beta1/phishingprotection.proto | 73 + ...ection_service_v1_beta1.report_phishing.js | 67 + ...ogle.cloud.phishingprotection.v1beta1.json | 59 + .../v1beta1/src/index.ts | 25 + .../v1beta1/src/v1beta1/gapic_metadata.json | 33 + .../v1beta1/src/v1beta1/index.ts | 19 + ...hing_protection_service_v1_beta1_client.ts | 421 ++ ...ection_service_v1_beta1_client_config.json | 31 + ...rotection_service_v1_beta1_proto_list.json | 3 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1beta1/system-test/install.ts | 49 + ...ing_protection_service_v1_beta1_v1beta1.ts | 291 + .../v1beta1/tsconfig.json | 19 + .../v1beta1/webpack.config.js | 64 + .../v3/.eslintignore | 7 + .../v3/.eslintrc.json | 3 + .../v3/.gitignore | 14 + .../v3/.jsdoc.js | 55 + .../v3/.mocharc.js | 33 + .../v3/.prettierrc.js | 22 + .../v3/README.md | 1 + .../v3/package.json | 59 + .../iam/v3/troubleshooter.proto | 757 ++ ..._troubleshooter.troubleshoot_iam_policy.js | 61 + ...gle.cloud.policytroubleshooter.iam.v3.json | 55 + .../v3/src/index.ts | 25 + .../v3/src/v3/gapic_metadata.json | 33 + .../v3/src/v3/index.ts | 19 + .../v3/src/v3/policy_troubleshooter_client.ts | 376 + .../policy_troubleshooter_client_config.json | 43 + .../v3/policy_troubleshooter_proto_list.json | 4 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v3/system-test/install.ts | 49 + .../v3/test/gapic_policy_troubleshooter_v3.ts | 225 + .../v3/tsconfig.json | 19 + .../v3/webpack.config.js | 64 + .../v3beta/.eslintignore | 7 + .../v3beta/.eslintrc.json | 3 + .../v3beta/.gitignore | 14 + .../v3beta/.jsdoc.js | 55 + .../v3beta/.mocharc.js | 33 + .../v3beta/.prettierrc.js | 22 + .../v3beta/README.md | 1 + .../v3beta/package.json | 59 + .../iam/v3beta/troubleshooter.proto | 754 ++ .../v3beta/protos/google/iam/v1/policy.proto | 410 ++ .../v3beta/protos/google/iam/v2/deny.proto | 109 + .../v3beta/protos/google/iam/v2/policy.proto | 287 + .../v3beta/protos/google/rpc/status.proto | 49 + .../v3beta/protos/google/type/expr.proto | 73 + ..._troubleshooter.troubleshoot_iam_policy.js | 61 + ...cloud.policytroubleshooter.iam.v3beta.json | 55 + .../v3beta/src/index.ts | 25 + .../v3beta/src/v3beta/gapic_metadata.json | 33 + .../v3beta/src/v3beta/index.ts | 19 + .../v3beta/policy_troubleshooter_client.ts | 376 + .../policy_troubleshooter_client_config.json | 43 + .../policy_troubleshooter_proto_list.json | 4 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v3beta/system-test/install.ts | 49 + .../gapic_policy_troubleshooter_v3beta.ts | 225 + .../v3beta/tsconfig.json | 19 + .../v3beta/webpack.config.js | 64 + .../v1/.eslintignore | 7 + .../v1/.eslintrc.json | 3 + .../v1/.gitignore | 14 + .../v1/.jsdoc.js | 55 + .../v1/.mocharc.js | 33 + .../v1/.prettierrc.js | 22 + .../v1/README.md | 1 + .../v1/package.json | 58 + .../policytroubleshooter/v1/checker.proto | 83 + .../v1/explanations.proto | 247 + .../v1/iam_checker.troubleshoot_iam_policy.js | 61 + ..._google.cloud.policytroubleshooter.v1.json | 55 + .../v1/src/index.ts | 25 + .../v1/src/v1/gapic_metadata.json | 33 + .../v1/src/v1/iam_checker_client.ts | 376 + .../v1/src/v1/iam_checker_client_config.json | 31 + .../v1/src/v1/iam_checker_proto_list.json | 4 + .../v1/src/v1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1/system-test/install.ts | 49 + .../v1/test/gapic_iam_checker_v1.ts | 225 + .../v1/tsconfig.json | 19 + .../v1/webpack.config.js | 64 + .../v1beta1/.eslintignore | 7 + .../v1beta1/.eslintrc.json | 3 + .../v1beta1/.gitignore | 14 + .../v1beta1/.jsdoc.js | 55 + .../v1beta1/.mocharc.js | 33 + .../v1beta1/.prettierrc.js | 22 + .../v1beta1/README.md | 1 + .../v1beta1/package.json | 58 + .../v1beta1/private_catalog.proto | 556 ++ .../private_catalog.search_catalogs.js | 80 + .../private_catalog.search_products.js | 82 + .../private_catalog.search_versions.js | 83 + ...a_google.cloud.privatecatalog.v1beta1.json | 171 + .../v1beta1/src/index.ts | 25 + .../v1beta1/src/v1beta1/gapic_metadata.json | 65 + .../v1beta1/src/v1beta1/index.ts | 19 + .../src/v1beta1/private_catalog_client.ts | 1053 +++ .../private_catalog_client_config.json | 38 + .../v1beta1/private_catalog_proto_list.json | 3 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1beta1/system-test/install.ts | 49 + .../test/gapic_private_catalog_v1beta1.ts | 1041 +++ .../v1beta1/tsconfig.json | 19 + .../v1beta1/webpack.config.js | 64 + .../v1/.eslintignore | 7 + .../v1/.eslintrc.json | 3 + .../v1/.gitignore | 14 + .../v1/.jsdoc.js | 55 + .../v1/.mocharc.js | 33 + .../v1/.prettierrc.js | 22 + .../v1/README.md | 1 + .../v1/package.json | 58 + .../v1/api_entities.proto | 171 + .../v1/rapidmigrationassessment.proto | 421 ++ ..._migration_assessment.create_annotation.js | 71 + ...d_migration_assessment.create_collector.js | 76 + ...d_migration_assessment.delete_collector.js | 76 + ...pid_migration_assessment.get_annotation.js | 61 + ...apid_migration_assessment.get_collector.js | 61 + ...id_migration_assessment.list_collectors.js | 80 + ...id_migration_assessment.pause_collector.js | 76 + ...migration_assessment.register_collector.js | 76 + ...d_migration_assessment.resume_collector.js | 76 + ...d_migration_assessment.update_collector.js | 85 + ...gle.cloud.rapidmigrationassessment.v1.json | 475 ++ .../v1/src/index.ts | 25 + .../v1/src/v1/gapic_metadata.json | 127 + .../v1/src/v1/index.ts | 19 + .../v1/rapid_migration_assessment_client.ts | 1839 +++++ ...id_migration_assessment_client_config.json | 85 + ...rapid_migration_assessment_proto_list.json | 4 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1/system-test/install.ts | 49 + .../gapic_rapid_migration_assessment_v1.ts | 2310 ++++++ .../v1/tsconfig.json | 19 + .../v1/webpack.config.js | 64 + .../v1/.eslintignore | 7 + .../v1/.eslintrc.json | 3 + .../v1/.gitignore | 14 + .../v1/.jsdoc.js | 55 + .../v1/.mocharc.js | 33 + .../v1/.prettierrc.js | 22 + .../v1/README.md | 1 + .../v1/package.json | 58 + .../v1/recaptchaenterprise.proto | 1427 ++++ ..._enterprise_service.annotate_assessment.js | 86 + ...ha_enterprise_service.create_assessment.js | 67 + ...recaptcha_enterprise_service.create_key.js | 67 + ...recaptcha_enterprise_service.delete_key.js | 62 + .../recaptcha_enterprise_service.get_key.js | 62 + ...ecaptcha_enterprise_service.get_metrics.js | 62 + .../recaptcha_enterprise_service.list_keys.js | 74 + ....list_related_account_group_memberships.js | 78 + ...ise_service.list_related_account_groups.js | 78 + ...ecaptcha_enterprise_service.migrate_key.js | 73 + ...rise_service.retrieve_legacy_secret_key.js | 62 + ...earch_related_account_group_memberships.js | 86 + ...recaptcha_enterprise_service.update_key.js | 66 + ...a_google.cloud.recaptchaenterprise.v1.json | 603 ++ .../v1/src/index.ts | 25 + .../v1/src/v1/gapic_metadata.json | 169 + .../v1/src/v1/index.ts | 19 + .../v1/recaptcha_enterprise_service_client.ts | 2023 ++++++ ...tcha_enterprise_service_client_config.json | 85 + ...captcha_enterprise_service_proto_list.json | 3 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1/system-test/install.ts | 49 + .../gapic_recaptcha_enterprise_service_v1.ts | 2384 ++++++ .../v1/tsconfig.json | 19 + .../v1/webpack.config.js | 64 + .../v1beta1/.eslintignore | 7 + .../v1beta1/.eslintrc.json | 3 + .../v1beta1/.gitignore | 14 + .../v1beta1/.jsdoc.js | 55 + .../v1beta1/.mocharc.js | 33 + .../v1beta1/.prettierrc.js | 22 + .../v1beta1/README.md | 1 + .../v1beta1/package.json | 58 + .../v1beta1/recaptchaenterprise.proto | 682 ++ ...se_service_v1_beta1.annotate_assessment.js | 86 + ...rise_service_v1_beta1.create_assessment.js | 67 + ...gle.cloud.recaptchaenterprise.v1beta1.json | 115 + .../v1beta1/src/index.ts | 25 + .../v1beta1/src/v1beta1/gapic_metadata.json | 43 + .../v1beta1/src/v1beta1/index.ts | 19 + ...tcha_enterprise_service_v1_beta1_client.ts | 542 ++ ...rprise_service_v1_beta1_client_config.json | 36 + ...nterprise_service_v1_beta1_proto_list.json | 3 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1beta1/system-test/install.ts | 49 + ...cha_enterprise_service_v1_beta1_v1beta1.ts | 437 ++ .../v1beta1/tsconfig.json | 19 + .../v1beta1/webpack.config.js | 64 + .../google-cloud-recommender/v1/.eslintignore | 7 + .../v1/.eslintrc.json | 3 + .../google-cloud-recommender/v1/.gitignore | 14 + .../google-cloud-recommender/v1/.jsdoc.js | 55 + .../google-cloud-recommender/v1/.mocharc.js | 33 + .../v1/.prettierrc.js | 22 + .../google-cloud-recommender/v1/README.md | 1 + .../google-cloud-recommender/v1/package.json | 58 + .../google/cloud/recommender/v1/insight.proto | 162 + .../recommender/v1/insight_type_config.proto | 85 + .../cloud/recommender/v1/recommendation.proto | 343 + .../recommender/v1/recommender_config.proto | 85 + .../recommender/v1/recommender_service.proto | 604 ++ .../generated/v1/recommender.get_insight.js | 61 + .../v1/recommender.get_insight_type_config.js | 65 + .../v1/recommender.get_recommendation.js | 61 + .../v1/recommender.get_recommender_config.js | 65 + .../generated/v1/recommender.list_insights.js | 101 + .../v1/recommender.list_recommendations.js | 101 + .../v1/recommender.mark_insight_accepted.js | 71 + ...recommender.mark_recommendation_claimed.js | 73 + .../recommender.mark_recommendation_failed.js | 73 + ...commender.mark_recommendation_succeeded.js | 73 + .../recommender.update_insight_type_config.js | 70 + .../recommender.update_recommender_config.js | 70 + ..._metadata_google.cloud.recommender.v1.json | 567 ++ .../google-cloud-recommender/v1/src/index.ts | 25 + .../v1/src/v1/gapic_metadata.json | 151 + .../v1/src/v1/index.ts | 19 + .../v1/src/v1/recommender_client.ts | 2866 ++++++++ .../v1/src/v1/recommender_client_config.json | 82 + .../v1/src/v1/recommender_proto_list.json | 7 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1/system-test/install.ts | 49 + .../v1/test/gapic_recommender_v1.ts | 2762 +++++++ .../google-cloud-recommender/v1/tsconfig.json | 19 + .../v1/webpack.config.js | 64 + .../v1beta1/.eslintignore | 7 + .../v1beta1/.eslintrc.json | 3 + .../v1beta1/.gitignore | 14 + .../v1beta1/.jsdoc.js | 55 + .../v1beta1/.mocharc.js | 33 + .../v1beta1/.prettierrc.js | 22 + .../v1beta1/README.md | 1 + .../v1beta1/package.json | 58 + .../cloud/recommender/v1beta1/insight.proto | 161 + .../v1beta1/insight_type_config.proto | 85 + .../recommender/v1beta1/recommendation.proto | 361 + .../v1beta1/recommender_config.proto | 85 + .../v1beta1/recommender_service.proto | 591 ++ .../v1beta1/recommender.get_insight.js | 61 + .../recommender.get_insight_type_config.js | 65 + .../v1beta1/recommender.get_recommendation.js | 61 + .../recommender.get_recommender_config.js | 65 + .../v1beta1/recommender.list_insights.js | 101 + .../recommender.list_recommendations.js | 101 + .../recommender.mark_insight_accepted.js | 71 + ...recommender.mark_recommendation_claimed.js | 73 + .../recommender.mark_recommendation_failed.js | 73 + ...commender.mark_recommendation_succeeded.js | 73 + .../recommender.update_insight_type_config.js | 70 + .../recommender.update_recommender_config.js | 70 + ...data_google.cloud.recommender.v1beta1.json | 567 ++ .../v1beta1/src/index.ts | 25 + .../v1beta1/src/v1beta1/gapic_metadata.json | 151 + .../v1beta1/src/v1beta1/index.ts | 19 + .../v1beta1/src/v1beta1/recommender_client.ts | 2866 ++++++++ .../v1beta1/recommender_client_config.json | 82 + .../src/v1beta1/recommender_proto_list.json | 7 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1beta1/system-test/install.ts | 49 + .../v1beta1/test/gapic_recommender_v1beta1.ts | 2762 +++++++ .../v1beta1/tsconfig.json | 19 + .../v1beta1/webpack.config.js | 64 + .../google-cloud-redis/v1/.eslintignore | 7 + .../google-cloud-redis/v1/.eslintrc.json | 3 + .../google-cloud-redis/v1/.gitignore | 14 + .../google-cloud-redis/v1/.jsdoc.js | 55 + .../google-cloud-redis/v1/.mocharc.js | 33 + .../google-cloud-redis/v1/.prettierrc.js | 22 + .../google-cloud-redis/v1/README.md | 1 + .../google-cloud-redis/v1/package.json | 58 + .../google/cloud/redis/v1/cloud_redis.proto | 1000 +++ .../v1/cloud_redis.create_instance.js | 80 + .../v1/cloud_redis.delete_instance.js | 64 + .../v1/cloud_redis.export_instance.js | 69 + .../v1/cloud_redis.failover_instance.js | 69 + .../generated/v1/cloud_redis.get_instance.js | 63 + .../cloud_redis.get_instance_auth_string.js | 63 + .../v1/cloud_redis.import_instance.js | 69 + .../v1/cloud_redis.list_instances.js | 80 + .../v1/cloud_redis.reschedule_maintenance.js | 76 + .../v1/cloud_redis.update_instance.js | 75 + .../v1/cloud_redis.upgrade_instance.js | 69 + ...nippet_metadata_google.cloud.redis.v1.json | 499 ++ .../google-cloud-redis/v1/src/index.ts | 25 + .../v1/src/v1/cloud_redis_client.ts | 1923 +++++ .../v1/src/v1/cloud_redis_client_config.json | 81 + .../v1/src/v1/cloud_redis_proto_list.json | 3 + .../v1/src/v1/gapic_metadata.json | 137 + .../google-cloud-redis/v1/src/v1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1/system-test/install.ts | 49 + .../v1/test/gapic_cloud_redis_v1.ts | 2418 +++++++ .../google-cloud-redis/v1/tsconfig.json | 19 + .../google-cloud-redis/v1/webpack.config.js | 64 + .../google-cloud-redis/v1beta1/.eslintignore | 7 + .../google-cloud-redis/v1beta1/.eslintrc.json | 3 + .../google-cloud-redis/v1beta1/.gitignore | 14 + .../google-cloud-redis/v1beta1/.jsdoc.js | 55 + .../google-cloud-redis/v1beta1/.mocharc.js | 33 + .../google-cloud-redis/v1beta1/.prettierrc.js | 22 + .../google-cloud-redis/v1beta1/README.md | 1 + .../google-cloud-redis/v1beta1/package.json | 58 + .../cloud/redis/v1beta1/cloud_redis.proto | 913 +++ .../v1beta1/cloud_redis.create_instance.js | 80 + .../v1beta1/cloud_redis.delete_instance.js | 64 + .../v1beta1/cloud_redis.export_instance.js | 69 + .../v1beta1/cloud_redis.failover_instance.js | 69 + .../v1beta1/cloud_redis.get_instance.js | 63 + .../cloud_redis.get_instance_auth_string.js | 63 + .../v1beta1/cloud_redis.import_instance.js | 69 + .../v1beta1/cloud_redis.list_instances.js | 79 + .../cloud_redis.reschedule_maintenance.js | 75 + .../v1beta1/cloud_redis.update_instance.js | 75 + .../v1beta1/cloud_redis.upgrade_instance.js | 69 + ...t_metadata_google.cloud.redis.v1beta1.json | 499 ++ .../google-cloud-redis/v1beta1/src/index.ts | 25 + .../v1beta1/src/v1beta1/cloud_redis_client.ts | 1659 +++++ .../v1beta1/cloud_redis_client_config.json | 80 + .../src/v1beta1/cloud_redis_proto_list.json | 3 + .../v1beta1/src/v1beta1/gapic_metadata.json | 137 + .../v1beta1/src/v1beta1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1beta1/system-test/install.ts | 49 + .../v1beta1/test/gapic_cloud_redis_v1beta1.ts | 1997 +++++ .../google-cloud-redis/v1beta1/tsconfig.json | 19 + .../v1beta1/webpack.config.js | 64 + .../v3/.eslintignore | 7 + .../v3/.eslintrc.json | 3 + .../v3/.gitignore | 14 + .../google-cloud-resourcemanager/v3/.jsdoc.js | 55 + .../v3/.mocharc.js | 33 + .../v3/.prettierrc.js | 22 + .../google-cloud-resourcemanager/v3/README.md | 1 + .../v3/package.json | 64 + .../cloud/resourcemanager/v3/folders.proto | 546 ++ .../resourcemanager/v3/organizations.proto | 241 + .../cloud/resourcemanager/v3/projects.proto | 638 ++ .../resourcemanager/v3/tag_bindings.proto | 268 + .../cloud/resourcemanager/v3/tag_holds.proto | 216 + .../cloud/resourcemanager/v3/tag_keys.proto | 367 + .../cloud/resourcemanager/v3/tag_values.proto | 331 + .../generated/v3/folders.create_folder.js | 63 + .../generated/v3/folders.delete_folder.js | 63 + .../generated/v3/folders.get_folder.js | 62 + .../generated/v3/folders.get_iam_policy.js | 67 + .../generated/v3/folders.list_folders.js | 86 + .../generated/v3/folders.move_folder.js | 70 + .../generated/v3/folders.search_folders.js | 98 + .../generated/v3/folders.set_iam_policy.js | 77 + .../v3/folders.test_iam_permissions.js | 70 + .../generated/v3/folders.undelete_folder.js | 63 + .../generated/v3/folders.update_folder.js | 69 + .../v3/organizations.get_iam_policy.js | 67 + .../v3/organizations.get_organization.js | 63 + .../v3/organizations.search_organizations.js | 87 + .../v3/organizations.set_iam_policy.js | 77 + .../v3/organizations.test_iam_permissions.js | 70 + .../generated/v3/projects.create_project.js | 68 + .../generated/v3/projects.delete_project.js | 62 + .../generated/v3/projects.get_iam_policy.js | 67 + .../generated/v3/projects.get_project.js | 61 + .../generated/v3/projects.list_projects.js | 84 + .../generated/v3/projects.move_project.js | 67 + .../generated/v3/projects.search_projects.js | 100 + .../generated/v3/projects.set_iam_policy.js | 77 + .../v3/projects.test_iam_permissions.js | 70 + .../generated/v3/projects.undelete_project.js | 63 + .../generated/v3/projects.update_project.js | 66 + ...adata_google.cloud.resourcemanager.v3.json | 2339 ++++++ .../v3/tag_bindings.create_tag_binding.js | 67 + .../v3/tag_bindings.delete_tag_binding.js | 64 + .../v3/tag_bindings.list_effective_tags.js | 76 + .../v3/tag_bindings.list_tag_bindings.js | 76 + .../generated/v3/tag_holds.create_tag_hold.js | 73 + .../generated/v3/tag_holds.delete_tag_hold.js | 68 + .../generated/v3/tag_holds.list_tag_holds.js | 88 + .../generated/v3/tag_keys.create_tag_key.js | 68 + .../generated/v3/tag_keys.delete_tag_key.js | 74 + .../generated/v3/tag_keys.get_iam_policy.js | 67 + .../v3/tag_keys.get_namespaced_tag_key.js | 64 + .../generated/v3/tag_keys.get_tag_key.js | 62 + .../generated/v3/tag_keys.list_tag_keys.js | 76 + .../generated/v3/tag_keys.set_iam_policy.js | 77 + .../v3/tag_keys.test_iam_permissions.js | 70 + .../generated/v3/tag_keys.update_tag_key.js | 76 + .../v3/tag_values.create_tag_value.js | 68 + .../v3/tag_values.delete_tag_value.js | 73 + .../generated/v3/tag_values.get_iam_policy.js | 67 + .../v3/tag_values.get_namespaced_tag_value.js | 67 + .../generated/v3/tag_values.get_tag_value.js | 62 + .../v3/tag_values.list_tag_values.js | 74 + .../generated/v3/tag_values.set_iam_policy.js | 77 + .../v3/tag_values.test_iam_permissions.js | 70 + .../v3/tag_values.update_tag_value.js | 74 + .../v3/src/index.ts | 37 + .../v3/src/v3/folders_client.ts | 2074 ++++++ .../v3/src/v3/folders_client_config.json | 83 + .../v3/src/v3/folders_proto_list.json | 9 + .../v3/src/v3/gapic_metadata.json | 667 ++ .../v3/src/v3/index.ts | 25 + .../v3/src/v3/organizations_client.ts | 1063 +++ .../src/v3/organizations_client_config.json | 53 + .../v3/src/v3/organizations_proto_list.json | 9 + .../v3/src/v3/projects_client.ts | 2093 ++++++ .../v3/src/v3/projects_client_config.json | 83 + .../v3/src/v3/projects_proto_list.json | 9 + .../v3/src/v3/tag_bindings_client.ts | 1258 ++++ .../v3/src/v3/tag_bindings_client_config.json | 48 + .../v3/src/v3/tag_bindings_proto_list.json | 9 + .../v3/src/v3/tag_holds_client.ts | 1143 +++ .../v3/src/v3/tag_holds_client_config.json | 38 + .../v3/src/v3/tag_holds_proto_list.json | 9 + .../v3/src/v3/tag_keys_client.ts | 1585 ++++ .../v3/src/v3/tag_keys_client_config.json | 72 + .../v3/src/v3/tag_keys_proto_list.json | 9 + .../v3/src/v3/tag_values_client.ts | 1581 ++++ .../v3/src/v3/tag_values_client_config.json | 72 + .../v3/src/v3/tag_values_proto_list.json | 9 + .../system-test/fixtures/sample/src/index.js | 33 + .../system-test/fixtures/sample/src/index.ts | 68 + .../v3/system-test/install.ts | 49 + .../v3/test/gapic_folders_v3.ts | 2205 ++++++ .../v3/test/gapic_organizations_v3.ts | 1025 +++ .../v3/test/gapic_projects_v3.ts | 2205 ++++++ .../v3/test/gapic_tag_bindings_v3.ts | 1307 ++++ .../v3/test/gapic_tag_holds_v3.ts | 1242 ++++ .../v3/test/gapic_tag_keys_v3.ts | 1797 +++++ .../v3/test/gapic_tag_values_v3.ts | 1797 +++++ .../v3/tsconfig.json | 19 + .../v3/webpack.config.js | 64 + .../v1/.eslintignore | 7 + .../v1/.eslintrc.json | 3 + .../v1/.gitignore | 14 + .../v1/.jsdoc.js | 55 + .../v1/.mocharc.js | 33 + .../v1/.prettierrc.js | 22 + .../v1/README.md | 1 + .../v1/package.json | 58 + .../v1/resource_settings.proto | 308 + .../resource_settings_service.get_setting.js | 66 + ...resource_settings_service.list_settings.js | 80 + ...esource_settings_service.update_setting.js | 61 + ...data_google.cloud.resourcesettings.v1.json | 151 + .../v1/src/index.ts | 25 + .../v1/src/v1/gapic_metadata.json | 57 + .../v1/src/v1/index.ts | 19 + .../v1/resource_settings_service_client.ts | 808 +++ ...source_settings_service_client_config.json | 50 + .../resource_settings_service_proto_list.json | 3 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1/system-test/install.ts | 49 + .../gapic_resource_settings_service_v1.ts | 779 ++ .../v1/tsconfig.json | 19 + .../v1/webpack.config.js | 64 + .../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 + .../google-cloud-retail/v2/package.json | 66 + .../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 | 2207 ++++++ .../src/v2/catalog_service_client_config.json | 90 + .../v2/src/v2/catalog_service_proto_list.json | 21 + .../v2/src/v2/completion_service_client.ts | 1288 ++++ .../v2/completion_service_client_config.json | 45 + .../src/v2/completion_service_proto_list.json | 21 + .../v2/src/v2/control_service_client.ts | 1546 ++++ .../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 | 1796 +++++ .../src/v2/model_service_client_config.json | 66 + .../v2/src/v2/model_service_proto_list.json | 21 + .../v2/src/v2/prediction_service_client.ts | 1222 ++++ .../v2/prediction_service_client_config.json | 40 + .../src/v2/prediction_service_proto_list.json | 21 + .../v2/src/v2/product_service_client.ts | 2835 ++++++++ .../src/v2/product_service_client_config.json | 99 + .../v2/src/v2/product_service_proto_list.json | 21 + .../v2/src/v2/search_service_client.ts | 2037 ++++++ .../src/v2/search_service_client_config.json | 40 + .../v2/src/v2/search_service_proto_list.json | 21 + .../src/v2/serving_config_service_client.ts | 1681 +++++ .../serving_config_service_client_config.json | 54 + .../v2/serving_config_service_proto_list.json | 21 + .../v2/src/v2/user_event_service_client.ts | 1548 ++++ .../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 + .../google-cloud-retail/v2alpha/package.json | 67 + .../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 | 2352 ++++++ .../catalog_service_client_config.json | 95 + .../v2alpha/catalog_service_proto_list.json | 24 + .../src/v2alpha/completion_service_client.ts | 1357 ++++ .../completion_service_client_config.json | 45 + .../completion_service_proto_list.json | 24 + .../src/v2alpha/control_service_client.ts | 1611 +++++ .../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 | 1350 ++++ ...er_account_link_service_client_config.json | 38 + ...enter_account_link_service_proto_list.json | 24 + .../src/v2alpha/model_service_client.ts | 1862 +++++ .../v2alpha/model_service_client_config.json | 66 + .../src/v2alpha/model_service_proto_list.json | 24 + .../src/v2alpha/prediction_service_client.ts | 1287 ++++ .../prediction_service_client_config.json | 40 + .../prediction_service_proto_list.json | 24 + .../src/v2alpha/product_service_client.ts | 3109 ++++++++ .../product_service_client_config.json | 104 + .../v2alpha/product_service_proto_list.json | 24 + .../src/v2alpha/search_service_client.ts | 2159 ++++++ .../v2alpha/search_service_client_config.json | 40 + .../v2alpha/search_service_proto_list.json | 24 + .../v2alpha/serving_config_service_client.ts | 1747 +++++ .../serving_config_service_client_config.json | 54 + .../serving_config_service_proto_list.json | 24 + .../src/v2alpha/user_event_service_client.ts | 1614 +++++ .../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 + .../google-cloud-retail/v2beta/package.json | 66 + .../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 | 2287 ++++++ .../v2beta/catalog_service_client_config.json | 95 + .../v2beta/catalog_service_proto_list.json | 22 + .../src/v2beta/completion_service_client.ts | 1288 ++++ .../completion_service_client_config.json | 45 + .../v2beta/completion_service_proto_list.json | 22 + .../src/v2beta/control_service_client.ts | 1546 ++++ .../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 | 1797 +++++ .../v2beta/model_service_client_config.json | 58 + .../src/v2beta/model_service_proto_list.json | 22 + .../src/v2beta/prediction_service_client.ts | 1222 ++++ .../prediction_service_client_config.json | 40 + .../v2beta/prediction_service_proto_list.json | 22 + .../src/v2beta/product_service_client.ts | 2843 ++++++++ .../v2beta/product_service_client_config.json | 99 + .../v2beta/product_service_proto_list.json | 22 + .../src/v2beta/search_service_client.ts | 2037 ++++++ .../v2beta/search_service_client_config.json | 40 + .../src/v2beta/search_service_proto_list.json | 22 + .../v2beta/serving_config_service_client.ts | 1681 +++++ .../serving_config_service_client_config.json | 54 + .../serving_config_service_proto_list.json | 22 + .../src/v2beta/user_event_service_client.ts | 1549 ++++ .../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 + .../google-cloud-run/v2/.eslintignore | 7 + .../google-cloud-run/v2/.eslintrc.json | 3 + .../google-cloud-run/v2/.gitignore | 14 + owl-bot-staging/google-cloud-run/v2/.jsdoc.js | 55 + .../google-cloud-run/v2/.mocharc.js | 33 + .../google-cloud-run/v2/.prettierrc.js | 22 + owl-bot-staging/google-cloud-run/v2/README.md | 1 + .../google-cloud-run/v2/package.json | 62 + .../google/cloud/run/v2/condition.proto | 209 + .../google/cloud/run/v2/execution.proto | 277 + .../cloud/run/v2/execution_template.proto | 74 + .../v2/protos/google/cloud/run/v2/job.proto | 424 ++ .../protos/google/cloud/run/v2/k8s.min.proto | 369 + .../protos/google/cloud/run/v2/revision.proto | 299 + .../cloud/run/v2/revision_template.proto | 103 + .../protos/google/cloud/run/v2/service.proto | 470 ++ .../v2/protos/google/cloud/run/v2/task.proto | 267 + .../google/cloud/run/v2/task_template.proto | 70 + .../google/cloud/run/v2/traffic_target.proto | 77 + .../google/cloud/run/v2/vendor_settings.proto | 115 + .../v2/executions.delete_execution.js | 75 + .../generated/v2/executions.get_execution.js | 64 + .../v2/executions.list_executions.js | 79 + .../samples/generated/v2/jobs.create_job.js | 80 + .../samples/generated/v2/jobs.delete_job.js | 74 + .../generated/v2/jobs.get_iam_policy.js | 67 + .../v2/samples/generated/v2/jobs.get_job.js | 63 + .../v2/samples/generated/v2/jobs.list_jobs.js | 78 + .../v2/samples/generated/v2/jobs.run_job.js | 74 + .../generated/v2/jobs.set_iam_policy.js | 77 + .../generated/v2/jobs.test_iam_permissions.js | 70 + .../samples/generated/v2/jobs.update_job.js | 73 + .../generated/v2/revisions.delete_revision.js | 74 + .../generated/v2/revisions.get_revision.js | 63 + .../generated/v2/revisions.list_revisions.js | 79 + .../generated/v2/services.create_service.js | 81 + .../generated/v2/services.delete_service.js | 74 + .../generated/v2/services.get_iam_policy.js | 67 + .../generated/v2/services.get_service.js | 63 + .../generated/v2/services.list_services.js | 79 + .../generated/v2/services.set_iam_policy.js | 77 + .../v2/services.test_iam_permissions.js | 70 + .../generated/v2/services.update_service.js | 73 + .../snippet_metadata_google.cloud.run.v2.json | 1187 +++ .../v2/samples/generated/v2/tasks.get_task.js | 63 + .../samples/generated/v2/tasks.list_tasks.js | 79 + .../google-cloud-run/v2/src/index.ts | 33 + .../v2/src/v2/executions_client.ts | 1349 ++++ .../v2/src/v2/executions_client_config.json | 38 + .../v2/src/v2/executions_proto_list.json | 14 + .../v2/src/v2/gapic_metadata.json | 349 + .../google-cloud-run/v2/src/v2/index.ts | 23 + .../google-cloud-run/v2/src/v2/jobs_client.ts | 1896 +++++ .../v2/src/v2/jobs_client_config.json | 62 + .../v2/src/v2/jobs_proto_list.json | 14 + .../v2/src/v2/revisions_client.ts | 1467 ++++ .../v2/src/v2/revisions_client_config.json | 38 + .../v2/src/v2/revisions_proto_list.json | 14 + .../v2/src/v2/services_client.ts | 1874 +++++ .../v2/src/v2/services_client_config.json | 75 + .../v2/src/v2/services_proto_list.json | 14 + .../v2/src/v2/tasks_client.ts | 1112 +++ .../v2/src/v2/tasks_client_config.json | 34 + .../v2/src/v2/tasks_proto_list.json | 14 + .../system-test/fixtures/sample/src/index.js | 31 + .../system-test/fixtures/sample/src/index.ts | 56 + .../v2/system-test/install.ts | 49 + .../v2/test/gapic_executions_v2.ts | 1474 ++++ .../google-cloud-run/v2/test/gapic_jobs_v2.ts | 2264 ++++++ .../v2/test/gapic_revisions_v2.ts | 1513 ++++ .../v2/test/gapic_services_v2.ts | 2087 ++++++ .../v2/test/gapic_tasks_v2.ts | 1103 +++ .../google-cloud-run/v2/tsconfig.json | 19 + .../google-cloud-run/v2/webpack.config.js | 64 + .../google-cloud-scheduler/v1/.eslintignore | 7 + .../google-cloud-scheduler/v1/.eslintrc.json | 3 + .../google-cloud-scheduler/v1/.gitignore | 14 + .../google-cloud-scheduler/v1/.jsdoc.js | 55 + .../google-cloud-scheduler/v1/.mocharc.js | 33 + .../google-cloud-scheduler/v1/.prettierrc.js | 22 + .../google-cloud-scheduler/v1/README.md | 1 + .../google-cloud-scheduler/v1/package.json | 58 + .../cloud/scheduler/v1/cloudscheduler.proto | 287 + .../google/cloud/scheduler/v1/job.proto | 259 + .../google/cloud/scheduler/v1/target.proto | 369 + .../v1/cloud_scheduler.create_job.js | 72 + .../v1/cloud_scheduler.delete_job.js | 62 + .../generated/v1/cloud_scheduler.get_job.js | 62 + .../generated/v1/cloud_scheduler.list_jobs.js | 85 + .../generated/v1/cloud_scheduler.pause_job.js | 62 + .../v1/cloud_scheduler.resume_job.js | 62 + .../generated/v1/cloud_scheduler.run_job.js | 62 + .../v1/cloud_scheduler.update_job.js | 68 + ...et_metadata_google.cloud.scheduler.v1.json | 351 + .../google-cloud-scheduler/v1/src/index.ts | 25 + .../v1/src/v1/cloud_scheduler_client.ts | 1281 ++++ .../src/v1/cloud_scheduler_client_config.json | 66 + .../v1/src/v1/cloud_scheduler_proto_list.json | 5 + .../v1/src/v1/gapic_metadata.json | 107 + .../google-cloud-scheduler/v1/src/v1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1/system-test/install.ts | 49 + .../v1/test/gapic_cloud_scheduler_v1.ts | 1485 ++++ .../google-cloud-scheduler/v1/tsconfig.json | 19 + .../v1/webpack.config.js | 64 + .../v1beta1/.eslintignore | 7 + .../v1beta1/.eslintrc.json | 3 + .../google-cloud-scheduler/v1beta1/.gitignore | 14 + .../google-cloud-scheduler/v1beta1/.jsdoc.js | 55 + .../v1beta1/.mocharc.js | 33 + .../v1beta1/.prettierrc.js | 22 + .../google-cloud-scheduler/v1beta1/README.md | 1 + .../v1beta1/package.json | 58 + .../scheduler/v1beta1/cloudscheduler.proto | 315 + .../google/cloud/scheduler/v1beta1/job.proto | 268 + .../cloud/scheduler/v1beta1/target.proto | 371 + .../v1beta1/cloud_scheduler.create_job.js | 72 + .../v1beta1/cloud_scheduler.delete_job.js | 68 + .../v1beta1/cloud_scheduler.get_job.js | 62 + .../v1beta1/cloud_scheduler.list_jobs.js | 101 + .../v1beta1/cloud_scheduler.pause_job.js | 62 + .../v1beta1/cloud_scheduler.resume_job.js | 62 + .../v1beta1/cloud_scheduler.run_job.js | 68 + .../v1beta1/cloud_scheduler.update_job.js | 68 + ...tadata_google.cloud.scheduler.v1beta1.json | 367 + .../v1beta1/src/index.ts | 25 + .../src/v1beta1/cloud_scheduler_client.ts | 1331 ++++ .../cloud_scheduler_client_config.json | 66 + .../v1beta1/cloud_scheduler_proto_list.json | 5 + .../v1beta1/src/v1beta1/gapic_metadata.json | 107 + .../v1beta1/src/v1beta1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1beta1/system-test/install.ts | 49 + .../test/gapic_cloud_scheduler_v1beta1.ts | 1485 ++++ .../v1beta1/tsconfig.json | 19 + .../v1beta1/webpack.config.js | 64 + 1601 files changed, 418178 insertions(+) create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/.gitignore create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/README.md create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/package.json create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/authorization_policy.proto create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/client_tls_policy.proto create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/common.proto create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/network_security.proto create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/server_tls_policy.proto create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/tls.proto create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_authorization_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_client_tls_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_server_tls_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_authorization_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_client_tls_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_server_tls_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_authorization_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_client_tls_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_server_tls_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_authorization_policies.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_client_tls_policies.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_server_tls_policies.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_authorization_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_client_tls_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_server_tls_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/snippet_metadata_google.cloud.networksecurity.v1.json create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/src/v1/index.ts create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_client.ts create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_client_config.json create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_proto_list.json create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/test/gapic_network_security_v1.ts create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/.gitignore create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/README.md create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/package.json create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/authorization_policy.proto create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/client_tls_policy.proto create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/common.proto create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/network_security.proto create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/server_tls_policy.proto create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/tls.proto create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_authorization_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_client_tls_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_server_tls_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_authorization_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_client_tls_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_server_tls_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_authorization_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_client_tls_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_server_tls_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_authorization_policies.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_client_tls_policies.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_server_tls_policies.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_authorization_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_client_tls_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_server_tls_policy.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.networksecurity.v1beta1.json create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/index.ts create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_client.ts create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_client_config.json create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_proto_list.json create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/test/gapic_network_security_v1beta1.ts create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/.gitignore create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/README.md create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/package.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/diagnostic_config.proto create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/environment.proto create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/event.proto create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/execution.proto create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/instance.proto create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/instance_config.proto create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/managed_service.proto create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/runtime.proto create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/schedule.proto create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/service.proto create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.create_runtime.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.delete_runtime.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.diagnose_runtime.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.get_runtime.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.list_runtimes.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.refresh_runtime_token_internal.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.report_runtime_event.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.reset_runtime.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.start_runtime.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.stop_runtime.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.switch_runtime.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.update_runtime.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.upgrade_runtime.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_environment.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_execution.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_schedule.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_environment.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_execution.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_schedule.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.diagnose_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_environment.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_execution.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_instance_health.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_schedule.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.is_instance_upgradeable.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_environments.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_executions.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_instances.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_schedules.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.register_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.report_instance_info.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.reset_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.rollback_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_accelerator.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_labels.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_machine_type.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.start_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.stop_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.trigger_schedule.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_instance_config.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_instance_metadata_items.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_shielded_instance_config.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.upgrade_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.upgrade_instance_internal.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/snippet_metadata_google.cloud.notebooks.v1.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/src/v1/index.ts create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_client.ts create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_client.ts create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/test/gapic_managed_notebook_service_v1.ts create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/test/gapic_notebook_service_v1.ts create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/.gitignore create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/README.md create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/package.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/environment.proto create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/instance.proto create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/service.proto create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.create_environment.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.create_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.delete_environment.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.delete_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.get_environment.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.get_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.is_instance_upgradeable.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.list_environments.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.list_instances.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.register_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.report_instance_info.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.reset_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_accelerator.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_labels.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_machine_type.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.start_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.stop_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.upgrade_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.upgrade_instance_internal.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.notebooks.v1beta1.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/index.ts create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_client.ts create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/test/gapic_notebook_service_v1beta1.ts create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/.eslintignore create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/.gitignore create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/README.md create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/package.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/diagnostic_config.proto create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/event.proto create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/gce_setup.proto create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/instance.proto create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/service.proto create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.check_instance_upgradability.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.create_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.delete_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.diagnose_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.get_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.list_instances.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.reset_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.rollback_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.start_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.stop_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.update_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.upgrade_instance.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/snippet_metadata_google.cloud.notebooks.v2.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/src/index.ts create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/src/v2/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/src/v2/index.ts create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_client.ts create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/test/gapic_notebook_service_v2.ts create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-notebooks/v2/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-optimization/v1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-optimization/v1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-optimization/v1/.gitignore create mode 100644 owl-bot-staging/google-cloud-optimization/v1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-optimization/v1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-optimization/v1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-optimization/v1/README.md create mode 100644 owl-bot-staging/google-cloud-optimization/v1/package.json create mode 100644 owl-bot-staging/google-cloud-optimization/v1/protos/google/cloud/optimization/v1/async_model.proto create mode 100644 owl-bot-staging/google-cloud-optimization/v1/protos/google/cloud/optimization/v1/fleet_routing.proto create mode 100644 owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/fleet_routing.batch_optimize_tours.js create mode 100644 owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/fleet_routing.optimize_tours.js create mode 100644 owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/snippet_metadata_google.cloud.optimization.v1.json create mode 100644 owl-bot-staging/google-cloud-optimization/v1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_client.ts create mode 100644 owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_client_config.json create mode 100644 owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_proto_list.json create mode 100644 owl-bot-staging/google-cloud-optimization/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-optimization/v1/src/v1/index.ts create mode 100644 owl-bot-staging/google-cloud-optimization/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-optimization/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-optimization/v1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-optimization/v1/test/gapic_fleet_routing_v1.ts create mode 100644 owl-bot-staging/google-cloud-optimization/v1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-optimization/v1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.gitignore create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/README.md create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/package.json create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/environments.proto create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/image_versions.proto create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/operations.proto create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.create_environment.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.database_failover.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.delete_environment.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.execute_airflow_command.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.fetch_database_properties.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.get_environment.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.list_environments.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.load_snapshot.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.poll_airflow_command.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.save_snapshot.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.stop_airflow_command.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.update_environment.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/image_versions.list_image_versions.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/snippet_metadata_google.cloud.orchestration.airflow.service.v1.json create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_client.ts create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_client_config.json create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_proto_list.json create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_client.ts create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_client_config.json create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_proto_list.json create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/index.ts create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/test/gapic_environments_v1.ts create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/test/gapic_image_versions_v1.ts create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.gitignore create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/README.md create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/package.json create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/environments.proto create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/image_versions.proto create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/operations.proto create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.check_upgrade.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.create_environment.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.database_failover.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.delete_environment.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.execute_airflow_command.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.fetch_database_properties.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.get_environment.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.list_environments.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.load_snapshot.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.poll_airflow_command.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.restart_web_server.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.save_snapshot.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.stop_airflow_command.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.update_environment.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/image_versions.list_image_versions.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.orchestration.airflow.service.v1beta1.json create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_client.ts create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_client_config.json create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_proto_list.json create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_client.ts create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_client_config.json create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_proto_list.json create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/index.ts create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/test/gapic_environments_v1beta1.ts create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/test/gapic_image_versions_v1beta1.ts create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/.eslintignore create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/.gitignore create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/README.md create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/package.json create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/protos/google/cloud/orgpolicy/v2/constraint.proto create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/protos/google/cloud/orgpolicy/v2/orgpolicy.proto create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.create_policy.js create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.delete_policy.js create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.get_effective_policy.js create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.get_policy.js create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.list_constraints.js create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.list_policies.js create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.update_policy.js create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/snippet_metadata_google.cloud.orgpolicy.v2.json create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/src/index.ts create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/index.ts create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_client.ts create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_client_config.json create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_proto_list.json create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/test/gapic_org_policy_v2.ts create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/.gitignore create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/README.md create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/package.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/inventory.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy_assignment_reports.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy_assignments.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_common.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_service.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_zonal_service.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/patch_deployments.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/patch_jobs.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/vulnerability.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.cancel_patch_job.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.create_patch_deployment.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.delete_patch_deployment.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.execute_patch_job.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.get_patch_deployment.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.get_patch_job.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_deployments.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_job_instance_details.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_jobs.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.pause_patch_deployment.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.resume_patch_deployment.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.update_patch_deployment.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.create_o_s_policy_assignment.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.delete_o_s_policy_assignment.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_inventory.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_o_s_policy_assignment.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_o_s_policy_assignment_report.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_vulnerability_report.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_inventories.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignment_reports.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignment_revisions.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignments.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_vulnerability_reports.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.update_o_s_policy_assignment.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/snippet_metadata_google.cloud.osconfig.v1.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/src/v1/index.ts create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_client.ts create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_client.ts create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/test/gapic_os_config_service_v1.ts create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/test/gapic_os_config_zonal_service_v1.ts create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/.eslintignore create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/.gitignore create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/README.md create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/package.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/config_common.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/instance_os_policies_compliance.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/inventory.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy_assignment_reports.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy_assignments.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/osconfig_common.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/osconfig_zonal_service.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/vulnerability.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.create_o_s_policy_assignment.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.delete_o_s_policy_assignment.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_instance_o_s_policies_compliance.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_inventory.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_o_s_policy_assignment.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_o_s_policy_assignment_report.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_vulnerability_report.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_instance_o_s_policies_compliances.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_inventories.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignment_reports.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignment_revisions.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignments.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_vulnerability_reports.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.update_o_s_policy_assignment.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/snippet_metadata_google.cloud.osconfig.v1alpha.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/src/index.ts create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/index.ts create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_client.ts create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/test/gapic_os_config_zonal_service_v1alpha.ts create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/.eslintignore create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/.gitignore create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/README.md create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/package.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/guest_policies.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/osconfig_common.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/osconfig_service.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/patch_deployments.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/patch_jobs.proto create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.cancel_patch_job.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.create_guest_policy.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.create_patch_deployment.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.delete_guest_policy.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.delete_patch_deployment.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.execute_patch_job.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_guest_policy.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_patch_deployment.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_patch_job.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_guest_policies.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_deployments.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_job_instance_details.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_jobs.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.lookup_effective_guest_policy.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.pause_patch_deployment.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.resume_patch_deployment.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.update_guest_policy.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.update_patch_deployment.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/snippet_metadata_google.cloud.osconfig.v1beta.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/src/index.ts create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/index.ts create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_client.ts create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/test/gapic_os_config_service_v1beta.ts create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/.gitignore create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/README.md create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/package.json create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/protos/google/cloud/oslogin/common/common.proto create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/protos/google/cloud/oslogin/v1/oslogin.proto create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.create_ssh_public_key.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.delete_posix_account.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.delete_ssh_public_key.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.get_login_profile.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.get_ssh_public_key.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.import_ssh_public_key.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.update_ssh_public_key.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/snippet_metadata_google.cloud.oslogin.v1.json create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/src/v1/index.ts create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_client.ts create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/test/gapic_os_login_service_v1.ts create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-oslogin/v1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/.eslintignore create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/.gitignore create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/README.md create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/package.json create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/protos/google/cloud/oslogin/common/common.proto create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/protos/google/cloud/oslogin/v1beta/oslogin.proto create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.create_ssh_public_key.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.delete_posix_account.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.delete_ssh_public_key.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.get_login_profile.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.get_ssh_public_key.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.import_ssh_public_key.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.sign_ssh_public_key.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.update_ssh_public_key.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/snippet_metadata_google.cloud.oslogin.v1beta.json create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/src/index.ts create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/index.ts create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_client.ts create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/test/gapic_os_login_service_v1beta.ts create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/.gitignore create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/README.md create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/package.json create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/protos/google/cloud/phishingprotection/v1beta1/phishingprotection.proto create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/samples/generated/v1beta1/phishing_protection_service_v1_beta1.report_phishing.js create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.phishingprotection.v1beta1.json create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/index.ts create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_client.ts create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_client_config.json create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_proto_list.json create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/test/gapic_phishing_protection_service_v1_beta1_v1beta1.ts create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.eslintignore create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.gitignore create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/README.md create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/package.json create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/protos/google/cloud/policytroubleshooter/iam/v3/troubleshooter.proto create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/samples/generated/v3/policy_troubleshooter.troubleshoot_iam_policy.js create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/samples/generated/v3/snippet_metadata_google.cloud.policytroubleshooter.iam.v3.json create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/index.ts create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/index.ts create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_client.ts create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_client_config.json create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_proto_list.json create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/test/gapic_policy_troubleshooter_v3.ts create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.eslintignore create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.gitignore create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/README.md create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/package.json create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/cloud/policytroubleshooter/iam/v3beta/troubleshooter.proto create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v1/policy.proto create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v2/deny.proto create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v2/policy.proto create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/rpc/status.proto create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/type/expr.proto create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/samples/generated/v3beta/policy_troubleshooter.troubleshoot_iam_policy.js create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/samples/generated/v3beta/snippet_metadata_google.cloud.policytroubleshooter.iam.v3beta.json create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/index.ts create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/index.ts create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_client.ts create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_client_config.json create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_proto_list.json create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/test/gapic_policy_troubleshooter_v3beta.ts create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/.gitignore create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/README.md create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/package.json create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/protos/google/cloud/policytroubleshooter/v1/checker.proto create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/protos/google/cloud/policytroubleshooter/v1/explanations.proto create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/samples/generated/v1/iam_checker.troubleshoot_iam_policy.js create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/samples/generated/v1/snippet_metadata_google.cloud.policytroubleshooter.v1.json create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_client.ts create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_client_config.json create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_proto_list.json create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/index.ts create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/test/gapic_iam_checker_v1.ts create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/.gitignore create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/README.md create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/package.json create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/protos/google/cloud/privatecatalog/v1beta1/private_catalog.proto create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_catalogs.js create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_products.js create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_versions.js create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.privatecatalog.v1beta1.json create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/index.ts create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_client.ts create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_client_config.json create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_proto_list.json create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/test/gapic_private_catalog_v1beta1.ts create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.gitignore create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/README.md create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/package.json create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/protos/google/cloud/rapidmigrationassessment/v1/api_entities.proto create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/protos/google/cloud/rapidmigrationassessment/v1/rapidmigrationassessment.proto create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.create_annotation.js create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.create_collector.js create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.delete_collector.js create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.get_annotation.js create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.get_collector.js create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.list_collectors.js create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.pause_collector.js create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.register_collector.js create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.resume_collector.js create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.update_collector.js create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/snippet_metadata_google.cloud.rapidmigrationassessment.v1.json create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/index.ts create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_client.ts create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_client_config.json create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_proto_list.json create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/test/gapic_rapid_migration_assessment_v1.ts create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/.gitignore create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/README.md create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/package.json create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.annotate_assessment.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.create_assessment.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.create_key.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.delete_key.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.get_key.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.get_metrics.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_keys.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_group_memberships.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_groups.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.migrate_key.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.retrieve_legacy_secret_key.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.search_related_account_group_memberships.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.update_key.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/snippet_metadata_google.cloud.recaptchaenterprise.v1.json create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/index.ts create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_client.ts create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/test/gapic_recaptcha_enterprise_service_v1.ts create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.gitignore create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/README.md create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/package.json create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.annotate_assessment.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_assessment.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.recaptchaenterprise.v1beta1.json create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/index.ts create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_proto_list.json create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/test/gapic_recaptcha_enterprise_service_v1_beta1_v1beta1.ts create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-recommender/v1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-recommender/v1/.gitignore create mode 100644 owl-bot-staging/google-cloud-recommender/v1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1/README.md create mode 100644 owl-bot-staging/google-cloud-recommender/v1/package.json create mode 100644 owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/insight.proto create mode 100644 owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/insight_type_config.proto create mode 100644 owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommendation.proto create mode 100644 owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommender_config.proto create mode 100644 owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommender_service.proto create mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_insight.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_insight_type_config.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_recommendation.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_recommender_config.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.list_insights.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.list_recommendations.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_insight_accepted.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_claimed.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_failed.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_succeeded.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.update_insight_type_config.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.update_recommender_config.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/snippet_metadata_google.cloud.recommender.v1.json create mode 100644 owl-bot-staging/google-cloud-recommender/v1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-recommender/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-recommender/v1/src/v1/index.ts create mode 100644 owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_client.ts create mode 100644 owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_client_config.json create mode 100644 owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_proto_list.json create mode 100644 owl-bot-staging/google-cloud-recommender/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-recommender/v1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-recommender/v1/test/gapic_recommender_v1.ts create mode 100644 owl-bot-staging/google-cloud-recommender/v1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-recommender/v1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/.gitignore create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/README.md create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/package.json create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/insight.proto create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/insight_type_config.proto create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommendation.proto create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommender_config.proto create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommender_service.proto create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_insight.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_insight_type_config.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_recommendation.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_recommender_config.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.list_insights.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.list_recommendations.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_insight_accepted.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_claimed.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_failed.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_succeeded.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.update_insight_type_config.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.update_recommender_config.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.recommender.v1beta1.json create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/index.ts create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_client.ts create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_client_config.json create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_proto_list.json create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/test/gapic_recommender_v1beta1.ts create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-redis/v1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-redis/v1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-redis/v1/.gitignore create mode 100644 owl-bot-staging/google-cloud-redis/v1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-redis/v1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-redis/v1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-redis/v1/README.md create mode 100644 owl-bot-staging/google-cloud-redis/v1/package.json create mode 100644 owl-bot-staging/google-cloud-redis/v1/protos/google/cloud/redis/v1/cloud_redis.proto create mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.create_instance.js create mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.delete_instance.js create mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.export_instance.js create mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.failover_instance.js create mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.get_instance.js create mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.get_instance_auth_string.js create mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.import_instance.js create mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.list_instances.js create mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.reschedule_maintenance.js create mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.update_instance.js create mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.upgrade_instance.js create mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/snippet_metadata_google.cloud.redis.v1.json create mode 100644 owl-bot-staging/google-cloud-redis/v1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_client.ts create mode 100644 owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_client_config.json create mode 100644 owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_proto_list.json create mode 100644 owl-bot-staging/google-cloud-redis/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-redis/v1/src/v1/index.ts create mode 100644 owl-bot-staging/google-cloud-redis/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-redis/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-redis/v1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-redis/v1/test/gapic_cloud_redis_v1.ts create mode 100644 owl-bot-staging/google-cloud-redis/v1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-redis/v1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/.gitignore create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/README.md create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/package.json create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/protos/google/cloud/redis/v1beta1/cloud_redis.proto create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.create_instance.js create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.delete_instance.js create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.export_instance.js create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.failover_instance.js create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.get_instance.js create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.get_instance_auth_string.js create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.import_instance.js create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.list_instances.js create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.reschedule_maintenance.js create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.update_instance.js create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.upgrade_instance.js create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.redis.v1beta1.json create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_client.ts create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_client_config.json create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_proto_list.json create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/index.ts create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/test/gapic_cloud_redis_v1beta1.ts create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/.eslintignore create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/.gitignore create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/README.md create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/package.json create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/folders.proto create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/organizations.proto create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/projects.proto create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_bindings.proto create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_holds.proto create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_keys.proto create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_values.proto create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.create_folder.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.delete_folder.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.get_folder.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.get_iam_policy.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.list_folders.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.move_folder.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.search_folders.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.set_iam_policy.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.test_iam_permissions.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.undelete_folder.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.update_folder.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.get_iam_policy.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.get_organization.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.search_organizations.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.set_iam_policy.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.test_iam_permissions.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.create_project.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.delete_project.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.get_iam_policy.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.get_project.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.list_projects.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.move_project.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.search_projects.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.set_iam_policy.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.test_iam_permissions.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.undelete_project.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.update_project.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/snippet_metadata_google.cloud.resourcemanager.v3.json create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.create_tag_binding.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.delete_tag_binding.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.list_effective_tags.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.list_tag_bindings.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.create_tag_hold.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.delete_tag_hold.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.list_tag_holds.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.create_tag_key.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.delete_tag_key.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_iam_policy.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_namespaced_tag_key.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_tag_key.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.list_tag_keys.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.set_iam_policy.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.test_iam_permissions.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.update_tag_key.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.create_tag_value.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.delete_tag_value.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_iam_policy.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_namespaced_tag_value.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_tag_value.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.list_tag_values.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.set_iam_policy.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.test_iam_permissions.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.update_tag_value.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/index.ts create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_client.ts create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_client_config.json create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_proto_list.json create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/index.ts create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_client.ts create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_client_config.json create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_proto_list.json create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_client.ts create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_client_config.json create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_proto_list.json create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_client.ts create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_client_config.json create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_proto_list.json create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_client.ts create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_client_config.json create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_proto_list.json create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_client.ts create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_client_config.json create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_proto_list.json create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_client.ts create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_client_config.json create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_proto_list.json create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_folders_v3.ts create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_organizations_v3.ts create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_projects_v3.ts create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_bindings_v3.ts create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_holds_v3.ts create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_keys_v3.ts create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_values_v3.ts create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/.gitignore create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/README.md create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/package.json create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/protos/google/cloud/resourcesettings/v1/resource_settings.proto create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.get_setting.js create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.list_settings.js create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.update_setting.js create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/snippet_metadata_google.cloud.resourcesettings.v1.json create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/index.ts create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_client.ts create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/test/gapic_resource_settings_service_v1.ts create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/webpack.config.js 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/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/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/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 create mode 100644 owl-bot-staging/google-cloud-run/v2/.eslintignore create mode 100644 owl-bot-staging/google-cloud-run/v2/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-run/v2/.gitignore create mode 100644 owl-bot-staging/google-cloud-run/v2/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-run/v2/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-run/v2/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-run/v2/README.md create mode 100644 owl-bot-staging/google-cloud-run/v2/package.json create mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/condition.proto create mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/execution.proto create mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/execution_template.proto create mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/job.proto create mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/k8s.min.proto create mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/revision.proto create mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/revision_template.proto create mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/service.proto create mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/task.proto create mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/task_template.proto create mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/traffic_target.proto create mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/vendor_settings.proto create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.delete_execution.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.get_execution.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.list_executions.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.create_job.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.delete_job.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.get_iam_policy.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.get_job.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.list_jobs.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.run_job.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.set_iam_policy.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.test_iam_permissions.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.update_job.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.delete_revision.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.get_revision.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.list_revisions.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.create_service.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.delete_service.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.get_iam_policy.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.get_service.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.list_services.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.set_iam_policy.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.test_iam_permissions.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.update_service.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/snippet_metadata_google.cloud.run.v2.json create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/tasks.get_task.js create mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/tasks.list_tasks.js create mode 100644 owl-bot-staging/google-cloud-run/v2/src/index.ts create mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/executions_client.ts create mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/executions_client_config.json create mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/executions_proto_list.json create mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/index.ts create mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/jobs_client.ts create mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/jobs_client_config.json create mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/jobs_proto_list.json create mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/revisions_client.ts create mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/revisions_client_config.json create mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/revisions_proto_list.json create mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/services_client.ts create mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/services_client_config.json create mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/services_proto_list.json create mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/tasks_client.ts create mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/tasks_client_config.json create mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/tasks_proto_list.json create mode 100644 owl-bot-staging/google-cloud-run/v2/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-run/v2/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-run/v2/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-run/v2/test/gapic_executions_v2.ts create mode 100644 owl-bot-staging/google-cloud-run/v2/test/gapic_jobs_v2.ts create mode 100644 owl-bot-staging/google-cloud-run/v2/test/gapic_revisions_v2.ts create mode 100644 owl-bot-staging/google-cloud-run/v2/test/gapic_services_v2.ts create mode 100644 owl-bot-staging/google-cloud-run/v2/test/gapic_tasks_v2.ts create mode 100644 owl-bot-staging/google-cloud-run/v2/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-run/v2/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.gitignore create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/README.md create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/package.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/cloudscheduler.proto create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/job.proto create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/target.proto create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.create_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.delete_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.get_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.list_jobs.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.pause_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.resume_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.run_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.update_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/snippet_metadata_google.cloud.scheduler.v1.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client_config.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_proto_list.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/v1/index.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/test/gapic_cloud_scheduler_v1.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.gitignore create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/README.md create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/package.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/job.proto create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/target.proto create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.create_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.delete_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.get_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.list_jobs.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.pause_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.resume_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.run_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.update_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.scheduler.v1beta1.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client_config.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_proto_list.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/index.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/test/gapic_cloud_scheduler_v1beta1.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/webpack.config.js diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/.eslintignore b/owl-bot-staging/google-cloud-networksecurity/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/.eslintrc.json b/owl-bot-staging/google-cloud-networksecurity/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/.gitignore b/owl-bot-staging/google-cloud-networksecurity/v1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/.jsdoc.js b/owl-bot-staging/google-cloud-networksecurity/v1/.jsdoc.js new file mode 100644 index 00000000000..4caec343c54 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/.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/networksecurity', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/.mocharc.js b/owl-bot-staging/google-cloud-networksecurity/v1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/.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-networksecurity/v1/.prettierrc.js b/owl-bot-staging/google-cloud-networksecurity/v1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/.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-networksecurity/v1/README.md b/owl-bot-staging/google-cloud-networksecurity/v1/README.md new file mode 100644 index 00000000000..aa251b5b5c0 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/README.md @@ -0,0 +1 @@ +Networksecurity: Nodejs Client diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/package.json b/owl-bot-staging/google-cloud-networksecurity/v1/package.json new file mode 100644 index 00000000000..4035fdcca29 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/networksecurity", + "version": "0.1.0", + "description": "Networksecurity client for Node.js", + "repository": "googleapis/nodejs-networksecurity", + "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 networksecurity", + "networksecurity", + "network security" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/authorization_policy.proto b/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/authorization_policy.proto new file mode 100644 index 00000000000..7d720d4e9c4 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/authorization_policy.proto @@ -0,0 +1,249 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.networksecurity.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.NetworkSecurity.V1"; +option go_package = "cloud.google.com/go/networksecurity/apiv1/networksecuritypb;networksecuritypb"; +option java_multiple_files = true; +option java_outer_classname = "AuthorizationPolicyProto"; +option java_package = "com.google.cloud.networksecurity.v1"; +option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1"; +option ruby_package = "Google::Cloud::NetworkSecurity::V1"; + +// AuthorizationPolicy is a resource that specifies how a server +// should authorize incoming connections. This resource in itself does +// not change the configuration unless it's attached to a target https +// proxy or endpoint config selector resource. +message AuthorizationPolicy { + option (google.api.resource) = { + type: "networksecurity.googleapis.com/AuthorizationPolicy" + pattern: "projects/{project}/locations/{location}/authorizationPolicies/{authorization_policy}" + }; + + // Specification of rules. + message Rule { + // Specification of traffic source attributes. + message Source { + // Optional. List of peer identities to match for authorization. At least one + // principal should match. Each peer can be an exact match, or a prefix + // match (example, "namespace/*") or a suffix match (example, + // "*/service-account") or a presence match "*". Authorization based on + // the principal name without certificate validation (configured by + // ServerTlsPolicy resource) is considered insecure. + repeated string principals = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. List of CIDR ranges to match based on source IP address. At least one + // IP block should match. Single IP (e.g., "1.2.3.4") and CIDR (e.g., + // "1.2.3.0/24") are supported. Authorization based on source IP alone + // should be avoided. The IP addresses of any load balancers or proxies + // should be considered untrusted. + repeated string ip_blocks = 2 [(google.api.field_behavior) = OPTIONAL]; + } + + // Specification of traffic destination attributes. + message Destination { + // Specification of HTTP header match attributes. + message HttpHeaderMatch { + oneof type { + // Required. The value of the header must match the regular expression + // specified in regexMatch. For regular expression grammar, + // please see: en.cppreference.com/w/cpp/regex/ecmascript + // For matching against a port specified in the HTTP + // request, use a headerMatch with headerName set to Host + // and a regular expression that satisfies the RFC2616 Host + // header's port specifier. + string regex_match = 2 [(google.api.field_behavior) = REQUIRED]; + } + + // Required. The name of the HTTP header to match. For matching + // against the HTTP request's authority, use a headerMatch + // with the header name ":authority". For matching a + // request's method, use the headerName ":method". + string header_name = 1 [(google.api.field_behavior) = REQUIRED]; + } + + // Required. List of host names to match. Matched against the ":authority" header in + // http requests. At least one host should match. Each host can be an + // exact match, or a prefix match (example "mydomain.*") or a suffix + // match (example "*.myorg.com") or a presence (any) match "*". + repeated string hosts = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. List of destination ports to match. At least one port should match. + repeated uint32 ports = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. A list of HTTP methods to match. At least one method should + // match. Should not be set for gRPC services. + repeated string methods = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Match against key:value pair in http header. Provides a flexible match + // based on HTTP headers, for potentially advanced use cases. At least one + // header should match. Avoid using header matches to make authorization + // decisions unless there is a strong guarantee that requests arrive + // through a trusted client or proxy. + HttpHeaderMatch http_header_match = 5 [(google.api.field_behavior) = OPTIONAL]; + } + + // Optional. List of attributes for the traffic source. All of the sources must match. + // A source is a match if both principals and ip_blocks match. If not set, + // the action specified in the 'action' field will be applied without any + // rule checks for the source. + repeated Source sources = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. List of attributes for the traffic destination. All of the destinations + // must match. A destination is a match if a request matches all the + // specified hosts, ports, methods and headers. If not set, the + // action specified in the 'action' field will be applied without any rule + // checks for the destination. + repeated Destination destinations = 2 [(google.api.field_behavior) = OPTIONAL]; + } + + // Possible values that define what action to take. + enum Action { + // Default value. + ACTION_UNSPECIFIED = 0; + + // Grant access. + ALLOW = 1; + + // Deny access. + // Deny rules should be avoided unless they are used to provide a default + // "deny all" fallback. + DENY = 2; + } + + // Required. Name of the AuthorizationPolicy resource. It matches pattern + // `projects/{project}/locations/{location}/authorizationPolicies/`. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Free-text description of the resource. + string description = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The timestamp when the resource was created. + google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp when the resource was updated. + google.protobuf.Timestamp update_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Set of label tags associated with the AuthorizationPolicy resource. + map labels = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Required. The action to take when a rule match is found. Possible values + // are "ALLOW" or "DENY". + Action action = 6 [(google.api.field_behavior) = REQUIRED]; + + // Optional. List of rules to match. Note that at least one of the rules must match in + // order for the action specified in the 'action' field to be taken. A rule is + // a match if there is a matching source and destination. If left blank, the + // action specified in the `action` field will be applied on every request. + repeated Rule rules = 7 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request used with the ListAuthorizationPolicies method. +message ListAuthorizationPoliciesRequest { + // Required. The project and location from which the AuthorizationPolicies + // should be listed, specified in the format + // `projects/{project}/locations/{location}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Maximum number of AuthorizationPolicies to return per call. + int32 page_size = 2; + + // The value returned by the last + // `ListAuthorizationPoliciesResponse` Indicates that this is a + // continuation of a prior `ListAuthorizationPolicies` call, and + // that the system should return the next page of data. + string page_token = 3; +} + +// Response returned by the ListAuthorizationPolicies method. +message ListAuthorizationPoliciesResponse { + // List of AuthorizationPolicies resources. + repeated AuthorizationPolicy authorization_policies = 1; + + // If there might be more results than those appearing in this response, then + // `next_page_token` is included. To get the next set of results, call this + // method again using the value of `next_page_token` as `page_token`. + string next_page_token = 2; +} + +// Request used by the GetAuthorizationPolicy method. +message GetAuthorizationPolicyRequest { + // Required. A name of the AuthorizationPolicy to get. Must be in the format + // `projects/{project}/locations/{location}/authorizationPolicies/*`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "networksecurity.googleapis.com/AuthorizationPolicy" + } + ]; +} + +// Request used by the CreateAuthorizationPolicy method. +message CreateAuthorizationPolicyRequest { + // Required. The parent resource of the AuthorizationPolicy. Must be in the + // format `projects/{project}/locations/{location}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "networksecurity.googleapis.com/AuthorizationPolicy" + } + ]; + + // Required. Short name of the AuthorizationPolicy resource to be created. + // This value should be 1-63 characters long, containing only + // letters, numbers, hyphens, and underscores, and should not start + // with a number. E.g. "authz_policy". + string authorization_policy_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. AuthorizationPolicy resource to be created. + AuthorizationPolicy authorization_policy = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request used by the UpdateAuthorizationPolicy method. +message UpdateAuthorizationPolicyRequest { + // Optional. Field mask is used to specify the fields to be overwritten in the + // AuthorizationPolicy resource by the update. + // The fields specified in the update_mask are relative to the resource, not + // the full request. A field will be overwritten if it is in the mask. If the + // user does not provide a mask then all fields will be overwritten. + google.protobuf.FieldMask update_mask = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Required. Updated AuthorizationPolicy resource. + AuthorizationPolicy authorization_policy = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request used by the DeleteAuthorizationPolicy method. +message DeleteAuthorizationPolicyRequest { + // Required. A name of the AuthorizationPolicy to delete. Must be in the format + // `projects/{project}/locations/{location}/authorizationPolicies/*`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "networksecurity.googleapis.com/AuthorizationPolicy" + } + ]; +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/client_tls_policy.proto b/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/client_tls_policy.proto new file mode 100644 index 00000000000..e201dd82c1c --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/client_tls_policy.proto @@ -0,0 +1,160 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.networksecurity.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/networksecurity/v1/tls.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.NetworkSecurity.V1"; +option go_package = "cloud.google.com/go/networksecurity/apiv1/networksecuritypb;networksecuritypb"; +option java_multiple_files = true; +option java_outer_classname = "ClientTlsPolicyProto"; +option java_package = "com.google.cloud.networksecurity.v1"; +option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1"; +option ruby_package = "Google::Cloud::NetworkSecurity::V1"; + +// ClientTlsPolicy is a resource that specifies how a client should authenticate +// connections to backends of a service. This resource itself does not affect +// configuration unless it is attached to a backend service resource. +message ClientTlsPolicy { + option (google.api.resource) = { + type: "networksecurity.googleapis.com/ClientTlsPolicy" + pattern: "projects/{project}/locations/{location}/clientTlsPolicies/{client_tls_policy}" + }; + + // Required. Name of the ClientTlsPolicy resource. It matches the pattern + // `projects/*/locations/{location}/clientTlsPolicies/{client_tls_policy}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Free-text description of the resource. + string description = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The timestamp when the resource was created. + google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp when the resource was updated. + google.protobuf.Timestamp update_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Set of label tags associated with the resource. + map labels = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Server Name Indication string to present to the server during TLS + // handshake. E.g: "secure.example.com". + string sni = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Defines a mechanism to provision client identity (public and private keys) + // for peer to peer authentication. The presence of this dictates mTLS. + CertificateProvider client_certificate = 7 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Defines the mechanism to obtain the Certificate Authority certificate to + // validate the server certificate. If empty, client does not validate the + // server certificate. + repeated ValidationCA server_validation_ca = 8 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request used by the ListClientTlsPolicies method. +message ListClientTlsPoliciesRequest { + // Required. The project and location from which the ClientTlsPolicies should + // be listed, specified in the format `projects/*/locations/{location}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Maximum number of ClientTlsPolicies to return per call. + int32 page_size = 2; + + // The value returned by the last `ListClientTlsPoliciesResponse` + // Indicates that this is a continuation of a prior + // `ListClientTlsPolicies` call, and that the system + // should return the next page of data. + string page_token = 3; +} + +// Response returned by the ListClientTlsPolicies method. +message ListClientTlsPoliciesResponse { + // List of ClientTlsPolicy resources. + repeated ClientTlsPolicy client_tls_policies = 1; + + // If there might be more results than those appearing in this response, then + // `next_page_token` is included. To get the next set of results, call this + // method again using the value of `next_page_token` as `page_token`. + string next_page_token = 2; +} + +// Request used by the GetClientTlsPolicy method. +message GetClientTlsPolicyRequest { + // Required. A name of the ClientTlsPolicy to get. Must be in the format + // `projects/*/locations/{location}/clientTlsPolicies/*`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "networksecurity.googleapis.com/ClientTlsPolicy" + } + ]; +} + +// Request used by the CreateClientTlsPolicy method. +message CreateClientTlsPolicyRequest { + // Required. The parent resource of the ClientTlsPolicy. Must be in + // the format `projects/*/locations/{location}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "networksecurity.googleapis.com/ClientTlsPolicy" + } + ]; + + // Required. Short name of the ClientTlsPolicy resource to be created. This value should + // be 1-63 characters long, containing only letters, numbers, hyphens, and + // underscores, and should not start with a number. E.g. "client_mtls_policy". + string client_tls_policy_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. ClientTlsPolicy resource to be created. + ClientTlsPolicy client_tls_policy = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request used by UpdateClientTlsPolicy method. +message UpdateClientTlsPolicyRequest { + // Optional. Field mask is used to specify the fields to be overwritten in the + // ClientTlsPolicy resource by the update. The fields + // specified in the update_mask are relative to the resource, not + // the full request. A field will be overwritten if it is in the + // mask. If the user does not provide a mask then all fields will be + // overwritten. + google.protobuf.FieldMask update_mask = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Required. Updated ClientTlsPolicy resource. + ClientTlsPolicy client_tls_policy = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request used by the DeleteClientTlsPolicy method. +message DeleteClientTlsPolicyRequest { + // Required. A name of the ClientTlsPolicy to delete. Must be in + // the format `projects/*/locations/{location}/clientTlsPolicies/*`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "networksecurity.googleapis.com/ClientTlsPolicy" + } + ]; +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/common.proto b/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/common.proto new file mode 100644 index 00000000000..728b9b08945 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/common.proto @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.networksecurity.v1; + +import "google/api/field_behavior.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.NetworkSecurity.V1"; +option go_package = "cloud.google.com/go/networksecurity/apiv1/networksecuritypb;networksecuritypb"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.cloud.networksecurity.v1"; +option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1"; +option ruby_package = "Google::Cloud::NetworkSecurity::V1"; + +// Represents the metadata of the long-running operation. +message OperationMetadata { + // Output only. The time the operation was created. + google.protobuf.Timestamp create_time = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time the operation finished running. + google.protobuf.Timestamp end_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Server-defined resource path for the target of the operation. + string target = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the verb executed by the operation. + string verb = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Human-readable status of the operation, if any. + string status_message = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Identifies whether the user has requested cancellation + // of the operation. Operations that have successfully been cancelled + // have [Operation.error][] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + // corresponding to `Code.CANCELLED`. + bool requested_cancellation = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. API version used to start the operation. + string api_version = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/network_security.proto b/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/network_security.proto new file mode 100644 index 00000000000..a77d11f6b25 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/network_security.proto @@ -0,0 +1,201 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.networksecurity.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/cloud/networksecurity/v1/authorization_policy.proto"; +import "google/cloud/networksecurity/v1/client_tls_policy.proto"; +import "google/cloud/networksecurity/v1/server_tls_policy.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.NetworkSecurity.V1"; +option go_package = "cloud.google.com/go/networksecurity/apiv1/networksecuritypb;networksecuritypb"; +option java_multiple_files = true; +option java_package = "com.google.cloud.networksecurity.v1"; +option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1"; +option ruby_package = "Google::Cloud::NetworkSecurity::V1"; + +// Network Security API provides resources to configure authentication and +// authorization policies. Refer to per API resource documentation for more +// information. +service NetworkSecurity { + option (google.api.default_host) = "networksecurity.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Lists AuthorizationPolicies in a given project and location. + rpc ListAuthorizationPolicies(ListAuthorizationPoliciesRequest) returns (ListAuthorizationPoliciesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/authorizationPolicies" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets details of a single AuthorizationPolicy. + rpc GetAuthorizationPolicy(GetAuthorizationPolicyRequest) returns (AuthorizationPolicy) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/authorizationPolicies/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new AuthorizationPolicy in a given project and location. + rpc CreateAuthorizationPolicy(CreateAuthorizationPolicyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/authorizationPolicies" + body: "authorization_policy" + }; + option (google.api.method_signature) = "parent,authorization_policy,authorization_policy_id"; + option (google.longrunning.operation_info) = { + response_type: "AuthorizationPolicy" + metadata_type: "google.cloud.networksecurity.v1.OperationMetadata" + }; + } + + // Updates the parameters of a single AuthorizationPolicy. + rpc UpdateAuthorizationPolicy(UpdateAuthorizationPolicyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{authorization_policy.name=projects/*/locations/*/authorizationPolicies/*}" + body: "authorization_policy" + }; + option (google.api.method_signature) = "authorization_policy,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "AuthorizationPolicy" + metadata_type: "google.cloud.networksecurity.v1.OperationMetadata" + }; + } + + // Deletes a single AuthorizationPolicy. + rpc DeleteAuthorizationPolicy(DeleteAuthorizationPolicyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/authorizationPolicies/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "google.cloud.networksecurity.v1.OperationMetadata" + }; + } + + // Lists ServerTlsPolicies in a given project and location. + rpc ListServerTlsPolicies(ListServerTlsPoliciesRequest) returns (ListServerTlsPoliciesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/serverTlsPolicies" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets details of a single ServerTlsPolicy. + rpc GetServerTlsPolicy(GetServerTlsPolicyRequest) returns (ServerTlsPolicy) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/serverTlsPolicies/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new ServerTlsPolicy in a given project and location. + rpc CreateServerTlsPolicy(CreateServerTlsPolicyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/serverTlsPolicies" + body: "server_tls_policy" + }; + option (google.api.method_signature) = "parent,server_tls_policy,server_tls_policy_id"; + option (google.longrunning.operation_info) = { + response_type: "ServerTlsPolicy" + metadata_type: "google.cloud.networksecurity.v1.OperationMetadata" + }; + } + + // Updates the parameters of a single ServerTlsPolicy. + rpc UpdateServerTlsPolicy(UpdateServerTlsPolicyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{server_tls_policy.name=projects/*/locations/*/serverTlsPolicies/*}" + body: "server_tls_policy" + }; + option (google.api.method_signature) = "server_tls_policy,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "ServerTlsPolicy" + metadata_type: "google.cloud.networksecurity.v1.OperationMetadata" + }; + } + + // Deletes a single ServerTlsPolicy. + rpc DeleteServerTlsPolicy(DeleteServerTlsPolicyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/serverTlsPolicies/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "google.cloud.networksecurity.v1.OperationMetadata" + }; + } + + // Lists ClientTlsPolicies in a given project and location. + rpc ListClientTlsPolicies(ListClientTlsPoliciesRequest) returns (ListClientTlsPoliciesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/clientTlsPolicies" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets details of a single ClientTlsPolicy. + rpc GetClientTlsPolicy(GetClientTlsPolicyRequest) returns (ClientTlsPolicy) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/clientTlsPolicies/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new ClientTlsPolicy in a given project and location. + rpc CreateClientTlsPolicy(CreateClientTlsPolicyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/clientTlsPolicies" + body: "client_tls_policy" + }; + option (google.api.method_signature) = "parent,client_tls_policy,client_tls_policy_id"; + option (google.longrunning.operation_info) = { + response_type: "ClientTlsPolicy" + metadata_type: "google.cloud.networksecurity.v1.OperationMetadata" + }; + } + + // Updates the parameters of a single ClientTlsPolicy. + rpc UpdateClientTlsPolicy(UpdateClientTlsPolicyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{client_tls_policy.name=projects/*/locations/*/clientTlsPolicies/*}" + body: "client_tls_policy" + }; + option (google.api.method_signature) = "client_tls_policy,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "ClientTlsPolicy" + metadata_type: "google.cloud.networksecurity.v1.OperationMetadata" + }; + } + + // Deletes a single ClientTlsPolicy. + rpc DeleteClientTlsPolicy(DeleteClientTlsPolicyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/clientTlsPolicies/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "google.cloud.networksecurity.v1.OperationMetadata" + }; + } +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/server_tls_policy.proto b/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/server_tls_policy.proto new file mode 100644 index 00000000000..c837d4a61f4 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/server_tls_policy.proto @@ -0,0 +1,181 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.networksecurity.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/networksecurity/v1/tls.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.NetworkSecurity.V1"; +option go_package = "cloud.google.com/go/networksecurity/apiv1/networksecuritypb;networksecuritypb"; +option java_multiple_files = true; +option java_outer_classname = "ServerTlsPolicyProto"; +option java_package = "com.google.cloud.networksecurity.v1"; +option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1"; +option ruby_package = "Google::Cloud::NetworkSecurity::V1"; + +// ServerTlsPolicy is a resource that specifies how a server should authenticate +// incoming requests. This resource itself does not affect configuration unless +// it is attached to a target https proxy or endpoint config selector resource. +message ServerTlsPolicy { + option (google.api.resource) = { + type: "networksecurity.googleapis.com/ServerTlsPolicy" + pattern: "projects/{project}/locations/{location}/serverTlsPolicies/{server_tls_policy}" + }; + + // Specification of the MTLSPolicy. + message MTLSPolicy { + // + // Defines the mechanism to obtain the Certificate Authority certificate to + // validate the client certificate. + repeated ValidationCA client_validation_ca = 1; + } + + // Required. Name of the ServerTlsPolicy resource. It matches the pattern + // `projects/*/locations/{location}/serverTlsPolicies/{server_tls_policy}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Free-text description of the resource. + string description = 2; + + // Output only. The timestamp when the resource was created. + google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp when the resource was updated. + google.protobuf.Timestamp update_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Set of label tags associated with the resource. + map labels = 5; + + // + // Determines if server allows plaintext connections. If set to true, server + // allows plain text connections. By default, it is set to false. This setting + // is not exclusive of other encryption modes. For example, if `allow_open` + // and `mtls_policy` are set, server allows both plain text and mTLS + // connections. See documentation of other encryption modes to confirm + // compatibility. + // + // Consider using it if you wish to upgrade in place your deployment to TLS + // while having mixed TLS and non-TLS traffic reaching port :80. + bool allow_open = 6; + + // + // Defines a mechanism to provision server identity (public and private keys). + // Cannot be combined with `allow_open` as a permissive mode that allows both + // plain text and TLS is not supported. + CertificateProvider server_certificate = 7; + + // + // Defines a mechanism to provision peer validation certificates for peer to + // peer authentication (Mutual TLS - mTLS). If not specified, client + // certificate will not be requested. The connection is treated as TLS and not + // mTLS. If `allow_open` and `mtls_policy` are set, server allows both plain + // text and mTLS connections. + MTLSPolicy mtls_policy = 8; +} + +// Request used by the ListServerTlsPolicies method. +message ListServerTlsPoliciesRequest { + // Required. The project and location from which the ServerTlsPolicies should + // be listed, specified in the format `projects/*/locations/{location}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Maximum number of ServerTlsPolicies to return per call. + int32 page_size = 2; + + // The value returned by the last `ListServerTlsPoliciesResponse` + // Indicates that this is a continuation of a prior + // `ListServerTlsPolicies` call, and that the system + // should return the next page of data. + string page_token = 3; +} + +// Response returned by the ListServerTlsPolicies method. +message ListServerTlsPoliciesResponse { + // List of ServerTlsPolicy resources. + repeated ServerTlsPolicy server_tls_policies = 1; + + // If there might be more results than those appearing in this response, then + // `next_page_token` is included. To get the next set of results, call this + // method again using the value of `next_page_token` as `page_token`. + string next_page_token = 2; +} + +// Request used by the GetServerTlsPolicy method. +message GetServerTlsPolicyRequest { + // Required. A name of the ServerTlsPolicy to get. Must be in the format + // `projects/*/locations/{location}/serverTlsPolicies/*`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "networksecurity.googleapis.com/ServerTlsPolicy" + } + ]; +} + +// Request used by the CreateServerTlsPolicy method. +message CreateServerTlsPolicyRequest { + // Required. The parent resource of the ServerTlsPolicy. Must be in + // the format `projects/*/locations/{location}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "networksecurity.googleapis.com/ServerTlsPolicy" + } + ]; + + // Required. Short name of the ServerTlsPolicy resource to be created. This value should + // be 1-63 characters long, containing only letters, numbers, hyphens, and + // underscores, and should not start with a number. E.g. "server_mtls_policy". + string server_tls_policy_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. ServerTlsPolicy resource to be created. + ServerTlsPolicy server_tls_policy = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request used by UpdateServerTlsPolicy method. +message UpdateServerTlsPolicyRequest { + // Optional. Field mask is used to specify the fields to be overwritten in the + // ServerTlsPolicy resource by the update. The fields + // specified in the update_mask are relative to the resource, not + // the full request. A field will be overwritten if it is in the + // mask. If the user does not provide a mask then all fields will be + // overwritten. + google.protobuf.FieldMask update_mask = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Required. Updated ServerTlsPolicy resource. + ServerTlsPolicy server_tls_policy = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request used by the DeleteServerTlsPolicy method. +message DeleteServerTlsPolicyRequest { + // Required. A name of the ServerTlsPolicy to delete. Must be in + // the format `projects/*/locations/{location}/serverTlsPolicies/*`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "networksecurity.googleapis.com/ServerTlsPolicy" + } + ]; +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/tls.proto b/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/tls.proto new file mode 100644 index 00000000000..2a82818593e --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/tls.proto @@ -0,0 +1,78 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.networksecurity.v1; + +import "google/api/field_behavior.proto"; + +option csharp_namespace = "Google.Cloud.NetworkSecurity.V1"; +option go_package = "cloud.google.com/go/networksecurity/apiv1/networksecuritypb;networksecuritypb"; +option java_multiple_files = true; +option java_outer_classname = "TlsProto"; +option java_package = "com.google.cloud.networksecurity.v1"; +option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1"; +option ruby_package = "Google::Cloud::NetworkSecurity::V1"; + +// Specification of the GRPC Endpoint. +message GrpcEndpoint { + // Required. The target URI of the gRPC endpoint. Only UDS path is supported, and + // should start with "unix:". + string target_uri = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Specification of ValidationCA. Defines the mechanism to obtain the +// Certificate Authority certificate to validate the peer certificate. +message ValidationCA { + // The type of certificate provider which provides the CA certificate. + oneof type { + // gRPC specific configuration to access the gRPC server to + // obtain the CA certificate. + GrpcEndpoint grpc_endpoint = 2; + + // The certificate provider instance specification that will be passed to + // the data plane, which will be used to load necessary credential + // information. + CertificateProviderInstance certificate_provider_instance = 3; + } +} + +// Specification of a TLS certificate provider instance. Workloads may have one +// or more CertificateProvider instances (plugins) and one of them is enabled +// and configured by specifying this message. Workloads use the values from this +// message to locate and load the CertificateProvider instance configuration. +message CertificateProviderInstance { + // Required. Plugin instance name, used to locate and load CertificateProvider instance + // configuration. Set to "google_cloud_private_spiffe" to use Certificate + // Authority Service certificate provider instance. + string plugin_instance = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Specification of certificate provider. Defines the mechanism to obtain the +// certificate and private key for peer to peer authentication. +message CertificateProvider { + // The type of certificate provider which provides the certificates and + // private keys. + oneof type { + // gRPC specific configuration to access the gRPC server to + // obtain the cert and private key. + GrpcEndpoint grpc_endpoint = 2; + + // The certificate provider instance specification that will be passed to + // the data plane, which will be used to load necessary credential + // information. + CertificateProviderInstance certificate_provider_instance = 3; + } +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_authorization_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_authorization_policy.js new file mode 100644 index 00000000000..e76bce8bd60 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_authorization_policy.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, authorizationPolicyId, authorizationPolicy) { + // [START networksecurity_v1_generated_NetworkSecurity_CreateAuthorizationPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 of the AuthorizationPolicy. Must be in the + * format `projects/{project}/locations/{location}`. + */ + // const parent = 'abc123' + /** + * Required. Short name of the AuthorizationPolicy resource to be created. + * This value should be 1-63 characters long, containing only + * letters, numbers, hyphens, and underscores, and should not start + * with a number. E.g. "authz_policy". + */ + // const authorizationPolicyId = 'abc123' + /** + * Required. AuthorizationPolicy resource to be created. + */ + // const authorizationPolicy = {} + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callCreateAuthorizationPolicy() { + // Construct request + const request = { + parent, + authorizationPolicyId, + authorizationPolicy, + }; + + // Run request + const [operation] = await networksecurityClient.createAuthorizationPolicy(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateAuthorizationPolicy(); + // [END networksecurity_v1_generated_NetworkSecurity_CreateAuthorizationPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_client_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_client_tls_policy.js new file mode 100644 index 00000000000..900a9007bdc --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_client_tls_policy.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, clientTlsPolicyId, clientTlsPolicy) { + // [START networksecurity_v1_generated_NetworkSecurity_CreateClientTlsPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 of the ClientTlsPolicy. Must be in + * the format `projects/* /locations/{location}`. + */ + // const parent = 'abc123' + /** + * Required. Short name of the ClientTlsPolicy resource to be created. This value should + * be 1-63 characters long, containing only letters, numbers, hyphens, and + * underscores, and should not start with a number. E.g. "client_mtls_policy". + */ + // const clientTlsPolicyId = 'abc123' + /** + * Required. ClientTlsPolicy resource to be created. + */ + // const clientTlsPolicy = {} + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callCreateClientTlsPolicy() { + // Construct request + const request = { + parent, + clientTlsPolicyId, + clientTlsPolicy, + }; + + // Run request + const [operation] = await networksecurityClient.createClientTlsPolicy(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateClientTlsPolicy(); + // [END networksecurity_v1_generated_NetworkSecurity_CreateClientTlsPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_server_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_server_tls_policy.js new file mode 100644 index 00000000000..ba11efbdcfc --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_server_tls_policy.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, serverTlsPolicyId, serverTlsPolicy) { + // [START networksecurity_v1_generated_NetworkSecurity_CreateServerTlsPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 of the ServerTlsPolicy. Must be in + * the format `projects/* /locations/{location}`. + */ + // const parent = 'abc123' + /** + * Required. Short name of the ServerTlsPolicy resource to be created. This value should + * be 1-63 characters long, containing only letters, numbers, hyphens, and + * underscores, and should not start with a number. E.g. "server_mtls_policy". + */ + // const serverTlsPolicyId = 'abc123' + /** + * Required. ServerTlsPolicy resource to be created. + */ + // const serverTlsPolicy = {} + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callCreateServerTlsPolicy() { + // Construct request + const request = { + parent, + serverTlsPolicyId, + serverTlsPolicy, + }; + + // Run request + const [operation] = await networksecurityClient.createServerTlsPolicy(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateServerTlsPolicy(); + // [END networksecurity_v1_generated_NetworkSecurity_CreateServerTlsPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_authorization_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_authorization_policy.js new file mode 100644 index 00000000000..3dcd0431ac9 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_authorization_policy.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 networksecurity_v1_generated_NetworkSecurity_DeleteAuthorizationPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A name of the AuthorizationPolicy to delete. Must be in the format + * `projects/{project}/locations/{location}/authorizationPolicies/*`. + */ + // const name = 'abc123' + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callDeleteAuthorizationPolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await networksecurityClient.deleteAuthorizationPolicy(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteAuthorizationPolicy(); + // [END networksecurity_v1_generated_NetworkSecurity_DeleteAuthorizationPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_client_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_client_tls_policy.js new file mode 100644 index 00000000000..9ece970e232 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_client_tls_policy.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 networksecurity_v1_generated_NetworkSecurity_DeleteClientTlsPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A name of the ClientTlsPolicy to delete. Must be in + * the format `projects/* /locations/{location}/clientTlsPolicies/*`. + */ + // const name = 'abc123' + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callDeleteClientTlsPolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await networksecurityClient.deleteClientTlsPolicy(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteClientTlsPolicy(); + // [END networksecurity_v1_generated_NetworkSecurity_DeleteClientTlsPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_server_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_server_tls_policy.js new file mode 100644 index 00000000000..2e2be0db04a --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_server_tls_policy.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 networksecurity_v1_generated_NetworkSecurity_DeleteServerTlsPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A name of the ServerTlsPolicy to delete. Must be in + * the format `projects/* /locations/{location}/serverTlsPolicies/*`. + */ + // const name = 'abc123' + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callDeleteServerTlsPolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await networksecurityClient.deleteServerTlsPolicy(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteServerTlsPolicy(); + // [END networksecurity_v1_generated_NetworkSecurity_DeleteServerTlsPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_authorization_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_authorization_policy.js new file mode 100644 index 00000000000..991d4b08055 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_authorization_policy.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 networksecurity_v1_generated_NetworkSecurity_GetAuthorizationPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A name of the AuthorizationPolicy to get. Must be in the format + * `projects/{project}/locations/{location}/authorizationPolicies/*`. + */ + // const name = 'abc123' + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callGetAuthorizationPolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await networksecurityClient.getAuthorizationPolicy(request); + console.log(response); + } + + callGetAuthorizationPolicy(); + // [END networksecurity_v1_generated_NetworkSecurity_GetAuthorizationPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_client_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_client_tls_policy.js new file mode 100644 index 00000000000..7c73d75f68f --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_client_tls_policy.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 networksecurity_v1_generated_NetworkSecurity_GetClientTlsPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A name of the ClientTlsPolicy to get. Must be in the format + * `projects/* /locations/{location}/clientTlsPolicies/*`. + */ + // const name = 'abc123' + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callGetClientTlsPolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await networksecurityClient.getClientTlsPolicy(request); + console.log(response); + } + + callGetClientTlsPolicy(); + // [END networksecurity_v1_generated_NetworkSecurity_GetClientTlsPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_server_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_server_tls_policy.js new file mode 100644 index 00000000000..33054403c72 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_server_tls_policy.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 networksecurity_v1_generated_NetworkSecurity_GetServerTlsPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A name of the ServerTlsPolicy to get. Must be in the format + * `projects/* /locations/{location}/serverTlsPolicies/*`. + */ + // const name = 'abc123' + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callGetServerTlsPolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await networksecurityClient.getServerTlsPolicy(request); + console.log(response); + } + + callGetServerTlsPolicy(); + // [END networksecurity_v1_generated_NetworkSecurity_GetServerTlsPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_authorization_policies.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_authorization_policies.js new file mode 100644 index 00000000000..e8f0b461843 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_authorization_policies.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) { + // [START networksecurity_v1_generated_NetworkSecurity_ListAuthorizationPolicies_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project and location from which the AuthorizationPolicies + * should be listed, specified in the format + * `projects/{project}/locations/{location}`. + */ + // const parent = 'abc123' + /** + * Maximum number of AuthorizationPolicies to return per call. + */ + // const pageSize = 1234 + /** + * The value returned by the last + * `ListAuthorizationPoliciesResponse` Indicates that this is a + * continuation of a prior `ListAuthorizationPolicies` call, and + * that the system should return the next page of data. + */ + // const pageToken = 'abc123' + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callListAuthorizationPolicies() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await networksecurityClient.listAuthorizationPoliciesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListAuthorizationPolicies(); + // [END networksecurity_v1_generated_NetworkSecurity_ListAuthorizationPolicies_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_client_tls_policies.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_client_tls_policies.js new file mode 100644 index 00000000000..fbc5b008e6b --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_client_tls_policies.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 networksecurity_v1_generated_NetworkSecurity_ListClientTlsPolicies_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project and location from which the ClientTlsPolicies should + * be listed, specified in the format `projects/* /locations/{location}`. + */ + // const parent = 'abc123' + /** + * Maximum number of ClientTlsPolicies to return per call. + */ + // const pageSize = 1234 + /** + * The value returned by the last `ListClientTlsPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListClientTlsPolicies` call, and that the system + * should return the next page of data. + */ + // const pageToken = 'abc123' + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callListClientTlsPolicies() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await networksecurityClient.listClientTlsPoliciesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListClientTlsPolicies(); + // [END networksecurity_v1_generated_NetworkSecurity_ListClientTlsPolicies_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_server_tls_policies.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_server_tls_policies.js new file mode 100644 index 00000000000..ca346255795 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_server_tls_policies.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 networksecurity_v1_generated_NetworkSecurity_ListServerTlsPolicies_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project and location from which the ServerTlsPolicies should + * be listed, specified in the format `projects/* /locations/{location}`. + */ + // const parent = 'abc123' + /** + * Maximum number of ServerTlsPolicies to return per call. + */ + // const pageSize = 1234 + /** + * The value returned by the last `ListServerTlsPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListServerTlsPolicies` call, and that the system + * should return the next page of data. + */ + // const pageToken = 'abc123' + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callListServerTlsPolicies() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await networksecurityClient.listServerTlsPoliciesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListServerTlsPolicies(); + // [END networksecurity_v1_generated_NetworkSecurity_ListServerTlsPolicies_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_authorization_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_authorization_policy.js new file mode 100644 index 00000000000..218edc063d0 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_authorization_policy.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(authorizationPolicy) { + // [START networksecurity_v1_generated_NetworkSecurity_UpdateAuthorizationPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Optional. Field mask is used to specify the fields to be overwritten in the + * AuthorizationPolicy resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + */ + // const updateMask = {} + /** + * Required. Updated AuthorizationPolicy resource. + */ + // const authorizationPolicy = {} + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callUpdateAuthorizationPolicy() { + // Construct request + const request = { + authorizationPolicy, + }; + + // Run request + const [operation] = await networksecurityClient.updateAuthorizationPolicy(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateAuthorizationPolicy(); + // [END networksecurity_v1_generated_NetworkSecurity_UpdateAuthorizationPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_client_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_client_tls_policy.js new file mode 100644 index 00000000000..9a75111060d --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_client_tls_policy.js @@ -0,0 +1,71 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(clientTlsPolicy) { + // [START networksecurity_v1_generated_NetworkSecurity_UpdateClientTlsPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Optional. Field mask is used to specify the fields to be overwritten in the + * ClientTlsPolicy resource by the update. The fields + * specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the + * mask. If the user does not provide a mask then all fields will be + * overwritten. + */ + // const updateMask = {} + /** + * Required. Updated ClientTlsPolicy resource. + */ + // const clientTlsPolicy = {} + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callUpdateClientTlsPolicy() { + // Construct request + const request = { + clientTlsPolicy, + }; + + // Run request + const [operation] = await networksecurityClient.updateClientTlsPolicy(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateClientTlsPolicy(); + // [END networksecurity_v1_generated_NetworkSecurity_UpdateClientTlsPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_server_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_server_tls_policy.js new file mode 100644 index 00000000000..713f138f1af --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_server_tls_policy.js @@ -0,0 +1,71 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(serverTlsPolicy) { + // [START networksecurity_v1_generated_NetworkSecurity_UpdateServerTlsPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Optional. Field mask is used to specify the fields to be overwritten in the + * ServerTlsPolicy resource by the update. The fields + * specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the + * mask. If the user does not provide a mask then all fields will be + * overwritten. + */ + // const updateMask = {} + /** + * Required. Updated ServerTlsPolicy resource. + */ + // const serverTlsPolicy = {} + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callUpdateServerTlsPolicy() { + // Construct request + const request = { + serverTlsPolicy, + }; + + // Run request + const [operation] = await networksecurityClient.updateServerTlsPolicy(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateServerTlsPolicy(); + // [END networksecurity_v1_generated_NetworkSecurity_UpdateServerTlsPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/snippet_metadata_google.cloud.networksecurity.v1.json b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/snippet_metadata_google.cloud.networksecurity.v1.json new file mode 100644 index 00000000000..ee181262eaa --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/snippet_metadata_google.cloud.networksecurity.v1.json @@ -0,0 +1,675 @@ +{ + "clientLibrary": { + "name": "nodejs-networksecurity", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.networksecurity.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "networksecurity_v1_generated_NetworkSecurity_ListAuthorizationPolicies_async", + "title": "NetworkSecurity listAuthorizationPolicies Sample", + "origin": "API_DEFINITION", + "description": " Lists AuthorizationPolicies in a given project and location.", + "canonical": true, + "file": "network_security.list_authorization_policies.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListAuthorizationPolicies", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.ListAuthorizationPolicies", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.networksecurity.v1.ListAuthorizationPoliciesResponse", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" + }, + "method": { + "shortName": "ListAuthorizationPolicies", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.ListAuthorizationPolicies", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1_generated_NetworkSecurity_GetAuthorizationPolicy_async", + "title": "NetworkSecurity getAuthorizationPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets details of a single AuthorizationPolicy.", + "canonical": true, + "file": "network_security.get_authorization_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetAuthorizationPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.GetAuthorizationPolicy", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.networksecurity.v1.AuthorizationPolicy", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" + }, + "method": { + "shortName": "GetAuthorizationPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.GetAuthorizationPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1_generated_NetworkSecurity_CreateAuthorizationPolicy_async", + "title": "NetworkSecurity createAuthorizationPolicy Sample", + "origin": "API_DEFINITION", + "description": " Creates a new AuthorizationPolicy in a given project and location.", + "canonical": true, + "file": "network_security.create_authorization_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateAuthorizationPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.CreateAuthorizationPolicy", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "authorization_policy_id", + "type": "TYPE_STRING" + }, + { + "name": "authorization_policy", + "type": ".google.cloud.networksecurity.v1.AuthorizationPolicy" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" + }, + "method": { + "shortName": "CreateAuthorizationPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.CreateAuthorizationPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1_generated_NetworkSecurity_UpdateAuthorizationPolicy_async", + "title": "NetworkSecurity updateAuthorizationPolicy Sample", + "origin": "API_DEFINITION", + "description": " Updates the parameters of a single AuthorizationPolicy.", + "canonical": true, + "file": "network_security.update_authorization_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateAuthorizationPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.UpdateAuthorizationPolicy", + "async": true, + "parameters": [ + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "authorization_policy", + "type": ".google.cloud.networksecurity.v1.AuthorizationPolicy" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" + }, + "method": { + "shortName": "UpdateAuthorizationPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.UpdateAuthorizationPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1_generated_NetworkSecurity_DeleteAuthorizationPolicy_async", + "title": "NetworkSecurity deleteAuthorizationPolicy Sample", + "origin": "API_DEFINITION", + "description": " Deletes a single AuthorizationPolicy.", + "canonical": true, + "file": "network_security.delete_authorization_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteAuthorizationPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.DeleteAuthorizationPolicy", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" + }, + "method": { + "shortName": "DeleteAuthorizationPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.DeleteAuthorizationPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1_generated_NetworkSecurity_ListServerTlsPolicies_async", + "title": "NetworkSecurity listServerTlsPolicies Sample", + "origin": "API_DEFINITION", + "description": " Lists ServerTlsPolicies in a given project and location.", + "canonical": true, + "file": "network_security.list_server_tls_policies.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListServerTlsPolicies", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.ListServerTlsPolicies", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.networksecurity.v1.ListServerTlsPoliciesResponse", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" + }, + "method": { + "shortName": "ListServerTlsPolicies", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.ListServerTlsPolicies", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1_generated_NetworkSecurity_GetServerTlsPolicy_async", + "title": "NetworkSecurity getServerTlsPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets details of a single ServerTlsPolicy.", + "canonical": true, + "file": "network_security.get_server_tls_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetServerTlsPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.GetServerTlsPolicy", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.networksecurity.v1.ServerTlsPolicy", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" + }, + "method": { + "shortName": "GetServerTlsPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.GetServerTlsPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1_generated_NetworkSecurity_CreateServerTlsPolicy_async", + "title": "NetworkSecurity createServerTlsPolicy Sample", + "origin": "API_DEFINITION", + "description": " Creates a new ServerTlsPolicy in a given project and location.", + "canonical": true, + "file": "network_security.create_server_tls_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateServerTlsPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.CreateServerTlsPolicy", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "server_tls_policy_id", + "type": "TYPE_STRING" + }, + { + "name": "server_tls_policy", + "type": ".google.cloud.networksecurity.v1.ServerTlsPolicy" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" + }, + "method": { + "shortName": "CreateServerTlsPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.CreateServerTlsPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1_generated_NetworkSecurity_UpdateServerTlsPolicy_async", + "title": "NetworkSecurity updateServerTlsPolicy Sample", + "origin": "API_DEFINITION", + "description": " Updates the parameters of a single ServerTlsPolicy.", + "canonical": true, + "file": "network_security.update_server_tls_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateServerTlsPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.UpdateServerTlsPolicy", + "async": true, + "parameters": [ + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "server_tls_policy", + "type": ".google.cloud.networksecurity.v1.ServerTlsPolicy" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" + }, + "method": { + "shortName": "UpdateServerTlsPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.UpdateServerTlsPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1_generated_NetworkSecurity_DeleteServerTlsPolicy_async", + "title": "NetworkSecurity deleteServerTlsPolicy Sample", + "origin": "API_DEFINITION", + "description": " Deletes a single ServerTlsPolicy.", + "canonical": true, + "file": "network_security.delete_server_tls_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteServerTlsPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.DeleteServerTlsPolicy", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" + }, + "method": { + "shortName": "DeleteServerTlsPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.DeleteServerTlsPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1_generated_NetworkSecurity_ListClientTlsPolicies_async", + "title": "NetworkSecurity listClientTlsPolicies Sample", + "origin": "API_DEFINITION", + "description": " Lists ClientTlsPolicies in a given project and location.", + "canonical": true, + "file": "network_security.list_client_tls_policies.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListClientTlsPolicies", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.ListClientTlsPolicies", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.networksecurity.v1.ListClientTlsPoliciesResponse", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" + }, + "method": { + "shortName": "ListClientTlsPolicies", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.ListClientTlsPolicies", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1_generated_NetworkSecurity_GetClientTlsPolicy_async", + "title": "NetworkSecurity getClientTlsPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets details of a single ClientTlsPolicy.", + "canonical": true, + "file": "network_security.get_client_tls_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetClientTlsPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.GetClientTlsPolicy", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.networksecurity.v1.ClientTlsPolicy", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" + }, + "method": { + "shortName": "GetClientTlsPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.GetClientTlsPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1_generated_NetworkSecurity_CreateClientTlsPolicy_async", + "title": "NetworkSecurity createClientTlsPolicy Sample", + "origin": "API_DEFINITION", + "description": " Creates a new ClientTlsPolicy in a given project and location.", + "canonical": true, + "file": "network_security.create_client_tls_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateClientTlsPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.CreateClientTlsPolicy", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "client_tls_policy_id", + "type": "TYPE_STRING" + }, + { + "name": "client_tls_policy", + "type": ".google.cloud.networksecurity.v1.ClientTlsPolicy" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" + }, + "method": { + "shortName": "CreateClientTlsPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.CreateClientTlsPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1_generated_NetworkSecurity_UpdateClientTlsPolicy_async", + "title": "NetworkSecurity updateClientTlsPolicy Sample", + "origin": "API_DEFINITION", + "description": " Updates the parameters of a single ClientTlsPolicy.", + "canonical": true, + "file": "network_security.update_client_tls_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateClientTlsPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.UpdateClientTlsPolicy", + "async": true, + "parameters": [ + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "client_tls_policy", + "type": ".google.cloud.networksecurity.v1.ClientTlsPolicy" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" + }, + "method": { + "shortName": "UpdateClientTlsPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.UpdateClientTlsPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1_generated_NetworkSecurity_DeleteClientTlsPolicy_async", + "title": "NetworkSecurity deleteClientTlsPolicy Sample", + "origin": "API_DEFINITION", + "description": " Deletes a single ClientTlsPolicy.", + "canonical": true, + "file": "network_security.delete_client_tls_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteClientTlsPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.DeleteClientTlsPolicy", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" + }, + "method": { + "shortName": "DeleteClientTlsPolicy", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.DeleteClientTlsPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/src/index.ts b/owl-bot-staging/google-cloud-networksecurity/v1/src/index.ts new file mode 100644 index 00000000000..67aad02cedc --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const NetworkSecurityClient = v1.NetworkSecurityClient; +type NetworkSecurityClient = v1.NetworkSecurityClient; +export {v1, NetworkSecurityClient}; +export default {v1, NetworkSecurityClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..af9154fe63b --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/gapic_metadata.json @@ -0,0 +1,185 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.networksecurity.v1", + "libraryPackage": "@google-cloud/networksecurity", + "services": { + "NetworkSecurity": { + "clients": { + "grpc": { + "libraryClient": "NetworkSecurityClient", + "rpcs": { + "GetAuthorizationPolicy": { + "methods": [ + "getAuthorizationPolicy" + ] + }, + "GetServerTlsPolicy": { + "methods": [ + "getServerTlsPolicy" + ] + }, + "GetClientTlsPolicy": { + "methods": [ + "getClientTlsPolicy" + ] + }, + "CreateAuthorizationPolicy": { + "methods": [ + "createAuthorizationPolicy" + ] + }, + "UpdateAuthorizationPolicy": { + "methods": [ + "updateAuthorizationPolicy" + ] + }, + "DeleteAuthorizationPolicy": { + "methods": [ + "deleteAuthorizationPolicy" + ] + }, + "CreateServerTlsPolicy": { + "methods": [ + "createServerTlsPolicy" + ] + }, + "UpdateServerTlsPolicy": { + "methods": [ + "updateServerTlsPolicy" + ] + }, + "DeleteServerTlsPolicy": { + "methods": [ + "deleteServerTlsPolicy" + ] + }, + "CreateClientTlsPolicy": { + "methods": [ + "createClientTlsPolicy" + ] + }, + "UpdateClientTlsPolicy": { + "methods": [ + "updateClientTlsPolicy" + ] + }, + "DeleteClientTlsPolicy": { + "methods": [ + "deleteClientTlsPolicy" + ] + }, + "ListAuthorizationPolicies": { + "methods": [ + "listAuthorizationPolicies", + "listAuthorizationPoliciesStream", + "listAuthorizationPoliciesAsync" + ] + }, + "ListServerTlsPolicies": { + "methods": [ + "listServerTlsPolicies", + "listServerTlsPoliciesStream", + "listServerTlsPoliciesAsync" + ] + }, + "ListClientTlsPolicies": { + "methods": [ + "listClientTlsPolicies", + "listClientTlsPoliciesStream", + "listClientTlsPoliciesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "NetworkSecurityClient", + "rpcs": { + "GetAuthorizationPolicy": { + "methods": [ + "getAuthorizationPolicy" + ] + }, + "GetServerTlsPolicy": { + "methods": [ + "getServerTlsPolicy" + ] + }, + "GetClientTlsPolicy": { + "methods": [ + "getClientTlsPolicy" + ] + }, + "CreateAuthorizationPolicy": { + "methods": [ + "createAuthorizationPolicy" + ] + }, + "UpdateAuthorizationPolicy": { + "methods": [ + "updateAuthorizationPolicy" + ] + }, + "DeleteAuthorizationPolicy": { + "methods": [ + "deleteAuthorizationPolicy" + ] + }, + "CreateServerTlsPolicy": { + "methods": [ + "createServerTlsPolicy" + ] + }, + "UpdateServerTlsPolicy": { + "methods": [ + "updateServerTlsPolicy" + ] + }, + "DeleteServerTlsPolicy": { + "methods": [ + "deleteServerTlsPolicy" + ] + }, + "CreateClientTlsPolicy": { + "methods": [ + "createClientTlsPolicy" + ] + }, + "UpdateClientTlsPolicy": { + "methods": [ + "updateClientTlsPolicy" + ] + }, + "DeleteClientTlsPolicy": { + "methods": [ + "deleteClientTlsPolicy" + ] + }, + "ListAuthorizationPolicies": { + "methods": [ + "listAuthorizationPolicies", + "listAuthorizationPoliciesStream", + "listAuthorizationPoliciesAsync" + ] + }, + "ListServerTlsPolicies": { + "methods": [ + "listServerTlsPolicies", + "listServerTlsPoliciesStream", + "listServerTlsPoliciesAsync" + ] + }, + "ListClientTlsPolicies": { + "methods": [ + "listClientTlsPolicies", + "listClientTlsPoliciesStream", + "listClientTlsPoliciesAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/index.ts new file mode 100644 index 00000000000..e2b4efdd9b3 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {NetworkSecurityClient} from './network_security_client'; diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_client.ts b/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_client.ts new file mode 100644 index 00000000000..d4576d88671 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_client.ts @@ -0,0 +1,2592 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/network_security_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './network_security_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Network Security API provides resources to configure authentication and + * authorization policies. Refer to per API resource documentation for more + * information. + * @class + * @memberof v1 + */ +export class NetworkSecurityClient { + 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}; + iamClient: IamClient; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + networkSecurityStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of NetworkSecurityClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 NetworkSecurityClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof NetworkSecurityClient; + 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.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); + + 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 { + 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 = { + authorizationPolicyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/authorizationPolicies/{authorization_policy}' + ), + clientTlsPolicyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/clientTlsPolicies/{client_tls_policy}' + ), + serverTlsPolicyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/serverTlsPolicies/{server_tls_policy}' + ), + }; + + // 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 = { + listAuthorizationPolicies: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'authorizationPolicies'), + listServerTlsPolicies: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'serverTlsPolicies'), + listClientTlsPolicies: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'clientTlsPolicies') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/*/authorizationPolicies/*}:getIamPolicy',additional_bindings: [{get: '/v1/{resource=projects/*/locations/*/serverTlsPolicies/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/clientTlsPolicies/*}:getIamPolicy',}], + },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/*/authorizationPolicies/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/serverTlsPolicies/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/clientTlsPolicies/*}:setIamPolicy',body: '*',}], + },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/*/authorizationPolicies/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/serverTlsPolicies/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/clientTlsPolicies/*}:testIamPermissions',body: '*',}], + },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createAuthorizationPolicyResponse = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1.AuthorizationPolicy') as gax.protobuf.Type; + const createAuthorizationPolicyMetadata = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1.OperationMetadata') as gax.protobuf.Type; + const updateAuthorizationPolicyResponse = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1.AuthorizationPolicy') as gax.protobuf.Type; + const updateAuthorizationPolicyMetadata = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1.OperationMetadata') as gax.protobuf.Type; + const deleteAuthorizationPolicyResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteAuthorizationPolicyMetadata = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1.OperationMetadata') as gax.protobuf.Type; + const createServerTlsPolicyResponse = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1.ServerTlsPolicy') as gax.protobuf.Type; + const createServerTlsPolicyMetadata = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1.OperationMetadata') as gax.protobuf.Type; + const updateServerTlsPolicyResponse = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1.ServerTlsPolicy') as gax.protobuf.Type; + const updateServerTlsPolicyMetadata = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1.OperationMetadata') as gax.protobuf.Type; + const deleteServerTlsPolicyResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteServerTlsPolicyMetadata = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1.OperationMetadata') as gax.protobuf.Type; + const createClientTlsPolicyResponse = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1.ClientTlsPolicy') as gax.protobuf.Type; + const createClientTlsPolicyMetadata = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1.OperationMetadata') as gax.protobuf.Type; + const updateClientTlsPolicyResponse = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1.ClientTlsPolicy') as gax.protobuf.Type; + const updateClientTlsPolicyMetadata = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1.OperationMetadata') as gax.protobuf.Type; + const deleteClientTlsPolicyResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteClientTlsPolicyMetadata = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createAuthorizationPolicy: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createAuthorizationPolicyResponse.decode.bind(createAuthorizationPolicyResponse), + createAuthorizationPolicyMetadata.decode.bind(createAuthorizationPolicyMetadata)), + updateAuthorizationPolicy: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateAuthorizationPolicyResponse.decode.bind(updateAuthorizationPolicyResponse), + updateAuthorizationPolicyMetadata.decode.bind(updateAuthorizationPolicyMetadata)), + deleteAuthorizationPolicy: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteAuthorizationPolicyResponse.decode.bind(deleteAuthorizationPolicyResponse), + deleteAuthorizationPolicyMetadata.decode.bind(deleteAuthorizationPolicyMetadata)), + createServerTlsPolicy: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createServerTlsPolicyResponse.decode.bind(createServerTlsPolicyResponse), + createServerTlsPolicyMetadata.decode.bind(createServerTlsPolicyMetadata)), + updateServerTlsPolicy: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateServerTlsPolicyResponse.decode.bind(updateServerTlsPolicyResponse), + updateServerTlsPolicyMetadata.decode.bind(updateServerTlsPolicyMetadata)), + deleteServerTlsPolicy: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteServerTlsPolicyResponse.decode.bind(deleteServerTlsPolicyResponse), + deleteServerTlsPolicyMetadata.decode.bind(deleteServerTlsPolicyMetadata)), + createClientTlsPolicy: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createClientTlsPolicyResponse.decode.bind(createClientTlsPolicyResponse), + createClientTlsPolicyMetadata.decode.bind(createClientTlsPolicyMetadata)), + updateClientTlsPolicy: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateClientTlsPolicyResponse.decode.bind(updateClientTlsPolicyResponse), + updateClientTlsPolicyMetadata.decode.bind(updateClientTlsPolicyMetadata)), + deleteClientTlsPolicy: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteClientTlsPolicyResponse.decode.bind(deleteClientTlsPolicyResponse), + deleteClientTlsPolicyMetadata.decode.bind(deleteClientTlsPolicyMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.networksecurity.v1.NetworkSecurity', 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.networkSecurityStub) { + return this.networkSecurityStub; + } + + // Put together the "service stub" for + // google.cloud.networksecurity.v1.NetworkSecurity. + this.networkSecurityStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.networksecurity.v1.NetworkSecurity') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.networksecurity.v1.NetworkSecurity, + 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 networkSecurityStubMethods = + ['listAuthorizationPolicies', 'getAuthorizationPolicy', 'createAuthorizationPolicy', 'updateAuthorizationPolicy', 'deleteAuthorizationPolicy', 'listServerTlsPolicies', 'getServerTlsPolicy', 'createServerTlsPolicy', 'updateServerTlsPolicy', 'deleteServerTlsPolicy', 'listClientTlsPolicies', 'getClientTlsPolicy', 'createClientTlsPolicy', 'updateClientTlsPolicy', 'deleteClientTlsPolicy']; + for (const methodName of networkSecurityStubMethods) { + const callPromise = this.networkSecurityStub.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.networkSecurityStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'networksecurity.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 'networksecurity.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 details of a single AuthorizationPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the AuthorizationPolicy to get. Must be in the format + * `projects/{project}/locations/{location}/authorizationPolicies/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.networksecurity.v1.AuthorizationPolicy|AuthorizationPolicy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.get_authorization_policy.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_GetAuthorizationPolicy_async + */ + getAuthorizationPolicy( + request?: protos.google.cloud.networksecurity.v1.IGetAuthorizationPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.networksecurity.v1.IAuthorizationPolicy, + protos.google.cloud.networksecurity.v1.IGetAuthorizationPolicyRequest|undefined, {}|undefined + ]>; + getAuthorizationPolicy( + request: protos.google.cloud.networksecurity.v1.IGetAuthorizationPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networksecurity.v1.IAuthorizationPolicy, + protos.google.cloud.networksecurity.v1.IGetAuthorizationPolicyRequest|null|undefined, + {}|null|undefined>): void; + getAuthorizationPolicy( + request: protos.google.cloud.networksecurity.v1.IGetAuthorizationPolicyRequest, + callback: Callback< + protos.google.cloud.networksecurity.v1.IAuthorizationPolicy, + protos.google.cloud.networksecurity.v1.IGetAuthorizationPolicyRequest|null|undefined, + {}|null|undefined>): void; + getAuthorizationPolicy( + request?: protos.google.cloud.networksecurity.v1.IGetAuthorizationPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.networksecurity.v1.IAuthorizationPolicy, + protos.google.cloud.networksecurity.v1.IGetAuthorizationPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.networksecurity.v1.IAuthorizationPolicy, + protos.google.cloud.networksecurity.v1.IGetAuthorizationPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.networksecurity.v1.IAuthorizationPolicy, + protos.google.cloud.networksecurity.v1.IGetAuthorizationPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getAuthorizationPolicy(request, options, callback); + } +/** + * Gets details of a single ServerTlsPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the ServerTlsPolicy to get. Must be in the format + * `projects/* /locations/{location}/serverTlsPolicies/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.networksecurity.v1.ServerTlsPolicy|ServerTlsPolicy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.get_server_tls_policy.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_GetServerTlsPolicy_async + */ + getServerTlsPolicy( + request?: protos.google.cloud.networksecurity.v1.IGetServerTlsPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.networksecurity.v1.IServerTlsPolicy, + protos.google.cloud.networksecurity.v1.IGetServerTlsPolicyRequest|undefined, {}|undefined + ]>; + getServerTlsPolicy( + request: protos.google.cloud.networksecurity.v1.IGetServerTlsPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networksecurity.v1.IServerTlsPolicy, + protos.google.cloud.networksecurity.v1.IGetServerTlsPolicyRequest|null|undefined, + {}|null|undefined>): void; + getServerTlsPolicy( + request: protos.google.cloud.networksecurity.v1.IGetServerTlsPolicyRequest, + callback: Callback< + protos.google.cloud.networksecurity.v1.IServerTlsPolicy, + protos.google.cloud.networksecurity.v1.IGetServerTlsPolicyRequest|null|undefined, + {}|null|undefined>): void; + getServerTlsPolicy( + request?: protos.google.cloud.networksecurity.v1.IGetServerTlsPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.networksecurity.v1.IServerTlsPolicy, + protos.google.cloud.networksecurity.v1.IGetServerTlsPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.networksecurity.v1.IServerTlsPolicy, + protos.google.cloud.networksecurity.v1.IGetServerTlsPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.networksecurity.v1.IServerTlsPolicy, + protos.google.cloud.networksecurity.v1.IGetServerTlsPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getServerTlsPolicy(request, options, callback); + } +/** + * Gets details of a single ClientTlsPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the ClientTlsPolicy to get. Must be in the format + * `projects/* /locations/{location}/clientTlsPolicies/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.networksecurity.v1.ClientTlsPolicy|ClientTlsPolicy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.get_client_tls_policy.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_GetClientTlsPolicy_async + */ + getClientTlsPolicy( + request?: protos.google.cloud.networksecurity.v1.IGetClientTlsPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.networksecurity.v1.IClientTlsPolicy, + protos.google.cloud.networksecurity.v1.IGetClientTlsPolicyRequest|undefined, {}|undefined + ]>; + getClientTlsPolicy( + request: protos.google.cloud.networksecurity.v1.IGetClientTlsPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networksecurity.v1.IClientTlsPolicy, + protos.google.cloud.networksecurity.v1.IGetClientTlsPolicyRequest|null|undefined, + {}|null|undefined>): void; + getClientTlsPolicy( + request: protos.google.cloud.networksecurity.v1.IGetClientTlsPolicyRequest, + callback: Callback< + protos.google.cloud.networksecurity.v1.IClientTlsPolicy, + protos.google.cloud.networksecurity.v1.IGetClientTlsPolicyRequest|null|undefined, + {}|null|undefined>): void; + getClientTlsPolicy( + request?: protos.google.cloud.networksecurity.v1.IGetClientTlsPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.networksecurity.v1.IClientTlsPolicy, + protos.google.cloud.networksecurity.v1.IGetClientTlsPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.networksecurity.v1.IClientTlsPolicy, + protos.google.cloud.networksecurity.v1.IGetClientTlsPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.networksecurity.v1.IClientTlsPolicy, + protos.google.cloud.networksecurity.v1.IGetClientTlsPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getClientTlsPolicy(request, options, callback); + } + +/** + * Creates a new AuthorizationPolicy in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the AuthorizationPolicy. Must be in the + * format `projects/{project}/locations/{location}`. + * @param {string} request.authorizationPolicyId + * Required. Short name of the AuthorizationPolicy resource to be created. + * This value should be 1-63 characters long, containing only + * letters, numbers, hyphens, and underscores, and should not start + * with a number. E.g. "authz_policy". + * @param {google.cloud.networksecurity.v1.AuthorizationPolicy} request.authorizationPolicy + * Required. AuthorizationPolicy resource to be created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.create_authorization_policy.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_CreateAuthorizationPolicy_async + */ + createAuthorizationPolicy( + request?: protos.google.cloud.networksecurity.v1.ICreateAuthorizationPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createAuthorizationPolicy( + request: protos.google.cloud.networksecurity.v1.ICreateAuthorizationPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createAuthorizationPolicy( + request: protos.google.cloud.networksecurity.v1.ICreateAuthorizationPolicyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createAuthorizationPolicy( + request?: protos.google.cloud.networksecurity.v1.ICreateAuthorizationPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createAuthorizationPolicy(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createAuthorizationPolicy()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.create_authorization_policy.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_CreateAuthorizationPolicy_async + */ + async checkCreateAuthorizationPolicyProgress(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.createAuthorizationPolicy, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the parameters of a single AuthorizationPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * AuthorizationPolicy resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.networksecurity.v1.AuthorizationPolicy} request.authorizationPolicy + * Required. Updated AuthorizationPolicy resource. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.update_authorization_policy.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_UpdateAuthorizationPolicy_async + */ + updateAuthorizationPolicy( + request?: protos.google.cloud.networksecurity.v1.IUpdateAuthorizationPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateAuthorizationPolicy( + request: protos.google.cloud.networksecurity.v1.IUpdateAuthorizationPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateAuthorizationPolicy( + request: protos.google.cloud.networksecurity.v1.IUpdateAuthorizationPolicyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateAuthorizationPolicy( + request?: protos.google.cloud.networksecurity.v1.IUpdateAuthorizationPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'authorization_policy.name': request.authorizationPolicy!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateAuthorizationPolicy(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateAuthorizationPolicy()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.update_authorization_policy.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_UpdateAuthorizationPolicy_async + */ + async checkUpdateAuthorizationPolicyProgress(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.updateAuthorizationPolicy, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a single AuthorizationPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the AuthorizationPolicy to delete. Must be in the format + * `projects/{project}/locations/{location}/authorizationPolicies/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.delete_authorization_policy.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_DeleteAuthorizationPolicy_async + */ + deleteAuthorizationPolicy( + request?: protos.google.cloud.networksecurity.v1.IDeleteAuthorizationPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteAuthorizationPolicy( + request: protos.google.cloud.networksecurity.v1.IDeleteAuthorizationPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteAuthorizationPolicy( + request: protos.google.cloud.networksecurity.v1.IDeleteAuthorizationPolicyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteAuthorizationPolicy( + request?: protos.google.cloud.networksecurity.v1.IDeleteAuthorizationPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteAuthorizationPolicy(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteAuthorizationPolicy()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.delete_authorization_policy.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_DeleteAuthorizationPolicy_async + */ + async checkDeleteAuthorizationPolicyProgress(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.deleteAuthorizationPolicy, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Creates a new ServerTlsPolicy in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the ServerTlsPolicy. Must be in + * the format `projects/* /locations/{location}`. + * @param {string} request.serverTlsPolicyId + * Required. Short name of the ServerTlsPolicy resource to be created. This value should + * be 1-63 characters long, containing only letters, numbers, hyphens, and + * underscores, and should not start with a number. E.g. "server_mtls_policy". + * @param {google.cloud.networksecurity.v1.ServerTlsPolicy} request.serverTlsPolicy + * Required. ServerTlsPolicy resource to be created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.create_server_tls_policy.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_CreateServerTlsPolicy_async + */ + createServerTlsPolicy( + request?: protos.google.cloud.networksecurity.v1.ICreateServerTlsPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createServerTlsPolicy( + request: protos.google.cloud.networksecurity.v1.ICreateServerTlsPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createServerTlsPolicy( + request: protos.google.cloud.networksecurity.v1.ICreateServerTlsPolicyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createServerTlsPolicy( + request?: protos.google.cloud.networksecurity.v1.ICreateServerTlsPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createServerTlsPolicy(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createServerTlsPolicy()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.create_server_tls_policy.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_CreateServerTlsPolicy_async + */ + async checkCreateServerTlsPolicyProgress(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.createServerTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the parameters of a single ServerTlsPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * ServerTlsPolicy resource by the update. The fields + * specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the + * mask. If the user does not provide a mask then all fields will be + * overwritten. + * @param {google.cloud.networksecurity.v1.ServerTlsPolicy} request.serverTlsPolicy + * Required. Updated ServerTlsPolicy resource. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.update_server_tls_policy.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_UpdateServerTlsPolicy_async + */ + updateServerTlsPolicy( + request?: protos.google.cloud.networksecurity.v1.IUpdateServerTlsPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateServerTlsPolicy( + request: protos.google.cloud.networksecurity.v1.IUpdateServerTlsPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateServerTlsPolicy( + request: protos.google.cloud.networksecurity.v1.IUpdateServerTlsPolicyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateServerTlsPolicy( + request?: protos.google.cloud.networksecurity.v1.IUpdateServerTlsPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'server_tls_policy.name': request.serverTlsPolicy!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateServerTlsPolicy(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateServerTlsPolicy()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.update_server_tls_policy.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_UpdateServerTlsPolicy_async + */ + async checkUpdateServerTlsPolicyProgress(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.updateServerTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a single ServerTlsPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the ServerTlsPolicy to delete. Must be in + * the format `projects/* /locations/{location}/serverTlsPolicies/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.delete_server_tls_policy.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_DeleteServerTlsPolicy_async + */ + deleteServerTlsPolicy( + request?: protos.google.cloud.networksecurity.v1.IDeleteServerTlsPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteServerTlsPolicy( + request: protos.google.cloud.networksecurity.v1.IDeleteServerTlsPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteServerTlsPolicy( + request: protos.google.cloud.networksecurity.v1.IDeleteServerTlsPolicyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteServerTlsPolicy( + request?: protos.google.cloud.networksecurity.v1.IDeleteServerTlsPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteServerTlsPolicy(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteServerTlsPolicy()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.delete_server_tls_policy.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_DeleteServerTlsPolicy_async + */ + async checkDeleteServerTlsPolicyProgress(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.deleteServerTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Creates a new ClientTlsPolicy in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the ClientTlsPolicy. Must be in + * the format `projects/* /locations/{location}`. + * @param {string} request.clientTlsPolicyId + * Required. Short name of the ClientTlsPolicy resource to be created. This value should + * be 1-63 characters long, containing only letters, numbers, hyphens, and + * underscores, and should not start with a number. E.g. "client_mtls_policy". + * @param {google.cloud.networksecurity.v1.ClientTlsPolicy} request.clientTlsPolicy + * Required. ClientTlsPolicy resource to be created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.create_client_tls_policy.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_CreateClientTlsPolicy_async + */ + createClientTlsPolicy( + request?: protos.google.cloud.networksecurity.v1.ICreateClientTlsPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createClientTlsPolicy( + request: protos.google.cloud.networksecurity.v1.ICreateClientTlsPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createClientTlsPolicy( + request: protos.google.cloud.networksecurity.v1.ICreateClientTlsPolicyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createClientTlsPolicy( + request?: protos.google.cloud.networksecurity.v1.ICreateClientTlsPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createClientTlsPolicy(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createClientTlsPolicy()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.create_client_tls_policy.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_CreateClientTlsPolicy_async + */ + async checkCreateClientTlsPolicyProgress(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.createClientTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the parameters of a single ClientTlsPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * ClientTlsPolicy resource by the update. The fields + * specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the + * mask. If the user does not provide a mask then all fields will be + * overwritten. + * @param {google.cloud.networksecurity.v1.ClientTlsPolicy} request.clientTlsPolicy + * Required. Updated ClientTlsPolicy resource. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.update_client_tls_policy.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_UpdateClientTlsPolicy_async + */ + updateClientTlsPolicy( + request?: protos.google.cloud.networksecurity.v1.IUpdateClientTlsPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateClientTlsPolicy( + request: protos.google.cloud.networksecurity.v1.IUpdateClientTlsPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateClientTlsPolicy( + request: protos.google.cloud.networksecurity.v1.IUpdateClientTlsPolicyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateClientTlsPolicy( + request?: protos.google.cloud.networksecurity.v1.IUpdateClientTlsPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'client_tls_policy.name': request.clientTlsPolicy!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateClientTlsPolicy(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateClientTlsPolicy()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.update_client_tls_policy.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_UpdateClientTlsPolicy_async + */ + async checkUpdateClientTlsPolicyProgress(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.updateClientTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a single ClientTlsPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the ClientTlsPolicy to delete. Must be in + * the format `projects/* /locations/{location}/clientTlsPolicies/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.delete_client_tls_policy.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_DeleteClientTlsPolicy_async + */ + deleteClientTlsPolicy( + request?: protos.google.cloud.networksecurity.v1.IDeleteClientTlsPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteClientTlsPolicy( + request: protos.google.cloud.networksecurity.v1.IDeleteClientTlsPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteClientTlsPolicy( + request: protos.google.cloud.networksecurity.v1.IDeleteClientTlsPolicyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteClientTlsPolicy( + request?: protos.google.cloud.networksecurity.v1.IDeleteClientTlsPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteClientTlsPolicy(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteClientTlsPolicy()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.delete_client_tls_policy.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_DeleteClientTlsPolicy_async + */ + async checkDeleteClientTlsPolicyProgress(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.deleteClientTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists AuthorizationPolicies in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the AuthorizationPolicies + * should be listed, specified in the format + * `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * Maximum number of AuthorizationPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last + * `ListAuthorizationPoliciesResponse` Indicates that this is a + * continuation of a prior `ListAuthorizationPolicies` call, and + * that the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.networksecurity.v1.AuthorizationPolicy|AuthorizationPolicy}. + * 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 `listAuthorizationPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listAuthorizationPolicies( + request?: protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.networksecurity.v1.IAuthorizationPolicy[], + protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest|null, + protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesResponse + ]>; + listAuthorizationPolicies( + request: protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest, + protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1.IAuthorizationPolicy>): void; + listAuthorizationPolicies( + request: protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest, + protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1.IAuthorizationPolicy>): void; + listAuthorizationPolicies( + request?: protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest, + protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1.IAuthorizationPolicy>, + callback?: PaginationCallback< + protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest, + protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1.IAuthorizationPolicy>): + Promise<[ + protos.google.cloud.networksecurity.v1.IAuthorizationPolicy[], + protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest|null, + protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listAuthorizationPolicies(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the AuthorizationPolicies + * should be listed, specified in the format + * `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * Maximum number of AuthorizationPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last + * `ListAuthorizationPoliciesResponse` Indicates that this is a + * continuation of a prior `ListAuthorizationPolicies` call, and + * that the system should return the next page of data. + * @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 protos.google.cloud.networksecurity.v1.AuthorizationPolicy|AuthorizationPolicy} 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 `listAuthorizationPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listAuthorizationPoliciesStream( + request?: protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest, + 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['listAuthorizationPolicies']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listAuthorizationPolicies.createStream( + this.innerApiCalls.listAuthorizationPolicies as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listAuthorizationPolicies`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the AuthorizationPolicies + * should be listed, specified in the format + * `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * Maximum number of AuthorizationPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last + * `ListAuthorizationPoliciesResponse` Indicates that this is a + * continuation of a prior `ListAuthorizationPolicies` call, and + * that the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networksecurity.v1.AuthorizationPolicy|AuthorizationPolicy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.list_authorization_policies.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_ListAuthorizationPolicies_async + */ + listAuthorizationPoliciesAsync( + request?: protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest, + 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['listAuthorizationPolicies']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listAuthorizationPolicies.asyncIterate( + this.innerApiCalls['listAuthorizationPolicies'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists ServerTlsPolicies in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the ServerTlsPolicies should + * be listed, specified in the format `projects/* /locations/{location}`. + * @param {number} request.pageSize + * Maximum number of ServerTlsPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListServerTlsPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListServerTlsPolicies` call, and that the system + * should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.networksecurity.v1.ServerTlsPolicy|ServerTlsPolicy}. + * 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 `listServerTlsPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listServerTlsPolicies( + request?: protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.networksecurity.v1.IServerTlsPolicy[], + protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest|null, + protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesResponse + ]>; + listServerTlsPolicies( + request: protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest, + protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1.IServerTlsPolicy>): void; + listServerTlsPolicies( + request: protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest, + protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1.IServerTlsPolicy>): void; + listServerTlsPolicies( + request?: protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest, + protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1.IServerTlsPolicy>, + callback?: PaginationCallback< + protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest, + protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1.IServerTlsPolicy>): + Promise<[ + protos.google.cloud.networksecurity.v1.IServerTlsPolicy[], + protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest|null, + protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listServerTlsPolicies(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the ServerTlsPolicies should + * be listed, specified in the format `projects/* /locations/{location}`. + * @param {number} request.pageSize + * Maximum number of ServerTlsPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListServerTlsPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListServerTlsPolicies` call, and that the system + * should return the next page of data. + * @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 protos.google.cloud.networksecurity.v1.ServerTlsPolicy|ServerTlsPolicy} 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 `listServerTlsPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listServerTlsPoliciesStream( + request?: protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest, + 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['listServerTlsPolicies']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServerTlsPolicies.createStream( + this.innerApiCalls.listServerTlsPolicies as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listServerTlsPolicies`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the ServerTlsPolicies should + * be listed, specified in the format `projects/* /locations/{location}`. + * @param {number} request.pageSize + * Maximum number of ServerTlsPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListServerTlsPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListServerTlsPolicies` call, and that the system + * should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networksecurity.v1.ServerTlsPolicy|ServerTlsPolicy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.list_server_tls_policies.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_ListServerTlsPolicies_async + */ + listServerTlsPoliciesAsync( + request?: protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest, + 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['listServerTlsPolicies']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServerTlsPolicies.asyncIterate( + this.innerApiCalls['listServerTlsPolicies'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists ClientTlsPolicies in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the ClientTlsPolicies should + * be listed, specified in the format `projects/* /locations/{location}`. + * @param {number} request.pageSize + * Maximum number of ClientTlsPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListClientTlsPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListClientTlsPolicies` call, and that the system + * should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.networksecurity.v1.ClientTlsPolicy|ClientTlsPolicy}. + * 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 `listClientTlsPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listClientTlsPolicies( + request?: protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.networksecurity.v1.IClientTlsPolicy[], + protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest|null, + protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesResponse + ]>; + listClientTlsPolicies( + request: protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest, + protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1.IClientTlsPolicy>): void; + listClientTlsPolicies( + request: protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest, + protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1.IClientTlsPolicy>): void; + listClientTlsPolicies( + request?: protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest, + protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1.IClientTlsPolicy>, + callback?: PaginationCallback< + protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest, + protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1.IClientTlsPolicy>): + Promise<[ + protos.google.cloud.networksecurity.v1.IClientTlsPolicy[], + protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest|null, + protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listClientTlsPolicies(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the ClientTlsPolicies should + * be listed, specified in the format `projects/* /locations/{location}`. + * @param {number} request.pageSize + * Maximum number of ClientTlsPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListClientTlsPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListClientTlsPolicies` call, and that the system + * should return the next page of data. + * @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 protos.google.cloud.networksecurity.v1.ClientTlsPolicy|ClientTlsPolicy} 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 `listClientTlsPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listClientTlsPoliciesStream( + request?: protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest, + 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['listClientTlsPolicies']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listClientTlsPolicies.createStream( + this.innerApiCalls.listClientTlsPolicies as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listClientTlsPolicies`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the ClientTlsPolicies should + * be listed, specified in the format `projects/* /locations/{location}`. + * @param {number} request.pageSize + * Maximum number of ClientTlsPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListClientTlsPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListClientTlsPolicies` call, and that the system + * should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networksecurity.v1.ClientTlsPolicy|ClientTlsPolicy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_security.list_client_tls_policies.js + * region_tag:networksecurity_v1_generated_NetworkSecurity_ListClientTlsPolicies_async + */ + listClientTlsPoliciesAsync( + request?: protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest, + 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['listClientTlsPolicies']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listClientTlsPolicies.asyncIterate( + this.innerApiCalls['listClientTlsPolicies'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @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/interfaces/CallOptions.html | 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.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getIamPolicy( + request: IamProtos.google.iam.v1.GetIamPolicyRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.Policy]> { + return this.iamClient.getIamPolicy(request, options, callback); + } + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + setIamPolicy( + request: IamProtos.google.iam.v1.SetIamPolicyRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.Policy]> { + return this.iamClient.setIamPolicy(request, options, callback); + } + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ + testIamPermissions( + request: IamProtos.google.iam.v1.TestIamPermissionsRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + return this.iamClient.testIamPermissions(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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 authorizationPolicy resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} authorization_policy + * @returns {string} Resource name string. + */ + authorizationPolicyPath(project:string,location:string,authorizationPolicy:string) { + return this.pathTemplates.authorizationPolicyPathTemplate.render({ + project: project, + location: location, + authorization_policy: authorizationPolicy, + }); + } + + /** + * Parse the project from AuthorizationPolicy resource. + * + * @param {string} authorizationPolicyName + * A fully-qualified path representing AuthorizationPolicy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAuthorizationPolicyName(authorizationPolicyName: string) { + return this.pathTemplates.authorizationPolicyPathTemplate.match(authorizationPolicyName).project; + } + + /** + * Parse the location from AuthorizationPolicy resource. + * + * @param {string} authorizationPolicyName + * A fully-qualified path representing AuthorizationPolicy resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAuthorizationPolicyName(authorizationPolicyName: string) { + return this.pathTemplates.authorizationPolicyPathTemplate.match(authorizationPolicyName).location; + } + + /** + * Parse the authorization_policy from AuthorizationPolicy resource. + * + * @param {string} authorizationPolicyName + * A fully-qualified path representing AuthorizationPolicy resource. + * @returns {string} A string representing the authorization_policy. + */ + matchAuthorizationPolicyFromAuthorizationPolicyName(authorizationPolicyName: string) { + return this.pathTemplates.authorizationPolicyPathTemplate.match(authorizationPolicyName).authorization_policy; + } + + /** + * Return a fully-qualified clientTlsPolicy resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} client_tls_policy + * @returns {string} Resource name string. + */ + clientTlsPolicyPath(project:string,location:string,clientTlsPolicy:string) { + return this.pathTemplates.clientTlsPolicyPathTemplate.render({ + project: project, + location: location, + client_tls_policy: clientTlsPolicy, + }); + } + + /** + * Parse the project from ClientTlsPolicy resource. + * + * @param {string} clientTlsPolicyName + * A fully-qualified path representing ClientTlsPolicy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromClientTlsPolicyName(clientTlsPolicyName: string) { + return this.pathTemplates.clientTlsPolicyPathTemplate.match(clientTlsPolicyName).project; + } + + /** + * Parse the location from ClientTlsPolicy resource. + * + * @param {string} clientTlsPolicyName + * A fully-qualified path representing ClientTlsPolicy resource. + * @returns {string} A string representing the location. + */ + matchLocationFromClientTlsPolicyName(clientTlsPolicyName: string) { + return this.pathTemplates.clientTlsPolicyPathTemplate.match(clientTlsPolicyName).location; + } + + /** + * Parse the client_tls_policy from ClientTlsPolicy resource. + * + * @param {string} clientTlsPolicyName + * A fully-qualified path representing ClientTlsPolicy resource. + * @returns {string} A string representing the client_tls_policy. + */ + matchClientTlsPolicyFromClientTlsPolicyName(clientTlsPolicyName: string) { + return this.pathTemplates.clientTlsPolicyPathTemplate.match(clientTlsPolicyName).client_tls_policy; + } + + /** + * Return a fully-qualified serverTlsPolicy resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} server_tls_policy + * @returns {string} Resource name string. + */ + serverTlsPolicyPath(project:string,location:string,serverTlsPolicy:string) { + return this.pathTemplates.serverTlsPolicyPathTemplate.render({ + project: project, + location: location, + server_tls_policy: serverTlsPolicy, + }); + } + + /** + * Parse the project from ServerTlsPolicy resource. + * + * @param {string} serverTlsPolicyName + * A fully-qualified path representing ServerTlsPolicy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServerTlsPolicyName(serverTlsPolicyName: string) { + return this.pathTemplates.serverTlsPolicyPathTemplate.match(serverTlsPolicyName).project; + } + + /** + * Parse the location from ServerTlsPolicy resource. + * + * @param {string} serverTlsPolicyName + * A fully-qualified path representing ServerTlsPolicy resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServerTlsPolicyName(serverTlsPolicyName: string) { + return this.pathTemplates.serverTlsPolicyPathTemplate.match(serverTlsPolicyName).location; + } + + /** + * Parse the server_tls_policy from ServerTlsPolicy resource. + * + * @param {string} serverTlsPolicyName + * A fully-qualified path representing ServerTlsPolicy resource. + * @returns {string} A string representing the server_tls_policy. + */ + matchServerTlsPolicyFromServerTlsPolicyName(serverTlsPolicyName: string) { + return this.pathTemplates.serverTlsPolicyPathTemplate.match(serverTlsPolicyName).server_tls_policy; + } + + /** + * 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.networkSecurityStub && !this._terminated) { + return this.networkSecurityStub.then(stub => { + this._terminated = true; + stub.close(); + this.iamClient.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_client_config.json b/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_client_config.json new file mode 100644 index 00000000000..eb0689a8517 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_client_config.json @@ -0,0 +1,101 @@ +{ + "interfaces": { + "google.cloud.networksecurity.v1.NetworkSecurity": { + "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": { + "ListAuthorizationPolicies": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetAuthorizationPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateAuthorizationPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateAuthorizationPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteAuthorizationPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListServerTlsPolicies": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetServerTlsPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateServerTlsPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateServerTlsPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteServerTlsPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListClientTlsPolicies": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetClientTlsPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateClientTlsPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateClientTlsPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteClientTlsPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_proto_list.json b/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_proto_list.json new file mode 100644 index 00000000000..4dea8c095ea --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/networksecurity/v1/authorization_policy.proto", + "../../protos/google/cloud/networksecurity/v1/client_tls_policy.proto", + "../../protos/google/cloud/networksecurity/v1/common.proto", + "../../protos/google/cloud/networksecurity/v1/network_security.proto", + "../../protos/google/cloud/networksecurity/v1/server_tls_policy.proto", + "../../protos/google/cloud/networksecurity/v1/tls.proto" +] diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-networksecurity/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..276817cefad --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const networksecurity = require('@google-cloud/networksecurity'); + +function main() { + const networkSecurityClient = new networksecurity.NetworkSecurityClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-networksecurity/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..4d3fbe66ebb --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {NetworkSecurityClient} from '@google-cloud/networksecurity'; + +// check that the client class type name can be used +function doStuffWithNetworkSecurityClient(client: NetworkSecurityClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const networkSecurityClient = new NetworkSecurityClient(); + doStuffWithNetworkSecurityClient(networkSecurityClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/system-test/install.ts b/owl-bot-staging/google-cloud-networksecurity/v1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/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-networksecurity/v1/test/gapic_network_security_v1.ts b/owl-bot-staging/google-cloud-networksecurity/v1/test/gapic_network_security_v1.ts new file mode 100644 index 00000000000..c7026aa1d19 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/test/gapic_network_security_v1.ts @@ -0,0 +1,3508 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 networksecurityModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.NetworkSecurityClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = networksecurityModule.v1.NetworkSecurityClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = networksecurityModule.v1.NetworkSecurityClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = networksecurityModule.v1.NetworkSecurityClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new networksecurityModule.v1.NetworkSecurityClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.networkSecurityStub, undefined); + await client.initialize(); + assert(client.networkSecurityStub); + }); + + it('has close method for the initialized client', done => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.networkSecurityStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.networkSecurityStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new networksecurityModule.v1.NetworkSecurityClient({ + 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 networksecurityModule.v1.NetworkSecurityClient({ + 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('getAuthorizationPolicy', () => { + it('invokes getAuthorizationPolicy without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.GetAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.GetAuthorizationPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.AuthorizationPolicy() + ); + client.innerApiCalls.getAuthorizationPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getAuthorizationPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAuthorizationPolicy without error using callback', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.GetAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.GetAuthorizationPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.AuthorizationPolicy() + ); + client.innerApiCalls.getAuthorizationPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAuthorizationPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.networksecurity.v1.IAuthorizationPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAuthorizationPolicy with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.GetAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.GetAuthorizationPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAuthorizationPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getAuthorizationPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAuthorizationPolicy with closed client', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.GetAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.GetAuthorizationPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getAuthorizationPolicy(request), expectedError); + }); + }); + + describe('getServerTlsPolicy', () => { + it('invokes getServerTlsPolicy without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.GetServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.GetServerTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ServerTlsPolicy() + ); + client.innerApiCalls.getServerTlsPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getServerTlsPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getServerTlsPolicy without error using callback', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.GetServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.GetServerTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ServerTlsPolicy() + ); + client.innerApiCalls.getServerTlsPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getServerTlsPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.networksecurity.v1.IServerTlsPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getServerTlsPolicy with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.GetServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.GetServerTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getServerTlsPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getServerTlsPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getServerTlsPolicy with closed client', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.GetServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.GetServerTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getServerTlsPolicy(request), expectedError); + }); + }); + + describe('getClientTlsPolicy', () => { + it('invokes getClientTlsPolicy without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.GetClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.GetClientTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ClientTlsPolicy() + ); + client.innerApiCalls.getClientTlsPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getClientTlsPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getClientTlsPolicy without error using callback', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.GetClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.GetClientTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ClientTlsPolicy() + ); + client.innerApiCalls.getClientTlsPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getClientTlsPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.networksecurity.v1.IClientTlsPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getClientTlsPolicy with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.GetClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.GetClientTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getClientTlsPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getClientTlsPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getClientTlsPolicy with closed client', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.GetClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.GetClientTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getClientTlsPolicy(request), expectedError); + }); + }); + + describe('createAuthorizationPolicy', () => { + it('invokes createAuthorizationPolicy without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.CreateAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateAuthorizationPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createAuthorizationPolicy = stubLongRunningCall(expectedResponse); + const [operation] = await client.createAuthorizationPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createAuthorizationPolicy without error using callback', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.CreateAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateAuthorizationPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createAuthorizationPolicy = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createAuthorizationPolicy( + request, + (err?: Error|null, + result?: 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.createAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createAuthorizationPolicy with call error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.CreateAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateAuthorizationPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createAuthorizationPolicy = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createAuthorizationPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createAuthorizationPolicy with LRO error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.CreateAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateAuthorizationPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createAuthorizationPolicy = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createAuthorizationPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateAuthorizationPolicyProgress without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateAuthorizationPolicyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateAuthorizationPolicyProgress with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateAuthorizationPolicyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateAuthorizationPolicy', () => { + it('invokes updateAuthorizationPolicy without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.UpdateAuthorizationPolicyRequest() + ); + request.authorizationPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateAuthorizationPolicyRequest', ['authorizationPolicy', 'name']); + request.authorizationPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `authorization_policy.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateAuthorizationPolicy = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateAuthorizationPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateAuthorizationPolicy without error using callback', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.UpdateAuthorizationPolicyRequest() + ); + request.authorizationPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateAuthorizationPolicyRequest', ['authorizationPolicy', 'name']); + request.authorizationPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `authorization_policy.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateAuthorizationPolicy = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateAuthorizationPolicy( + request, + (err?: Error|null, + result?: 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.updateAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateAuthorizationPolicy with call error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.UpdateAuthorizationPolicyRequest() + ); + request.authorizationPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateAuthorizationPolicyRequest', ['authorizationPolicy', 'name']); + request.authorizationPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `authorization_policy.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAuthorizationPolicy = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateAuthorizationPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateAuthorizationPolicy with LRO error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.UpdateAuthorizationPolicyRequest() + ); + request.authorizationPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateAuthorizationPolicyRequest', ['authorizationPolicy', 'name']); + request.authorizationPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `authorization_policy.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAuthorizationPolicy = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateAuthorizationPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateAuthorizationPolicyProgress without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateAuthorizationPolicyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateAuthorizationPolicyProgress with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateAuthorizationPolicyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteAuthorizationPolicy', () => { + it('invokes deleteAuthorizationPolicy without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.DeleteAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteAuthorizationPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteAuthorizationPolicy = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteAuthorizationPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteAuthorizationPolicy without error using callback', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.DeleteAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteAuthorizationPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteAuthorizationPolicy = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteAuthorizationPolicy( + request, + (err?: Error|null, + result?: 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.deleteAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteAuthorizationPolicy with call error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.DeleteAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteAuthorizationPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteAuthorizationPolicy = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteAuthorizationPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteAuthorizationPolicy with LRO error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.DeleteAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteAuthorizationPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteAuthorizationPolicy = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteAuthorizationPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteAuthorizationPolicyProgress without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteAuthorizationPolicyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteAuthorizationPolicyProgress with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteAuthorizationPolicyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('createServerTlsPolicy', () => { + it('invokes createServerTlsPolicy without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.CreateServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateServerTlsPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createServerTlsPolicy = stubLongRunningCall(expectedResponse); + const [operation] = await client.createServerTlsPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createServerTlsPolicy without error using callback', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.CreateServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateServerTlsPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createServerTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createServerTlsPolicy( + request, + (err?: Error|null, + result?: 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.createServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createServerTlsPolicy with call error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.CreateServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateServerTlsPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createServerTlsPolicy = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createServerTlsPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.createServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createServerTlsPolicy with LRO error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.CreateServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateServerTlsPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createServerTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createServerTlsPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateServerTlsPolicyProgress without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateServerTlsPolicyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateServerTlsPolicyProgress with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateServerTlsPolicyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateServerTlsPolicy', () => { + it('invokes updateServerTlsPolicy without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.UpdateServerTlsPolicyRequest() + ); + request.serverTlsPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateServerTlsPolicyRequest', ['serverTlsPolicy', 'name']); + request.serverTlsPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `server_tls_policy.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateServerTlsPolicy = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateServerTlsPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateServerTlsPolicy without error using callback', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.UpdateServerTlsPolicyRequest() + ); + request.serverTlsPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateServerTlsPolicyRequest', ['serverTlsPolicy', 'name']); + request.serverTlsPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `server_tls_policy.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateServerTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateServerTlsPolicy( + request, + (err?: Error|null, + result?: 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.updateServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateServerTlsPolicy with call error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.UpdateServerTlsPolicyRequest() + ); + request.serverTlsPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateServerTlsPolicyRequest', ['serverTlsPolicy', 'name']); + request.serverTlsPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `server_tls_policy.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServerTlsPolicy = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateServerTlsPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateServerTlsPolicy with LRO error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.UpdateServerTlsPolicyRequest() + ); + request.serverTlsPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateServerTlsPolicyRequest', ['serverTlsPolicy', 'name']); + request.serverTlsPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `server_tls_policy.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServerTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateServerTlsPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateServerTlsPolicyProgress without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateServerTlsPolicyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateServerTlsPolicyProgress with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateServerTlsPolicyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteServerTlsPolicy', () => { + it('invokes deleteServerTlsPolicy without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.DeleteServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteServerTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteServerTlsPolicy = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteServerTlsPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteServerTlsPolicy without error using callback', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.DeleteServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteServerTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteServerTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteServerTlsPolicy( + request, + (err?: Error|null, + result?: 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.deleteServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteServerTlsPolicy with call error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.DeleteServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteServerTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServerTlsPolicy = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteServerTlsPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteServerTlsPolicy with LRO error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.DeleteServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteServerTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServerTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteServerTlsPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteServerTlsPolicyProgress without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteServerTlsPolicyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteServerTlsPolicyProgress with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteServerTlsPolicyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('createClientTlsPolicy', () => { + it('invokes createClientTlsPolicy without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.CreateClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateClientTlsPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createClientTlsPolicy = stubLongRunningCall(expectedResponse); + const [operation] = await client.createClientTlsPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createClientTlsPolicy without error using callback', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.CreateClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateClientTlsPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createClientTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createClientTlsPolicy( + request, + (err?: Error|null, + result?: 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.createClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createClientTlsPolicy with call error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.CreateClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateClientTlsPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createClientTlsPolicy = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createClientTlsPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.createClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createClientTlsPolicy with LRO error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.CreateClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateClientTlsPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createClientTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createClientTlsPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateClientTlsPolicyProgress without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateClientTlsPolicyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateClientTlsPolicyProgress with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateClientTlsPolicyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateClientTlsPolicy', () => { + it('invokes updateClientTlsPolicy without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.UpdateClientTlsPolicyRequest() + ); + request.clientTlsPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateClientTlsPolicyRequest', ['clientTlsPolicy', 'name']); + request.clientTlsPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `client_tls_policy.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateClientTlsPolicy = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateClientTlsPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateClientTlsPolicy without error using callback', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.UpdateClientTlsPolicyRequest() + ); + request.clientTlsPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateClientTlsPolicyRequest', ['clientTlsPolicy', 'name']); + request.clientTlsPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `client_tls_policy.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateClientTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateClientTlsPolicy( + request, + (err?: Error|null, + result?: 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.updateClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateClientTlsPolicy with call error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.UpdateClientTlsPolicyRequest() + ); + request.clientTlsPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateClientTlsPolicyRequest', ['clientTlsPolicy', 'name']); + request.clientTlsPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `client_tls_policy.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateClientTlsPolicy = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateClientTlsPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateClientTlsPolicy with LRO error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.UpdateClientTlsPolicyRequest() + ); + request.clientTlsPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateClientTlsPolicyRequest', ['clientTlsPolicy', 'name']); + request.clientTlsPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `client_tls_policy.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateClientTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateClientTlsPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateClientTlsPolicyProgress without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateClientTlsPolicyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateClientTlsPolicyProgress with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateClientTlsPolicyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteClientTlsPolicy', () => { + it('invokes deleteClientTlsPolicy without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.DeleteClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteClientTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteClientTlsPolicy = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteClientTlsPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteClientTlsPolicy without error using callback', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.DeleteClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteClientTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteClientTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteClientTlsPolicy( + request, + (err?: Error|null, + result?: 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.deleteClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteClientTlsPolicy with call error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.DeleteClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteClientTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteClientTlsPolicy = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteClientTlsPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteClientTlsPolicy with LRO error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.DeleteClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteClientTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteClientTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteClientTlsPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteClientTlsPolicyProgress without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteClientTlsPolicyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteClientTlsPolicyProgress with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteClientTlsPolicyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listAuthorizationPolicies', () => { + it('invokes listAuthorizationPolicies without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), + ]; + client.innerApiCalls.listAuthorizationPolicies = stubSimpleCall(expectedResponse); + const [response] = await client.listAuthorizationPolicies(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listAuthorizationPolicies without error using callback', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), + ]; + client.innerApiCalls.listAuthorizationPolicies = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listAuthorizationPolicies( + request, + (err?: Error|null, result?: protos.google.cloud.networksecurity.v1.IAuthorizationPolicy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listAuthorizationPolicies with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listAuthorizationPolicies = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listAuthorizationPolicies(request), expectedError); + const actualRequest = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listAuthorizationPoliciesStream without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), + ]; + client.descriptors.page.listAuthorizationPolicies.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listAuthorizationPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networksecurity.v1.AuthorizationPolicy[] = []; + stream.on('data', (response: protos.google.cloud.networksecurity.v1.AuthorizationPolicy) => { + 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.listAuthorizationPolicies.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listAuthorizationPolicies, request)); + assert( + (client.descriptors.page.listAuthorizationPolicies.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listAuthorizationPoliciesStream with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAuthorizationPolicies.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listAuthorizationPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networksecurity.v1.AuthorizationPolicy[] = []; + stream.on('data', (response: protos.google.cloud.networksecurity.v1.AuthorizationPolicy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listAuthorizationPolicies.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listAuthorizationPolicies, request)); + assert( + (client.descriptors.page.listAuthorizationPolicies.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listAuthorizationPolicies without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), + ]; + client.descriptors.page.listAuthorizationPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networksecurity.v1.IAuthorizationPolicy[] = []; + const iterable = client.listAuthorizationPoliciesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listAuthorizationPolicies.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listAuthorizationPolicies.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listAuthorizationPolicies with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAuthorizationPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAuthorizationPoliciesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networksecurity.v1.IAuthorizationPolicy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listAuthorizationPolicies.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listAuthorizationPolicies.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listServerTlsPolicies', () => { + it('invokes listServerTlsPolicies without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), + ]; + client.innerApiCalls.listServerTlsPolicies = stubSimpleCall(expectedResponse); + const [response] = await client.listServerTlsPolicies(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listServerTlsPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listServerTlsPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServerTlsPolicies without error using callback', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), + ]; + client.innerApiCalls.listServerTlsPolicies = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServerTlsPolicies( + request, + (err?: Error|null, result?: protos.google.cloud.networksecurity.v1.IServerTlsPolicy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listServerTlsPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listServerTlsPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServerTlsPolicies with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listServerTlsPolicies = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listServerTlsPolicies(request), expectedError); + const actualRequest = (client.innerApiCalls.listServerTlsPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listServerTlsPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServerTlsPoliciesStream without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), + ]; + client.descriptors.page.listServerTlsPolicies.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listServerTlsPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networksecurity.v1.ServerTlsPolicy[] = []; + stream.on('data', (response: protos.google.cloud.networksecurity.v1.ServerTlsPolicy) => { + 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.listServerTlsPolicies.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServerTlsPolicies, request)); + assert( + (client.descriptors.page.listServerTlsPolicies.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listServerTlsPoliciesStream with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServerTlsPolicies.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listServerTlsPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networksecurity.v1.ServerTlsPolicy[] = []; + stream.on('data', (response: protos.google.cloud.networksecurity.v1.ServerTlsPolicy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listServerTlsPolicies.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServerTlsPolicies, request)); + assert( + (client.descriptors.page.listServerTlsPolicies.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listServerTlsPolicies without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), + ]; + client.descriptors.page.listServerTlsPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networksecurity.v1.IServerTlsPolicy[] = []; + const iterable = client.listServerTlsPoliciesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listServerTlsPolicies.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listServerTlsPolicies.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listServerTlsPolicies with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServerTlsPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServerTlsPoliciesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networksecurity.v1.IServerTlsPolicy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listServerTlsPolicies.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listServerTlsPolicies.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listClientTlsPolicies', () => { + it('invokes listClientTlsPolicies without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), + ]; + client.innerApiCalls.listClientTlsPolicies = stubSimpleCall(expectedResponse); + const [response] = await client.listClientTlsPolicies(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listClientTlsPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listClientTlsPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listClientTlsPolicies without error using callback', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), + ]; + client.innerApiCalls.listClientTlsPolicies = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listClientTlsPolicies( + request, + (err?: Error|null, result?: protos.google.cloud.networksecurity.v1.IClientTlsPolicy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listClientTlsPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listClientTlsPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listClientTlsPolicies with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listClientTlsPolicies = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listClientTlsPolicies(request), expectedError); + const actualRequest = (client.innerApiCalls.listClientTlsPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listClientTlsPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listClientTlsPoliciesStream without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), + ]; + client.descriptors.page.listClientTlsPolicies.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listClientTlsPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networksecurity.v1.ClientTlsPolicy[] = []; + stream.on('data', (response: protos.google.cloud.networksecurity.v1.ClientTlsPolicy) => { + 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.listClientTlsPolicies.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listClientTlsPolicies, request)); + assert( + (client.descriptors.page.listClientTlsPolicies.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listClientTlsPoliciesStream with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listClientTlsPolicies.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listClientTlsPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networksecurity.v1.ClientTlsPolicy[] = []; + stream.on('data', (response: protos.google.cloud.networksecurity.v1.ClientTlsPolicy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listClientTlsPolicies.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listClientTlsPolicies, request)); + assert( + (client.descriptors.page.listClientTlsPolicies.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listClientTlsPolicies without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), + ]; + client.descriptors.page.listClientTlsPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networksecurity.v1.IClientTlsPolicy[] = []; + const iterable = client.listClientTlsPoliciesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listClientTlsPolicies.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listClientTlsPolicies.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listClientTlsPolicies with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listClientTlsPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listClientTlsPoliciesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networksecurity.v1.IClientTlsPolicy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listClientTlsPolicies.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listClientTlsPolicies.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0)); + }); + it('invokes getIamPolicy with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0)); + }); + it('invokes setIamPolicy with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new networksecurityModule.v1.NetworkSecurityClient({ + 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 networksecurityModule.v1.NetworkSecurityClient({ + 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 networksecurityModule.v1.NetworkSecurityClient({ + 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 networksecurityModule.v1.NetworkSecurityClient({ + 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 networksecurityModule.v1.NetworkSecurityClient({ + 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 networksecurityModule.v1.NetworkSecurityClient({ + 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 networksecurityModule.v1.NetworkSecurityClient({ + 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 networksecurityModule.v1.NetworkSecurityClient({ + 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 networksecurityModule.v1.NetworkSecurityClient({ + 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 networksecurityModule.v1.NetworkSecurityClient({ + 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 networksecurityModule.v1.NetworkSecurityClient({ + 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 networksecurityModule.v1.NetworkSecurityClient({ + 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 networksecurityModule.v1.NetworkSecurityClient({ + 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 networksecurityModule.v1.NetworkSecurityClient({ + 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 networksecurityModule.v1.NetworkSecurityClient({ + 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 networksecurityModule.v1.NetworkSecurityClient({ + 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('authorizationPolicy', () => { + const fakePath = "/rendered/path/authorizationPolicy"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + authorization_policy: "authorizationPolicyValue", + }; + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.authorizationPolicyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.authorizationPolicyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('authorizationPolicyPath', () => { + const result = client.authorizationPolicyPath("projectValue", "locationValue", "authorizationPolicyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.authorizationPolicyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAuthorizationPolicyName', () => { + const result = client.matchProjectFromAuthorizationPolicyName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.authorizationPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAuthorizationPolicyName', () => { + const result = client.matchLocationFromAuthorizationPolicyName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.authorizationPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchAuthorizationPolicyFromAuthorizationPolicyName', () => { + const result = client.matchAuthorizationPolicyFromAuthorizationPolicyName(fakePath); + assert.strictEqual(result, "authorizationPolicyValue"); + assert((client.pathTemplates.authorizationPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('clientTlsPolicy', () => { + const fakePath = "/rendered/path/clientTlsPolicy"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + client_tls_policy: "clientTlsPolicyValue", + }; + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.clientTlsPolicyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.clientTlsPolicyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('clientTlsPolicyPath', () => { + const result = client.clientTlsPolicyPath("projectValue", "locationValue", "clientTlsPolicyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.clientTlsPolicyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromClientTlsPolicyName', () => { + const result = client.matchProjectFromClientTlsPolicyName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.clientTlsPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromClientTlsPolicyName', () => { + const result = client.matchLocationFromClientTlsPolicyName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.clientTlsPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchClientTlsPolicyFromClientTlsPolicyName', () => { + const result = client.matchClientTlsPolicyFromClientTlsPolicyName(fakePath); + assert.strictEqual(result, "clientTlsPolicyValue"); + assert((client.pathTemplates.clientTlsPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('serverTlsPolicy', () => { + const fakePath = "/rendered/path/serverTlsPolicy"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + server_tls_policy: "serverTlsPolicyValue", + }; + const client = new networksecurityModule.v1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.serverTlsPolicyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.serverTlsPolicyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('serverTlsPolicyPath', () => { + const result = client.serverTlsPolicyPath("projectValue", "locationValue", "serverTlsPolicyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.serverTlsPolicyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServerTlsPolicyName', () => { + const result = client.matchProjectFromServerTlsPolicyName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.serverTlsPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServerTlsPolicyName', () => { + const result = client.matchLocationFromServerTlsPolicyName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.serverTlsPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServerTlsPolicyFromServerTlsPolicyName', () => { + const result = client.matchServerTlsPolicyFromServerTlsPolicyName(fakePath); + assert.strictEqual(result, "serverTlsPolicyValue"); + assert((client.pathTemplates.serverTlsPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/tsconfig.json b/owl-bot-staging/google-cloud-networksecurity/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/webpack.config.js b/owl-bot-staging/google-cloud-networksecurity/v1/webpack.config.js new file mode 100644 index 00000000000..d5abc33e904 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'NetworkSecurity', + filename: './network-security.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-networksecurity/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-networksecurity/v1beta1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-networksecurity/v1beta1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/.gitignore b/owl-bot-staging/google-cloud-networksecurity/v1beta1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/.jsdoc.js new file mode 100644 index 00000000000..1a78e759476 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/.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/network-security', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/.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-networksecurity/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/.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-networksecurity/v1beta1/README.md b/owl-bot-staging/google-cloud-networksecurity/v1beta1/README.md new file mode 100644 index 00000000000..aa251b5b5c0 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/README.md @@ -0,0 +1 @@ +Networksecurity: Nodejs Client diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/package.json b/owl-bot-staging/google-cloud-networksecurity/v1beta1/package.json new file mode 100644 index 00000000000..b8a5aa0ce92 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/network-security", + "version": "0.1.0", + "description": "Networksecurity client for Node.js", + "repository": "googleapis/nodejs-networksecurity", + "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 networksecurity", + "networksecurity", + "network security" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/authorization_policy.proto b/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/authorization_policy.proto new file mode 100644 index 00000000000..e52f06d6a89 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/authorization_policy.proto @@ -0,0 +1,259 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.networksecurity.v1beta1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.NetworkSecurity.V1Beta1"; +option go_package = "cloud.google.com/go/networksecurity/apiv1beta1/networksecuritypb;networksecuritypb"; +option java_multiple_files = true; +option java_outer_classname = "AuthorizationPolicyProto"; +option java_package = "com.google.cloud.networksecurity.v1beta1"; +option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1beta1"; +option ruby_package = "Google::Cloud::NetworkSecurity::V1beta1"; + +// AuthorizationPolicy is a resource that specifies how a server +// should authorize incoming connections. This resource in itself does +// not change the configuration unless it's attached to a target https +// proxy or endpoint config selector resource. +message AuthorizationPolicy { + option (google.api.resource) = { + type: "networksecurity.googleapis.com/AuthorizationPolicy" + pattern: "projects/{project}/locations/{location}/authorizationPolicies/{authorization_policy}" + }; + + // Specification of rules. + message Rule { + // Specification of traffic source attributes. + message Source { + // Optional. List of peer identities to match for authorization. At least + // one principal should match. Each peer can be an exact match, or a + // prefix match (example, "namespace/*") or a suffix match (example, + // "*/service-account") or a presence match "*". Authorization based on + // the principal name without certificate validation (configured by + // ServerTlsPolicy resource) is considered insecure. + repeated string principals = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. List of CIDR ranges to match based on source IP address. At + // least one IP block should match. Single IP (e.g., "1.2.3.4") and CIDR + // (e.g., "1.2.3.0/24") are supported. Authorization based on source IP + // alone should be avoided. The IP addresses of any load balancers or + // proxies should be considered untrusted. + repeated string ip_blocks = 2 [(google.api.field_behavior) = OPTIONAL]; + } + + // Specification of traffic destination attributes. + message Destination { + // Specification of HTTP header match attributes. + message HttpHeaderMatch { + oneof type { + // Required. The value of the header must match the regular expression + // specified in regexMatch. For regular expression grammar, + // please see: en.cppreference.com/w/cpp/regex/ecmascript + // For matching against a port specified in the HTTP + // request, use a headerMatch with headerName set to Host + // and a regular expression that satisfies the RFC2616 Host + // header's port specifier. + string regex_match = 2 [(google.api.field_behavior) = REQUIRED]; + } + + // Required. The name of the HTTP header to match. For matching + // against the HTTP request's authority, use a headerMatch + // with the header name ":authority". For matching a + // request's method, use the headerName ":method". + string header_name = 1 [(google.api.field_behavior) = REQUIRED]; + } + + // Required. List of host names to match. Matched against the ":authority" + // header in http requests. At least one host should match. Each host can + // be an exact match, or a prefix match (example "mydomain.*") or a suffix + // match (example "*.myorg.com") or a presence (any) match "*". + repeated string hosts = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. List of destination ports to match. At least one port should + // match. + repeated uint32 ports = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. A list of HTTP methods to match. At least one method should + // match. Should not be set for gRPC services. + repeated string methods = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Match against key:value pair in http header. Provides a + // flexible match based on HTTP headers, for potentially advanced use + // cases. At least one header should match. Avoid using header matches to + // make authorization decisions unless there is a strong guarantee that + // requests arrive through a trusted client or proxy. + HttpHeaderMatch http_header_match = 5 + [(google.api.field_behavior) = OPTIONAL]; + } + + // Optional. List of attributes for the traffic source. All of the sources + // must match. A source is a match if both principals and ip_blocks match. + // If not set, the action specified in the 'action' field will be applied + // without any rule checks for the source. + repeated Source sources = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. List of attributes for the traffic destination. All of the + // destinations must match. A destination is a match if a request matches + // all the specified hosts, ports, methods and headers. If not set, the + // action specified in the 'action' field will be applied without any rule + // checks for the destination. + repeated Destination destinations = 2 + [(google.api.field_behavior) = OPTIONAL]; + } + + // Possible values that define what action to take. + enum Action { + // Default value. + ACTION_UNSPECIFIED = 0; + + // Grant access. + ALLOW = 1; + + // Deny access. + // Deny rules should be avoided unless they are used to provide a default + // "deny all" fallback. + DENY = 2; + } + + // Required. Name of the AuthorizationPolicy resource. It matches pattern + // `projects/{project}/locations/{location}/authorizationPolicies/`. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Free-text description of the resource. + string description = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The timestamp when the resource was created. + google.protobuf.Timestamp create_time = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp when the resource was updated. + google.protobuf.Timestamp update_time = 4 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Set of label tags associated with the AuthorizationPolicy + // resource. + map labels = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Required. The action to take when a rule match is found. Possible values + // are "ALLOW" or "DENY". + Action action = 6 [(google.api.field_behavior) = REQUIRED]; + + // Optional. List of rules to match. Note that at least one of the rules must + // match in order for the action specified in the 'action' field to be taken. + // A rule is a match if there is a matching source and destination. If left + // blank, the action specified in the `action` field will be applied on every + // request. + repeated Rule rules = 7 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request used with the ListAuthorizationPolicies method. +message ListAuthorizationPoliciesRequest { + // Required. The project and location from which the AuthorizationPolicies + // should be listed, specified in the format + // `projects/{project}/locations/{location}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Maximum number of AuthorizationPolicies to return per call. + int32 page_size = 2; + + // The value returned by the last + // `ListAuthorizationPoliciesResponse` Indicates that this is a + // continuation of a prior `ListAuthorizationPolicies` call, and + // that the system should return the next page of data. + string page_token = 3; +} + +// Response returned by the ListAuthorizationPolicies method. +message ListAuthorizationPoliciesResponse { + // List of AuthorizationPolicies resources. + repeated AuthorizationPolicy authorization_policies = 1; + + // If there might be more results than those appearing in this response, then + // `next_page_token` is included. To get the next set of results, call this + // method again using the value of `next_page_token` as `page_token`. + string next_page_token = 2; +} + +// Request used by the GetAuthorizationPolicy method. +message GetAuthorizationPolicyRequest { + // Required. A name of the AuthorizationPolicy to get. Must be in the format + // `projects/{project}/locations/{location}/authorizationPolicies/*`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "networksecurity.googleapis.com/AuthorizationPolicy" + } + ]; +} + +// Request used by the CreateAuthorizationPolicy method. +message CreateAuthorizationPolicyRequest { + // Required. The parent resource of the AuthorizationPolicy. Must be in the + // format `projects/{project}/locations/{location}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "networksecurity.googleapis.com/AuthorizationPolicy" + } + ]; + + // Required. Short name of the AuthorizationPolicy resource to be created. + // This value should be 1-63 characters long, containing only + // letters, numbers, hyphens, and underscores, and should not start + // with a number. E.g. "authz_policy". + string authorization_policy_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. AuthorizationPolicy resource to be created. + AuthorizationPolicy authorization_policy = 3 + [(google.api.field_behavior) = REQUIRED]; +} + +// Request used by the UpdateAuthorizationPolicy method. +message UpdateAuthorizationPolicyRequest { + // Optional. Field mask is used to specify the fields to be overwritten in the + // AuthorizationPolicy resource by the update. + // The fields specified in the update_mask are relative to the resource, not + // the full request. A field will be overwritten if it is in the mask. If the + // user does not provide a mask then all fields will be overwritten. + google.protobuf.FieldMask update_mask = 1 + [(google.api.field_behavior) = OPTIONAL]; + + // Required. Updated AuthorizationPolicy resource. + AuthorizationPolicy authorization_policy = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// Request used by the DeleteAuthorizationPolicy method. +message DeleteAuthorizationPolicyRequest { + // Required. A name of the AuthorizationPolicy to delete. Must be in the + // format `projects/{project}/locations/{location}/authorizationPolicies/*`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "networksecurity.googleapis.com/AuthorizationPolicy" + } + ]; +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/client_tls_policy.proto b/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/client_tls_policy.proto new file mode 100644 index 00000000000..23b51077410 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/client_tls_policy.proto @@ -0,0 +1,169 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.networksecurity.v1beta1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/networksecurity/v1beta1/tls.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.NetworkSecurity.V1Beta1"; +option go_package = "cloud.google.com/go/networksecurity/apiv1beta1/networksecuritypb;networksecuritypb"; +option java_multiple_files = true; +option java_outer_classname = "ClientTlsPolicyProto"; +option java_package = "com.google.cloud.networksecurity.v1beta1"; +option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1beta1"; +option ruby_package = "Google::Cloud::NetworkSecurity::V1beta1"; + +// ClientTlsPolicy is a resource that specifies how a client should authenticate +// connections to backends of a service. This resource itself does not affect +// configuration unless it is attached to a backend service resource. +message ClientTlsPolicy { + option (google.api.resource) = { + type: "networksecurity.googleapis.com/ClientTlsPolicy" + pattern: "projects/{project}/locations/{location}/clientTlsPolicies/{client_tls_policy}" + }; + + // Required. Name of the ClientTlsPolicy resource. It matches the pattern + // `projects/*/locations/{location}/clientTlsPolicies/{client_tls_policy}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Free-text description of the resource. + string description = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The timestamp when the resource was created. + google.protobuf.Timestamp create_time = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp when the resource was updated. + google.protobuf.Timestamp update_time = 4 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Set of label tags associated with the resource. + map labels = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Server Name Indication string to present to the server during TLS + // handshake. E.g: "secure.example.com". + string sni = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Defines a mechanism to provision client identity (public and + // private keys) for peer to peer authentication. The presence of this + // dictates mTLS. + CertificateProvider client_certificate = 7 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Defines the mechanism to obtain the Certificate Authority + // certificate to validate the server certificate. If empty, client does not + // validate the server certificate. + repeated ValidationCA server_validation_ca = 8 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Request used by the ListClientTlsPolicies method. +message ListClientTlsPoliciesRequest { + // Required. The project and location from which the ClientTlsPolicies should + // be listed, specified in the format `projects/*/locations/{location}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Maximum number of ClientTlsPolicies to return per call. + int32 page_size = 2; + + // The value returned by the last `ListClientTlsPoliciesResponse` + // Indicates that this is a continuation of a prior + // `ListClientTlsPolicies` call, and that the system + // should return the next page of data. + string page_token = 3; +} + +// Response returned by the ListClientTlsPolicies method. +message ListClientTlsPoliciesResponse { + // List of ClientTlsPolicy resources. + repeated ClientTlsPolicy client_tls_policies = 1; + + // If there might be more results than those appearing in this response, then + // `next_page_token` is included. To get the next set of results, call this + // method again using the value of `next_page_token` as `page_token`. + string next_page_token = 2; +} + +// Request used by the GetClientTlsPolicy method. +message GetClientTlsPolicyRequest { + // Required. A name of the ClientTlsPolicy to get. Must be in the format + // `projects/*/locations/{location}/clientTlsPolicies/*`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "networksecurity.googleapis.com/ClientTlsPolicy" + } + ]; +} + +// Request used by the CreateClientTlsPolicy method. +message CreateClientTlsPolicyRequest { + // Required. The parent resource of the ClientTlsPolicy. Must be in + // the format `projects/*/locations/{location}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "networksecurity.googleapis.com/ClientTlsPolicy" + } + ]; + + // Required. Short name of the ClientTlsPolicy resource to be created. This + // value should be 1-63 characters long, containing only letters, numbers, + // hyphens, and underscores, and should not start with a number. E.g. + // "client_mtls_policy". + string client_tls_policy_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. ClientTlsPolicy resource to be created. + ClientTlsPolicy client_tls_policy = 3 + [(google.api.field_behavior) = REQUIRED]; +} + +// Request used by UpdateClientTlsPolicy method. +message UpdateClientTlsPolicyRequest { + // Optional. Field mask is used to specify the fields to be overwritten in the + // ClientTlsPolicy resource by the update. The fields + // specified in the update_mask are relative to the resource, not + // the full request. A field will be overwritten if it is in the + // mask. If the user does not provide a mask then all fields will be + // overwritten. + google.protobuf.FieldMask update_mask = 1 + [(google.api.field_behavior) = OPTIONAL]; + + // Required. Updated ClientTlsPolicy resource. + ClientTlsPolicy client_tls_policy = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// Request used by the DeleteClientTlsPolicy method. +message DeleteClientTlsPolicyRequest { + // Required. A name of the ClientTlsPolicy to delete. Must be in + // the format `projects/*/locations/{location}/clientTlsPolicies/*`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "networksecurity.googleapis.com/ClientTlsPolicy" + } + ]; +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/common.proto b/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/common.proto new file mode 100644 index 00000000000..04f37a45ec9 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/common.proto @@ -0,0 +1,58 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.networksecurity.v1beta1; + +import "google/api/field_behavior.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.NetworkSecurity.V1Beta1"; +option go_package = "cloud.google.com/go/networksecurity/apiv1beta1/networksecuritypb;networksecuritypb"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.cloud.networksecurity.v1beta1"; +option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1beta1"; +option ruby_package = "Google::Cloud::NetworkSecurity::V1beta1"; + +// Represents the metadata of the long-running operation. +message OperationMetadata { + // Output only. The time the operation was created. + google.protobuf.Timestamp create_time = 1 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time the operation finished running. + google.protobuf.Timestamp end_time = 2 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Server-defined resource path for the target of the operation. + string target = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the verb executed by the operation. + string verb = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Human-readable status of the operation, if any. + string status_message = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Identifies whether the user has requested cancellation + // of the operation. Operations that have successfully been cancelled + // have [Operation.error][] value with a + // [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + // `Code.CANCELLED`. + bool requested_cancellation = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. API version used to start the operation. + string api_version = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/network_security.proto b/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/network_security.proto new file mode 100644 index 00000000000..157948f65c5 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/network_security.proto @@ -0,0 +1,201 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.networksecurity.v1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/cloud/networksecurity/v1beta1/authorization_policy.proto"; +import "google/cloud/networksecurity/v1beta1/client_tls_policy.proto"; +import "google/cloud/networksecurity/v1beta1/server_tls_policy.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.NetworkSecurity.V1Beta1"; +option go_package = "cloud.google.com/go/networksecurity/apiv1beta1/networksecuritypb;networksecuritypb"; +option java_multiple_files = true; +option java_package = "com.google.cloud.networksecurity.v1beta1"; +option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1beta1"; +option ruby_package = "Google::Cloud::NetworkSecurity::V1beta1"; + +// Network Security API provides resources to configure authentication and +// authorization policies. Refer to per API resource documentation for more +// information. +service NetworkSecurity { + option (google.api.default_host) = "networksecurity.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Lists AuthorizationPolicies in a given project and location. + rpc ListAuthorizationPolicies(ListAuthorizationPoliciesRequest) returns (ListAuthorizationPoliciesResponse) { + option (google.api.http) = { + get: "/v1beta1/{parent=projects/*/locations/*}/authorizationPolicies" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets details of a single AuthorizationPolicy. + rpc GetAuthorizationPolicy(GetAuthorizationPolicyRequest) returns (AuthorizationPolicy) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/locations/*/authorizationPolicies/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new AuthorizationPolicy in a given project and location. + rpc CreateAuthorizationPolicy(CreateAuthorizationPolicyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*/locations/*}/authorizationPolicies" + body: "authorization_policy" + }; + option (google.api.method_signature) = "parent,authorization_policy,authorization_policy_id"; + option (google.longrunning.operation_info) = { + response_type: "AuthorizationPolicy" + metadata_type: "google.cloud.networksecurity.v1beta1.OperationMetadata" + }; + } + + // Updates the parameters of a single AuthorizationPolicy. + rpc UpdateAuthorizationPolicy(UpdateAuthorizationPolicyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1beta1/{authorization_policy.name=projects/*/locations/*/authorizationPolicies/*}" + body: "authorization_policy" + }; + option (google.api.method_signature) = "authorization_policy,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "AuthorizationPolicy" + metadata_type: "google.cloud.networksecurity.v1beta1.OperationMetadata" + }; + } + + // Deletes a single AuthorizationPolicy. + rpc DeleteAuthorizationPolicy(DeleteAuthorizationPolicyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1beta1/{name=projects/*/locations/*/authorizationPolicies/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "google.cloud.networksecurity.v1beta1.OperationMetadata" + }; + } + + // Lists ServerTlsPolicies in a given project and location. + rpc ListServerTlsPolicies(ListServerTlsPoliciesRequest) returns (ListServerTlsPoliciesResponse) { + option (google.api.http) = { + get: "/v1beta1/{parent=projects/*/locations/*}/serverTlsPolicies" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets details of a single ServerTlsPolicy. + rpc GetServerTlsPolicy(GetServerTlsPolicyRequest) returns (ServerTlsPolicy) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/locations/*/serverTlsPolicies/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new ServerTlsPolicy in a given project and location. + rpc CreateServerTlsPolicy(CreateServerTlsPolicyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*/locations/*}/serverTlsPolicies" + body: "server_tls_policy" + }; + option (google.api.method_signature) = "parent,server_tls_policy,server_tls_policy_id"; + option (google.longrunning.operation_info) = { + response_type: "ServerTlsPolicy" + metadata_type: "google.cloud.networksecurity.v1beta1.OperationMetadata" + }; + } + + // Updates the parameters of a single ServerTlsPolicy. + rpc UpdateServerTlsPolicy(UpdateServerTlsPolicyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1beta1/{server_tls_policy.name=projects/*/locations/*/serverTlsPolicies/*}" + body: "server_tls_policy" + }; + option (google.api.method_signature) = "server_tls_policy,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "ServerTlsPolicy" + metadata_type: "google.cloud.networksecurity.v1beta1.OperationMetadata" + }; + } + + // Deletes a single ServerTlsPolicy. + rpc DeleteServerTlsPolicy(DeleteServerTlsPolicyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1beta1/{name=projects/*/locations/*/serverTlsPolicies/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "google.cloud.networksecurity.v1beta1.OperationMetadata" + }; + } + + // Lists ClientTlsPolicies in a given project and location. + rpc ListClientTlsPolicies(ListClientTlsPoliciesRequest) returns (ListClientTlsPoliciesResponse) { + option (google.api.http) = { + get: "/v1beta1/{parent=projects/*/locations/*}/clientTlsPolicies" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets details of a single ClientTlsPolicy. + rpc GetClientTlsPolicy(GetClientTlsPolicyRequest) returns (ClientTlsPolicy) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/locations/*/clientTlsPolicies/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new ClientTlsPolicy in a given project and location. + rpc CreateClientTlsPolicy(CreateClientTlsPolicyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*/locations/*}/clientTlsPolicies" + body: "client_tls_policy" + }; + option (google.api.method_signature) = "parent,client_tls_policy,client_tls_policy_id"; + option (google.longrunning.operation_info) = { + response_type: "ClientTlsPolicy" + metadata_type: "google.cloud.networksecurity.v1beta1.OperationMetadata" + }; + } + + // Updates the parameters of a single ClientTlsPolicy. + rpc UpdateClientTlsPolicy(UpdateClientTlsPolicyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1beta1/{client_tls_policy.name=projects/*/locations/*/clientTlsPolicies/*}" + body: "client_tls_policy" + }; + option (google.api.method_signature) = "client_tls_policy,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "ClientTlsPolicy" + metadata_type: "google.cloud.networksecurity.v1beta1.OperationMetadata" + }; + } + + // Deletes a single ClientTlsPolicy. + rpc DeleteClientTlsPolicy(DeleteClientTlsPolicyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1beta1/{name=projects/*/locations/*/clientTlsPolicies/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "google.cloud.networksecurity.v1beta1.OperationMetadata" + }; + } +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/server_tls_policy.proto b/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/server_tls_policy.proto new file mode 100644 index 00000000000..02b5a7443bc --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/server_tls_policy.proto @@ -0,0 +1,187 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.networksecurity.v1beta1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/networksecurity/v1beta1/tls.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.NetworkSecurity.V1Beta1"; +option go_package = "cloud.google.com/go/networksecurity/apiv1beta1/networksecuritypb;networksecuritypb"; +option java_multiple_files = true; +option java_outer_classname = "ServerTlsPolicyProto"; +option java_package = "com.google.cloud.networksecurity.v1beta1"; +option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1beta1"; +option ruby_package = "Google::Cloud::NetworkSecurity::V1beta1"; + +// ServerTlsPolicy is a resource that specifies how a server should authenticate +// incoming requests. This resource itself does not affect configuration unless +// it is attached to a target https proxy or endpoint config selector resource. +message ServerTlsPolicy { + option (google.api.resource) = { + type: "networksecurity.googleapis.com/ServerTlsPolicy" + pattern: "projects/{project}/locations/{location}/serverTlsPolicies/{server_tls_policy}" + }; + + // Specification of the MTLSPolicy. + message MTLSPolicy { + // + // Defines the mechanism to obtain the Certificate Authority certificate to + // validate the client certificate. + repeated ValidationCA client_validation_ca = 1; + } + + // Required. Name of the ServerTlsPolicy resource. It matches the pattern + // `projects/*/locations/{location}/serverTlsPolicies/{server_tls_policy}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Free-text description of the resource. + string description = 2; + + // Output only. The timestamp when the resource was created. + google.protobuf.Timestamp create_time = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp when the resource was updated. + google.protobuf.Timestamp update_time = 4 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Set of label tags associated with the resource. + map labels = 5; + + // + // Determines if server allows plaintext connections. If set to true, server + // allows plain text connections. By default, it is set to false. This setting + // is not exclusive of other encryption modes. For example, if `allow_open` + // and `mtls_policy` are set, server allows both plain text and mTLS + // connections. See documentation of other encryption modes to confirm + // compatibility. + // + // Consider using it if you wish to upgrade in place your deployment to TLS + // while having mixed TLS and non-TLS traffic reaching port :80. + bool allow_open = 6; + + // + // Defines a mechanism to provision server identity (public and private keys). + // Cannot be combined with `allow_open` as a permissive mode that allows both + // plain text and TLS is not supported. + CertificateProvider server_certificate = 7; + + // + // Defines a mechanism to provision peer validation certificates for peer to + // peer authentication (Mutual TLS - mTLS). If not specified, client + // certificate will not be requested. The connection is treated as TLS and not + // mTLS. If `allow_open` and `mtls_policy` are set, server allows both plain + // text and mTLS connections. + MTLSPolicy mtls_policy = 8; +} + +// Request used by the ListServerTlsPolicies method. +message ListServerTlsPoliciesRequest { + // Required. The project and location from which the ServerTlsPolicies should + // be listed, specified in the format `projects/*/locations/{location}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Maximum number of ServerTlsPolicies to return per call. + int32 page_size = 2; + + // The value returned by the last `ListServerTlsPoliciesResponse` + // Indicates that this is a continuation of a prior + // `ListServerTlsPolicies` call, and that the system + // should return the next page of data. + string page_token = 3; +} + +// Response returned by the ListServerTlsPolicies method. +message ListServerTlsPoliciesResponse { + // List of ServerTlsPolicy resources. + repeated ServerTlsPolicy server_tls_policies = 1; + + // If there might be more results than those appearing in this response, then + // `next_page_token` is included. To get the next set of results, call this + // method again using the value of `next_page_token` as `page_token`. + string next_page_token = 2; +} + +// Request used by the GetServerTlsPolicy method. +message GetServerTlsPolicyRequest { + // Required. A name of the ServerTlsPolicy to get. Must be in the format + // `projects/*/locations/{location}/serverTlsPolicies/*`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "networksecurity.googleapis.com/ServerTlsPolicy" + } + ]; +} + +// Request used by the CreateServerTlsPolicy method. +message CreateServerTlsPolicyRequest { + // Required. The parent resource of the ServerTlsPolicy. Must be in + // the format `projects/*/locations/{location}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "networksecurity.googleapis.com/ServerTlsPolicy" + } + ]; + + // Required. Short name of the ServerTlsPolicy resource to be created. This + // value should be 1-63 characters long, containing only letters, numbers, + // hyphens, and underscores, and should not start with a number. E.g. + // "server_mtls_policy". + string server_tls_policy_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. ServerTlsPolicy resource to be created. + ServerTlsPolicy server_tls_policy = 3 + [(google.api.field_behavior) = REQUIRED]; +} + +// Request used by UpdateServerTlsPolicy method. +message UpdateServerTlsPolicyRequest { + // Optional. Field mask is used to specify the fields to be overwritten in the + // ServerTlsPolicy resource by the update. The fields + // specified in the update_mask are relative to the resource, not + // the full request. A field will be overwritten if it is in the + // mask. If the user does not provide a mask then all fields will be + // overwritten. + google.protobuf.FieldMask update_mask = 1 + [(google.api.field_behavior) = OPTIONAL]; + + // Required. Updated ServerTlsPolicy resource. + ServerTlsPolicy server_tls_policy = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// Request used by the DeleteServerTlsPolicy method. +message DeleteServerTlsPolicyRequest { + // Required. A name of the ServerTlsPolicy to delete. Must be in + // the format `projects/*/locations/{location}/serverTlsPolicies/*`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "networksecurity.googleapis.com/ServerTlsPolicy" + } + ]; +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/tls.proto b/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/tls.proto new file mode 100644 index 00000000000..f160146c186 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/tls.proto @@ -0,0 +1,78 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.networksecurity.v1beta1; + +import "google/api/field_behavior.proto"; + +option csharp_namespace = "Google.Cloud.NetworkSecurity.V1Beta1"; +option go_package = "cloud.google.com/go/networksecurity/apiv1beta1/networksecuritypb;networksecuritypb"; +option java_multiple_files = true; +option java_outer_classname = "TlsProto"; +option java_package = "com.google.cloud.networksecurity.v1beta1"; +option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1beta1"; +option ruby_package = "Google::Cloud::NetworkSecurity::V1beta1"; + +// Specification of the GRPC Endpoint. +message GrpcEndpoint { + // Required. The target URI of the gRPC endpoint. Only UDS path is supported, + // and should start with "unix:". + string target_uri = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Specification of ValidationCA. Defines the mechanism to obtain the +// Certificate Authority certificate to validate the peer certificate. +message ValidationCA { + // The type of certificate provider which provides the CA certificate. + oneof type { + // gRPC specific configuration to access the gRPC server to + // obtain the CA certificate. + GrpcEndpoint grpc_endpoint = 2; + + // The certificate provider instance specification that will be passed to + // the data plane, which will be used to load necessary credential + // information. + CertificateProviderInstance certificate_provider_instance = 3; + } +} + +// Specification of a TLS certificate provider instance. Workloads may have one +// or more CertificateProvider instances (plugins) and one of them is enabled +// and configured by specifying this message. Workloads use the values from this +// message to locate and load the CertificateProvider instance configuration. +message CertificateProviderInstance { + // Required. Plugin instance name, used to locate and load CertificateProvider + // instance configuration. Set to "google_cloud_private_spiffe" to use + // Certificate Authority Service certificate provider instance. + string plugin_instance = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Specification of certificate provider. Defines the mechanism to obtain the +// certificate and private key for peer to peer authentication. +message CertificateProvider { + // The type of certificate provider which provides the certificates and + // private keys. + oneof type { + // gRPC specific configuration to access the gRPC server to + // obtain the cert and private key. + GrpcEndpoint grpc_endpoint = 2; + + // The certificate provider instance specification that will be passed to + // the data plane, which will be used to load necessary credential + // information. + CertificateProviderInstance certificate_provider_instance = 3; + } +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_authorization_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_authorization_policy.js new file mode 100644 index 00000000000..09b602c953d --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_authorization_policy.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, authorizationPolicyId, authorizationPolicy) { + // [START networksecurity_v1beta1_generated_NetworkSecurity_CreateAuthorizationPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 of the AuthorizationPolicy. Must be in the + * format `projects/{project}/locations/{location}`. + */ + // const parent = 'abc123' + /** + * Required. Short name of the AuthorizationPolicy resource to be created. + * This value should be 1-63 characters long, containing only + * letters, numbers, hyphens, and underscores, and should not start + * with a number. E.g. "authz_policy". + */ + // const authorizationPolicyId = 'abc123' + /** + * Required. AuthorizationPolicy resource to be created. + */ + // const authorizationPolicy = {} + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callCreateAuthorizationPolicy() { + // Construct request + const request = { + parent, + authorizationPolicyId, + authorizationPolicy, + }; + + // Run request + const [operation] = await networksecurityClient.createAuthorizationPolicy(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateAuthorizationPolicy(); + // [END networksecurity_v1beta1_generated_NetworkSecurity_CreateAuthorizationPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_client_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_client_tls_policy.js new file mode 100644 index 00000000000..73511aa2b59 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_client_tls_policy.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, clientTlsPolicyId, clientTlsPolicy) { + // [START networksecurity_v1beta1_generated_NetworkSecurity_CreateClientTlsPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 of the ClientTlsPolicy. Must be in + * the format `projects/* /locations/{location}`. + */ + // const parent = 'abc123' + /** + * Required. Short name of the ClientTlsPolicy resource to be created. This + * value should be 1-63 characters long, containing only letters, numbers, + * hyphens, and underscores, and should not start with a number. E.g. + * "client_mtls_policy". + */ + // const clientTlsPolicyId = 'abc123' + /** + * Required. ClientTlsPolicy resource to be created. + */ + // const clientTlsPolicy = {} + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callCreateClientTlsPolicy() { + // Construct request + const request = { + parent, + clientTlsPolicyId, + clientTlsPolicy, + }; + + // Run request + const [operation] = await networksecurityClient.createClientTlsPolicy(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateClientTlsPolicy(); + // [END networksecurity_v1beta1_generated_NetworkSecurity_CreateClientTlsPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_server_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_server_tls_policy.js new file mode 100644 index 00000000000..2e9fa72315a --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_server_tls_policy.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, serverTlsPolicyId, serverTlsPolicy) { + // [START networksecurity_v1beta1_generated_NetworkSecurity_CreateServerTlsPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 of the ServerTlsPolicy. Must be in + * the format `projects/* /locations/{location}`. + */ + // const parent = 'abc123' + /** + * Required. Short name of the ServerTlsPolicy resource to be created. This + * value should be 1-63 characters long, containing only letters, numbers, + * hyphens, and underscores, and should not start with a number. E.g. + * "server_mtls_policy". + */ + // const serverTlsPolicyId = 'abc123' + /** + * Required. ServerTlsPolicy resource to be created. + */ + // const serverTlsPolicy = {} + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callCreateServerTlsPolicy() { + // Construct request + const request = { + parent, + serverTlsPolicyId, + serverTlsPolicy, + }; + + // Run request + const [operation] = await networksecurityClient.createServerTlsPolicy(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateServerTlsPolicy(); + // [END networksecurity_v1beta1_generated_NetworkSecurity_CreateServerTlsPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_authorization_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_authorization_policy.js new file mode 100644 index 00000000000..13551ea50ae --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_authorization_policy.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 networksecurity_v1beta1_generated_NetworkSecurity_DeleteAuthorizationPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A name of the AuthorizationPolicy to delete. Must be in the + * format `projects/{project}/locations/{location}/authorizationPolicies/*`. + */ + // const name = 'abc123' + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callDeleteAuthorizationPolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await networksecurityClient.deleteAuthorizationPolicy(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteAuthorizationPolicy(); + // [END networksecurity_v1beta1_generated_NetworkSecurity_DeleteAuthorizationPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_client_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_client_tls_policy.js new file mode 100644 index 00000000000..7b9f981d457 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_client_tls_policy.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 networksecurity_v1beta1_generated_NetworkSecurity_DeleteClientTlsPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A name of the ClientTlsPolicy to delete. Must be in + * the format `projects/* /locations/{location}/clientTlsPolicies/*`. + */ + // const name = 'abc123' + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callDeleteClientTlsPolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await networksecurityClient.deleteClientTlsPolicy(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteClientTlsPolicy(); + // [END networksecurity_v1beta1_generated_NetworkSecurity_DeleteClientTlsPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_server_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_server_tls_policy.js new file mode 100644 index 00000000000..6fd1a0a27d7 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_server_tls_policy.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 networksecurity_v1beta1_generated_NetworkSecurity_DeleteServerTlsPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A name of the ServerTlsPolicy to delete. Must be in + * the format `projects/* /locations/{location}/serverTlsPolicies/*`. + */ + // const name = 'abc123' + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callDeleteServerTlsPolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await networksecurityClient.deleteServerTlsPolicy(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteServerTlsPolicy(); + // [END networksecurity_v1beta1_generated_NetworkSecurity_DeleteServerTlsPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_authorization_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_authorization_policy.js new file mode 100644 index 00000000000..c3d6417d0fd --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_authorization_policy.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 networksecurity_v1beta1_generated_NetworkSecurity_GetAuthorizationPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A name of the AuthorizationPolicy to get. Must be in the format + * `projects/{project}/locations/{location}/authorizationPolicies/*`. + */ + // const name = 'abc123' + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callGetAuthorizationPolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await networksecurityClient.getAuthorizationPolicy(request); + console.log(response); + } + + callGetAuthorizationPolicy(); + // [END networksecurity_v1beta1_generated_NetworkSecurity_GetAuthorizationPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_client_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_client_tls_policy.js new file mode 100644 index 00000000000..1004b7ad7bd --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_client_tls_policy.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 networksecurity_v1beta1_generated_NetworkSecurity_GetClientTlsPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A name of the ClientTlsPolicy to get. Must be in the format + * `projects/* /locations/{location}/clientTlsPolicies/*`. + */ + // const name = 'abc123' + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callGetClientTlsPolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await networksecurityClient.getClientTlsPolicy(request); + console.log(response); + } + + callGetClientTlsPolicy(); + // [END networksecurity_v1beta1_generated_NetworkSecurity_GetClientTlsPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_server_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_server_tls_policy.js new file mode 100644 index 00000000000..939edabe360 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_server_tls_policy.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 networksecurity_v1beta1_generated_NetworkSecurity_GetServerTlsPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A name of the ServerTlsPolicy to get. Must be in the format + * `projects/* /locations/{location}/serverTlsPolicies/*`. + */ + // const name = 'abc123' + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callGetServerTlsPolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await networksecurityClient.getServerTlsPolicy(request); + console.log(response); + } + + callGetServerTlsPolicy(); + // [END networksecurity_v1beta1_generated_NetworkSecurity_GetServerTlsPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_authorization_policies.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_authorization_policies.js new file mode 100644 index 00000000000..1e87e193215 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_authorization_policies.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) { + // [START networksecurity_v1beta1_generated_NetworkSecurity_ListAuthorizationPolicies_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project and location from which the AuthorizationPolicies + * should be listed, specified in the format + * `projects/{project}/locations/{location}`. + */ + // const parent = 'abc123' + /** + * Maximum number of AuthorizationPolicies to return per call. + */ + // const pageSize = 1234 + /** + * The value returned by the last + * `ListAuthorizationPoliciesResponse` Indicates that this is a + * continuation of a prior `ListAuthorizationPolicies` call, and + * that the system should return the next page of data. + */ + // const pageToken = 'abc123' + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callListAuthorizationPolicies() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await networksecurityClient.listAuthorizationPoliciesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListAuthorizationPolicies(); + // [END networksecurity_v1beta1_generated_NetworkSecurity_ListAuthorizationPolicies_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_client_tls_policies.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_client_tls_policies.js new file mode 100644 index 00000000000..2b9b7aa9706 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_client_tls_policies.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 networksecurity_v1beta1_generated_NetworkSecurity_ListClientTlsPolicies_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project and location from which the ClientTlsPolicies should + * be listed, specified in the format `projects/* /locations/{location}`. + */ + // const parent = 'abc123' + /** + * Maximum number of ClientTlsPolicies to return per call. + */ + // const pageSize = 1234 + /** + * The value returned by the last `ListClientTlsPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListClientTlsPolicies` call, and that the system + * should return the next page of data. + */ + // const pageToken = 'abc123' + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callListClientTlsPolicies() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await networksecurityClient.listClientTlsPoliciesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListClientTlsPolicies(); + // [END networksecurity_v1beta1_generated_NetworkSecurity_ListClientTlsPolicies_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_server_tls_policies.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_server_tls_policies.js new file mode 100644 index 00000000000..5be89c04144 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_server_tls_policies.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 networksecurity_v1beta1_generated_NetworkSecurity_ListServerTlsPolicies_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project and location from which the ServerTlsPolicies should + * be listed, specified in the format `projects/* /locations/{location}`. + */ + // const parent = 'abc123' + /** + * Maximum number of ServerTlsPolicies to return per call. + */ + // const pageSize = 1234 + /** + * The value returned by the last `ListServerTlsPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListServerTlsPolicies` call, and that the system + * should return the next page of data. + */ + // const pageToken = 'abc123' + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callListServerTlsPolicies() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await networksecurityClient.listServerTlsPoliciesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListServerTlsPolicies(); + // [END networksecurity_v1beta1_generated_NetworkSecurity_ListServerTlsPolicies_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_authorization_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_authorization_policy.js new file mode 100644 index 00000000000..3b5db121a7c --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_authorization_policy.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(authorizationPolicy) { + // [START networksecurity_v1beta1_generated_NetworkSecurity_UpdateAuthorizationPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Optional. Field mask is used to specify the fields to be overwritten in the + * AuthorizationPolicy resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + */ + // const updateMask = {} + /** + * Required. Updated AuthorizationPolicy resource. + */ + // const authorizationPolicy = {} + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callUpdateAuthorizationPolicy() { + // Construct request + const request = { + authorizationPolicy, + }; + + // Run request + const [operation] = await networksecurityClient.updateAuthorizationPolicy(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateAuthorizationPolicy(); + // [END networksecurity_v1beta1_generated_NetworkSecurity_UpdateAuthorizationPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_client_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_client_tls_policy.js new file mode 100644 index 00000000000..c18ee51a0b5 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_client_tls_policy.js @@ -0,0 +1,71 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(clientTlsPolicy) { + // [START networksecurity_v1beta1_generated_NetworkSecurity_UpdateClientTlsPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Optional. Field mask is used to specify the fields to be overwritten in the + * ClientTlsPolicy resource by the update. The fields + * specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the + * mask. If the user does not provide a mask then all fields will be + * overwritten. + */ + // const updateMask = {} + /** + * Required. Updated ClientTlsPolicy resource. + */ + // const clientTlsPolicy = {} + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callUpdateClientTlsPolicy() { + // Construct request + const request = { + clientTlsPolicy, + }; + + // Run request + const [operation] = await networksecurityClient.updateClientTlsPolicy(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateClientTlsPolicy(); + // [END networksecurity_v1beta1_generated_NetworkSecurity_UpdateClientTlsPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_server_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_server_tls_policy.js new file mode 100644 index 00000000000..b6c9a2252d0 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_server_tls_policy.js @@ -0,0 +1,71 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(serverTlsPolicy) { + // [START networksecurity_v1beta1_generated_NetworkSecurity_UpdateServerTlsPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Optional. Field mask is used to specify the fields to be overwritten in the + * ServerTlsPolicy resource by the update. The fields + * specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the + * mask. If the user does not provide a mask then all fields will be + * overwritten. + */ + // const updateMask = {} + /** + * Required. Updated ServerTlsPolicy resource. + */ + // const serverTlsPolicy = {} + + // Imports the Networksecurity library + const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; + + // Instantiates a client + const networksecurityClient = new NetworkSecurityClient(); + + async function callUpdateServerTlsPolicy() { + // Construct request + const request = { + serverTlsPolicy, + }; + + // Run request + const [operation] = await networksecurityClient.updateServerTlsPolicy(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateServerTlsPolicy(); + // [END networksecurity_v1beta1_generated_NetworkSecurity_UpdateServerTlsPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.networksecurity.v1beta1.json b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.networksecurity.v1beta1.json new file mode 100644 index 00000000000..e6aa109a35f --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.networksecurity.v1beta1.json @@ -0,0 +1,675 @@ +{ + "clientLibrary": { + "name": "nodejs-networksecurity", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.networksecurity.v1beta1", + "version": "v1beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_ListAuthorizationPolicies_async", + "title": "NetworkSecurity listAuthorizationPolicies Sample", + "origin": "API_DEFINITION", + "description": " Lists AuthorizationPolicies in a given project and location.", + "canonical": true, + "file": "network_security.list_authorization_policies.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListAuthorizationPolicies", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.ListAuthorizationPolicies", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesResponse", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" + }, + "method": { + "shortName": "ListAuthorizationPolicies", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.ListAuthorizationPolicies", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_GetAuthorizationPolicy_async", + "title": "NetworkSecurity getAuthorizationPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets details of a single AuthorizationPolicy.", + "canonical": true, + "file": "network_security.get_authorization_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetAuthorizationPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.GetAuthorizationPolicy", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.networksecurity.v1beta1.AuthorizationPolicy", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" + }, + "method": { + "shortName": "GetAuthorizationPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.GetAuthorizationPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_CreateAuthorizationPolicy_async", + "title": "NetworkSecurity createAuthorizationPolicy Sample", + "origin": "API_DEFINITION", + "description": " Creates a new AuthorizationPolicy in a given project and location.", + "canonical": true, + "file": "network_security.create_authorization_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateAuthorizationPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.CreateAuthorizationPolicy", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "authorization_policy_id", + "type": "TYPE_STRING" + }, + { + "name": "authorization_policy", + "type": ".google.cloud.networksecurity.v1beta1.AuthorizationPolicy" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" + }, + "method": { + "shortName": "CreateAuthorizationPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.CreateAuthorizationPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_UpdateAuthorizationPolicy_async", + "title": "NetworkSecurity updateAuthorizationPolicy Sample", + "origin": "API_DEFINITION", + "description": " Updates the parameters of a single AuthorizationPolicy.", + "canonical": true, + "file": "network_security.update_authorization_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateAuthorizationPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.UpdateAuthorizationPolicy", + "async": true, + "parameters": [ + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "authorization_policy", + "type": ".google.cloud.networksecurity.v1beta1.AuthorizationPolicy" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" + }, + "method": { + "shortName": "UpdateAuthorizationPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.UpdateAuthorizationPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_DeleteAuthorizationPolicy_async", + "title": "NetworkSecurity deleteAuthorizationPolicy Sample", + "origin": "API_DEFINITION", + "description": " Deletes a single AuthorizationPolicy.", + "canonical": true, + "file": "network_security.delete_authorization_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteAuthorizationPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.DeleteAuthorizationPolicy", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" + }, + "method": { + "shortName": "DeleteAuthorizationPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.DeleteAuthorizationPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_ListServerTlsPolicies_async", + "title": "NetworkSecurity listServerTlsPolicies Sample", + "origin": "API_DEFINITION", + "description": " Lists ServerTlsPolicies in a given project and location.", + "canonical": true, + "file": "network_security.list_server_tls_policies.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListServerTlsPolicies", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.ListServerTlsPolicies", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesResponse", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" + }, + "method": { + "shortName": "ListServerTlsPolicies", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.ListServerTlsPolicies", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_GetServerTlsPolicy_async", + "title": "NetworkSecurity getServerTlsPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets details of a single ServerTlsPolicy.", + "canonical": true, + "file": "network_security.get_server_tls_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetServerTlsPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.GetServerTlsPolicy", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.networksecurity.v1beta1.ServerTlsPolicy", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" + }, + "method": { + "shortName": "GetServerTlsPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.GetServerTlsPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_CreateServerTlsPolicy_async", + "title": "NetworkSecurity createServerTlsPolicy Sample", + "origin": "API_DEFINITION", + "description": " Creates a new ServerTlsPolicy in a given project and location.", + "canonical": true, + "file": "network_security.create_server_tls_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateServerTlsPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.CreateServerTlsPolicy", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "server_tls_policy_id", + "type": "TYPE_STRING" + }, + { + "name": "server_tls_policy", + "type": ".google.cloud.networksecurity.v1beta1.ServerTlsPolicy" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" + }, + "method": { + "shortName": "CreateServerTlsPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.CreateServerTlsPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_UpdateServerTlsPolicy_async", + "title": "NetworkSecurity updateServerTlsPolicy Sample", + "origin": "API_DEFINITION", + "description": " Updates the parameters of a single ServerTlsPolicy.", + "canonical": true, + "file": "network_security.update_server_tls_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateServerTlsPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.UpdateServerTlsPolicy", + "async": true, + "parameters": [ + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "server_tls_policy", + "type": ".google.cloud.networksecurity.v1beta1.ServerTlsPolicy" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" + }, + "method": { + "shortName": "UpdateServerTlsPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.UpdateServerTlsPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_DeleteServerTlsPolicy_async", + "title": "NetworkSecurity deleteServerTlsPolicy Sample", + "origin": "API_DEFINITION", + "description": " Deletes a single ServerTlsPolicy.", + "canonical": true, + "file": "network_security.delete_server_tls_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteServerTlsPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.DeleteServerTlsPolicy", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" + }, + "method": { + "shortName": "DeleteServerTlsPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.DeleteServerTlsPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_ListClientTlsPolicies_async", + "title": "NetworkSecurity listClientTlsPolicies Sample", + "origin": "API_DEFINITION", + "description": " Lists ClientTlsPolicies in a given project and location.", + "canonical": true, + "file": "network_security.list_client_tls_policies.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListClientTlsPolicies", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.ListClientTlsPolicies", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesResponse", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" + }, + "method": { + "shortName": "ListClientTlsPolicies", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.ListClientTlsPolicies", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_GetClientTlsPolicy_async", + "title": "NetworkSecurity getClientTlsPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets details of a single ClientTlsPolicy.", + "canonical": true, + "file": "network_security.get_client_tls_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetClientTlsPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.GetClientTlsPolicy", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.networksecurity.v1beta1.ClientTlsPolicy", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" + }, + "method": { + "shortName": "GetClientTlsPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.GetClientTlsPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_CreateClientTlsPolicy_async", + "title": "NetworkSecurity createClientTlsPolicy Sample", + "origin": "API_DEFINITION", + "description": " Creates a new ClientTlsPolicy in a given project and location.", + "canonical": true, + "file": "network_security.create_client_tls_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateClientTlsPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.CreateClientTlsPolicy", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "client_tls_policy_id", + "type": "TYPE_STRING" + }, + { + "name": "client_tls_policy", + "type": ".google.cloud.networksecurity.v1beta1.ClientTlsPolicy" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" + }, + "method": { + "shortName": "CreateClientTlsPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.CreateClientTlsPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_UpdateClientTlsPolicy_async", + "title": "NetworkSecurity updateClientTlsPolicy Sample", + "origin": "API_DEFINITION", + "description": " Updates the parameters of a single ClientTlsPolicy.", + "canonical": true, + "file": "network_security.update_client_tls_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateClientTlsPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.UpdateClientTlsPolicy", + "async": true, + "parameters": [ + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "client_tls_policy", + "type": ".google.cloud.networksecurity.v1beta1.ClientTlsPolicy" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" + }, + "method": { + "shortName": "UpdateClientTlsPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.UpdateClientTlsPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" + } + } + } + }, + { + "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_DeleteClientTlsPolicy_async", + "title": "NetworkSecurity deleteClientTlsPolicy Sample", + "origin": "API_DEFINITION", + "description": " Deletes a single ClientTlsPolicy.", + "canonical": true, + "file": "network_security.delete_client_tls_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteClientTlsPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.DeleteClientTlsPolicy", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NetworkSecurityClient", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" + }, + "method": { + "shortName": "DeleteClientTlsPolicy", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.DeleteClientTlsPolicy", + "service": { + "shortName": "NetworkSecurity", + "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/index.ts new file mode 100644 index 00000000000..550885bb0e9 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1beta1 from './v1beta1'; +const NetworkSecurityClient = v1beta1.NetworkSecurityClient; +type NetworkSecurityClient = v1beta1.NetworkSecurityClient; +export {v1beta1, NetworkSecurityClient}; +export default {v1beta1, NetworkSecurityClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/gapic_metadata.json new file mode 100644 index 00000000000..4378e4f3a6b --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/gapic_metadata.json @@ -0,0 +1,185 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.networksecurity.v1beta1", + "libraryPackage": "@google-cloud/network-security", + "services": { + "NetworkSecurity": { + "clients": { + "grpc": { + "libraryClient": "NetworkSecurityClient", + "rpcs": { + "GetAuthorizationPolicy": { + "methods": [ + "getAuthorizationPolicy" + ] + }, + "GetServerTlsPolicy": { + "methods": [ + "getServerTlsPolicy" + ] + }, + "GetClientTlsPolicy": { + "methods": [ + "getClientTlsPolicy" + ] + }, + "CreateAuthorizationPolicy": { + "methods": [ + "createAuthorizationPolicy" + ] + }, + "UpdateAuthorizationPolicy": { + "methods": [ + "updateAuthorizationPolicy" + ] + }, + "DeleteAuthorizationPolicy": { + "methods": [ + "deleteAuthorizationPolicy" + ] + }, + "CreateServerTlsPolicy": { + "methods": [ + "createServerTlsPolicy" + ] + }, + "UpdateServerTlsPolicy": { + "methods": [ + "updateServerTlsPolicy" + ] + }, + "DeleteServerTlsPolicy": { + "methods": [ + "deleteServerTlsPolicy" + ] + }, + "CreateClientTlsPolicy": { + "methods": [ + "createClientTlsPolicy" + ] + }, + "UpdateClientTlsPolicy": { + "methods": [ + "updateClientTlsPolicy" + ] + }, + "DeleteClientTlsPolicy": { + "methods": [ + "deleteClientTlsPolicy" + ] + }, + "ListAuthorizationPolicies": { + "methods": [ + "listAuthorizationPolicies", + "listAuthorizationPoliciesStream", + "listAuthorizationPoliciesAsync" + ] + }, + "ListServerTlsPolicies": { + "methods": [ + "listServerTlsPolicies", + "listServerTlsPoliciesStream", + "listServerTlsPoliciesAsync" + ] + }, + "ListClientTlsPolicies": { + "methods": [ + "listClientTlsPolicies", + "listClientTlsPoliciesStream", + "listClientTlsPoliciesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "NetworkSecurityClient", + "rpcs": { + "GetAuthorizationPolicy": { + "methods": [ + "getAuthorizationPolicy" + ] + }, + "GetServerTlsPolicy": { + "methods": [ + "getServerTlsPolicy" + ] + }, + "GetClientTlsPolicy": { + "methods": [ + "getClientTlsPolicy" + ] + }, + "CreateAuthorizationPolicy": { + "methods": [ + "createAuthorizationPolicy" + ] + }, + "UpdateAuthorizationPolicy": { + "methods": [ + "updateAuthorizationPolicy" + ] + }, + "DeleteAuthorizationPolicy": { + "methods": [ + "deleteAuthorizationPolicy" + ] + }, + "CreateServerTlsPolicy": { + "methods": [ + "createServerTlsPolicy" + ] + }, + "UpdateServerTlsPolicy": { + "methods": [ + "updateServerTlsPolicy" + ] + }, + "DeleteServerTlsPolicy": { + "methods": [ + "deleteServerTlsPolicy" + ] + }, + "CreateClientTlsPolicy": { + "methods": [ + "createClientTlsPolicy" + ] + }, + "UpdateClientTlsPolicy": { + "methods": [ + "updateClientTlsPolicy" + ] + }, + "DeleteClientTlsPolicy": { + "methods": [ + "deleteClientTlsPolicy" + ] + }, + "ListAuthorizationPolicies": { + "methods": [ + "listAuthorizationPolicies", + "listAuthorizationPoliciesStream", + "listAuthorizationPoliciesAsync" + ] + }, + "ListServerTlsPolicies": { + "methods": [ + "listServerTlsPolicies", + "listServerTlsPoliciesStream", + "listServerTlsPoliciesAsync" + ] + }, + "ListClientTlsPolicies": { + "methods": [ + "listClientTlsPolicies", + "listClientTlsPoliciesStream", + "listClientTlsPoliciesAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/index.ts new file mode 100644 index 00000000000..e2b4efdd9b3 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {NetworkSecurityClient} from './network_security_client'; diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_client.ts b/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_client.ts new file mode 100644 index 00000000000..30faca4b9a8 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_client.ts @@ -0,0 +1,2594 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, IamClient, IamProtos, 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/v1beta1/network_security_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './network_security_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Network Security API provides resources to configure authentication and + * authorization policies. Refer to per API resource documentation for more + * information. + * @class + * @memberof v1beta1 + */ +export class NetworkSecurityClient { + 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}; + iamClient: IamClient; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + networkSecurityStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of NetworkSecurityClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 NetworkSecurityClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof NetworkSecurityClient; + 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.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); + + 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 { + 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 = { + authorizationPolicyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/authorizationPolicies/{authorization_policy}' + ), + clientTlsPolicyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/clientTlsPolicies/{client_tls_policy}' + ), + serverTlsPolicyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/serverTlsPolicies/{server_tls_policy}' + ), + }; + + // 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 = { + listAuthorizationPolicies: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'authorizationPolicies'), + listServerTlsPolicies: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'serverTlsPolicies'), + listClientTlsPolicies: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'clientTlsPolicies') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1beta1/{resource=projects/*/locations/*/authorizationPolicies/*}:getIamPolicy',additional_bindings: [{get: '/v1beta1/{resource=projects/*/locations/*/serverTlsPolicies/*}:getIamPolicy',},{get: '/v1beta1/{resource=projects/*/locations/*/clientTlsPolicies/*}:getIamPolicy',}], + },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1beta1/{resource=projects/*/locations/*/authorizationPolicies/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1beta1/{resource=projects/*/locations/*/serverTlsPolicies/*}:setIamPolicy',body: '*',},{post: '/v1beta1/{resource=projects/*/locations/*/clientTlsPolicies/*}:setIamPolicy',body: '*',}], + },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1beta1/{resource=projects/*/locations/*/authorizationPolicies/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1beta1/{resource=projects/*/locations/*/serverTlsPolicies/*}:testIamPermissions',body: '*',},{post: '/v1beta1/{resource=projects/*/locations/*/clientTlsPolicies/*}:testIamPermissions',body: '*',}], + },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta1/{name=projects/*/locations/*}/operations',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createAuthorizationPolicyResponse = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1beta1.AuthorizationPolicy') as gax.protobuf.Type; + const createAuthorizationPolicyMetadata = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1beta1.OperationMetadata') as gax.protobuf.Type; + const updateAuthorizationPolicyResponse = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1beta1.AuthorizationPolicy') as gax.protobuf.Type; + const updateAuthorizationPolicyMetadata = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1beta1.OperationMetadata') as gax.protobuf.Type; + const deleteAuthorizationPolicyResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteAuthorizationPolicyMetadata = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1beta1.OperationMetadata') as gax.protobuf.Type; + const createServerTlsPolicyResponse = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1beta1.ServerTlsPolicy') as gax.protobuf.Type; + const createServerTlsPolicyMetadata = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1beta1.OperationMetadata') as gax.protobuf.Type; + const updateServerTlsPolicyResponse = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1beta1.ServerTlsPolicy') as gax.protobuf.Type; + const updateServerTlsPolicyMetadata = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1beta1.OperationMetadata') as gax.protobuf.Type; + const deleteServerTlsPolicyResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteServerTlsPolicyMetadata = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1beta1.OperationMetadata') as gax.protobuf.Type; + const createClientTlsPolicyResponse = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1beta1.ClientTlsPolicy') as gax.protobuf.Type; + const createClientTlsPolicyMetadata = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1beta1.OperationMetadata') as gax.protobuf.Type; + const updateClientTlsPolicyResponse = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1beta1.ClientTlsPolicy') as gax.protobuf.Type; + const updateClientTlsPolicyMetadata = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1beta1.OperationMetadata') as gax.protobuf.Type; + const deleteClientTlsPolicyResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteClientTlsPolicyMetadata = protoFilesRoot.lookup( + '.google.cloud.networksecurity.v1beta1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createAuthorizationPolicy: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createAuthorizationPolicyResponse.decode.bind(createAuthorizationPolicyResponse), + createAuthorizationPolicyMetadata.decode.bind(createAuthorizationPolicyMetadata)), + updateAuthorizationPolicy: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateAuthorizationPolicyResponse.decode.bind(updateAuthorizationPolicyResponse), + updateAuthorizationPolicyMetadata.decode.bind(updateAuthorizationPolicyMetadata)), + deleteAuthorizationPolicy: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteAuthorizationPolicyResponse.decode.bind(deleteAuthorizationPolicyResponse), + deleteAuthorizationPolicyMetadata.decode.bind(deleteAuthorizationPolicyMetadata)), + createServerTlsPolicy: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createServerTlsPolicyResponse.decode.bind(createServerTlsPolicyResponse), + createServerTlsPolicyMetadata.decode.bind(createServerTlsPolicyMetadata)), + updateServerTlsPolicy: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateServerTlsPolicyResponse.decode.bind(updateServerTlsPolicyResponse), + updateServerTlsPolicyMetadata.decode.bind(updateServerTlsPolicyMetadata)), + deleteServerTlsPolicy: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteServerTlsPolicyResponse.decode.bind(deleteServerTlsPolicyResponse), + deleteServerTlsPolicyMetadata.decode.bind(deleteServerTlsPolicyMetadata)), + createClientTlsPolicy: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createClientTlsPolicyResponse.decode.bind(createClientTlsPolicyResponse), + createClientTlsPolicyMetadata.decode.bind(createClientTlsPolicyMetadata)), + updateClientTlsPolicy: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateClientTlsPolicyResponse.decode.bind(updateClientTlsPolicyResponse), + updateClientTlsPolicyMetadata.decode.bind(updateClientTlsPolicyMetadata)), + deleteClientTlsPolicy: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteClientTlsPolicyResponse.decode.bind(deleteClientTlsPolicyResponse), + deleteClientTlsPolicyMetadata.decode.bind(deleteClientTlsPolicyMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.networksecurity.v1beta1.NetworkSecurity', 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.networkSecurityStub) { + return this.networkSecurityStub; + } + + // Put together the "service stub" for + // google.cloud.networksecurity.v1beta1.NetworkSecurity. + this.networkSecurityStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.networksecurity.v1beta1.NetworkSecurity') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.networksecurity.v1beta1.NetworkSecurity, + 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 networkSecurityStubMethods = + ['listAuthorizationPolicies', 'getAuthorizationPolicy', 'createAuthorizationPolicy', 'updateAuthorizationPolicy', 'deleteAuthorizationPolicy', 'listServerTlsPolicies', 'getServerTlsPolicy', 'createServerTlsPolicy', 'updateServerTlsPolicy', 'deleteServerTlsPolicy', 'listClientTlsPolicies', 'getClientTlsPolicy', 'createClientTlsPolicy', 'updateClientTlsPolicy', 'deleteClientTlsPolicy']; + for (const methodName of networkSecurityStubMethods) { + const callPromise = this.networkSecurityStub.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.networkSecurityStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'networksecurity.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 'networksecurity.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 details of a single AuthorizationPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the AuthorizationPolicy to get. Must be in the format + * `projects/{project}/locations/{location}/authorizationPolicies/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy|AuthorizationPolicy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.get_authorization_policy.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_GetAuthorizationPolicy_async + */ + getAuthorizationPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.IGetAuthorizationPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy, + protos.google.cloud.networksecurity.v1beta1.IGetAuthorizationPolicyRequest|undefined, {}|undefined + ]>; + getAuthorizationPolicy( + request: protos.google.cloud.networksecurity.v1beta1.IGetAuthorizationPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy, + protos.google.cloud.networksecurity.v1beta1.IGetAuthorizationPolicyRequest|null|undefined, + {}|null|undefined>): void; + getAuthorizationPolicy( + request: protos.google.cloud.networksecurity.v1beta1.IGetAuthorizationPolicyRequest, + callback: Callback< + protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy, + protos.google.cloud.networksecurity.v1beta1.IGetAuthorizationPolicyRequest|null|undefined, + {}|null|undefined>): void; + getAuthorizationPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.IGetAuthorizationPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy, + protos.google.cloud.networksecurity.v1beta1.IGetAuthorizationPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy, + protos.google.cloud.networksecurity.v1beta1.IGetAuthorizationPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy, + protos.google.cloud.networksecurity.v1beta1.IGetAuthorizationPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getAuthorizationPolicy(request, options, callback); + } +/** + * Gets details of a single ServerTlsPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the ServerTlsPolicy to get. Must be in the format + * `projects/* /locations/{location}/serverTlsPolicies/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy|ServerTlsPolicy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.get_server_tls_policy.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_GetServerTlsPolicy_async + */ + getServerTlsPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.IGetServerTlsPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy, + protos.google.cloud.networksecurity.v1beta1.IGetServerTlsPolicyRequest|undefined, {}|undefined + ]>; + getServerTlsPolicy( + request: protos.google.cloud.networksecurity.v1beta1.IGetServerTlsPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy, + protos.google.cloud.networksecurity.v1beta1.IGetServerTlsPolicyRequest|null|undefined, + {}|null|undefined>): void; + getServerTlsPolicy( + request: protos.google.cloud.networksecurity.v1beta1.IGetServerTlsPolicyRequest, + callback: Callback< + protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy, + protos.google.cloud.networksecurity.v1beta1.IGetServerTlsPolicyRequest|null|undefined, + {}|null|undefined>): void; + getServerTlsPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.IGetServerTlsPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy, + protos.google.cloud.networksecurity.v1beta1.IGetServerTlsPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy, + protos.google.cloud.networksecurity.v1beta1.IGetServerTlsPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy, + protos.google.cloud.networksecurity.v1beta1.IGetServerTlsPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getServerTlsPolicy(request, options, callback); + } +/** + * Gets details of a single ClientTlsPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the ClientTlsPolicy to get. Must be in the format + * `projects/* /locations/{location}/clientTlsPolicies/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy|ClientTlsPolicy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.get_client_tls_policy.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_GetClientTlsPolicy_async + */ + getClientTlsPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.IGetClientTlsPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy, + protos.google.cloud.networksecurity.v1beta1.IGetClientTlsPolicyRequest|undefined, {}|undefined + ]>; + getClientTlsPolicy( + request: protos.google.cloud.networksecurity.v1beta1.IGetClientTlsPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy, + protos.google.cloud.networksecurity.v1beta1.IGetClientTlsPolicyRequest|null|undefined, + {}|null|undefined>): void; + getClientTlsPolicy( + request: protos.google.cloud.networksecurity.v1beta1.IGetClientTlsPolicyRequest, + callback: Callback< + protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy, + protos.google.cloud.networksecurity.v1beta1.IGetClientTlsPolicyRequest|null|undefined, + {}|null|undefined>): void; + getClientTlsPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.IGetClientTlsPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy, + protos.google.cloud.networksecurity.v1beta1.IGetClientTlsPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy, + protos.google.cloud.networksecurity.v1beta1.IGetClientTlsPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy, + protos.google.cloud.networksecurity.v1beta1.IGetClientTlsPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getClientTlsPolicy(request, options, callback); + } + +/** + * Creates a new AuthorizationPolicy in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the AuthorizationPolicy. Must be in the + * format `projects/{project}/locations/{location}`. + * @param {string} request.authorizationPolicyId + * Required. Short name of the AuthorizationPolicy resource to be created. + * This value should be 1-63 characters long, containing only + * letters, numbers, hyphens, and underscores, and should not start + * with a number. E.g. "authz_policy". + * @param {google.cloud.networksecurity.v1beta1.AuthorizationPolicy} request.authorizationPolicy + * Required. AuthorizationPolicy resource to be created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.create_authorization_policy.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_CreateAuthorizationPolicy_async + */ + createAuthorizationPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.ICreateAuthorizationPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createAuthorizationPolicy( + request: protos.google.cloud.networksecurity.v1beta1.ICreateAuthorizationPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createAuthorizationPolicy( + request: protos.google.cloud.networksecurity.v1beta1.ICreateAuthorizationPolicyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createAuthorizationPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.ICreateAuthorizationPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createAuthorizationPolicy(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createAuthorizationPolicy()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.create_authorization_policy.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_CreateAuthorizationPolicy_async + */ + async checkCreateAuthorizationPolicyProgress(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.createAuthorizationPolicy, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the parameters of a single AuthorizationPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * AuthorizationPolicy resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.networksecurity.v1beta1.AuthorizationPolicy} request.authorizationPolicy + * Required. Updated AuthorizationPolicy resource. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.update_authorization_policy.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_UpdateAuthorizationPolicy_async + */ + updateAuthorizationPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.IUpdateAuthorizationPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateAuthorizationPolicy( + request: protos.google.cloud.networksecurity.v1beta1.IUpdateAuthorizationPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateAuthorizationPolicy( + request: protos.google.cloud.networksecurity.v1beta1.IUpdateAuthorizationPolicyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateAuthorizationPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.IUpdateAuthorizationPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'authorization_policy.name': request.authorizationPolicy!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateAuthorizationPolicy(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateAuthorizationPolicy()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.update_authorization_policy.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_UpdateAuthorizationPolicy_async + */ + async checkUpdateAuthorizationPolicyProgress(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.updateAuthorizationPolicy, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a single AuthorizationPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the AuthorizationPolicy to delete. Must be in the + * format `projects/{project}/locations/{location}/authorizationPolicies/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.delete_authorization_policy.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_DeleteAuthorizationPolicy_async + */ + deleteAuthorizationPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.IDeleteAuthorizationPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteAuthorizationPolicy( + request: protos.google.cloud.networksecurity.v1beta1.IDeleteAuthorizationPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteAuthorizationPolicy( + request: protos.google.cloud.networksecurity.v1beta1.IDeleteAuthorizationPolicyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteAuthorizationPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.IDeleteAuthorizationPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteAuthorizationPolicy(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteAuthorizationPolicy()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.delete_authorization_policy.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_DeleteAuthorizationPolicy_async + */ + async checkDeleteAuthorizationPolicyProgress(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.deleteAuthorizationPolicy, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Creates a new ServerTlsPolicy in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the ServerTlsPolicy. Must be in + * the format `projects/* /locations/{location}`. + * @param {string} request.serverTlsPolicyId + * Required. Short name of the ServerTlsPolicy resource to be created. This + * value should be 1-63 characters long, containing only letters, numbers, + * hyphens, and underscores, and should not start with a number. E.g. + * "server_mtls_policy". + * @param {google.cloud.networksecurity.v1beta1.ServerTlsPolicy} request.serverTlsPolicy + * Required. ServerTlsPolicy resource to be created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.create_server_tls_policy.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_CreateServerTlsPolicy_async + */ + createServerTlsPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.ICreateServerTlsPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createServerTlsPolicy( + request: protos.google.cloud.networksecurity.v1beta1.ICreateServerTlsPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createServerTlsPolicy( + request: protos.google.cloud.networksecurity.v1beta1.ICreateServerTlsPolicyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createServerTlsPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.ICreateServerTlsPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createServerTlsPolicy(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createServerTlsPolicy()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.create_server_tls_policy.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_CreateServerTlsPolicy_async + */ + async checkCreateServerTlsPolicyProgress(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.createServerTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the parameters of a single ServerTlsPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * ServerTlsPolicy resource by the update. The fields + * specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the + * mask. If the user does not provide a mask then all fields will be + * overwritten. + * @param {google.cloud.networksecurity.v1beta1.ServerTlsPolicy} request.serverTlsPolicy + * Required. Updated ServerTlsPolicy resource. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.update_server_tls_policy.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_UpdateServerTlsPolicy_async + */ + updateServerTlsPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.IUpdateServerTlsPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateServerTlsPolicy( + request: protos.google.cloud.networksecurity.v1beta1.IUpdateServerTlsPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateServerTlsPolicy( + request: protos.google.cloud.networksecurity.v1beta1.IUpdateServerTlsPolicyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateServerTlsPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.IUpdateServerTlsPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'server_tls_policy.name': request.serverTlsPolicy!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateServerTlsPolicy(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateServerTlsPolicy()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.update_server_tls_policy.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_UpdateServerTlsPolicy_async + */ + async checkUpdateServerTlsPolicyProgress(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.updateServerTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a single ServerTlsPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the ServerTlsPolicy to delete. Must be in + * the format `projects/* /locations/{location}/serverTlsPolicies/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.delete_server_tls_policy.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_DeleteServerTlsPolicy_async + */ + deleteServerTlsPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.IDeleteServerTlsPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteServerTlsPolicy( + request: protos.google.cloud.networksecurity.v1beta1.IDeleteServerTlsPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteServerTlsPolicy( + request: protos.google.cloud.networksecurity.v1beta1.IDeleteServerTlsPolicyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteServerTlsPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.IDeleteServerTlsPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteServerTlsPolicy(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteServerTlsPolicy()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.delete_server_tls_policy.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_DeleteServerTlsPolicy_async + */ + async checkDeleteServerTlsPolicyProgress(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.deleteServerTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Creates a new ClientTlsPolicy in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the ClientTlsPolicy. Must be in + * the format `projects/* /locations/{location}`. + * @param {string} request.clientTlsPolicyId + * Required. Short name of the ClientTlsPolicy resource to be created. This + * value should be 1-63 characters long, containing only letters, numbers, + * hyphens, and underscores, and should not start with a number. E.g. + * "client_mtls_policy". + * @param {google.cloud.networksecurity.v1beta1.ClientTlsPolicy} request.clientTlsPolicy + * Required. ClientTlsPolicy resource to be created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.create_client_tls_policy.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_CreateClientTlsPolicy_async + */ + createClientTlsPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.ICreateClientTlsPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createClientTlsPolicy( + request: protos.google.cloud.networksecurity.v1beta1.ICreateClientTlsPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createClientTlsPolicy( + request: protos.google.cloud.networksecurity.v1beta1.ICreateClientTlsPolicyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createClientTlsPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.ICreateClientTlsPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createClientTlsPolicy(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createClientTlsPolicy()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.create_client_tls_policy.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_CreateClientTlsPolicy_async + */ + async checkCreateClientTlsPolicyProgress(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.createClientTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the parameters of a single ClientTlsPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * ClientTlsPolicy resource by the update. The fields + * specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the + * mask. If the user does not provide a mask then all fields will be + * overwritten. + * @param {google.cloud.networksecurity.v1beta1.ClientTlsPolicy} request.clientTlsPolicy + * Required. Updated ClientTlsPolicy resource. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.update_client_tls_policy.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_UpdateClientTlsPolicy_async + */ + updateClientTlsPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.IUpdateClientTlsPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateClientTlsPolicy( + request: protos.google.cloud.networksecurity.v1beta1.IUpdateClientTlsPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateClientTlsPolicy( + request: protos.google.cloud.networksecurity.v1beta1.IUpdateClientTlsPolicyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateClientTlsPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.IUpdateClientTlsPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'client_tls_policy.name': request.clientTlsPolicy!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateClientTlsPolicy(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateClientTlsPolicy()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.update_client_tls_policy.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_UpdateClientTlsPolicy_async + */ + async checkUpdateClientTlsPolicyProgress(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.updateClientTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a single ClientTlsPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the ClientTlsPolicy to delete. Must be in + * the format `projects/* /locations/{location}/clientTlsPolicies/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.delete_client_tls_policy.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_DeleteClientTlsPolicy_async + */ + deleteClientTlsPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.IDeleteClientTlsPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteClientTlsPolicy( + request: protos.google.cloud.networksecurity.v1beta1.IDeleteClientTlsPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteClientTlsPolicy( + request: protos.google.cloud.networksecurity.v1beta1.IDeleteClientTlsPolicyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteClientTlsPolicy( + request?: protos.google.cloud.networksecurity.v1beta1.IDeleteClientTlsPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteClientTlsPolicy(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteClientTlsPolicy()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.delete_client_tls_policy.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_DeleteClientTlsPolicy_async + */ + async checkDeleteClientTlsPolicyProgress(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.deleteClientTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists AuthorizationPolicies in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the AuthorizationPolicies + * should be listed, specified in the format + * `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * Maximum number of AuthorizationPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last + * `ListAuthorizationPoliciesResponse` Indicates that this is a + * continuation of a prior `ListAuthorizationPolicies` call, and + * that the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy|AuthorizationPolicy}. + * 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 `listAuthorizationPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listAuthorizationPolicies( + request?: protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy[], + protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest|null, + protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesResponse + ]>; + listAuthorizationPolicies( + request: protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest, + protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy>): void; + listAuthorizationPolicies( + request: protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest, + protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy>): void; + listAuthorizationPolicies( + request?: protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest, + protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy>, + callback?: PaginationCallback< + protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest, + protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy>): + Promise<[ + protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy[], + protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest|null, + protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listAuthorizationPolicies(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the AuthorizationPolicies + * should be listed, specified in the format + * `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * Maximum number of AuthorizationPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last + * `ListAuthorizationPoliciesResponse` Indicates that this is a + * continuation of a prior `ListAuthorizationPolicies` call, and + * that the system should return the next page of data. + * @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 protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy|AuthorizationPolicy} 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 `listAuthorizationPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listAuthorizationPoliciesStream( + request?: protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest, + 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['listAuthorizationPolicies']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listAuthorizationPolicies.createStream( + this.innerApiCalls.listAuthorizationPolicies as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listAuthorizationPolicies`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the AuthorizationPolicies + * should be listed, specified in the format + * `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * Maximum number of AuthorizationPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last + * `ListAuthorizationPoliciesResponse` Indicates that this is a + * continuation of a prior `ListAuthorizationPolicies` call, and + * that the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy|AuthorizationPolicy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.list_authorization_policies.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_ListAuthorizationPolicies_async + */ + listAuthorizationPoliciesAsync( + request?: protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest, + 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['listAuthorizationPolicies']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listAuthorizationPolicies.asyncIterate( + this.innerApiCalls['listAuthorizationPolicies'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists ServerTlsPolicies in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the ServerTlsPolicies should + * be listed, specified in the format `projects/* /locations/{location}`. + * @param {number} request.pageSize + * Maximum number of ServerTlsPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListServerTlsPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListServerTlsPolicies` call, and that the system + * should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy|ServerTlsPolicy}. + * 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 `listServerTlsPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listServerTlsPolicies( + request?: protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy[], + protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest|null, + protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesResponse + ]>; + listServerTlsPolicies( + request: protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest, + protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy>): void; + listServerTlsPolicies( + request: protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest, + protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy>): void; + listServerTlsPolicies( + request?: protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest, + protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy>, + callback?: PaginationCallback< + protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest, + protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy>): + Promise<[ + protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy[], + protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest|null, + protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listServerTlsPolicies(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the ServerTlsPolicies should + * be listed, specified in the format `projects/* /locations/{location}`. + * @param {number} request.pageSize + * Maximum number of ServerTlsPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListServerTlsPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListServerTlsPolicies` call, and that the system + * should return the next page of data. + * @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 protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy|ServerTlsPolicy} 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 `listServerTlsPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listServerTlsPoliciesStream( + request?: protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest, + 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['listServerTlsPolicies']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServerTlsPolicies.createStream( + this.innerApiCalls.listServerTlsPolicies as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listServerTlsPolicies`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the ServerTlsPolicies should + * be listed, specified in the format `projects/* /locations/{location}`. + * @param {number} request.pageSize + * Maximum number of ServerTlsPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListServerTlsPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListServerTlsPolicies` call, and that the system + * should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy|ServerTlsPolicy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.list_server_tls_policies.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_ListServerTlsPolicies_async + */ + listServerTlsPoliciesAsync( + request?: protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest, + 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['listServerTlsPolicies']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServerTlsPolicies.asyncIterate( + this.innerApiCalls['listServerTlsPolicies'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists ClientTlsPolicies in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the ClientTlsPolicies should + * be listed, specified in the format `projects/* /locations/{location}`. + * @param {number} request.pageSize + * Maximum number of ClientTlsPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListClientTlsPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListClientTlsPolicies` call, and that the system + * should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy|ClientTlsPolicy}. + * 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 `listClientTlsPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listClientTlsPolicies( + request?: protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy[], + protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest|null, + protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesResponse + ]>; + listClientTlsPolicies( + request: protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest, + protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy>): void; + listClientTlsPolicies( + request: protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest, + protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy>): void; + listClientTlsPolicies( + request?: protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest, + protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy>, + callback?: PaginationCallback< + protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest, + protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesResponse|null|undefined, + protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy>): + Promise<[ + protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy[], + protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest|null, + protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listClientTlsPolicies(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the ClientTlsPolicies should + * be listed, specified in the format `projects/* /locations/{location}`. + * @param {number} request.pageSize + * Maximum number of ClientTlsPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListClientTlsPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListClientTlsPolicies` call, and that the system + * should return the next page of data. + * @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 protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy|ClientTlsPolicy} 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 `listClientTlsPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listClientTlsPoliciesStream( + request?: protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest, + 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['listClientTlsPolicies']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listClientTlsPolicies.createStream( + this.innerApiCalls.listClientTlsPolicies as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listClientTlsPolicies`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the ClientTlsPolicies should + * be listed, specified in the format `projects/* /locations/{location}`. + * @param {number} request.pageSize + * Maximum number of ClientTlsPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListClientTlsPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListClientTlsPolicies` call, and that the system + * should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy|ClientTlsPolicy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_security.list_client_tls_policies.js + * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_ListClientTlsPolicies_async + */ + listClientTlsPoliciesAsync( + request?: protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest, + 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['listClientTlsPolicies']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listClientTlsPolicies.asyncIterate( + this.innerApiCalls['listClientTlsPolicies'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @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/interfaces/CallOptions.html | 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.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getIamPolicy( + request: IamProtos.google.iam.v1.GetIamPolicyRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.Policy]> { + return this.iamClient.getIamPolicy(request, options, callback); + } + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + setIamPolicy( + request: IamProtos.google.iam.v1.SetIamPolicyRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.Policy]> { + return this.iamClient.setIamPolicy(request, options, callback); + } + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ + testIamPermissions( + request: IamProtos.google.iam.v1.TestIamPermissionsRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + return this.iamClient.testIamPermissions(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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 authorizationPolicy resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} authorization_policy + * @returns {string} Resource name string. + */ + authorizationPolicyPath(project:string,location:string,authorizationPolicy:string) { + return this.pathTemplates.authorizationPolicyPathTemplate.render({ + project: project, + location: location, + authorization_policy: authorizationPolicy, + }); + } + + /** + * Parse the project from AuthorizationPolicy resource. + * + * @param {string} authorizationPolicyName + * A fully-qualified path representing AuthorizationPolicy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAuthorizationPolicyName(authorizationPolicyName: string) { + return this.pathTemplates.authorizationPolicyPathTemplate.match(authorizationPolicyName).project; + } + + /** + * Parse the location from AuthorizationPolicy resource. + * + * @param {string} authorizationPolicyName + * A fully-qualified path representing AuthorizationPolicy resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAuthorizationPolicyName(authorizationPolicyName: string) { + return this.pathTemplates.authorizationPolicyPathTemplate.match(authorizationPolicyName).location; + } + + /** + * Parse the authorization_policy from AuthorizationPolicy resource. + * + * @param {string} authorizationPolicyName + * A fully-qualified path representing AuthorizationPolicy resource. + * @returns {string} A string representing the authorization_policy. + */ + matchAuthorizationPolicyFromAuthorizationPolicyName(authorizationPolicyName: string) { + return this.pathTemplates.authorizationPolicyPathTemplate.match(authorizationPolicyName).authorization_policy; + } + + /** + * Return a fully-qualified clientTlsPolicy resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} client_tls_policy + * @returns {string} Resource name string. + */ + clientTlsPolicyPath(project:string,location:string,clientTlsPolicy:string) { + return this.pathTemplates.clientTlsPolicyPathTemplate.render({ + project: project, + location: location, + client_tls_policy: clientTlsPolicy, + }); + } + + /** + * Parse the project from ClientTlsPolicy resource. + * + * @param {string} clientTlsPolicyName + * A fully-qualified path representing ClientTlsPolicy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromClientTlsPolicyName(clientTlsPolicyName: string) { + return this.pathTemplates.clientTlsPolicyPathTemplate.match(clientTlsPolicyName).project; + } + + /** + * Parse the location from ClientTlsPolicy resource. + * + * @param {string} clientTlsPolicyName + * A fully-qualified path representing ClientTlsPolicy resource. + * @returns {string} A string representing the location. + */ + matchLocationFromClientTlsPolicyName(clientTlsPolicyName: string) { + return this.pathTemplates.clientTlsPolicyPathTemplate.match(clientTlsPolicyName).location; + } + + /** + * Parse the client_tls_policy from ClientTlsPolicy resource. + * + * @param {string} clientTlsPolicyName + * A fully-qualified path representing ClientTlsPolicy resource. + * @returns {string} A string representing the client_tls_policy. + */ + matchClientTlsPolicyFromClientTlsPolicyName(clientTlsPolicyName: string) { + return this.pathTemplates.clientTlsPolicyPathTemplate.match(clientTlsPolicyName).client_tls_policy; + } + + /** + * Return a fully-qualified serverTlsPolicy resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} server_tls_policy + * @returns {string} Resource name string. + */ + serverTlsPolicyPath(project:string,location:string,serverTlsPolicy:string) { + return this.pathTemplates.serverTlsPolicyPathTemplate.render({ + project: project, + location: location, + server_tls_policy: serverTlsPolicy, + }); + } + + /** + * Parse the project from ServerTlsPolicy resource. + * + * @param {string} serverTlsPolicyName + * A fully-qualified path representing ServerTlsPolicy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServerTlsPolicyName(serverTlsPolicyName: string) { + return this.pathTemplates.serverTlsPolicyPathTemplate.match(serverTlsPolicyName).project; + } + + /** + * Parse the location from ServerTlsPolicy resource. + * + * @param {string} serverTlsPolicyName + * A fully-qualified path representing ServerTlsPolicy resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServerTlsPolicyName(serverTlsPolicyName: string) { + return this.pathTemplates.serverTlsPolicyPathTemplate.match(serverTlsPolicyName).location; + } + + /** + * Parse the server_tls_policy from ServerTlsPolicy resource. + * + * @param {string} serverTlsPolicyName + * A fully-qualified path representing ServerTlsPolicy resource. + * @returns {string} A string representing the server_tls_policy. + */ + matchServerTlsPolicyFromServerTlsPolicyName(serverTlsPolicyName: string) { + return this.pathTemplates.serverTlsPolicyPathTemplate.match(serverTlsPolicyName).server_tls_policy; + } + + /** + * 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.networkSecurityStub && !this._terminated) { + return this.networkSecurityStub.then(stub => { + this._terminated = true; + stub.close(); + this.iamClient.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_client_config.json b/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_client_config.json new file mode 100644 index 00000000000..a8a5697e043 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_client_config.json @@ -0,0 +1,101 @@ +{ + "interfaces": { + "google.cloud.networksecurity.v1beta1.NetworkSecurity": { + "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": { + "ListAuthorizationPolicies": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetAuthorizationPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateAuthorizationPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateAuthorizationPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteAuthorizationPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListServerTlsPolicies": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetServerTlsPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateServerTlsPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateServerTlsPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteServerTlsPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListClientTlsPolicies": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetClientTlsPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateClientTlsPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateClientTlsPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteClientTlsPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_proto_list.json b/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_proto_list.json new file mode 100644 index 00000000000..dd0ef0b24df --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/networksecurity/v1beta1/authorization_policy.proto", + "../../protos/google/cloud/networksecurity/v1beta1/client_tls_policy.proto", + "../../protos/google/cloud/networksecurity/v1beta1/common.proto", + "../../protos/google/cloud/networksecurity/v1beta1/network_security.proto", + "../../protos/google/cloud/networksecurity/v1beta1/server_tls_policy.proto", + "../../protos/google/cloud/networksecurity/v1beta1/tls.proto" +] diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..ffbf8b4ca50 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const networksecurity = require('@google-cloud/network-security'); + +function main() { + const networkSecurityClient = new networksecurity.NetworkSecurityClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..496dee08836 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {NetworkSecurityClient} from '@google-cloud/network-security'; + +// check that the client class type name can be used +function doStuffWithNetworkSecurityClient(client: NetworkSecurityClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const networkSecurityClient = new NetworkSecurityClient(); + doStuffWithNetworkSecurityClient(networkSecurityClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/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-networksecurity/v1beta1/test/gapic_network_security_v1beta1.ts b/owl-bot-staging/google-cloud-networksecurity/v1beta1/test/gapic_network_security_v1beta1.ts new file mode 100644 index 00000000000..f0a23c69f11 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/test/gapic_network_security_v1beta1.ts @@ -0,0 +1,3508 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 networksecurityModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos, IamProtos, 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('v1beta1.NetworkSecurityClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = networksecurityModule.v1beta1.NetworkSecurityClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = networksecurityModule.v1beta1.NetworkSecurityClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = networksecurityModule.v1beta1.NetworkSecurityClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.networkSecurityStub, undefined); + await client.initialize(); + assert(client.networkSecurityStub); + }); + + it('has close method for the initialized client', done => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.networkSecurityStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.networkSecurityStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + 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 networksecurityModule.v1beta1.NetworkSecurityClient({ + 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('getAuthorizationPolicy', () => { + it('invokes getAuthorizationPolicy without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.GetAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetAuthorizationPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy() + ); + client.innerApiCalls.getAuthorizationPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getAuthorizationPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAuthorizationPolicy without error using callback', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.GetAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetAuthorizationPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy() + ); + client.innerApiCalls.getAuthorizationPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAuthorizationPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAuthorizationPolicy with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.GetAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetAuthorizationPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAuthorizationPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getAuthorizationPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAuthorizationPolicy with closed client', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.GetAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetAuthorizationPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getAuthorizationPolicy(request), expectedError); + }); + }); + + describe('getServerTlsPolicy', () => { + it('invokes getServerTlsPolicy without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.GetServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetServerTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy() + ); + client.innerApiCalls.getServerTlsPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getServerTlsPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getServerTlsPolicy without error using callback', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.GetServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetServerTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy() + ); + client.innerApiCalls.getServerTlsPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getServerTlsPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getServerTlsPolicy with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.GetServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetServerTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getServerTlsPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getServerTlsPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getServerTlsPolicy with closed client', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.GetServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetServerTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getServerTlsPolicy(request), expectedError); + }); + }); + + describe('getClientTlsPolicy', () => { + it('invokes getClientTlsPolicy without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.GetClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetClientTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy() + ); + client.innerApiCalls.getClientTlsPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getClientTlsPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getClientTlsPolicy without error using callback', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.GetClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetClientTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy() + ); + client.innerApiCalls.getClientTlsPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getClientTlsPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getClientTlsPolicy with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.GetClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetClientTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getClientTlsPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getClientTlsPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getClientTlsPolicy with closed client', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.GetClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetClientTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getClientTlsPolicy(request), expectedError); + }); + }); + + describe('createAuthorizationPolicy', () => { + it('invokes createAuthorizationPolicy without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.CreateAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateAuthorizationPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createAuthorizationPolicy = stubLongRunningCall(expectedResponse); + const [operation] = await client.createAuthorizationPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createAuthorizationPolicy without error using callback', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.CreateAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateAuthorizationPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createAuthorizationPolicy = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createAuthorizationPolicy( + request, + (err?: Error|null, + result?: 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.createAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createAuthorizationPolicy with call error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.CreateAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateAuthorizationPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createAuthorizationPolicy = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createAuthorizationPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createAuthorizationPolicy with LRO error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.CreateAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateAuthorizationPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createAuthorizationPolicy = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createAuthorizationPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateAuthorizationPolicyProgress without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateAuthorizationPolicyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateAuthorizationPolicyProgress with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateAuthorizationPolicyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateAuthorizationPolicy', () => { + it('invokes updateAuthorizationPolicy without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.UpdateAuthorizationPolicyRequest() + ); + request.authorizationPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateAuthorizationPolicyRequest', ['authorizationPolicy', 'name']); + request.authorizationPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `authorization_policy.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateAuthorizationPolicy = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateAuthorizationPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateAuthorizationPolicy without error using callback', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.UpdateAuthorizationPolicyRequest() + ); + request.authorizationPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateAuthorizationPolicyRequest', ['authorizationPolicy', 'name']); + request.authorizationPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `authorization_policy.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateAuthorizationPolicy = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateAuthorizationPolicy( + request, + (err?: Error|null, + result?: 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.updateAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateAuthorizationPolicy with call error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.UpdateAuthorizationPolicyRequest() + ); + request.authorizationPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateAuthorizationPolicyRequest', ['authorizationPolicy', 'name']); + request.authorizationPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `authorization_policy.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAuthorizationPolicy = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateAuthorizationPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateAuthorizationPolicy with LRO error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.UpdateAuthorizationPolicyRequest() + ); + request.authorizationPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateAuthorizationPolicyRequest', ['authorizationPolicy', 'name']); + request.authorizationPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `authorization_policy.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAuthorizationPolicy = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateAuthorizationPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateAuthorizationPolicyProgress without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateAuthorizationPolicyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateAuthorizationPolicyProgress with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateAuthorizationPolicyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteAuthorizationPolicy', () => { + it('invokes deleteAuthorizationPolicy without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.DeleteAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteAuthorizationPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteAuthorizationPolicy = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteAuthorizationPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteAuthorizationPolicy without error using callback', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.DeleteAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteAuthorizationPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteAuthorizationPolicy = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteAuthorizationPolicy( + request, + (err?: Error|null, + result?: 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.deleteAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteAuthorizationPolicy with call error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.DeleteAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteAuthorizationPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteAuthorizationPolicy = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteAuthorizationPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteAuthorizationPolicy with LRO error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.DeleteAuthorizationPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteAuthorizationPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteAuthorizationPolicy = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteAuthorizationPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteAuthorizationPolicyProgress without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteAuthorizationPolicyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteAuthorizationPolicyProgress with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteAuthorizationPolicyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('createServerTlsPolicy', () => { + it('invokes createServerTlsPolicy without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.CreateServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateServerTlsPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createServerTlsPolicy = stubLongRunningCall(expectedResponse); + const [operation] = await client.createServerTlsPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createServerTlsPolicy without error using callback', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.CreateServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateServerTlsPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createServerTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createServerTlsPolicy( + request, + (err?: Error|null, + result?: 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.createServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createServerTlsPolicy with call error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.CreateServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateServerTlsPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createServerTlsPolicy = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createServerTlsPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.createServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createServerTlsPolicy with LRO error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.CreateServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateServerTlsPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createServerTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createServerTlsPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateServerTlsPolicyProgress without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateServerTlsPolicyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateServerTlsPolicyProgress with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateServerTlsPolicyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateServerTlsPolicy', () => { + it('invokes updateServerTlsPolicy without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.UpdateServerTlsPolicyRequest() + ); + request.serverTlsPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateServerTlsPolicyRequest', ['serverTlsPolicy', 'name']); + request.serverTlsPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `server_tls_policy.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateServerTlsPolicy = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateServerTlsPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateServerTlsPolicy without error using callback', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.UpdateServerTlsPolicyRequest() + ); + request.serverTlsPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateServerTlsPolicyRequest', ['serverTlsPolicy', 'name']); + request.serverTlsPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `server_tls_policy.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateServerTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateServerTlsPolicy( + request, + (err?: Error|null, + result?: 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.updateServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateServerTlsPolicy with call error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.UpdateServerTlsPolicyRequest() + ); + request.serverTlsPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateServerTlsPolicyRequest', ['serverTlsPolicy', 'name']); + request.serverTlsPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `server_tls_policy.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServerTlsPolicy = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateServerTlsPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateServerTlsPolicy with LRO error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.UpdateServerTlsPolicyRequest() + ); + request.serverTlsPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateServerTlsPolicyRequest', ['serverTlsPolicy', 'name']); + request.serverTlsPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `server_tls_policy.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServerTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateServerTlsPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateServerTlsPolicyProgress without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateServerTlsPolicyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateServerTlsPolicyProgress with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateServerTlsPolicyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteServerTlsPolicy', () => { + it('invokes deleteServerTlsPolicy without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.DeleteServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteServerTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteServerTlsPolicy = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteServerTlsPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteServerTlsPolicy without error using callback', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.DeleteServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteServerTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteServerTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteServerTlsPolicy( + request, + (err?: Error|null, + result?: 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.deleteServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteServerTlsPolicy with call error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.DeleteServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteServerTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServerTlsPolicy = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteServerTlsPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteServerTlsPolicy with LRO error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.DeleteServerTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteServerTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServerTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteServerTlsPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteServerTlsPolicyProgress without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteServerTlsPolicyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteServerTlsPolicyProgress with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteServerTlsPolicyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('createClientTlsPolicy', () => { + it('invokes createClientTlsPolicy without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.CreateClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateClientTlsPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createClientTlsPolicy = stubLongRunningCall(expectedResponse); + const [operation] = await client.createClientTlsPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createClientTlsPolicy without error using callback', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.CreateClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateClientTlsPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createClientTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createClientTlsPolicy( + request, + (err?: Error|null, + result?: 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.createClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createClientTlsPolicy with call error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.CreateClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateClientTlsPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createClientTlsPolicy = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createClientTlsPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.createClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createClientTlsPolicy with LRO error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.CreateClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateClientTlsPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createClientTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createClientTlsPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateClientTlsPolicyProgress without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateClientTlsPolicyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateClientTlsPolicyProgress with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateClientTlsPolicyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateClientTlsPolicy', () => { + it('invokes updateClientTlsPolicy without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.UpdateClientTlsPolicyRequest() + ); + request.clientTlsPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateClientTlsPolicyRequest', ['clientTlsPolicy', 'name']); + request.clientTlsPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `client_tls_policy.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateClientTlsPolicy = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateClientTlsPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateClientTlsPolicy without error using callback', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.UpdateClientTlsPolicyRequest() + ); + request.clientTlsPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateClientTlsPolicyRequest', ['clientTlsPolicy', 'name']); + request.clientTlsPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `client_tls_policy.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateClientTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateClientTlsPolicy( + request, + (err?: Error|null, + result?: 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.updateClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateClientTlsPolicy with call error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.UpdateClientTlsPolicyRequest() + ); + request.clientTlsPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateClientTlsPolicyRequest', ['clientTlsPolicy', 'name']); + request.clientTlsPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `client_tls_policy.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateClientTlsPolicy = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateClientTlsPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateClientTlsPolicy with LRO error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.UpdateClientTlsPolicyRequest() + ); + request.clientTlsPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateClientTlsPolicyRequest', ['clientTlsPolicy', 'name']); + request.clientTlsPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `client_tls_policy.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateClientTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateClientTlsPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateClientTlsPolicyProgress without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateClientTlsPolicyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateClientTlsPolicyProgress with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateClientTlsPolicyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteClientTlsPolicy', () => { + it('invokes deleteClientTlsPolicy without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.DeleteClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteClientTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteClientTlsPolicy = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteClientTlsPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteClientTlsPolicy without error using callback', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.DeleteClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteClientTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteClientTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteClientTlsPolicy( + request, + (err?: Error|null, + result?: 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.deleteClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteClientTlsPolicy with call error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.DeleteClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteClientTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteClientTlsPolicy = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteClientTlsPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteClientTlsPolicy with LRO error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.DeleteClientTlsPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteClientTlsPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteClientTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteClientTlsPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteClientTlsPolicyProgress without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteClientTlsPolicyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteClientTlsPolicyProgress with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteClientTlsPolicyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listAuthorizationPolicies', () => { + it('invokes listAuthorizationPolicies without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), + ]; + client.innerApiCalls.listAuthorizationPolicies = stubSimpleCall(expectedResponse); + const [response] = await client.listAuthorizationPolicies(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listAuthorizationPolicies without error using callback', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), + ]; + client.innerApiCalls.listAuthorizationPolicies = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listAuthorizationPolicies( + request, + (err?: Error|null, result?: protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listAuthorizationPolicies with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listAuthorizationPolicies = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listAuthorizationPolicies(request), expectedError); + const actualRequest = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listAuthorizationPoliciesStream without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), + ]; + client.descriptors.page.listAuthorizationPolicies.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listAuthorizationPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy[] = []; + stream.on('data', (response: protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy) => { + 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.listAuthorizationPolicies.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listAuthorizationPolicies, request)); + assert( + (client.descriptors.page.listAuthorizationPolicies.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listAuthorizationPoliciesStream with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAuthorizationPolicies.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listAuthorizationPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy[] = []; + stream.on('data', (response: protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listAuthorizationPolicies.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listAuthorizationPolicies, request)); + assert( + (client.descriptors.page.listAuthorizationPolicies.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listAuthorizationPolicies without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), + ]; + client.descriptors.page.listAuthorizationPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy[] = []; + const iterable = client.listAuthorizationPoliciesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listAuthorizationPolicies.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listAuthorizationPolicies.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listAuthorizationPolicies with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAuthorizationPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAuthorizationPoliciesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listAuthorizationPolicies.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listAuthorizationPolicies.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listServerTlsPolicies', () => { + it('invokes listServerTlsPolicies without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), + ]; + client.innerApiCalls.listServerTlsPolicies = stubSimpleCall(expectedResponse); + const [response] = await client.listServerTlsPolicies(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listServerTlsPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listServerTlsPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServerTlsPolicies without error using callback', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), + ]; + client.innerApiCalls.listServerTlsPolicies = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServerTlsPolicies( + request, + (err?: Error|null, result?: protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listServerTlsPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listServerTlsPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServerTlsPolicies with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listServerTlsPolicies = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listServerTlsPolicies(request), expectedError); + const actualRequest = (client.innerApiCalls.listServerTlsPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listServerTlsPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServerTlsPoliciesStream without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), + ]; + client.descriptors.page.listServerTlsPolicies.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listServerTlsPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy[] = []; + stream.on('data', (response: protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy) => { + 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.listServerTlsPolicies.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServerTlsPolicies, request)); + assert( + (client.descriptors.page.listServerTlsPolicies.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listServerTlsPoliciesStream with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServerTlsPolicies.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listServerTlsPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy[] = []; + stream.on('data', (response: protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listServerTlsPolicies.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServerTlsPolicies, request)); + assert( + (client.descriptors.page.listServerTlsPolicies.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listServerTlsPolicies without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), + ]; + client.descriptors.page.listServerTlsPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy[] = []; + const iterable = client.listServerTlsPoliciesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listServerTlsPolicies.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listServerTlsPolicies.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listServerTlsPolicies with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServerTlsPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServerTlsPoliciesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listServerTlsPolicies.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listServerTlsPolicies.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listClientTlsPolicies', () => { + it('invokes listClientTlsPolicies without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), + ]; + client.innerApiCalls.listClientTlsPolicies = stubSimpleCall(expectedResponse); + const [response] = await client.listClientTlsPolicies(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listClientTlsPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listClientTlsPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listClientTlsPolicies without error using callback', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), + ]; + client.innerApiCalls.listClientTlsPolicies = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listClientTlsPolicies( + request, + (err?: Error|null, result?: protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listClientTlsPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listClientTlsPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listClientTlsPolicies with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listClientTlsPolicies = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listClientTlsPolicies(request), expectedError); + const actualRequest = (client.innerApiCalls.listClientTlsPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listClientTlsPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listClientTlsPoliciesStream without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), + ]; + client.descriptors.page.listClientTlsPolicies.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listClientTlsPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy[] = []; + stream.on('data', (response: protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy) => { + 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.listClientTlsPolicies.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listClientTlsPolicies, request)); + assert( + (client.descriptors.page.listClientTlsPolicies.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listClientTlsPoliciesStream with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listClientTlsPolicies.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listClientTlsPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy[] = []; + stream.on('data', (response: protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listClientTlsPolicies.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listClientTlsPolicies, request)); + assert( + (client.descriptors.page.listClientTlsPolicies.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listClientTlsPolicies without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), + generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), + ]; + client.descriptors.page.listClientTlsPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy[] = []; + const iterable = client.listClientTlsPoliciesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listClientTlsPolicies.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listClientTlsPolicies.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listClientTlsPolicies with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listClientTlsPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listClientTlsPoliciesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listClientTlsPolicies.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listClientTlsPolicies.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0)); + }); + it('invokes getIamPolicy with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0)); + }); + it('invokes setIamPolicy with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + 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 networksecurityModule.v1beta1.NetworkSecurityClient({ + 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 networksecurityModule.v1beta1.NetworkSecurityClient({ + 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 networksecurityModule.v1beta1.NetworkSecurityClient({ + 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 networksecurityModule.v1beta1.NetworkSecurityClient({ + 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 networksecurityModule.v1beta1.NetworkSecurityClient({ + 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 networksecurityModule.v1beta1.NetworkSecurityClient({ + 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 networksecurityModule.v1beta1.NetworkSecurityClient({ + 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 networksecurityModule.v1beta1.NetworkSecurityClient({ + 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 networksecurityModule.v1beta1.NetworkSecurityClient({ + 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 networksecurityModule.v1beta1.NetworkSecurityClient({ + 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 networksecurityModule.v1beta1.NetworkSecurityClient({ + 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 networksecurityModule.v1beta1.NetworkSecurityClient({ + 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 networksecurityModule.v1beta1.NetworkSecurityClient({ + 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 networksecurityModule.v1beta1.NetworkSecurityClient({ + 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 networksecurityModule.v1beta1.NetworkSecurityClient({ + 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('authorizationPolicy', () => { + const fakePath = "/rendered/path/authorizationPolicy"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + authorization_policy: "authorizationPolicyValue", + }; + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.authorizationPolicyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.authorizationPolicyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('authorizationPolicyPath', () => { + const result = client.authorizationPolicyPath("projectValue", "locationValue", "authorizationPolicyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.authorizationPolicyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAuthorizationPolicyName', () => { + const result = client.matchProjectFromAuthorizationPolicyName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.authorizationPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAuthorizationPolicyName', () => { + const result = client.matchLocationFromAuthorizationPolicyName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.authorizationPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchAuthorizationPolicyFromAuthorizationPolicyName', () => { + const result = client.matchAuthorizationPolicyFromAuthorizationPolicyName(fakePath); + assert.strictEqual(result, "authorizationPolicyValue"); + assert((client.pathTemplates.authorizationPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('clientTlsPolicy', () => { + const fakePath = "/rendered/path/clientTlsPolicy"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + client_tls_policy: "clientTlsPolicyValue", + }; + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.clientTlsPolicyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.clientTlsPolicyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('clientTlsPolicyPath', () => { + const result = client.clientTlsPolicyPath("projectValue", "locationValue", "clientTlsPolicyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.clientTlsPolicyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromClientTlsPolicyName', () => { + const result = client.matchProjectFromClientTlsPolicyName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.clientTlsPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromClientTlsPolicyName', () => { + const result = client.matchLocationFromClientTlsPolicyName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.clientTlsPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchClientTlsPolicyFromClientTlsPolicyName', () => { + const result = client.matchClientTlsPolicyFromClientTlsPolicyName(fakePath); + assert.strictEqual(result, "clientTlsPolicyValue"); + assert((client.pathTemplates.clientTlsPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('serverTlsPolicy', () => { + const fakePath = "/rendered/path/serverTlsPolicy"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + server_tls_policy: "serverTlsPolicyValue", + }; + const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.serverTlsPolicyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.serverTlsPolicyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('serverTlsPolicyPath', () => { + const result = client.serverTlsPolicyPath("projectValue", "locationValue", "serverTlsPolicyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.serverTlsPolicyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServerTlsPolicyName', () => { + const result = client.matchProjectFromServerTlsPolicyName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.serverTlsPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServerTlsPolicyName', () => { + const result = client.matchLocationFromServerTlsPolicyName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.serverTlsPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServerTlsPolicyFromServerTlsPolicyName', () => { + const result = client.matchServerTlsPolicyFromServerTlsPolicyName(fakePath); + assert.strictEqual(result, "serverTlsPolicyValue"); + assert((client.pathTemplates.serverTlsPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-networksecurity/v1beta1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/webpack.config.js new file mode 100644 index 00000000000..d5abc33e904 --- /dev/null +++ b/owl-bot-staging/google-cloud-networksecurity/v1beta1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'NetworkSecurity', + filename: './network-security.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-notebooks/v1/.eslintignore b/owl-bot-staging/google-cloud-notebooks/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-notebooks/v1/.eslintrc.json b/owl-bot-staging/google-cloud-notebooks/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/.gitignore b/owl-bot-staging/google-cloud-notebooks/v1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-notebooks/v1/.jsdoc.js b/owl-bot-staging/google-cloud-notebooks/v1/.jsdoc.js new file mode 100644 index 00000000000..b562faf1159 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/.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/notebooks', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-notebooks/v1/.mocharc.js b/owl-bot-staging/google-cloud-notebooks/v1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/.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-notebooks/v1/.prettierrc.js b/owl-bot-staging/google-cloud-notebooks/v1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/.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-notebooks/v1/README.md b/owl-bot-staging/google-cloud-notebooks/v1/README.md new file mode 100644 index 00000000000..31cec215a8f --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/README.md @@ -0,0 +1 @@ +Notebooks: Nodejs Client diff --git a/owl-bot-staging/google-cloud-notebooks/v1/package.json b/owl-bot-staging/google-cloud-notebooks/v1/package.json new file mode 100644 index 00000000000..7ee890b3f9f --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/package.json @@ -0,0 +1,59 @@ +{ + "name": "@google-cloud/notebooks", + "version": "0.1.0", + "description": "Notebooks client for Node.js", + "repository": "googleapis/nodejs-notebooks", + "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 notebooks", + "notebooks", + "managed notebook service", + "notebook service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/diagnostic_config.proto b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/diagnostic_config.proto new file mode 100644 index 00000000000..ab8b98f1694 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/diagnostic_config.proto @@ -0,0 +1,60 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.notebooks.v1; + +import "google/api/field_behavior.proto"; + +option go_package = "cloud.google.com/go/notebooks/apiv1/notebookspb;notebookspb"; +option java_multiple_files = true; +option java_outer_classname = "DiagnosticConfigProto"; +option java_package = "com.google.cloud.notebooks.v1"; + +// Defines flags that are used to run the diagnostic tool +message DiagnosticConfig { + // Required. User Cloud Storage bucket location (REQUIRED). + // Must be formatted with path prefix (`gs://$GCS_BUCKET`). + // + // Permissions: + // User Managed Notebooks: + // - storage.buckets.writer: Must be given to the project's service account + // attached to VM. + // Google Managed Notebooks: + // - storage.buckets.writer: Must be given to the project's service account or + // user credentials attached to VM depending on authentication mode. + // + // Cloud Storage bucket Log file will be written to + // `gs://$GCS_BUCKET/$RELATIVE_PATH/$VM_DATE_$TIME.tar.gz` + string gcs_bucket = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Defines the relative storage path in the Cloud Storage bucket + // where the diagnostic logs will be written: Default path will be the root + // directory of the Cloud Storage bucket + // (`gs://$GCS_BUCKET/$DATE_$TIME.tar.gz`) + // Example of full path where Log file will be written: + // `gs://$GCS_BUCKET/$RELATIVE_PATH/` + string relative_path = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Enables flag to repair service for instance + bool repair_flag_enabled = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Enables flag to capture packets from the instance for 30 seconds + bool packet_capture_flag_enabled = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Enables flag to copy all `/home/jupyter` folder contents + bool copy_home_files_flag_enabled = 5 + [(google.api.field_behavior) = OPTIONAL]; +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/environment.proto b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/environment.proto new file mode 100644 index 00000000000..cf947b8249d --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/environment.proto @@ -0,0 +1,96 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.notebooks.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Notebooks.V1"; +option go_package = "cloud.google.com/go/notebooks/apiv1/notebookspb;notebookspb"; +option java_multiple_files = true; +option java_outer_classname = "EnvironmentProto"; +option java_package = "com.google.cloud.notebooks.v1"; +option php_namespace = "Google\\Cloud\\Notebooks\\V1"; +option ruby_package = "Google::Cloud::Notebooks::V1"; + +// Definition of a software environment that is used to start a notebook +// instance. +message Environment { + option (google.api.resource) = { + type: "notebooks.googleapis.com/Environment" + pattern: "projects/{project}/environments/{environment}" + }; + + // Output only. Name of this environment. + // Format: + // `projects/{project_id}/locations/{location}/environments/{environment_id}` + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Display name of this environment for the UI. + string display_name = 2; + + // A brief description of this environment. + string description = 3; + + // Type of the environment; can be one of VM image, or container image. + oneof image_type { + // Use a Compute Engine VM image to start the notebook instance. + VmImage vm_image = 6; + + // Use a container image to start the notebook instance. + ContainerImage container_image = 7; + } + + // Path to a Bash script that automatically runs after a notebook instance + // fully boots up. The path must be a URL or + // Cloud Storage path. Example: `"gs://path-to-file/file-name"` + string post_startup_script = 8; + + // Output only. The time at which this environment was created. + google.protobuf.Timestamp create_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Definition of a custom Compute Engine virtual machine image for starting a +// notebook instance with the environment installed directly on the VM. +message VmImage { + // Required. The name of the Google Cloud project that this VM image belongs to. + // Format: `{project_id}` + string project = 1 [(google.api.field_behavior) = REQUIRED]; + + // The reference to an external Compute Engine VM image. + oneof image { + // Use VM image name to find the image. + string image_name = 2; + + // Use this VM image family to find the image; the newest image in this + // family will be used. + string image_family = 3; + } +} + +// Definition of a container image for starting a notebook instance with the +// environment installed in a container. +message ContainerImage { + // Required. The path to the container image repository. For example: + // `gcr.io/{project_id}/{image_name}` + string repository = 1 [(google.api.field_behavior) = REQUIRED]; + + // The tag of the container image. If not specified, this defaults + // to the latest tag. + string tag = 2; +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/event.proto b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/event.proto new file mode 100644 index 00000000000..2f62bda3217 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/event.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.notebooks.v1; + +import "google/api/field_behavior.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "cloud.google.com/go/notebooks/apiv1/notebookspb;notebookspb"; +option java_multiple_files = true; +option java_outer_classname = "EventProto"; +option java_package = "com.google.cloud.notebooks.v1"; + +// The definition of an Event for a managed / semi-managed notebook instance. +message Event { + // The definition of the event types. + enum EventType { + // Event is not specified. + EVENT_TYPE_UNSPECIFIED = 0; + + // The instance / runtime is idle + IDLE = 1; + + // The instance / runtime is available. + // This event indicates that instance / runtime underlying compute is + // operational. + HEARTBEAT = 2; + + // The instance / runtime health is available. + // This event indicates that instance / runtime health information. + HEALTH = 3; + + // The instance / runtime is available. + // This event allows instance / runtime to send Host maintenance + // information to Control Plane. + // https://cloud.google.com/compute/docs/gpus/gpu-host-maintenance + MAINTENANCE = 4; + } + + // Event report time. + google.protobuf.Timestamp report_time = 1; + + // Event type. + EventType type = 2; + + // Optional. Event details. This field is used to pass event information. + map details = 3 [(google.api.field_behavior) = OPTIONAL]; +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/execution.proto b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/execution.proto new file mode 100644 index 00000000000..c23545d31eb --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/execution.proto @@ -0,0 +1,350 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.notebooks.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "cloud.google.com/go/notebooks/apiv1/notebookspb;notebookspb"; +option java_multiple_files = true; +option java_outer_classname = "ExecutionProto"; +option java_package = "com.google.cloud.notebooks.v1"; +option (google.api.resource_definition) = { + type: "aiplatform.googleapis.com/Tensorboard" + pattern: "projects/{project}/locations/{location}/tensorboards/{tensorboard}" +}; + +// The description a notebook execution workload. +message ExecutionTemplate { + // Required. Specifies the machine types, the number of replicas for workers + // and parameter servers. + enum ScaleTier { + // Unspecified Scale Tier. + SCALE_TIER_UNSPECIFIED = 0; + + // A single worker instance. This tier is suitable for learning how to use + // Cloud ML, and for experimenting with new models using small datasets. + BASIC = 1; + + // Many workers and a few parameter servers. + STANDARD_1 = 2; + + // A large number of workers with many parameter servers. + PREMIUM_1 = 3; + + // A single worker instance with a K80 GPU. + BASIC_GPU = 4; + + // A single worker instance with a Cloud TPU. + BASIC_TPU = 5; + + // The CUSTOM tier is not a set tier, but rather enables you to use your + // own cluster specification. When you use this tier, set values to + // configure your processing cluster according to these guidelines: + // + // * You _must_ set `ExecutionTemplate.masterType` to specify the type + // of machine to use for your master node. This is the only required + // setting. + CUSTOM = 6; + } + + // Hardware accelerator types for AI Platform Training jobs. + enum SchedulerAcceleratorType { + // Unspecified accelerator type. Default to no GPU. + SCHEDULER_ACCELERATOR_TYPE_UNSPECIFIED = 0; + + // Nvidia Tesla K80 GPU. + NVIDIA_TESLA_K80 = 1; + + // Nvidia Tesla P100 GPU. + NVIDIA_TESLA_P100 = 2; + + // Nvidia Tesla V100 GPU. + NVIDIA_TESLA_V100 = 3; + + // Nvidia Tesla P4 GPU. + NVIDIA_TESLA_P4 = 4; + + // Nvidia Tesla T4 GPU. + NVIDIA_TESLA_T4 = 5; + + // Nvidia Tesla A100 GPU. + NVIDIA_TESLA_A100 = 10; + + // TPU v2. + TPU_V2 = 6; + + // TPU v3. + TPU_V3 = 7; + } + + // Definition of a hardware accelerator. Note that not all combinations + // of `type` and `core_count` are valid. Check [GPUs on + // Compute Engine](https://cloud.google.com/compute/docs/gpus) to find a valid + // combination. TPUs are not supported. + message SchedulerAcceleratorConfig { + // Type of this accelerator. + SchedulerAcceleratorType type = 1; + + // Count of cores of this accelerator. + int64 core_count = 2; + } + + // The backend used for this execution. + enum JobType { + // No type specified. + JOB_TYPE_UNSPECIFIED = 0; + + // Custom Job in `aiplatform.googleapis.com`. + // Default value for an execution. + VERTEX_AI = 1; + + // Run execution on a cluster with Dataproc as a job. + // https://cloud.google.com/dataproc/docs/reference/rest/v1/projects.regions.jobs + DATAPROC = 2; + } + + // Parameters used in Dataproc JobType executions. + message DataprocParameters { + // URI for cluster used to run Dataproc execution. + // Format: `projects/{PROJECT_ID}/regions/{REGION}/clusters/{CLUSTER_NAME}` + string cluster = 1; + } + + // Parameters used in Vertex AI JobType executions. + message VertexAIParameters { + // The full name of the Compute Engine + // [network](https://cloud.google.com/compute/docs/networks-and-firewalls#networks) + // to which the Job should be peered. For example, + // `projects/12345/global/networks/myVPC`. + // [Format](https://cloud.google.com/compute/docs/reference/rest/v1/networks/insert) + // is of the form `projects/{project}/global/networks/{network}`. + // Where `{project}` is a project number, as in `12345`, and `{network}` is + // a network name. + // + // Private services access must already be configured for the network. If + // left unspecified, the job is not peered with any network. + string network = 1; + + // Environment variables. + // At most 100 environment variables can be specified and unique. + // Example: `GCP_BUCKET=gs://my-bucket/samples/` + map env = 2; + } + + // Required. Scale tier of the hardware used for notebook execution. + // DEPRECATED Will be discontinued. As right now only CUSTOM is supported. + ScaleTier scale_tier = 1 [ + deprecated = true, + (google.api.field_behavior) = REQUIRED + ]; + + // Specifies the type of virtual machine to use for your training + // job's master worker. You must specify this field when `scaleTier` is set to + // `CUSTOM`. + // + // You can use certain Compute Engine machine types directly in this field. + // The following types are supported: + // + // - `n1-standard-4` + // - `n1-standard-8` + // - `n1-standard-16` + // - `n1-standard-32` + // - `n1-standard-64` + // - `n1-standard-96` + // - `n1-highmem-2` + // - `n1-highmem-4` + // - `n1-highmem-8` + // - `n1-highmem-16` + // - `n1-highmem-32` + // - `n1-highmem-64` + // - `n1-highmem-96` + // - `n1-highcpu-16` + // - `n1-highcpu-32` + // - `n1-highcpu-64` + // - `n1-highcpu-96` + // + // + // Alternatively, you can use the following legacy machine types: + // + // - `standard` + // - `large_model` + // - `complex_model_s` + // - `complex_model_m` + // - `complex_model_l` + // - `standard_gpu` + // - `complex_model_m_gpu` + // - `complex_model_l_gpu` + // - `standard_p100` + // - `complex_model_m_p100` + // - `standard_v100` + // - `large_model_v100` + // - `complex_model_m_v100` + // - `complex_model_l_v100` + // + // + // Finally, if you want to use a TPU for training, specify `cloud_tpu` in this + // field. Learn more about the [special configuration options for training + // with + // TPU](https://cloud.google.com/ai-platform/training/docs/using-tpus#configuring_a_custom_tpu_machine). + string master_type = 2; + + // Configuration (count and accelerator type) for hardware running notebook + // execution. + SchedulerAcceleratorConfig accelerator_config = 3; + + // Labels for execution. + // If execution is scheduled, a field included will be 'nbs-scheduled'. + // Otherwise, it is an immediate execution, and an included field will be + // 'nbs-immediate'. Use fields to efficiently index between various types of + // executions. + map labels = 4; + + // Path to the notebook file to execute. + // Must be in a Google Cloud Storage bucket. + // Format: `gs://{bucket_name}/{folder}/{notebook_file_name}` + // Ex: `gs://notebook_user/scheduled_notebooks/sentiment_notebook.ipynb` + string input_notebook_file = 5; + + // Container Image URI to a DLVM + // Example: 'gcr.io/deeplearning-platform-release/base-cu100' + // More examples can be found at: + // https://cloud.google.com/ai-platform/deep-learning-containers/docs/choosing-container + string container_image_uri = 6; + + // Path to the notebook folder to write to. + // Must be in a Google Cloud Storage bucket path. + // Format: `gs://{bucket_name}/{folder}` + // Ex: `gs://notebook_user/scheduled_notebooks` + string output_notebook_folder = 7; + + // Parameters to be overridden in the notebook during execution. + // Ref https://papermill.readthedocs.io/en/latest/usage-parameterize.html on + // how to specifying parameters in the input notebook and pass them here + // in an YAML file. + // Ex: `gs://notebook_user/scheduled_notebooks/sentiment_notebook_params.yaml` + string params_yaml_file = 8; + + // Parameters used within the 'input_notebook_file' notebook. + string parameters = 9; + + // The email address of a service account to use when running the execution. + // You must have the `iam.serviceAccounts.actAs` permission for the specified + // service account. + string service_account = 10; + + // The type of Job to be used on this execution. + JobType job_type = 11; + + // Parameters for an execution type. + // NOTE: There are currently no extra parameters for VertexAI jobs. + oneof job_parameters { + // Parameters used in Dataproc JobType executions. + DataprocParameters dataproc_parameters = 12; + + // Parameters used in Vertex AI JobType executions. + VertexAIParameters vertex_ai_parameters = 13; + } + + // Name of the kernel spec to use. This must be specified if the + // kernel spec name on the execution target does not match the name in the + // input notebook file. + string kernel_spec = 14; + + // The name of a Vertex AI [Tensorboard] resource to which this execution + // will upload Tensorboard logs. + // Format: + // `projects/{project}/locations/{location}/tensorboards/{tensorboard}` + string tensorboard = 15 [(google.api.resource_reference) = { + type: "aiplatform.googleapis.com/Tensorboard" + }]; +} + +// The definition of a single executed notebook. +message Execution { + option (google.api.resource) = { + type: "notebooks.googleapis.com/Execution" + pattern: "projects/{project}/location/{location}/executions/{execution}" + }; + + // Enum description of the state of the underlying AIP job. + enum State { + // The job state is unspecified. + STATE_UNSPECIFIED = 0; + + // The job has been just created and processing has not yet begun. + QUEUED = 1; + + // The service is preparing to execution the job. + PREPARING = 2; + + // The job is in progress. + RUNNING = 3; + + // The job completed successfully. + SUCCEEDED = 4; + + // The job failed. + // `error_message` should contain the details of the failure. + FAILED = 5; + + // The job is being cancelled. + // `error_message` should describe the reason for the cancellation. + CANCELLING = 6; + + // The job has been cancelled. + // `error_message` should describe the reason for the cancellation. + CANCELLED = 7; + + // The job has become expired (relevant to Vertex AI jobs) + // https://cloud.google.com/vertex-ai/docs/reference/rest/v1/JobState + EXPIRED = 9; + + // The Execution is being created. + INITIALIZING = 10; + } + + // execute metadata including name, hardware spec, region, labels, etc. + ExecutionTemplate execution_template = 1; + + // Output only. The resource name of the execute. Format: + // `projects/{project_id}/locations/{location}/executions/{execution_id}` + string name = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name used for UI purposes. + // Name can only contain alphanumeric characters and underscores '_'. + string display_name = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // A brief description of this execution. + string description = 4; + + // Output only. Time the Execution was instantiated. + google.protobuf.Timestamp create_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Time the Execution was last updated. + google.protobuf.Timestamp update_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. State of the underlying AI Platform job. + State state = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output notebook file generated by this execution + string output_notebook_file = 8; + + // Output only. The URI of the external job used to execute the notebook. + string job_uri = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/instance.proto b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/instance.proto new file mode 100644 index 00000000000..d7888393837 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/instance.proto @@ -0,0 +1,541 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.notebooks.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/notebooks/v1/environment.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Notebooks.V1"; +option go_package = "cloud.google.com/go/notebooks/apiv1/notebookspb;notebookspb"; +option java_multiple_files = true; +option java_outer_classname = "InstanceProto"; +option java_package = "com.google.cloud.notebooks.v1"; +option php_namespace = "Google\\Cloud\\Notebooks\\V1"; +option ruby_package = "Google::Cloud::Notebooks::V1"; + +// Reservation Affinity for consuming Zonal reservation. +message ReservationAffinity { + // Indicates whether to consume capacity from an reservation or not. + enum Type { + // Default type. + TYPE_UNSPECIFIED = 0; + + // Do not consume from any allocated capacity. + NO_RESERVATION = 1; + + // Consume any reservation available. + ANY_RESERVATION = 2; + + // Must consume from a specific reservation. Must specify key value fields + // for specifying the reservations. + SPECIFIC_RESERVATION = 3; + } + + // Optional. Type of reservation to consume + Type consume_reservation_type = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Corresponds to the label key of reservation resource. + string key = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Corresponds to the label values of reservation resource. + repeated string values = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The definition of a notebook instance. +message Instance { + option (google.api.resource) = { + type: "notebooks.googleapis.com/Instance" + pattern: "projects/{project}/instances/{instance}" + }; + + // Definition of the types of hardware accelerators that can be used on this + // instance. + enum AcceleratorType { + // Accelerator type is not specified. + ACCELERATOR_TYPE_UNSPECIFIED = 0; + + // Accelerator type is Nvidia Tesla K80. + NVIDIA_TESLA_K80 = 1; + + // Accelerator type is Nvidia Tesla P100. + NVIDIA_TESLA_P100 = 2; + + // Accelerator type is Nvidia Tesla V100. + NVIDIA_TESLA_V100 = 3; + + // Accelerator type is Nvidia Tesla P4. + NVIDIA_TESLA_P4 = 4; + + // Accelerator type is Nvidia Tesla T4. + NVIDIA_TESLA_T4 = 5; + + // Accelerator type is Nvidia Tesla A100. + NVIDIA_TESLA_A100 = 11; + + // Accelerator type is NVIDIA Tesla T4 Virtual Workstations. + NVIDIA_TESLA_T4_VWS = 8; + + // Accelerator type is NVIDIA Tesla P100 Virtual Workstations. + NVIDIA_TESLA_P100_VWS = 9; + + // Accelerator type is NVIDIA Tesla P4 Virtual Workstations. + NVIDIA_TESLA_P4_VWS = 10; + + // (Coming soon) Accelerator type is TPU V2. + TPU_V2 = 6; + + // (Coming soon) Accelerator type is TPU V3. + TPU_V3 = 7; + } + + // Definition of a hardware accelerator. Note that not all combinations + // of `type` and `core_count` are valid. Check [GPUs on Compute + // Engine](https://cloud.google.com/compute/docs/gpus/#gpus-list) to find a + // valid combination. TPUs are not supported. + message AcceleratorConfig { + // Type of this accelerator. + AcceleratorType type = 1; + + // Count of cores of this accelerator. + int64 core_count = 2; + } + + // The definition of the states of this instance. + enum State { + // State is not specified. + STATE_UNSPECIFIED = 0; + + // The control logic is starting the instance. + STARTING = 1; + + // The control logic is installing required frameworks and registering the + // instance with notebook proxy + PROVISIONING = 2; + + // The instance is running. + ACTIVE = 3; + + // The control logic is stopping the instance. + STOPPING = 4; + + // The instance is stopped. + STOPPED = 5; + + // The instance is deleted. + DELETED = 6; + + // The instance is upgrading. + UPGRADING = 7; + + // The instance is being created. + INITIALIZING = 8; + + // The instance is getting registered. + REGISTERING = 9; + + // The instance is suspending. + SUSPENDING = 10; + + // The instance is suspended. + SUSPENDED = 11; + } + + // Possible disk types for notebook instances. + enum DiskType { + // Disk type not set. + DISK_TYPE_UNSPECIFIED = 0; + + // Standard persistent disk type. + PD_STANDARD = 1; + + // SSD persistent disk type. + PD_SSD = 2; + + // Balanced persistent disk type. + PD_BALANCED = 3; + + // Extreme persistent disk type. + PD_EXTREME = 4; + } + + // Definition of the disk encryption options. + enum DiskEncryption { + // Disk encryption is not specified. + DISK_ENCRYPTION_UNSPECIFIED = 0; + + // Use Google managed encryption keys to encrypt the boot disk. + GMEK = 1; + + // Use customer managed encryption keys to encrypt the boot disk. + CMEK = 2; + } + + // An instance-attached disk resource. + message Disk { + // Guest OS features for boot disk. + message GuestOsFeature { + // The ID of a supported feature. Read Enabling guest operating system + // features to see a list of available options. + // Valid values: + // + // * `FEATURE_TYPE_UNSPECIFIED` + // * `MULTI_IP_SUBNET` + // * `SECURE_BOOT` + // * `UEFI_COMPATIBLE` + // * `VIRTIO_SCSI_MULTIQUEUE` + // * `WINDOWS` + string type = 1; + } + + // Indicates whether the disk will be auto-deleted when the instance is + // deleted (but not when the disk is detached from the instance). + bool auto_delete = 1; + + // Indicates that this is a boot disk. The virtual machine will use the + // first partition of the disk for its root filesystem. + bool boot = 2; + + // Indicates a unique device name of your choice that is reflected into the + // `/dev/disk/by-id/google-*` tree of a Linux operating system running + // within the instance. This name can be used to reference the device for + // mounting, resizing, and so on, from within the instance. + // + // If not specified, the server chooses a default device name to apply to + // this disk, in the form persistent-disk-x, where x is a number assigned by + // Google Compute Engine.This field is only applicable for persistent disks. + string device_name = 3; + + // Indicates the size of the disk in base-2 GB. + int64 disk_size_gb = 4; + + // Indicates a list of features to enable on the guest operating system. + // Applicable only for bootable images. Read Enabling guest operating + // system features to see a list of available options. + repeated GuestOsFeature guest_os_features = 5; + + // A zero-based index to this disk, where 0 is reserved for the + // boot disk. If you have many disks attached to an instance, each disk + // would have a unique index number. + int64 index = 6; + + // Indicates the disk interface to use for attaching this disk, which is + // either SCSI or NVME. The default is SCSI. Persistent disks must always + // use SCSI and the request will fail if you attempt to attach a persistent + // disk in any other format than SCSI. Local SSDs can use either NVME or + // SCSI. For performance characteristics of SCSI over NVMe, see Local SSD + // performance. + // Valid values: + // + // * `NVME` + // * `SCSI` + string interface = 7; + + // Type of the resource. Always compute#attachedDisk for attached + // disks. + string kind = 8; + + // A list of publicly visible licenses. Reserved for Google's use. + // A License represents billing and aggregate usage data for public + // and marketplace images. + repeated string licenses = 9; + + // The mode in which to attach this disk, either `READ_WRITE` or + // `READ_ONLY`. If not specified, the default is to attach the disk in + // `READ_WRITE` mode. Valid values: + // + // * `READ_ONLY` + // * `READ_WRITE` + string mode = 10; + + // Indicates a valid partial or full URL to an existing Persistent Disk + // resource. + string source = 11; + + // Indicates the type of the disk, either `SCRATCH` or `PERSISTENT`. + // Valid values: + // + // * `PERSISTENT` + // * `SCRATCH` + string type = 12; + } + + // A set of Shielded Instance options. + // Check [Images using supported Shielded VM + // features](https://cloud.google.com/compute/docs/instances/modifying-shielded-vm). + // Not all combinations are valid. + message ShieldedInstanceConfig { + // Defines whether the instance has Secure Boot enabled. + // + // Secure Boot helps ensure that the system only runs authentic software by + // verifying the digital signature of all boot components, and halting the + // boot process if signature verification fails. Disabled by default. + bool enable_secure_boot = 1; + + // Defines whether the instance has the vTPM enabled. Enabled by default. + bool enable_vtpm = 2; + + // Defines whether the instance has integrity monitoring enabled. + // + // Enables monitoring and attestation of the boot integrity of the instance. + // The attestation is performed against the integrity policy baseline. This + // baseline is initially derived from the implicitly trusted boot image when + // the instance is created. Enabled by default. + bool enable_integrity_monitoring = 3; + } + + // The entry of VM image upgrade history. + message UpgradeHistoryEntry { + // The definition of the states of this upgrade history entry. + enum State { + // State is not specified. + STATE_UNSPECIFIED = 0; + + // The instance upgrade is started. + STARTED = 1; + + // The instance upgrade is succeeded. + SUCCEEDED = 2; + + // The instance upgrade is failed. + FAILED = 3; + } + + // The definition of operations of this upgrade history entry. + enum Action { + // Operation is not specified. + ACTION_UNSPECIFIED = 0; + + // Upgrade. + UPGRADE = 1; + + // Rollback. + ROLLBACK = 2; + } + + // The snapshot of the boot disk of this notebook instance before upgrade. + string snapshot = 1; + + // The VM image before this instance upgrade. + string vm_image = 2; + + // The container image before this instance upgrade. + string container_image = 3; + + // The framework of this notebook instance. + string framework = 4; + + // The version of the notebook instance before this upgrade. + string version = 5; + + // The state of this instance upgrade history entry. + State state = 6; + + // The time that this instance upgrade history entry is created. + google.protobuf.Timestamp create_time = 7; + + // Target VM Image. Format: `ainotebooks-vm/project/image-name/name`. + string target_image = 8 [deprecated = true]; + + // Action. Rolloback or Upgrade. + Action action = 9; + + // Target VM Version, like m63. + string target_version = 10; + } + + // The type of vNIC driver. + // Default should be UNSPECIFIED_NIC_TYPE. + enum NicType { + // No type specified. + UNSPECIFIED_NIC_TYPE = 0; + + // VIRTIO + VIRTIO_NET = 1; + + // GVNIC + GVNIC = 2; + } + + // Output only. The name of this notebook instance. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Type of the environment; can be one of VM image, or container image. + oneof environment { + // Use a Compute Engine VM image to start the notebook instance. + VmImage vm_image = 2; + + // Use a container image to start the notebook instance. + ContainerImage container_image = 3; + } + + // Path to a Bash script that automatically runs after a notebook instance + // fully boots up. The path must be a URL or + // Cloud Storage path (`gs://path-to-file/file-name`). + string post_startup_script = 4; + + // Output only. The proxy endpoint that is used to access the Jupyter notebook. + string proxy_uri = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Input only. The owner of this instance after creation. Format: `alias@example.com` + // + // Currently supports one owner only. If not specified, all of the service + // account users of your VM instance's service account can use + // the instance. + repeated string instance_owners = 6 [(google.api.field_behavior) = INPUT_ONLY]; + + // The service account on this instance, giving access to other Google + // Cloud services. + // You can use any service account within the same project, but you + // must have the service account user permission to use the instance. + // + // If not specified, the [Compute Engine default service + // account](https://cloud.google.com/compute/docs/access/service-accounts#default_service_account) + // is used. + string service_account = 7; + + // Optional. The URIs of service account scopes to be included in + // Compute Engine instances. + // + // If not specified, the following + // [scopes](https://cloud.google.com/compute/docs/access/service-accounts#accesscopesiam) + // are defined: + // - https://www.googleapis.com/auth/cloud-platform + // - https://www.googleapis.com/auth/userinfo.email + // If not using default scopes, you need at least: + // https://www.googleapis.com/auth/compute + repeated string service_account_scopes = 31 [(google.api.field_behavior) = OPTIONAL]; + + // Required. The [Compute Engine machine + // type](https://cloud.google.com/compute/docs/machine-types) of this + // instance. + string machine_type = 8 [(google.api.field_behavior) = REQUIRED]; + + // The hardware accelerator used on this instance. If you use + // accelerators, make sure that your configuration has + // [enough vCPUs and memory to support the `machine_type` you have + // selected](https://cloud.google.com/compute/docs/gpus/#gpus-list). + AcceleratorConfig accelerator_config = 9; + + // Output only. The state of this instance. + State state = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Whether the end user authorizes Google Cloud to install GPU driver + // on this instance. + // If this field is empty or set to false, the GPU driver won't be installed. + // Only applicable to instances with GPUs. + bool install_gpu_driver = 11; + + // Specify a custom Cloud Storage path where the GPU driver is stored. + // If not specified, we'll automatically choose from official GPU drivers. + string custom_gpu_driver_path = 12; + + // Input only. The type of the boot disk attached to this instance, defaults to + // standard persistent disk (`PD_STANDARD`). + DiskType boot_disk_type = 13 [(google.api.field_behavior) = INPUT_ONLY]; + + // Input only. The size of the boot disk in GB attached to this instance, up to a maximum + // of 64000 GB (64 TB). The minimum recommended value is 100 GB. If not + // specified, this defaults to 100. + int64 boot_disk_size_gb = 14 [(google.api.field_behavior) = INPUT_ONLY]; + + // Input only. The type of the data disk attached to this instance, defaults to + // standard persistent disk (`PD_STANDARD`). + DiskType data_disk_type = 25 [(google.api.field_behavior) = INPUT_ONLY]; + + // Input only. The size of the data disk in GB attached to this instance, up to a maximum + // of 64000 GB (64 TB). You can choose the size of the data disk based on how + // big your notebooks and data are. If not specified, this defaults to 100. + int64 data_disk_size_gb = 26 [(google.api.field_behavior) = INPUT_ONLY]; + + // Input only. If true, the data disk will not be auto deleted when deleting the instance. + bool no_remove_data_disk = 27 [(google.api.field_behavior) = INPUT_ONLY]; + + // Input only. Disk encryption method used on the boot and data disks, defaults to GMEK. + DiskEncryption disk_encryption = 15 [(google.api.field_behavior) = INPUT_ONLY]; + + // Input only. The KMS key used to encrypt the disks, only applicable if disk_encryption + // is CMEK. + // Format: + // `projects/{project_id}/locations/{location}/keyRings/{key_ring_id}/cryptoKeys/{key_id}` + // + // Learn more about [using your own encryption keys](/kms/docs/quickstart). + string kms_key = 16 [(google.api.field_behavior) = INPUT_ONLY]; + + // Output only. Attached disks to notebook instance. + repeated Disk disks = 28 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Shielded VM configuration. + // [Images using supported Shielded VM + // features](https://cloud.google.com/compute/docs/instances/modifying-shielded-vm). + ShieldedInstanceConfig shielded_instance_config = 30 [(google.api.field_behavior) = OPTIONAL]; + + // If true, no public IP will be assigned to this instance. + bool no_public_ip = 17; + + // If true, the notebook instance will not register with the proxy. + bool no_proxy_access = 18; + + // The name of the VPC that this instance is in. + // Format: + // `projects/{project_id}/global/networks/{network_id}` + string network = 19; + + // The name of the subnet that this instance is in. + // Format: + // `projects/{project_id}/regions/{region}/subnetworks/{subnetwork_id}` + string subnet = 20; + + // Labels to apply to this instance. + // These can be later modified by the setLabels method. + map labels = 21; + + // Custom metadata to apply to this instance. + map metadata = 22; + + // Optional. The Compute Engine tags to add to runtime (see [Tagging + // instances](https://cloud.google.com/compute/docs/label-or-tag-resources#tags)). + repeated string tags = 32 [(google.api.field_behavior) = OPTIONAL]; + + // The upgrade history of this instance. + repeated UpgradeHistoryEntry upgrade_history = 29; + + // Optional. The type of vNIC to be used on this interface. This may be gVNIC or + // VirtioNet. + NicType nic_type = 33 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The optional reservation affinity. Setting this field will apply + // the specified [Zonal Compute + // Reservation](https://cloud.google.com/compute/docs/instances/reserving-zonal-resources) + // to this notebook instance. + ReservationAffinity reservation_affinity = 34 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. Email address of entity that sent original CreateInstance request. + string creator = 36 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Flag to enable ip forwarding or not, default false/off. + // https://cloud.google.com/vpc/docs/using-routes#canipforward + bool can_ip_forward = 39 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. Instance creation time. + google.protobuf.Timestamp create_time = 23 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Instance update time. + google.protobuf.Timestamp update_time = 24 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/instance_config.proto b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/instance_config.proto new file mode 100644 index 00000000000..59fd01ef7ea --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/instance_config.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.notebooks.v1; + +option csharp_namespace = "Google.Cloud.Notebooks.V1"; +option go_package = "cloud.google.com/go/notebooks/apiv1/notebookspb;notebookspb"; +option java_multiple_files = true; +option java_outer_classname = "InstanceConfigProto"; +option java_package = "com.google.cloud.notebooks.v1"; +option php_namespace = "Google\\Cloud\\Notebooks\\V1"; +option ruby_package = "Google::Cloud::Notebooks::V1"; + +// Notebook instance configurations that can be updated. +message InstanceConfig { + // Cron expression in UTC timezone, used to schedule instance auto upgrade. + // Please follow the [cron format](https://en.wikipedia.org/wiki/Cron). + string notebook_upgrade_schedule = 1; + + // Verifies core internal services are running. + bool enable_health_monitoring = 2; +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/managed_service.proto b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/managed_service.proto new file mode 100644 index 00000000000..245e0764006 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/managed_service.proto @@ -0,0 +1,439 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.notebooks.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/notebooks/v1/diagnostic_config.proto"; +import "google/cloud/notebooks/v1/event.proto"; +import "google/cloud/notebooks/v1/runtime.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Notebooks.V1"; +option go_package = "cloud.google.com/go/notebooks/apiv1/notebookspb;notebookspb"; +option java_multiple_files = true; +option java_outer_classname = "ManagedNotebooksProto"; +option java_package = "com.google.cloud.notebooks.v1"; +option php_namespace = "Google\\Cloud\\Notebooks\\V1"; +option ruby_package = "Google::Cloud::Notebooks::V1"; + +// API v1 service for Managed Notebooks. +service ManagedNotebookService { + option (google.api.default_host) = "notebooks.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Lists Runtimes in a given project and location. + rpc ListRuntimes(ListRuntimesRequest) returns (ListRuntimesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/runtimes" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets details of a single Runtime. The location must be a regional endpoint + // rather than zonal. + rpc GetRuntime(GetRuntimeRequest) returns (Runtime) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/runtimes/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new Runtime in a given project and location. + rpc CreateRuntime(CreateRuntimeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/runtimes" + body: "runtime" + }; + option (google.api.method_signature) = "parent,runtime_id,runtime"; + option (google.longrunning.operation_info) = { + response_type: "Runtime" + metadata_type: "OperationMetadata" + }; + } + + // Update Notebook Runtime configuration. + rpc UpdateRuntime(UpdateRuntimeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{runtime.name=projects/*/locations/*/runtimes/*}" + body: "runtime" + }; + option (google.api.method_signature) = "runtime,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "Runtime" + metadata_type: "OperationMetadata" + }; + } + + // Deletes a single Runtime. + rpc DeleteRuntime(DeleteRuntimeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/runtimes/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "OperationMetadata" + }; + } + + // Starts a Managed Notebook Runtime. + // Perform "Start" on GPU instances; "Resume" on CPU instances + // See: + // https://cloud.google.com/compute/docs/instances/stop-start-instance + // https://cloud.google.com/compute/docs/instances/suspend-resume-instance + rpc StartRuntime(StartRuntimeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/runtimes/*}:start" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Runtime" + metadata_type: "OperationMetadata" + }; + } + + // Stops a Managed Notebook Runtime. + // Perform "Stop" on GPU instances; "Suspend" on CPU instances + // See: + // https://cloud.google.com/compute/docs/instances/stop-start-instance + // https://cloud.google.com/compute/docs/instances/suspend-resume-instance + rpc StopRuntime(StopRuntimeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/runtimes/*}:stop" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Runtime" + metadata_type: "OperationMetadata" + }; + } + + // Switch a Managed Notebook Runtime. + rpc SwitchRuntime(SwitchRuntimeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/runtimes/*}:switch" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Runtime" + metadata_type: "OperationMetadata" + }; + } + + // Resets a Managed Notebook Runtime. + rpc ResetRuntime(ResetRuntimeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/runtimes/*}:reset" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Runtime" + metadata_type: "OperationMetadata" + }; + } + + // Upgrades a Managed Notebook Runtime to the latest version. + rpc UpgradeRuntime(UpgradeRuntimeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/runtimes/*}:upgrade" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Runtime" + metadata_type: "OperationMetadata" + }; + } + + // Report and process a runtime event. + rpc ReportRuntimeEvent(ReportRuntimeEventRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/runtimes/*}:reportEvent" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Runtime" + metadata_type: "OperationMetadata" + }; + } + + // Gets an access token for the consumer service account that the customer + // attached to the runtime. Only accessible from the tenant instance. + rpc RefreshRuntimeTokenInternal(RefreshRuntimeTokenInternalRequest) returns (RefreshRuntimeTokenInternalResponse) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/runtimes/*}:refreshRuntimeTokenInternal" + body: "*" + }; + option (google.api.method_signature) = "name,vm_id"; + } + + // Creates a Diagnostic File and runs Diagnostic Tool given a Runtime. + rpc DiagnoseRuntime(DiagnoseRuntimeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/runtimes/*}:diagnose" + body: "*" + }; + option (google.api.method_signature) = "name,diagnostic_config"; + option (google.longrunning.operation_info) = { + response_type: "Runtime" + metadata_type: "OperationMetadata" + }; + } +} + +// Request for listing Managed Notebook Runtimes. +message ListRuntimesRequest { + // Required. Format: + // `parent=projects/{project_id}/locations/{location}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "notebooks.googleapis.com/Runtime" + } + ]; + + // Maximum return size of the list call. + int32 page_size = 2; + + // A previous returned page token that can be used to continue listing + // from the last result. + string page_token = 3; +} + +// Response for listing Managed Notebook Runtimes. +message ListRuntimesResponse { + // A list of returned Runtimes. + repeated Runtime runtimes = 1; + + // Page token that can be used to continue listing from the last result in the + // next list call. + string next_page_token = 2; + + // Locations that could not be reached. For example, + // `['us-west1', 'us-central1']`. + // A ListRuntimesResponse will only contain either runtimes or unreachables, + repeated string unreachable = 3; +} + +// Request for getting a Managed Notebook Runtime. +message GetRuntimeRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "notebooks.googleapis.com/Runtime" + } + ]; +} + +// Request for creating a Managed Notebook Runtime. +message CreateRuntimeRequest { + // Required. Format: + // `parent=projects/{project_id}/locations/{location}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "notebooks.googleapis.com/Runtime" + } + ]; + + // Required. User-defined unique ID of this Runtime. + string runtime_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The Runtime to be created. + Runtime runtime = 3 [(google.api.field_behavior) = REQUIRED]; + + // Idempotent request UUID. + string request_id = 4; +} + +// Request for deleting a Managed Notebook Runtime. +message DeleteRuntimeRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "notebooks.googleapis.com/Runtime" + } + ]; + + // Idempotent request UUID. + string request_id = 2; +} + +// Request for starting a Managed Notebook Runtime. +message StartRuntimeRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Idempotent request UUID. + string request_id = 2; +} + +// Request for stopping a Managed Notebook Runtime. +message StopRuntimeRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Idempotent request UUID. + string request_id = 2; +} + +// Request for switching a Managed Notebook Runtime. +message SwitchRuntimeRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // machine type. + string machine_type = 2; + + // accelerator config. + RuntimeAcceleratorConfig accelerator_config = 3; + + // Idempotent request UUID. + string request_id = 4; +} + +// Request for resetting a Managed Notebook Runtime. +message ResetRuntimeRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Idempotent request UUID. + string request_id = 2; +} + +// Request for upgrading a Managed Notebook Runtime to the latest version. +// option (google.api.message_visibility).restriction = +// "TRUSTED_TESTER,SPECIAL_TESTER"; +message UpgradeRuntimeRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Idempotent request UUID. + string request_id = 2; +} + +// Request for reporting a Managed Notebook Event. +message ReportRuntimeEventRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "notebooks.googleapis.com/Runtime" + } + ]; + + // Required. The VM hardware token for authenticating the VM. + // https://cloud.google.com/compute/docs/instances/verifying-instance-identity + string vm_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The Event to be reported. + Event event = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for updating a Managed Notebook configuration. +message UpdateRuntimeRequest { + // Required. The Runtime to be updated. + Runtime runtime = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Specifies the path, relative to `Runtime`, of + // the field to update. For example, to change the software configuration + // kernels, the `update_mask` parameter would be + // specified as `software_config.kernels`, + // and the `PATCH` request body would specify the new value, as follows: + // + // { + // "software_config":{ + // "kernels": [{ + // 'repository': + // 'gcr.io/deeplearning-platform-release/pytorch-gpu', 'tag': + // 'latest' }], + // } + // } + // + // + // Currently, only the following fields can be updated: + // - `software_config.kernels` + // - `software_config.post_startup_script` + // - `software_config.custom_gpu_driver_path` + // - `software_config.idle_shutdown` + // - `software_config.idle_shutdown_timeout` + // - `software_config.disable_terminal` + google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED]; + + // Idempotent request UUID. + string request_id = 3; +} + +// Request for getting a new access token. +message RefreshRuntimeTokenInternalRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "notebooks.googleapis.com/Runtime" + } + ]; + + // Required. The VM hardware token for authenticating the VM. + // https://cloud.google.com/compute/docs/instances/verifying-instance-identity + string vm_id = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response with a new access token. +message RefreshRuntimeTokenInternalResponse { + // The OAuth 2.0 access token. + string access_token = 1; + + // Output only. Token expiration time. + google.protobuf.Timestamp expire_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Request for creating a notebook instance diagnostic file. +message DiagnoseRuntimeRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/runtimes/{runtimes_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "notebooks.googleapis.com/Runtime" + } + ]; + + // Required. Defines flags that are used to run the diagnostic tool + DiagnosticConfig diagnostic_config = 2 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/runtime.proto b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/runtime.proto new file mode 100644 index 00000000000..48505b537b5 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/runtime.proto @@ -0,0 +1,611 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.notebooks.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/notebooks/v1/environment.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Notebooks.V1"; +option go_package = "cloud.google.com/go/notebooks/apiv1/notebookspb;notebookspb"; +option java_multiple_files = true; +option java_outer_classname = "RuntimeProto"; +option java_package = "com.google.cloud.notebooks.v1"; +option php_namespace = "Google\\Cloud\\Notebooks\\V1"; +option ruby_package = "Google::Cloud::Notebooks::V1"; + +// The definition of a Runtime for a managed notebook instance. +message Runtime { + option (google.api.resource) = { + type: "notebooks.googleapis.com/Runtime" + pattern: "projects/{project}/locations/{location}/runtimes/{runtime}" + }; + + // The definition of the states of this runtime. + enum State { + // State is not specified. + STATE_UNSPECIFIED = 0; + + // The compute layer is starting the runtime. It is not ready for use. + STARTING = 1; + + // The compute layer is installing required frameworks and registering the + // runtime with notebook proxy. It cannot be used. + PROVISIONING = 2; + + // The runtime is currently running. It is ready for use. + ACTIVE = 3; + + // The control logic is stopping the runtime. It cannot be used. + STOPPING = 4; + + // The runtime is stopped. It cannot be used. + STOPPED = 5; + + // The runtime is being deleted. It cannot be used. + DELETING = 6; + + // The runtime is upgrading. It cannot be used. + UPGRADING = 7; + + // The runtime is being created and set up. It is not ready for use. + INITIALIZING = 8; + } + + // The runtime substate. + enum HealthState { + // The runtime substate is unknown. + HEALTH_STATE_UNSPECIFIED = 0; + + // The runtime is known to be in an healthy state + // (for example, critical daemons are running) + // Applies to ACTIVE state. + HEALTHY = 1; + + // The runtime is known to be in an unhealthy state + // (for example, critical daemons are not running) + // Applies to ACTIVE state. + UNHEALTHY = 2; + + // The runtime has not installed health monitoring agent. + // Applies to ACTIVE state. + AGENT_NOT_INSTALLED = 3; + + // The runtime health monitoring agent is not running. + // Applies to ACTIVE state. + AGENT_NOT_RUNNING = 4; + } + + // Output only. The resource name of the runtime. + // Format: + // `projects/{project}/locations/{location}/runtimes/{runtimeId}` + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Type of the runtime; currently only supports Compute Engine VM. + oneof runtime_type { + // Use a Compute Engine VM image to start the managed notebook instance. + VirtualMachine virtual_machine = 2; + } + + // Output only. Runtime state. + State state = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Runtime health_state. + HealthState health_state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The config settings for accessing runtime. + RuntimeAccessConfig access_config = 5; + + // The config settings for software inside the runtime. + RuntimeSoftwareConfig software_config = 6; + + // Output only. Contains Runtime daemon metrics such as Service status and JupyterLab + // stats. + RuntimeMetrics metrics = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Runtime creation time. + google.protobuf.Timestamp create_time = 20 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Runtime update time. + google.protobuf.Timestamp update_time = 21 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Definition of the types of hardware accelerators that can be used. +// Definition of the types of hardware accelerators that can be used. +// See [Compute Engine +// AcceleratorTypes](https://cloud.google.com/compute/docs/reference/beta/acceleratorTypes). +// Examples: +// +// * `nvidia-tesla-k80` +// * `nvidia-tesla-p100` +// * `nvidia-tesla-v100` +// * `nvidia-tesla-p4` +// * `nvidia-tesla-t4` +// * `nvidia-tesla-a100` +message RuntimeAcceleratorConfig { + // Type of this accelerator. + enum AcceleratorType { + // Accelerator type is not specified. + ACCELERATOR_TYPE_UNSPECIFIED = 0; + + // Accelerator type is Nvidia Tesla K80. + NVIDIA_TESLA_K80 = 1 [deprecated = true]; + + // Accelerator type is Nvidia Tesla P100. + NVIDIA_TESLA_P100 = 2; + + // Accelerator type is Nvidia Tesla V100. + NVIDIA_TESLA_V100 = 3; + + // Accelerator type is Nvidia Tesla P4. + NVIDIA_TESLA_P4 = 4; + + // Accelerator type is Nvidia Tesla T4. + NVIDIA_TESLA_T4 = 5; + + // Accelerator type is Nvidia Tesla A100. + NVIDIA_TESLA_A100 = 6; + + // (Coming soon) Accelerator type is TPU V2. + TPU_V2 = 7; + + // (Coming soon) Accelerator type is TPU V3. + TPU_V3 = 8; + + // Accelerator type is NVIDIA Tesla T4 Virtual Workstations. + NVIDIA_TESLA_T4_VWS = 9; + + // Accelerator type is NVIDIA Tesla P100 Virtual Workstations. + NVIDIA_TESLA_P100_VWS = 10; + + // Accelerator type is NVIDIA Tesla P4 Virtual Workstations. + NVIDIA_TESLA_P4_VWS = 11; + } + + // Accelerator model. + AcceleratorType type = 1; + + // Count of cores of this accelerator. + int64 core_count = 2; +} + +// Represents a custom encryption key configuration that can be applied to +// a resource. This will encrypt all disks in Virtual Machine. +message EncryptionConfig { + // The Cloud KMS resource identifier of the customer-managed encryption key + // used to protect a resource, such as a disks. It has the following + // format: + // `projects/{PROJECT_ID}/locations/{REGION}/keyRings/{KEY_RING_NAME}/cryptoKeys/{KEY_NAME}` + string kms_key = 1; +} + +// A Local attached disk resource. +message LocalDisk { + // Optional. A list of features to enable on the guest operating system. + // Applicable only for bootable images. + // Read [Enabling guest operating system + // features](https://cloud.google.com/compute/docs/images/create-delete-deprecate-private-images#guest-os-features) + // to see a list of available options. + // Guest OS features for boot disk. + message RuntimeGuestOsFeature { + // The ID of a supported feature. Read [Enabling guest operating system + // features](https://cloud.google.com/compute/docs/images/create-delete-deprecate-private-images#guest-os-features) + // to see a list of available options. + // + // Valid values: + // + // * `FEATURE_TYPE_UNSPECIFIED` + // * `MULTI_IP_SUBNET` + // * `SECURE_BOOT` + // * `UEFI_COMPATIBLE` + // * `VIRTIO_SCSI_MULTIQUEUE` + // * `WINDOWS` + string type = 1; + } + + // Optional. Output only. Specifies whether the disk will be auto-deleted when the + // instance is deleted (but not when the disk is detached from the instance). + bool auto_delete = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Output only. Indicates that this is a boot disk. The virtual machine + // will use the first partition of the disk for its root filesystem. + bool boot = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Output only. Specifies a unique device name + // of your choice that is reflected into the + // `/dev/disk/by-id/google-*` tree of a Linux operating system running within + // the instance. This name can be used to reference the device for mounting, + // resizing, and so on, from within the instance. + // + // If not specified, the server chooses a default device name to apply to this + // disk, in the form persistent-disk-x, where x is a number assigned by Google + // Compute Engine. This field is only applicable for persistent disks. + string device_name = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Indicates a list of features to enable on the guest operating system. + // Applicable only for bootable images. Read Enabling guest operating + // system features to see a list of available options. + repeated RuntimeGuestOsFeature guest_os_features = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A zero-based index to this disk, where 0 is reserved for the + // boot disk. If you have many disks attached to an instance, each disk would + // have a unique index number. + int32 index = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Input only. Specifies the parameters for a new disk that will be created + // alongside the new instance. Use initialization parameters to create boot + // disks or local SSDs attached to the new instance. + // + // This property is mutually exclusive with the source property; you can only + // define one or the other, but not both. + LocalDiskInitializeParams initialize_params = 6 [(google.api.field_behavior) = INPUT_ONLY]; + + // Specifies the disk interface to use for attaching this disk, which is + // either SCSI or NVME. The default is SCSI. Persistent disks must always use + // SCSI and the request will fail if you attempt to attach a persistent disk + // in any other format than SCSI. Local SSDs can use either NVME or SCSI. For + // performance characteristics of SCSI over NVMe, see Local SSD performance. + // Valid values: + // + // * `NVME` + // * `SCSI` + string interface = 7; + + // Output only. Type of the resource. Always compute#attachedDisk for attached disks. + string kind = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Any valid publicly visible licenses. + repeated string licenses = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The mode in which to attach this disk, either `READ_WRITE` or `READ_ONLY`. + // If not specified, the default is to attach the disk in `READ_WRITE` mode. + // Valid values: + // + // * `READ_ONLY` + // * `READ_WRITE` + string mode = 10; + + // Specifies a valid partial or full URL to an existing Persistent Disk + // resource. + string source = 11; + + // Specifies the type of the disk, either `SCRATCH` or `PERSISTENT`. If not + // specified, the default is `PERSISTENT`. + // Valid values: + // + // * `PERSISTENT` + // * `SCRATCH` + string type = 12; +} + +// Input only. Specifies the parameters for a new disk that will be created +// alongside the new instance. Use initialization parameters to create boot +// disks or local SSDs attached to the new runtime. +// This property is mutually exclusive with the source property; you can only +// define one or the other, but not both. +message LocalDiskInitializeParams { + // Possible disk types. + enum DiskType { + // Disk type not set. + DISK_TYPE_UNSPECIFIED = 0; + + // Standard persistent disk type. + PD_STANDARD = 1; + + // SSD persistent disk type. + PD_SSD = 2; + + // Balanced persistent disk type. + PD_BALANCED = 3; + + // Extreme persistent disk type. + PD_EXTREME = 4; + } + + // Optional. Provide this property when creating the disk. + string description = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Specifies the disk name. If not specified, the default is to use the name + // of the instance. If the disk with the instance name exists already in the + // given zone/region, a new name will be automatically generated. + string disk_name = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Specifies the size of the disk in base-2 GB. If not specified, the disk + // will be the same size as the image (usually 10GB). If specified, the size + // must be equal to or larger than 10GB. Default 100 GB. + int64 disk_size_gb = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Input only. The type of the boot disk attached to this instance, defaults to + // standard persistent disk (`PD_STANDARD`). + DiskType disk_type = 4 [(google.api.field_behavior) = INPUT_ONLY]; + + // Optional. Labels to apply to this disk. These can be later modified by the + // disks.setLabels method. This field is only applicable for persistent disks. + map labels = 5 [(google.api.field_behavior) = OPTIONAL]; +} + +// Specifies the login configuration for Runtime +message RuntimeAccessConfig { + // Possible ways to access runtime. Authentication mode. + // Currently supports: Single User only. + enum RuntimeAccessType { + // Unspecified access. + RUNTIME_ACCESS_TYPE_UNSPECIFIED = 0; + + // Single user login. + SINGLE_USER = 1; + + // Service Account mode. + // In Service Account mode, Runtime creator will specify a SA that exists + // in the consumer project. Using Runtime Service Account field. + // Users accessing the Runtime need ActAs (Service Account User) permission. + SERVICE_ACCOUNT = 2; + } + + // The type of access mode this instance. + RuntimeAccessType access_type = 1; + + // The owner of this runtime after creation. Format: `alias@example.com` + // Currently supports one owner only. + string runtime_owner = 2; + + // Output only. The proxy endpoint that is used to access the runtime. + string proxy_uri = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Specifies the selection and configuration of software inside the runtime. +// The properties to set on runtime. +// Properties keys are specified in `key:value` format, for example: +// +// * `idle_shutdown: true` +// * `idle_shutdown_timeout: 180` +// * `enable_health_monitoring: true` +message RuntimeSoftwareConfig { + // Behavior for the post startup script. + enum PostStartupScriptBehavior { + // Unspecified post startup script behavior. Will run only once at creation. + POST_STARTUP_SCRIPT_BEHAVIOR_UNSPECIFIED = 0; + + // Runs the post startup script provided during creation at every start. + RUN_EVERY_START = 1; + + // Downloads and runs the provided post startup script at every start. + DOWNLOAD_AND_RUN_EVERY_START = 2; + } + + // Cron expression in UTC timezone, used to schedule instance auto upgrade. + // Please follow the [cron format](https://en.wikipedia.org/wiki/Cron). + string notebook_upgrade_schedule = 1; + + // Verifies core internal services are running. + // Default: True + optional bool enable_health_monitoring = 2; + + // Runtime will automatically shutdown after idle_shutdown_time. + // Default: True + optional bool idle_shutdown = 3; + + // Time in minutes to wait before shutting down runtime. Default: 180 minutes + int32 idle_shutdown_timeout = 4; + + // Install Nvidia Driver automatically. + // Default: True + bool install_gpu_driver = 5; + + // Specify a custom Cloud Storage path where the GPU driver is stored. + // If not specified, we'll automatically choose from official GPU drivers. + string custom_gpu_driver_path = 6; + + // Path to a Bash script that automatically runs after a notebook instance + // fully boots up. The path must be a URL or + // Cloud Storage path (`gs://path-to-file/file-name`). + string post_startup_script = 7; + + // Optional. Use a list of container images to use as Kernels in the notebook instance. + repeated ContainerImage kernels = 8 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. Bool indicating whether an newer image is available in an image family. + optional bool upgradeable = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Behavior for the post startup script. + PostStartupScriptBehavior post_startup_script_behavior = 10; + + // Bool indicating whether JupyterLab terminal will be available or not. + // Default: False + optional bool disable_terminal = 11; + + // Output only. version of boot image such as M100, from release label of the image. + optional string version = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Contains runtime daemon metrics, such as OS and kernels and sessions stats. +message RuntimeMetrics { + // Output only. The system metrics. + map system_metrics = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A set of Shielded Instance options. +// Check [Images using supported Shielded VM +// features](https://cloud.google.com/compute/docs/instances/modifying-shielded-vm). +// Not all combinations are valid. +message RuntimeShieldedInstanceConfig { + // Defines whether the instance has Secure Boot enabled. + // + // Secure Boot helps ensure that the system only runs authentic software by + // verifying the digital signature of all boot components, and halting the + // boot process if signature verification fails. Disabled by default. + bool enable_secure_boot = 1; + + // Defines whether the instance has the vTPM enabled. Enabled by default. + bool enable_vtpm = 2; + + // Defines whether the instance has integrity monitoring enabled. + // + // Enables monitoring and attestation of the boot integrity of the instance. + // The attestation is performed against the integrity policy baseline. This + // baseline is initially derived from the implicitly trusted boot image when + // the instance is created. Enabled by default. + bool enable_integrity_monitoring = 3; +} + +// Runtime using Virtual Machine for computing. +message VirtualMachine { + // Output only. The user-friendly name of the Managed Compute Engine instance. + string instance_name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The unique identifier of the Managed Compute Engine instance. + string instance_id = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Virtual Machine configuration settings. + VirtualMachineConfig virtual_machine_config = 3; +} + +// The config settings for virtual machine. +message VirtualMachineConfig { + // The type of vNIC driver. + // Default should be UNSPECIFIED_NIC_TYPE. + enum NicType { + // No type specified. + UNSPECIFIED_NIC_TYPE = 0; + + // VIRTIO + VIRTIO_NET = 1; + + // GVNIC + GVNIC = 2; + } + + // Definition of the boot image used by the Runtime. + // Used to facilitate runtime upgradeability. + message BootImage { + + } + + // Output only. The zone where the virtual machine is located. + // If using regional request, the notebooks service will pick a location + // in the corresponding runtime region. + // On a get request, zone will always be present. Example: + // * `us-central1-b` + string zone = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. The Compute Engine machine type used for runtimes. + // Short name is valid. Examples: + // * `n1-standard-2` + // * `e2-standard-8` + string machine_type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Use a list of container images to use as Kernels in the notebook instance. + repeated ContainerImage container_images = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Required. Data disk option configuration settings. + LocalDisk data_disk = 4 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Encryption settings for virtual machine data disk. + EncryptionConfig encryption_config = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Shielded VM Instance configuration settings. + RuntimeShieldedInstanceConfig shielded_instance_config = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The Compute Engine accelerator configuration for this runtime. + RuntimeAcceleratorConfig accelerator_config = 7 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The Compute Engine network to be used for machine + // communications. Cannot be specified with subnetwork. If neither + // `network` nor `subnet` is specified, the "default" network of + // the project is used, if it exists. + // + // A full URL or partial URI. Examples: + // + // * `https://www.googleapis.com/compute/v1/projects/[project_id]/global/networks/default` + // * `projects/[project_id]/global/networks/default` + // + // Runtimes are managed resources inside Google Infrastructure. + // Runtimes support the following network configurations: + // + // * Google Managed Network (Network & subnet are empty) + // * Consumer Project VPC (network & subnet are required). Requires + // configuring Private Service Access. + // * Shared VPC (network & subnet are required). Requires configuring Private + // Service Access. + string network = 8 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The Compute Engine subnetwork to be used for machine + // communications. Cannot be specified with network. + // + // A full URL or partial URI are valid. Examples: + // + // * `https://www.googleapis.com/compute/v1/projects/[project_id]/regions/us-east1/subnetworks/sub0` + // * `projects/[project_id]/regions/us-east1/subnetworks/sub0` + string subnet = 9 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If true, runtime will only have internal IP + // addresses. By default, runtimes are not restricted to internal IP + // addresses, and will have ephemeral external IP addresses assigned to each + // vm. This `internal_ip_only` restriction can only be enabled for + // subnetwork enabled networks, and all dependencies must be + // configured to be accessible without external IP addresses. + bool internal_ip_only = 10 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The Compute Engine tags to add to runtime (see [Tagging + // instances](https://cloud.google.com/compute/docs/label-or-tag-resources#tags)). + repeated string tags = 13 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The Compute Engine guest attributes. (see + // [Project and instance + // guest + // attributes](https://cloud.google.com/compute/docs/storing-retrieving-metadata#guest_attributes)). + map guest_attributes = 14 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. The Compute Engine metadata entries to add to virtual machine. (see + // [Project and instance + // metadata](https://cloud.google.com/compute/docs/storing-retrieving-metadata#project_and_instance_metadata)). + map metadata = 15 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The labels to associate with this runtime. + // Label **keys** must contain 1 to 63 characters, and must conform to + // [RFC 1035](https://www.ietf.org/rfc/rfc1035.txt). + // Label **values** may be empty, but, if present, must contain 1 to 63 + // characters, and must conform to [RFC + // 1035](https://www.ietf.org/rfc/rfc1035.txt). No more than 32 labels can be + // associated with a cluster. + map labels = 16 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The type of vNIC to be used on this interface. This may be gVNIC or + // VirtioNet. + NicType nic_type = 17 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Reserved IP Range name is used for VPC Peering. + // The subnetwork allocation will use the range *name* if it's assigned. + // + // Example: managed-notebooks-range-c + // + // PEERING_RANGE_NAME_3=managed-notebooks-range-c + // gcloud compute addresses create $PEERING_RANGE_NAME_3 \ + // --global \ + // --prefix-length=24 \ + // --description="Google Cloud Managed Notebooks Range 24 c" \ + // --network=$NETWORK \ + // --addresses=192.168.0.0 \ + // --purpose=VPC_PEERING + // + // Field value will be: `managed-notebooks-range-c` + string reserved_ip_range = 18 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Boot image metadata used for runtime upgradeability. + BootImage boot_image = 19 [(google.api.field_behavior) = OPTIONAL]; +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/schedule.proto b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/schedule.proto new file mode 100644 index 00000000000..9d30a17eed8 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/schedule.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.notebooks.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/notebooks/v1/execution.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "cloud.google.com/go/notebooks/apiv1/notebookspb;notebookspb"; +option java_multiple_files = true; +option java_outer_classname = "ScheduleProto"; +option java_package = "com.google.cloud.notebooks.v1"; + +// The definition of a schedule. +message Schedule { + option (google.api.resource) = { + type: "notebooks.googleapis.com/Schedule" + pattern: "projects/{project}/location/{location}/schedules/{schedule}" + }; + + // State of the job. + enum State { + // Unspecified state. + STATE_UNSPECIFIED = 0; + + // The job is executing normally. + ENABLED = 1; + + // The job is paused by the user. It will not execute. A user can + // intentionally pause the job using + // [PauseJobRequest][]. + PAUSED = 2; + + // The job is disabled by the system due to error. The user + // cannot directly set a job to be disabled. + DISABLED = 3; + + // The job state resulting from a failed [CloudScheduler.UpdateJob][] + // operation. To recover a job from this state, retry + // [CloudScheduler.UpdateJob][] until a successful response is received. + UPDATE_FAILED = 4; + + // The schedule resource is being created. + INITIALIZING = 5; + + // The schedule resource is being deleted. + DELETING = 6; + } + + // Output only. The name of this schedule. Format: + // `projects/{project_id}/locations/{location}/schedules/{schedule_id}` + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Display name used for UI purposes. + // Name can only contain alphanumeric characters, hyphens `-`, + // and underscores `_`. + string display_name = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // A brief description of this environment. + string description = 3; + + State state = 4; + + // Cron-tab formatted schedule by which the job will execute. + // Format: minute, hour, day of month, month, day of week, + // e.g. `0 0 * * WED` = every Wednesday + // More examples: https://crontab.guru/examples.html + string cron_schedule = 5; + + // Timezone on which the cron_schedule. + // The value of this field must be a time zone name from the tz database. + // TZ Database: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones + // + // Note that some time zones include a provision for daylight savings time. + // The rules for daylight saving time are determined by the chosen tz. + // For UTC use the string "utc". If a time zone is not specified, + // the default will be in UTC (also known as GMT). + string time_zone = 6; + + // Output only. Time the schedule was created. + google.protobuf.Timestamp create_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Time the schedule was last updated. + google.protobuf.Timestamp update_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Notebook Execution Template corresponding to this schedule. + ExecutionTemplate execution_template = 9; + + // Output only. The most recent execution names triggered from this schedule and their + // corresponding states. + repeated Execution recent_executions = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/service.proto b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/service.proto new file mode 100644 index 00000000000..04c42eddd12 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/service.proto @@ -0,0 +1,1017 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.notebooks.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/notebooks/v1/diagnostic_config.proto"; +import "google/cloud/notebooks/v1/environment.proto"; +import "google/cloud/notebooks/v1/execution.proto"; +import "google/cloud/notebooks/v1/instance.proto"; +import "google/cloud/notebooks/v1/instance_config.proto"; +import "google/cloud/notebooks/v1/schedule.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Notebooks.V1"; +option go_package = "cloud.google.com/go/notebooks/apiv1/notebookspb;notebookspb"; +option java_multiple_files = true; +option java_outer_classname = "NotebooksProto"; +option java_package = "com.google.cloud.notebooks.v1"; +option php_namespace = "Google\\Cloud\\Notebooks\\V1"; +option ruby_package = "Google::Cloud::Notebooks::V1"; + +// API v1 service for Cloud AI Platform Notebooks. +service NotebookService { + option (google.api.default_host) = "notebooks.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Lists instances in a given project and location. + rpc ListInstances(ListInstancesRequest) returns (ListInstancesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/instances" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets details of a single Instance. + rpc GetInstance(GetInstanceRequest) returns (Instance) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/instances/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new Instance in a given project and location. + rpc CreateInstance(CreateInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/instances" + body: "instance" + }; + option (google.api.method_signature) = "parent,instance,instance_id"; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Registers an existing legacy notebook instance to the Notebooks API server. + // Legacy instances are instances created with the legacy Compute Engine + // calls. They are not manageable by the Notebooks API out of the box. This + // call makes these instances manageable by the Notebooks API. + rpc RegisterInstance(RegisterInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/instances:register" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Updates the guest accelerators of a single Instance. + rpc SetInstanceAccelerator(SetInstanceAcceleratorRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{name=projects/*/locations/*/instances/*}:setAccelerator" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Updates the machine type of a single Instance. + rpc SetInstanceMachineType(SetInstanceMachineTypeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{name=projects/*/locations/*/instances/*}:setMachineType" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Update Notebook Instance configurations. + rpc UpdateInstanceConfig(UpdateInstanceConfigRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{name=projects/*/locations/*/instances/*}:updateConfig" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Updates the Shielded instance configuration of a single Instance. + rpc UpdateShieldedInstanceConfig(UpdateShieldedInstanceConfigRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{name=projects/*/locations/*/instances/*}:updateShieldedInstanceConfig" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Replaces all the labels of an Instance. + rpc SetInstanceLabels(SetInstanceLabelsRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{name=projects/*/locations/*/instances/*}:setLabels" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Add/update metadata items for an instance. + rpc UpdateInstanceMetadataItems(UpdateInstanceMetadataItemsRequest) returns (UpdateInstanceMetadataItemsResponse) { + option (google.api.http) = { + patch: "/v1/{name=projects/*/locations/*/instances/*}:updateMetadataItems" + body: "*" + }; + } + + // Deletes a single Instance. + rpc DeleteInstance(DeleteInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/instances/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "OperationMetadata" + }; + } + + // Starts a notebook instance. + rpc StartInstance(StartInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/instances/*}:start" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Stops a notebook instance. + rpc StopInstance(StopInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/instances/*}:stop" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Resets a notebook instance. + rpc ResetInstance(ResetInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/instances/*}:reset" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Allows notebook instances to + // report their latest instance information to the Notebooks + // API server. The server will merge the reported information to + // the instance metadata store. Do not use this method directly. + rpc ReportInstanceInfo(ReportInstanceInfoRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/instances/*}:report" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Check if a notebook instance is upgradable. + rpc IsInstanceUpgradeable(IsInstanceUpgradeableRequest) returns (IsInstanceUpgradeableResponse) { + option (google.api.http) = { + get: "/v1/{notebook_instance=projects/*/locations/*/instances/*}:isUpgradeable" + }; + } + + // Check if a notebook instance is healthy. + rpc GetInstanceHealth(GetInstanceHealthRequest) returns (GetInstanceHealthResponse) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/instances/*}:getInstanceHealth" + }; + option (google.api.method_signature) = "name"; + } + + // Upgrades a notebook instance to the latest version. + rpc UpgradeInstance(UpgradeInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/instances/*}:upgrade" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Rollbacks a notebook instance to the previous version. + rpc RollbackInstance(RollbackInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/instances/*}:rollback" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Creates a Diagnostic File and runs Diagnostic Tool given an Instance. + rpc DiagnoseInstance(DiagnoseInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/instances/*}:diagnose" + body: "*" + }; + option (google.api.method_signature) = "name,diagnostic_config"; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Allows notebook instances to + // call this endpoint to upgrade themselves. Do not use this method directly. + rpc UpgradeInstanceInternal(UpgradeInstanceInternalRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/instances/*}:upgradeInternal" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Lists environments in a project. + rpc ListEnvironments(ListEnvironmentsRequest) returns (ListEnvironmentsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/environments" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets details of a single Environment. + rpc GetEnvironment(GetEnvironmentRequest) returns (Environment) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/environments/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new Environment. + rpc CreateEnvironment(CreateEnvironmentRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/environments" + body: "environment" + }; + option (google.api.method_signature) = "parent,environment,environment_id"; + option (google.longrunning.operation_info) = { + response_type: "Environment" + metadata_type: "OperationMetadata" + }; + } + + // Deletes a single Environment. + rpc DeleteEnvironment(DeleteEnvironmentRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/environments/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "OperationMetadata" + }; + } + + // Lists schedules in a given project and location. + rpc ListSchedules(ListSchedulesRequest) returns (ListSchedulesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/schedules" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets details of schedule + rpc GetSchedule(GetScheduleRequest) returns (Schedule) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/schedules/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Deletes schedule and all underlying jobs + rpc DeleteSchedule(DeleteScheduleRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/schedules/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "OperationMetadata" + }; + } + + // Creates a new Scheduled Notebook in a given project and location. + rpc CreateSchedule(CreateScheduleRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/schedules" + body: "schedule" + }; + option (google.api.method_signature) = "parent,schedule,schedule_id"; + option (google.longrunning.operation_info) = { + response_type: "Schedule" + metadata_type: "OperationMetadata" + }; + } + + // Triggers execution of an existing schedule. + rpc TriggerSchedule(TriggerScheduleRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/schedules/*}:trigger" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Schedule" + metadata_type: "OperationMetadata" + }; + } + + // Lists executions in a given project and location + rpc ListExecutions(ListExecutionsRequest) returns (ListExecutionsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/executions" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets details of executions + rpc GetExecution(GetExecutionRequest) returns (Execution) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/executions/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Deletes execution + rpc DeleteExecution(DeleteExecutionRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/executions/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "OperationMetadata" + }; + } + + // Creates a new Execution in a given project and location. + rpc CreateExecution(CreateExecutionRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/executions" + body: "execution" + }; + option (google.api.method_signature) = "parent,execution,execution_id"; + option (google.longrunning.operation_info) = { + response_type: "Execution" + metadata_type: "OperationMetadata" + }; + } +} + +// Represents the metadata of the long-running operation. +message OperationMetadata { + // The time the operation was created. + google.protobuf.Timestamp create_time = 1; + + // The time the operation finished running. + google.protobuf.Timestamp end_time = 2; + + // Server-defined resource path for the target of the operation. + string target = 3; + + // Name of the verb executed by the operation. + string verb = 4; + + // Human-readable status of the operation, if any. + string status_message = 5; + + // Identifies whether the user has requested cancellation + // of the operation. Operations that have successfully been cancelled + // have [Operation.error][] value with a + // [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`. + bool requested_cancellation = 6; + + // API version used to start the operation. + string api_version = 7; + + // API endpoint name of this operation. + string endpoint = 8; +} + +// Request for listing notebook instances. +message ListInstancesRequest { + // Required. Format: + // `parent=projects/{project_id}/locations/{location}` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Maximum return size of the list call. + int32 page_size = 2; + + // A previous returned page token that can be used to continue listing + // from the last result. + string page_token = 3; +} + +// Response for listing notebook instances. +message ListInstancesResponse { + // A list of returned instances. + repeated Instance instances = 1; + + // Page token that can be used to continue listing from the last result in the + // next list call. + string next_page_token = 2; + + // Locations that could not be reached. For example, + // `['us-west1-a', 'us-central1-b']`. + // A ListInstancesResponse will only contain either instances or unreachables, + repeated string unreachable = 3; +} + +// Request for getting a notebook instance. +message GetInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for creating a notebook instance. +message CreateInstanceRequest { + // Required. Format: + // `parent=projects/{project_id}/locations/{location}` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. User-defined unique ID of this instance. + string instance_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The instance to be created. + Instance instance = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for registering a notebook instance. +message RegisterInstanceRequest { + // Required. Format: + // `parent=projects/{project_id}/locations/{location}` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. User defined unique ID of this instance. The `instance_id` must + // be 1 to 63 characters long and contain only lowercase letters, + // numeric characters, and dashes. The first character must be a lowercase + // letter and the last character cannot be a dash. + string instance_id = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for setting instance accelerator. +message SetInstanceAcceleratorRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Type of this accelerator. + Instance.AcceleratorType type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. Count of cores of this accelerator. Note that not all combinations + // of `type` and `core_count` are valid. Check [GPUs on + // Compute Engine](https://cloud.google.com/compute/docs/gpus/#gpus-list) to + // find a valid combination. TPUs are not supported. + int64 core_count = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for setting instance machine type. +message SetInstanceMachineTypeRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The [Compute Engine machine + // type](https://cloud.google.com/compute/docs/machine-types). + string machine_type = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for updating instance configurations. +message UpdateInstanceConfigRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // The instance configurations to be updated. + InstanceConfig config = 2; +} + +// Request for setting instance labels. +message SetInstanceLabelsRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Labels to apply to this instance. + // These can be later modified by the setLabels method + map labels = 2; +} + +// Request for adding/changing metadata items for an instance. +message UpdateInstanceMetadataItemsRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Metadata items to add/update for the instance. + map items = 2; +} + +// Response for adding/changing metadata items for an instance. +message UpdateInstanceMetadataItemsResponse { + // Map of items that were added/updated to/in the metadata. + map items = 1; +} + +// Request for updating the Shielded Instance config for a notebook instance. +// You can only use this method on a stopped instance +message UpdateShieldedInstanceConfigRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // ShieldedInstance configuration to be updated. + Instance.ShieldedInstanceConfig shielded_instance_config = 2; +} + +// Request for deleting a notebook instance. +message DeleteInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for starting a notebook instance +message StartInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for stopping a notebook instance +message StopInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for resetting a notebook instance +message ResetInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for notebook instances to report information to Notebooks API. +message ReportInstanceInfoRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The VM hardware token for authenticating the VM. + // https://cloud.google.com/compute/docs/instances/verifying-instance-identity + string vm_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // The metadata reported to Notebooks API. This will be merged to the instance + // metadata store + map metadata = 3; +} + +// Request for checking if a notebook instance is upgradeable. +message IsInstanceUpgradeableRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string notebook_instance = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The optional UpgradeType. Setting this field will search for additional + // compute images to upgrade this instance. + UpgradeType type = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response for checking if a notebook instance is upgradeable. +message IsInstanceUpgradeableResponse { + // If an instance is upgradeable. + bool upgradeable = 1; + + // The version this instance will be upgraded to if calling the upgrade + // endpoint. This field will only be populated if field upgradeable is true. + string upgrade_version = 2; + + // Additional information about upgrade. + string upgrade_info = 3; + + // The new image self link this instance will be upgraded to if calling the + // upgrade endpoint. This field will only be populated if field upgradeable + // is true. + string upgrade_image = 4; +} + +// Request for checking if a notebook instance is healthy. +message GetInstanceHealthRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "notebooks.googleapis.com/Instance" + } + ]; +} + +// Response for checking if a notebook instance is healthy. +message GetInstanceHealthResponse { + // If an instance is healthy or not. + enum HealthState { + // The instance substate is unknown. + HEALTH_STATE_UNSPECIFIED = 0; + + // The instance is known to be in an healthy state + // (for example, critical daemons are running) + // Applies to ACTIVE state. + HEALTHY = 1; + + // The instance is known to be in an unhealthy state + // (for example, critical daemons are not running) + // Applies to ACTIVE state. + UNHEALTHY = 2; + + // The instance has not installed health monitoring agent. + // Applies to ACTIVE state. + AGENT_NOT_INSTALLED = 3; + + // The instance health monitoring agent is not running. + // Applies to ACTIVE state. + AGENT_NOT_RUNNING = 4; + } + + // Output only. Runtime health_state. + HealthState health_state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Additional information about instance health. + // Example: + // healthInfo": { + // "docker_proxy_agent_status": "1", + // "docker_status": "1", + // "jupyterlab_api_status": "-1", + // "jupyterlab_status": "-1", + // "updated": "2020-10-18 09:40:03.573409" + // } + map health_info = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Request for upgrading a notebook instance +message UpgradeInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The optional UpgradeType. Setting this field will search for additional + // compute images to upgrade this instance. + UpgradeType type = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for rollbacking a notebook instance +message RollbackInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The snapshot for rollback. + // Example: `projects/test-project/global/snapshots/krwlzipynril`. + string target_snapshot = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for upgrading a notebook instance from within the VM +message UpgradeInstanceInternalRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The VM hardware token for authenticating the VM. + // https://cloud.google.com/compute/docs/instances/verifying-instance-identity + string vm_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The optional UpgradeType. Setting this field will search for additional + // compute images to upgrade this instance. + UpgradeType type = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for listing environments. +message ListEnvironmentsRequest { + // Required. Format: `projects/{project_id}/locations/{location}` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Maximum return size of the list call. + int32 page_size = 2; + + // A previous returned page token that can be used to continue listing from + // the last result. + string page_token = 3; +} + +// Request for creating a notebook instance diagnostic file. +message DiagnoseInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "notebooks.googleapis.com/Instance" + } + ]; + + // Required. Defines flags that are used to run the diagnostic tool + DiagnosticConfig diagnostic_config = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response for listing environments. +message ListEnvironmentsResponse { + // A list of returned environments. + repeated Environment environments = 1; + + // A page token that can be used to continue listing from the last result + // in the next list call. + string next_page_token = 2; + + // Locations that could not be reached. + repeated string unreachable = 3; +} + +// Request for getting a notebook environment. +message GetEnvironmentRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/environments/{environment_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for creating a notebook environment. +message CreateEnvironmentRequest { + // Required. Format: `projects/{project_id}/locations/{location}` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. User-defined unique ID of this environment. The `environment_id` must + // be 1 to 63 characters long and contain only lowercase letters, + // numeric characters, and dashes. The first character must be a lowercase + // letter and the last character cannot be a dash. + string environment_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The environment to be created. + Environment environment = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for deleting a notebook environment. +message DeleteEnvironmentRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/environments/{environment_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for listing scheduled notebook job. +message ListSchedulesRequest { + // Required. Format: + // `parent=projects/{project_id}/locations/{location}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "notebooks.googleapis.com/Schedule" + } + ]; + + // Maximum return size of the list call. + int32 page_size = 2; + + // A previous returned page token that can be used to continue listing + // from the last result. + string page_token = 3; + + // Filter applied to resulting schedules. + string filter = 4; + + // Field to order results by. + string order_by = 5; +} + +// Response for listing scheduled notebook job. +message ListSchedulesResponse { + // A list of returned instances. + repeated Schedule schedules = 1; + + // Page token that can be used to continue listing from the last result in the + // next list call. + string next_page_token = 2; + + // Schedules that could not be reached. For example: + // + // ['projects/{project_id}/location/{location}/schedules/monthly_digest', + // 'projects/{project_id}/location/{location}/schedules/weekly_sentiment'] + repeated string unreachable = 3; +} + +// Request for getting scheduled notebook. +message GetScheduleRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/schedules/{schedule_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "notebooks.googleapis.com/Schedule" + } + ]; +} + +// Request for deleting an Schedule +message DeleteScheduleRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/schedules/{schedule_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "notebooks.googleapis.com/Schedule" + } + ]; +} + +// Request for created scheduled notebooks +message CreateScheduleRequest { + // Required. Format: + // `parent=projects/{project_id}/locations/{location}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "notebooks.googleapis.com/Schedule" + } + ]; + + // Required. User-defined unique ID of this schedule. + string schedule_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The schedule to be created. + Schedule schedule = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for created scheduled notebooks +message TriggerScheduleRequest { + // Required. Format: + // `parent=projects/{project_id}/locations/{location}/schedules/{schedule_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "notebooks.googleapis.com/Schedule" + } + ]; +} + +// Request for listing scheduled notebook executions. +message ListExecutionsRequest { + // Required. Format: + // `parent=projects/{project_id}/locations/{location}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "notebooks.googleapis.com/Execution" + } + ]; + + // Maximum return size of the list call. + int32 page_size = 2; + + // A previous returned page token that can be used to continue listing + // from the last result. + string page_token = 3; + + // Filter applied to resulting executions. Currently only supports filtering + // executions by a specified `schedule_id`. + // Format: `schedule_id=` + string filter = 4; + + // Sort by field. + string order_by = 5; +} + +// Response for listing scheduled notebook executions +message ListExecutionsResponse { + // A list of returned instances. + repeated Execution executions = 1; + + // Page token that can be used to continue listing from the last result in the + // next list call. + string next_page_token = 2; + + // Executions IDs that could not be reached. For example: + // + // ['projects/{project_id}/location/{location}/executions/imagenet_test1', + // 'projects/{project_id}/location/{location}/executions/classifier_train1'] + repeated string unreachable = 3; +} + +// Request for getting scheduled notebook execution +message GetExecutionRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/executions/{execution_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "notebooks.googleapis.com/Execution" + } + ]; +} + +// Request for deleting a scheduled notebook execution +message DeleteExecutionRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/executions/{execution_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "notebooks.googleapis.com/Execution" + } + ]; +} + +// Request to create notebook execution +message CreateExecutionRequest { + // Required. Format: + // `parent=projects/{project_id}/locations/{location}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "notebooks.googleapis.com/Execution" + } + ]; + + // Required. User-defined unique ID of this execution. + string execution_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The execution to be created. + Execution execution = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Definition of the types of upgrade that can be used on this +// instance. +enum UpgradeType { + // Upgrade type is not specified. + UPGRADE_TYPE_UNSPECIFIED = 0; + + // Upgrade ML framework. + UPGRADE_FRAMEWORK = 1; + + // Upgrade Operating System. + UPGRADE_OS = 2; + + // Upgrade CUDA. + UPGRADE_CUDA = 3; + + // Upgrade All (OS, Framework and CUDA). + UPGRADE_ALL = 4; +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.create_runtime.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.create_runtime.js new file mode 100644 index 00000000000..2c1efc1c9bd --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.create_runtime.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(parent, runtimeId, runtime) { + // [START notebooks_v1_generated_ManagedNotebookService_CreateRuntime_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + */ + // const parent = 'abc123' + /** + * Required. User-defined unique ID of this Runtime. + */ + // const runtimeId = 'abc123' + /** + * Required. The Runtime to be created. + */ + // const runtime = {} + /** + * Idempotent request UUID. + */ + // const requestId = 'abc123' + + // Imports the Notebooks library + const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new ManagedNotebookServiceClient(); + + async function callCreateRuntime() { + // Construct request + const request = { + parent, + runtimeId, + runtime, + }; + + // Run request + const [operation] = await notebooksClient.createRuntime(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateRuntime(); + // [END notebooks_v1_generated_ManagedNotebookService_CreateRuntime_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.delete_runtime.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.delete_runtime.js new file mode 100644 index 00000000000..e85d4f18750 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.delete_runtime.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(name) { + // [START notebooks_v1_generated_ManagedNotebookService_DeleteRuntime_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + */ + // const name = 'abc123' + /** + * Idempotent request UUID. + */ + // const requestId = 'abc123' + + // Imports the Notebooks library + const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new ManagedNotebookServiceClient(); + + async function callDeleteRuntime() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.deleteRuntime(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteRuntime(); + // [END notebooks_v1_generated_ManagedNotebookService_DeleteRuntime_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.diagnose_runtime.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.diagnose_runtime.js new file mode 100644 index 00000000000..009022105ae --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.diagnose_runtime.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, diagnosticConfig) { + // [START notebooks_v1_generated_ManagedNotebookService_DiagnoseRuntime_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtimes_id}` + */ + // const name = 'abc123' + /** + * Required. Defines flags that are used to run the diagnostic tool + */ + // const diagnosticConfig = {} + + // Imports the Notebooks library + const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new ManagedNotebookServiceClient(); + + async function callDiagnoseRuntime() { + // Construct request + const request = { + name, + diagnosticConfig, + }; + + // Run request + const [operation] = await notebooksClient.diagnoseRuntime(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDiagnoseRuntime(); + // [END notebooks_v1_generated_ManagedNotebookService_DiagnoseRuntime_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.get_runtime.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.get_runtime.js new file mode 100644 index 00000000000..221b3758754 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.get_runtime.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 notebooks_v1_generated_ManagedNotebookService_GetRuntime_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new ManagedNotebookServiceClient(); + + async function callGetRuntime() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await notebooksClient.getRuntime(request); + console.log(response); + } + + callGetRuntime(); + // [END notebooks_v1_generated_ManagedNotebookService_GetRuntime_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.list_runtimes.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.list_runtimes.js new file mode 100644 index 00000000000..fc7fd13a218 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.list_runtimes.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(parent) { + // [START notebooks_v1_generated_ManagedNotebookService_ListRuntimes_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + */ + // const parent = 'abc123' + /** + * Maximum return size of the list call. + */ + // const pageSize = 1234 + /** + * A previous returned page token that can be used to continue listing + * from the last result. + */ + // const pageToken = 'abc123' + + // Imports the Notebooks library + const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new ManagedNotebookServiceClient(); + + async function callListRuntimes() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await notebooksClient.listRuntimesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListRuntimes(); + // [END notebooks_v1_generated_ManagedNotebookService_ListRuntimes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.refresh_runtime_token_internal.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.refresh_runtime_token_internal.js new file mode 100644 index 00000000000..7f5cc0143ab --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.refresh_runtime_token_internal.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, vmId) { + // [START notebooks_v1_generated_ManagedNotebookService_RefreshRuntimeTokenInternal_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + */ + // const name = 'abc123' + /** + * Required. The VM hardware token for authenticating the VM. + * https://cloud.google.com/compute/docs/instances/verifying-instance-identity + */ + // const vmId = 'abc123' + + // Imports the Notebooks library + const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new ManagedNotebookServiceClient(); + + async function callRefreshRuntimeTokenInternal() { + // Construct request + const request = { + name, + vmId, + }; + + // Run request + const response = await notebooksClient.refreshRuntimeTokenInternal(request); + console.log(response); + } + + callRefreshRuntimeTokenInternal(); + // [END notebooks_v1_generated_ManagedNotebookService_RefreshRuntimeTokenInternal_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.report_runtime_event.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.report_runtime_event.js new file mode 100644 index 00000000000..cc3bd959a5f --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.report_runtime_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(name, vmId, event) { + // [START notebooks_v1_generated_ManagedNotebookService_ReportRuntimeEvent_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + */ + // const name = 'abc123' + /** + * Required. The VM hardware token for authenticating the VM. + * https://cloud.google.com/compute/docs/instances/verifying-instance-identity + */ + // const vmId = 'abc123' + /** + * Required. The Event to be reported. + */ + // const event = {} + + // Imports the Notebooks library + const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new ManagedNotebookServiceClient(); + + async function callReportRuntimeEvent() { + // Construct request + const request = { + name, + vmId, + event, + }; + + // Run request + const [operation] = await notebooksClient.reportRuntimeEvent(request); + const [response] = await operation.promise(); + console.log(response); + } + + callReportRuntimeEvent(); + // [END notebooks_v1_generated_ManagedNotebookService_ReportRuntimeEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.reset_runtime.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.reset_runtime.js new file mode 100644 index 00000000000..67ea0e65e35 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.reset_runtime.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(name) { + // [START notebooks_v1_generated_ManagedNotebookService_ResetRuntime_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + */ + // const name = 'abc123' + /** + * Idempotent request UUID. + */ + // const requestId = 'abc123' + + // Imports the Notebooks library + const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new ManagedNotebookServiceClient(); + + async function callResetRuntime() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.resetRuntime(request); + const [response] = await operation.promise(); + console.log(response); + } + + callResetRuntime(); + // [END notebooks_v1_generated_ManagedNotebookService_ResetRuntime_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.start_runtime.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.start_runtime.js new file mode 100644 index 00000000000..3745d55e645 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.start_runtime.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(name) { + // [START notebooks_v1_generated_ManagedNotebookService_StartRuntime_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + */ + // const name = 'abc123' + /** + * Idempotent request UUID. + */ + // const requestId = 'abc123' + + // Imports the Notebooks library + const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new ManagedNotebookServiceClient(); + + async function callStartRuntime() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.startRuntime(request); + const [response] = await operation.promise(); + console.log(response); + } + + callStartRuntime(); + // [END notebooks_v1_generated_ManagedNotebookService_StartRuntime_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.stop_runtime.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.stop_runtime.js new file mode 100644 index 00000000000..728bdd30463 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.stop_runtime.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(name) { + // [START notebooks_v1_generated_ManagedNotebookService_StopRuntime_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + */ + // const name = 'abc123' + /** + * Idempotent request UUID. + */ + // const requestId = 'abc123' + + // Imports the Notebooks library + const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new ManagedNotebookServiceClient(); + + async function callStopRuntime() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.stopRuntime(request); + const [response] = await operation.promise(); + console.log(response); + } + + callStopRuntime(); + // [END notebooks_v1_generated_ManagedNotebookService_StopRuntime_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.switch_runtime.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.switch_runtime.js new file mode 100644 index 00000000000..e50f396f885 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.switch_runtime.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(name) { + // [START notebooks_v1_generated_ManagedNotebookService_SwitchRuntime_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + */ + // const name = 'abc123' + /** + * machine type. + */ + // const machineType = 'abc123' + /** + * accelerator config. + */ + // const acceleratorConfig = {} + /** + * Idempotent request UUID. + */ + // const requestId = 'abc123' + + // Imports the Notebooks library + const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new ManagedNotebookServiceClient(); + + async function callSwitchRuntime() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.switchRuntime(request); + const [response] = await operation.promise(); + console.log(response); + } + + callSwitchRuntime(); + // [END notebooks_v1_generated_ManagedNotebookService_SwitchRuntime_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.update_runtime.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.update_runtime.js new file mode 100644 index 00000000000..1d5e411c15a --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.update_runtime.js @@ -0,0 +1,90 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(runtime, updateMask) { + // [START notebooks_v1_generated_ManagedNotebookService_UpdateRuntime_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Runtime to be updated. + */ + // const runtime = {} + /** + * Required. Specifies the path, relative to `Runtime`, of + * the field to update. For example, to change the software configuration + * kernels, the `update_mask` parameter would be + * specified as `software_config.kernels`, + * and the `PATCH` request body would specify the new value, as follows: + * { + * "software_config":{ + * "kernels": { + * 'repository': + * 'gcr.io/deeplearning-platform-release/pytorch-gpu', 'tag': + * 'latest' }, + * } + * } + * Currently, only the following fields can be updated: + * - `software_config.kernels` + * - `software_config.post_startup_script` + * - `software_config.custom_gpu_driver_path` + * - `software_config.idle_shutdown` + * - `software_config.idle_shutdown_timeout` + * - `software_config.disable_terminal` + */ + // const updateMask = {} + /** + * Idempotent request UUID. + */ + // const requestId = 'abc123' + + // Imports the Notebooks library + const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new ManagedNotebookServiceClient(); + + async function callUpdateRuntime() { + // Construct request + const request = { + runtime, + updateMask, + }; + + // Run request + const [operation] = await notebooksClient.updateRuntime(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateRuntime(); + // [END notebooks_v1_generated_ManagedNotebookService_UpdateRuntime_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.upgrade_runtime.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.upgrade_runtime.js new file mode 100644 index 00000000000..80093bc62cf --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.upgrade_runtime.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(name) { + // [START notebooks_v1_generated_ManagedNotebookService_UpgradeRuntime_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + */ + // const name = 'abc123' + /** + * Idempotent request UUID. + */ + // const requestId = 'abc123' + + // Imports the Notebooks library + const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new ManagedNotebookServiceClient(); + + async function callUpgradeRuntime() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.upgradeRuntime(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpgradeRuntime(); + // [END notebooks_v1_generated_ManagedNotebookService_UpgradeRuntime_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_environment.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_environment.js new file mode 100644 index 00000000000..5508ef29a8d --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_environment.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, environmentId, environment) { + // [START notebooks_v1_generated_NotebookService_CreateEnvironment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: `projects/{project_id}/locations/{location}` + */ + // const parent = 'abc123' + /** + * Required. User-defined unique ID of this environment. The `environment_id` must + * be 1 to 63 characters long and contain only lowercase letters, + * numeric characters, and dashes. The first character must be a lowercase + * letter and the last character cannot be a dash. + */ + // const environmentId = 'abc123' + /** + * Required. The environment to be created. + */ + // const environment = {} + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callCreateEnvironment() { + // Construct request + const request = { + parent, + environmentId, + environment, + }; + + // Run request + const [operation] = await notebooksClient.createEnvironment(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateEnvironment(); + // [END notebooks_v1_generated_NotebookService_CreateEnvironment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_execution.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_execution.js new file mode 100644 index 00000000000..6434cc9bd94 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_execution.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(parent, executionId, execution) { + // [START notebooks_v1_generated_NotebookService_CreateExecution_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + */ + // const parent = 'abc123' + /** + * Required. User-defined unique ID of this execution. + */ + // const executionId = 'abc123' + /** + * Required. The execution to be created. + */ + // const execution = {} + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callCreateExecution() { + // Construct request + const request = { + parent, + executionId, + execution, + }; + + // Run request + const [operation] = await notebooksClient.createExecution(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateExecution(); + // [END notebooks_v1_generated_NotebookService_CreateExecution_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_instance.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_instance.js new file mode 100644 index 00000000000..c59353d7f12 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_instance.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(parent, instanceId, instance) { + // [START notebooks_v1_generated_NotebookService_CreateInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + */ + // const parent = 'abc123' + /** + * Required. User-defined unique ID of this instance. + */ + // const instanceId = 'abc123' + /** + * Required. The instance to be created. + */ + // const instance = {} + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callCreateInstance() { + // Construct request + const request = { + parent, + instanceId, + instance, + }; + + // Run request + const [operation] = await notebooksClient.createInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateInstance(); + // [END notebooks_v1_generated_NotebookService_CreateInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_schedule.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_schedule.js new file mode 100644 index 00000000000..8e52043dd40 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_schedule.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(parent, scheduleId, schedule) { + // [START notebooks_v1_generated_NotebookService_CreateSchedule_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + */ + // const parent = 'abc123' + /** + * Required. User-defined unique ID of this schedule. + */ + // const scheduleId = 'abc123' + /** + * Required. The schedule to be created. + */ + // const schedule = {} + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callCreateSchedule() { + // Construct request + const request = { + parent, + scheduleId, + schedule, + }; + + // Run request + const [operation] = await notebooksClient.createSchedule(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateSchedule(); + // [END notebooks_v1_generated_NotebookService_CreateSchedule_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_environment.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_environment.js new file mode 100644 index 00000000000..899d01a5db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_environment.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 notebooks_v1_generated_NotebookService_DeleteEnvironment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/environments/{environment_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callDeleteEnvironment() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.deleteEnvironment(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteEnvironment(); + // [END notebooks_v1_generated_NotebookService_DeleteEnvironment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_execution.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_execution.js new file mode 100644 index 00000000000..57c8e49f520 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_execution.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 notebooks_v1_generated_NotebookService_DeleteExecution_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/executions/{execution_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callDeleteExecution() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.deleteExecution(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteExecution(); + // [END notebooks_v1_generated_NotebookService_DeleteExecution_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_instance.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_instance.js new file mode 100644 index 00000000000..7a828f3606f --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_instance.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 notebooks_v1_generated_NotebookService_DeleteInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callDeleteInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.deleteInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteInstance(); + // [END notebooks_v1_generated_NotebookService_DeleteInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_schedule.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_schedule.js new file mode 100644 index 00000000000..fcf20012a5d --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_schedule.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 notebooks_v1_generated_NotebookService_DeleteSchedule_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/schedules/{schedule_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callDeleteSchedule() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.deleteSchedule(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteSchedule(); + // [END notebooks_v1_generated_NotebookService_DeleteSchedule_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.diagnose_instance.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.diagnose_instance.js new file mode 100644 index 00000000000..67bfcb44975 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.diagnose_instance.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, diagnosticConfig) { + // [START notebooks_v1_generated_NotebookService_DiagnoseInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + /** + * Required. Defines flags that are used to run the diagnostic tool + */ + // const diagnosticConfig = {} + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callDiagnoseInstance() { + // Construct request + const request = { + name, + diagnosticConfig, + }; + + // Run request + const [operation] = await notebooksClient.diagnoseInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDiagnoseInstance(); + // [END notebooks_v1_generated_NotebookService_DiagnoseInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_environment.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_environment.js new file mode 100644 index 00000000000..a7ef2fedfb1 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_environment.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 notebooks_v1_generated_NotebookService_GetEnvironment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/environments/{environment_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callGetEnvironment() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await notebooksClient.getEnvironment(request); + console.log(response); + } + + callGetEnvironment(); + // [END notebooks_v1_generated_NotebookService_GetEnvironment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_execution.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_execution.js new file mode 100644 index 00000000000..5e38f97f0eb --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_execution.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 notebooks_v1_generated_NotebookService_GetExecution_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/executions/{execution_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callGetExecution() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await notebooksClient.getExecution(request); + console.log(response); + } + + callGetExecution(); + // [END notebooks_v1_generated_NotebookService_GetExecution_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_instance.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_instance.js new file mode 100644 index 00000000000..02effd56308 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_instance.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 notebooks_v1_generated_NotebookService_GetInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callGetInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await notebooksClient.getInstance(request); + console.log(response); + } + + callGetInstance(); + // [END notebooks_v1_generated_NotebookService_GetInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_instance_health.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_instance_health.js new file mode 100644 index 00000000000..e367e94aba7 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_instance_health.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 notebooks_v1_generated_NotebookService_GetInstanceHealth_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callGetInstanceHealth() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await notebooksClient.getInstanceHealth(request); + console.log(response); + } + + callGetInstanceHealth(); + // [END notebooks_v1_generated_NotebookService_GetInstanceHealth_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_schedule.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_schedule.js new file mode 100644 index 00000000000..543e60e0a18 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_schedule.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 notebooks_v1_generated_NotebookService_GetSchedule_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/schedules/{schedule_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callGetSchedule() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await notebooksClient.getSchedule(request); + console.log(response); + } + + callGetSchedule(); + // [END notebooks_v1_generated_NotebookService_GetSchedule_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.is_instance_upgradeable.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.is_instance_upgradeable.js new file mode 100644 index 00000000000..d30fa51d3fd --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.is_instance_upgradeable.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(notebookInstance) { + // [START notebooks_v1_generated_NotebookService_IsInstanceUpgradeable_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const notebookInstance = 'abc123' + /** + * Optional. The optional UpgradeType. Setting this field will search for additional + * compute images to upgrade this instance. + */ + // const type = {} + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callIsInstanceUpgradeable() { + // Construct request + const request = { + notebookInstance, + }; + + // Run request + const response = await notebooksClient.isInstanceUpgradeable(request); + console.log(response); + } + + callIsInstanceUpgradeable(); + // [END notebooks_v1_generated_NotebookService_IsInstanceUpgradeable_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_environments.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_environments.js new file mode 100644 index 00000000000..2d5dab68f11 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_environments.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) { + // [START notebooks_v1_generated_NotebookService_ListEnvironments_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: `projects/{project_id}/locations/{location}` + */ + // const parent = 'abc123' + /** + * Maximum return size of the list call. + */ + // const pageSize = 1234 + /** + * A previous returned page token that can be used to continue listing from + * the last result. + */ + // const pageToken = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callListEnvironments() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await notebooksClient.listEnvironmentsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListEnvironments(); + // [END notebooks_v1_generated_NotebookService_ListEnvironments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_executions.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_executions.js new file mode 100644 index 00000000000..31ccc62092b --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_executions.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) { + // [START notebooks_v1_generated_NotebookService_ListExecutions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + */ + // const parent = 'abc123' + /** + * Maximum return size of the list call. + */ + // const pageSize = 1234 + /** + * A previous returned page token that can be used to continue listing + * from the last result. + */ + // const pageToken = 'abc123' + /** + * Filter applied to resulting executions. Currently only supports filtering + * executions by a specified `schedule_id`. + * Format: `schedule_id=` + */ + // const filter = 'abc123' + /** + * Sort by field. + */ + // const orderBy = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callListExecutions() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await notebooksClient.listExecutionsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListExecutions(); + // [END notebooks_v1_generated_NotebookService_ListExecutions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_instances.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_instances.js new file mode 100644 index 00000000000..95716959568 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_instances.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(parent) { + // [START notebooks_v1_generated_NotebookService_ListInstances_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + */ + // const parent = 'abc123' + /** + * Maximum return size of the list call. + */ + // const pageSize = 1234 + /** + * A previous returned page token that can be used to continue listing + * from the last result. + */ + // const pageToken = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callListInstances() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await notebooksClient.listInstancesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListInstances(); + // [END notebooks_v1_generated_NotebookService_ListInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_schedules.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_schedules.js new file mode 100644 index 00000000000..663cefb6b9b --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_schedules.js @@ -0,0 +1,81 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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 notebooks_v1_generated_NotebookService_ListSchedules_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + */ + // const parent = 'abc123' + /** + * Maximum return size of the list call. + */ + // const pageSize = 1234 + /** + * A previous returned page token that can be used to continue listing + * from the last result. + */ + // const pageToken = 'abc123' + /** + * Filter applied to resulting schedules. + */ + // const filter = 'abc123' + /** + * Field to order results by. + */ + // const orderBy = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callListSchedules() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await notebooksClient.listSchedulesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListSchedules(); + // [END notebooks_v1_generated_NotebookService_ListSchedules_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.register_instance.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.register_instance.js new file mode 100644 index 00000000000..a85bf3f93ab --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.register_instance.js @@ -0,0 +1,71 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, instanceId) { + // [START notebooks_v1_generated_NotebookService_RegisterInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + */ + // const parent = 'abc123' + /** + * Required. User defined unique ID of this instance. The `instance_id` must + * be 1 to 63 characters long and contain only lowercase letters, + * numeric characters, and dashes. The first character must be a lowercase + * letter and the last character cannot be a dash. + */ + // const instanceId = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callRegisterInstance() { + // Construct request + const request = { + parent, + instanceId, + }; + + // Run request + const [operation] = await notebooksClient.registerInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRegisterInstance(); + // [END notebooks_v1_generated_NotebookService_RegisterInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.report_instance_info.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.report_instance_info.js new file mode 100644 index 00000000000..bde15816407 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.report_instance_info.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(name, vmId) { + // [START notebooks_v1_generated_NotebookService_ReportInstanceInfo_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + /** + * Required. The VM hardware token for authenticating the VM. + * https://cloud.google.com/compute/docs/instances/verifying-instance-identity + */ + // const vmId = 'abc123' + /** + * The metadata reported to Notebooks API. This will be merged to the instance + * metadata store + */ + // const metadata = [1,2,3,4] + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callReportInstanceInfo() { + // Construct request + const request = { + name, + vmId, + }; + + // Run request + const [operation] = await notebooksClient.reportInstanceInfo(request); + const [response] = await operation.promise(); + console.log(response); + } + + callReportInstanceInfo(); + // [END notebooks_v1_generated_NotebookService_ReportInstanceInfo_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.reset_instance.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.reset_instance.js new file mode 100644 index 00000000000..bcc1ef34d20 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.reset_instance.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 notebooks_v1_generated_NotebookService_ResetInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callResetInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.resetInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callResetInstance(); + // [END notebooks_v1_generated_NotebookService_ResetInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.rollback_instance.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.rollback_instance.js new file mode 100644 index 00000000000..963801eead1 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.rollback_instance.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(name, targetSnapshot) { + // [START notebooks_v1_generated_NotebookService_RollbackInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + /** + * Required. The snapshot for rollback. + * Example: `projects/test-project/global/snapshots/krwlzipynril`. + */ + // const targetSnapshot = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callRollbackInstance() { + // Construct request + const request = { + name, + targetSnapshot, + }; + + // Run request + const [operation] = await notebooksClient.rollbackInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRollbackInstance(); + // [END notebooks_v1_generated_NotebookService_RollbackInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_accelerator.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_accelerator.js new file mode 100644 index 00000000000..d0e42f8ebb3 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_accelerator.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(name, type, coreCount) { + // [START notebooks_v1_generated_NotebookService_SetInstanceAccelerator_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + /** + * Required. Type of this accelerator. + */ + // const type = {} + /** + * Required. Count of cores of this accelerator. Note that not all combinations + * of `type` and `core_count` are valid. Check GPUs on + * Compute Engine (https://cloud.google.com/compute/docs/gpus/#gpus-list) to + * find a valid combination. TPUs are not supported. + */ + // const coreCount = 1234 + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callSetInstanceAccelerator() { + // Construct request + const request = { + name, + type, + coreCount, + }; + + // Run request + const [operation] = await notebooksClient.setInstanceAccelerator(request); + const [response] = await operation.promise(); + console.log(response); + } + + callSetInstanceAccelerator(); + // [END notebooks_v1_generated_NotebookService_SetInstanceAccelerator_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_labels.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_labels.js new file mode 100644 index 00000000000..e3c35129fab --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_labels.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 notebooks_v1_generated_NotebookService_SetInstanceLabels_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + /** + * Labels to apply to this instance. + * These can be later modified by the setLabels method + */ + // const labels = [1,2,3,4] + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callSetInstanceLabels() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.setInstanceLabels(request); + const [response] = await operation.promise(); + console.log(response); + } + + callSetInstanceLabels(); + // [END notebooks_v1_generated_NotebookService_SetInstanceLabels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_machine_type.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_machine_type.js new file mode 100644 index 00000000000..d2d37138214 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_machine_type.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(name, machineType) { + // [START notebooks_v1_generated_NotebookService_SetInstanceMachineType_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + /** + * Required. The Compute Engine machine + * type (https://cloud.google.com/compute/docs/machine-types). + */ + // const machineType = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callSetInstanceMachineType() { + // Construct request + const request = { + name, + machineType, + }; + + // Run request + const [operation] = await notebooksClient.setInstanceMachineType(request); + const [response] = await operation.promise(); + console.log(response); + } + + callSetInstanceMachineType(); + // [END notebooks_v1_generated_NotebookService_SetInstanceMachineType_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.start_instance.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.start_instance.js new file mode 100644 index 00000000000..627d0ad2a3f --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.start_instance.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 notebooks_v1_generated_NotebookService_StartInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callStartInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.startInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callStartInstance(); + // [END notebooks_v1_generated_NotebookService_StartInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.stop_instance.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.stop_instance.js new file mode 100644 index 00000000000..d8ed2784043 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.stop_instance.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 notebooks_v1_generated_NotebookService_StopInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callStopInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.stopInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callStopInstance(); + // [END notebooks_v1_generated_NotebookService_StopInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.trigger_schedule.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.trigger_schedule.js new file mode 100644 index 00000000000..35135e288b0 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.trigger_schedule.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 notebooks_v1_generated_NotebookService_TriggerSchedule_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `parent=projects/{project_id}/locations/{location}/schedules/{schedule_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callTriggerSchedule() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.triggerSchedule(request); + const [response] = await operation.promise(); + console.log(response); + } + + callTriggerSchedule(); + // [END notebooks_v1_generated_NotebookService_TriggerSchedule_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_instance_config.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_instance_config.js new file mode 100644 index 00000000000..e326271d4c1 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_instance_config.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(name) { + // [START notebooks_v1_generated_NotebookService_UpdateInstanceConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + /** + * The instance configurations to be updated. + */ + // const config = {} + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callUpdateInstanceConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.updateInstanceConfig(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateInstanceConfig(); + // [END notebooks_v1_generated_NotebookService_UpdateInstanceConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_instance_metadata_items.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_instance_metadata_items.js new file mode 100644 index 00000000000..316c356ff8f --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_instance_metadata_items.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(name) { + // [START notebooks_v1_generated_NotebookService_UpdateInstanceMetadataItems_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + /** + * Metadata items to add/update for the instance. + */ + // const items = [1,2,3,4] + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callUpdateInstanceMetadataItems() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await notebooksClient.updateInstanceMetadataItems(request); + console.log(response); + } + + callUpdateInstanceMetadataItems(); + // [END notebooks_v1_generated_NotebookService_UpdateInstanceMetadataItems_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_shielded_instance_config.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_shielded_instance_config.js new file mode 100644 index 00000000000..79a4789d1f2 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_shielded_instance_config.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(name) { + // [START notebooks_v1_generated_NotebookService_UpdateShieldedInstanceConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + /** + * ShieldedInstance configuration to be updated. + */ + // const shieldedInstanceConfig = {} + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callUpdateShieldedInstanceConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.updateShieldedInstanceConfig(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateShieldedInstanceConfig(); + // [END notebooks_v1_generated_NotebookService_UpdateShieldedInstanceConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.upgrade_instance.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.upgrade_instance.js new file mode 100644 index 00000000000..3dc2fe02e4f --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.upgrade_instance.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 notebooks_v1_generated_NotebookService_UpgradeInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + /** + * Optional. The optional UpgradeType. Setting this field will search for additional + * compute images to upgrade this instance. + */ + // const type = {} + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callUpgradeInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.upgradeInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpgradeInstance(); + // [END notebooks_v1_generated_NotebookService_UpgradeInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.upgrade_instance_internal.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.upgrade_instance_internal.js new file mode 100644 index 00000000000..c9b99adefa3 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.upgrade_instance_internal.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(name, vmId) { + // [START notebooks_v1_generated_NotebookService_UpgradeInstanceInternal_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + /** + * Required. The VM hardware token for authenticating the VM. + * https://cloud.google.com/compute/docs/instances/verifying-instance-identity + */ + // const vmId = 'abc123' + /** + * Optional. The optional UpgradeType. Setting this field will search for additional + * compute images to upgrade this instance. + */ + // const type = {} + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callUpgradeInstanceInternal() { + // Construct request + const request = { + name, + vmId, + }; + + // Run request + const [operation] = await notebooksClient.upgradeInstanceInternal(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpgradeInstanceInternal(); + // [END notebooks_v1_generated_NotebookService_UpgradeInstanceInternal_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/snippet_metadata_google.cloud.notebooks.v1.json b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/snippet_metadata_google.cloud.notebooks.v1.json new file mode 100644 index 00000000000..48fb0a043d9 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/snippet_metadata_google.cloud.notebooks.v1.json @@ -0,0 +1,2115 @@ +{ + "clientLibrary": { + "name": "nodejs-notebooks", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.notebooks.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "notebooks_v1_generated_ManagedNotebookService_ListRuntimes_async", + "title": "ManagedNotebookService listRuntimes Sample", + "origin": "API_DEFINITION", + "description": " Lists Runtimes in a given project and location.", + "canonical": true, + "file": "managed_notebook_service.list_runtimes.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListRuntimes", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.ListRuntimes", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.notebooks.v1.ListRuntimesResponse", + "client": { + "shortName": "ManagedNotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" + }, + "method": { + "shortName": "ListRuntimes", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.ListRuntimes", + "service": { + "shortName": "ManagedNotebookService", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_ManagedNotebookService_GetRuntime_async", + "title": "ManagedNotebookService getRuntime Sample", + "origin": "API_DEFINITION", + "description": " Gets details of a single Runtime. The location must be a regional endpoint rather than zonal.", + "canonical": true, + "file": "managed_notebook_service.get_runtime.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetRuntime", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.GetRuntime", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.notebooks.v1.Runtime", + "client": { + "shortName": "ManagedNotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" + }, + "method": { + "shortName": "GetRuntime", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.GetRuntime", + "service": { + "shortName": "ManagedNotebookService", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_ManagedNotebookService_CreateRuntime_async", + "title": "ManagedNotebookService createRuntime Sample", + "origin": "API_DEFINITION", + "description": " Creates a new Runtime in a given project and location.", + "canonical": true, + "file": "managed_notebook_service.create_runtime.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateRuntime", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.CreateRuntime", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "runtime_id", + "type": "TYPE_STRING" + }, + { + "name": "runtime", + "type": ".google.cloud.notebooks.v1.Runtime" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ManagedNotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" + }, + "method": { + "shortName": "CreateRuntime", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.CreateRuntime", + "service": { + "shortName": "ManagedNotebookService", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_ManagedNotebookService_UpdateRuntime_async", + "title": "ManagedNotebookService updateRuntime Sample", + "origin": "API_DEFINITION", + "description": " Update Notebook Runtime configuration.", + "canonical": true, + "file": "managed_notebook_service.update_runtime.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 82, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateRuntime", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.UpdateRuntime", + "async": true, + "parameters": [ + { + "name": "runtime", + "type": ".google.cloud.notebooks.v1.Runtime" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ManagedNotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" + }, + "method": { + "shortName": "UpdateRuntime", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.UpdateRuntime", + "service": { + "shortName": "ManagedNotebookService", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_ManagedNotebookService_DeleteRuntime_async", + "title": "ManagedNotebookService deleteRuntime Sample", + "origin": "API_DEFINITION", + "description": " Deletes a single Runtime.", + "canonical": true, + "file": "managed_notebook_service.delete_runtime.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteRuntime", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.DeleteRuntime", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ManagedNotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" + }, + "method": { + "shortName": "DeleteRuntime", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.DeleteRuntime", + "service": { + "shortName": "ManagedNotebookService", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_ManagedNotebookService_StartRuntime_async", + "title": "ManagedNotebookService startRuntime Sample", + "origin": "API_DEFINITION", + "description": " Starts a Managed Notebook Runtime. Perform \"Start\" on GPU instances; \"Resume\" on CPU instances See: https://cloud.google.com/compute/docs/instances/stop-start-instance https://cloud.google.com/compute/docs/instances/suspend-resume-instance", + "canonical": true, + "file": "managed_notebook_service.start_runtime.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StartRuntime", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.StartRuntime", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ManagedNotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" + }, + "method": { + "shortName": "StartRuntime", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.StartRuntime", + "service": { + "shortName": "ManagedNotebookService", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_ManagedNotebookService_StopRuntime_async", + "title": "ManagedNotebookService stopRuntime Sample", + "origin": "API_DEFINITION", + "description": " Stops a Managed Notebook Runtime. Perform \"Stop\" on GPU instances; \"Suspend\" on CPU instances See: https://cloud.google.com/compute/docs/instances/stop-start-instance https://cloud.google.com/compute/docs/instances/suspend-resume-instance", + "canonical": true, + "file": "managed_notebook_service.stop_runtime.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StopRuntime", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.StopRuntime", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ManagedNotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" + }, + "method": { + "shortName": "StopRuntime", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.StopRuntime", + "service": { + "shortName": "ManagedNotebookService", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_ManagedNotebookService_SwitchRuntime_async", + "title": "ManagedNotebookService switchRuntime Sample", + "origin": "API_DEFINITION", + "description": " Switch a Managed Notebook Runtime.", + "canonical": true, + "file": "managed_notebook_service.switch_runtime.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SwitchRuntime", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.SwitchRuntime", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "machine_type", + "type": "TYPE_STRING" + }, + { + "name": "accelerator_config", + "type": ".google.cloud.notebooks.v1.RuntimeAcceleratorConfig" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ManagedNotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" + }, + "method": { + "shortName": "SwitchRuntime", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.SwitchRuntime", + "service": { + "shortName": "ManagedNotebookService", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_ManagedNotebookService_ResetRuntime_async", + "title": "ManagedNotebookService resetRuntime Sample", + "origin": "API_DEFINITION", + "description": " Resets a Managed Notebook Runtime.", + "canonical": true, + "file": "managed_notebook_service.reset_runtime.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ResetRuntime", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.ResetRuntime", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ManagedNotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" + }, + "method": { + "shortName": "ResetRuntime", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.ResetRuntime", + "service": { + "shortName": "ManagedNotebookService", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_ManagedNotebookService_UpgradeRuntime_async", + "title": "ManagedNotebookService upgradeRuntime Sample", + "origin": "API_DEFINITION", + "description": " Upgrades a Managed Notebook Runtime to the latest version.", + "canonical": true, + "file": "managed_notebook_service.upgrade_runtime.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpgradeRuntime", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.UpgradeRuntime", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ManagedNotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" + }, + "method": { + "shortName": "UpgradeRuntime", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.UpgradeRuntime", + "service": { + "shortName": "ManagedNotebookService", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_ManagedNotebookService_ReportRuntimeEvent_async", + "title": "ManagedNotebookService reportRuntimeEvent Sample", + "origin": "API_DEFINITION", + "description": " Report and process a runtime event.", + "canonical": true, + "file": "managed_notebook_service.report_runtime_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ReportRuntimeEvent", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.ReportRuntimeEvent", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "vm_id", + "type": "TYPE_STRING" + }, + { + "name": "event", + "type": ".google.cloud.notebooks.v1.Event" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ManagedNotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" + }, + "method": { + "shortName": "ReportRuntimeEvent", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.ReportRuntimeEvent", + "service": { + "shortName": "ManagedNotebookService", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_ManagedNotebookService_RefreshRuntimeTokenInternal_async", + "title": "ManagedNotebookService refreshRuntimeTokenInternal Sample", + "origin": "API_DEFINITION", + "description": " Gets an access token for the consumer service account that the customer attached to the runtime. Only accessible from the tenant instance.", + "canonical": true, + "file": "managed_notebook_service.refresh_runtime_token_internal.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RefreshRuntimeTokenInternal", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.RefreshRuntimeTokenInternal", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "vm_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.notebooks.v1.RefreshRuntimeTokenInternalResponse", + "client": { + "shortName": "ManagedNotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" + }, + "method": { + "shortName": "RefreshRuntimeTokenInternal", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.RefreshRuntimeTokenInternal", + "service": { + "shortName": "ManagedNotebookService", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_ManagedNotebookService_DiagnoseRuntime_async", + "title": "ManagedNotebookService diagnoseRuntime Sample", + "origin": "API_DEFINITION", + "description": " Creates a Diagnostic File and runs Diagnostic Tool given a Runtime.", + "canonical": true, + "file": "managed_notebook_service.diagnose_runtime.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DiagnoseRuntime", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.DiagnoseRuntime", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "diagnostic_config", + "type": ".google.cloud.notebooks.v1.DiagnosticConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ManagedNotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" + }, + "method": { + "shortName": "DiagnoseRuntime", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.DiagnoseRuntime", + "service": { + "shortName": "ManagedNotebookService", + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_ListInstances_async", + "title": "ManagedNotebookService listInstances Sample", + "origin": "API_DEFINITION", + "description": " Lists instances in a given project and location.", + "canonical": true, + "file": "notebook_service.list_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListInstances", + "fullName": "google.cloud.notebooks.v1.NotebookService.ListInstances", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.notebooks.v1.ListInstancesResponse", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "ListInstances", + "fullName": "google.cloud.notebooks.v1.NotebookService.ListInstances", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_GetInstance_async", + "title": "ManagedNotebookService getInstance Sample", + "origin": "API_DEFINITION", + "description": " Gets details of a single Instance.", + "canonical": true, + "file": "notebook_service.get_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetInstance", + "fullName": "google.cloud.notebooks.v1.NotebookService.GetInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.notebooks.v1.Instance", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "GetInstance", + "fullName": "google.cloud.notebooks.v1.NotebookService.GetInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_CreateInstance_async", + "title": "ManagedNotebookService createInstance Sample", + "origin": "API_DEFINITION", + "description": " Creates a new Instance in a given project and location.", + "canonical": true, + "file": "notebook_service.create_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateInstance", + "fullName": "google.cloud.notebooks.v1.NotebookService.CreateInstance", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "instance_id", + "type": "TYPE_STRING" + }, + { + "name": "instance", + "type": ".google.cloud.notebooks.v1.Instance" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "CreateInstance", + "fullName": "google.cloud.notebooks.v1.NotebookService.CreateInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_RegisterInstance_async", + "title": "ManagedNotebookService registerInstance Sample", + "origin": "API_DEFINITION", + "description": " Registers an existing legacy notebook instance to the Notebooks API server. Legacy instances are instances created with the legacy Compute Engine calls. They are not manageable by the Notebooks API out of the box. This call makes these instances manageable by the Notebooks API.", + "canonical": true, + "file": "notebook_service.register_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RegisterInstance", + "fullName": "google.cloud.notebooks.v1.NotebookService.RegisterInstance", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "instance_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "RegisterInstance", + "fullName": "google.cloud.notebooks.v1.NotebookService.RegisterInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_SetInstanceAccelerator_async", + "title": "ManagedNotebookService setInstanceAccelerator Sample", + "origin": "API_DEFINITION", + "description": " Updates the guest accelerators of a single Instance.", + "canonical": true, + "file": "notebook_service.set_instance_accelerator.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetInstanceAccelerator", + "fullName": "google.cloud.notebooks.v1.NotebookService.SetInstanceAccelerator", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": ".google.cloud.notebooks.v1.Instance.AcceleratorType" + }, + { + "name": "core_count", + "type": "TYPE_INT64" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "SetInstanceAccelerator", + "fullName": "google.cloud.notebooks.v1.NotebookService.SetInstanceAccelerator", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_SetInstanceMachineType_async", + "title": "ManagedNotebookService setInstanceMachineType Sample", + "origin": "API_DEFINITION", + "description": " Updates the machine type of a single Instance.", + "canonical": true, + "file": "notebook_service.set_instance_machine_type.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetInstanceMachineType", + "fullName": "google.cloud.notebooks.v1.NotebookService.SetInstanceMachineType", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "machine_type", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "SetInstanceMachineType", + "fullName": "google.cloud.notebooks.v1.NotebookService.SetInstanceMachineType", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_UpdateInstanceConfig_async", + "title": "ManagedNotebookService updateInstanceConfig Sample", + "origin": "API_DEFINITION", + "description": " Update Notebook Instance configurations.", + "canonical": true, + "file": "notebook_service.update_instance_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateInstanceConfig", + "fullName": "google.cloud.notebooks.v1.NotebookService.UpdateInstanceConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "config", + "type": ".google.cloud.notebooks.v1.InstanceConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "UpdateInstanceConfig", + "fullName": "google.cloud.notebooks.v1.NotebookService.UpdateInstanceConfig", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_UpdateShieldedInstanceConfig_async", + "title": "ManagedNotebookService updateShieldedInstanceConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates the Shielded instance configuration of a single Instance.", + "canonical": true, + "file": "notebook_service.update_shielded_instance_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateShieldedInstanceConfig", + "fullName": "google.cloud.notebooks.v1.NotebookService.UpdateShieldedInstanceConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "shielded_instance_config", + "type": ".google.cloud.notebooks.v1.Instance.ShieldedInstanceConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "UpdateShieldedInstanceConfig", + "fullName": "google.cloud.notebooks.v1.NotebookService.UpdateShieldedInstanceConfig", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_SetInstanceLabels_async", + "title": "ManagedNotebookService setInstanceLabels Sample", + "origin": "API_DEFINITION", + "description": " Replaces all the labels of an Instance.", + "canonical": true, + "file": "notebook_service.set_instance_labels.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetInstanceLabels", + "fullName": "google.cloud.notebooks.v1.NotebookService.SetInstanceLabels", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "SetInstanceLabels", + "fullName": "google.cloud.notebooks.v1.NotebookService.SetInstanceLabels", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_UpdateInstanceMetadataItems_async", + "title": "ManagedNotebookService updateInstanceMetadataItems Sample", + "origin": "API_DEFINITION", + "description": " Add/update metadata items for an instance.", + "canonical": true, + "file": "notebook_service.update_instance_metadata_items.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateInstanceMetadataItems", + "fullName": "google.cloud.notebooks.v1.NotebookService.UpdateInstanceMetadataItems", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "items", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.notebooks.v1.UpdateInstanceMetadataItemsResponse", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "UpdateInstanceMetadataItems", + "fullName": "google.cloud.notebooks.v1.NotebookService.UpdateInstanceMetadataItems", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_DeleteInstance_async", + "title": "ManagedNotebookService deleteInstance Sample", + "origin": "API_DEFINITION", + "description": " Deletes a single Instance.", + "canonical": true, + "file": "notebook_service.delete_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteInstance", + "fullName": "google.cloud.notebooks.v1.NotebookService.DeleteInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "DeleteInstance", + "fullName": "google.cloud.notebooks.v1.NotebookService.DeleteInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_StartInstance_async", + "title": "ManagedNotebookService startInstance Sample", + "origin": "API_DEFINITION", + "description": " Starts a notebook instance.", + "canonical": true, + "file": "notebook_service.start_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StartInstance", + "fullName": "google.cloud.notebooks.v1.NotebookService.StartInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "StartInstance", + "fullName": "google.cloud.notebooks.v1.NotebookService.StartInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_StopInstance_async", + "title": "ManagedNotebookService stopInstance Sample", + "origin": "API_DEFINITION", + "description": " Stops a notebook instance.", + "canonical": true, + "file": "notebook_service.stop_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StopInstance", + "fullName": "google.cloud.notebooks.v1.NotebookService.StopInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "StopInstance", + "fullName": "google.cloud.notebooks.v1.NotebookService.StopInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_ResetInstance_async", + "title": "ManagedNotebookService resetInstance Sample", + "origin": "API_DEFINITION", + "description": " Resets a notebook instance.", + "canonical": true, + "file": "notebook_service.reset_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ResetInstance", + "fullName": "google.cloud.notebooks.v1.NotebookService.ResetInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "ResetInstance", + "fullName": "google.cloud.notebooks.v1.NotebookService.ResetInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_ReportInstanceInfo_async", + "title": "ManagedNotebookService reportInstanceInfo Sample", + "origin": "API_DEFINITION", + "description": " Allows notebook instances to report their latest instance information to the Notebooks API server. The server will merge the reported information to the instance metadata store. Do not use this method directly.", + "canonical": true, + "file": "notebook_service.report_instance_info.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ReportInstanceInfo", + "fullName": "google.cloud.notebooks.v1.NotebookService.ReportInstanceInfo", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "vm_id", + "type": "TYPE_STRING" + }, + { + "name": "metadata", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "ReportInstanceInfo", + "fullName": "google.cloud.notebooks.v1.NotebookService.ReportInstanceInfo", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_IsInstanceUpgradeable_async", + "title": "ManagedNotebookService isInstanceUpgradeable Sample", + "origin": "API_DEFINITION", + "description": " Check if a notebook instance is upgradable.", + "canonical": true, + "file": "notebook_service.is_instance_upgradeable.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "IsInstanceUpgradeable", + "fullName": "google.cloud.notebooks.v1.NotebookService.IsInstanceUpgradeable", + "async": true, + "parameters": [ + { + "name": "notebook_instance", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": ".google.cloud.notebooks.v1.UpgradeType" + } + ], + "resultType": ".google.cloud.notebooks.v1.IsInstanceUpgradeableResponse", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "IsInstanceUpgradeable", + "fullName": "google.cloud.notebooks.v1.NotebookService.IsInstanceUpgradeable", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_GetInstanceHealth_async", + "title": "ManagedNotebookService getInstanceHealth Sample", + "origin": "API_DEFINITION", + "description": " Check if a notebook instance is healthy.", + "canonical": true, + "file": "notebook_service.get_instance_health.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetInstanceHealth", + "fullName": "google.cloud.notebooks.v1.NotebookService.GetInstanceHealth", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.notebooks.v1.GetInstanceHealthResponse", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "GetInstanceHealth", + "fullName": "google.cloud.notebooks.v1.NotebookService.GetInstanceHealth", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_UpgradeInstance_async", + "title": "ManagedNotebookService upgradeInstance Sample", + "origin": "API_DEFINITION", + "description": " Upgrades a notebook instance to the latest version.", + "canonical": true, + "file": "notebook_service.upgrade_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpgradeInstance", + "fullName": "google.cloud.notebooks.v1.NotebookService.UpgradeInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": ".google.cloud.notebooks.v1.UpgradeType" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "UpgradeInstance", + "fullName": "google.cloud.notebooks.v1.NotebookService.UpgradeInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_RollbackInstance_async", + "title": "ManagedNotebookService rollbackInstance Sample", + "origin": "API_DEFINITION", + "description": " Rollbacks a notebook instance to the previous version.", + "canonical": true, + "file": "notebook_service.rollback_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RollbackInstance", + "fullName": "google.cloud.notebooks.v1.NotebookService.RollbackInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "target_snapshot", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "RollbackInstance", + "fullName": "google.cloud.notebooks.v1.NotebookService.RollbackInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_DiagnoseInstance_async", + "title": "ManagedNotebookService diagnoseInstance Sample", + "origin": "API_DEFINITION", + "description": " Creates a Diagnostic File and runs Diagnostic Tool given an Instance.", + "canonical": true, + "file": "notebook_service.diagnose_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DiagnoseInstance", + "fullName": "google.cloud.notebooks.v1.NotebookService.DiagnoseInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "diagnostic_config", + "type": ".google.cloud.notebooks.v1.DiagnosticConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "DiagnoseInstance", + "fullName": "google.cloud.notebooks.v1.NotebookService.DiagnoseInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_UpgradeInstanceInternal_async", + "title": "ManagedNotebookService upgradeInstanceInternal Sample", + "origin": "API_DEFINITION", + "description": " Allows notebook instances to call this endpoint to upgrade themselves. Do not use this method directly.", + "canonical": true, + "file": "notebook_service.upgrade_instance_internal.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpgradeInstanceInternal", + "fullName": "google.cloud.notebooks.v1.NotebookService.UpgradeInstanceInternal", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "vm_id", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": ".google.cloud.notebooks.v1.UpgradeType" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "UpgradeInstanceInternal", + "fullName": "google.cloud.notebooks.v1.NotebookService.UpgradeInstanceInternal", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_ListEnvironments_async", + "title": "ManagedNotebookService listEnvironments Sample", + "origin": "API_DEFINITION", + "description": " Lists environments in a project.", + "canonical": true, + "file": "notebook_service.list_environments.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListEnvironments", + "fullName": "google.cloud.notebooks.v1.NotebookService.ListEnvironments", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.notebooks.v1.ListEnvironmentsResponse", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "ListEnvironments", + "fullName": "google.cloud.notebooks.v1.NotebookService.ListEnvironments", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_GetEnvironment_async", + "title": "ManagedNotebookService getEnvironment Sample", + "origin": "API_DEFINITION", + "description": " Gets details of a single Environment.", + "canonical": true, + "file": "notebook_service.get_environment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetEnvironment", + "fullName": "google.cloud.notebooks.v1.NotebookService.GetEnvironment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.notebooks.v1.Environment", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "GetEnvironment", + "fullName": "google.cloud.notebooks.v1.NotebookService.GetEnvironment", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_CreateEnvironment_async", + "title": "ManagedNotebookService createEnvironment Sample", + "origin": "API_DEFINITION", + "description": " Creates a new Environment.", + "canonical": true, + "file": "notebook_service.create_environment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateEnvironment", + "fullName": "google.cloud.notebooks.v1.NotebookService.CreateEnvironment", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "environment_id", + "type": "TYPE_STRING" + }, + { + "name": "environment", + "type": ".google.cloud.notebooks.v1.Environment" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "CreateEnvironment", + "fullName": "google.cloud.notebooks.v1.NotebookService.CreateEnvironment", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_DeleteEnvironment_async", + "title": "ManagedNotebookService deleteEnvironment Sample", + "origin": "API_DEFINITION", + "description": " Deletes a single Environment.", + "canonical": true, + "file": "notebook_service.delete_environment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteEnvironment", + "fullName": "google.cloud.notebooks.v1.NotebookService.DeleteEnvironment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "DeleteEnvironment", + "fullName": "google.cloud.notebooks.v1.NotebookService.DeleteEnvironment", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_ListSchedules_async", + "title": "ManagedNotebookService listSchedules Sample", + "origin": "API_DEFINITION", + "description": " Lists schedules in a given project and location.", + "canonical": true, + "file": "notebook_service.list_schedules.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 73, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListSchedules", + "fullName": "google.cloud.notebooks.v1.NotebookService.ListSchedules", + "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": "order_by", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.notebooks.v1.ListSchedulesResponse", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "ListSchedules", + "fullName": "google.cloud.notebooks.v1.NotebookService.ListSchedules", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_GetSchedule_async", + "title": "ManagedNotebookService getSchedule Sample", + "origin": "API_DEFINITION", + "description": " Gets details of schedule", + "canonical": true, + "file": "notebook_service.get_schedule.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetSchedule", + "fullName": "google.cloud.notebooks.v1.NotebookService.GetSchedule", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.notebooks.v1.Schedule", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "GetSchedule", + "fullName": "google.cloud.notebooks.v1.NotebookService.GetSchedule", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_DeleteSchedule_async", + "title": "ManagedNotebookService deleteSchedule Sample", + "origin": "API_DEFINITION", + "description": " Deletes schedule and all underlying jobs", + "canonical": true, + "file": "notebook_service.delete_schedule.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteSchedule", + "fullName": "google.cloud.notebooks.v1.NotebookService.DeleteSchedule", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "DeleteSchedule", + "fullName": "google.cloud.notebooks.v1.NotebookService.DeleteSchedule", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_CreateSchedule_async", + "title": "ManagedNotebookService createSchedule Sample", + "origin": "API_DEFINITION", + "description": " Creates a new Scheduled Notebook in a given project and location.", + "canonical": true, + "file": "notebook_service.create_schedule.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateSchedule", + "fullName": "google.cloud.notebooks.v1.NotebookService.CreateSchedule", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "schedule_id", + "type": "TYPE_STRING" + }, + { + "name": "schedule", + "type": ".google.cloud.notebooks.v1.Schedule" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "CreateSchedule", + "fullName": "google.cloud.notebooks.v1.NotebookService.CreateSchedule", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_TriggerSchedule_async", + "title": "ManagedNotebookService triggerSchedule Sample", + "origin": "API_DEFINITION", + "description": " Triggers execution of an existing schedule.", + "canonical": true, + "file": "notebook_service.trigger_schedule.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TriggerSchedule", + "fullName": "google.cloud.notebooks.v1.NotebookService.TriggerSchedule", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "TriggerSchedule", + "fullName": "google.cloud.notebooks.v1.NotebookService.TriggerSchedule", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_ListExecutions_async", + "title": "ManagedNotebookService listExecutions Sample", + "origin": "API_DEFINITION", + "description": " Lists executions in a given project and location", + "canonical": true, + "file": "notebook_service.list_executions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListExecutions", + "fullName": "google.cloud.notebooks.v1.NotebookService.ListExecutions", + "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": "order_by", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.notebooks.v1.ListExecutionsResponse", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "ListExecutions", + "fullName": "google.cloud.notebooks.v1.NotebookService.ListExecutions", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_GetExecution_async", + "title": "ManagedNotebookService getExecution Sample", + "origin": "API_DEFINITION", + "description": " Gets details of executions", + "canonical": true, + "file": "notebook_service.get_execution.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetExecution", + "fullName": "google.cloud.notebooks.v1.NotebookService.GetExecution", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.notebooks.v1.Execution", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "GetExecution", + "fullName": "google.cloud.notebooks.v1.NotebookService.GetExecution", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_DeleteExecution_async", + "title": "ManagedNotebookService deleteExecution Sample", + "origin": "API_DEFINITION", + "description": " Deletes execution", + "canonical": true, + "file": "notebook_service.delete_execution.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteExecution", + "fullName": "google.cloud.notebooks.v1.NotebookService.DeleteExecution", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "DeleteExecution", + "fullName": "google.cloud.notebooks.v1.NotebookService.DeleteExecution", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1_generated_NotebookService_CreateExecution_async", + "title": "ManagedNotebookService createExecution Sample", + "origin": "API_DEFINITION", + "description": " Creates a new Execution in a given project and location.", + "canonical": true, + "file": "notebook_service.create_execution.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateExecution", + "fullName": "google.cloud.notebooks.v1.NotebookService.CreateExecution", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "execution_id", + "type": "TYPE_STRING" + }, + { + "name": "execution", + "type": ".google.cloud.notebooks.v1.Execution" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" + }, + "method": { + "shortName": "CreateExecution", + "fullName": "google.cloud.notebooks.v1.NotebookService.CreateExecution", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1.NotebookService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/src/index.ts b/owl-bot-staging/google-cloud-notebooks/v1/src/index.ts new file mode 100644 index 00000000000..c7a2a16c438 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/src/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. ** + +import * as v1 from './v1'; +const ManagedNotebookServiceClient = v1.ManagedNotebookServiceClient; +type ManagedNotebookServiceClient = v1.ManagedNotebookServiceClient; +const NotebookServiceClient = v1.NotebookServiceClient; +type NotebookServiceClient = v1.NotebookServiceClient; +export {v1, ManagedNotebookServiceClient, NotebookServiceClient}; +export default {v1, ManagedNotebookServiceClient, NotebookServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..f6aa197ee97 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/gapic_metadata.json @@ -0,0 +1,527 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.notebooks.v1", + "libraryPackage": "@google-cloud/notebooks", + "services": { + "ManagedNotebookService": { + "clients": { + "grpc": { + "libraryClient": "ManagedNotebookServiceClient", + "rpcs": { + "GetRuntime": { + "methods": [ + "getRuntime" + ] + }, + "RefreshRuntimeTokenInternal": { + "methods": [ + "refreshRuntimeTokenInternal" + ] + }, + "CreateRuntime": { + "methods": [ + "createRuntime" + ] + }, + "UpdateRuntime": { + "methods": [ + "updateRuntime" + ] + }, + "DeleteRuntime": { + "methods": [ + "deleteRuntime" + ] + }, + "StartRuntime": { + "methods": [ + "startRuntime" + ] + }, + "StopRuntime": { + "methods": [ + "stopRuntime" + ] + }, + "SwitchRuntime": { + "methods": [ + "switchRuntime" + ] + }, + "ResetRuntime": { + "methods": [ + "resetRuntime" + ] + }, + "UpgradeRuntime": { + "methods": [ + "upgradeRuntime" + ] + }, + "ReportRuntimeEvent": { + "methods": [ + "reportRuntimeEvent" + ] + }, + "DiagnoseRuntime": { + "methods": [ + "diagnoseRuntime" + ] + }, + "ListRuntimes": { + "methods": [ + "listRuntimes", + "listRuntimesStream", + "listRuntimesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ManagedNotebookServiceClient", + "rpcs": { + "GetRuntime": { + "methods": [ + "getRuntime" + ] + }, + "RefreshRuntimeTokenInternal": { + "methods": [ + "refreshRuntimeTokenInternal" + ] + }, + "CreateRuntime": { + "methods": [ + "createRuntime" + ] + }, + "UpdateRuntime": { + "methods": [ + "updateRuntime" + ] + }, + "DeleteRuntime": { + "methods": [ + "deleteRuntime" + ] + }, + "StartRuntime": { + "methods": [ + "startRuntime" + ] + }, + "StopRuntime": { + "methods": [ + "stopRuntime" + ] + }, + "SwitchRuntime": { + "methods": [ + "switchRuntime" + ] + }, + "ResetRuntime": { + "methods": [ + "resetRuntime" + ] + }, + "UpgradeRuntime": { + "methods": [ + "upgradeRuntime" + ] + }, + "ReportRuntimeEvent": { + "methods": [ + "reportRuntimeEvent" + ] + }, + "DiagnoseRuntime": { + "methods": [ + "diagnoseRuntime" + ] + }, + "ListRuntimes": { + "methods": [ + "listRuntimes", + "listRuntimesStream", + "listRuntimesAsync" + ] + } + } + } + } + }, + "NotebookService": { + "clients": { + "grpc": { + "libraryClient": "NotebookServiceClient", + "rpcs": { + "GetInstance": { + "methods": [ + "getInstance" + ] + }, + "UpdateInstanceMetadataItems": { + "methods": [ + "updateInstanceMetadataItems" + ] + }, + "IsInstanceUpgradeable": { + "methods": [ + "isInstanceUpgradeable" + ] + }, + "GetInstanceHealth": { + "methods": [ + "getInstanceHealth" + ] + }, + "GetEnvironment": { + "methods": [ + "getEnvironment" + ] + }, + "GetSchedule": { + "methods": [ + "getSchedule" + ] + }, + "GetExecution": { + "methods": [ + "getExecution" + ] + }, + "CreateInstance": { + "methods": [ + "createInstance" + ] + }, + "RegisterInstance": { + "methods": [ + "registerInstance" + ] + }, + "SetInstanceAccelerator": { + "methods": [ + "setInstanceAccelerator" + ] + }, + "SetInstanceMachineType": { + "methods": [ + "setInstanceMachineType" + ] + }, + "UpdateInstanceConfig": { + "methods": [ + "updateInstanceConfig" + ] + }, + "UpdateShieldedInstanceConfig": { + "methods": [ + "updateShieldedInstanceConfig" + ] + }, + "SetInstanceLabels": { + "methods": [ + "setInstanceLabels" + ] + }, + "DeleteInstance": { + "methods": [ + "deleteInstance" + ] + }, + "StartInstance": { + "methods": [ + "startInstance" + ] + }, + "StopInstance": { + "methods": [ + "stopInstance" + ] + }, + "ResetInstance": { + "methods": [ + "resetInstance" + ] + }, + "ReportInstanceInfo": { + "methods": [ + "reportInstanceInfo" + ] + }, + "UpgradeInstance": { + "methods": [ + "upgradeInstance" + ] + }, + "RollbackInstance": { + "methods": [ + "rollbackInstance" + ] + }, + "DiagnoseInstance": { + "methods": [ + "diagnoseInstance" + ] + }, + "UpgradeInstanceInternal": { + "methods": [ + "upgradeInstanceInternal" + ] + }, + "CreateEnvironment": { + "methods": [ + "createEnvironment" + ] + }, + "DeleteEnvironment": { + "methods": [ + "deleteEnvironment" + ] + }, + "DeleteSchedule": { + "methods": [ + "deleteSchedule" + ] + }, + "CreateSchedule": { + "methods": [ + "createSchedule" + ] + }, + "TriggerSchedule": { + "methods": [ + "triggerSchedule" + ] + }, + "DeleteExecution": { + "methods": [ + "deleteExecution" + ] + }, + "CreateExecution": { + "methods": [ + "createExecution" + ] + }, + "ListInstances": { + "methods": [ + "listInstances", + "listInstancesStream", + "listInstancesAsync" + ] + }, + "ListEnvironments": { + "methods": [ + "listEnvironments", + "listEnvironmentsStream", + "listEnvironmentsAsync" + ] + }, + "ListSchedules": { + "methods": [ + "listSchedules", + "listSchedulesStream", + "listSchedulesAsync" + ] + }, + "ListExecutions": { + "methods": [ + "listExecutions", + "listExecutionsStream", + "listExecutionsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "NotebookServiceClient", + "rpcs": { + "GetInstance": { + "methods": [ + "getInstance" + ] + }, + "UpdateInstanceMetadataItems": { + "methods": [ + "updateInstanceMetadataItems" + ] + }, + "IsInstanceUpgradeable": { + "methods": [ + "isInstanceUpgradeable" + ] + }, + "GetInstanceHealth": { + "methods": [ + "getInstanceHealth" + ] + }, + "GetEnvironment": { + "methods": [ + "getEnvironment" + ] + }, + "GetSchedule": { + "methods": [ + "getSchedule" + ] + }, + "GetExecution": { + "methods": [ + "getExecution" + ] + }, + "CreateInstance": { + "methods": [ + "createInstance" + ] + }, + "RegisterInstance": { + "methods": [ + "registerInstance" + ] + }, + "SetInstanceAccelerator": { + "methods": [ + "setInstanceAccelerator" + ] + }, + "SetInstanceMachineType": { + "methods": [ + "setInstanceMachineType" + ] + }, + "UpdateInstanceConfig": { + "methods": [ + "updateInstanceConfig" + ] + }, + "UpdateShieldedInstanceConfig": { + "methods": [ + "updateShieldedInstanceConfig" + ] + }, + "SetInstanceLabels": { + "methods": [ + "setInstanceLabels" + ] + }, + "DeleteInstance": { + "methods": [ + "deleteInstance" + ] + }, + "StartInstance": { + "methods": [ + "startInstance" + ] + }, + "StopInstance": { + "methods": [ + "stopInstance" + ] + }, + "ResetInstance": { + "methods": [ + "resetInstance" + ] + }, + "ReportInstanceInfo": { + "methods": [ + "reportInstanceInfo" + ] + }, + "UpgradeInstance": { + "methods": [ + "upgradeInstance" + ] + }, + "RollbackInstance": { + "methods": [ + "rollbackInstance" + ] + }, + "DiagnoseInstance": { + "methods": [ + "diagnoseInstance" + ] + }, + "UpgradeInstanceInternal": { + "methods": [ + "upgradeInstanceInternal" + ] + }, + "CreateEnvironment": { + "methods": [ + "createEnvironment" + ] + }, + "DeleteEnvironment": { + "methods": [ + "deleteEnvironment" + ] + }, + "DeleteSchedule": { + "methods": [ + "deleteSchedule" + ] + }, + "CreateSchedule": { + "methods": [ + "createSchedule" + ] + }, + "TriggerSchedule": { + "methods": [ + "triggerSchedule" + ] + }, + "DeleteExecution": { + "methods": [ + "deleteExecution" + ] + }, + "CreateExecution": { + "methods": [ + "createExecution" + ] + }, + "ListInstances": { + "methods": [ + "listInstances", + "listInstancesStream", + "listInstancesAsync" + ] + }, + "ListEnvironments": { + "methods": [ + "listEnvironments", + "listEnvironmentsStream", + "listEnvironmentsAsync" + ] + }, + "ListSchedules": { + "methods": [ + "listSchedules", + "listSchedulesStream", + "listSchedulesAsync" + ] + }, + "ListExecutions": { + "methods": [ + "listExecutions", + "listExecutionsStream", + "listExecutionsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/index.ts new file mode 100644 index 00000000000..9ee9b360808 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ManagedNotebookServiceClient} from './managed_notebook_service_client'; +export {NotebookServiceClient} from './notebook_service_client'; diff --git a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_client.ts b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_client.ts new file mode 100644 index 00000000000..66a350c542c --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_client.ts @@ -0,0 +1,2414 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/managed_notebook_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './managed_notebook_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * API v1 service for Managed Notebooks. + * @class + * @memberof v1 + */ +export class ManagedNotebookServiceClient { + 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}; + iamClient: IamClient; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + managedNotebookServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ManagedNotebookServiceClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 ManagedNotebookServiceClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ManagedNotebookServiceClient; + 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.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); + + 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 { + 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 = { + environmentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/environments/{environment}' + ), + executionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/location/{location}/executions/{execution}' + ), + instancePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/instances/{instance}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + runtimePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/runtimes/{runtime}' + ), + schedulePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/location/{location}/schedules/{schedule}' + ), + }; + + // 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 = { + listRuntimes: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'runtimes') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/*/instances/*}:getIamPolicy',additional_bindings: [{get: '/v1/{resource=projects/*/locations/*/runtimes/*}:getIamPolicy',}], + },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/*/instances/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/runtimes/*}:setIamPolicy',body: '*',}], + },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/*/instances/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/runtimes/*}:testIamPermissions',body: '*',}], + },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createRuntimeResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; + const createRuntimeMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const updateRuntimeResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; + const updateRuntimeMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const deleteRuntimeResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteRuntimeMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const startRuntimeResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; + const startRuntimeMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const stopRuntimeResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; + const stopRuntimeMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const switchRuntimeResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; + const switchRuntimeMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const resetRuntimeResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; + const resetRuntimeMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const upgradeRuntimeResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; + const upgradeRuntimeMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const reportRuntimeEventResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; + const reportRuntimeEventMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const diagnoseRuntimeResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; + const diagnoseRuntimeMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createRuntime: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createRuntimeResponse.decode.bind(createRuntimeResponse), + createRuntimeMetadata.decode.bind(createRuntimeMetadata)), + updateRuntime: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateRuntimeResponse.decode.bind(updateRuntimeResponse), + updateRuntimeMetadata.decode.bind(updateRuntimeMetadata)), + deleteRuntime: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteRuntimeResponse.decode.bind(deleteRuntimeResponse), + deleteRuntimeMetadata.decode.bind(deleteRuntimeMetadata)), + startRuntime: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + startRuntimeResponse.decode.bind(startRuntimeResponse), + startRuntimeMetadata.decode.bind(startRuntimeMetadata)), + stopRuntime: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + stopRuntimeResponse.decode.bind(stopRuntimeResponse), + stopRuntimeMetadata.decode.bind(stopRuntimeMetadata)), + switchRuntime: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + switchRuntimeResponse.decode.bind(switchRuntimeResponse), + switchRuntimeMetadata.decode.bind(switchRuntimeMetadata)), + resetRuntime: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + resetRuntimeResponse.decode.bind(resetRuntimeResponse), + resetRuntimeMetadata.decode.bind(resetRuntimeMetadata)), + upgradeRuntime: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + upgradeRuntimeResponse.decode.bind(upgradeRuntimeResponse), + upgradeRuntimeMetadata.decode.bind(upgradeRuntimeMetadata)), + reportRuntimeEvent: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + reportRuntimeEventResponse.decode.bind(reportRuntimeEventResponse), + reportRuntimeEventMetadata.decode.bind(reportRuntimeEventMetadata)), + diagnoseRuntime: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + diagnoseRuntimeResponse.decode.bind(diagnoseRuntimeResponse), + diagnoseRuntimeMetadata.decode.bind(diagnoseRuntimeMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.notebooks.v1.ManagedNotebookService', 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.managedNotebookServiceStub) { + return this.managedNotebookServiceStub; + } + + // Put together the "service stub" for + // google.cloud.notebooks.v1.ManagedNotebookService. + this.managedNotebookServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.notebooks.v1.ManagedNotebookService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.notebooks.v1.ManagedNotebookService, + 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 managedNotebookServiceStubMethods = + ['listRuntimes', 'getRuntime', 'createRuntime', 'updateRuntime', 'deleteRuntime', 'startRuntime', 'stopRuntime', 'switchRuntime', 'resetRuntime', 'upgradeRuntime', 'reportRuntimeEvent', 'refreshRuntimeTokenInternal', 'diagnoseRuntime']; + for (const methodName of managedNotebookServiceStubMethods) { + const callPromise = this.managedNotebookServiceStub.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.managedNotebookServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'notebooks.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 'notebooks.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 details of a single Runtime. The location must be a regional endpoint + * rather than zonal. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1.Runtime|Runtime}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.get_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_GetRuntime_async + */ + getRuntime( + request?: protos.google.cloud.notebooks.v1.IGetRuntimeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IGetRuntimeRequest|undefined, {}|undefined + ]>; + getRuntime( + request: protos.google.cloud.notebooks.v1.IGetRuntimeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IGetRuntimeRequest|null|undefined, + {}|null|undefined>): void; + getRuntime( + request: protos.google.cloud.notebooks.v1.IGetRuntimeRequest, + callback: Callback< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IGetRuntimeRequest|null|undefined, + {}|null|undefined>): void; + getRuntime( + request?: protos.google.cloud.notebooks.v1.IGetRuntimeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IGetRuntimeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IGetRuntimeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IGetRuntimeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getRuntime(request, options, callback); + } +/** + * Gets an access token for the consumer service account that the customer + * attached to the runtime. Only accessible from the tenant instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + * @param {string} request.vmId + * Required. The VM hardware token for authenticating the VM. + * https://cloud.google.com/compute/docs/instances/verifying-instance-identity + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalResponse|RefreshRuntimeTokenInternalResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.refresh_runtime_token_internal.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_RefreshRuntimeTokenInternal_async + */ + refreshRuntimeTokenInternal( + request?: protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, + protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest|undefined, {}|undefined + ]>; + refreshRuntimeTokenInternal( + request: protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, + protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest|null|undefined, + {}|null|undefined>): void; + refreshRuntimeTokenInternal( + request: protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest, + callback: Callback< + protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, + protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest|null|undefined, + {}|null|undefined>): void; + refreshRuntimeTokenInternal( + request?: protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, + protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, + protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, + protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.refreshRuntimeTokenInternal(request, options, callback); + } + +/** + * Creates a new Runtime in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {string} request.runtimeId + * Required. User-defined unique ID of this Runtime. + * @param {google.cloud.notebooks.v1.Runtime} request.runtime + * Required. The Runtime to be created. + * @param {string} request.requestId + * Idempotent request UUID. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.create_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_CreateRuntime_async + */ + createRuntime( + request?: protos.google.cloud.notebooks.v1.ICreateRuntimeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createRuntime( + request: protos.google.cloud.notebooks.v1.ICreateRuntimeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createRuntime( + request: protos.google.cloud.notebooks.v1.ICreateRuntimeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createRuntime( + request?: protos.google.cloud.notebooks.v1.ICreateRuntimeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createRuntime(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createRuntime()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.create_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_CreateRuntime_async + */ + async checkCreateRuntimeProgress(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.createRuntime, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Update Notebook Runtime configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.notebooks.v1.Runtime} request.runtime + * Required. The Runtime to be updated. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Specifies the path, relative to `Runtime`, of + * the field to update. For example, to change the software configuration + * kernels, the `update_mask` parameter would be + * specified as `software_config.kernels`, + * and the `PATCH` request body would specify the new value, as follows: + * + * { + * "software_config":{ + * "kernels": [{ + * 'repository': + * 'gcr.io/deeplearning-platform-release/pytorch-gpu', 'tag': + * 'latest' }], + * } + * } + * + * + * Currently, only the following fields can be updated: + * - `software_config.kernels` + * - `software_config.post_startup_script` + * - `software_config.custom_gpu_driver_path` + * - `software_config.idle_shutdown` + * - `software_config.idle_shutdown_timeout` + * - `software_config.disable_terminal` + * @param {string} request.requestId + * Idempotent request UUID. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.update_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_UpdateRuntime_async + */ + updateRuntime( + request?: protos.google.cloud.notebooks.v1.IUpdateRuntimeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateRuntime( + request: protos.google.cloud.notebooks.v1.IUpdateRuntimeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateRuntime( + request: protos.google.cloud.notebooks.v1.IUpdateRuntimeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateRuntime( + request?: protos.google.cloud.notebooks.v1.IUpdateRuntimeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'runtime.name': request.runtime!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateRuntime(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateRuntime()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.update_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_UpdateRuntime_async + */ + async checkUpdateRuntimeProgress(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.updateRuntime, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a single Runtime. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + * @param {string} request.requestId + * Idempotent request UUID. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.delete_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_DeleteRuntime_async + */ + deleteRuntime( + request?: protos.google.cloud.notebooks.v1.IDeleteRuntimeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteRuntime( + request: protos.google.cloud.notebooks.v1.IDeleteRuntimeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteRuntime( + request: protos.google.cloud.notebooks.v1.IDeleteRuntimeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteRuntime( + request?: protos.google.cloud.notebooks.v1.IDeleteRuntimeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteRuntime(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteRuntime()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.delete_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_DeleteRuntime_async + */ + async checkDeleteRuntimeProgress(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.deleteRuntime, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Starts a Managed Notebook Runtime. + * Perform "Start" on GPU instances; "Resume" on CPU instances + * See: + * https://cloud.google.com/compute/docs/instances/stop-start-instance + * https://cloud.google.com/compute/docs/instances/suspend-resume-instance + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + * @param {string} request.requestId + * Idempotent request UUID. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.start_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_StartRuntime_async + */ + startRuntime( + request?: protos.google.cloud.notebooks.v1.IStartRuntimeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + startRuntime( + request: protos.google.cloud.notebooks.v1.IStartRuntimeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + startRuntime( + request: protos.google.cloud.notebooks.v1.IStartRuntimeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + startRuntime( + request?: protos.google.cloud.notebooks.v1.IStartRuntimeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.startRuntime(request, options, callback); + } +/** + * Check the status of the long running operation returned by `startRuntime()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.start_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_StartRuntime_async + */ + async checkStartRuntimeProgress(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.startRuntime, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Stops a Managed Notebook Runtime. + * Perform "Stop" on GPU instances; "Suspend" on CPU instances + * See: + * https://cloud.google.com/compute/docs/instances/stop-start-instance + * https://cloud.google.com/compute/docs/instances/suspend-resume-instance + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + * @param {string} request.requestId + * Idempotent request UUID. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.stop_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_StopRuntime_async + */ + stopRuntime( + request?: protos.google.cloud.notebooks.v1.IStopRuntimeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + stopRuntime( + request: protos.google.cloud.notebooks.v1.IStopRuntimeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + stopRuntime( + request: protos.google.cloud.notebooks.v1.IStopRuntimeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + stopRuntime( + request?: protos.google.cloud.notebooks.v1.IStopRuntimeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.stopRuntime(request, options, callback); + } +/** + * Check the status of the long running operation returned by `stopRuntime()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.stop_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_StopRuntime_async + */ + async checkStopRuntimeProgress(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.stopRuntime, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Switch a Managed Notebook Runtime. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + * @param {string} request.machineType + * machine type. + * @param {google.cloud.notebooks.v1.RuntimeAcceleratorConfig} request.acceleratorConfig + * accelerator config. + * @param {string} request.requestId + * Idempotent request UUID. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.switch_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_SwitchRuntime_async + */ + switchRuntime( + request?: protos.google.cloud.notebooks.v1.ISwitchRuntimeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + switchRuntime( + request: protos.google.cloud.notebooks.v1.ISwitchRuntimeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + switchRuntime( + request: protos.google.cloud.notebooks.v1.ISwitchRuntimeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + switchRuntime( + request?: protos.google.cloud.notebooks.v1.ISwitchRuntimeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.switchRuntime(request, options, callback); + } +/** + * Check the status of the long running operation returned by `switchRuntime()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.switch_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_SwitchRuntime_async + */ + async checkSwitchRuntimeProgress(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.switchRuntime, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Resets a Managed Notebook Runtime. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + * @param {string} request.requestId + * Idempotent request UUID. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.reset_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_ResetRuntime_async + */ + resetRuntime( + request?: protos.google.cloud.notebooks.v1.IResetRuntimeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + resetRuntime( + request: protos.google.cloud.notebooks.v1.IResetRuntimeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + resetRuntime( + request: protos.google.cloud.notebooks.v1.IResetRuntimeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + resetRuntime( + request?: protos.google.cloud.notebooks.v1.IResetRuntimeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.resetRuntime(request, options, callback); + } +/** + * Check the status of the long running operation returned by `resetRuntime()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.reset_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_ResetRuntime_async + */ + async checkResetRuntimeProgress(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.resetRuntime, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Upgrades a Managed Notebook Runtime to the latest version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + * @param {string} request.requestId + * Idempotent request UUID. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.upgrade_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_UpgradeRuntime_async + */ + upgradeRuntime( + request?: protos.google.cloud.notebooks.v1.IUpgradeRuntimeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + upgradeRuntime( + request: protos.google.cloud.notebooks.v1.IUpgradeRuntimeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + upgradeRuntime( + request: protos.google.cloud.notebooks.v1.IUpgradeRuntimeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + upgradeRuntime( + request?: protos.google.cloud.notebooks.v1.IUpgradeRuntimeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.upgradeRuntime(request, options, callback); + } +/** + * Check the status of the long running operation returned by `upgradeRuntime()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.upgrade_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_UpgradeRuntime_async + */ + async checkUpgradeRuntimeProgress(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.upgradeRuntime, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Report and process a runtime event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + * @param {string} request.vmId + * Required. The VM hardware token for authenticating the VM. + * https://cloud.google.com/compute/docs/instances/verifying-instance-identity + * @param {google.cloud.notebooks.v1.Event} request.event + * Required. The Event to be reported. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.report_runtime_event.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_ReportRuntimeEvent_async + */ + reportRuntimeEvent( + request?: protos.google.cloud.notebooks.v1.IReportRuntimeEventRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + reportRuntimeEvent( + request: protos.google.cloud.notebooks.v1.IReportRuntimeEventRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + reportRuntimeEvent( + request: protos.google.cloud.notebooks.v1.IReportRuntimeEventRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + reportRuntimeEvent( + request?: protos.google.cloud.notebooks.v1.IReportRuntimeEventRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.reportRuntimeEvent(request, options, callback); + } +/** + * Check the status of the long running operation returned by `reportRuntimeEvent()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.report_runtime_event.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_ReportRuntimeEvent_async + */ + async checkReportRuntimeEventProgress(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.reportRuntimeEvent, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Creates a Diagnostic File and runs Diagnostic Tool given a Runtime. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtimes_id}` + * @param {google.cloud.notebooks.v1.DiagnosticConfig} request.diagnosticConfig + * Required. Defines flags that are used to run the diagnostic tool + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.diagnose_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_DiagnoseRuntime_async + */ + diagnoseRuntime( + request?: protos.google.cloud.notebooks.v1.IDiagnoseRuntimeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + diagnoseRuntime( + request: protos.google.cloud.notebooks.v1.IDiagnoseRuntimeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + diagnoseRuntime( + request: protos.google.cloud.notebooks.v1.IDiagnoseRuntimeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + diagnoseRuntime( + request?: protos.google.cloud.notebooks.v1.IDiagnoseRuntimeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.diagnoseRuntime(request, options, callback); + } +/** + * Check the status of the long running operation returned by `diagnoseRuntime()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.diagnose_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_DiagnoseRuntime_async + */ + async checkDiagnoseRuntimeProgress(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.diagnoseRuntime, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists Runtimes in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.notebooks.v1.Runtime|Runtime}. + * 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 `listRuntimesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listRuntimes( + request?: protos.google.cloud.notebooks.v1.IListRuntimesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v1.IRuntime[], + protos.google.cloud.notebooks.v1.IListRuntimesRequest|null, + protos.google.cloud.notebooks.v1.IListRuntimesResponse + ]>; + listRuntimes( + request: protos.google.cloud.notebooks.v1.IListRuntimesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1.IListRuntimesRequest, + protos.google.cloud.notebooks.v1.IListRuntimesResponse|null|undefined, + protos.google.cloud.notebooks.v1.IRuntime>): void; + listRuntimes( + request: protos.google.cloud.notebooks.v1.IListRuntimesRequest, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1.IListRuntimesRequest, + protos.google.cloud.notebooks.v1.IListRuntimesResponse|null|undefined, + protos.google.cloud.notebooks.v1.IRuntime>): void; + listRuntimes( + request?: protos.google.cloud.notebooks.v1.IListRuntimesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.notebooks.v1.IListRuntimesRequest, + protos.google.cloud.notebooks.v1.IListRuntimesResponse|null|undefined, + protos.google.cloud.notebooks.v1.IRuntime>, + callback?: PaginationCallback< + protos.google.cloud.notebooks.v1.IListRuntimesRequest, + protos.google.cloud.notebooks.v1.IListRuntimesResponse|null|undefined, + protos.google.cloud.notebooks.v1.IRuntime>): + Promise<[ + protos.google.cloud.notebooks.v1.IRuntime[], + protos.google.cloud.notebooks.v1.IListRuntimesRequest|null, + protos.google.cloud.notebooks.v1.IListRuntimesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listRuntimes(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. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @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 protos.google.cloud.notebooks.v1.Runtime|Runtime} 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 `listRuntimesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listRuntimesStream( + request?: protos.google.cloud.notebooks.v1.IListRuntimesRequest, + 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['listRuntimes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRuntimes.createStream( + this.innerApiCalls.listRuntimes as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listRuntimes`, 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. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.notebooks.v1.Runtime|Runtime}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.list_runtimes.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_ListRuntimes_async + */ + listRuntimesAsync( + request?: protos.google.cloud.notebooks.v1.IListRuntimesRequest, + 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['listRuntimes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRuntimes.asyncIterate( + this.innerApiCalls['listRuntimes'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @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/interfaces/CallOptions.html | 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.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getIamPolicy( + request: IamProtos.google.iam.v1.GetIamPolicyRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.Policy]> { + return this.iamClient.getIamPolicy(request, options, callback); + } + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + setIamPolicy( + request: IamProtos.google.iam.v1.SetIamPolicyRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.Policy]> { + return this.iamClient.setIamPolicy(request, options, callback); + } + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ + testIamPermissions( + request: IamProtos.google.iam.v1.TestIamPermissionsRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + return this.iamClient.testIamPermissions(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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 environment resource name string. + * + * @param {string} project + * @param {string} environment + * @returns {string} Resource name string. + */ + environmentPath(project:string,environment:string) { + return this.pathTemplates.environmentPathTemplate.render({ + project: project, + environment: environment, + }); + } + + /** + * Parse the project from Environment resource. + * + * @param {string} environmentName + * A fully-qualified path representing Environment resource. + * @returns {string} A string representing the project. + */ + matchProjectFromEnvironmentName(environmentName: string) { + return this.pathTemplates.environmentPathTemplate.match(environmentName).project; + } + + /** + * Parse the environment from Environment resource. + * + * @param {string} environmentName + * A fully-qualified path representing Environment resource. + * @returns {string} A string representing the environment. + */ + matchEnvironmentFromEnvironmentName(environmentName: string) { + return this.pathTemplates.environmentPathTemplate.match(environmentName).environment; + } + + /** + * Return a fully-qualified execution resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} execution + * @returns {string} Resource name string. + */ + executionPath(project:string,location:string,execution:string) { + return this.pathTemplates.executionPathTemplate.render({ + project: project, + location: location, + execution: execution, + }); + } + + /** + * Parse the project from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the project. + */ + matchProjectFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).project; + } + + /** + * Parse the location from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the location. + */ + matchLocationFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).location; + } + + /** + * Parse the execution from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the execution. + */ + matchExecutionFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).execution; + } + + /** + * Return a fully-qualified instance resource name string. + * + * @param {string} project + * @param {string} instance + * @returns {string} Resource name string. + */ + instancePath(project:string,instance:string) { + return this.pathTemplates.instancePathTemplate.render({ + project: project, + instance: instance, + }); + } + + /** + * Parse the project from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the project. + */ + matchProjectFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).project; + } + + /** + * Parse the instance from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).instance; + } + + /** + * 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 project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified runtime resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} runtime + * @returns {string} Resource name string. + */ + runtimePath(project:string,location:string,runtime:string) { + return this.pathTemplates.runtimePathTemplate.render({ + project: project, + location: location, + runtime: runtime, + }); + } + + /** + * Parse the project from Runtime resource. + * + * @param {string} runtimeName + * A fully-qualified path representing Runtime resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRuntimeName(runtimeName: string) { + return this.pathTemplates.runtimePathTemplate.match(runtimeName).project; + } + + /** + * Parse the location from Runtime resource. + * + * @param {string} runtimeName + * A fully-qualified path representing Runtime resource. + * @returns {string} A string representing the location. + */ + matchLocationFromRuntimeName(runtimeName: string) { + return this.pathTemplates.runtimePathTemplate.match(runtimeName).location; + } + + /** + * Parse the runtime from Runtime resource. + * + * @param {string} runtimeName + * A fully-qualified path representing Runtime resource. + * @returns {string} A string representing the runtime. + */ + matchRuntimeFromRuntimeName(runtimeName: string) { + return this.pathTemplates.runtimePathTemplate.match(runtimeName).runtime; + } + + /** + * Return a fully-qualified schedule resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} schedule + * @returns {string} Resource name string. + */ + schedulePath(project:string,location:string,schedule:string) { + return this.pathTemplates.schedulePathTemplate.render({ + project: project, + location: location, + schedule: schedule, + }); + } + + /** + * Parse the project from Schedule resource. + * + * @param {string} scheduleName + * A fully-qualified path representing Schedule resource. + * @returns {string} A string representing the project. + */ + matchProjectFromScheduleName(scheduleName: string) { + return this.pathTemplates.schedulePathTemplate.match(scheduleName).project; + } + + /** + * Parse the location from Schedule resource. + * + * @param {string} scheduleName + * A fully-qualified path representing Schedule resource. + * @returns {string} A string representing the location. + */ + matchLocationFromScheduleName(scheduleName: string) { + return this.pathTemplates.schedulePathTemplate.match(scheduleName).location; + } + + /** + * Parse the schedule from Schedule resource. + * + * @param {string} scheduleName + * A fully-qualified path representing Schedule resource. + * @returns {string} A string representing the schedule. + */ + matchScheduleFromScheduleName(scheduleName: string) { + return this.pathTemplates.schedulePathTemplate.match(scheduleName).schedule; + } + + /** + * 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.managedNotebookServiceStub && !this._terminated) { + return this.managedNotebookServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.iamClient.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_client_config.json b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_client_config.json new file mode 100644 index 00000000000..d44cface756 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_client_config.json @@ -0,0 +1,94 @@ +{ + "interfaces": { + "google.cloud.notebooks.v1.ManagedNotebookService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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": { + "ListRuntimes": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetRuntime": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateRuntime": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateRuntime": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteRuntime": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StartRuntime": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StopRuntime": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SwitchRuntime": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ResetRuntime": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "UpgradeRuntime": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "ReportRuntimeEvent": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RefreshRuntimeTokenInternal": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "DiagnoseRuntime": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_proto_list.json b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_proto_list.json new file mode 100644 index 00000000000..3861b9317a6 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_proto_list.json @@ -0,0 +1,12 @@ +[ + "../../protos/google/cloud/notebooks/v1/diagnostic_config.proto", + "../../protos/google/cloud/notebooks/v1/environment.proto", + "../../protos/google/cloud/notebooks/v1/event.proto", + "../../protos/google/cloud/notebooks/v1/execution.proto", + "../../protos/google/cloud/notebooks/v1/instance.proto", + "../../protos/google/cloud/notebooks/v1/instance_config.proto", + "../../protos/google/cloud/notebooks/v1/managed_service.proto", + "../../protos/google/cloud/notebooks/v1/runtime.proto", + "../../protos/google/cloud/notebooks/v1/schedule.proto", + "../../protos/google/cloud/notebooks/v1/service.proto" +] diff --git a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_client.ts b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_client.ts new file mode 100644 index 00000000000..bc34f4bcea2 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_client.ts @@ -0,0 +1,4544 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/notebook_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './notebook_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * API v1 service for Cloud AI Platform Notebooks. + * @class + * @memberof v1 + */ +export class NotebookServiceClient { + 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}; + iamClient: IamClient; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + notebookServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of NotebookServiceClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 NotebookServiceClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof NotebookServiceClient; + 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.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); + + 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 { + 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 = { + environmentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/environments/{environment}' + ), + executionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/location/{location}/executions/{execution}' + ), + instancePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/instances/{instance}' + ), + runtimePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/runtimes/{runtime}' + ), + schedulePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/location/{location}/schedules/{schedule}' + ), + }; + + // 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 = { + listInstances: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instances'), + listEnvironments: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'environments'), + listSchedules: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'schedules'), + listExecutions: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'executions') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/*/instances/*}:getIamPolicy',additional_bindings: [{get: '/v1/{resource=projects/*/locations/*/runtimes/*}:getIamPolicy',}], + },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/*/instances/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/runtimes/*}:setIamPolicy',body: '*',}], + },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/*/instances/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/runtimes/*}:testIamPermissions',body: '*',}], + },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + const createInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const registerInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + const registerInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const setInstanceAcceleratorResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + const setInstanceAcceleratorMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const setInstanceMachineTypeResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + const setInstanceMachineTypeMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const updateInstanceConfigResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + const updateInstanceConfigMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const updateShieldedInstanceConfigResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + const updateShieldedInstanceConfigMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const setInstanceLabelsResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + const setInstanceLabelsMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const deleteInstanceResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const startInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + const startInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const stopInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + const stopInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const resetInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + const resetInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const reportInstanceInfoResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + const reportInstanceInfoMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const upgradeInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + const upgradeInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const rollbackInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + const rollbackInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const diagnoseInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + const diagnoseInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const upgradeInstanceInternalResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + const upgradeInstanceInternalMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const createEnvironmentResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Environment') as gax.protobuf.Type; + const createEnvironmentMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const deleteEnvironmentResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteEnvironmentMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const deleteScheduleResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteScheduleMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const createScheduleResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Schedule') as gax.protobuf.Type; + const createScheduleMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const triggerScheduleResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Schedule') as gax.protobuf.Type; + const triggerScheduleMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const deleteExecutionResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteExecutionMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + const createExecutionResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.Execution') as gax.protobuf.Type; + const createExecutionMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createInstanceResponse.decode.bind(createInstanceResponse), + createInstanceMetadata.decode.bind(createInstanceMetadata)), + registerInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + registerInstanceResponse.decode.bind(registerInstanceResponse), + registerInstanceMetadata.decode.bind(registerInstanceMetadata)), + setInstanceAccelerator: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + setInstanceAcceleratorResponse.decode.bind(setInstanceAcceleratorResponse), + setInstanceAcceleratorMetadata.decode.bind(setInstanceAcceleratorMetadata)), + setInstanceMachineType: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + setInstanceMachineTypeResponse.decode.bind(setInstanceMachineTypeResponse), + setInstanceMachineTypeMetadata.decode.bind(setInstanceMachineTypeMetadata)), + updateInstanceConfig: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateInstanceConfigResponse.decode.bind(updateInstanceConfigResponse), + updateInstanceConfigMetadata.decode.bind(updateInstanceConfigMetadata)), + updateShieldedInstanceConfig: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateShieldedInstanceConfigResponse.decode.bind(updateShieldedInstanceConfigResponse), + updateShieldedInstanceConfigMetadata.decode.bind(updateShieldedInstanceConfigMetadata)), + setInstanceLabels: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + setInstanceLabelsResponse.decode.bind(setInstanceLabelsResponse), + setInstanceLabelsMetadata.decode.bind(setInstanceLabelsMetadata)), + deleteInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteInstanceResponse.decode.bind(deleteInstanceResponse), + deleteInstanceMetadata.decode.bind(deleteInstanceMetadata)), + startInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + startInstanceResponse.decode.bind(startInstanceResponse), + startInstanceMetadata.decode.bind(startInstanceMetadata)), + stopInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + stopInstanceResponse.decode.bind(stopInstanceResponse), + stopInstanceMetadata.decode.bind(stopInstanceMetadata)), + resetInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + resetInstanceResponse.decode.bind(resetInstanceResponse), + resetInstanceMetadata.decode.bind(resetInstanceMetadata)), + reportInstanceInfo: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + reportInstanceInfoResponse.decode.bind(reportInstanceInfoResponse), + reportInstanceInfoMetadata.decode.bind(reportInstanceInfoMetadata)), + upgradeInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + upgradeInstanceResponse.decode.bind(upgradeInstanceResponse), + upgradeInstanceMetadata.decode.bind(upgradeInstanceMetadata)), + rollbackInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + rollbackInstanceResponse.decode.bind(rollbackInstanceResponse), + rollbackInstanceMetadata.decode.bind(rollbackInstanceMetadata)), + diagnoseInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + diagnoseInstanceResponse.decode.bind(diagnoseInstanceResponse), + diagnoseInstanceMetadata.decode.bind(diagnoseInstanceMetadata)), + upgradeInstanceInternal: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + upgradeInstanceInternalResponse.decode.bind(upgradeInstanceInternalResponse), + upgradeInstanceInternalMetadata.decode.bind(upgradeInstanceInternalMetadata)), + createEnvironment: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createEnvironmentResponse.decode.bind(createEnvironmentResponse), + createEnvironmentMetadata.decode.bind(createEnvironmentMetadata)), + deleteEnvironment: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteEnvironmentResponse.decode.bind(deleteEnvironmentResponse), + deleteEnvironmentMetadata.decode.bind(deleteEnvironmentMetadata)), + deleteSchedule: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteScheduleResponse.decode.bind(deleteScheduleResponse), + deleteScheduleMetadata.decode.bind(deleteScheduleMetadata)), + createSchedule: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createScheduleResponse.decode.bind(createScheduleResponse), + createScheduleMetadata.decode.bind(createScheduleMetadata)), + triggerSchedule: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + triggerScheduleResponse.decode.bind(triggerScheduleResponse), + triggerScheduleMetadata.decode.bind(triggerScheduleMetadata)), + deleteExecution: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteExecutionResponse.decode.bind(deleteExecutionResponse), + deleteExecutionMetadata.decode.bind(deleteExecutionMetadata)), + createExecution: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createExecutionResponse.decode.bind(createExecutionResponse), + createExecutionMetadata.decode.bind(createExecutionMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.notebooks.v1.NotebookService', 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.notebookServiceStub) { + return this.notebookServiceStub; + } + + // Put together the "service stub" for + // google.cloud.notebooks.v1.NotebookService. + this.notebookServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.notebooks.v1.NotebookService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.notebooks.v1.NotebookService, + 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 notebookServiceStubMethods = + ['listInstances', 'getInstance', 'createInstance', 'registerInstance', 'setInstanceAccelerator', 'setInstanceMachineType', 'updateInstanceConfig', 'updateShieldedInstanceConfig', 'setInstanceLabels', 'updateInstanceMetadataItems', 'deleteInstance', 'startInstance', 'stopInstance', 'resetInstance', 'reportInstanceInfo', 'isInstanceUpgradeable', 'getInstanceHealth', 'upgradeInstance', 'rollbackInstance', 'diagnoseInstance', 'upgradeInstanceInternal', 'listEnvironments', 'getEnvironment', 'createEnvironment', 'deleteEnvironment', 'listSchedules', 'getSchedule', 'deleteSchedule', 'createSchedule', 'triggerSchedule', 'listExecutions', 'getExecution', 'deleteExecution', 'createExecution']; + for (const methodName of notebookServiceStubMethods) { + const callPromise = this.notebookServiceStub.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.notebookServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'notebooks.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 'notebooks.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 details of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1.Instance|Instance}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.get_instance.js + * region_tag:notebooks_v1_generated_NotebookService_GetInstance_async + */ + getInstance( + request?: protos.google.cloud.notebooks.v1.IGetInstanceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IGetInstanceRequest|undefined, {}|undefined + ]>; + getInstance( + request: protos.google.cloud.notebooks.v1.IGetInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IGetInstanceRequest|null|undefined, + {}|null|undefined>): void; + getInstance( + request: protos.google.cloud.notebooks.v1.IGetInstanceRequest, + callback: Callback< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IGetInstanceRequest|null|undefined, + {}|null|undefined>): void; + getInstance( + request?: protos.google.cloud.notebooks.v1.IGetInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IGetInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IGetInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IGetInstanceRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getInstance(request, options, callback); + } +/** + * Add/update metadata items for an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {number[]} request.items + * Metadata items to add/update for the instance. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsResponse|UpdateInstanceMetadataItemsResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.update_instance_metadata_items.js + * region_tag:notebooks_v1_generated_NotebookService_UpdateInstanceMetadataItems_async + */ + updateInstanceMetadataItems( + request?: protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, + protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest|undefined, {}|undefined + ]>; + updateInstanceMetadataItems( + request: protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, + protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest|null|undefined, + {}|null|undefined>): void; + updateInstanceMetadataItems( + request: protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest, + callback: Callback< + protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, + protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest|null|undefined, + {}|null|undefined>): void; + updateInstanceMetadataItems( + request?: protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, + protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, + protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, + protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateInstanceMetadataItems(request, options, callback); + } +/** + * Check if a notebook instance is upgradable. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.notebookInstance + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {google.cloud.notebooks.v1.UpgradeType} [request.type] + * Optional. The optional UpgradeType. Setting this field will search for additional + * compute images to upgrade this instance. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1.IsInstanceUpgradeableResponse|IsInstanceUpgradeableResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.is_instance_upgradeable.js + * region_tag:notebooks_v1_generated_NotebookService_IsInstanceUpgradeable_async + */ + isInstanceUpgradeable( + request?: protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, + protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest|undefined, {}|undefined + ]>; + isInstanceUpgradeable( + request: protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, + protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest|null|undefined, + {}|null|undefined>): void; + isInstanceUpgradeable( + request: protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest, + callback: Callback< + protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, + protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest|null|undefined, + {}|null|undefined>): void; + isInstanceUpgradeable( + request?: protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, + protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, + protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, + protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'notebook_instance': request.notebookInstance ?? '', + }); + this.initialize(); + return this.innerApiCalls.isInstanceUpgradeable(request, options, callback); + } +/** + * Check if a notebook instance is healthy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1.GetInstanceHealthResponse|GetInstanceHealthResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.get_instance_health.js + * region_tag:notebooks_v1_generated_NotebookService_GetInstanceHealth_async + */ + getInstanceHealth( + request?: protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, + protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest|undefined, {}|undefined + ]>; + getInstanceHealth( + request: protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, + protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest|null|undefined, + {}|null|undefined>): void; + getInstanceHealth( + request: protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest, + callback: Callback< + protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, + protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest|null|undefined, + {}|null|undefined>): void; + getInstanceHealth( + request?: protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, + protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, + protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, + protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getInstanceHealth(request, options, callback); + } +/** + * Gets details of a single Environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/environments/{environment_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1.Environment|Environment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.get_environment.js + * region_tag:notebooks_v1_generated_NotebookService_GetEnvironment_async + */ + getEnvironment( + request?: protos.google.cloud.notebooks.v1.IGetEnvironmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v1.IEnvironment, + protos.google.cloud.notebooks.v1.IGetEnvironmentRequest|undefined, {}|undefined + ]>; + getEnvironment( + request: protos.google.cloud.notebooks.v1.IGetEnvironmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1.IEnvironment, + protos.google.cloud.notebooks.v1.IGetEnvironmentRequest|null|undefined, + {}|null|undefined>): void; + getEnvironment( + request: protos.google.cloud.notebooks.v1.IGetEnvironmentRequest, + callback: Callback< + protos.google.cloud.notebooks.v1.IEnvironment, + protos.google.cloud.notebooks.v1.IGetEnvironmentRequest|null|undefined, + {}|null|undefined>): void; + getEnvironment( + request?: protos.google.cloud.notebooks.v1.IGetEnvironmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.notebooks.v1.IEnvironment, + protos.google.cloud.notebooks.v1.IGetEnvironmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.notebooks.v1.IEnvironment, + protos.google.cloud.notebooks.v1.IGetEnvironmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.notebooks.v1.IEnvironment, + protos.google.cloud.notebooks.v1.IGetEnvironmentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getEnvironment(request, options, callback); + } +/** + * Gets details of schedule + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/schedules/{schedule_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1.Schedule|Schedule}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.get_schedule.js + * region_tag:notebooks_v1_generated_NotebookService_GetSchedule_async + */ + getSchedule( + request?: protos.google.cloud.notebooks.v1.IGetScheduleRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IGetScheduleRequest|undefined, {}|undefined + ]>; + getSchedule( + request: protos.google.cloud.notebooks.v1.IGetScheduleRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IGetScheduleRequest|null|undefined, + {}|null|undefined>): void; + getSchedule( + request: protos.google.cloud.notebooks.v1.IGetScheduleRequest, + callback: Callback< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IGetScheduleRequest|null|undefined, + {}|null|undefined>): void; + getSchedule( + request?: protos.google.cloud.notebooks.v1.IGetScheduleRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IGetScheduleRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IGetScheduleRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IGetScheduleRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getSchedule(request, options, callback); + } +/** + * Gets details of executions + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/executions/{execution_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1.Execution|Execution}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.get_execution.js + * region_tag:notebooks_v1_generated_NotebookService_GetExecution_async + */ + getExecution( + request?: protos.google.cloud.notebooks.v1.IGetExecutionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IGetExecutionRequest|undefined, {}|undefined + ]>; + getExecution( + request: protos.google.cloud.notebooks.v1.IGetExecutionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IGetExecutionRequest|null|undefined, + {}|null|undefined>): void; + getExecution( + request: protos.google.cloud.notebooks.v1.IGetExecutionRequest, + callback: Callback< + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IGetExecutionRequest|null|undefined, + {}|null|undefined>): void; + getExecution( + request?: protos.google.cloud.notebooks.v1.IGetExecutionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IGetExecutionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IGetExecutionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IGetExecutionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getExecution(request, options, callback); + } + +/** + * Creates a new Instance in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {string} request.instanceId + * Required. User-defined unique ID of this instance. + * @param {google.cloud.notebooks.v1.Instance} request.instance + * Required. The instance to be created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.create_instance.js + * region_tag:notebooks_v1_generated_NotebookService_CreateInstance_async + */ + createInstance( + request?: protos.google.cloud.notebooks.v1.ICreateInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createInstance( + request: protos.google.cloud.notebooks.v1.ICreateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createInstance( + request: protos.google.cloud.notebooks.v1.ICreateInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createInstance( + request?: protos.google.cloud.notebooks.v1.ICreateInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.create_instance.js + * region_tag:notebooks_v1_generated_NotebookService_CreateInstance_async + */ + async checkCreateInstanceProgress(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.createInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Registers an existing legacy notebook instance to the Notebooks API server. + * Legacy instances are instances created with the legacy Compute Engine + * calls. They are not manageable by the Notebooks API out of the box. This + * call makes these instances manageable by the Notebooks API. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {string} request.instanceId + * Required. User defined unique ID of this instance. The `instance_id` must + * be 1 to 63 characters long and contain only lowercase letters, + * numeric characters, and dashes. The first character must be a lowercase + * letter and the last character cannot be a dash. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.register_instance.js + * region_tag:notebooks_v1_generated_NotebookService_RegisterInstance_async + */ + registerInstance( + request?: protos.google.cloud.notebooks.v1.IRegisterInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + registerInstance( + request: protos.google.cloud.notebooks.v1.IRegisterInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + registerInstance( + request: protos.google.cloud.notebooks.v1.IRegisterInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + registerInstance( + request?: protos.google.cloud.notebooks.v1.IRegisterInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.registerInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `registerInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.register_instance.js + * region_tag:notebooks_v1_generated_NotebookService_RegisterInstance_async + */ + async checkRegisterInstanceProgress(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.registerInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the guest accelerators of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {google.cloud.notebooks.v1.Instance.AcceleratorType} request.type + * Required. Type of this accelerator. + * @param {number} request.coreCount + * Required. Count of cores of this accelerator. Note that not all combinations + * of `type` and `core_count` are valid. Check [GPUs on + * Compute Engine](https://cloud.google.com/compute/docs/gpus/#gpus-list) to + * find a valid combination. TPUs are not supported. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.set_instance_accelerator.js + * region_tag:notebooks_v1_generated_NotebookService_SetInstanceAccelerator_async + */ + setInstanceAccelerator( + request?: protos.google.cloud.notebooks.v1.ISetInstanceAcceleratorRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + setInstanceAccelerator( + request: protos.google.cloud.notebooks.v1.ISetInstanceAcceleratorRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInstanceAccelerator( + request: protos.google.cloud.notebooks.v1.ISetInstanceAcceleratorRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInstanceAccelerator( + request?: protos.google.cloud.notebooks.v1.ISetInstanceAcceleratorRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.setInstanceAccelerator(request, options, callback); + } +/** + * Check the status of the long running operation returned by `setInstanceAccelerator()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.set_instance_accelerator.js + * region_tag:notebooks_v1_generated_NotebookService_SetInstanceAccelerator_async + */ + async checkSetInstanceAcceleratorProgress(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.setInstanceAccelerator, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the machine type of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {string} request.machineType + * Required. The [Compute Engine machine + * type](https://cloud.google.com/compute/docs/machine-types). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.set_instance_machine_type.js + * region_tag:notebooks_v1_generated_NotebookService_SetInstanceMachineType_async + */ + setInstanceMachineType( + request?: protos.google.cloud.notebooks.v1.ISetInstanceMachineTypeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + setInstanceMachineType( + request: protos.google.cloud.notebooks.v1.ISetInstanceMachineTypeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInstanceMachineType( + request: protos.google.cloud.notebooks.v1.ISetInstanceMachineTypeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInstanceMachineType( + request?: protos.google.cloud.notebooks.v1.ISetInstanceMachineTypeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.setInstanceMachineType(request, options, callback); + } +/** + * Check the status of the long running operation returned by `setInstanceMachineType()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.set_instance_machine_type.js + * region_tag:notebooks_v1_generated_NotebookService_SetInstanceMachineType_async + */ + async checkSetInstanceMachineTypeProgress(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.setInstanceMachineType, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Update Notebook Instance configurations. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {google.cloud.notebooks.v1.InstanceConfig} request.config + * The instance configurations to be 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.update_instance_config.js + * region_tag:notebooks_v1_generated_NotebookService_UpdateInstanceConfig_async + */ + updateInstanceConfig( + request?: protos.google.cloud.notebooks.v1.IUpdateInstanceConfigRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateInstanceConfig( + request: protos.google.cloud.notebooks.v1.IUpdateInstanceConfigRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateInstanceConfig( + request: protos.google.cloud.notebooks.v1.IUpdateInstanceConfigRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateInstanceConfig( + request?: protos.google.cloud.notebooks.v1.IUpdateInstanceConfigRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateInstanceConfig(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateInstanceConfig()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.update_instance_config.js + * region_tag:notebooks_v1_generated_NotebookService_UpdateInstanceConfig_async + */ + async checkUpdateInstanceConfigProgress(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.updateInstanceConfig, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the Shielded instance configuration of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {google.cloud.notebooks.v1.Instance.ShieldedInstanceConfig} request.shieldedInstanceConfig + * ShieldedInstance configuration to be 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.update_shielded_instance_config.js + * region_tag:notebooks_v1_generated_NotebookService_UpdateShieldedInstanceConfig_async + */ + updateShieldedInstanceConfig( + request?: protos.google.cloud.notebooks.v1.IUpdateShieldedInstanceConfigRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateShieldedInstanceConfig( + request: protos.google.cloud.notebooks.v1.IUpdateShieldedInstanceConfigRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateShieldedInstanceConfig( + request: protos.google.cloud.notebooks.v1.IUpdateShieldedInstanceConfigRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateShieldedInstanceConfig( + request?: protos.google.cloud.notebooks.v1.IUpdateShieldedInstanceConfigRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateShieldedInstanceConfig(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateShieldedInstanceConfig()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.update_shielded_instance_config.js + * region_tag:notebooks_v1_generated_NotebookService_UpdateShieldedInstanceConfig_async + */ + async checkUpdateShieldedInstanceConfigProgress(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.updateShieldedInstanceConfig, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Replaces all the labels of an Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {number[]} request.labels + * Labels to apply to this instance. + * These can be later modified by the setLabels method + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.set_instance_labels.js + * region_tag:notebooks_v1_generated_NotebookService_SetInstanceLabels_async + */ + setInstanceLabels( + request?: protos.google.cloud.notebooks.v1.ISetInstanceLabelsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + setInstanceLabels( + request: protos.google.cloud.notebooks.v1.ISetInstanceLabelsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInstanceLabels( + request: protos.google.cloud.notebooks.v1.ISetInstanceLabelsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInstanceLabels( + request?: protos.google.cloud.notebooks.v1.ISetInstanceLabelsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.setInstanceLabels(request, options, callback); + } +/** + * Check the status of the long running operation returned by `setInstanceLabels()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.set_instance_labels.js + * region_tag:notebooks_v1_generated_NotebookService_SetInstanceLabels_async + */ + async checkSetInstanceLabelsProgress(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.setInstanceLabels, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.delete_instance.js + * region_tag:notebooks_v1_generated_NotebookService_DeleteInstance_async + */ + deleteInstance( + request?: protos.google.cloud.notebooks.v1.IDeleteInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteInstance( + request: protos.google.cloud.notebooks.v1.IDeleteInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteInstance( + request: protos.google.cloud.notebooks.v1.IDeleteInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteInstance( + request?: protos.google.cloud.notebooks.v1.IDeleteInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.delete_instance.js + * region_tag:notebooks_v1_generated_NotebookService_DeleteInstance_async + */ + async checkDeleteInstanceProgress(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.deleteInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Starts a notebook instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.start_instance.js + * region_tag:notebooks_v1_generated_NotebookService_StartInstance_async + */ + startInstance( + request?: protos.google.cloud.notebooks.v1.IStartInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + startInstance( + request: protos.google.cloud.notebooks.v1.IStartInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + startInstance( + request: protos.google.cloud.notebooks.v1.IStartInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + startInstance( + request?: protos.google.cloud.notebooks.v1.IStartInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.startInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `startInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.start_instance.js + * region_tag:notebooks_v1_generated_NotebookService_StartInstance_async + */ + async checkStartInstanceProgress(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.startInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Stops a notebook instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.stop_instance.js + * region_tag:notebooks_v1_generated_NotebookService_StopInstance_async + */ + stopInstance( + request?: protos.google.cloud.notebooks.v1.IStopInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + stopInstance( + request: protos.google.cloud.notebooks.v1.IStopInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + stopInstance( + request: protos.google.cloud.notebooks.v1.IStopInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + stopInstance( + request?: protos.google.cloud.notebooks.v1.IStopInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.stopInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `stopInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.stop_instance.js + * region_tag:notebooks_v1_generated_NotebookService_StopInstance_async + */ + async checkStopInstanceProgress(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.stopInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Resets a notebook instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.reset_instance.js + * region_tag:notebooks_v1_generated_NotebookService_ResetInstance_async + */ + resetInstance( + request?: protos.google.cloud.notebooks.v1.IResetInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + resetInstance( + request: protos.google.cloud.notebooks.v1.IResetInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + resetInstance( + request: protos.google.cloud.notebooks.v1.IResetInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + resetInstance( + request?: protos.google.cloud.notebooks.v1.IResetInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.resetInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `resetInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.reset_instance.js + * region_tag:notebooks_v1_generated_NotebookService_ResetInstance_async + */ + async checkResetInstanceProgress(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.resetInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Allows notebook instances to + * report their latest instance information to the Notebooks + * API server. The server will merge the reported information to + * the instance metadata store. Do not use this method directly. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {string} request.vmId + * Required. The VM hardware token for authenticating the VM. + * https://cloud.google.com/compute/docs/instances/verifying-instance-identity + * @param {number[]} request.metadata + * The metadata reported to Notebooks API. This will be merged to the instance + * metadata store + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.report_instance_info.js + * region_tag:notebooks_v1_generated_NotebookService_ReportInstanceInfo_async + */ + reportInstanceInfo( + request?: protos.google.cloud.notebooks.v1.IReportInstanceInfoRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + reportInstanceInfo( + request: protos.google.cloud.notebooks.v1.IReportInstanceInfoRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + reportInstanceInfo( + request: protos.google.cloud.notebooks.v1.IReportInstanceInfoRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + reportInstanceInfo( + request?: protos.google.cloud.notebooks.v1.IReportInstanceInfoRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.reportInstanceInfo(request, options, callback); + } +/** + * Check the status of the long running operation returned by `reportInstanceInfo()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.report_instance_info.js + * region_tag:notebooks_v1_generated_NotebookService_ReportInstanceInfo_async + */ + async checkReportInstanceInfoProgress(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.reportInstanceInfo, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Upgrades a notebook instance to the latest version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {google.cloud.notebooks.v1.UpgradeType} [request.type] + * Optional. The optional UpgradeType. Setting this field will search for additional + * compute images to upgrade this instance. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.upgrade_instance.js + * region_tag:notebooks_v1_generated_NotebookService_UpgradeInstance_async + */ + upgradeInstance( + request?: protos.google.cloud.notebooks.v1.IUpgradeInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + upgradeInstance( + request: protos.google.cloud.notebooks.v1.IUpgradeInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + upgradeInstance( + request: protos.google.cloud.notebooks.v1.IUpgradeInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + upgradeInstance( + request?: protos.google.cloud.notebooks.v1.IUpgradeInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.upgradeInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `upgradeInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.upgrade_instance.js + * region_tag:notebooks_v1_generated_NotebookService_UpgradeInstance_async + */ + async checkUpgradeInstanceProgress(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.upgradeInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Rollbacks a notebook instance to the previous version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {string} request.targetSnapshot + * Required. The snapshot for rollback. + * Example: `projects/test-project/global/snapshots/krwlzipynril`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.rollback_instance.js + * region_tag:notebooks_v1_generated_NotebookService_RollbackInstance_async + */ + rollbackInstance( + request?: protos.google.cloud.notebooks.v1.IRollbackInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + rollbackInstance( + request: protos.google.cloud.notebooks.v1.IRollbackInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + rollbackInstance( + request: protos.google.cloud.notebooks.v1.IRollbackInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + rollbackInstance( + request?: protos.google.cloud.notebooks.v1.IRollbackInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.rollbackInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `rollbackInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.rollback_instance.js + * region_tag:notebooks_v1_generated_NotebookService_RollbackInstance_async + */ + async checkRollbackInstanceProgress(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.rollbackInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Creates a Diagnostic File and runs Diagnostic Tool given an Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {google.cloud.notebooks.v1.DiagnosticConfig} request.diagnosticConfig + * Required. Defines flags that are used to run the diagnostic tool + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.diagnose_instance.js + * region_tag:notebooks_v1_generated_NotebookService_DiagnoseInstance_async + */ + diagnoseInstance( + request?: protos.google.cloud.notebooks.v1.IDiagnoseInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + diagnoseInstance( + request: protos.google.cloud.notebooks.v1.IDiagnoseInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + diagnoseInstance( + request: protos.google.cloud.notebooks.v1.IDiagnoseInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + diagnoseInstance( + request?: protos.google.cloud.notebooks.v1.IDiagnoseInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.diagnoseInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `diagnoseInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.diagnose_instance.js + * region_tag:notebooks_v1_generated_NotebookService_DiagnoseInstance_async + */ + async checkDiagnoseInstanceProgress(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.diagnoseInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Allows notebook instances to + * call this endpoint to upgrade themselves. Do not use this method directly. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {string} request.vmId + * Required. The VM hardware token for authenticating the VM. + * https://cloud.google.com/compute/docs/instances/verifying-instance-identity + * @param {google.cloud.notebooks.v1.UpgradeType} [request.type] + * Optional. The optional UpgradeType. Setting this field will search for additional + * compute images to upgrade this instance. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.upgrade_instance_internal.js + * region_tag:notebooks_v1_generated_NotebookService_UpgradeInstanceInternal_async + */ + upgradeInstanceInternal( + request?: protos.google.cloud.notebooks.v1.IUpgradeInstanceInternalRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + upgradeInstanceInternal( + request: protos.google.cloud.notebooks.v1.IUpgradeInstanceInternalRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + upgradeInstanceInternal( + request: protos.google.cloud.notebooks.v1.IUpgradeInstanceInternalRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + upgradeInstanceInternal( + request?: protos.google.cloud.notebooks.v1.IUpgradeInstanceInternalRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.upgradeInstanceInternal(request, options, callback); + } +/** + * Check the status of the long running operation returned by `upgradeInstanceInternal()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.upgrade_instance_internal.js + * region_tag:notebooks_v1_generated_NotebookService_UpgradeInstanceInternal_async + */ + async checkUpgradeInstanceInternalProgress(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.upgradeInstanceInternal, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Creates a new Environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: `projects/{project_id}/locations/{location}` + * @param {string} request.environmentId + * Required. User-defined unique ID of this environment. The `environment_id` must + * be 1 to 63 characters long and contain only lowercase letters, + * numeric characters, and dashes. The first character must be a lowercase + * letter and the last character cannot be a dash. + * @param {google.cloud.notebooks.v1.Environment} request.environment + * Required. The environment to be created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.create_environment.js + * region_tag:notebooks_v1_generated_NotebookService_CreateEnvironment_async + */ + createEnvironment( + request?: protos.google.cloud.notebooks.v1.ICreateEnvironmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createEnvironment( + request: protos.google.cloud.notebooks.v1.ICreateEnvironmentRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createEnvironment( + request: protos.google.cloud.notebooks.v1.ICreateEnvironmentRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createEnvironment( + request?: protos.google.cloud.notebooks.v1.ICreateEnvironmentRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createEnvironment(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createEnvironment()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.create_environment.js + * region_tag:notebooks_v1_generated_NotebookService_CreateEnvironment_async + */ + async checkCreateEnvironmentProgress(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.createEnvironment, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a single Environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/environments/{environment_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.delete_environment.js + * region_tag:notebooks_v1_generated_NotebookService_DeleteEnvironment_async + */ + deleteEnvironment( + request?: protos.google.cloud.notebooks.v1.IDeleteEnvironmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteEnvironment( + request: protos.google.cloud.notebooks.v1.IDeleteEnvironmentRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteEnvironment( + request: protos.google.cloud.notebooks.v1.IDeleteEnvironmentRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteEnvironment( + request?: protos.google.cloud.notebooks.v1.IDeleteEnvironmentRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteEnvironment(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteEnvironment()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.delete_environment.js + * region_tag:notebooks_v1_generated_NotebookService_DeleteEnvironment_async + */ + async checkDeleteEnvironmentProgress(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.deleteEnvironment, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes schedule and all underlying jobs + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/schedules/{schedule_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.delete_schedule.js + * region_tag:notebooks_v1_generated_NotebookService_DeleteSchedule_async + */ + deleteSchedule( + request?: protos.google.cloud.notebooks.v1.IDeleteScheduleRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteSchedule( + request: protos.google.cloud.notebooks.v1.IDeleteScheduleRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteSchedule( + request: protos.google.cloud.notebooks.v1.IDeleteScheduleRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteSchedule( + request?: protos.google.cloud.notebooks.v1.IDeleteScheduleRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteSchedule(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteSchedule()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.delete_schedule.js + * region_tag:notebooks_v1_generated_NotebookService_DeleteSchedule_async + */ + async checkDeleteScheduleProgress(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.deleteSchedule, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Creates a new Scheduled Notebook in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {string} request.scheduleId + * Required. User-defined unique ID of this schedule. + * @param {google.cloud.notebooks.v1.Schedule} request.schedule + * Required. The schedule to be created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.create_schedule.js + * region_tag:notebooks_v1_generated_NotebookService_CreateSchedule_async + */ + createSchedule( + request?: protos.google.cloud.notebooks.v1.ICreateScheduleRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createSchedule( + request: protos.google.cloud.notebooks.v1.ICreateScheduleRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createSchedule( + request: protos.google.cloud.notebooks.v1.ICreateScheduleRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createSchedule( + request?: protos.google.cloud.notebooks.v1.ICreateScheduleRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createSchedule(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createSchedule()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.create_schedule.js + * region_tag:notebooks_v1_generated_NotebookService_CreateSchedule_async + */ + async checkCreateScheduleProgress(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.createSchedule, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Triggers execution of an existing schedule. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `parent=projects/{project_id}/locations/{location}/schedules/{schedule_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.trigger_schedule.js + * region_tag:notebooks_v1_generated_NotebookService_TriggerSchedule_async + */ + triggerSchedule( + request?: protos.google.cloud.notebooks.v1.ITriggerScheduleRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + triggerSchedule( + request: protos.google.cloud.notebooks.v1.ITriggerScheduleRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + triggerSchedule( + request: protos.google.cloud.notebooks.v1.ITriggerScheduleRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + triggerSchedule( + request?: protos.google.cloud.notebooks.v1.ITriggerScheduleRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.triggerSchedule(request, options, callback); + } +/** + * Check the status of the long running operation returned by `triggerSchedule()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.trigger_schedule.js + * region_tag:notebooks_v1_generated_NotebookService_TriggerSchedule_async + */ + async checkTriggerScheduleProgress(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.triggerSchedule, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes execution + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/executions/{execution_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.delete_execution.js + * region_tag:notebooks_v1_generated_NotebookService_DeleteExecution_async + */ + deleteExecution( + request?: protos.google.cloud.notebooks.v1.IDeleteExecutionRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteExecution( + request: protos.google.cloud.notebooks.v1.IDeleteExecutionRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteExecution( + request: protos.google.cloud.notebooks.v1.IDeleteExecutionRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteExecution( + request?: protos.google.cloud.notebooks.v1.IDeleteExecutionRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteExecution(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteExecution()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.delete_execution.js + * region_tag:notebooks_v1_generated_NotebookService_DeleteExecution_async + */ + async checkDeleteExecutionProgress(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.deleteExecution, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Creates a new Execution in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {string} request.executionId + * Required. User-defined unique ID of this execution. + * @param {google.cloud.notebooks.v1.Execution} request.execution + * Required. The execution to be created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.create_execution.js + * region_tag:notebooks_v1_generated_NotebookService_CreateExecution_async + */ + createExecution( + request?: protos.google.cloud.notebooks.v1.ICreateExecutionRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createExecution( + request: protos.google.cloud.notebooks.v1.ICreateExecutionRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createExecution( + request: protos.google.cloud.notebooks.v1.ICreateExecutionRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createExecution( + request?: protos.google.cloud.notebooks.v1.ICreateExecutionRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createExecution(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createExecution()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.create_execution.js + * region_tag:notebooks_v1_generated_NotebookService_CreateExecution_async + */ + async checkCreateExecutionProgress(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.createExecution, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists instances in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.notebooks.v1.Instance|Instance}. + * 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 `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listInstances( + request?: protos.google.cloud.notebooks.v1.IListInstancesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v1.IInstance[], + protos.google.cloud.notebooks.v1.IListInstancesRequest|null, + protos.google.cloud.notebooks.v1.IListInstancesResponse + ]>; + listInstances( + request: protos.google.cloud.notebooks.v1.IListInstancesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1.IListInstancesRequest, + protos.google.cloud.notebooks.v1.IListInstancesResponse|null|undefined, + protos.google.cloud.notebooks.v1.IInstance>): void; + listInstances( + request: protos.google.cloud.notebooks.v1.IListInstancesRequest, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1.IListInstancesRequest, + protos.google.cloud.notebooks.v1.IListInstancesResponse|null|undefined, + protos.google.cloud.notebooks.v1.IInstance>): void; + listInstances( + request?: protos.google.cloud.notebooks.v1.IListInstancesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.notebooks.v1.IListInstancesRequest, + protos.google.cloud.notebooks.v1.IListInstancesResponse|null|undefined, + protos.google.cloud.notebooks.v1.IInstance>, + callback?: PaginationCallback< + protos.google.cloud.notebooks.v1.IListInstancesRequest, + protos.google.cloud.notebooks.v1.IListInstancesResponse|null|undefined, + protos.google.cloud.notebooks.v1.IInstance>): + Promise<[ + protos.google.cloud.notebooks.v1.IInstance[], + protos.google.cloud.notebooks.v1.IListInstancesRequest|null, + protos.google.cloud.notebooks.v1.IListInstancesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listInstances(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. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @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 protos.google.cloud.notebooks.v1.Instance|Instance} 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 `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listInstancesStream( + request?: protos.google.cloud.notebooks.v1.IListInstancesRequest, + 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['listInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInstances.createStream( + this.innerApiCalls.listInstances as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listInstances`, 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. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.notebooks.v1.Instance|Instance}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.list_instances.js + * region_tag:notebooks_v1_generated_NotebookService_ListInstances_async + */ + listInstancesAsync( + request?: protos.google.cloud.notebooks.v1.IListInstancesRequest, + 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['listInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInstances.asyncIterate( + this.innerApiCalls['listInstances'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists environments in a project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: `projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing from + * the last result. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.notebooks.v1.Environment|Environment}. + * 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 `listEnvironmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listEnvironments( + request?: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v1.IEnvironment[], + protos.google.cloud.notebooks.v1.IListEnvironmentsRequest|null, + protos.google.cloud.notebooks.v1.IListEnvironmentsResponse + ]>; + listEnvironments( + request: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, + protos.google.cloud.notebooks.v1.IListEnvironmentsResponse|null|undefined, + protos.google.cloud.notebooks.v1.IEnvironment>): void; + listEnvironments( + request: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, + protos.google.cloud.notebooks.v1.IListEnvironmentsResponse|null|undefined, + protos.google.cloud.notebooks.v1.IEnvironment>): void; + listEnvironments( + request?: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, + protos.google.cloud.notebooks.v1.IListEnvironmentsResponse|null|undefined, + protos.google.cloud.notebooks.v1.IEnvironment>, + callback?: PaginationCallback< + protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, + protos.google.cloud.notebooks.v1.IListEnvironmentsResponse|null|undefined, + protos.google.cloud.notebooks.v1.IEnvironment>): + Promise<[ + protos.google.cloud.notebooks.v1.IEnvironment[], + protos.google.cloud.notebooks.v1.IListEnvironmentsRequest|null, + protos.google.cloud.notebooks.v1.IListEnvironmentsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listEnvironments(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. Format: `projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing from + * the last result. + * @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 protos.google.cloud.notebooks.v1.Environment|Environment} 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 `listEnvironmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listEnvironmentsStream( + request?: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, + 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['listEnvironments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listEnvironments.createStream( + this.innerApiCalls.listEnvironments as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listEnvironments`, 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. Format: `projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing from + * the last result. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.notebooks.v1.Environment|Environment}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.list_environments.js + * region_tag:notebooks_v1_generated_NotebookService_ListEnvironments_async + */ + listEnvironmentsAsync( + request?: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, + 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['listEnvironments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listEnvironments.asyncIterate( + this.innerApiCalls['listEnvironments'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists schedules in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {string} request.filter + * Filter applied to resulting schedules. + * @param {string} request.orderBy + * Field to order results by. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.notebooks.v1.Schedule|Schedule}. + * 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 `listSchedulesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listSchedules( + request?: protos.google.cloud.notebooks.v1.IListSchedulesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v1.ISchedule[], + protos.google.cloud.notebooks.v1.IListSchedulesRequest|null, + protos.google.cloud.notebooks.v1.IListSchedulesResponse + ]>; + listSchedules( + request: protos.google.cloud.notebooks.v1.IListSchedulesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1.IListSchedulesRequest, + protos.google.cloud.notebooks.v1.IListSchedulesResponse|null|undefined, + protos.google.cloud.notebooks.v1.ISchedule>): void; + listSchedules( + request: protos.google.cloud.notebooks.v1.IListSchedulesRequest, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1.IListSchedulesRequest, + protos.google.cloud.notebooks.v1.IListSchedulesResponse|null|undefined, + protos.google.cloud.notebooks.v1.ISchedule>): void; + listSchedules( + request?: protos.google.cloud.notebooks.v1.IListSchedulesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.notebooks.v1.IListSchedulesRequest, + protos.google.cloud.notebooks.v1.IListSchedulesResponse|null|undefined, + protos.google.cloud.notebooks.v1.ISchedule>, + callback?: PaginationCallback< + protos.google.cloud.notebooks.v1.IListSchedulesRequest, + protos.google.cloud.notebooks.v1.IListSchedulesResponse|null|undefined, + protos.google.cloud.notebooks.v1.ISchedule>): + Promise<[ + protos.google.cloud.notebooks.v1.ISchedule[], + protos.google.cloud.notebooks.v1.IListSchedulesRequest|null, + protos.google.cloud.notebooks.v1.IListSchedulesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listSchedules(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. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {string} request.filter + * Filter applied to resulting schedules. + * @param {string} request.orderBy + * Field to order results by. + * @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 protos.google.cloud.notebooks.v1.Schedule|Schedule} 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 `listSchedulesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listSchedulesStream( + request?: protos.google.cloud.notebooks.v1.IListSchedulesRequest, + 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['listSchedules']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listSchedules.createStream( + this.innerApiCalls.listSchedules as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listSchedules`, 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. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {string} request.filter + * Filter applied to resulting schedules. + * @param {string} request.orderBy + * Field to order results by. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.notebooks.v1.Schedule|Schedule}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.list_schedules.js + * region_tag:notebooks_v1_generated_NotebookService_ListSchedules_async + */ + listSchedulesAsync( + request?: protos.google.cloud.notebooks.v1.IListSchedulesRequest, + 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['listSchedules']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listSchedules.asyncIterate( + this.innerApiCalls['listSchedules'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists executions in a given project and location + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {string} request.filter + * Filter applied to resulting executions. Currently only supports filtering + * executions by a specified `schedule_id`. + * Format: `schedule_id=` + * @param {string} request.orderBy + * Sort by field. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.notebooks.v1.Execution|Execution}. + * 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 `listExecutionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listExecutions( + request?: protos.google.cloud.notebooks.v1.IListExecutionsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v1.IExecution[], + protos.google.cloud.notebooks.v1.IListExecutionsRequest|null, + protos.google.cloud.notebooks.v1.IListExecutionsResponse + ]>; + listExecutions( + request: protos.google.cloud.notebooks.v1.IListExecutionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1.IListExecutionsRequest, + protos.google.cloud.notebooks.v1.IListExecutionsResponse|null|undefined, + protos.google.cloud.notebooks.v1.IExecution>): void; + listExecutions( + request: protos.google.cloud.notebooks.v1.IListExecutionsRequest, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1.IListExecutionsRequest, + protos.google.cloud.notebooks.v1.IListExecutionsResponse|null|undefined, + protos.google.cloud.notebooks.v1.IExecution>): void; + listExecutions( + request?: protos.google.cloud.notebooks.v1.IListExecutionsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.notebooks.v1.IListExecutionsRequest, + protos.google.cloud.notebooks.v1.IListExecutionsResponse|null|undefined, + protos.google.cloud.notebooks.v1.IExecution>, + callback?: PaginationCallback< + protos.google.cloud.notebooks.v1.IListExecutionsRequest, + protos.google.cloud.notebooks.v1.IListExecutionsResponse|null|undefined, + protos.google.cloud.notebooks.v1.IExecution>): + Promise<[ + protos.google.cloud.notebooks.v1.IExecution[], + protos.google.cloud.notebooks.v1.IListExecutionsRequest|null, + protos.google.cloud.notebooks.v1.IListExecutionsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listExecutions(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. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {string} request.filter + * Filter applied to resulting executions. Currently only supports filtering + * executions by a specified `schedule_id`. + * Format: `schedule_id=` + * @param {string} request.orderBy + * Sort by field. + * @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 protos.google.cloud.notebooks.v1.Execution|Execution} 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 `listExecutionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listExecutionsStream( + request?: protos.google.cloud.notebooks.v1.IListExecutionsRequest, + 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['listExecutions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listExecutions.createStream( + this.innerApiCalls.listExecutions as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listExecutions`, 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. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {string} request.filter + * Filter applied to resulting executions. Currently only supports filtering + * executions by a specified `schedule_id`. + * Format: `schedule_id=` + * @param {string} request.orderBy + * Sort by field. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.notebooks.v1.Execution|Execution}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.list_executions.js + * region_tag:notebooks_v1_generated_NotebookService_ListExecutions_async + */ + listExecutionsAsync( + request?: protos.google.cloud.notebooks.v1.IListExecutionsRequest, + 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['listExecutions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listExecutions.asyncIterate( + this.innerApiCalls['listExecutions'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @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/interfaces/CallOptions.html | 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.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getIamPolicy( + request: IamProtos.google.iam.v1.GetIamPolicyRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.Policy]> { + return this.iamClient.getIamPolicy(request, options, callback); + } + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + setIamPolicy( + request: IamProtos.google.iam.v1.SetIamPolicyRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.Policy]> { + return this.iamClient.setIamPolicy(request, options, callback); + } + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ + testIamPermissions( + request: IamProtos.google.iam.v1.TestIamPermissionsRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + return this.iamClient.testIamPermissions(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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 environment resource name string. + * + * @param {string} project + * @param {string} environment + * @returns {string} Resource name string. + */ + environmentPath(project:string,environment:string) { + return this.pathTemplates.environmentPathTemplate.render({ + project: project, + environment: environment, + }); + } + + /** + * Parse the project from Environment resource. + * + * @param {string} environmentName + * A fully-qualified path representing Environment resource. + * @returns {string} A string representing the project. + */ + matchProjectFromEnvironmentName(environmentName: string) { + return this.pathTemplates.environmentPathTemplate.match(environmentName).project; + } + + /** + * Parse the environment from Environment resource. + * + * @param {string} environmentName + * A fully-qualified path representing Environment resource. + * @returns {string} A string representing the environment. + */ + matchEnvironmentFromEnvironmentName(environmentName: string) { + return this.pathTemplates.environmentPathTemplate.match(environmentName).environment; + } + + /** + * Return a fully-qualified execution resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} execution + * @returns {string} Resource name string. + */ + executionPath(project:string,location:string,execution:string) { + return this.pathTemplates.executionPathTemplate.render({ + project: project, + location: location, + execution: execution, + }); + } + + /** + * Parse the project from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the project. + */ + matchProjectFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).project; + } + + /** + * Parse the location from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the location. + */ + matchLocationFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).location; + } + + /** + * Parse the execution from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the execution. + */ + matchExecutionFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).execution; + } + + /** + * Return a fully-qualified instance resource name string. + * + * @param {string} project + * @param {string} instance + * @returns {string} Resource name string. + */ + instancePath(project:string,instance:string) { + return this.pathTemplates.instancePathTemplate.render({ + project: project, + instance: instance, + }); + } + + /** + * Parse the project from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the project. + */ + matchProjectFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).project; + } + + /** + * Parse the instance from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).instance; + } + + /** + * Return a fully-qualified runtime resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} runtime + * @returns {string} Resource name string. + */ + runtimePath(project:string,location:string,runtime:string) { + return this.pathTemplates.runtimePathTemplate.render({ + project: project, + location: location, + runtime: runtime, + }); + } + + /** + * Parse the project from Runtime resource. + * + * @param {string} runtimeName + * A fully-qualified path representing Runtime resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRuntimeName(runtimeName: string) { + return this.pathTemplates.runtimePathTemplate.match(runtimeName).project; + } + + /** + * Parse the location from Runtime resource. + * + * @param {string} runtimeName + * A fully-qualified path representing Runtime resource. + * @returns {string} A string representing the location. + */ + matchLocationFromRuntimeName(runtimeName: string) { + return this.pathTemplates.runtimePathTemplate.match(runtimeName).location; + } + + /** + * Parse the runtime from Runtime resource. + * + * @param {string} runtimeName + * A fully-qualified path representing Runtime resource. + * @returns {string} A string representing the runtime. + */ + matchRuntimeFromRuntimeName(runtimeName: string) { + return this.pathTemplates.runtimePathTemplate.match(runtimeName).runtime; + } + + /** + * Return a fully-qualified schedule resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} schedule + * @returns {string} Resource name string. + */ + schedulePath(project:string,location:string,schedule:string) { + return this.pathTemplates.schedulePathTemplate.render({ + project: project, + location: location, + schedule: schedule, + }); + } + + /** + * Parse the project from Schedule resource. + * + * @param {string} scheduleName + * A fully-qualified path representing Schedule resource. + * @returns {string} A string representing the project. + */ + matchProjectFromScheduleName(scheduleName: string) { + return this.pathTemplates.schedulePathTemplate.match(scheduleName).project; + } + + /** + * Parse the location from Schedule resource. + * + * @param {string} scheduleName + * A fully-qualified path representing Schedule resource. + * @returns {string} A string representing the location. + */ + matchLocationFromScheduleName(scheduleName: string) { + return this.pathTemplates.schedulePathTemplate.match(scheduleName).location; + } + + /** + * Parse the schedule from Schedule resource. + * + * @param {string} scheduleName + * A fully-qualified path representing Schedule resource. + * @returns {string} A string representing the schedule. + */ + matchScheduleFromScheduleName(scheduleName: string) { + return this.pathTemplates.schedulePathTemplate.match(scheduleName).schedule; + } + + /** + * 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.notebookServiceStub && !this._terminated) { + return this.notebookServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.iamClient.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_client_config.json b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_client_config.json new file mode 100644 index 00000000000..0d27109878e --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_client_config.json @@ -0,0 +1,199 @@ +{ + "interfaces": { + "google.cloud.notebooks.v1.NotebookService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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": { + "ListInstances": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RegisterInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetInstanceAccelerator": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetInstanceMachineType": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateInstanceConfig": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateShieldedInstanceConfig": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetInstanceLabels": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateInstanceMetadataItems": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "DeleteInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StartInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StopInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ResetInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ReportInstanceInfo": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "IsInstanceUpgradeable": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetInstanceHealth": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpgradeInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RollbackInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DiagnoseInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpgradeInstanceInternal": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListEnvironments": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetEnvironment": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateEnvironment": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteEnvironment": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListSchedules": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetSchedule": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteSchedule": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateSchedule": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TriggerSchedule": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "ListExecutions": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetExecution": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteExecution": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateExecution": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_proto_list.json b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_proto_list.json new file mode 100644 index 00000000000..3861b9317a6 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_proto_list.json @@ -0,0 +1,12 @@ +[ + "../../protos/google/cloud/notebooks/v1/diagnostic_config.proto", + "../../protos/google/cloud/notebooks/v1/environment.proto", + "../../protos/google/cloud/notebooks/v1/event.proto", + "../../protos/google/cloud/notebooks/v1/execution.proto", + "../../protos/google/cloud/notebooks/v1/instance.proto", + "../../protos/google/cloud/notebooks/v1/instance_config.proto", + "../../protos/google/cloud/notebooks/v1/managed_service.proto", + "../../protos/google/cloud/notebooks/v1/runtime.proto", + "../../protos/google/cloud/notebooks/v1/schedule.proto", + "../../protos/google/cloud/notebooks/v1/service.proto" +] diff --git a/owl-bot-staging/google-cloud-notebooks/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-notebooks/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..fd40b36724c --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const notebooks = require('@google-cloud/notebooks'); + +function main() { + const managedNotebookServiceClient = new notebooks.ManagedNotebookServiceClient(); + const notebookServiceClient = new notebooks.NotebookServiceClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-notebooks/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..6d7f3eac2b2 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {ManagedNotebookServiceClient, NotebookServiceClient} from '@google-cloud/notebooks'; + +// check that the client class type name can be used +function doStuffWithManagedNotebookServiceClient(client: ManagedNotebookServiceClient) { + client.close(); +} +function doStuffWithNotebookServiceClient(client: NotebookServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const managedNotebookServiceClient = new ManagedNotebookServiceClient(); + doStuffWithManagedNotebookServiceClient(managedNotebookServiceClient); + // check that the client instance can be created + const notebookServiceClient = new NotebookServiceClient(); + doStuffWithNotebookServiceClient(notebookServiceClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/system-test/install.ts b/owl-bot-staging/google-cloud-notebooks/v1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/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-notebooks/v1/test/gapic_managed_notebook_service_v1.ts b/owl-bot-staging/google-cloud-notebooks/v1/test/gapic_managed_notebook_service_v1.ts new file mode 100644 index 00000000000..874034af34f --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/test/gapic_managed_notebook_service_v1.ts @@ -0,0 +1,3200 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 managednotebookserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.ManagedNotebookServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = managednotebookserviceModule.v1.ManagedNotebookServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = managednotebookserviceModule.v1.ManagedNotebookServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = managednotebookserviceModule.v1.ManagedNotebookServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.managedNotebookServiceStub, undefined); + await client.initialize(); + assert(client.managedNotebookServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.managedNotebookServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.managedNotebookServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + 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('getRuntime', () => { + it('invokes getRuntime without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.Runtime() + ); + client.innerApiCalls.getRuntime = stubSimpleCall(expectedResponse); + const [response] = await client.getRuntime(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRuntime without error using callback', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.Runtime() + ); + client.innerApiCalls.getRuntime = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRuntime( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IRuntime|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRuntime with error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getRuntime = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getRuntime(request), expectedError); + const actualRequest = (client.innerApiCalls.getRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRuntime with closed client', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getRuntime(request), expectedError); + }); + }); + + describe('refreshRuntimeTokenInternal', () => { + it('invokes refreshRuntimeTokenInternal without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalResponse() + ); + client.innerApiCalls.refreshRuntimeTokenInternal = stubSimpleCall(expectedResponse); + const [response] = await client.refreshRuntimeTokenInternal(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes refreshRuntimeTokenInternal without error using callback', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalResponse() + ); + client.innerApiCalls.refreshRuntimeTokenInternal = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.refreshRuntimeTokenInternal( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes refreshRuntimeTokenInternal with error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.refreshRuntimeTokenInternal = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.refreshRuntimeTokenInternal(request), expectedError); + const actualRequest = (client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes refreshRuntimeTokenInternal with closed client', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.refreshRuntimeTokenInternal(request), expectedError); + }); + }); + + describe('createRuntime', () => { + it('invokes createRuntime without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.CreateRuntimeRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createRuntime = stubLongRunningCall(expectedResponse); + const [operation] = await client.createRuntime(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createRuntime without error using callback', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.CreateRuntimeRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createRuntime = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createRuntime( + request, + (err?: Error|null, + result?: 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.createRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createRuntime with call error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.CreateRuntimeRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createRuntime = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createRuntime(request), expectedError); + const actualRequest = (client.innerApiCalls.createRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createRuntime with LRO error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.CreateRuntimeRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createRuntime = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createRuntime(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateRuntimeProgress without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateRuntimeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateRuntimeProgress with error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateRuntimeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateRuntime', () => { + it('invokes updateRuntime without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateRuntimeRequest() + ); + request.runtime ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateRuntimeRequest', ['runtime', 'name']); + request.runtime.name = defaultValue1; + const expectedHeaderRequestParams = `runtime.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateRuntime = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateRuntime(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateRuntime without error using callback', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateRuntimeRequest() + ); + request.runtime ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateRuntimeRequest', ['runtime', 'name']); + request.runtime.name = defaultValue1; + const expectedHeaderRequestParams = `runtime.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateRuntime = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateRuntime( + request, + (err?: Error|null, + result?: 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.updateRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateRuntime with call error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateRuntimeRequest() + ); + request.runtime ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateRuntimeRequest', ['runtime', 'name']); + request.runtime.name = defaultValue1; + const expectedHeaderRequestParams = `runtime.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateRuntime = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateRuntime(request), expectedError); + const actualRequest = (client.innerApiCalls.updateRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateRuntime with LRO error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateRuntimeRequest() + ); + request.runtime ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateRuntimeRequest', ['runtime', 'name']); + request.runtime.name = defaultValue1; + const expectedHeaderRequestParams = `runtime.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateRuntime = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateRuntime(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateRuntimeProgress without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateRuntimeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateRuntimeProgress with error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateRuntimeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteRuntime', () => { + it('invokes deleteRuntime without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteRuntime = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteRuntime(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteRuntime without error using callback', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteRuntime = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteRuntime( + request, + (err?: Error|null, + result?: 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.deleteRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteRuntime with call error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteRuntime = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteRuntime(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteRuntime with LRO error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteRuntime = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteRuntime(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteRuntimeProgress without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteRuntimeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteRuntimeProgress with error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteRuntimeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('startRuntime', () => { + it('invokes startRuntime without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StartRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.StartRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.startRuntime = stubLongRunningCall(expectedResponse); + const [operation] = await client.startRuntime(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.startRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startRuntime without error using callback', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StartRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.StartRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.startRuntime = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.startRuntime( + request, + (err?: Error|null, + result?: 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.startRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startRuntime with call error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StartRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.StartRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startRuntime = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.startRuntime(request), expectedError); + const actualRequest = (client.innerApiCalls.startRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startRuntime with LRO error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StartRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.StartRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startRuntime = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.startRuntime(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.startRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkStartRuntimeProgress without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkStartRuntimeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkStartRuntimeProgress with error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkStartRuntimeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('stopRuntime', () => { + it('invokes stopRuntime without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StopRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.StopRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.stopRuntime = stubLongRunningCall(expectedResponse); + const [operation] = await client.stopRuntime(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.stopRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopRuntime without error using callback', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StopRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.StopRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.stopRuntime = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.stopRuntime( + request, + (err?: Error|null, + result?: 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.stopRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopRuntime with call error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StopRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.StopRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopRuntime = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.stopRuntime(request), expectedError); + const actualRequest = (client.innerApiCalls.stopRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopRuntime with LRO error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StopRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.StopRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopRuntime = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.stopRuntime(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.stopRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkStopRuntimeProgress without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkStopRuntimeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkStopRuntimeProgress with error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkStopRuntimeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('switchRuntime', () => { + it('invokes switchRuntime without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SwitchRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.SwitchRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.switchRuntime = stubLongRunningCall(expectedResponse); + const [operation] = await client.switchRuntime(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.switchRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.switchRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes switchRuntime without error using callback', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SwitchRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.SwitchRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.switchRuntime = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.switchRuntime( + request, + (err?: Error|null, + result?: 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.switchRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.switchRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes switchRuntime with call error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SwitchRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.SwitchRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.switchRuntime = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.switchRuntime(request), expectedError); + const actualRequest = (client.innerApiCalls.switchRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.switchRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes switchRuntime with LRO error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SwitchRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.SwitchRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.switchRuntime = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.switchRuntime(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.switchRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.switchRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkSwitchRuntimeProgress without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkSwitchRuntimeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkSwitchRuntimeProgress with error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkSwitchRuntimeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('resetRuntime', () => { + it('invokes resetRuntime without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ResetRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ResetRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.resetRuntime = stubLongRunningCall(expectedResponse); + const [operation] = await client.resetRuntime(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resetRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resetRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resetRuntime without error using callback', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ResetRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ResetRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.resetRuntime = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resetRuntime( + request, + (err?: Error|null, + result?: 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.resetRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resetRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resetRuntime with call error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ResetRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ResetRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resetRuntime = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.resetRuntime(request), expectedError); + const actualRequest = (client.innerApiCalls.resetRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resetRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resetRuntime with LRO error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ResetRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ResetRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resetRuntime = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.resetRuntime(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.resetRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resetRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkResetRuntimeProgress without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkResetRuntimeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkResetRuntimeProgress with error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkResetRuntimeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('upgradeRuntime', () => { + it('invokes upgradeRuntime without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.upgradeRuntime = stubLongRunningCall(expectedResponse); + const [operation] = await client.upgradeRuntime(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.upgradeRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeRuntime without error using callback', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.upgradeRuntime = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.upgradeRuntime( + request, + (err?: Error|null, + result?: 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.upgradeRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeRuntime with call error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeRuntime = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.upgradeRuntime(request), expectedError); + const actualRequest = (client.innerApiCalls.upgradeRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeRuntime with LRO error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeRuntime = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.upgradeRuntime(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.upgradeRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpgradeRuntimeProgress without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpgradeRuntimeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpgradeRuntimeProgress with error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpgradeRuntimeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('reportRuntimeEvent', () => { + it('invokes reportRuntimeEvent without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ReportRuntimeEventRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ReportRuntimeEventRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.reportRuntimeEvent = stubLongRunningCall(expectedResponse); + const [operation] = await client.reportRuntimeEvent(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.reportRuntimeEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reportRuntimeEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reportRuntimeEvent without error using callback', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ReportRuntimeEventRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ReportRuntimeEventRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.reportRuntimeEvent = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.reportRuntimeEvent( + request, + (err?: Error|null, + result?: 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.reportRuntimeEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reportRuntimeEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reportRuntimeEvent with call error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ReportRuntimeEventRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ReportRuntimeEventRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reportRuntimeEvent = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.reportRuntimeEvent(request), expectedError); + const actualRequest = (client.innerApiCalls.reportRuntimeEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reportRuntimeEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reportRuntimeEvent with LRO error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ReportRuntimeEventRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ReportRuntimeEventRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reportRuntimeEvent = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.reportRuntimeEvent(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.reportRuntimeEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reportRuntimeEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkReportRuntimeEventProgress without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkReportRuntimeEventProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkReportRuntimeEventProgress with error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkReportRuntimeEventProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('diagnoseRuntime', () => { + it('invokes diagnoseRuntime without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DiagnoseRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.diagnoseRuntime = stubLongRunningCall(expectedResponse); + const [operation] = await client.diagnoseRuntime(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.diagnoseRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.diagnoseRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes diagnoseRuntime without error using callback', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DiagnoseRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.diagnoseRuntime = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.diagnoseRuntime( + request, + (err?: Error|null, + result?: 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.diagnoseRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.diagnoseRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes diagnoseRuntime with call error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DiagnoseRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.diagnoseRuntime = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.diagnoseRuntime(request), expectedError); + const actualRequest = (client.innerApiCalls.diagnoseRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.diagnoseRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes diagnoseRuntime with LRO error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DiagnoseRuntimeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseRuntimeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.diagnoseRuntime = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.diagnoseRuntime(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.diagnoseRuntime as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.diagnoseRuntime as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDiagnoseRuntimeProgress without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDiagnoseRuntimeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDiagnoseRuntimeProgress with error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDiagnoseRuntimeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listRuntimes', () => { + it('invokes listRuntimes without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListRuntimesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListRuntimesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + ]; + client.innerApiCalls.listRuntimes = stubSimpleCall(expectedResponse); + const [response] = await client.listRuntimes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listRuntimes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRuntimes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRuntimes without error using callback', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListRuntimesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListRuntimesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + ]; + client.innerApiCalls.listRuntimes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listRuntimes( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IRuntime[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listRuntimes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRuntimes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRuntimes with error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListRuntimesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListRuntimesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listRuntimes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listRuntimes(request), expectedError); + const actualRequest = (client.innerApiCalls.listRuntimes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRuntimes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRuntimesStream without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListRuntimesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListRuntimesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + ]; + client.descriptors.page.listRuntimes.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listRuntimesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1.Runtime[] = []; + stream.on('data', (response: protos.google.cloud.notebooks.v1.Runtime) => { + 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.listRuntimes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRuntimes, request)); + assert( + (client.descriptors.page.listRuntimes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listRuntimesStream with error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListRuntimesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListRuntimesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRuntimes.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listRuntimesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1.Runtime[] = []; + stream.on('data', (response: protos.google.cloud.notebooks.v1.Runtime) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listRuntimes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRuntimes, request)); + assert( + (client.descriptors.page.listRuntimes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listRuntimes without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListRuntimesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListRuntimesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + ]; + client.descriptors.page.listRuntimes.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.notebooks.v1.IRuntime[] = []; + const iterable = client.listRuntimesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listRuntimes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listRuntimes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listRuntimes with error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListRuntimesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListRuntimesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRuntimes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listRuntimesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.notebooks.v1.IRuntime[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listRuntimes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listRuntimes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0)); + }); + it('invokes getIamPolicy with error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0)); + }); + it('invokes setIamPolicy with error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + 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('environment', () => { + const fakePath = "/rendered/path/environment"; + const expectedParameters = { + project: "projectValue", + environment: "environmentValue", + }; + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.environmentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.environmentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('environmentPath', () => { + const result = client.environmentPath("projectValue", "environmentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.environmentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromEnvironmentName', () => { + const result = client.matchProjectFromEnvironmentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchEnvironmentFromEnvironmentName', () => { + const result = client.matchEnvironmentFromEnvironmentName(fakePath); + assert.strictEqual(result, "environmentValue"); + assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('execution', () => { + const fakePath = "/rendered/path/execution"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + execution: "executionValue", + }; + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.executionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.executionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('executionPath', () => { + const result = client.executionPath("projectValue", "locationValue", "executionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.executionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromExecutionName', () => { + const result = client.matchProjectFromExecutionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromExecutionName', () => { + const result = client.matchLocationFromExecutionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchExecutionFromExecutionName', () => { + const result = client.matchExecutionFromExecutionName(fakePath); + assert.strictEqual(result, "executionValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('instance', () => { + const fakePath = "/rendered/path/instance"; + const expectedParameters = { + project: "projectValue", + instance: "instanceValue", + }; + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.instancePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.instancePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath("projectValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + 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('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('runtime', () => { + const fakePath = "/rendered/path/runtime"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + runtime: "runtimeValue", + }; + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.runtimePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.runtimePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('runtimePath', () => { + const result = client.runtimePath("projectValue", "locationValue", "runtimeValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.runtimePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRuntimeName', () => { + const result = client.matchProjectFromRuntimeName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.runtimePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromRuntimeName', () => { + const result = client.matchLocationFromRuntimeName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.runtimePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRuntimeFromRuntimeName', () => { + const result = client.matchRuntimeFromRuntimeName(fakePath); + assert.strictEqual(result, "runtimeValue"); + assert((client.pathTemplates.runtimePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('schedule', () => { + const fakePath = "/rendered/path/schedule"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + schedule: "scheduleValue", + }; + const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.schedulePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.schedulePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('schedulePath', () => { + const result = client.schedulePath("projectValue", "locationValue", "scheduleValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.schedulePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromScheduleName', () => { + const result = client.matchProjectFromScheduleName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.schedulePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromScheduleName', () => { + const result = client.matchLocationFromScheduleName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.schedulePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchScheduleFromScheduleName', () => { + const result = client.matchScheduleFromScheduleName(fakePath); + assert.strictEqual(result, "scheduleValue"); + assert((client.pathTemplates.schedulePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/test/gapic_notebook_service_v1.ts b/owl-bot-staging/google-cloud-notebooks/v1/test/gapic_notebook_service_v1.ts new file mode 100644 index 00000000000..aa5feafcbb0 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/test/gapic_notebook_service_v1.ts @@ -0,0 +1,6405 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 notebookserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.NotebookServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = notebookserviceModule.v1.NotebookServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = notebookserviceModule.v1.NotebookServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = notebookserviceModule.v1.NotebookServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new notebookserviceModule.v1.NotebookServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.notebookServiceStub, undefined); + await client.initialize(); + assert(client.notebookServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.notebookServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.notebookServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new notebookserviceModule.v1.NotebookServiceClient({ + 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 notebookserviceModule.v1.NotebookServiceClient({ + 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('getInstance', () => { + it('invokes getInstance without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.Instance() + ); + client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); + const [response] = await client.getInstance(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstance without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.Instance() + ); + client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstance( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IInstance|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstance with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstance with closed client', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getInstance(request), expectedError); + }); + }); + + describe('updateInstanceMetadataItems', () => { + it('invokes updateInstanceMetadataItems without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsResponse() + ); + client.innerApiCalls.updateInstanceMetadataItems = stubSimpleCall(expectedResponse); + const [response] = await client.updateInstanceMetadataItems(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateInstanceMetadataItems as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceMetadataItems as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstanceMetadataItems without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsResponse() + ); + client.innerApiCalls.updateInstanceMetadataItems = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateInstanceMetadataItems( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateInstanceMetadataItems as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceMetadataItems as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstanceMetadataItems with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstanceMetadataItems = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateInstanceMetadataItems(request), expectedError); + const actualRequest = (client.innerApiCalls.updateInstanceMetadataItems as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceMetadataItems as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstanceMetadataItems with closed client', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateInstanceMetadataItems(request), expectedError); + }); + }); + + describe('isInstanceUpgradeable', () => { + it('invokes isInstanceUpgradeable without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest', ['notebookInstance']); + request.notebookInstance = defaultValue1; + const expectedHeaderRequestParams = `notebook_instance=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableResponse() + ); + client.innerApiCalls.isInstanceUpgradeable = stubSimpleCall(expectedResponse); + const [response] = await client.isInstanceUpgradeable(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes isInstanceUpgradeable without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest', ['notebookInstance']); + request.notebookInstance = defaultValue1; + const expectedHeaderRequestParams = `notebook_instance=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableResponse() + ); + client.innerApiCalls.isInstanceUpgradeable = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.isInstanceUpgradeable( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes isInstanceUpgradeable with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest', ['notebookInstance']); + request.notebookInstance = defaultValue1; + const expectedHeaderRequestParams = `notebook_instance=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.isInstanceUpgradeable = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.isInstanceUpgradeable(request), expectedError); + const actualRequest = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes isInstanceUpgradeable with closed client', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest', ['notebookInstance']); + request.notebookInstance = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.isInstanceUpgradeable(request), expectedError); + }); + }); + + describe('getInstanceHealth', () => { + it('invokes getInstanceHealth without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetInstanceHealthRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceHealthRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetInstanceHealthResponse() + ); + client.innerApiCalls.getInstanceHealth = stubSimpleCall(expectedResponse); + const [response] = await client.getInstanceHealth(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstanceHealth as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstanceHealth as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstanceHealth without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetInstanceHealthRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceHealthRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetInstanceHealthResponse() + ); + client.innerApiCalls.getInstanceHealth = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstanceHealth( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstanceHealth as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstanceHealth as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstanceHealth with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetInstanceHealthRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceHealthRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstanceHealth = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getInstanceHealth(request), expectedError); + const actualRequest = (client.innerApiCalls.getInstanceHealth as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstanceHealth as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstanceHealth with closed client', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetInstanceHealthRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceHealthRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getInstanceHealth(request), expectedError); + }); + }); + + describe('getEnvironment', () => { + it('invokes getEnvironment without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.Environment() + ); + client.innerApiCalls.getEnvironment = stubSimpleCall(expectedResponse); + const [response] = await client.getEnvironment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEnvironment without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.Environment() + ); + client.innerApiCalls.getEnvironment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getEnvironment( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IEnvironment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEnvironment with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getEnvironment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getEnvironment(request), expectedError); + const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEnvironment with closed client', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getEnvironment(request), expectedError); + }); + }); + + describe('getSchedule', () => { + it('invokes getSchedule without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetScheduleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetScheduleRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.Schedule() + ); + client.innerApiCalls.getSchedule = stubSimpleCall(expectedResponse); + const [response] = await client.getSchedule(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getSchedule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSchedule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSchedule without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetScheduleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetScheduleRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.Schedule() + ); + client.innerApiCalls.getSchedule = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSchedule( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v1.ISchedule|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getSchedule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSchedule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSchedule with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetScheduleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetScheduleRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getSchedule = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getSchedule(request), expectedError); + const actualRequest = (client.innerApiCalls.getSchedule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSchedule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSchedule with closed client', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetScheduleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetScheduleRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getSchedule(request), expectedError); + }); + }); + + describe('getExecution', () => { + it('invokes getExecution without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetExecutionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetExecutionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.Execution() + ); + client.innerApiCalls.getExecution = stubSimpleCall(expectedResponse); + const [response] = await client.getExecution(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getExecution as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getExecution as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getExecution without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetExecutionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetExecutionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.Execution() + ); + client.innerApiCalls.getExecution = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getExecution( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IExecution|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getExecution as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getExecution as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getExecution with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetExecutionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetExecutionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getExecution = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getExecution(request), expectedError); + const actualRequest = (client.innerApiCalls.getExecution as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getExecution as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getExecution with closed client', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetExecutionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.GetExecutionRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getExecution(request), expectedError); + }); + }); + + describe('createInstance', () => { + it('invokes createInstance without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.createInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstance without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createInstance( + request, + (err?: Error|null, + result?: 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.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstance with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstance with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('registerInstance', () => { + it('invokes registerInstance without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RegisterInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.RegisterInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.registerInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.registerInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.registerInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes registerInstance without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RegisterInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.RegisterInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.registerInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.registerInstance( + request, + (err?: Error|null, + result?: 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.registerInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes registerInstance with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RegisterInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.RegisterInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.registerInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.registerInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.registerInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes registerInstance with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RegisterInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.RegisterInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.registerInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.registerInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.registerInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkRegisterInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRegisterInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRegisterInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRegisterInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('setInstanceAccelerator', () => { + it('invokes setInstanceAccelerator without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall(expectedResponse); + const [operation] = await client.setInstanceAccelerator(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setInstanceAccelerator as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceAccelerator without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setInstanceAccelerator = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInstanceAccelerator( + request, + (err?: Error|null, + result?: 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.setInstanceAccelerator as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceAccelerator with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.setInstanceAccelerator(request), expectedError); + const actualRequest = (client.innerApiCalls.setInstanceAccelerator as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceAccelerator with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.setInstanceAccelerator(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.setInstanceAccelerator as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkSetInstanceAcceleratorProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkSetInstanceAcceleratorProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkSetInstanceAcceleratorProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkSetInstanceAcceleratorProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('setInstanceMachineType', () => { + it('invokes setInstanceMachineType without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setInstanceMachineType = stubLongRunningCall(expectedResponse); + const [operation] = await client.setInstanceMachineType(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setInstanceMachineType as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceMachineType without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setInstanceMachineType = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInstanceMachineType( + request, + (err?: Error|null, + result?: 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.setInstanceMachineType as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceMachineType with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceMachineType = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.setInstanceMachineType(request), expectedError); + const actualRequest = (client.innerApiCalls.setInstanceMachineType as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceMachineType with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceMachineType = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.setInstanceMachineType(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.setInstanceMachineType as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkSetInstanceMachineTypeProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkSetInstanceMachineTypeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkSetInstanceMachineTypeProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkSetInstanceMachineTypeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateInstanceConfig', () => { + it('invokes updateInstanceConfig without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateInstanceConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateInstanceConfig = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateInstanceConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstanceConfig without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateInstanceConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateInstanceConfig = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateInstanceConfig( + request, + (err?: Error|null, + result?: 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.updateInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstanceConfig with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateInstanceConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstanceConfig = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateInstanceConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.updateInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstanceConfig with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateInstanceConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstanceConfig = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateInstanceConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateInstanceConfigProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateInstanceConfigProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateInstanceConfigProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateInstanceConfigProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateShieldedInstanceConfig', () => { + it('invokes updateShieldedInstanceConfig without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateShieldedInstanceConfig = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateShieldedInstanceConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateShieldedInstanceConfig without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateShieldedInstanceConfig = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateShieldedInstanceConfig( + request, + (err?: Error|null, + result?: 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.updateShieldedInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateShieldedInstanceConfig with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateShieldedInstanceConfig = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateShieldedInstanceConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateShieldedInstanceConfig with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateShieldedInstanceConfig = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateShieldedInstanceConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateShieldedInstanceConfigProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateShieldedInstanceConfigProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateShieldedInstanceConfigProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateShieldedInstanceConfigProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('setInstanceLabels', () => { + it('invokes setInstanceLabels without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceLabelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceLabelsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setInstanceLabels = stubLongRunningCall(expectedResponse); + const [operation] = await client.setInstanceLabels(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setInstanceLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceLabels without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceLabelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceLabelsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setInstanceLabels = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInstanceLabels( + request, + (err?: Error|null, + result?: 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.setInstanceLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceLabels with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceLabelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceLabelsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceLabels = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.setInstanceLabels(request), expectedError); + const actualRequest = (client.innerApiCalls.setInstanceLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceLabels with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceLabelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceLabelsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceLabels = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.setInstanceLabels(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.setInstanceLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkSetInstanceLabelsProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkSetInstanceLabelsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkSetInstanceLabelsProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkSetInstanceLabelsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteInstance', () => { + it('invokes deleteInstance without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstance without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteInstance( + request, + (err?: Error|null, + result?: 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.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstance with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstance with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('startInstance', () => { + it('invokes startInstance without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StartInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.StartInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.startInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.startInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startInstance without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StartInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.StartInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.startInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.startInstance( + request, + (err?: Error|null, + result?: 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.startInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startInstance with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StartInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.StartInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.startInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startInstance with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StartInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.StartInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.startInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkStartInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkStartInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkStartInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkStartInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('stopInstance', () => { + it('invokes stopInstance without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StopInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.StopInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.stopInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.stopInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopInstance without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StopInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.StopInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.stopInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.stopInstance( + request, + (err?: Error|null, + result?: 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.stopInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopInstance with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StopInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.StopInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.stopInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopInstance with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StopInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.StopInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.stopInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkStopInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkStopInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkStopInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkStopInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('resetInstance', () => { + it('invokes resetInstance without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ResetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ResetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.resetInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.resetInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resetInstance without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ResetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ResetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.resetInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resetInstance( + request, + (err?: Error|null, + result?: 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.resetInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resetInstance with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ResetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ResetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resetInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.resetInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resetInstance with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ResetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ResetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resetInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.resetInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkResetInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkResetInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkResetInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkResetInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('reportInstanceInfo', () => { + it('invokes reportInstanceInfo without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ReportInstanceInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ReportInstanceInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.reportInstanceInfo = stubLongRunningCall(expectedResponse); + const [operation] = await client.reportInstanceInfo(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.reportInstanceInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reportInstanceInfo without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ReportInstanceInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ReportInstanceInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.reportInstanceInfo = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.reportInstanceInfo( + request, + (err?: Error|null, + result?: 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.reportInstanceInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reportInstanceInfo with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ReportInstanceInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ReportInstanceInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reportInstanceInfo = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.reportInstanceInfo(request), expectedError); + const actualRequest = (client.innerApiCalls.reportInstanceInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reportInstanceInfo with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ReportInstanceInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ReportInstanceInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reportInstanceInfo = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.reportInstanceInfo(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.reportInstanceInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkReportInstanceInfoProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkReportInstanceInfoProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkReportInstanceInfoProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkReportInstanceInfoProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('upgradeInstance', () => { + it('invokes upgradeInstance without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.upgradeInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.upgradeInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeInstance without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.upgradeInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.upgradeInstance( + request, + (err?: Error|null, + result?: 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.upgradeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeInstance with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.upgradeInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeInstance with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.upgradeInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpgradeInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpgradeInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpgradeInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpgradeInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('rollbackInstance', () => { + it('invokes rollbackInstance without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RollbackInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.RollbackInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.rollbackInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.rollbackInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.rollbackInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rollbackInstance without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RollbackInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.RollbackInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.rollbackInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rollbackInstance( + request, + (err?: Error|null, + result?: 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.rollbackInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rollbackInstance with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RollbackInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.RollbackInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rollbackInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.rollbackInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.rollbackInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rollbackInstance with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RollbackInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.RollbackInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rollbackInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.rollbackInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.rollbackInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkRollbackInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRollbackInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRollbackInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRollbackInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('diagnoseInstance', () => { + it('invokes diagnoseInstance without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DiagnoseInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.diagnoseInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.diagnoseInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.diagnoseInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes diagnoseInstance without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DiagnoseInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.diagnoseInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.diagnoseInstance( + request, + (err?: Error|null, + result?: 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.diagnoseInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes diagnoseInstance with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DiagnoseInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.diagnoseInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.diagnoseInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.diagnoseInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes diagnoseInstance with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DiagnoseInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.diagnoseInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.diagnoseInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.diagnoseInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDiagnoseInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDiagnoseInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDiagnoseInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDiagnoseInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('upgradeInstanceInternal', () => { + it('invokes upgradeInstanceInternal without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall(expectedResponse); + const [operation] = await client.upgradeInstanceInternal(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeInstanceInternal without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.upgradeInstanceInternal( + request, + (err?: Error|null, + result?: 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.upgradeInstanceInternal as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeInstanceInternal with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.upgradeInstanceInternal(request), expectedError); + const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeInstanceInternal with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.upgradeInstanceInternal(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpgradeInstanceInternalProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpgradeInstanceInternalProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpgradeInstanceInternalProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpgradeInstanceInternalProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('createEnvironment', () => { + it('invokes createEnvironment without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.CreateEnvironmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createEnvironment = stubLongRunningCall(expectedResponse); + const [operation] = await client.createEnvironment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createEnvironment without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.CreateEnvironmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createEnvironment = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createEnvironment( + request, + (err?: Error|null, + result?: 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.createEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createEnvironment with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.CreateEnvironmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEnvironment = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createEnvironment(request), expectedError); + const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createEnvironment with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.CreateEnvironmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEnvironment = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createEnvironment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateEnvironmentProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateEnvironmentProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateEnvironmentProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateEnvironmentProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteEnvironment', () => { + it('invokes deleteEnvironment without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteEnvironment = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteEnvironment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteEnvironment without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteEnvironment = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteEnvironment( + request, + (err?: Error|null, + result?: 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.deleteEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteEnvironment with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteEnvironment = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteEnvironment(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteEnvironment with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteEnvironment = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteEnvironment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteEnvironmentProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteEnvironmentProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteEnvironmentProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteEnvironmentProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteSchedule', () => { + it('invokes deleteSchedule without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteScheduleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteScheduleRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteSchedule = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteSchedule(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteSchedule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSchedule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSchedule without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteScheduleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteScheduleRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteSchedule = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteSchedule( + request, + (err?: Error|null, + result?: 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.deleteSchedule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSchedule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSchedule with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteScheduleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteScheduleRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSchedule = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteSchedule(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteSchedule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSchedule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSchedule with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteScheduleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteScheduleRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSchedule = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteSchedule(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteSchedule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSchedule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteScheduleProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteScheduleProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteScheduleProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteScheduleProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('createSchedule', () => { + it('invokes createSchedule without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateScheduleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.CreateScheduleRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createSchedule = stubLongRunningCall(expectedResponse); + const [operation] = await client.createSchedule(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createSchedule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSchedule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSchedule without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateScheduleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.CreateScheduleRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createSchedule = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createSchedule( + request, + (err?: Error|null, + result?: 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.createSchedule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSchedule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSchedule with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateScheduleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.CreateScheduleRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSchedule = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createSchedule(request), expectedError); + const actualRequest = (client.innerApiCalls.createSchedule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSchedule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSchedule with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateScheduleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.CreateScheduleRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSchedule = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createSchedule(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createSchedule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSchedule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateScheduleProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateScheduleProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateScheduleProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateScheduleProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('triggerSchedule', () => { + it('invokes triggerSchedule without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.TriggerScheduleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.TriggerScheduleRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.triggerSchedule = stubLongRunningCall(expectedResponse); + const [operation] = await client.triggerSchedule(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.triggerSchedule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.triggerSchedule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes triggerSchedule without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.TriggerScheduleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.TriggerScheduleRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.triggerSchedule = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.triggerSchedule( + request, + (err?: Error|null, + result?: 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.triggerSchedule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.triggerSchedule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes triggerSchedule with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.TriggerScheduleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.TriggerScheduleRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.triggerSchedule = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.triggerSchedule(request), expectedError); + const actualRequest = (client.innerApiCalls.triggerSchedule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.triggerSchedule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes triggerSchedule with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.TriggerScheduleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.TriggerScheduleRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.triggerSchedule = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.triggerSchedule(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.triggerSchedule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.triggerSchedule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkTriggerScheduleProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkTriggerScheduleProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkTriggerScheduleProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkTriggerScheduleProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteExecution', () => { + it('invokes deleteExecution without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteExecutionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteExecutionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteExecution = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteExecution(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteExecution as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteExecution as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteExecution without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteExecutionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteExecutionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteExecution = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteExecution( + request, + (err?: Error|null, + result?: 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.deleteExecution as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteExecution as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteExecution with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteExecutionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteExecutionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteExecution = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteExecution(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteExecution as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteExecution as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteExecution with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteExecutionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteExecutionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteExecution = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteExecution(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteExecution as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteExecution as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteExecutionProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteExecutionProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteExecutionProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteExecutionProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('createExecution', () => { + it('invokes createExecution without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateExecutionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.CreateExecutionRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createExecution = stubLongRunningCall(expectedResponse); + const [operation] = await client.createExecution(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createExecution as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createExecution as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createExecution without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateExecutionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.CreateExecutionRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createExecution = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createExecution( + request, + (err?: Error|null, + result?: 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.createExecution as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createExecution as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createExecution with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateExecutionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.CreateExecutionRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createExecution = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createExecution(request), expectedError); + const actualRequest = (client.innerApiCalls.createExecution as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createExecution as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createExecution with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateExecutionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.CreateExecutionRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createExecution = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createExecution(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createExecution as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createExecution as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateExecutionProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateExecutionProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateExecutionProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateExecutionProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listInstances', () => { + it('invokes listInstances without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + ]; + client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); + const [response] = await client.listInstances(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstances without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + ]; + client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstances( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IInstance[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstances with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listInstances(request), expectedError); + const actualRequest = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstancesStream without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + ]; + client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1.Instance[] = []; + stream.on('data', (response: protos.google.cloud.notebooks.v1.Instance) => { + 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.listInstances.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listInstancesStream with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1.Instance[] = []; + stream.on('data', (response: protos.google.cloud.notebooks.v1.Instance) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstances without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + ]; + client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.notebooks.v1.IInstance[] = []; + const iterable = client.listInstancesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstances with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInstancesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.notebooks.v1.IInstance[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listEnvironments', () => { + it('invokes listEnvironments without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), + ]; + client.innerApiCalls.listEnvironments = stubSimpleCall(expectedResponse); + const [response] = await client.listEnvironments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listEnvironments without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), + ]; + client.innerApiCalls.listEnvironments = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listEnvironments( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IEnvironment[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listEnvironments with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listEnvironments = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listEnvironments(request), expectedError); + const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listEnvironmentsStream without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), + ]; + client.descriptors.page.listEnvironments.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listEnvironmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1.Environment[] = []; + stream.on('data', (response: protos.google.cloud.notebooks.v1.Environment) => { + 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.listEnvironments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listEnvironments, request)); + assert( + (client.descriptors.page.listEnvironments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listEnvironmentsStream with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEnvironments.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listEnvironmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1.Environment[] = []; + stream.on('data', (response: protos.google.cloud.notebooks.v1.Environment) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listEnvironments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listEnvironments, request)); + assert( + (client.descriptors.page.listEnvironments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listEnvironments without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), + ]; + client.descriptors.page.listEnvironments.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.notebooks.v1.IEnvironment[] = []; + const iterable = client.listEnvironmentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listEnvironments with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEnvironments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listEnvironmentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.notebooks.v1.IEnvironment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listSchedules', () => { + it('invokes listSchedules without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListSchedulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListSchedulesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + ]; + client.innerApiCalls.listSchedules = stubSimpleCall(expectedResponse); + const [response] = await client.listSchedules(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listSchedules as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSchedules as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSchedules without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListSchedulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListSchedulesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + ]; + client.innerApiCalls.listSchedules = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listSchedules( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v1.ISchedule[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listSchedules as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSchedules as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSchedules with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListSchedulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListSchedulesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listSchedules = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listSchedules(request), expectedError); + const actualRequest = (client.innerApiCalls.listSchedules as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSchedules as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSchedulesStream without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListSchedulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListSchedulesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + ]; + client.descriptors.page.listSchedules.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listSchedulesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1.Schedule[] = []; + stream.on('data', (response: protos.google.cloud.notebooks.v1.Schedule) => { + 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.listSchedules.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listSchedules, request)); + assert( + (client.descriptors.page.listSchedules.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listSchedulesStream with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListSchedulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListSchedulesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSchedules.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listSchedulesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1.Schedule[] = []; + stream.on('data', (response: protos.google.cloud.notebooks.v1.Schedule) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listSchedules.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listSchedules, request)); + assert( + (client.descriptors.page.listSchedules.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listSchedules without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListSchedulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListSchedulesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + ]; + client.descriptors.page.listSchedules.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.notebooks.v1.ISchedule[] = []; + const iterable = client.listSchedulesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listSchedules.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listSchedules.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listSchedules with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListSchedulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListSchedulesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSchedules.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listSchedulesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.notebooks.v1.ISchedule[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listSchedules.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listSchedules.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listExecutions', () => { + it('invokes listExecutions without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListExecutionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListExecutionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + ]; + client.innerApiCalls.listExecutions = stubSimpleCall(expectedResponse); + const [response] = await client.listExecutions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listExecutions without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListExecutionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListExecutionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + ]; + client.innerApiCalls.listExecutions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listExecutions( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IExecution[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listExecutions with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListExecutionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListExecutionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listExecutions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listExecutions(request), expectedError); + const actualRequest = (client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listExecutionsStream without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListExecutionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListExecutionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + ]; + client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listExecutionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1.Execution[] = []; + stream.on('data', (response: protos.google.cloud.notebooks.v1.Execution) => { + 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.listExecutions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); + assert( + (client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listExecutionsStream with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListExecutionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListExecutionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listExecutionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1.Execution[] = []; + stream.on('data', (response: protos.google.cloud.notebooks.v1.Execution) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); + assert( + (client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listExecutions without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListExecutionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListExecutionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + ]; + client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.notebooks.v1.IExecution[] = []; + const iterable = client.listExecutionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listExecutions with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListExecutionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1.ListExecutionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listExecutionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.notebooks.v1.IExecution[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0)); + }); + it('invokes getIamPolicy with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0)); + }); + it('invokes setIamPolicy with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + 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 notebookserviceModule.v1.NotebookServiceClient({ + 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 notebookserviceModule.v1.NotebookServiceClient({ + 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 notebookserviceModule.v1.NotebookServiceClient({ + 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 notebookserviceModule.v1.NotebookServiceClient({ + 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 notebookserviceModule.v1.NotebookServiceClient({ + 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 notebookserviceModule.v1.NotebookServiceClient({ + 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 notebookserviceModule.v1.NotebookServiceClient({ + 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 notebookserviceModule.v1.NotebookServiceClient({ + 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 notebookserviceModule.v1.NotebookServiceClient({ + 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 notebookserviceModule.v1.NotebookServiceClient({ + 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 notebookserviceModule.v1.NotebookServiceClient({ + 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 notebookserviceModule.v1.NotebookServiceClient({ + 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 notebookserviceModule.v1.NotebookServiceClient({ + 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 notebookserviceModule.v1.NotebookServiceClient({ + 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 notebookserviceModule.v1.NotebookServiceClient({ + 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('environment', () => { + const fakePath = "/rendered/path/environment"; + const expectedParameters = { + project: "projectValue", + environment: "environmentValue", + }; + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.environmentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.environmentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('environmentPath', () => { + const result = client.environmentPath("projectValue", "environmentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.environmentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromEnvironmentName', () => { + const result = client.matchProjectFromEnvironmentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchEnvironmentFromEnvironmentName', () => { + const result = client.matchEnvironmentFromEnvironmentName(fakePath); + assert.strictEqual(result, "environmentValue"); + assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('execution', () => { + const fakePath = "/rendered/path/execution"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + execution: "executionValue", + }; + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.executionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.executionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('executionPath', () => { + const result = client.executionPath("projectValue", "locationValue", "executionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.executionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromExecutionName', () => { + const result = client.matchProjectFromExecutionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromExecutionName', () => { + const result = client.matchLocationFromExecutionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchExecutionFromExecutionName', () => { + const result = client.matchExecutionFromExecutionName(fakePath); + assert.strictEqual(result, "executionValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('instance', () => { + const fakePath = "/rendered/path/instance"; + const expectedParameters = { + project: "projectValue", + instance: "instanceValue", + }; + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.instancePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.instancePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath("projectValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('runtime', () => { + const fakePath = "/rendered/path/runtime"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + runtime: "runtimeValue", + }; + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.runtimePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.runtimePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('runtimePath', () => { + const result = client.runtimePath("projectValue", "locationValue", "runtimeValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.runtimePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRuntimeName', () => { + const result = client.matchProjectFromRuntimeName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.runtimePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromRuntimeName', () => { + const result = client.matchLocationFromRuntimeName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.runtimePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRuntimeFromRuntimeName', () => { + const result = client.matchRuntimeFromRuntimeName(fakePath); + assert.strictEqual(result, "runtimeValue"); + assert((client.pathTemplates.runtimePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('schedule', () => { + const fakePath = "/rendered/path/schedule"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + schedule: "scheduleValue", + }; + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.schedulePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.schedulePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('schedulePath', () => { + const result = client.schedulePath("projectValue", "locationValue", "scheduleValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.schedulePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromScheduleName', () => { + const result = client.matchProjectFromScheduleName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.schedulePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromScheduleName', () => { + const result = client.matchLocationFromScheduleName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.schedulePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchScheduleFromScheduleName', () => { + const result = client.matchScheduleFromScheduleName(fakePath); + assert.strictEqual(result, "scheduleValue"); + assert((client.pathTemplates.schedulePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/tsconfig.json b/owl-bot-staging/google-cloud-notebooks/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/webpack.config.js b/owl-bot-staging/google-cloud-notebooks/v1/webpack.config.js new file mode 100644 index 00000000000..8b93a8e29df --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'ManagedNotebookService', + filename: './managed-notebook-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-notebooks/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-notebooks/v1beta1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-notebooks/v1beta1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/.gitignore b/owl-bot-staging/google-cloud-notebooks/v1beta1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/.jsdoc.js new file mode 100644 index 00000000000..b562faf1159 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/.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/notebooks', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/.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-notebooks/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/.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-notebooks/v1beta1/README.md b/owl-bot-staging/google-cloud-notebooks/v1beta1/README.md new file mode 100644 index 00000000000..31cec215a8f --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/README.md @@ -0,0 +1 @@ +Notebooks: Nodejs Client diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/package.json b/owl-bot-staging/google-cloud-notebooks/v1beta1/package.json new file mode 100644 index 00000000000..c3911a749c3 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/notebooks", + "version": "0.1.0", + "description": "Notebooks client for Node.js", + "repository": "googleapis/nodejs-notebooks", + "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 notebooks", + "notebooks", + "notebook service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/environment.proto b/owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/environment.proto new file mode 100644 index 00000000000..abe75507305 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/environment.proto @@ -0,0 +1,96 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.notebooks.v1beta1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Notebooks.V1Beta1"; +option go_package = "cloud.google.com/go/notebooks/apiv1beta1/notebookspb;notebookspb"; +option java_multiple_files = true; +option java_outer_classname = "EnvironmentProto"; +option java_package = "com.google.cloud.notebooks.v1beta1"; +option php_namespace = "Google\\Cloud\\Notebooks\\V1beta1"; +option ruby_package = "Google::Cloud::Notebooks::V1beta1"; + +// Definition of a software environment that is used to start a notebook +// instance. +message Environment { + option (google.api.resource) = { + type: "notebooks.googleapis.com/Environment" + pattern: "projects/{project}/environments/{environment}" + }; + + // Output only. Name of this environment. + // Format: + // `projects/{project_id}/locations/{location}/environments/{environment_id}` + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Display name of this environment for the UI. + string display_name = 2; + + // A brief description of this environment. + string description = 3; + + // Type of the environment; can be one of VM image, or container image. + oneof image_type { + // Use a Compute Engine VM image to start the notebook instance. + VmImage vm_image = 6; + + // Use a container image to start the notebook instance. + ContainerImage container_image = 7; + } + + // Path to a Bash script that automatically runs after a notebook instance + // fully boots up. The path must be a URL or + // Cloud Storage path. Example: `"gs://path-to-file/file-name"` + string post_startup_script = 8; + + // Output only. The time at which this environment was created. + google.protobuf.Timestamp create_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Definition of a custom Compute Engine virtual machine image for starting a +// notebook instance with the environment installed directly on the VM. +message VmImage { + // Required. The name of the Google Cloud project that this VM image belongs to. + // Format: `projects/{project_id}` + string project = 1 [(google.api.field_behavior) = REQUIRED]; + + // The reference to an external Compute Engine VM image. + oneof image { + // Use VM image name to find the image. + string image_name = 2; + + // Use this VM image family to find the image; the newest image in this + // family will be used. + string image_family = 3; + } +} + +// Definition of a container image for starting a notebook instance with the +// environment installed in a container. +message ContainerImage { + // Required. The path to the container image repository. For example: + // `gcr.io/{project_id}/{image_name}` + string repository = 1 [(google.api.field_behavior) = REQUIRED]; + + // The tag of the container image. If not specified, this defaults + // to the latest tag. + string tag = 2; +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/instance.proto b/owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/instance.proto new file mode 100644 index 00000000000..123ace8c1a1 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/instance.proto @@ -0,0 +1,333 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.notebooks.v1beta1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/notebooks/v1beta1/environment.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Notebooks.V1Beta1"; +option go_package = "cloud.google.com/go/notebooks/apiv1beta1/notebookspb;notebookspb"; +option java_multiple_files = true; +option java_outer_classname = "InstanceProto"; +option java_package = "com.google.cloud.notebooks.v1beta1"; +option php_namespace = "Google\\Cloud\\Notebooks\\V1beta1"; +option ruby_package = "Google::Cloud::Notebooks::V1beta1"; + +// Reservation Affinity for consuming Zonal reservation. +message ReservationAffinity { + // Indicates whether to consume capacity from an reservation or not. + enum Type { + // Default type. + TYPE_UNSPECIFIED = 0; + + // Do not consume from any allocated capacity. + NO_RESERVATION = 1; + + // Consume any reservation available. + ANY_RESERVATION = 2; + + // Must consume from a specific reservation. Must specify key value fields + // for specifying the reservations. + SPECIFIC_RESERVATION = 3; + } + + // Optional. Type of reservation to consume + Type consume_reservation_type = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Corresponds to the label key of reservation resource. + string key = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Corresponds to the label values of reservation resource. + repeated string values = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The definition of a notebook instance. +message Instance { + option (google.api.resource) = { + type: "notebooks.googleapis.com/Instance" + pattern: "projects/{project}/instances/{instance}" + }; + + // Definition of the types of hardware accelerators that can be used on this + // instance. + enum AcceleratorType { + // Accelerator type is not specified. + ACCELERATOR_TYPE_UNSPECIFIED = 0; + + // Accelerator type is Nvidia Tesla K80. + NVIDIA_TESLA_K80 = 1; + + // Accelerator type is Nvidia Tesla P100. + NVIDIA_TESLA_P100 = 2; + + // Accelerator type is Nvidia Tesla V100. + NVIDIA_TESLA_V100 = 3; + + // Accelerator type is Nvidia Tesla P4. + NVIDIA_TESLA_P4 = 4; + + // Accelerator type is Nvidia Tesla T4. + NVIDIA_TESLA_T4 = 5; + + // Accelerator type is NVIDIA Tesla T4 Virtual Workstations. + NVIDIA_TESLA_T4_VWS = 8; + + // Accelerator type is NVIDIA Tesla P100 Virtual Workstations. + NVIDIA_TESLA_P100_VWS = 9; + + // Accelerator type is NVIDIA Tesla P4 Virtual Workstations. + NVIDIA_TESLA_P4_VWS = 10; + + // (Coming soon) Accelerator type is TPU V2. + TPU_V2 = 6; + + // (Coming soon) Accelerator type is TPU V3. + TPU_V3 = 7; + } + + // Definition of a hardware accelerator. Note that not all combinations + // of `type` and `core_count` are valid. Check [GPUs on Compute + // Engine](https://cloud.google.com/compute/docs/gpus/#gpus-list) to find a + // valid combination. TPUs are not supported. + message AcceleratorConfig { + // Type of this accelerator. + AcceleratorType type = 1; + + // Count of cores of this accelerator. + int64 core_count = 2; + } + + // The definition of the states of this instance. + enum State { + // State is not specified. + STATE_UNSPECIFIED = 0; + + // The control logic is starting the instance. + STARTING = 1; + + // The control logic is installing required frameworks and registering the + // instance with notebook proxy + PROVISIONING = 2; + + // The instance is running. + ACTIVE = 3; + + // The control logic is stopping the instance. + STOPPING = 4; + + // The instance is stopped. + STOPPED = 5; + + // The instance is deleted. + DELETED = 6; + + // The instance is upgrading. + UPGRADING = 7; + + // The instance is being created. + INITIALIZING = 8; + + // The instance is getting registered. + REGISTERING = 9; + + // The instance is suspending. + SUSPENDING = 10; + + // The instance is suspended. + SUSPENDED = 11; + } + + // Possible disk types for notebook instances. + enum DiskType { + // Disk type not set. + DISK_TYPE_UNSPECIFIED = 0; + + // Standard persistent disk type. + PD_STANDARD = 1; + + // SSD persistent disk type. + PD_SSD = 2; + + // Balanced persistent disk type. + PD_BALANCED = 3; + } + + // Definition of the disk encryption options. + enum DiskEncryption { + // Disk encryption is not specified. + DISK_ENCRYPTION_UNSPECIFIED = 0; + + // Use Google managed encryption keys to encrypt the boot disk. + GMEK = 1; + + // Use customer managed encryption keys to encrypt the boot disk. + CMEK = 2; + } + + // The type of vNIC driver. + enum NicType { + // No type specified. Default should be UNSPECIFIED_NIC_TYPE. + UNSPECIFIED_NIC_TYPE = 0; + + // VIRTIO. Default in Notebooks DLVM. + VIRTIO_NET = 1; + + // GVNIC. Alternative to VIRTIO. + // https://github.com/GoogleCloudPlatform/compute-virtual-ethernet-linux + GVNIC = 2; + } + + // Output only. The name of this notebook instance. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Type of the environment; can be one of VM image, or container image. + oneof environment { + // Use a Compute Engine VM image to start the notebook instance. + VmImage vm_image = 2; + + // Use a container image to start the notebook instance. + ContainerImage container_image = 3; + } + + // Path to a Bash script that automatically runs after a notebook instance + // fully boots up. The path must be a URL or + // Cloud Storage path (`gs://path-to-file/file-name`). + string post_startup_script = 4; + + // Output only. The proxy endpoint that is used to access the Jupyter notebook. + string proxy_uri = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Input only. The owner of this instance after creation. Format: `alias@example.com` + // + // Currently supports one owner only. If not specified, all of the service + // account users of your VM instance's service account can use + // the instance. + repeated string instance_owners = 6 [(google.api.field_behavior) = INPUT_ONLY]; + + // The service account on this instance, giving access to other Google + // Cloud services. + // You can use any service account within the same project, but you + // must have the service account user permission to use the instance. + // + // If not specified, the [Compute Engine default service + // account](https://cloud.google.com/compute/docs/access/service-accounts#default_service_account) + // is used. + string service_account = 7; + + // Required. The [Compute Engine machine + // type](https://cloud.google.com/compute/docs/machine-types) of this + // instance. + string machine_type = 8 [(google.api.field_behavior) = REQUIRED]; + + // The hardware accelerator used on this instance. If you use + // accelerators, make sure that your configuration has + // [enough vCPUs and memory to support the `machine_type` you have + // selected](https://cloud.google.com/compute/docs/gpus/#gpus-list). + AcceleratorConfig accelerator_config = 9; + + // Output only. The state of this instance. + State state = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Whether the end user authorizes Google Cloud to install GPU driver + // on this instance. + // If this field is empty or set to false, the GPU driver won't be installed. + // Only applicable to instances with GPUs. + bool install_gpu_driver = 11; + + // Specify a custom Cloud Storage path where the GPU driver is stored. + // If not specified, we'll automatically choose from official GPU drivers. + string custom_gpu_driver_path = 12; + + // Input only. The type of the boot disk attached to this instance, defaults to + // standard persistent disk (`PD_STANDARD`). + DiskType boot_disk_type = 13 [(google.api.field_behavior) = INPUT_ONLY]; + + // Input only. The size of the boot disk in GB attached to this instance, up to a maximum + // of 64000 GB (64 TB). The minimum recommended value is 100 GB. If not + // specified, this defaults to 100. + int64 boot_disk_size_gb = 14 [(google.api.field_behavior) = INPUT_ONLY]; + + // Input only. The type of the data disk attached to this instance, defaults to + // standard persistent disk (`PD_STANDARD`). + DiskType data_disk_type = 25 [(google.api.field_behavior) = INPUT_ONLY]; + + // Input only. The size of the data disk in GB attached to this instance, up to a maximum + // of 64000 GB (64 TB). You can choose the size of the data disk based on how + // big your notebooks and data are. If not specified, this defaults to 100. + int64 data_disk_size_gb = 26 [(google.api.field_behavior) = INPUT_ONLY]; + + // Input only. If true, the data disk will not be auto deleted when deleting the instance. + bool no_remove_data_disk = 27 [(google.api.field_behavior) = INPUT_ONLY]; + + // Input only. Disk encryption method used on the boot and data disks, defaults to GMEK. + DiskEncryption disk_encryption = 15 [(google.api.field_behavior) = INPUT_ONLY]; + + // Input only. The KMS key used to encrypt the disks, only applicable if disk_encryption + // is CMEK. + // Format: + // `projects/{project_id}/locations/{location}/keyRings/{key_ring_id}/cryptoKeys/{key_id}` + // + // Learn more about [using your own encryption + // keys](https://cloud.google.com/kms/docs/quickstart). + string kms_key = 16 [(google.api.field_behavior) = INPUT_ONLY]; + + // If true, no public IP will be assigned to this instance. + bool no_public_ip = 17; + + // If true, the notebook instance will not register with the proxy. + bool no_proxy_access = 18; + + // The name of the VPC that this instance is in. + // Format: + // `projects/{project_id}/global/networks/{network_id}` + string network = 19; + + // The name of the subnet that this instance is in. + // Format: + // `projects/{project_id}/regions/{region}/subnetworks/{subnetwork_id}` + string subnet = 20; + + // Labels to apply to this instance. + // These can be later modified by the setLabels method. + map labels = 21; + + // Custom metadata to apply to this instance. + map metadata = 22; + + // Optional. The type of vNIC to be used on this interface. This may be gVNIC or + // VirtioNet. + NicType nic_type = 28 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The optional reservation affinity. Setting this field will apply + // the specified [Zonal Compute + // Reservation](https://cloud.google.com/compute/docs/instances/reserving-zonal-resources) + // to this notebook instance. + ReservationAffinity reservation_affinity = 29 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Flag to enable ip forwarding or not, default false/off. + // https://cloud.google.com/vpc/docs/using-routes#canipforward + bool can_ip_forward = 31 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. Instance creation time. + google.protobuf.Timestamp create_time = 23 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Instance update time. + google.protobuf.Timestamp update_time = 24 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/service.proto b/owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/service.proto new file mode 100644 index 00000000000..57dfe2f381d --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/service.proto @@ -0,0 +1,524 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.notebooks.v1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/notebooks/v1beta1/environment.proto"; +import "google/cloud/notebooks/v1beta1/instance.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Notebooks.V1Beta1"; +option go_package = "cloud.google.com/go/notebooks/apiv1beta1/notebookspb;notebookspb"; +option java_multiple_files = true; +option java_outer_classname = "NotebooksProto"; +option java_package = "com.google.cloud.notebooks.v1beta1"; +option php_namespace = "Google\\Cloud\\Notebooks\\V1beta1"; +option ruby_package = "Google::Cloud::Notebooks::V1beta1"; + +// API v1beta1 service for Cloud AI Platform Notebooks. +service NotebookService { + option (google.api.default_host) = "notebooks.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Lists instances in a given project and location. + rpc ListInstances(ListInstancesRequest) returns (ListInstancesResponse) { + option (google.api.http) = { + get: "/v1beta1/{parent=projects/*/locations/*}/instances" + }; + } + + // Gets details of a single Instance. + rpc GetInstance(GetInstanceRequest) returns (Instance) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/locations/*/instances/*}" + }; + } + + // Creates a new Instance in a given project and location. + rpc CreateInstance(CreateInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*/locations/*}/instances" + body: "instance" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Registers an existing legacy notebook instance to the Notebooks API server. + // Legacy instances are instances created with the legacy Compute Engine + // calls. They are not manageable by the Notebooks API out of the box. This + // call makes these instances manageable by the Notebooks API. + rpc RegisterInstance(RegisterInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*/locations/*}/instances:register" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Updates the guest accelerators of a single Instance. + rpc SetInstanceAccelerator(SetInstanceAcceleratorRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1beta1/{name=projects/*/locations/*/instances/*}:setAccelerator" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Updates the machine type of a single Instance. + rpc SetInstanceMachineType(SetInstanceMachineTypeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1beta1/{name=projects/*/locations/*/instances/*}:setMachineType" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Updates the labels of an Instance. + rpc SetInstanceLabels(SetInstanceLabelsRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1beta1/{name=projects/*/locations/*/instances/*}:setLabels" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Deletes a single Instance. + rpc DeleteInstance(DeleteInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1beta1/{name=projects/*/locations/*/instances/*}" + }; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "OperationMetadata" + }; + } + + // Starts a notebook instance. + rpc StartInstance(StartInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/instances/*}:start" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Stops a notebook instance. + rpc StopInstance(StopInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/instances/*}:stop" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Resets a notebook instance. + rpc ResetInstance(ResetInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/instances/*}:reset" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Allows notebook instances to + // report their latest instance information to the Notebooks + // API server. The server will merge the reported information to + // the instance metadata store. Do not use this method directly. + rpc ReportInstanceInfo(ReportInstanceInfoRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/instances/*}:report" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Check if a notebook instance is upgradable. + // Deprecated. Please consider using v1. + rpc IsInstanceUpgradeable(IsInstanceUpgradeableRequest) returns (IsInstanceUpgradeableResponse) { + option deprecated = true; + option (google.api.http) = { + get: "/v1beta1/{notebook_instance=projects/*/locations/*/instances/*}:isUpgradeable" + }; + } + + // Upgrades a notebook instance to the latest version. + // Deprecated. Please consider using v1. + rpc UpgradeInstance(UpgradeInstanceRequest) returns (google.longrunning.Operation) { + option deprecated = true; + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/instances/*}:upgrade" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Allows notebook instances to + // call this endpoint to upgrade themselves. Do not use this method directly. + // Deprecated. Please consider using v1. + rpc UpgradeInstanceInternal(UpgradeInstanceInternalRequest) returns (google.longrunning.Operation) { + option deprecated = true; + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/instances/*}:upgradeInternal" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Lists environments in a project. + rpc ListEnvironments(ListEnvironmentsRequest) returns (ListEnvironmentsResponse) { + option (google.api.http) = { + get: "/v1beta1/{parent=projects/*/locations/*}/environments" + }; + } + + // Gets details of a single Environment. + rpc GetEnvironment(GetEnvironmentRequest) returns (Environment) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/locations/*/environments/*}" + }; + } + + // Creates a new Environment. + rpc CreateEnvironment(CreateEnvironmentRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*/locations/*}/environments" + body: "environment" + }; + option (google.longrunning.operation_info) = { + response_type: "Environment" + metadata_type: "OperationMetadata" + }; + } + + // Deletes a single Environment. + rpc DeleteEnvironment(DeleteEnvironmentRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1beta1/{name=projects/*/locations/*/environments/*}" + }; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "OperationMetadata" + }; + } +} + +// Represents the metadata of the long-running operation. +message OperationMetadata { + // The time the operation was created. + google.protobuf.Timestamp create_time = 1; + + // The time the operation finished running. + google.protobuf.Timestamp end_time = 2; + + // Server-defined resource path for the target of the operation. + string target = 3; + + // Name of the verb executed by the operation. + string verb = 4; + + // Human-readable status of the operation, if any. + string status_message = 5; + + // Identifies whether the user has requested cancellation + // of the operation. Operations that have successfully been cancelled + // have [Operation.error][] value with a + // [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`. + bool requested_cancellation = 6; + + // API version used to start the operation. + string api_version = 7; + + // API endpoint name of this operation. + string endpoint = 8; +} + +// Request for listing notebook instances. +message ListInstancesRequest { + // Required. Format: + // `parent=projects/{project_id}/locations/{location}` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Maximum return size of the list call. + int32 page_size = 2; + + // A previous returned page token that can be used to continue listing + // from the last result. + string page_token = 3; +} + +// Response for listing notebook instances. +message ListInstancesResponse { + // A list of returned instances. + repeated Instance instances = 1; + + // Page token that can be used to continue listing from the last result in the + // next list call. + string next_page_token = 2; + + // Locations that could not be reached. For example, + // `['us-west1-a', 'us-central1-b']`. + // A ListInstancesResponse will only contain either instances or unreachables, + repeated string unreachable = 3; +} + +// Request for getting a notebook instance. +message GetInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for creating a notebook instance. +message CreateInstanceRequest { + // Required. Format: + // `parent=projects/{project_id}/locations/{location}` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. User-defined unique ID of this instance. + string instance_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The instance to be created. + Instance instance = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for registering a notebook instance. +message RegisterInstanceRequest { + // Required. Format: + // `parent=projects/{project_id}/locations/{location}` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. User defined unique ID of this instance. The `instance_id` must + // be 1 to 63 characters long and contain only lowercase letters, + // numeric characters, and dashes. The first character must be a lowercase + // letter and the last character cannot be a dash. + string instance_id = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for setting instance accelerator. +message SetInstanceAcceleratorRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Type of this accelerator. + Instance.AcceleratorType type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. Count of cores of this accelerator. Note that not all combinations + // of `type` and `core_count` are valid. Check [GPUs on + // Compute Engine](https://cloud.google.com/compute/docs/gpus/#gpus-list) to + // find a valid combination. TPUs are not supported. + int64 core_count = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for setting instance machine type. +message SetInstanceMachineTypeRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The [Compute Engine machine + // type](https://cloud.google.com/compute/docs/machine-types). + string machine_type = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for setting instance labels. +message SetInstanceLabelsRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Labels to apply to this instance. + // These can be later modified by the setLabels method + map labels = 2; +} + +// Request for deleting a notebook instance. +message DeleteInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for starting a notebook instance +message StartInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for stopping a notebook instance +message StopInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for reseting a notebook instance +message ResetInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for notebook instances to report information to Notebooks API. +message ReportInstanceInfoRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The VM hardware token for authenticating the VM. + // https://cloud.google.com/compute/docs/instances/verifying-instance-identity + string vm_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // The metadata reported to Notebooks API. This will be merged to the instance + // metadata store + map metadata = 3; +} + +// Request for checking if a notebook instance is upgradeable. +message IsInstanceUpgradeableRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string notebook_instance = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response for checking if a notebook instance is upgradeable. +message IsInstanceUpgradeableResponse { + // If an instance is upgradeable. + bool upgradeable = 1; + + // The version this instance will be upgraded to if calling the upgrade + // endpoint. This field will only be populated if field upgradeable is true. + string upgrade_version = 2; + + // Additional information about upgrade. + string upgrade_info = 3; + + // The new image self link this instance will be upgraded to if calling the + // upgrade endpoint. This field will only be populated if field upgradeable + // is true. + string upgrade_image = 4; +} + +// Request for upgrading a notebook instance +message UpgradeInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for upgrading a notebook instance from within the VM +message UpgradeInstanceInternalRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The VM hardware token for authenticating the VM. + // https://cloud.google.com/compute/docs/instances/verifying-instance-identity + string vm_id = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for listing environments. +message ListEnvironmentsRequest { + // Required. Format: `projects/{project_id}/locations/{location}` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Maximum return size of the list call. + int32 page_size = 2; + + // A previous returned page token that can be used to continue listing from + // the last result. + string page_token = 3; +} + +// Response for listing environments. +message ListEnvironmentsResponse { + // A list of returned environments. + repeated Environment environments = 1; + + // A page token that can be used to continue listing from the last result + // in the next list call. + string next_page_token = 2; + + // Locations that could not be reached. + repeated string unreachable = 3; +} + +// Request for getting a notebook environment. +message GetEnvironmentRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/environments/{environment_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for creating a notebook environment. +message CreateEnvironmentRequest { + // Required. Format: `projects/{project_id}/locations/{location}` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. User-defined unique ID of this environment. The `environment_id` must + // be 1 to 63 characters long and contain only lowercase letters, + // numeric characters, and dashes. The first character must be a lowercase + // letter and the last character cannot be a dash. + string environment_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The environment to be created. + Environment environment = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for deleting a notebook environment. +message DeleteEnvironmentRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/environments/{environment_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.create_environment.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.create_environment.js new file mode 100644 index 00000000000..8ce3685c35e --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.create_environment.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, environmentId, environment) { + // [START notebooks_v1beta1_generated_NotebookService_CreateEnvironment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: `projects/{project_id}/locations/{location}` + */ + // const parent = 'abc123' + /** + * Required. User-defined unique ID of this environment. The `environment_id` must + * be 1 to 63 characters long and contain only lowercase letters, + * numeric characters, and dashes. The first character must be a lowercase + * letter and the last character cannot be a dash. + */ + // const environmentId = 'abc123' + /** + * Required. The environment to be created. + */ + // const environment = {} + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callCreateEnvironment() { + // Construct request + const request = { + parent, + environmentId, + environment, + }; + + // Run request + const [operation] = await notebooksClient.createEnvironment(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateEnvironment(); + // [END notebooks_v1beta1_generated_NotebookService_CreateEnvironment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.create_instance.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.create_instance.js new file mode 100644 index 00000000000..bed48c95939 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.create_instance.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(parent, instanceId, instance) { + // [START notebooks_v1beta1_generated_NotebookService_CreateInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + */ + // const parent = 'abc123' + /** + * Required. User-defined unique ID of this instance. + */ + // const instanceId = 'abc123' + /** + * Required. The instance to be created. + */ + // const instance = {} + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callCreateInstance() { + // Construct request + const request = { + parent, + instanceId, + instance, + }; + + // Run request + const [operation] = await notebooksClient.createInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateInstance(); + // [END notebooks_v1beta1_generated_NotebookService_CreateInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.delete_environment.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.delete_environment.js new file mode 100644 index 00000000000..32a94e35a7c --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.delete_environment.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 notebooks_v1beta1_generated_NotebookService_DeleteEnvironment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/environments/{environment_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callDeleteEnvironment() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.deleteEnvironment(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteEnvironment(); + // [END notebooks_v1beta1_generated_NotebookService_DeleteEnvironment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.delete_instance.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.delete_instance.js new file mode 100644 index 00000000000..eb82d4cfcb7 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.delete_instance.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 notebooks_v1beta1_generated_NotebookService_DeleteInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callDeleteInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.deleteInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteInstance(); + // [END notebooks_v1beta1_generated_NotebookService_DeleteInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.get_environment.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.get_environment.js new file mode 100644 index 00000000000..7c2709563bb --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.get_environment.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 notebooks_v1beta1_generated_NotebookService_GetEnvironment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/environments/{environment_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callGetEnvironment() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await notebooksClient.getEnvironment(request); + console.log(response); + } + + callGetEnvironment(); + // [END notebooks_v1beta1_generated_NotebookService_GetEnvironment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.get_instance.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.get_instance.js new file mode 100644 index 00000000000..e8259ff7579 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.get_instance.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 notebooks_v1beta1_generated_NotebookService_GetInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callGetInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await notebooksClient.getInstance(request); + console.log(response); + } + + callGetInstance(); + // [END notebooks_v1beta1_generated_NotebookService_GetInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.is_instance_upgradeable.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.is_instance_upgradeable.js new file mode 100644 index 00000000000..0062600b6d5 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.is_instance_upgradeable.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(notebookInstance) { + // [START notebooks_v1beta1_generated_NotebookService_IsInstanceUpgradeable_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const notebookInstance = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callIsInstanceUpgradeable() { + // Construct request + const request = { + notebookInstance, + }; + + // Run request + const response = await notebooksClient.isInstanceUpgradeable(request); + console.log(response); + } + + callIsInstanceUpgradeable(); + // [END notebooks_v1beta1_generated_NotebookService_IsInstanceUpgradeable_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.list_environments.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.list_environments.js new file mode 100644 index 00000000000..2b45b6f6403 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.list_environments.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) { + // [START notebooks_v1beta1_generated_NotebookService_ListEnvironments_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: `projects/{project_id}/locations/{location}` + */ + // const parent = 'abc123' + /** + * Maximum return size of the list call. + */ + // const pageSize = 1234 + /** + * A previous returned page token that can be used to continue listing from + * the last result. + */ + // const pageToken = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callListEnvironments() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await notebooksClient.listEnvironmentsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListEnvironments(); + // [END notebooks_v1beta1_generated_NotebookService_ListEnvironments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.list_instances.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.list_instances.js new file mode 100644 index 00000000000..1d74cc1e390 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.list_instances.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(parent) { + // [START notebooks_v1beta1_generated_NotebookService_ListInstances_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + */ + // const parent = 'abc123' + /** + * Maximum return size of the list call. + */ + // const pageSize = 1234 + /** + * A previous returned page token that can be used to continue listing + * from the last result. + */ + // const pageToken = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callListInstances() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await notebooksClient.listInstancesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListInstances(); + // [END notebooks_v1beta1_generated_NotebookService_ListInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.register_instance.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.register_instance.js new file mode 100644 index 00000000000..b8aacbe7688 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.register_instance.js @@ -0,0 +1,71 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, instanceId) { + // [START notebooks_v1beta1_generated_NotebookService_RegisterInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + */ + // const parent = 'abc123' + /** + * Required. User defined unique ID of this instance. The `instance_id` must + * be 1 to 63 characters long and contain only lowercase letters, + * numeric characters, and dashes. The first character must be a lowercase + * letter and the last character cannot be a dash. + */ + // const instanceId = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callRegisterInstance() { + // Construct request + const request = { + parent, + instanceId, + }; + + // Run request + const [operation] = await notebooksClient.registerInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRegisterInstance(); + // [END notebooks_v1beta1_generated_NotebookService_RegisterInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.report_instance_info.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.report_instance_info.js new file mode 100644 index 00000000000..baddddb82a0 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.report_instance_info.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(name, vmId) { + // [START notebooks_v1beta1_generated_NotebookService_ReportInstanceInfo_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + /** + * Required. The VM hardware token for authenticating the VM. + * https://cloud.google.com/compute/docs/instances/verifying-instance-identity + */ + // const vmId = 'abc123' + /** + * The metadata reported to Notebooks API. This will be merged to the instance + * metadata store + */ + // const metadata = [1,2,3,4] + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callReportInstanceInfo() { + // Construct request + const request = { + name, + vmId, + }; + + // Run request + const [operation] = await notebooksClient.reportInstanceInfo(request); + const [response] = await operation.promise(); + console.log(response); + } + + callReportInstanceInfo(); + // [END notebooks_v1beta1_generated_NotebookService_ReportInstanceInfo_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.reset_instance.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.reset_instance.js new file mode 100644 index 00000000000..8edc3b234cd --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.reset_instance.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 notebooks_v1beta1_generated_NotebookService_ResetInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callResetInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.resetInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callResetInstance(); + // [END notebooks_v1beta1_generated_NotebookService_ResetInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_accelerator.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_accelerator.js new file mode 100644 index 00000000000..83a8cb9963e --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_accelerator.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(name, type, coreCount) { + // [START notebooks_v1beta1_generated_NotebookService_SetInstanceAccelerator_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + /** + * Required. Type of this accelerator. + */ + // const type = {} + /** + * Required. Count of cores of this accelerator. Note that not all combinations + * of `type` and `core_count` are valid. Check GPUs on + * Compute Engine (https://cloud.google.com/compute/docs/gpus/#gpus-list) to + * find a valid combination. TPUs are not supported. + */ + // const coreCount = 1234 + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callSetInstanceAccelerator() { + // Construct request + const request = { + name, + type, + coreCount, + }; + + // Run request + const [operation] = await notebooksClient.setInstanceAccelerator(request); + const [response] = await operation.promise(); + console.log(response); + } + + callSetInstanceAccelerator(); + // [END notebooks_v1beta1_generated_NotebookService_SetInstanceAccelerator_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_labels.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_labels.js new file mode 100644 index 00000000000..285697d9fe0 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_labels.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 notebooks_v1beta1_generated_NotebookService_SetInstanceLabels_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + /** + * Labels to apply to this instance. + * These can be later modified by the setLabels method + */ + // const labels = [1,2,3,4] + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callSetInstanceLabels() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.setInstanceLabels(request); + const [response] = await operation.promise(); + console.log(response); + } + + callSetInstanceLabels(); + // [END notebooks_v1beta1_generated_NotebookService_SetInstanceLabels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_machine_type.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_machine_type.js new file mode 100644 index 00000000000..d8ca6a3d2a2 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_machine_type.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(name, machineType) { + // [START notebooks_v1beta1_generated_NotebookService_SetInstanceMachineType_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + /** + * Required. The Compute Engine machine + * type (https://cloud.google.com/compute/docs/machine-types). + */ + // const machineType = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callSetInstanceMachineType() { + // Construct request + const request = { + name, + machineType, + }; + + // Run request + const [operation] = await notebooksClient.setInstanceMachineType(request); + const [response] = await operation.promise(); + console.log(response); + } + + callSetInstanceMachineType(); + // [END notebooks_v1beta1_generated_NotebookService_SetInstanceMachineType_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.start_instance.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.start_instance.js new file mode 100644 index 00000000000..683ea73caac --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.start_instance.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 notebooks_v1beta1_generated_NotebookService_StartInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callStartInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.startInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callStartInstance(); + // [END notebooks_v1beta1_generated_NotebookService_StartInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.stop_instance.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.stop_instance.js new file mode 100644 index 00000000000..ce9ff135eb7 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.stop_instance.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 notebooks_v1beta1_generated_NotebookService_StopInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callStopInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.stopInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callStopInstance(); + // [END notebooks_v1beta1_generated_NotebookService_StopInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.upgrade_instance.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.upgrade_instance.js new file mode 100644 index 00000000000..16d68328574 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.upgrade_instance.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 notebooks_v1beta1_generated_NotebookService_UpgradeInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callUpgradeInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.upgradeInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpgradeInstance(); + // [END notebooks_v1beta1_generated_NotebookService_UpgradeInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.upgrade_instance_internal.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.upgrade_instance_internal.js new file mode 100644 index 00000000000..9c967ae9616 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.upgrade_instance_internal.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(name, vmId) { + // [START notebooks_v1beta1_generated_NotebookService_UpgradeInstanceInternal_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + /** + * Required. The VM hardware token for authenticating the VM. + * https://cloud.google.com/compute/docs/instances/verifying-instance-identity + */ + // const vmId = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callUpgradeInstanceInternal() { + // Construct request + const request = { + name, + vmId, + }; + + // Run request + const [operation] = await notebooksClient.upgradeInstanceInternal(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpgradeInstanceInternal(); + // [END notebooks_v1beta1_generated_NotebookService_UpgradeInstanceInternal_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.notebooks.v1beta1.json b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.notebooks.v1beta1.json new file mode 100644 index 00000000000..e4feeb81fd3 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.notebooks.v1beta1.json @@ -0,0 +1,839 @@ +{ + "clientLibrary": { + "name": "nodejs-notebooks", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.notebooks.v1beta1", + "version": "v1beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "notebooks_v1beta1_generated_NotebookService_ListInstances_async", + "title": "NotebookService listInstances Sample", + "origin": "API_DEFINITION", + "description": " Lists instances in a given project and location.", + "canonical": true, + "file": "notebook_service.list_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListInstances", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.ListInstances", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.notebooks.v1beta1.ListInstancesResponse", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" + }, + "method": { + "shortName": "ListInstances", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.ListInstances", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1beta1_generated_NotebookService_GetInstance_async", + "title": "NotebookService getInstance Sample", + "origin": "API_DEFINITION", + "description": " Gets details of a single Instance.", + "canonical": true, + "file": "notebook_service.get_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetInstance", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.GetInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.notebooks.v1beta1.Instance", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" + }, + "method": { + "shortName": "GetInstance", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.GetInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1beta1_generated_NotebookService_CreateInstance_async", + "title": "NotebookService createInstance Sample", + "origin": "API_DEFINITION", + "description": " Creates a new Instance in a given project and location.", + "canonical": true, + "file": "notebook_service.create_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateInstance", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.CreateInstance", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "instance_id", + "type": "TYPE_STRING" + }, + { + "name": "instance", + "type": ".google.cloud.notebooks.v1beta1.Instance" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" + }, + "method": { + "shortName": "CreateInstance", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.CreateInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1beta1_generated_NotebookService_RegisterInstance_async", + "title": "NotebookService registerInstance Sample", + "origin": "API_DEFINITION", + "description": " Registers an existing legacy notebook instance to the Notebooks API server. Legacy instances are instances created with the legacy Compute Engine calls. They are not manageable by the Notebooks API out of the box. This call makes these instances manageable by the Notebooks API.", + "canonical": true, + "file": "notebook_service.register_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RegisterInstance", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.RegisterInstance", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "instance_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" + }, + "method": { + "shortName": "RegisterInstance", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.RegisterInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1beta1_generated_NotebookService_SetInstanceAccelerator_async", + "title": "NotebookService setInstanceAccelerator Sample", + "origin": "API_DEFINITION", + "description": " Updates the guest accelerators of a single Instance.", + "canonical": true, + "file": "notebook_service.set_instance_accelerator.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetInstanceAccelerator", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.SetInstanceAccelerator", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": ".google.cloud.notebooks.v1beta1.Instance.AcceleratorType" + }, + { + "name": "core_count", + "type": "TYPE_INT64" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" + }, + "method": { + "shortName": "SetInstanceAccelerator", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.SetInstanceAccelerator", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1beta1_generated_NotebookService_SetInstanceMachineType_async", + "title": "NotebookService setInstanceMachineType Sample", + "origin": "API_DEFINITION", + "description": " Updates the machine type of a single Instance.", + "canonical": true, + "file": "notebook_service.set_instance_machine_type.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetInstanceMachineType", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.SetInstanceMachineType", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "machine_type", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" + }, + "method": { + "shortName": "SetInstanceMachineType", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.SetInstanceMachineType", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1beta1_generated_NotebookService_SetInstanceLabels_async", + "title": "NotebookService setInstanceLabels Sample", + "origin": "API_DEFINITION", + "description": " Updates the labels of an Instance.", + "canonical": true, + "file": "notebook_service.set_instance_labels.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetInstanceLabels", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.SetInstanceLabels", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" + }, + "method": { + "shortName": "SetInstanceLabels", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.SetInstanceLabels", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1beta1_generated_NotebookService_DeleteInstance_async", + "title": "NotebookService deleteInstance Sample", + "origin": "API_DEFINITION", + "description": " Deletes a single Instance.", + "canonical": true, + "file": "notebook_service.delete_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteInstance", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.DeleteInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" + }, + "method": { + "shortName": "DeleteInstance", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.DeleteInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1beta1_generated_NotebookService_StartInstance_async", + "title": "NotebookService startInstance Sample", + "origin": "API_DEFINITION", + "description": " Starts a notebook instance.", + "canonical": true, + "file": "notebook_service.start_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StartInstance", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.StartInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" + }, + "method": { + "shortName": "StartInstance", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.StartInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1beta1_generated_NotebookService_StopInstance_async", + "title": "NotebookService stopInstance Sample", + "origin": "API_DEFINITION", + "description": " Stops a notebook instance.", + "canonical": true, + "file": "notebook_service.stop_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StopInstance", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.StopInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" + }, + "method": { + "shortName": "StopInstance", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.StopInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1beta1_generated_NotebookService_ResetInstance_async", + "title": "NotebookService resetInstance Sample", + "origin": "API_DEFINITION", + "description": " Resets a notebook instance.", + "canonical": true, + "file": "notebook_service.reset_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ResetInstance", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.ResetInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" + }, + "method": { + "shortName": "ResetInstance", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.ResetInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1beta1_generated_NotebookService_ReportInstanceInfo_async", + "title": "NotebookService reportInstanceInfo Sample", + "origin": "API_DEFINITION", + "description": " Allows notebook instances to report their latest instance information to the Notebooks API server. The server will merge the reported information to the instance metadata store. Do not use this method directly.", + "canonical": true, + "file": "notebook_service.report_instance_info.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ReportInstanceInfo", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.ReportInstanceInfo", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "vm_id", + "type": "TYPE_STRING" + }, + { + "name": "metadata", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" + }, + "method": { + "shortName": "ReportInstanceInfo", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.ReportInstanceInfo", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1beta1_generated_NotebookService_IsInstanceUpgradeable_async", + "title": "NotebookService isInstanceUpgradeable Sample", + "origin": "API_DEFINITION", + "description": " Check if a notebook instance is upgradable. Deprecated. Please consider using v1.", + "canonical": true, + "file": "notebook_service.is_instance_upgradeable.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "IsInstanceUpgradeable", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.IsInstanceUpgradeable", + "async": true, + "parameters": [ + { + "name": "notebook_instance", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.notebooks.v1beta1.IsInstanceUpgradeableResponse", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" + }, + "method": { + "shortName": "IsInstanceUpgradeable", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.IsInstanceUpgradeable", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1beta1_generated_NotebookService_UpgradeInstance_async", + "title": "NotebookService upgradeInstance Sample", + "origin": "API_DEFINITION", + "description": " Upgrades a notebook instance to the latest version. Deprecated. Please consider using v1.", + "canonical": true, + "file": "notebook_service.upgrade_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpgradeInstance", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.UpgradeInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" + }, + "method": { + "shortName": "UpgradeInstance", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.UpgradeInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1beta1_generated_NotebookService_UpgradeInstanceInternal_async", + "title": "NotebookService upgradeInstanceInternal Sample", + "origin": "API_DEFINITION", + "description": " Allows notebook instances to call this endpoint to upgrade themselves. Do not use this method directly. Deprecated. Please consider using v1.", + "canonical": true, + "file": "notebook_service.upgrade_instance_internal.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpgradeInstanceInternal", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.UpgradeInstanceInternal", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "vm_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" + }, + "method": { + "shortName": "UpgradeInstanceInternal", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.UpgradeInstanceInternal", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1beta1_generated_NotebookService_ListEnvironments_async", + "title": "NotebookService listEnvironments Sample", + "origin": "API_DEFINITION", + "description": " Lists environments in a project.", + "canonical": true, + "file": "notebook_service.list_environments.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListEnvironments", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.ListEnvironments", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.notebooks.v1beta1.ListEnvironmentsResponse", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" + }, + "method": { + "shortName": "ListEnvironments", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.ListEnvironments", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1beta1_generated_NotebookService_GetEnvironment_async", + "title": "NotebookService getEnvironment Sample", + "origin": "API_DEFINITION", + "description": " Gets details of a single Environment.", + "canonical": true, + "file": "notebook_service.get_environment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetEnvironment", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.GetEnvironment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.notebooks.v1beta1.Environment", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" + }, + "method": { + "shortName": "GetEnvironment", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.GetEnvironment", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1beta1_generated_NotebookService_CreateEnvironment_async", + "title": "NotebookService createEnvironment Sample", + "origin": "API_DEFINITION", + "description": " Creates a new Environment.", + "canonical": true, + "file": "notebook_service.create_environment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateEnvironment", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.CreateEnvironment", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "environment_id", + "type": "TYPE_STRING" + }, + { + "name": "environment", + "type": ".google.cloud.notebooks.v1beta1.Environment" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" + }, + "method": { + "shortName": "CreateEnvironment", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.CreateEnvironment", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v1beta1_generated_NotebookService_DeleteEnvironment_async", + "title": "NotebookService deleteEnvironment Sample", + "origin": "API_DEFINITION", + "description": " Deletes a single Environment.", + "canonical": true, + "file": "notebook_service.delete_environment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteEnvironment", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.DeleteEnvironment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" + }, + "method": { + "shortName": "DeleteEnvironment", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService.DeleteEnvironment", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v1beta1.NotebookService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-notebooks/v1beta1/src/index.ts new file mode 100644 index 00000000000..e46a09175ed --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1beta1 from './v1beta1'; +const NotebookServiceClient = v1beta1.NotebookServiceClient; +type NotebookServiceClient = v1beta1.NotebookServiceClient; +export {v1beta1, NotebookServiceClient}; +export default {v1beta1, NotebookServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/gapic_metadata.json new file mode 100644 index 00000000000..4a231d3bb35 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/gapic_metadata.json @@ -0,0 +1,221 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.notebooks.v1beta1", + "libraryPackage": "@google-cloud/notebooks", + "services": { + "NotebookService": { + "clients": { + "grpc": { + "libraryClient": "NotebookServiceClient", + "rpcs": { + "GetInstance": { + "methods": [ + "getInstance" + ] + }, + "IsInstanceUpgradeable": { + "methods": [ + "isInstanceUpgradeable" + ] + }, + "GetEnvironment": { + "methods": [ + "getEnvironment" + ] + }, + "CreateInstance": { + "methods": [ + "createInstance" + ] + }, + "RegisterInstance": { + "methods": [ + "registerInstance" + ] + }, + "SetInstanceAccelerator": { + "methods": [ + "setInstanceAccelerator" + ] + }, + "SetInstanceMachineType": { + "methods": [ + "setInstanceMachineType" + ] + }, + "SetInstanceLabels": { + "methods": [ + "setInstanceLabels" + ] + }, + "DeleteInstance": { + "methods": [ + "deleteInstance" + ] + }, + "StartInstance": { + "methods": [ + "startInstance" + ] + }, + "StopInstance": { + "methods": [ + "stopInstance" + ] + }, + "ResetInstance": { + "methods": [ + "resetInstance" + ] + }, + "ReportInstanceInfo": { + "methods": [ + "reportInstanceInfo" + ] + }, + "UpgradeInstance": { + "methods": [ + "upgradeInstance" + ] + }, + "UpgradeInstanceInternal": { + "methods": [ + "upgradeInstanceInternal" + ] + }, + "CreateEnvironment": { + "methods": [ + "createEnvironment" + ] + }, + "DeleteEnvironment": { + "methods": [ + "deleteEnvironment" + ] + }, + "ListInstances": { + "methods": [ + "listInstances", + "listInstancesStream", + "listInstancesAsync" + ] + }, + "ListEnvironments": { + "methods": [ + "listEnvironments", + "listEnvironmentsStream", + "listEnvironmentsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "NotebookServiceClient", + "rpcs": { + "GetInstance": { + "methods": [ + "getInstance" + ] + }, + "IsInstanceUpgradeable": { + "methods": [ + "isInstanceUpgradeable" + ] + }, + "GetEnvironment": { + "methods": [ + "getEnvironment" + ] + }, + "CreateInstance": { + "methods": [ + "createInstance" + ] + }, + "RegisterInstance": { + "methods": [ + "registerInstance" + ] + }, + "SetInstanceAccelerator": { + "methods": [ + "setInstanceAccelerator" + ] + }, + "SetInstanceMachineType": { + "methods": [ + "setInstanceMachineType" + ] + }, + "SetInstanceLabels": { + "methods": [ + "setInstanceLabels" + ] + }, + "DeleteInstance": { + "methods": [ + "deleteInstance" + ] + }, + "StartInstance": { + "methods": [ + "startInstance" + ] + }, + "StopInstance": { + "methods": [ + "stopInstance" + ] + }, + "ResetInstance": { + "methods": [ + "resetInstance" + ] + }, + "ReportInstanceInfo": { + "methods": [ + "reportInstanceInfo" + ] + }, + "UpgradeInstance": { + "methods": [ + "upgradeInstance" + ] + }, + "UpgradeInstanceInternal": { + "methods": [ + "upgradeInstanceInternal" + ] + }, + "CreateEnvironment": { + "methods": [ + "createEnvironment" + ] + }, + "DeleteEnvironment": { + "methods": [ + "deleteEnvironment" + ] + }, + "ListInstances": { + "methods": [ + "listInstances", + "listInstancesStream", + "listInstancesAsync" + ] + }, + "ListEnvironments": { + "methods": [ + "listEnvironments", + "listEnvironmentsStream", + "listEnvironmentsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/index.ts new file mode 100644 index 00000000000..5f1ec6b1546 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {NotebookServiceClient} from './notebook_service_client'; diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_client.ts b/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_client.ts new file mode 100644 index 00000000000..0a2053a2053 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_client.ts @@ -0,0 +1,2818 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, IamClient, IamProtos, 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/v1beta1/notebook_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './notebook_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * API v1beta1 service for Cloud AI Platform Notebooks. + * @class + * @memberof v1beta1 + */ +export class NotebookServiceClient { + 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}; + iamClient: IamClient; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + notebookServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of NotebookServiceClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 NotebookServiceClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof NotebookServiceClient; + 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.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); + + 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 { + 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 = { + environmentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/environments/{environment}' + ), + instancePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/instances/{instance}' + ), + }; + + // 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 = { + listInstances: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instances'), + listEnvironments: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'environments') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1beta1/{resource=projects/*/locations/*/instances/*}:getIamPolicy',},{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1beta1/{resource=projects/*/locations/*/instances/*}:setIamPolicy',body: '*',},{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1beta1/{resource=projects/*/locations/*/instances/*}:testIamPermissions',body: '*',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta1/{name=projects/*/locations/*}/operations',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + const createInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + const registerInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + const registerInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + const setInstanceAcceleratorResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + const setInstanceAcceleratorMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + const setInstanceMachineTypeResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + const setInstanceMachineTypeMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + const setInstanceLabelsResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + const setInstanceLabelsMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + const deleteInstanceResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + const startInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + const startInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + const stopInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + const stopInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + const resetInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + const resetInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + const reportInstanceInfoResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + const reportInstanceInfoMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + const upgradeInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + const upgradeInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + const upgradeInstanceInternalResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + const upgradeInstanceInternalMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + const createEnvironmentResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.Environment') as gax.protobuf.Type; + const createEnvironmentMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + const deleteEnvironmentResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteEnvironmentMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createInstanceResponse.decode.bind(createInstanceResponse), + createInstanceMetadata.decode.bind(createInstanceMetadata)), + registerInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + registerInstanceResponse.decode.bind(registerInstanceResponse), + registerInstanceMetadata.decode.bind(registerInstanceMetadata)), + setInstanceAccelerator: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + setInstanceAcceleratorResponse.decode.bind(setInstanceAcceleratorResponse), + setInstanceAcceleratorMetadata.decode.bind(setInstanceAcceleratorMetadata)), + setInstanceMachineType: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + setInstanceMachineTypeResponse.decode.bind(setInstanceMachineTypeResponse), + setInstanceMachineTypeMetadata.decode.bind(setInstanceMachineTypeMetadata)), + setInstanceLabels: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + setInstanceLabelsResponse.decode.bind(setInstanceLabelsResponse), + setInstanceLabelsMetadata.decode.bind(setInstanceLabelsMetadata)), + deleteInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteInstanceResponse.decode.bind(deleteInstanceResponse), + deleteInstanceMetadata.decode.bind(deleteInstanceMetadata)), + startInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + startInstanceResponse.decode.bind(startInstanceResponse), + startInstanceMetadata.decode.bind(startInstanceMetadata)), + stopInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + stopInstanceResponse.decode.bind(stopInstanceResponse), + stopInstanceMetadata.decode.bind(stopInstanceMetadata)), + resetInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + resetInstanceResponse.decode.bind(resetInstanceResponse), + resetInstanceMetadata.decode.bind(resetInstanceMetadata)), + reportInstanceInfo: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + reportInstanceInfoResponse.decode.bind(reportInstanceInfoResponse), + reportInstanceInfoMetadata.decode.bind(reportInstanceInfoMetadata)), + upgradeInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + upgradeInstanceResponse.decode.bind(upgradeInstanceResponse), + upgradeInstanceMetadata.decode.bind(upgradeInstanceMetadata)), + upgradeInstanceInternal: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + upgradeInstanceInternalResponse.decode.bind(upgradeInstanceInternalResponse), + upgradeInstanceInternalMetadata.decode.bind(upgradeInstanceInternalMetadata)), + createEnvironment: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createEnvironmentResponse.decode.bind(createEnvironmentResponse), + createEnvironmentMetadata.decode.bind(createEnvironmentMetadata)), + deleteEnvironment: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteEnvironmentResponse.decode.bind(deleteEnvironmentResponse), + deleteEnvironmentMetadata.decode.bind(deleteEnvironmentMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.notebooks.v1beta1.NotebookService', 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.notebookServiceStub) { + return this.notebookServiceStub; + } + + // Put together the "service stub" for + // google.cloud.notebooks.v1beta1.NotebookService. + this.notebookServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.notebooks.v1beta1.NotebookService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.notebooks.v1beta1.NotebookService, + 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 notebookServiceStubMethods = + ['listInstances', 'getInstance', 'createInstance', 'registerInstance', 'setInstanceAccelerator', 'setInstanceMachineType', 'setInstanceLabels', 'deleteInstance', 'startInstance', 'stopInstance', 'resetInstance', 'reportInstanceInfo', 'isInstanceUpgradeable', 'upgradeInstance', 'upgradeInstanceInternal', 'listEnvironments', 'getEnvironment', 'createEnvironment', 'deleteEnvironment']; + for (const methodName of notebookServiceStubMethods) { + const callPromise = this.notebookServiceStub.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.notebookServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'notebooks.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 'notebooks.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 details of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1beta1.Instance|Instance}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.get_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_GetInstance_async + */ + getInstance( + request?: protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest|undefined, {}|undefined + ]>; + getInstance( + request: protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest|null|undefined, + {}|null|undefined>): void; + getInstance( + request: protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest, + callback: Callback< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest|null|undefined, + {}|null|undefined>): void; + getInstance( + request?: protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getInstance(request, options, callback); + } +/** + * Check if a notebook instance is upgradable. + * Deprecated. Please consider using v1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.notebookInstance + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableResponse|IsInstanceUpgradeableResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.is_instance_upgradeable.js + * region_tag:notebooks_v1beta1_generated_NotebookService_IsInstanceUpgradeable_async + * @deprecated IsInstanceUpgradeable is deprecated and may be removed in a future version. + */ + isInstanceUpgradeable( + request?: protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, + protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest|undefined, {}|undefined + ]>; + isInstanceUpgradeable( + request: protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, + protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest|null|undefined, + {}|null|undefined>): void; + isInstanceUpgradeable( + request: protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest, + callback: Callback< + protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, + protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest|null|undefined, + {}|null|undefined>): void; + isInstanceUpgradeable( + request?: protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, + protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, + protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, + protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'notebook_instance': request.notebookInstance ?? '', + }); + this.initialize(); + this.warn('DEP$NotebookService-$IsInstanceUpgradeable','IsInstanceUpgradeable is deprecated and may be removed in a future version.', 'DeprecationWarning'); + return this.innerApiCalls.isInstanceUpgradeable(request, options, callback); + } +/** + * Gets details of a single Environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/environments/{environment_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1beta1.Environment|Environment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.get_environment.js + * region_tag:notebooks_v1beta1_generated_NotebookService_GetEnvironment_async + */ + getEnvironment( + request?: protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v1beta1.IEnvironment, + protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest|undefined, {}|undefined + ]>; + getEnvironment( + request: protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1beta1.IEnvironment, + protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest|null|undefined, + {}|null|undefined>): void; + getEnvironment( + request: protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest, + callback: Callback< + protos.google.cloud.notebooks.v1beta1.IEnvironment, + protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest|null|undefined, + {}|null|undefined>): void; + getEnvironment( + request?: protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.notebooks.v1beta1.IEnvironment, + protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.notebooks.v1beta1.IEnvironment, + protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.notebooks.v1beta1.IEnvironment, + protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getEnvironment(request, options, callback); + } + +/** + * Creates a new Instance in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {string} request.instanceId + * Required. User-defined unique ID of this instance. + * @param {google.cloud.notebooks.v1beta1.Instance} request.instance + * Required. The instance to be created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.create_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_CreateInstance_async + */ + createInstance( + request?: protos.google.cloud.notebooks.v1beta1.ICreateInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createInstance( + request: protos.google.cloud.notebooks.v1beta1.ICreateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createInstance( + request: protos.google.cloud.notebooks.v1beta1.ICreateInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createInstance( + request?: protos.google.cloud.notebooks.v1beta1.ICreateInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.create_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_CreateInstance_async + */ + async checkCreateInstanceProgress(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.createInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Registers an existing legacy notebook instance to the Notebooks API server. + * Legacy instances are instances created with the legacy Compute Engine + * calls. They are not manageable by the Notebooks API out of the box. This + * call makes these instances manageable by the Notebooks API. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {string} request.instanceId + * Required. User defined unique ID of this instance. The `instance_id` must + * be 1 to 63 characters long and contain only lowercase letters, + * numeric characters, and dashes. The first character must be a lowercase + * letter and the last character cannot be a dash. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.register_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_RegisterInstance_async + */ + registerInstance( + request?: protos.google.cloud.notebooks.v1beta1.IRegisterInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + registerInstance( + request: protos.google.cloud.notebooks.v1beta1.IRegisterInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + registerInstance( + request: protos.google.cloud.notebooks.v1beta1.IRegisterInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + registerInstance( + request?: protos.google.cloud.notebooks.v1beta1.IRegisterInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.registerInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `registerInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.register_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_RegisterInstance_async + */ + async checkRegisterInstanceProgress(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.registerInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the guest accelerators of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {google.cloud.notebooks.v1beta1.Instance.AcceleratorType} request.type + * Required. Type of this accelerator. + * @param {number} request.coreCount + * Required. Count of cores of this accelerator. Note that not all combinations + * of `type` and `core_count` are valid. Check [GPUs on + * Compute Engine](https://cloud.google.com/compute/docs/gpus/#gpus-list) to + * find a valid combination. TPUs are not supported. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.set_instance_accelerator.js + * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceAccelerator_async + */ + setInstanceAccelerator( + request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceAcceleratorRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + setInstanceAccelerator( + request: protos.google.cloud.notebooks.v1beta1.ISetInstanceAcceleratorRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInstanceAccelerator( + request: protos.google.cloud.notebooks.v1beta1.ISetInstanceAcceleratorRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInstanceAccelerator( + request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceAcceleratorRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.setInstanceAccelerator(request, options, callback); + } +/** + * Check the status of the long running operation returned by `setInstanceAccelerator()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.set_instance_accelerator.js + * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceAccelerator_async + */ + async checkSetInstanceAcceleratorProgress(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.setInstanceAccelerator, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the machine type of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {string} request.machineType + * Required. The [Compute Engine machine + * type](https://cloud.google.com/compute/docs/machine-types). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.set_instance_machine_type.js + * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceMachineType_async + */ + setInstanceMachineType( + request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceMachineTypeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + setInstanceMachineType( + request: protos.google.cloud.notebooks.v1beta1.ISetInstanceMachineTypeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInstanceMachineType( + request: protos.google.cloud.notebooks.v1beta1.ISetInstanceMachineTypeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInstanceMachineType( + request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceMachineTypeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.setInstanceMachineType(request, options, callback); + } +/** + * Check the status of the long running operation returned by `setInstanceMachineType()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.set_instance_machine_type.js + * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceMachineType_async + */ + async checkSetInstanceMachineTypeProgress(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.setInstanceMachineType, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the labels of an Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {number[]} request.labels + * Labels to apply to this instance. + * These can be later modified by the setLabels method + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.set_instance_labels.js + * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceLabels_async + */ + setInstanceLabels( + request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceLabelsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + setInstanceLabels( + request: protos.google.cloud.notebooks.v1beta1.ISetInstanceLabelsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInstanceLabels( + request: protos.google.cloud.notebooks.v1beta1.ISetInstanceLabelsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInstanceLabels( + request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceLabelsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.setInstanceLabels(request, options, callback); + } +/** + * Check the status of the long running operation returned by `setInstanceLabels()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.set_instance_labels.js + * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceLabels_async + */ + async checkSetInstanceLabelsProgress(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.setInstanceLabels, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.delete_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_DeleteInstance_async + */ + deleteInstance( + request?: protos.google.cloud.notebooks.v1beta1.IDeleteInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteInstance( + request: protos.google.cloud.notebooks.v1beta1.IDeleteInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteInstance( + request: protos.google.cloud.notebooks.v1beta1.IDeleteInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteInstance( + request?: protos.google.cloud.notebooks.v1beta1.IDeleteInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.delete_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_DeleteInstance_async + */ + async checkDeleteInstanceProgress(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.deleteInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Starts a notebook instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.start_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_StartInstance_async + */ + startInstance( + request?: protos.google.cloud.notebooks.v1beta1.IStartInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + startInstance( + request: protos.google.cloud.notebooks.v1beta1.IStartInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + startInstance( + request: protos.google.cloud.notebooks.v1beta1.IStartInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + startInstance( + request?: protos.google.cloud.notebooks.v1beta1.IStartInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.startInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `startInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.start_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_StartInstance_async + */ + async checkStartInstanceProgress(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.startInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Stops a notebook instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.stop_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_StopInstance_async + */ + stopInstance( + request?: protos.google.cloud.notebooks.v1beta1.IStopInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + stopInstance( + request: protos.google.cloud.notebooks.v1beta1.IStopInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + stopInstance( + request: protos.google.cloud.notebooks.v1beta1.IStopInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + stopInstance( + request?: protos.google.cloud.notebooks.v1beta1.IStopInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.stopInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `stopInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.stop_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_StopInstance_async + */ + async checkStopInstanceProgress(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.stopInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Resets a notebook instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.reset_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_ResetInstance_async + */ + resetInstance( + request?: protos.google.cloud.notebooks.v1beta1.IResetInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + resetInstance( + request: protos.google.cloud.notebooks.v1beta1.IResetInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + resetInstance( + request: protos.google.cloud.notebooks.v1beta1.IResetInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + resetInstance( + request?: protos.google.cloud.notebooks.v1beta1.IResetInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.resetInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `resetInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.reset_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_ResetInstance_async + */ + async checkResetInstanceProgress(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.resetInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Allows notebook instances to + * report their latest instance information to the Notebooks + * API server. The server will merge the reported information to + * the instance metadata store. Do not use this method directly. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {string} request.vmId + * Required. The VM hardware token for authenticating the VM. + * https://cloud.google.com/compute/docs/instances/verifying-instance-identity + * @param {number[]} request.metadata + * The metadata reported to Notebooks API. This will be merged to the instance + * metadata store + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.report_instance_info.js + * region_tag:notebooks_v1beta1_generated_NotebookService_ReportInstanceInfo_async + */ + reportInstanceInfo( + request?: protos.google.cloud.notebooks.v1beta1.IReportInstanceInfoRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + reportInstanceInfo( + request: protos.google.cloud.notebooks.v1beta1.IReportInstanceInfoRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + reportInstanceInfo( + request: protos.google.cloud.notebooks.v1beta1.IReportInstanceInfoRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + reportInstanceInfo( + request?: protos.google.cloud.notebooks.v1beta1.IReportInstanceInfoRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.reportInstanceInfo(request, options, callback); + } +/** + * Check the status of the long running operation returned by `reportInstanceInfo()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.report_instance_info.js + * region_tag:notebooks_v1beta1_generated_NotebookService_ReportInstanceInfo_async + */ + async checkReportInstanceInfoProgress(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.reportInstanceInfo, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Upgrades a notebook instance to the latest version. + * Deprecated. Please consider using v1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.upgrade_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_UpgradeInstance_async + * @deprecated UpgradeInstance is deprecated and may be removed in a future version. + */ + upgradeInstance( + request?: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + upgradeInstance( + request: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + upgradeInstance( + request: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + upgradeInstance( + request?: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + this.warn('DEP$NotebookService-$UpgradeInstance','UpgradeInstance is deprecated and may be removed in a future version.', 'DeprecationWarning'); + return this.innerApiCalls.upgradeInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `upgradeInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.upgrade_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_UpgradeInstance_async + * @deprecated UpgradeInstance is deprecated and may be removed in a future version. + */ + async checkUpgradeInstanceProgress(name: string): Promise>{ + this.warn('DEP$NotebookService-$checkUpgradeInstanceProgress','checkUpgradeInstanceProgress is deprecated and may be removed in a future version.', 'DeprecationWarning'); + 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.upgradeInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Allows notebook instances to + * call this endpoint to upgrade themselves. Do not use this method directly. + * Deprecated. Please consider using v1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {string} request.vmId + * Required. The VM hardware token for authenticating the VM. + * https://cloud.google.com/compute/docs/instances/verifying-instance-identity + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.upgrade_instance_internal.js + * region_tag:notebooks_v1beta1_generated_NotebookService_UpgradeInstanceInternal_async + * @deprecated UpgradeInstanceInternal is deprecated and may be removed in a future version. + */ + upgradeInstanceInternal( + request?: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceInternalRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + upgradeInstanceInternal( + request: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceInternalRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + upgradeInstanceInternal( + request: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceInternalRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + upgradeInstanceInternal( + request?: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceInternalRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + this.warn('DEP$NotebookService-$UpgradeInstanceInternal','UpgradeInstanceInternal is deprecated and may be removed in a future version.', 'DeprecationWarning'); + return this.innerApiCalls.upgradeInstanceInternal(request, options, callback); + } +/** + * Check the status of the long running operation returned by `upgradeInstanceInternal()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.upgrade_instance_internal.js + * region_tag:notebooks_v1beta1_generated_NotebookService_UpgradeInstanceInternal_async + * @deprecated UpgradeInstanceInternal is deprecated and may be removed in a future version. + */ + async checkUpgradeInstanceInternalProgress(name: string): Promise>{ + this.warn('DEP$NotebookService-$checkUpgradeInstanceInternalProgress','checkUpgradeInstanceInternalProgress is deprecated and may be removed in a future version.', 'DeprecationWarning'); + 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.upgradeInstanceInternal, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Creates a new Environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: `projects/{project_id}/locations/{location}` + * @param {string} request.environmentId + * Required. User-defined unique ID of this environment. The `environment_id` must + * be 1 to 63 characters long and contain only lowercase letters, + * numeric characters, and dashes. The first character must be a lowercase + * letter and the last character cannot be a dash. + * @param {google.cloud.notebooks.v1beta1.Environment} request.environment + * Required. The environment to be created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.create_environment.js + * region_tag:notebooks_v1beta1_generated_NotebookService_CreateEnvironment_async + */ + createEnvironment( + request?: protos.google.cloud.notebooks.v1beta1.ICreateEnvironmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createEnvironment( + request: protos.google.cloud.notebooks.v1beta1.ICreateEnvironmentRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createEnvironment( + request: protos.google.cloud.notebooks.v1beta1.ICreateEnvironmentRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createEnvironment( + request?: protos.google.cloud.notebooks.v1beta1.ICreateEnvironmentRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createEnvironment(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createEnvironment()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.create_environment.js + * region_tag:notebooks_v1beta1_generated_NotebookService_CreateEnvironment_async + */ + async checkCreateEnvironmentProgress(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.createEnvironment, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a single Environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/environments/{environment_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.delete_environment.js + * region_tag:notebooks_v1beta1_generated_NotebookService_DeleteEnvironment_async + */ + deleteEnvironment( + request?: protos.google.cloud.notebooks.v1beta1.IDeleteEnvironmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteEnvironment( + request: protos.google.cloud.notebooks.v1beta1.IDeleteEnvironmentRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteEnvironment( + request: protos.google.cloud.notebooks.v1beta1.IDeleteEnvironmentRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteEnvironment( + request?: protos.google.cloud.notebooks.v1beta1.IDeleteEnvironmentRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteEnvironment(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteEnvironment()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.delete_environment.js + * region_tag:notebooks_v1beta1_generated_NotebookService_DeleteEnvironment_async + */ + async checkDeleteEnvironmentProgress(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.deleteEnvironment, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists instances in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.notebooks.v1beta1.Instance|Instance}. + * 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 `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listInstances( + request?: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v1beta1.IInstance[], + protos.google.cloud.notebooks.v1beta1.IListInstancesRequest|null, + protos.google.cloud.notebooks.v1beta1.IListInstancesResponse + ]>; + listInstances( + request: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, + protos.google.cloud.notebooks.v1beta1.IListInstancesResponse|null|undefined, + protos.google.cloud.notebooks.v1beta1.IInstance>): void; + listInstances( + request: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, + protos.google.cloud.notebooks.v1beta1.IListInstancesResponse|null|undefined, + protos.google.cloud.notebooks.v1beta1.IInstance>): void; + listInstances( + request?: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, + protos.google.cloud.notebooks.v1beta1.IListInstancesResponse|null|undefined, + protos.google.cloud.notebooks.v1beta1.IInstance>, + callback?: PaginationCallback< + protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, + protos.google.cloud.notebooks.v1beta1.IListInstancesResponse|null|undefined, + protos.google.cloud.notebooks.v1beta1.IInstance>): + Promise<[ + protos.google.cloud.notebooks.v1beta1.IInstance[], + protos.google.cloud.notebooks.v1beta1.IListInstancesRequest|null, + protos.google.cloud.notebooks.v1beta1.IListInstancesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listInstances(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. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @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 protos.google.cloud.notebooks.v1beta1.Instance|Instance} 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 `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listInstancesStream( + request?: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, + 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['listInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInstances.createStream( + this.innerApiCalls.listInstances as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listInstances`, 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. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.notebooks.v1beta1.Instance|Instance}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.list_instances.js + * region_tag:notebooks_v1beta1_generated_NotebookService_ListInstances_async + */ + listInstancesAsync( + request?: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, + 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['listInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInstances.asyncIterate( + this.innerApiCalls['listInstances'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists environments in a project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: `projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing from + * the last result. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.notebooks.v1beta1.Environment|Environment}. + * 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 `listEnvironmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listEnvironments( + request?: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v1beta1.IEnvironment[], + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest|null, + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse + ]>; + listEnvironments( + request: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse|null|undefined, + protos.google.cloud.notebooks.v1beta1.IEnvironment>): void; + listEnvironments( + request: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse|null|undefined, + protos.google.cloud.notebooks.v1beta1.IEnvironment>): void; + listEnvironments( + request?: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse|null|undefined, + protos.google.cloud.notebooks.v1beta1.IEnvironment>, + callback?: PaginationCallback< + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse|null|undefined, + protos.google.cloud.notebooks.v1beta1.IEnvironment>): + Promise<[ + protos.google.cloud.notebooks.v1beta1.IEnvironment[], + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest|null, + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listEnvironments(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. Format: `projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing from + * the last result. + * @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 protos.google.cloud.notebooks.v1beta1.Environment|Environment} 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 `listEnvironmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listEnvironmentsStream( + request?: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, + 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['listEnvironments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listEnvironments.createStream( + this.innerApiCalls.listEnvironments as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listEnvironments`, 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. Format: `projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing from + * the last result. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.notebooks.v1beta1.Environment|Environment}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.list_environments.js + * region_tag:notebooks_v1beta1_generated_NotebookService_ListEnvironments_async + */ + listEnvironmentsAsync( + request?: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, + 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['listEnvironments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listEnvironments.asyncIterate( + this.innerApiCalls['listEnvironments'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @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/interfaces/CallOptions.html | 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.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getIamPolicy( + request: IamProtos.google.iam.v1.GetIamPolicyRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.Policy]> { + return this.iamClient.getIamPolicy(request, options, callback); + } + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + setIamPolicy( + request: IamProtos.google.iam.v1.SetIamPolicyRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.Policy]> { + return this.iamClient.setIamPolicy(request, options, callback); + } + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ + testIamPermissions( + request: IamProtos.google.iam.v1.TestIamPermissionsRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + return this.iamClient.testIamPermissions(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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 environment resource name string. + * + * @param {string} project + * @param {string} environment + * @returns {string} Resource name string. + */ + environmentPath(project:string,environment:string) { + return this.pathTemplates.environmentPathTemplate.render({ + project: project, + environment: environment, + }); + } + + /** + * Parse the project from Environment resource. + * + * @param {string} environmentName + * A fully-qualified path representing Environment resource. + * @returns {string} A string representing the project. + */ + matchProjectFromEnvironmentName(environmentName: string) { + return this.pathTemplates.environmentPathTemplate.match(environmentName).project; + } + + /** + * Parse the environment from Environment resource. + * + * @param {string} environmentName + * A fully-qualified path representing Environment resource. + * @returns {string} A string representing the environment. + */ + matchEnvironmentFromEnvironmentName(environmentName: string) { + return this.pathTemplates.environmentPathTemplate.match(environmentName).environment; + } + + /** + * Return a fully-qualified instance resource name string. + * + * @param {string} project + * @param {string} instance + * @returns {string} Resource name string. + */ + instancePath(project:string,instance:string) { + return this.pathTemplates.instancePathTemplate.render({ + project: project, + instance: instance, + }); + } + + /** + * Parse the project from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the project. + */ + matchProjectFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).project; + } + + /** + * Parse the instance from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).instance; + } + + /** + * 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.notebookServiceStub && !this._terminated) { + return this.notebookServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.iamClient.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_client_config.json b/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_client_config.json new file mode 100644 index 00000000000..f50e40f8530 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_client_config.json @@ -0,0 +1,121 @@ +{ + "interfaces": { + "google.cloud.notebooks.v1beta1.NotebookService": { + "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": { + "ListInstances": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RegisterInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetInstanceAccelerator": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetInstanceMachineType": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetInstanceLabels": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StartInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StopInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ResetInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ReportInstanceInfo": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "IsInstanceUpgradeable": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpgradeInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpgradeInstanceInternal": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListEnvironments": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetEnvironment": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateEnvironment": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteEnvironment": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_proto_list.json b/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_proto_list.json new file mode 100644 index 00000000000..40c171063ca --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_proto_list.json @@ -0,0 +1,5 @@ +[ + "../../protos/google/cloud/notebooks/v1beta1/environment.proto", + "../../protos/google/cloud/notebooks/v1beta1/instance.proto", + "../../protos/google/cloud/notebooks/v1beta1/service.proto" +] diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..193e9b0e75d --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const notebooks = require('@google-cloud/notebooks'); + +function main() { + const notebookServiceClient = new notebooks.NotebookServiceClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..624792a563f --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {NotebookServiceClient} from '@google-cloud/notebooks'; + +// check that the client class type name can be used +function doStuffWithNotebookServiceClient(client: NotebookServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const notebookServiceClient = new NotebookServiceClient(); + doStuffWithNotebookServiceClient(notebookServiceClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/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-notebooks/v1beta1/test/gapic_notebook_service_v1beta1.ts b/owl-bot-staging/google-cloud-notebooks/v1beta1/test/gapic_notebook_service_v1beta1.ts new file mode 100644 index 00000000000..488faefa079 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/test/gapic_notebook_service_v1beta1.ts @@ -0,0 +1,3991 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 notebookserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos, IamProtos, 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('v1beta1.NotebookServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = notebookserviceModule.v1beta1.NotebookServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = notebookserviceModule.v1beta1.NotebookServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = notebookserviceModule.v1beta1.NotebookServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.notebookServiceStub, undefined); + await client.initialize(); + assert(client.notebookServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.notebookServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.notebookServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + 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 notebookserviceModule.v1beta1.NotebookServiceClient({ + 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('getInstance', () => { + it('invokes getInstance without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Instance() + ); + client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); + const [response] = await client.getInstance(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstance without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Instance() + ); + client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstance( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v1beta1.IInstance|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstance with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstance with closed client', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getInstance(request), expectedError); + }); + }); + + describe('isInstanceUpgradeable', () => { + it('invokes isInstanceUpgradeable without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest', ['notebookInstance']); + request.notebookInstance = defaultValue1; + const expectedHeaderRequestParams = `notebook_instance=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableResponse() + ); + client.innerApiCalls.isInstanceUpgradeable = stubSimpleCall(expectedResponse); + const [response] = await client.isInstanceUpgradeable(request); + assert(stub.calledOnce); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes isInstanceUpgradeable without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest', ['notebookInstance']); + request.notebookInstance = defaultValue1; + const expectedHeaderRequestParams = `notebook_instance=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableResponse() + ); + client.innerApiCalls.isInstanceUpgradeable = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.isInstanceUpgradeable( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert(stub.calledOnce); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes isInstanceUpgradeable with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest', ['notebookInstance']); + request.notebookInstance = defaultValue1; + const expectedHeaderRequestParams = `notebook_instance=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.isInstanceUpgradeable = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.isInstanceUpgradeable(request), expectedError); + assert(stub.calledOnce); + const actualRequest = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes isInstanceUpgradeable with closed client', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest', ['notebookInstance']); + request.notebookInstance = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.isInstanceUpgradeable(request), expectedError); + assert(stub.calledOnce); + }); + }); + + describe('getEnvironment', () => { + it('invokes getEnvironment without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.GetEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Environment() + ); + client.innerApiCalls.getEnvironment = stubSimpleCall(expectedResponse); + const [response] = await client.getEnvironment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEnvironment without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.GetEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Environment() + ); + client.innerApiCalls.getEnvironment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getEnvironment( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v1beta1.IEnvironment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEnvironment with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.GetEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getEnvironment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getEnvironment(request), expectedError); + const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEnvironment with closed client', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.GetEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getEnvironment(request), expectedError); + }); + }); + + describe('createInstance', () => { + it('invokes createInstance without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.createInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstance without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createInstance( + request, + (err?: Error|null, + result?: 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.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstance with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstance with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('registerInstance', () => { + it('invokes registerInstance without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.RegisterInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.RegisterInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.registerInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.registerInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.registerInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes registerInstance without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.RegisterInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.RegisterInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.registerInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.registerInstance( + request, + (err?: Error|null, + result?: 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.registerInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes registerInstance with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.RegisterInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.RegisterInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.registerInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.registerInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.registerInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes registerInstance with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.RegisterInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.RegisterInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.registerInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.registerInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.registerInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkRegisterInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRegisterInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRegisterInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRegisterInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('setInstanceAccelerator', () => { + it('invokes setInstanceAccelerator without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall(expectedResponse); + const [operation] = await client.setInstanceAccelerator(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setInstanceAccelerator as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceAccelerator without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setInstanceAccelerator = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInstanceAccelerator( + request, + (err?: Error|null, + result?: 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.setInstanceAccelerator as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceAccelerator with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.setInstanceAccelerator(request), expectedError); + const actualRequest = (client.innerApiCalls.setInstanceAccelerator as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceAccelerator with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.setInstanceAccelerator(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.setInstanceAccelerator as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkSetInstanceAcceleratorProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkSetInstanceAcceleratorProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkSetInstanceAcceleratorProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkSetInstanceAcceleratorProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('setInstanceMachineType', () => { + it('invokes setInstanceMachineType without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setInstanceMachineType = stubLongRunningCall(expectedResponse); + const [operation] = await client.setInstanceMachineType(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setInstanceMachineType as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceMachineType without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setInstanceMachineType = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInstanceMachineType( + request, + (err?: Error|null, + result?: 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.setInstanceMachineType as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceMachineType with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceMachineType = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.setInstanceMachineType(request), expectedError); + const actualRequest = (client.innerApiCalls.setInstanceMachineType as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceMachineType with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceMachineType = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.setInstanceMachineType(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.setInstanceMachineType as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkSetInstanceMachineTypeProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkSetInstanceMachineTypeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkSetInstanceMachineTypeProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkSetInstanceMachineTypeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('setInstanceLabels', () => { + it('invokes setInstanceLabels without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setInstanceLabels = stubLongRunningCall(expectedResponse); + const [operation] = await client.setInstanceLabels(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setInstanceLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceLabels without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setInstanceLabels = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInstanceLabels( + request, + (err?: Error|null, + result?: 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.setInstanceLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceLabels with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceLabels = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.setInstanceLabels(request), expectedError); + const actualRequest = (client.innerApiCalls.setInstanceLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceLabels with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceLabels = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.setInstanceLabels(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.setInstanceLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkSetInstanceLabelsProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkSetInstanceLabelsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkSetInstanceLabelsProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkSetInstanceLabelsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteInstance', () => { + it('invokes deleteInstance without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstance without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteInstance( + request, + (err?: Error|null, + result?: 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.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstance with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstance with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('startInstance', () => { + it('invokes startInstance without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.StartInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StartInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.startInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.startInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startInstance without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.StartInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StartInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.startInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.startInstance( + request, + (err?: Error|null, + result?: 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.startInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startInstance with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.StartInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StartInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.startInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startInstance with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.StartInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StartInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.startInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkStartInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkStartInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkStartInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkStartInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('stopInstance', () => { + it('invokes stopInstance without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.StopInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StopInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.stopInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.stopInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopInstance without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.StopInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StopInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.stopInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.stopInstance( + request, + (err?: Error|null, + result?: 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.stopInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopInstance with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.StopInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StopInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.stopInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopInstance with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.StopInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StopInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.stopInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkStopInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkStopInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkStopInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkStopInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('resetInstance', () => { + it('invokes resetInstance without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ResetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ResetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.resetInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.resetInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resetInstance without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ResetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ResetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.resetInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resetInstance( + request, + (err?: Error|null, + result?: 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.resetInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resetInstance with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ResetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ResetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resetInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.resetInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resetInstance with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ResetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ResetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resetInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.resetInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkResetInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkResetInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkResetInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkResetInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('reportInstanceInfo', () => { + it('invokes reportInstanceInfo without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.reportInstanceInfo = stubLongRunningCall(expectedResponse); + const [operation] = await client.reportInstanceInfo(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.reportInstanceInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reportInstanceInfo without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.reportInstanceInfo = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.reportInstanceInfo( + request, + (err?: Error|null, + result?: 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.reportInstanceInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reportInstanceInfo with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reportInstanceInfo = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.reportInstanceInfo(request), expectedError); + const actualRequest = (client.innerApiCalls.reportInstanceInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reportInstanceInfo with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reportInstanceInfo = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.reportInstanceInfo(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.reportInstanceInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkReportInstanceInfoProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkReportInstanceInfoProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkReportInstanceInfoProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkReportInstanceInfoProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('upgradeInstance', () => { + it('invokes upgradeInstance without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.upgradeInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.upgradeInstance(request); + const [response] = await operation.promise(); + assert(stub.calledOnce); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeInstance without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.upgradeInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.upgradeInstance( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert(stub.calledOnce); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeInstance with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.upgradeInstance(request), expectedError); + assert(stub.calledOnce); + const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeInstance with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.upgradeInstance(request); + await assert.rejects(operation.promise(), expectedError); + assert(stub.calledOnce); + const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpgradeInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpgradeInstanceProgress(expectedResponse.name); + assert(stub.calledOnce); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpgradeInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpgradeInstanceProgress(''), expectedError); + assert(stub.calledOnce); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('upgradeInstanceInternal', () => { + it('invokes upgradeInstanceInternal without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall(expectedResponse); + const [operation] = await client.upgradeInstanceInternal(request); + const [response] = await operation.promise(); + assert(stub.calledOnce); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeInstanceInternal without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.upgradeInstanceInternal( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert(stub.calledOnce); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeInstanceInternal with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.upgradeInstanceInternal(request), expectedError); + assert(stub.calledOnce); + const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeInstanceInternal with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.upgradeInstanceInternal(request); + await assert.rejects(operation.promise(), expectedError); + assert(stub.calledOnce); + const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpgradeInstanceInternalProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpgradeInstanceInternalProgress(expectedResponse.name); + assert(stub.calledOnce); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpgradeInstanceInternalProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpgradeInstanceInternalProgress(''), expectedError); + assert(stub.calledOnce); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('createEnvironment', () => { + it('invokes createEnvironment without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createEnvironment = stubLongRunningCall(expectedResponse); + const [operation] = await client.createEnvironment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createEnvironment without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createEnvironment = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createEnvironment( + request, + (err?: Error|null, + result?: 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.createEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createEnvironment with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEnvironment = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createEnvironment(request), expectedError); + const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createEnvironment with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEnvironment = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createEnvironment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateEnvironmentProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateEnvironmentProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateEnvironmentProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateEnvironmentProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteEnvironment', () => { + it('invokes deleteEnvironment without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteEnvironment = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteEnvironment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteEnvironment without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteEnvironment = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteEnvironment( + request, + (err?: Error|null, + result?: 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.deleteEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteEnvironment with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteEnvironment = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteEnvironment(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteEnvironment with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteEnvironment = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteEnvironment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteEnvironmentProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteEnvironmentProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteEnvironmentProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteEnvironmentProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listInstances', () => { + it('invokes listInstances without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), + ]; + client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); + const [response] = await client.listInstances(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstances without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), + ]; + client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstances( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v1beta1.IInstance[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstances with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listInstances(request), expectedError); + const actualRequest = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstancesStream without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), + ]; + client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1beta1.Instance[] = []; + stream.on('data', (response: protos.google.cloud.notebooks.v1beta1.Instance) => { + 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.listInstances.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listInstancesStream with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1beta1.Instance[] = []; + stream.on('data', (response: protos.google.cloud.notebooks.v1beta1.Instance) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstances without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), + ]; + client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.notebooks.v1beta1.IInstance[] = []; + const iterable = client.listInstancesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstances with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInstancesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.notebooks.v1beta1.IInstance[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listEnvironments', () => { + it('invokes listEnvironments without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), + ]; + client.innerApiCalls.listEnvironments = stubSimpleCall(expectedResponse); + const [response] = await client.listEnvironments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listEnvironments without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), + ]; + client.innerApiCalls.listEnvironments = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listEnvironments( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v1beta1.IEnvironment[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listEnvironments with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listEnvironments = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listEnvironments(request), expectedError); + const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listEnvironmentsStream without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), + ]; + client.descriptors.page.listEnvironments.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listEnvironmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1beta1.Environment[] = []; + stream.on('data', (response: protos.google.cloud.notebooks.v1beta1.Environment) => { + 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.listEnvironments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listEnvironments, request)); + assert( + (client.descriptors.page.listEnvironments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listEnvironmentsStream with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEnvironments.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listEnvironmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1beta1.Environment[] = []; + stream.on('data', (response: protos.google.cloud.notebooks.v1beta1.Environment) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listEnvironments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listEnvironments, request)); + assert( + (client.descriptors.page.listEnvironments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listEnvironments without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), + generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), + ]; + client.descriptors.page.listEnvironments.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.notebooks.v1beta1.IEnvironment[] = []; + const iterable = client.listEnvironmentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listEnvironments with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEnvironments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listEnvironmentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.notebooks.v1beta1.IEnvironment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0)); + }); + it('invokes getIamPolicy with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0)); + }); + it('invokes setIamPolicy with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + 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 notebookserviceModule.v1beta1.NotebookServiceClient({ + 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 notebookserviceModule.v1beta1.NotebookServiceClient({ + 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 notebookserviceModule.v1beta1.NotebookServiceClient({ + 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 notebookserviceModule.v1beta1.NotebookServiceClient({ + 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 notebookserviceModule.v1beta1.NotebookServiceClient({ + 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 notebookserviceModule.v1beta1.NotebookServiceClient({ + 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 notebookserviceModule.v1beta1.NotebookServiceClient({ + 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 notebookserviceModule.v1beta1.NotebookServiceClient({ + 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 notebookserviceModule.v1beta1.NotebookServiceClient({ + 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 notebookserviceModule.v1beta1.NotebookServiceClient({ + 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 notebookserviceModule.v1beta1.NotebookServiceClient({ + 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 notebookserviceModule.v1beta1.NotebookServiceClient({ + 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 notebookserviceModule.v1beta1.NotebookServiceClient({ + 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 notebookserviceModule.v1beta1.NotebookServiceClient({ + 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 notebookserviceModule.v1beta1.NotebookServiceClient({ + 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('environment', () => { + const fakePath = "/rendered/path/environment"; + const expectedParameters = { + project: "projectValue", + environment: "environmentValue", + }; + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.environmentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.environmentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('environmentPath', () => { + const result = client.environmentPath("projectValue", "environmentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.environmentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromEnvironmentName', () => { + const result = client.matchProjectFromEnvironmentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchEnvironmentFromEnvironmentName', () => { + const result = client.matchEnvironmentFromEnvironmentName(fakePath); + assert.strictEqual(result, "environmentValue"); + assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('instance', () => { + const fakePath = "/rendered/path/instance"; + const expectedParameters = { + project: "projectValue", + instance: "instanceValue", + }; + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.instancePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.instancePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath("projectValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-notebooks/v1beta1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/webpack.config.js new file mode 100644 index 00000000000..b41a2c182e9 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v1beta1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'NotebookService', + filename: './notebook-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-notebooks/v2/.eslintignore b/owl-bot-staging/google-cloud-notebooks/v2/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-notebooks/v2/.eslintrc.json b/owl-bot-staging/google-cloud-notebooks/v2/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/.gitignore b/owl-bot-staging/google-cloud-notebooks/v2/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/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-notebooks/v2/.jsdoc.js b/owl-bot-staging/google-cloud-notebooks/v2/.jsdoc.js new file mode 100644 index 00000000000..b562faf1159 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/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/notebooks', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-notebooks/v2/.mocharc.js b/owl-bot-staging/google-cloud-notebooks/v2/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/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-notebooks/v2/.prettierrc.js b/owl-bot-staging/google-cloud-notebooks/v2/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/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-notebooks/v2/README.md b/owl-bot-staging/google-cloud-notebooks/v2/README.md new file mode 100644 index 00000000000..31cec215a8f --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/README.md @@ -0,0 +1 @@ +Notebooks: Nodejs Client diff --git a/owl-bot-staging/google-cloud-notebooks/v2/package.json b/owl-bot-staging/google-cloud-notebooks/v2/package.json new file mode 100644 index 00000000000..c3911a749c3 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/notebooks", + "version": "0.1.0", + "description": "Notebooks client for Node.js", + "repository": "googleapis/nodejs-notebooks", + "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 notebooks", + "notebooks", + "notebook service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/diagnostic_config.proto b/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/diagnostic_config.proto new file mode 100644 index 00000000000..ccd60acd05c --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/diagnostic_config.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.notebooks.v2; + +import "google/api/field_behavior.proto"; + +option csharp_namespace = "Google.Cloud.Notebooks.V2"; +option go_package = "cloud.google.com/go/notebooks/apiv2/notebookspb;notebookspb"; +option java_multiple_files = true; +option java_outer_classname = "DiagnosticConfigProto"; +option java_package = "com.google.cloud.notebooks.v2"; +option php_namespace = "Google\\Cloud\\Notebooks\\V2"; +option ruby_package = "Google::Cloud::Notebooks::V2"; + +// Defines flags that are used to run the diagnostic tool +message DiagnosticConfig { + // Required. User Cloud Storage bucket location (REQUIRED). + // Must be formatted with path prefix (`gs://$GCS_BUCKET`). + // + // Permissions: + // User Managed Notebooks: + // - storage.buckets.writer: Must be given to the project's service account + // attached to VM. + // Google Managed Notebooks: + // - storage.buckets.writer: Must be given to the project's service account or + // user credentials attached to VM depending on authentication mode. + // + // Cloud Storage bucket Log file will be written to + // `gs://$GCS_BUCKET/$RELATIVE_PATH/$VM_DATE_$TIME.tar.gz` + string gcs_bucket = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Defines the relative storage path in the Cloud Storage bucket + // where the diagnostic logs will be written: Default path will be the root + // directory of the Cloud Storage bucket + // (`gs://$GCS_BUCKET/$DATE_$TIME.tar.gz`) Example of full path where Log file + // will be written: `gs://$GCS_BUCKET/$RELATIVE_PATH/` + string relative_path = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Enables flag to repair service for instance + bool enable_repair_flag = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Enables flag to capture packets from the instance for 30 seconds + bool enable_packet_capture_flag = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Enables flag to copy all `/home/jupyter` folder contents + bool enable_copy_home_files_flag = 5 [(google.api.field_behavior) = OPTIONAL]; +} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/event.proto b/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/event.proto new file mode 100644 index 00000000000..1480bbc3e46 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/event.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.notebooks.v2; + +import "google/api/field_behavior.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Notebooks.V2"; +option go_package = "cloud.google.com/go/notebooks/apiv2/notebookspb;notebookspb"; +option java_multiple_files = true; +option java_outer_classname = "EventProto"; +option java_package = "com.google.cloud.notebooks.v2"; +option php_namespace = "Google\\Cloud\\Notebooks\\V2"; +option ruby_package = "Google::Cloud::Notebooks::V2"; + +// The definition of an Event for a managed / semi-managed notebook instance. +message Event { + // The definition of the event types. + enum EventType { + // Event is not specified. + EVENT_TYPE_UNSPECIFIED = 0; + + // The instance / runtime is idle + IDLE = 1; + + // The instance / runtime is available. + // This event indicates that instance / runtime underlying compute is + // operational. + HEARTBEAT = 2; + + // The instance / runtime health is available. + // This event indicates that instance / runtime health information. + HEALTH = 3; + + // The instance / runtime is available. + // This event allows instance / runtime to send Host maintenance + // information to Control Plane. + // https://cloud.google.com/compute/docs/gpus/gpu-host-maintenance + MAINTENANCE = 4; + + // The instance / runtime is available. + // This event indicates that the instance had metadata that needs to be + // modified. + METADATA_CHANGE = 5; + } + + // Optional. Event report time. + google.protobuf.Timestamp report_time = 1 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Event type. + EventType type = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Event details. This field is used to pass event information. + map details = 3 [(google.api.field_behavior) = OPTIONAL]; +} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/gce_setup.proto b/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/gce_setup.proto new file mode 100644 index 00000000000..e3fb8b18d6f --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/gce_setup.proto @@ -0,0 +1,340 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.notebooks.v2; + +import "google/api/field_behavior.proto"; + +option csharp_namespace = "Google.Cloud.Notebooks.V2"; +option go_package = "cloud.google.com/go/notebooks/apiv2/notebookspb;notebookspb"; +option java_multiple_files = true; +option java_outer_classname = "GceSetupProto"; +option java_package = "com.google.cloud.notebooks.v2"; +option php_namespace = "Google\\Cloud\\Notebooks\\V2"; +option ruby_package = "Google::Cloud::Notebooks::V2"; + +// The definition of a network interface resource attached to a VM. +message NetworkInterface { + // The type of vNIC driver. + // Default should be NIC_TYPE_UNSPECIFIED. + enum NicType { + // No type specified. + NIC_TYPE_UNSPECIFIED = 0; + + // VIRTIO + VIRTIO_NET = 1; + + // GVNIC + GVNIC = 2; + } + + // Optional. The name of the VPC that this VM instance is in. + // Format: + // `projects/{project_id}/global/networks/{network_id}` + string network = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The name of the subnet that this VM instance is in. + // Format: + // `projects/{project_id}/regions/{region}/subnetworks/{subnetwork_id}` + string subnet = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The type of vNIC to be used on this interface. This may be gVNIC + // or VirtioNet. + NicType nic_type = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Definition of a custom Compute Engine virtual machine image for starting a +// notebook instance with the environment installed directly on the VM. +message VmImage { + // Required. The name of the Google Cloud project that this VM image belongs + // to. Format: `{project_id}` + string project = 1 [(google.api.field_behavior) = REQUIRED]; + + // The reference to an external Compute Engine VM image. + oneof image { + // Optional. Use VM image name to find the image. + string name = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Use this VM image family to find the image; the newest image in + // this family will be used. + string family = 3 [(google.api.field_behavior) = OPTIONAL]; + } +} + +// Definition of a container image for starting a notebook instance with the +// environment installed in a container. +message ContainerImage { + // Required. The path to the container image repository. For example: + // `gcr.io/{project_id}/{image_name}` + string repository = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The tag of the container image. If not specified, this defaults + // to the latest tag. + string tag = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// An accelerator configuration for a VM instance +// Definition of a hardware accelerator. Note that there is no check on `type` +// and `core_count` combinations. TPUs are not supported. +// See [GPUs on Compute +// Engine](https://cloud.google.com/compute/docs/gpus/#gpus-list) to find a +// valid combination. +message AcceleratorConfig { + // Definition of the types of hardware accelerators that can be used on + // this instance. + enum AcceleratorType { + // Accelerator type is not specified. + ACCELERATOR_TYPE_UNSPECIFIED = 0; + + // Accelerator type is Nvidia Tesla P100. + NVIDIA_TESLA_P100 = 2; + + // Accelerator type is Nvidia Tesla V100. + NVIDIA_TESLA_V100 = 3; + + // Accelerator type is Nvidia Tesla P4. + NVIDIA_TESLA_P4 = 4; + + // Accelerator type is Nvidia Tesla T4. + NVIDIA_TESLA_T4 = 5; + + // Accelerator type is Nvidia Tesla A100 - 40GB. + NVIDIA_TESLA_A100 = 11; + + // Accelerator type is Nvidia Tesla A100 - 80GB. + NVIDIA_A100_80GB = 12; + + // Accelerator type is Nvidia Tesla L4. + NVIDIA_L4 = 13; + + // Accelerator type is NVIDIA Tesla T4 Virtual Workstations. + NVIDIA_TESLA_T4_VWS = 8; + + // Accelerator type is NVIDIA Tesla P100 Virtual Workstations. + NVIDIA_TESLA_P100_VWS = 9; + + // Accelerator type is NVIDIA Tesla P4 Virtual Workstations. + NVIDIA_TESLA_P4_VWS = 10; + } + + // Optional. Type of this accelerator. + AcceleratorType type = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Count of cores of this accelerator. + int64 core_count = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// A set of Shielded Instance options. +// See [Images using supported Shielded VM +// features](https://cloud.google.com/compute/docs/instances/modifying-shielded-vm). +// Not all combinations are valid. +message ShieldedInstanceConfig { + // Optional. Defines whether the VM instance has Secure Boot enabled. + // + // Secure Boot helps ensure that the system only runs authentic software by + // verifying the digital signature of all boot components, and halting the + // boot process if signature verification fails. Disabled by default. + bool enable_secure_boot = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Defines whether the VM instance has the vTPM enabled. Enabled by + // default. + bool enable_vtpm = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Defines whether the VM instance has integrity monitoring enabled. + // + // Enables monitoring and attestation of the boot integrity of the VM + // instance. The attestation is performed against the integrity policy + // baseline. This baseline is initially derived from the implicitly trusted + // boot image when the VM instance is created. Enabled by default. + bool enable_integrity_monitoring = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// A GPU driver configuration +message GPUDriverConfig { + // Optional. Whether the end user authorizes Google Cloud to install GPU + // driver on this VM instance. If this field is empty or set to false, the GPU + // driver won't be installed. Only applicable to instances with GPUs. + bool enable_gpu_driver = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Specify a custom Cloud Storage path where the GPU driver is + // stored. If not specified, we'll automatically choose from official GPU + // drivers. + string custom_gpu_driver_path = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// An instance-attached disk resource. +message DataDisk { + // Optional. The size of the disk in GB attached to this VM instance, up to a + // maximum of 64000 GB (64 TB). If not specified, this defaults to 100. + int64 disk_size_gb = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Input only. Indicates the type of the disk. + DiskType disk_type = 2 [ + (google.api.field_behavior) = INPUT_ONLY, + (google.api.field_behavior) = OPTIONAL + ]; + + // Optional. Input only. Disk encryption method used on the boot and data + // disks, defaults to GMEK. + DiskEncryption disk_encryption = 5 [ + (google.api.field_behavior) = INPUT_ONLY, + (google.api.field_behavior) = OPTIONAL + ]; + + // Optional. Input only. The KMS key used to encrypt the disks, only + // applicable if disk_encryption is CMEK. Format: + // `projects/{project_id}/locations/{location}/keyRings/{key_ring_id}/cryptoKeys/{key_id}` + // + // Learn more about using your own encryption keys. + string kms_key = 6 [ + (google.api.field_behavior) = INPUT_ONLY, + (google.api.field_behavior) = OPTIONAL + ]; +} + +// The definition of a boot disk. +message BootDisk { + // Optional. The size of the boot disk in GB attached to this instance, up to + // a maximum of 64000 GB (64 TB). If not specified, this defaults to the + // recommended value of 150GB. + int64 disk_size_gb = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Indicates the type of the disk. + DiskType disk_type = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Input only. Disk encryption method used on the boot and data + // disks, defaults to GMEK. + DiskEncryption disk_encryption = 3 [ + (google.api.field_behavior) = INPUT_ONLY, + (google.api.field_behavior) = OPTIONAL + ]; + + // Optional. Input only. The KMS key used to encrypt the disks, only + // applicable if disk_encryption is CMEK. Format: + // `projects/{project_id}/locations/{location}/keyRings/{key_ring_id}/cryptoKeys/{key_id}` + // + // Learn more about using your own encryption keys. + string kms_key = 4 [ + (google.api.field_behavior) = INPUT_ONLY, + (google.api.field_behavior) = OPTIONAL + ]; +} + +// A service account that acts as an identity. +message ServiceAccount { + // Optional. Email address of the service account. + string email = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The list of scopes to be made available for this service + // account. Set by the CLH to https://www.googleapis.com/auth/cloud-platform + repeated string scopes = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The definition of how to configure a VM instance outside of Resources and +// Identity. +message GceSetup { + // Optional. The machine type of the VM instance. + // https://cloud.google.com/compute/docs/machine-resource + string machine_type = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The hardware accelerators used on this instance. If you use + // accelerators, make sure that your configuration has + // [enough vCPUs and memory to support the `machine_type` you have + // selected](https://cloud.google.com/compute/docs/gpus/#gpus-list). + // Currently supports only one accelerator configuration. + repeated AcceleratorConfig accelerator_configs = 2 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The service account that serves as an identity for the VM + // instance. Currently supports only one service account. + repeated ServiceAccount service_accounts = 3 + [(google.api.field_behavior) = OPTIONAL]; + + // Type of the image; can be one of VM image, or container image. + oneof image { + // Optional. Use a Compute Engine VM image to start the notebook instance. + VmImage vm_image = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Use a container image to start the notebook instance. + ContainerImage container_image = 5 [(google.api.field_behavior) = OPTIONAL]; + } + + // Optional. The boot disk for the VM. + BootDisk boot_disk = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Data disks attached to the VM instance. + // Currently supports only one data disk. + repeated DataDisk data_disks = 7 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Shielded VM configuration. + // [Images using supported Shielded VM + // features](https://cloud.google.com/compute/docs/instances/modifying-shielded-vm). + ShieldedInstanceConfig shielded_instance_config = 8 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The network interfaces for the VM. + // Supports only one interface. + repeated NetworkInterface network_interfaces = 9 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If true, no external IP will be assigned to this VM instance. + bool disable_public_ip = 10 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The Compute Engine tags to add to runtime (see [Tagging + // instances](https://cloud.google.com/compute/docs/label-or-tag-resources#tags)). + repeated string tags = 11 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Custom metadata to apply to this instance. + map metadata = 12 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Flag to enable ip forwarding or not, default false/off. + // https://cloud.google.com/vpc/docs/using-routes#canipforward + bool enable_ip_forwarding = 13 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Configuration for GPU drivers. + GPUDriverConfig gpu_driver_config = 14 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Definition of the disk encryption options. +enum DiskEncryption { + // Disk encryption is not specified. + DISK_ENCRYPTION_UNSPECIFIED = 0; + + // Use Google managed encryption keys to encrypt the boot disk. + GMEK = 1; + + // Use customer managed encryption keys to encrypt the boot disk. + CMEK = 2; +} + +// Possible disk types. +enum DiskType { + // Disk type not set. + DISK_TYPE_UNSPECIFIED = 0; + + // Standard persistent disk type. + PD_STANDARD = 1; + + // SSD persistent disk type. + PD_SSD = 2; + + // Balanced persistent disk type. + PD_BALANCED = 3; + + // Extreme persistent disk type. + PD_EXTREME = 4; +} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/instance.proto b/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/instance.proto new file mode 100644 index 00000000000..9a3dff5bfe5 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/instance.proto @@ -0,0 +1,231 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.notebooks.v2; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/notebooks/v2/gce_setup.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Notebooks.V2"; +option go_package = "cloud.google.com/go/notebooks/apiv2/notebookspb;notebookspb"; +option java_multiple_files = true; +option java_outer_classname = "InstanceProto"; +option java_package = "com.google.cloud.notebooks.v2"; +option php_namespace = "Google\\Cloud\\Notebooks\\V2"; +option ruby_package = "Google::Cloud::Notebooks::V2"; + +// The entry of VM image upgrade history. +message UpgradeHistoryEntry { + // The definition of the states of this upgrade history entry. + enum State { + // State is not specified. + STATE_UNSPECIFIED = 0; + + // The instance upgrade is started. + STARTED = 1; + + // The instance upgrade is succeeded. + SUCCEEDED = 2; + + // The instance upgrade is failed. + FAILED = 3; + } + + // The definition of operations of this upgrade history entry. + enum Action { + // Operation is not specified. + ACTION_UNSPECIFIED = 0; + + // Upgrade. + UPGRADE = 1; + + // Rollback. + ROLLBACK = 2; + } + + // Optional. The snapshot of the boot disk of this notebook instance before + // upgrade. + string snapshot = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The VM image before this instance upgrade. + string vm_image = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The container image before this instance upgrade. + string container_image = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The framework of this notebook instance. + string framework = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The version of the notebook instance before this upgrade. + string version = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The state of this instance upgrade history entry. + State state = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Immutable. The time that this instance upgrade history entry is created. + google.protobuf.Timestamp create_time = 7 + [(google.api.field_behavior) = IMMUTABLE]; + + // Optional. Action. Rolloback or Upgrade. + Action action = 8 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Target VM Version, like m63. + string target_version = 9 [(google.api.field_behavior) = OPTIONAL]; +} + +// The definition of a notebook instance. +message Instance { + option (google.api.resource) = { + type: "notebooks.googleapis.com/Instance" + pattern: "projects/{project}/locations/{location}/instances/{instance}" + plural: "instances" + singular: "instance" + }; + + // Output only. The name of this notebook instance. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Setup for the Notebook instance. + oneof infrastructure { + // Optional. Compute Engine setup for the notebook. Uses notebook-defined + // fields. + GceSetup gce_setup = 2 [(google.api.field_behavior) = OPTIONAL]; + } + + // Output only. The proxy endpoint that is used to access the Jupyter + // notebook. + string proxy_uri = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Input only. The owner of this instance after creation. Format: + // `alias@example.com` + // + // Currently supports one owner only. If not specified, all of the service + // account users of your VM instance's service account can use + // the instance. + repeated string instance_owners = 4 [ + (google.api.field_behavior) = INPUT_ONLY, + (google.api.field_behavior) = OPTIONAL + ]; + + // Output only. Email address of entity that sent original CreateInstance + // request. + string creator = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The state of this instance. + State state = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The upgrade history of this instance. + repeated UpgradeHistoryEntry upgrade_history = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Unique ID of the resource. + string id = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Instance health_state. + HealthState health_state = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Additional information about instance health. + // Example: + // + // healthInfo": { + // "docker_proxy_agent_status": "1", + // "docker_status": "1", + // "jupyterlab_api_status": "-1", + // "jupyterlab_status": "-1", + // "updated": "2020-10-18 09:40:03.573409" + // } + map health_info = 10 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Instance creation time. + google.protobuf.Timestamp create_time = 11 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Instance update time. + google.protobuf.Timestamp update_time = 12 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. If true, the notebook instance will not register with the proxy. + bool disable_proxy_access = 13 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Labels to apply to this instance. + // These can be later modified by the UpdateInstance method. + map labels = 14 [(google.api.field_behavior) = OPTIONAL]; +} + +// The definition of the states of this instance. +enum State { + // State is not specified. + STATE_UNSPECIFIED = 0; + + // The control logic is starting the instance. + STARTING = 1; + + // The control logic is installing required frameworks and registering the + // instance with notebook proxy + PROVISIONING = 2; + + // The instance is running. + ACTIVE = 3; + + // The control logic is stopping the instance. + STOPPING = 4; + + // The instance is stopped. + STOPPED = 5; + + // The instance is deleted. + DELETED = 6; + + // The instance is upgrading. + UPGRADING = 7; + + // The instance is being created. + INITIALIZING = 8; + + // The instance is suspending. + SUSPENDING = 9; + + // The instance is suspended. + SUSPENDED = 10; +} + +// The instance health state. +enum HealthState { + // The instance substate is unknown. + HEALTH_STATE_UNSPECIFIED = 0; + + // The instance is known to be in an healthy state + // (for example, critical daemons are running) + // Applies to ACTIVE state. + HEALTHY = 1; + + // The instance is known to be in an unhealthy state + // (for example, critical daemons are not running) + // Applies to ACTIVE state. + UNHEALTHY = 2; + + // The instance has not installed health monitoring agent. + // Applies to ACTIVE state. + AGENT_NOT_INSTALLED = 3; + + // The instance health monitoring agent is not running. + // Applies to ACTIVE state. + AGENT_NOT_RUNNING = 4; +} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/service.proto b/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/service.proto new file mode 100644 index 00000000000..04bcb485cc8 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/service.proto @@ -0,0 +1,413 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.notebooks.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/notebooks/v2/diagnostic_config.proto"; +import "google/cloud/notebooks/v2/instance.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.Notebooks.V2"; +option go_package = "cloud.google.com/go/notebooks/apiv2/notebookspb;notebookspb"; +option java_multiple_files = true; +option java_outer_classname = "ServiceProto"; +option java_package = "com.google.cloud.notebooks.v2"; +option php_namespace = "Google\\Cloud\\Notebooks\\V2"; +option ruby_package = "Google::Cloud::Notebooks::V2"; + +// API v2 service for Workbench Notebooks Instances. +service NotebookService { + option (google.api.default_host) = "notebooks.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Lists instances in a given project and location. + rpc ListInstances(ListInstancesRequest) returns (ListInstancesResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*}/instances" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets details of a single Instance. + rpc GetInstance(GetInstanceRequest) returns (Instance) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/instances/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new Instance in a given project and location. + rpc CreateInstance(CreateInstanceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*}/instances" + body: "instance" + }; + option (google.api.method_signature) = "parent,instance,instance_id"; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // UpdateInstance updates an Instance. + rpc UpdateInstance(UpdateInstanceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v2/{instance.name=projects/*/locations/*/instances/*}" + body: "instance" + }; + option (google.api.method_signature) = "instance,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Deletes a single Instance. + rpc DeleteInstance(DeleteInstanceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/instances/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "OperationMetadata" + }; + } + + // Starts a notebook instance. + rpc StartInstance(StartInstanceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{name=projects/*/locations/*/instances/*}:start" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Stops a notebook instance. + rpc StopInstance(StopInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{name=projects/*/locations/*/instances/*}:stop" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Resets a notebook instance. + rpc ResetInstance(ResetInstanceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{name=projects/*/locations/*/instances/*}:reset" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Checks whether a notebook instance is upgradable. + rpc CheckInstanceUpgradability(CheckInstanceUpgradabilityRequest) + returns (CheckInstanceUpgradabilityResponse) { + option (google.api.http) = { + get: "/v2/{notebook_instance=projects/*/locations/*/instances/*}:checkUpgradability" + }; + } + + // Upgrades a notebook instance to the latest version. + rpc UpgradeInstance(UpgradeInstanceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{name=projects/*/locations/*/instances/*}:upgrade" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Rollbacks a notebook instance to the previous version. + rpc RollbackInstance(RollbackInstanceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{name=projects/*/locations/*/instances/*}:rollback" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } + + // Creates a Diagnostic File and runs Diagnostic Tool given an Instance. + rpc DiagnoseInstance(DiagnoseInstanceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{name=projects/*/locations/*/instances/*}:diagnose" + body: "*" + }; + option (google.api.method_signature) = "name,diagnostic_config"; + option (google.longrunning.operation_info) = { + response_type: "Instance" + metadata_type: "OperationMetadata" + }; + } +} + +// Represents the metadata of the long-running operation. +message OperationMetadata { + // The time the operation was created. + google.protobuf.Timestamp create_time = 1; + + // The time the operation finished running. + google.protobuf.Timestamp end_time = 2; + + // Server-defined resource path for the target of the operation. + string target = 3; + + // Name of the verb executed by the operation. + string verb = 4; + + // Human-readable status of the operation, if any. + string status_message = 5; + + // Identifies whether the user has requested cancellation + // of the operation. Operations that have successfully been cancelled + // have [Operation.error][] value with a + // [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + // `Code.CANCELLED`. + bool requested_cancellation = 6; + + // API version used to start the operation. + string api_version = 7; + + // API endpoint name of this operation. + string endpoint = 8; +} + +// Request for listing notebook instances. +message ListInstancesRequest { + // Required. Format: + // `parent=projects/{project_id}/locations/{location}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "notebooks.googleapis.com/Instance" + } + ]; + + // Optional. Maximum return size of the list call. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A previous returned page token that can be used to continue + // listing from the last result. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Sort results. Supported values are "name", "name desc" or "" + // (unsorted). + string order_by = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. List filter. + string filter = 5 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response for listing notebook instances. +message ListInstancesResponse { + // A list of returned instances. + repeated Instance instances = 1; + + // Page token that can be used to continue listing from the last result in the + // next list call. + string next_page_token = 2; + + // Locations that could not be reached. For example, + // ['us-west1-a', 'us-central1-b']. + // A ListInstancesResponse will only contain either instances or unreachables, + repeated string unreachable = 3; +} + +// Request for getting a notebook instance. +message GetInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "notebooks.googleapis.com/Instance" + } + ]; +} + +// Request for creating a notebook instance. +message CreateInstanceRequest { + // Required. Format: + // `parent=projects/{project_id}/locations/{location}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "notebooks.googleapis.com/Instance" + } + ]; + + // Required. User-defined unique ID of this instance. + string instance_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The instance to be created. + Instance instance = 3 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Idempotent request UUID. + string request_id = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for updating a notebook instance. +message UpdateInstanceRequest { + // Required. A representation of an instance. + Instance instance = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Mask used to update an instance + google.protobuf.FieldMask update_mask = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Optional. Idempotent request UUID. + string request_id = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for deleting a notebook instance. +message DeleteInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "notebooks.googleapis.com/Instance" + } + ]; + + // Optional. Idempotent request UUID. + string request_id = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for starting a notebook instance +message StartInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for stopping a notebook instance +message StopInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for resetting a notebook instance +message ResetInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for checking if a notebook instance is upgradeable. +message CheckInstanceUpgradabilityRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string notebook_instance = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response for checking if a notebook instance is upgradeable. +message CheckInstanceUpgradabilityResponse { + // If an instance is upgradeable. + bool upgradeable = 1; + + // The version this instance will be upgraded to if calling the upgrade + // endpoint. This field will only be populated if field upgradeable is true. + string upgrade_version = 2; + + // Additional information about upgrade. + string upgrade_info = 3; + + // The new image self link this instance will be upgraded to if calling the + // upgrade endpoint. This field will only be populated if field upgradeable + // is true. + string upgrade_image = 4; +} + +// Request for upgrading a notebook instance +message UpgradeInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for rollbacking a notebook instance +message RollbackInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "notebooks.googleapis.com/Instance" + } + ]; + + // Required. The snapshot for rollback. + // Example: "projects/test-project/global/snapshots/krwlzipynril". + string target_snapshot = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. Output only. Revision Id + string revision_id = 3 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.field_behavior) = REQUIRED + ]; +} + +// Request for creating a notebook instance diagnostic file. +message DiagnoseInstanceRequest { + // Required. Format: + // `projects/{project_id}/locations/{location}/instances/{instance_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "notebooks.googleapis.com/Instance" + } + ]; + + // Required. Defines flags that are used to run the diagnostic tool + DiagnosticConfig diagnostic_config = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Optional. Maxmium amount of time in minutes before the operation times out. + int32 timeout_minutes = 3 [(google.api.field_behavior) = OPTIONAL]; +} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.check_instance_upgradability.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.check_instance_upgradability.js new file mode 100644 index 00000000000..226e4e33fb3 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.check_instance_upgradability.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(notebookInstance) { + // [START notebooks_v2_generated_NotebookService_CheckInstanceUpgradability_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const notebookInstance = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callCheckInstanceUpgradability() { + // Construct request + const request = { + notebookInstance, + }; + + // Run request + const response = await notebooksClient.checkInstanceUpgradability(request); + console.log(response); + } + + callCheckInstanceUpgradability(); + // [END notebooks_v2_generated_NotebookService_CheckInstanceUpgradability_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.create_instance.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.create_instance.js new file mode 100644 index 00000000000..c47a2f0c711 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.create_instance.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(parent, instanceId, instance) { + // [START notebooks_v2_generated_NotebookService_CreateInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + */ + // const parent = 'abc123' + /** + * Required. User-defined unique ID of this instance. + */ + // const instanceId = 'abc123' + /** + * Required. The instance to be created. + */ + // const instance = {} + /** + * Optional. Idempotent request UUID. + */ + // const requestId = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callCreateInstance() { + // Construct request + const request = { + parent, + instanceId, + instance, + }; + + // Run request + const [operation] = await notebooksClient.createInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateInstance(); + // [END notebooks_v2_generated_NotebookService_CreateInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.delete_instance.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.delete_instance.js new file mode 100644 index 00000000000..d20dd83e65b --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.delete_instance.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(name) { + // [START notebooks_v2_generated_NotebookService_DeleteInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + /** + * Optional. Idempotent request UUID. + */ + // const requestId = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callDeleteInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.deleteInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteInstance(); + // [END notebooks_v2_generated_NotebookService_DeleteInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.diagnose_instance.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.diagnose_instance.js new file mode 100644 index 00000000000..2a68a795b57 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.diagnose_instance.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(name, diagnosticConfig) { + // [START notebooks_v2_generated_NotebookService_DiagnoseInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + /** + * Required. Defines flags that are used to run the diagnostic tool + */ + // const diagnosticConfig = {} + /** + * Optional. Maxmium amount of time in minutes before the operation times out. + */ + // const timeoutMinutes = 1234 + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callDiagnoseInstance() { + // Construct request + const request = { + name, + diagnosticConfig, + }; + + // Run request + const [operation] = await notebooksClient.diagnoseInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDiagnoseInstance(); + // [END notebooks_v2_generated_NotebookService_DiagnoseInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.get_instance.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.get_instance.js new file mode 100644 index 00000000000..1f75cd51458 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.get_instance.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 notebooks_v2_generated_NotebookService_GetInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callGetInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await notebooksClient.getInstance(request); + console.log(response); + } + + callGetInstance(); + // [END notebooks_v2_generated_NotebookService_GetInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.list_instances.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.list_instances.js new file mode 100644 index 00000000000..996876dfe70 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.list_instances.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 notebooks_v2_generated_NotebookService_ListInstances_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + */ + // const parent = 'abc123' + /** + * Optional. Maximum return size of the list call. + */ + // const pageSize = 1234 + /** + * Optional. A previous returned page token that can be used to continue + * listing from the last result. + */ + // const pageToken = 'abc123' + /** + * Optional. Sort results. Supported values are "name", "name desc" or "" + * (unsorted). + */ + // const orderBy = 'abc123' + /** + * Optional. List filter. + */ + // const filter = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callListInstances() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await notebooksClient.listInstancesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListInstances(); + // [END notebooks_v2_generated_NotebookService_ListInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.reset_instance.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.reset_instance.js new file mode 100644 index 00000000000..2e35fc2e837 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.reset_instance.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 notebooks_v2_generated_NotebookService_ResetInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callResetInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.resetInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callResetInstance(); + // [END notebooks_v2_generated_NotebookService_ResetInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.rollback_instance.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.rollback_instance.js new file mode 100644 index 00000000000..5af331d50df --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.rollback_instance.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(name, targetSnapshot, revisionId) { + // [START notebooks_v2_generated_NotebookService_RollbackInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + /** + * Required. The snapshot for rollback. + * Example: "projects/test-project/global/snapshots/krwlzipynril". + */ + // const targetSnapshot = 'abc123' + /** + * Required. Output only. Revision Id + */ + // const revisionId = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callRollbackInstance() { + // Construct request + const request = { + name, + targetSnapshot, + revisionId, + }; + + // Run request + const [operation] = await notebooksClient.rollbackInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRollbackInstance(); + // [END notebooks_v2_generated_NotebookService_RollbackInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.start_instance.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.start_instance.js new file mode 100644 index 00000000000..0e25373f5cf --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.start_instance.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 notebooks_v2_generated_NotebookService_StartInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callStartInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.startInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callStartInstance(); + // [END notebooks_v2_generated_NotebookService_StartInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.stop_instance.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.stop_instance.js new file mode 100644 index 00000000000..5be18e647aa --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.stop_instance.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 notebooks_v2_generated_NotebookService_StopInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callStopInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.stopInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callStopInstance(); + // [END notebooks_v2_generated_NotebookService_StopInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.update_instance.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.update_instance.js new file mode 100644 index 00000000000..ecbc45352f0 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.update_instance.js @@ -0,0 +1,71 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(instance, updateMask) { + // [START notebooks_v2_generated_NotebookService_UpdateInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A representation of an instance. + */ + // const instance = {} + /** + * Required. Mask used to update an instance + */ + // const updateMask = {} + /** + * Optional. Idempotent request UUID. + */ + // const requestId = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callUpdateInstance() { + // Construct request + const request = { + instance, + updateMask, + }; + + // Run request + const [operation] = await notebooksClient.updateInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateInstance(); + // [END notebooks_v2_generated_NotebookService_UpdateInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.upgrade_instance.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.upgrade_instance.js new file mode 100644 index 00000000000..43bd123be1b --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.upgrade_instance.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 notebooks_v2_generated_NotebookService_UpgradeInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + */ + // const name = 'abc123' + + // Imports the Notebooks library + const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; + + // Instantiates a client + const notebooksClient = new NotebookServiceClient(); + + async function callUpgradeInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await notebooksClient.upgradeInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpgradeInstance(); + // [END notebooks_v2_generated_NotebookService_UpgradeInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/snippet_metadata_google.cloud.notebooks.v2.json b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/snippet_metadata_google.cloud.notebooks.v2.json new file mode 100644 index 00000000000..51586370b43 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/snippet_metadata_google.cloud.notebooks.v2.json @@ -0,0 +1,551 @@ +{ + "clientLibrary": { + "name": "nodejs-notebooks", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.notebooks.v2", + "version": "v2" + } + ] + }, + "snippets": [ + { + "regionTag": "notebooks_v2_generated_NotebookService_ListInstances_async", + "title": "NotebookService listInstances Sample", + "origin": "API_DEFINITION", + "description": " Lists instances in a given project and location.", + "canonical": true, + "file": "notebook_service.list_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 74, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListInstances", + "fullName": "google.cloud.notebooks.v2.NotebookService.ListInstances", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.notebooks.v2.ListInstancesResponse", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" + }, + "method": { + "shortName": "ListInstances", + "fullName": "google.cloud.notebooks.v2.NotebookService.ListInstances", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v2.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v2_generated_NotebookService_GetInstance_async", + "title": "NotebookService getInstance Sample", + "origin": "API_DEFINITION", + "description": " Gets details of a single Instance.", + "canonical": true, + "file": "notebook_service.get_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetInstance", + "fullName": "google.cloud.notebooks.v2.NotebookService.GetInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.notebooks.v2.Instance", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" + }, + "method": { + "shortName": "GetInstance", + "fullName": "google.cloud.notebooks.v2.NotebookService.GetInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v2.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v2_generated_NotebookService_CreateInstance_async", + "title": "NotebookService createInstance Sample", + "origin": "API_DEFINITION", + "description": " Creates a new Instance in a given project and location.", + "canonical": true, + "file": "notebook_service.create_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateInstance", + "fullName": "google.cloud.notebooks.v2.NotebookService.CreateInstance", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "instance_id", + "type": "TYPE_STRING" + }, + { + "name": "instance", + "type": ".google.cloud.notebooks.v2.Instance" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" + }, + "method": { + "shortName": "CreateInstance", + "fullName": "google.cloud.notebooks.v2.NotebookService.CreateInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v2.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v2_generated_NotebookService_UpdateInstance_async", + "title": "NotebookService updateInstance Sample", + "origin": "API_DEFINITION", + "description": " UpdateInstance updates an Instance.", + "canonical": true, + "file": "notebook_service.update_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateInstance", + "fullName": "google.cloud.notebooks.v2.NotebookService.UpdateInstance", + "async": true, + "parameters": [ + { + "name": "instance", + "type": ".google.cloud.notebooks.v2.Instance" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" + }, + "method": { + "shortName": "UpdateInstance", + "fullName": "google.cloud.notebooks.v2.NotebookService.UpdateInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v2.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v2_generated_NotebookService_DeleteInstance_async", + "title": "NotebookService deleteInstance Sample", + "origin": "API_DEFINITION", + "description": " Deletes a single Instance.", + "canonical": true, + "file": "notebook_service.delete_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteInstance", + "fullName": "google.cloud.notebooks.v2.NotebookService.DeleteInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" + }, + "method": { + "shortName": "DeleteInstance", + "fullName": "google.cloud.notebooks.v2.NotebookService.DeleteInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v2.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v2_generated_NotebookService_StartInstance_async", + "title": "NotebookService startInstance Sample", + "origin": "API_DEFINITION", + "description": " Starts a notebook instance.", + "canonical": true, + "file": "notebook_service.start_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StartInstance", + "fullName": "google.cloud.notebooks.v2.NotebookService.StartInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" + }, + "method": { + "shortName": "StartInstance", + "fullName": "google.cloud.notebooks.v2.NotebookService.StartInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v2.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v2_generated_NotebookService_StopInstance_async", + "title": "NotebookService stopInstance Sample", + "origin": "API_DEFINITION", + "description": " Stops a notebook instance.", + "canonical": true, + "file": "notebook_service.stop_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StopInstance", + "fullName": "google.cloud.notebooks.v2.NotebookService.StopInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" + }, + "method": { + "shortName": "StopInstance", + "fullName": "google.cloud.notebooks.v2.NotebookService.StopInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v2.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v2_generated_NotebookService_ResetInstance_async", + "title": "NotebookService resetInstance Sample", + "origin": "API_DEFINITION", + "description": " Resets a notebook instance.", + "canonical": true, + "file": "notebook_service.reset_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ResetInstance", + "fullName": "google.cloud.notebooks.v2.NotebookService.ResetInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" + }, + "method": { + "shortName": "ResetInstance", + "fullName": "google.cloud.notebooks.v2.NotebookService.ResetInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v2.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v2_generated_NotebookService_CheckInstanceUpgradability_async", + "title": "NotebookService checkInstanceUpgradability Sample", + "origin": "API_DEFINITION", + "description": " Checks whether a notebook instance is upgradable.", + "canonical": true, + "file": "notebook_service.check_instance_upgradability.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CheckInstanceUpgradability", + "fullName": "google.cloud.notebooks.v2.NotebookService.CheckInstanceUpgradability", + "async": true, + "parameters": [ + { + "name": "notebook_instance", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.notebooks.v2.CheckInstanceUpgradabilityResponse", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" + }, + "method": { + "shortName": "CheckInstanceUpgradability", + "fullName": "google.cloud.notebooks.v2.NotebookService.CheckInstanceUpgradability", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v2.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v2_generated_NotebookService_UpgradeInstance_async", + "title": "NotebookService upgradeInstance Sample", + "origin": "API_DEFINITION", + "description": " Upgrades a notebook instance to the latest version.", + "canonical": true, + "file": "notebook_service.upgrade_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpgradeInstance", + "fullName": "google.cloud.notebooks.v2.NotebookService.UpgradeInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" + }, + "method": { + "shortName": "UpgradeInstance", + "fullName": "google.cloud.notebooks.v2.NotebookService.UpgradeInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v2.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v2_generated_NotebookService_RollbackInstance_async", + "title": "NotebookService rollbackInstance Sample", + "origin": "API_DEFINITION", + "description": " Rollbacks a notebook instance to the previous version.", + "canonical": true, + "file": "notebook_service.rollback_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RollbackInstance", + "fullName": "google.cloud.notebooks.v2.NotebookService.RollbackInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "target_snapshot", + "type": "TYPE_STRING" + }, + { + "name": "revision_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" + }, + "method": { + "shortName": "RollbackInstance", + "fullName": "google.cloud.notebooks.v2.NotebookService.RollbackInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v2.NotebookService" + } + } + } + }, + { + "regionTag": "notebooks_v2_generated_NotebookService_DiagnoseInstance_async", + "title": "NotebookService diagnoseInstance Sample", + "origin": "API_DEFINITION", + "description": " Creates a Diagnostic File and runs Diagnostic Tool given an Instance.", + "canonical": true, + "file": "notebook_service.diagnose_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DiagnoseInstance", + "fullName": "google.cloud.notebooks.v2.NotebookService.DiagnoseInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "diagnostic_config", + "type": ".google.cloud.notebooks.v2.DiagnosticConfig" + }, + { + "name": "timeout_minutes", + "type": "TYPE_INT32" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NotebookServiceClient", + "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" + }, + "method": { + "shortName": "DiagnoseInstance", + "fullName": "google.cloud.notebooks.v2.NotebookService.DiagnoseInstance", + "service": { + "shortName": "NotebookService", + "fullName": "google.cloud.notebooks.v2.NotebookService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/src/index.ts b/owl-bot-staging/google-cloud-notebooks/v2/src/index.ts new file mode 100644 index 00000000000..a05bfd55a28 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 NotebookServiceClient = v2.NotebookServiceClient; +type NotebookServiceClient = v2.NotebookServiceClient; +export {v2, NotebookServiceClient}; +export default {v2, NotebookServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/src/v2/gapic_metadata.json b/owl-bot-staging/google-cloud-notebooks/v2/src/v2/gapic_metadata.json new file mode 100644 index 00000000000..07e9638a231 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/src/v2/gapic_metadata.json @@ -0,0 +1,147 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.notebooks.v2", + "libraryPackage": "@google-cloud/notebooks", + "services": { + "NotebookService": { + "clients": { + "grpc": { + "libraryClient": "NotebookServiceClient", + "rpcs": { + "GetInstance": { + "methods": [ + "getInstance" + ] + }, + "CheckInstanceUpgradability": { + "methods": [ + "checkInstanceUpgradability" + ] + }, + "CreateInstance": { + "methods": [ + "createInstance" + ] + }, + "UpdateInstance": { + "methods": [ + "updateInstance" + ] + }, + "DeleteInstance": { + "methods": [ + "deleteInstance" + ] + }, + "StartInstance": { + "methods": [ + "startInstance" + ] + }, + "StopInstance": { + "methods": [ + "stopInstance" + ] + }, + "ResetInstance": { + "methods": [ + "resetInstance" + ] + }, + "UpgradeInstance": { + "methods": [ + "upgradeInstance" + ] + }, + "RollbackInstance": { + "methods": [ + "rollbackInstance" + ] + }, + "DiagnoseInstance": { + "methods": [ + "diagnoseInstance" + ] + }, + "ListInstances": { + "methods": [ + "listInstances", + "listInstancesStream", + "listInstancesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "NotebookServiceClient", + "rpcs": { + "GetInstance": { + "methods": [ + "getInstance" + ] + }, + "CheckInstanceUpgradability": { + "methods": [ + "checkInstanceUpgradability" + ] + }, + "CreateInstance": { + "methods": [ + "createInstance" + ] + }, + "UpdateInstance": { + "methods": [ + "updateInstance" + ] + }, + "DeleteInstance": { + "methods": [ + "deleteInstance" + ] + }, + "StartInstance": { + "methods": [ + "startInstance" + ] + }, + "StopInstance": { + "methods": [ + "stopInstance" + ] + }, + "ResetInstance": { + "methods": [ + "resetInstance" + ] + }, + "UpgradeInstance": { + "methods": [ + "upgradeInstance" + ] + }, + "RollbackInstance": { + "methods": [ + "rollbackInstance" + ] + }, + "DiagnoseInstance": { + "methods": [ + "diagnoseInstance" + ] + }, + "ListInstances": { + "methods": [ + "listInstances", + "listInstancesStream", + "listInstancesAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/src/v2/index.ts b/owl-bot-staging/google-cloud-notebooks/v2/src/v2/index.ts new file mode 100644 index 00000000000..5f1ec6b1546 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/src/v2/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {NotebookServiceClient} from './notebook_service_client'; diff --git a/owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_client.ts b/owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_client.ts new file mode 100644 index 00000000000..126c4b7441e --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_client.ts @@ -0,0 +1,2099 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, IamClient, IamProtos, 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/notebook_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './notebook_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * API v2 service for Workbench Notebooks Instances. + * @class + * @memberof v2 + */ +export class NotebookServiceClient { + 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}; + iamClient: IamClient; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + notebookServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of NotebookServiceClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 NotebookServiceClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof NotebookServiceClient; + 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.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); + + 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 { + 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 = { + instancePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/instances/{instance}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listInstances: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instances') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v2/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v2/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v2/{resource=projects/*/locations/*/instances/*}:getIamPolicy',},{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v2/{resource=projects/*/locations/*/instances/*}:setIamPolicy',body: '*',},{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v2/{resource=projects/*/locations/*/instances/*}:testIamPermissions',body: '*',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v2/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; + const createInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; + const updateInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; + const updateInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; + const deleteInstanceResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; + const startInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; + const startInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; + const stopInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; + const stopInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; + const resetInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; + const resetInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; + const upgradeInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; + const upgradeInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; + const rollbackInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; + const rollbackInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; + const diagnoseInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; + const diagnoseInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createInstanceResponse.decode.bind(createInstanceResponse), + createInstanceMetadata.decode.bind(createInstanceMetadata)), + updateInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateInstanceResponse.decode.bind(updateInstanceResponse), + updateInstanceMetadata.decode.bind(updateInstanceMetadata)), + deleteInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteInstanceResponse.decode.bind(deleteInstanceResponse), + deleteInstanceMetadata.decode.bind(deleteInstanceMetadata)), + startInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + startInstanceResponse.decode.bind(startInstanceResponse), + startInstanceMetadata.decode.bind(startInstanceMetadata)), + stopInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + stopInstanceResponse.decode.bind(stopInstanceResponse), + stopInstanceMetadata.decode.bind(stopInstanceMetadata)), + resetInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + resetInstanceResponse.decode.bind(resetInstanceResponse), + resetInstanceMetadata.decode.bind(resetInstanceMetadata)), + upgradeInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + upgradeInstanceResponse.decode.bind(upgradeInstanceResponse), + upgradeInstanceMetadata.decode.bind(upgradeInstanceMetadata)), + rollbackInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + rollbackInstanceResponse.decode.bind(rollbackInstanceResponse), + rollbackInstanceMetadata.decode.bind(rollbackInstanceMetadata)), + diagnoseInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + diagnoseInstanceResponse.decode.bind(diagnoseInstanceResponse), + diagnoseInstanceMetadata.decode.bind(diagnoseInstanceMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.notebooks.v2.NotebookService', 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.notebookServiceStub) { + return this.notebookServiceStub; + } + + // Put together the "service stub" for + // google.cloud.notebooks.v2.NotebookService. + this.notebookServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.notebooks.v2.NotebookService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.notebooks.v2.NotebookService, + 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 notebookServiceStubMethods = + ['listInstances', 'getInstance', 'createInstance', 'updateInstance', 'deleteInstance', 'startInstance', 'stopInstance', 'resetInstance', 'checkInstanceUpgradability', 'upgradeInstance', 'rollbackInstance', 'diagnoseInstance']; + for (const methodName of notebookServiceStubMethods) { + const callPromise = this.notebookServiceStub.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.notebookServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'notebooks.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 'notebooks.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 details of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v2.Instance|Instance}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.get_instance.js + * region_tag:notebooks_v2_generated_NotebookService_GetInstance_async + */ + getInstance( + request?: protos.google.cloud.notebooks.v2.IGetInstanceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IGetInstanceRequest|undefined, {}|undefined + ]>; + getInstance( + request: protos.google.cloud.notebooks.v2.IGetInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IGetInstanceRequest|null|undefined, + {}|null|undefined>): void; + getInstance( + request: protos.google.cloud.notebooks.v2.IGetInstanceRequest, + callback: Callback< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IGetInstanceRequest|null|undefined, + {}|null|undefined>): void; + getInstance( + request?: protos.google.cloud.notebooks.v2.IGetInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IGetInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IGetInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IGetInstanceRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getInstance(request, options, callback); + } +/** + * Checks whether a notebook instance is upgradable. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.notebookInstance + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityResponse|CheckInstanceUpgradabilityResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.check_instance_upgradability.js + * region_tag:notebooks_v2_generated_NotebookService_CheckInstanceUpgradability_async + */ + checkInstanceUpgradability( + request?: protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, + protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest|undefined, {}|undefined + ]>; + checkInstanceUpgradability( + request: protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, + protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest|null|undefined, + {}|null|undefined>): void; + checkInstanceUpgradability( + request: protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest, + callback: Callback< + protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, + protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest|null|undefined, + {}|null|undefined>): void; + checkInstanceUpgradability( + request?: protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, + protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, + protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, + protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'notebook_instance': request.notebookInstance ?? '', + }); + this.initialize(); + return this.innerApiCalls.checkInstanceUpgradability(request, options, callback); + } + +/** + * Creates a new Instance in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {string} request.instanceId + * Required. User-defined unique ID of this instance. + * @param {google.cloud.notebooks.v2.Instance} request.instance + * Required. The instance to be created. + * @param {string} [request.requestId] + * Optional. Idempotent request UUID. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.create_instance.js + * region_tag:notebooks_v2_generated_NotebookService_CreateInstance_async + */ + createInstance( + request?: protos.google.cloud.notebooks.v2.ICreateInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createInstance( + request: protos.google.cloud.notebooks.v2.ICreateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createInstance( + request: protos.google.cloud.notebooks.v2.ICreateInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createInstance( + request?: protos.google.cloud.notebooks.v2.ICreateInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.create_instance.js + * region_tag:notebooks_v2_generated_NotebookService_CreateInstance_async + */ + async checkCreateInstanceProgress(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.createInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * UpdateInstance updates an Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.notebooks.v2.Instance} request.instance + * Required. A representation of an instance. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask used to update an instance + * @param {string} [request.requestId] + * Optional. Idempotent request UUID. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.update_instance.js + * region_tag:notebooks_v2_generated_NotebookService_UpdateInstance_async + */ + updateInstance( + request?: protos.google.cloud.notebooks.v2.IUpdateInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateInstance( + request: protos.google.cloud.notebooks.v2.IUpdateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateInstance( + request: protos.google.cloud.notebooks.v2.IUpdateInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateInstance( + request?: protos.google.cloud.notebooks.v2.IUpdateInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'instance.name': request.instance!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.update_instance.js + * region_tag:notebooks_v2_generated_NotebookService_UpdateInstance_async + */ + async checkUpdateInstanceProgress(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.updateInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {string} [request.requestId] + * Optional. Idempotent request UUID. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.delete_instance.js + * region_tag:notebooks_v2_generated_NotebookService_DeleteInstance_async + */ + deleteInstance( + request?: protos.google.cloud.notebooks.v2.IDeleteInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteInstance( + request: protos.google.cloud.notebooks.v2.IDeleteInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteInstance( + request: protos.google.cloud.notebooks.v2.IDeleteInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteInstance( + request?: protos.google.cloud.notebooks.v2.IDeleteInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.delete_instance.js + * region_tag:notebooks_v2_generated_NotebookService_DeleteInstance_async + */ + async checkDeleteInstanceProgress(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.deleteInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Starts a notebook instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.start_instance.js + * region_tag:notebooks_v2_generated_NotebookService_StartInstance_async + */ + startInstance( + request?: protos.google.cloud.notebooks.v2.IStartInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + startInstance( + request: protos.google.cloud.notebooks.v2.IStartInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + startInstance( + request: protos.google.cloud.notebooks.v2.IStartInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + startInstance( + request?: protos.google.cloud.notebooks.v2.IStartInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.startInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `startInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.start_instance.js + * region_tag:notebooks_v2_generated_NotebookService_StartInstance_async + */ + async checkStartInstanceProgress(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.startInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Stops a notebook instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.stop_instance.js + * region_tag:notebooks_v2_generated_NotebookService_StopInstance_async + */ + stopInstance( + request?: protos.google.cloud.notebooks.v2.IStopInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + stopInstance( + request: protos.google.cloud.notebooks.v2.IStopInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + stopInstance( + request: protos.google.cloud.notebooks.v2.IStopInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + stopInstance( + request?: protos.google.cloud.notebooks.v2.IStopInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.stopInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `stopInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.stop_instance.js + * region_tag:notebooks_v2_generated_NotebookService_StopInstance_async + */ + async checkStopInstanceProgress(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.stopInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Resets a notebook instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.reset_instance.js + * region_tag:notebooks_v2_generated_NotebookService_ResetInstance_async + */ + resetInstance( + request?: protos.google.cloud.notebooks.v2.IResetInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + resetInstance( + request: protos.google.cloud.notebooks.v2.IResetInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + resetInstance( + request: protos.google.cloud.notebooks.v2.IResetInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + resetInstance( + request?: protos.google.cloud.notebooks.v2.IResetInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.resetInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `resetInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.reset_instance.js + * region_tag:notebooks_v2_generated_NotebookService_ResetInstance_async + */ + async checkResetInstanceProgress(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.resetInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Upgrades a notebook instance to the latest version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.upgrade_instance.js + * region_tag:notebooks_v2_generated_NotebookService_UpgradeInstance_async + */ + upgradeInstance( + request?: protos.google.cloud.notebooks.v2.IUpgradeInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + upgradeInstance( + request: protos.google.cloud.notebooks.v2.IUpgradeInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + upgradeInstance( + request: protos.google.cloud.notebooks.v2.IUpgradeInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + upgradeInstance( + request?: protos.google.cloud.notebooks.v2.IUpgradeInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.upgradeInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `upgradeInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.upgrade_instance.js + * region_tag:notebooks_v2_generated_NotebookService_UpgradeInstance_async + */ + async checkUpgradeInstanceProgress(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.upgradeInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Rollbacks a notebook instance to the previous version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {string} request.targetSnapshot + * Required. The snapshot for rollback. + * Example: "projects/test-project/global/snapshots/krwlzipynril". + * @param {string} request.revisionId + * Required. Output only. Revision Id + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.rollback_instance.js + * region_tag:notebooks_v2_generated_NotebookService_RollbackInstance_async + */ + rollbackInstance( + request?: protos.google.cloud.notebooks.v2.IRollbackInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + rollbackInstance( + request: protos.google.cloud.notebooks.v2.IRollbackInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + rollbackInstance( + request: protos.google.cloud.notebooks.v2.IRollbackInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + rollbackInstance( + request?: protos.google.cloud.notebooks.v2.IRollbackInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.rollbackInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `rollbackInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.rollback_instance.js + * region_tag:notebooks_v2_generated_NotebookService_RollbackInstance_async + */ + async checkRollbackInstanceProgress(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.rollbackInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Creates a Diagnostic File and runs Diagnostic Tool given an Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {google.cloud.notebooks.v2.DiagnosticConfig} request.diagnosticConfig + * Required. Defines flags that are used to run the diagnostic tool + * @param {number} [request.timeoutMinutes] + * Optional. Maxmium amount of time in minutes before the operation times out. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.diagnose_instance.js + * region_tag:notebooks_v2_generated_NotebookService_DiagnoseInstance_async + */ + diagnoseInstance( + request?: protos.google.cloud.notebooks.v2.IDiagnoseInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + diagnoseInstance( + request: protos.google.cloud.notebooks.v2.IDiagnoseInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + diagnoseInstance( + request: protos.google.cloud.notebooks.v2.IDiagnoseInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + diagnoseInstance( + request?: protos.google.cloud.notebooks.v2.IDiagnoseInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.diagnoseInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `diagnoseInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.diagnose_instance.js + * region_tag:notebooks_v2_generated_NotebookService_DiagnoseInstance_async + */ + async checkDiagnoseInstanceProgress(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.diagnoseInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists instances in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} [request.pageSize] + * Optional. Maximum return size of the list call. + * @param {string} [request.pageToken] + * Optional. A previous returned page token that can be used to continue + * listing from the last result. + * @param {string} [request.orderBy] + * Optional. Sort results. Supported values are "name", "name desc" or "" + * (unsorted). + * @param {string} [request.filter] + * Optional. List filter. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.notebooks.v2.Instance|Instance}. + * 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 `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listInstances( + request?: protos.google.cloud.notebooks.v2.IListInstancesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.notebooks.v2.IInstance[], + protos.google.cloud.notebooks.v2.IListInstancesRequest|null, + protos.google.cloud.notebooks.v2.IListInstancesResponse + ]>; + listInstances( + request: protos.google.cloud.notebooks.v2.IListInstancesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.notebooks.v2.IListInstancesRequest, + protos.google.cloud.notebooks.v2.IListInstancesResponse|null|undefined, + protos.google.cloud.notebooks.v2.IInstance>): void; + listInstances( + request: protos.google.cloud.notebooks.v2.IListInstancesRequest, + callback: PaginationCallback< + protos.google.cloud.notebooks.v2.IListInstancesRequest, + protos.google.cloud.notebooks.v2.IListInstancesResponse|null|undefined, + protos.google.cloud.notebooks.v2.IInstance>): void; + listInstances( + request?: protos.google.cloud.notebooks.v2.IListInstancesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.notebooks.v2.IListInstancesRequest, + protos.google.cloud.notebooks.v2.IListInstancesResponse|null|undefined, + protos.google.cloud.notebooks.v2.IInstance>, + callback?: PaginationCallback< + protos.google.cloud.notebooks.v2.IListInstancesRequest, + protos.google.cloud.notebooks.v2.IListInstancesResponse|null|undefined, + protos.google.cloud.notebooks.v2.IInstance>): + Promise<[ + protos.google.cloud.notebooks.v2.IInstance[], + protos.google.cloud.notebooks.v2.IListInstancesRequest|null, + protos.google.cloud.notebooks.v2.IListInstancesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listInstances(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. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} [request.pageSize] + * Optional. Maximum return size of the list call. + * @param {string} [request.pageToken] + * Optional. A previous returned page token that can be used to continue + * listing from the last result. + * @param {string} [request.orderBy] + * Optional. Sort results. Supported values are "name", "name desc" or "" + * (unsorted). + * @param {string} [request.filter] + * Optional. List filter. + * @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 protos.google.cloud.notebooks.v2.Instance|Instance} 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 `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listInstancesStream( + request?: protos.google.cloud.notebooks.v2.IListInstancesRequest, + 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['listInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInstances.createStream( + this.innerApiCalls.listInstances as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listInstances`, 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. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} [request.pageSize] + * Optional. Maximum return size of the list call. + * @param {string} [request.pageToken] + * Optional. A previous returned page token that can be used to continue + * listing from the last result. + * @param {string} [request.orderBy] + * Optional. Sort results. Supported values are "name", "name desc" or "" + * (unsorted). + * @param {string} [request.filter] + * Optional. List filter. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.notebooks.v2.Instance|Instance}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.list_instances.js + * region_tag:notebooks_v2_generated_NotebookService_ListInstances_async + */ + listInstancesAsync( + request?: protos.google.cloud.notebooks.v2.IListInstancesRequest, + 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['listInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInstances.asyncIterate( + this.innerApiCalls['listInstances'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @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/interfaces/CallOptions.html | 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.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getIamPolicy( + request: IamProtos.google.iam.v1.GetIamPolicyRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.Policy]> { + return this.iamClient.getIamPolicy(request, options, callback); + } + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + setIamPolicy( + request: IamProtos.google.iam.v1.SetIamPolicyRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.Policy]> { + return this.iamClient.setIamPolicy(request, options, callback); + } + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ + testIamPermissions( + request: IamProtos.google.iam.v1.TestIamPermissionsRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + return this.iamClient.testIamPermissions(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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 instance resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} instance + * @returns {string} Resource name string. + */ + instancePath(project:string,location:string,instance:string) { + return this.pathTemplates.instancePathTemplate.render({ + project: project, + location: location, + instance: instance, + }); + } + + /** + * Parse the project from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the project. + */ + matchProjectFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).project; + } + + /** + * Parse the location from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the location. + */ + matchLocationFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).location; + } + + /** + * Parse the instance from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).instance; + } + + /** + * 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 project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.notebookServiceStub && !this._terminated) { + return this.notebookServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.iamClient.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_client_config.json b/owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_client_config.json new file mode 100644 index 00000000000..e8f6f421921 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_client_config.json @@ -0,0 +1,89 @@ +{ + "interfaces": { + "google.cloud.notebooks.v2.NotebookService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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": { + "ListInstances": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateInstance": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "DeleteInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StartInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StopInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ResetInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CheckInstanceUpgradability": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "UpgradeInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RollbackInstance": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DiagnoseInstance": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_proto_list.json b/owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_proto_list.json new file mode 100644 index 00000000000..3b19a9b7a72 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_proto_list.json @@ -0,0 +1,7 @@ +[ + "../../protos/google/cloud/notebooks/v2/diagnostic_config.proto", + "../../protos/google/cloud/notebooks/v2/event.proto", + "../../protos/google/cloud/notebooks/v2/gce_setup.proto", + "../../protos/google/cloud/notebooks/v2/instance.proto", + "../../protos/google/cloud/notebooks/v2/service.proto" +] diff --git a/owl-bot-staging/google-cloud-notebooks/v2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-notebooks/v2/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..193e9b0e75d --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const notebooks = require('@google-cloud/notebooks'); + +function main() { + const notebookServiceClient = new notebooks.NotebookServiceClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-notebooks/v2/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..624792a563f --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {NotebookServiceClient} from '@google-cloud/notebooks'; + +// check that the client class type name can be used +function doStuffWithNotebookServiceClient(client: NotebookServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const notebookServiceClient = new NotebookServiceClient(); + doStuffWithNotebookServiceClient(notebookServiceClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/system-test/install.ts b/owl-bot-staging/google-cloud-notebooks/v2/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/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-notebooks/v2/test/gapic_notebook_service_v2.ts b/owl-bot-staging/google-cloud-notebooks/v2/test/gapic_notebook_service_v2.ts new file mode 100644 index 00000000000..c85784f8a2f --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/v2/test/gapic_notebook_service_v2.ts @@ -0,0 +1,2878 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 notebookserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos, IamProtos, 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.NotebookServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = notebookserviceModule.v2.NotebookServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = notebookserviceModule.v2.NotebookServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = notebookserviceModule.v2.NotebookServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new notebookserviceModule.v2.NotebookServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.notebookServiceStub, undefined); + await client.initialize(); + assert(client.notebookServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.notebookServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.notebookServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new notebookserviceModule.v2.NotebookServiceClient({ + 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 notebookserviceModule.v2.NotebookServiceClient({ + 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('getInstance', () => { + it('invokes getInstance without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v2.Instance() + ); + client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); + const [response] = await client.getInstance(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstance without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v2.Instance() + ); + client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstance( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v2.IInstance|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstance with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstance with closed client', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getInstance(request), expectedError); + }); + }); + + describe('checkInstanceUpgradability', () => { + it('invokes checkInstanceUpgradability without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest', ['notebookInstance']); + request.notebookInstance = defaultValue1; + const expectedHeaderRequestParams = `notebook_instance=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityResponse() + ); + client.innerApiCalls.checkInstanceUpgradability = stubSimpleCall(expectedResponse); + const [response] = await client.checkInstanceUpgradability(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.checkInstanceUpgradability as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.checkInstanceUpgradability as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkInstanceUpgradability without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest', ['notebookInstance']); + request.notebookInstance = defaultValue1; + const expectedHeaderRequestParams = `notebook_instance=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityResponse() + ); + client.innerApiCalls.checkInstanceUpgradability = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.checkInstanceUpgradability( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.checkInstanceUpgradability as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.checkInstanceUpgradability as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkInstanceUpgradability with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest', ['notebookInstance']); + request.notebookInstance = defaultValue1; + const expectedHeaderRequestParams = `notebook_instance=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.checkInstanceUpgradability = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkInstanceUpgradability(request), expectedError); + const actualRequest = (client.innerApiCalls.checkInstanceUpgradability as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.checkInstanceUpgradability as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkInstanceUpgradability with closed client', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest', ['notebookInstance']); + request.notebookInstance = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.checkInstanceUpgradability(request), expectedError); + }); + }); + + describe('createInstance', () => { + it('invokes createInstance without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.createInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstance without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createInstance( + request, + (err?: Error|null, + result?: 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.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstance with call error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstance with LRO error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateInstanceProgress without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateInstanceProgress with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateInstance', () => { + it('invokes updateInstance without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.UpdateInstanceRequest() + ); + request.instance ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.UpdateInstanceRequest', ['instance', 'name']); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstance without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.UpdateInstanceRequest() + ); + request.instance ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.UpdateInstanceRequest', ['instance', 'name']); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateInstance( + request, + (err?: Error|null, + result?: 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.updateInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstance with call error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.UpdateInstanceRequest() + ); + request.instance ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.UpdateInstanceRequest', ['instance', 'name']); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstance with LRO error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.UpdateInstanceRequest() + ); + request.instance ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.UpdateInstanceRequest', ['instance', 'name']); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateInstanceProgress without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateInstanceProgress with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteInstance', () => { + it('invokes deleteInstance without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstance without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteInstance( + request, + (err?: Error|null, + result?: 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.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstance with call error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstance with LRO error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteInstanceProgress without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteInstanceProgress with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('startInstance', () => { + it('invokes startInstance without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.StartInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.StartInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.startInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.startInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startInstance without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.StartInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.StartInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.startInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.startInstance( + request, + (err?: Error|null, + result?: 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.startInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startInstance with call error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.StartInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.StartInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.startInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startInstance with LRO error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.StartInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.StartInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.startInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkStartInstanceProgress without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkStartInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkStartInstanceProgress with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkStartInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('stopInstance', () => { + it('invokes stopInstance without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.StopInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.StopInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.stopInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.stopInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopInstance without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.StopInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.StopInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.stopInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.stopInstance( + request, + (err?: Error|null, + result?: 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.stopInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopInstance with call error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.StopInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.StopInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.stopInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopInstance with LRO error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.StopInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.StopInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.stopInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkStopInstanceProgress without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkStopInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkStopInstanceProgress with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkStopInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('resetInstance', () => { + it('invokes resetInstance without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ResetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.ResetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.resetInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.resetInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resetInstance without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ResetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.ResetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.resetInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resetInstance( + request, + (err?: Error|null, + result?: 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.resetInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resetInstance with call error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ResetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.ResetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resetInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.resetInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resetInstance with LRO error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ResetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.ResetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resetInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.resetInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkResetInstanceProgress without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkResetInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkResetInstanceProgress with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkResetInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('upgradeInstance', () => { + it('invokes upgradeInstance without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.UpgradeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.UpgradeInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.upgradeInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.upgradeInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeInstance without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.UpgradeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.UpgradeInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.upgradeInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.upgradeInstance( + request, + (err?: Error|null, + result?: 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.upgradeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeInstance with call error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.UpgradeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.UpgradeInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.upgradeInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeInstance with LRO error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.UpgradeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.UpgradeInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.upgradeInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpgradeInstanceProgress without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpgradeInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpgradeInstanceProgress with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpgradeInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('rollbackInstance', () => { + it('invokes rollbackInstance without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.RollbackInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.RollbackInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.rollbackInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.rollbackInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.rollbackInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rollbackInstance without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.RollbackInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.RollbackInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.rollbackInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rollbackInstance( + request, + (err?: Error|null, + result?: 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.rollbackInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rollbackInstance with call error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.RollbackInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.RollbackInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rollbackInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.rollbackInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.rollbackInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rollbackInstance with LRO error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.RollbackInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.RollbackInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rollbackInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.rollbackInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.rollbackInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkRollbackInstanceProgress without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRollbackInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRollbackInstanceProgress with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRollbackInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('diagnoseInstance', () => { + it('invokes diagnoseInstance without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.DiagnoseInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.DiagnoseInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.diagnoseInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.diagnoseInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.diagnoseInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes diagnoseInstance without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.DiagnoseInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.DiagnoseInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.diagnoseInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.diagnoseInstance( + request, + (err?: Error|null, + result?: 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.diagnoseInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes diagnoseInstance with call error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.DiagnoseInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.DiagnoseInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.diagnoseInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.diagnoseInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.diagnoseInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes diagnoseInstance with LRO error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.DiagnoseInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.DiagnoseInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.diagnoseInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.diagnoseInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.diagnoseInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDiagnoseInstanceProgress without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDiagnoseInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDiagnoseInstanceProgress with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDiagnoseInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listInstances', () => { + it('invokes listInstances without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + ]; + client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); + const [response] = await client.listInstances(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstances without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + ]; + client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstances( + request, + (err?: Error|null, result?: protos.google.cloud.notebooks.v2.IInstance[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstances with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listInstances(request), expectedError); + const actualRequest = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstancesStream without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + ]; + client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v2.Instance[] = []; + stream.on('data', (response: protos.google.cloud.notebooks.v2.Instance) => { + 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.listInstances.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listInstancesStream with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v2.Instance[] = []; + stream.on('data', (response: protos.google.cloud.notebooks.v2.Instance) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstances without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + ]; + client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.notebooks.v2.IInstance[] = []; + const iterable = client.listInstancesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstances with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.notebooks.v2.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInstancesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.notebooks.v2.IInstance[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0)); + }); + it('invokes getIamPolicy with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0)); + }); + it('invokes setIamPolicy with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + 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 notebookserviceModule.v2.NotebookServiceClient({ + 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 notebookserviceModule.v2.NotebookServiceClient({ + 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 notebookserviceModule.v2.NotebookServiceClient({ + 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 notebookserviceModule.v2.NotebookServiceClient({ + 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 notebookserviceModule.v2.NotebookServiceClient({ + 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 notebookserviceModule.v2.NotebookServiceClient({ + 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 notebookserviceModule.v2.NotebookServiceClient({ + 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 notebookserviceModule.v2.NotebookServiceClient({ + 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 notebookserviceModule.v2.NotebookServiceClient({ + 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 notebookserviceModule.v2.NotebookServiceClient({ + 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 notebookserviceModule.v2.NotebookServiceClient({ + 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 notebookserviceModule.v2.NotebookServiceClient({ + 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 notebookserviceModule.v2.NotebookServiceClient({ + 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 notebookserviceModule.v2.NotebookServiceClient({ + 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 notebookserviceModule.v2.NotebookServiceClient({ + 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('instance', () => { + const fakePath = "/rendered/path/instance"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + instance: "instanceValue", + }; + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.instancePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.instancePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath("projectValue", "locationValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromInstanceName', () => { + const result = client.matchLocationFromInstanceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new notebookserviceModule.v2.NotebookServiceClient({ + 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('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/tsconfig.json b/owl-bot-staging/google-cloud-notebooks/v2/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/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-notebooks/v2/webpack.config.js b/owl-bot-staging/google-cloud-notebooks/v2/webpack.config.js new file mode 100644 index 00000000000..b41a2c182e9 --- /dev/null +++ b/owl-bot-staging/google-cloud-notebooks/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: 'NotebookService', + filename: './notebook-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-optimization/v1/.eslintignore b/owl-bot-staging/google-cloud-optimization/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-optimization/v1/.eslintrc.json b/owl-bot-staging/google-cloud-optimization/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-optimization/v1/.gitignore b/owl-bot-staging/google-cloud-optimization/v1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-optimization/v1/.jsdoc.js b/owl-bot-staging/google-cloud-optimization/v1/.jsdoc.js new file mode 100644 index 00000000000..0c4bf8eb4ef --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/.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/optimization', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-optimization/v1/.mocharc.js b/owl-bot-staging/google-cloud-optimization/v1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/.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-optimization/v1/.prettierrc.js b/owl-bot-staging/google-cloud-optimization/v1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/.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-optimization/v1/README.md b/owl-bot-staging/google-cloud-optimization/v1/README.md new file mode 100644 index 00000000000..14af819c25c --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/README.md @@ -0,0 +1 @@ +Optimization: Nodejs Client diff --git a/owl-bot-staging/google-cloud-optimization/v1/package.json b/owl-bot-staging/google-cloud-optimization/v1/package.json new file mode 100644 index 00000000000..812b062d0e7 --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/optimization", + "version": "0.1.0", + "description": "Optimization client for Node.js", + "repository": "googleapis/nodejs-optimization", + "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 optimization", + "optimization", + "fleet routing" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-optimization/v1/protos/google/cloud/optimization/v1/async_model.proto b/owl-bot-staging/google-cloud-optimization/v1/protos/google/cloud/optimization/v1/async_model.proto new file mode 100644 index 00000000000..a3da0e47970 --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/protos/google/cloud/optimization/v1/async_model.proto @@ -0,0 +1,110 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.optimization.v1; + +import "google/api/field_behavior.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "cloud.google.com/go/optimization/apiv1/optimizationpb;optimizationpb"; +option java_multiple_files = true; +option java_outer_classname = "AsyncModelProto"; +option java_package = "com.google.cloud.optimization.v1"; + +// The desired input location information. +message InputConfig { + // The location of the input model in cloud storage. + // Required. + oneof source { + // The Google Cloud Storage location to read the input from. This must be a + // single file. + GcsSource gcs_source = 1; + } + + // The input data format that used to store the model in Cloud Storage. + DataFormat data_format = 2; +} + +// The desired output location. +message OutputConfig { + // The location of the output result in cloud storage. + // Required. + oneof destination { + // The Google Cloud Storage location to write the output to. + GcsDestination gcs_destination = 1; + } + + // The output data format that used to store the results in Cloud Storage. + DataFormat data_format = 2; +} + +// The Google Cloud Storage location where the input file will be read from. +message GcsSource { + // Required. URI of the Google Cloud Storage location. + string uri = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The Google Cloud Storage location where the output file will be written to. +message GcsDestination { + // Required. URI of the Google Cloud Storage location. + string uri = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The long running operation metadata for async model related methods. +message AsyncModelMetadata { + // Possible states of the operation. + enum State { + // The default value. This value is used if the state is omitted. + STATE_UNSPECIFIED = 0; + + // Request is being processed. + RUNNING = 1; + + // The operation completed successfully. + SUCCEEDED = 2; + + // The operation was cancelled. + CANCELLED = 3; + + // The operation has failed. + FAILED = 4; + } + + // The state of the current operation. + State state = 1; + + // A message providing more details about the current state of the operation. + // For example, the error message if the operation is failed. + string state_message = 2; + + // The creation time of the operation. + google.protobuf.Timestamp create_time = 3; + + // The last update time of the operation. + google.protobuf.Timestamp update_time = 4; +} + +// Data formats for input and output files. +enum DataFormat { + // Default value. + DATA_FORMAT_UNSPECIFIED = 0; + + // Input data in json format. + JSON = 1; + + // Input data in string format. + STRING = 2; +} diff --git a/owl-bot-staging/google-cloud-optimization/v1/protos/google/cloud/optimization/v1/fleet_routing.proto b/owl-bot-staging/google-cloud-optimization/v1/protos/google/cloud/optimization/v1/fleet_routing.proto new file mode 100644 index 00000000000..cef17ad7ef3 --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/protos/google/cloud/optimization/v1/fleet_routing.proto @@ -0,0 +1,2750 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.optimization.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/optimization/v1/async_model.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/latlng.proto"; + +option go_package = "cloud.google.com/go/optimization/apiv1/optimizationpb;optimizationpb"; +option java_multiple_files = true; +option java_outer_classname = "FleetRoutingProto"; +option java_package = "com.google.cloud.optimization.v1"; + +// A service for optimizing vehicle tours. +// +// Validity of certain types of fields: +// +// * `google.protobuf.Timestamp` +// * Times are in Unix time: seconds since 1970-01-01T00:00:00+00:00. +// * seconds must be in [0, 253402300799], +// i.e. in [1970-01-01T00:00:00+00:00, 9999-12-31T23:59:59+00:00]. +// * nanos must be unset or set to 0. +// * `google.protobuf.Duration` +// * seconds must be in [0, 253402300799], +// i.e. in [1970-01-01T00:00:00+00:00, 9999-12-31T23:59:59+00:00]. +// * nanos must be unset or set to 0. +// * `google.type.LatLng` +// * latitude must be in [-90.0, 90.0]. +// * longitude must be in [-180.0, 180.0]. +// * at least one of latitude and longitude must be non-zero. +service FleetRouting { + option (google.api.default_host) = "cloudoptimization.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Sends an `OptimizeToursRequest` containing a `ShipmentModel` and returns an + // `OptimizeToursResponse` containing `ShipmentRoute`s, which are a set of + // routes to be performed by vehicles minimizing the overall cost. + // + // A `ShipmentModel` model consists mainly of `Shipment`s that need to be + // carried out and `Vehicle`s that can be used to transport the `Shipment`s. + // The `ShipmentRoute`s assign `Shipment`s to `Vehicle`s. More specifically, + // they assign a series of `Visit`s to each vehicle, where a `Visit` + // corresponds to a `VisitRequest`, which is a pickup or delivery for a + // `Shipment`. + // + // The goal is to provide an assignment of `ShipmentRoute`s to `Vehicle`s that + // minimizes the total cost where cost has many components defined in the + // `ShipmentModel`. + rpc OptimizeTours(OptimizeToursRequest) returns (OptimizeToursResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}:optimizeTours" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*}:optimizeTours" + body: "*" + } + }; + } + + // Optimizes vehicle tours for one or more `OptimizeToursRequest` + // messages as a batch. + // + // This method is a Long Running Operation (LRO). The inputs for optimization + // (`OptimizeToursRequest` messages) and outputs (`OptimizeToursResponse` + // messages) are read/written from/to Cloud Storage in user-specified + // format. Like the `OptimizeTours` method, each `OptimizeToursRequest` + // contains a `ShipmentModel` and returns an `OptimizeToursResponse` + // containing `ShipmentRoute`s, which are a set of routes to be performed by + // vehicles minimizing the overall cost. + rpc BatchOptimizeTours(BatchOptimizeToursRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}:batchOptimizeTours" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*}:batchOptimizeTours" + body: "*" + } + }; + option (google.longrunning.operation_info) = { + response_type: "BatchOptimizeToursResponse" + metadata_type: "AsyncModelMetadata" + }; + } +} + +// Request to be given to a tour optimization solver which defines the +// shipment model to solve as well as optimization parameters. +message OptimizeToursRequest { + // Defines how the solver should handle the request. In all modes but + // `VALIDATE_ONLY`, if the request is invalid, you will receive an + // `INVALID_REQUEST` error. See + // [max_validation_errors][google.cloud.optimization.v1.OptimizeToursRequest.max_validation_errors] + // to cap the number of errors returned. + enum SolvingMode { + // Solve the model. + DEFAULT_SOLVE = 0; + + // Only validates the model without solving it: populates as many + // [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors] + // as possible. + VALIDATE_ONLY = 1; + + // Only populates + // [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments], + // and doesn't actually solve the rest of the request (`status` and `routes` + // are unset in the response). + // + // *IMPORTANT*: not all infeasible shipments are returned here, but only the + // ones that are detected as infeasible as a preprocessing. + DETECT_SOME_INFEASIBLE_SHIPMENTS = 2; + } + + // Mode defining the behavior of the search, trading off latency versus + // solution quality. In all modes, the global request deadline is enforced. + enum SearchMode { + // Unspecified search mode, equivalent to `RETURN_FAST`. + SEARCH_MODE_UNSPECIFIED = 0; + + // Stop the search after finding the first good solution. + RETURN_FAST = 1; + + // Spend all the available time to search for better solutions. + CONSUME_ALL_AVAILABLE_TIME = 2; + } + + // Required. Target project and location to make a call. + // + // Format: `projects/{project-id}/locations/{location-id}`. + // + // If no location is specified, a region will be chosen automatically. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // If this timeout is set, the server returns a response before the timeout + // period has elapsed or the server deadline for synchronous requests is + // reached, whichever is sooner. + // + // For asynchronous requests, the server will generate a solution (if + // possible) before the timeout has elapsed. + google.protobuf.Duration timeout = 2; + + // Shipment model to solve. + ShipmentModel model = 3; + + // By default, the solving mode is `DEFAULT_SOLVE` (0). + SolvingMode solving_mode = 4; + + // Truncates the number of validation errors returned. These errors are + // typically attached to an INVALID_ARGUMENT error payload as a BadRequest + // error detail (https://cloud.google.com/apis/design/errors#error_details), + // unless solving_mode=VALIDATE_ONLY: see the + // [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors] + // field. + // This defaults to 100 and is capped at 10,000. + optional int32 max_validation_errors = 5; + + // Search mode used to solve the request. + SearchMode search_mode = 6; + + // Guide the optimization algorithm in finding a first solution that is + // similar to a previous solution. + // + // The model is constrained when the first solution is built. + // Any shipments not performed on a route are implicitly skipped in the first + // solution, but they may be performed in successive solutions. + // + // The solution must satisfy some basic validity assumptions: + // + // * for all routes, `vehicle_index` must be in range and not be duplicated. + // * for all visits, `shipment_index` and `visit_request_index` must be + // in range. + // * a shipment may only be referenced on one route. + // * the pickup of a pickup-delivery shipment must be performed before + // the delivery. + // * no more than one pickup alternative or delivery alternative of + // a shipment may be performed. + // * for all routes, times are increasing (i.e., `vehicle_start_time + // <= visits[0].start_time <= visits[1].start_time ... + // <= vehicle_end_time`). + // * a shipment may only be performed on a vehicle that is allowed. A + // vehicle is allowed if + // [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices] + // is empty or its `vehicle_index` is included in + // [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices]. + // + // If the injected solution is not feasible, a validation error is not + // necessarily returned and an error indicating infeasibility may be returned + // instead. + repeated ShipmentRoute injected_first_solution_routes = 7; + + // Constrain the optimization algorithm to find a final solution that is + // similar to a previous solution. For example, this may be used to freeze + // portions of routes which have already been completed or which are to be + // completed but must not be modified. + // + // If the injected solution is not feasible, a validation error is not + // necessarily returned and an error indicating infeasibility may be returned + // instead. + InjectedSolutionConstraint injected_solution_constraint = 8; + + // If non-empty, the given routes will be refreshed, without modifying their + // underlying sequence of visits or travel times: only other details will be + // updated. This does not solve the model. + // + // As of 2020/11, this only populates the polylines of non-empty routes and + // requires that `populate_polylines` is true. + // + // The `route_polyline` fields of the passed-in routes may be inconsistent + // with route `transitions`. + // + // This field must not be used together with `injected_first_solution_routes` + // or `injected_solution_constraint`. + // + // `Shipment.ignore` and `Vehicle.ignore` have no effect on the behavior. + // Polylines are still populated between all visits in all non-empty routes + // regardless of whether the related shipments or vehicles are ignored. + repeated ShipmentRoute refresh_details_routes = 9; + + // If true: + // + // * uses + // [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label] + // instead of `vehicle_index` to + // match routes in an injected solution with vehicles in the request; + // reuses the mapping of original + // [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index] + // to new + // [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index] + // to update + // [ConstraintRelaxation.vehicle_indices][google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices] + // if non-empty, but the mapping must be unambiguous (i.e., multiple + // `ShipmentRoute`s must not share the same original `vehicle_index`). + // * uses + // [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label] + // instead of `shipment_index` + // to match visits in an injected solution with shipments in the request; + // * uses + // [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label] + // instead of + // [SkippedShipment.index][google.cloud.optimization.v1.SkippedShipment.index] + // to + // match skipped shipments in the injected solution with request + // shipments. + // + // This interpretation applies to the `injected_first_solution_routes`, + // `injected_solution_constraint`, and `refresh_details_routes` fields. + // It can be used when shipment or vehicle indices in the request have + // changed since the solution was created, perhaps because shipments or + // vehicles have been removed from or added to the request. + // + // If true, labels in the following categories must appear at most once in + // their category: + // + // * [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] in the + // request; + // * [Shipment.label][google.cloud.optimization.v1.Shipment.label] in the + // request; + // * [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label] in the injected solution; + // * [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label] and [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label] in + // the injected solution (except pickup/delivery visit pairs, whose + // `shipment_label` must appear twice). + // + // If a `vehicle_label` in the injected solution does not correspond to a + // request vehicle, the corresponding route is removed from the solution + // along with its visits. If a `shipment_label` in the injected solution does + // not correspond to a request shipment, the corresponding visit is removed + // from the solution. If a + // [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label] + // in the injected solution does not correspond to a request shipment, the + // `SkippedShipment` is removed from the solution. + // + // Removing route visits or entire routes from an injected solution may + // have an effect on the implied constraints, which may lead to change in + // solution, validation errors, or infeasibility. + // + // NOTE: The caller must ensure that each + // [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] (resp. + // [Shipment.label][google.cloud.optimization.v1.Shipment.label]) uniquely + // identifies a vehicle (resp. shipment) entity used across the two relevant + // requests: the past request that produced the `OptimizeToursResponse` used + // in the injected solution and the current request that includes the injected + // solution. The uniqueness checks described above are not enough to guarantee + // this requirement. + bool interpret_injected_solutions_using_labels = 10; + + // Consider traffic estimation in calculating `ShipmentRoute` fields + // [Transition.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration], + // [Visit.start_time][google.cloud.optimization.v1.ShipmentRoute.Visit.start_time], + // and `vehicle_end_time`; in setting the + // [ShipmentRoute.has_traffic_infeasibilities][google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities] + // field, and in calculating the + // [OptimizeToursResponse.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.total_cost] + // field. + bool consider_road_traffic = 11; + + // If true, polylines will be populated in response `ShipmentRoute`s. + bool populate_polylines = 12; + + // If true, polylines will be populated in response + // [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]. + // Note that in this case, the polylines will also be populated in the + // deprecated `travel_steps`. + bool populate_transition_polylines = 13; + + // If this is set, then the request can have a deadline + // (see https://grpc.io/blog/deadlines) of up to 60 minutes. + // Otherwise, the maximum deadline is only 30 minutes. + // Note that long-lived requests have a significantly larger (but still small) + // risk of interruption. + bool allow_large_deadline_despite_interruption_risk = 14; + + // If true, travel distances will be computed using geodesic distances instead + // of Google Maps distances, and travel times will be computed using geodesic + // distances with a speed defined by `geodesic_meters_per_second`. + bool use_geodesic_distances = 15; + + // When `use_geodesic_distances` is true, this field must be set and defines + // the speed applied to compute travel times. Its value must be at least 1.0 + // meters/seconds. + optional double geodesic_meters_per_second = 16; + + // Label that may be used to identify this request, reported back in the + // [OptimizeToursResponse.request_label][google.cloud.optimization.v1.OptimizeToursResponse.request_label]. + string label = 17; + + // Deprecated: Use + // [OptimizeToursRequest.populate_transition_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines] + // instead. If true, polylines will be populated in response + // [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]. + // Note that in this case, the polylines will also be populated in the + // deprecated `travel_steps`. + bool populate_travel_step_polylines = 20 [deprecated = true]; +} + +// Response after solving a tour optimization problem containing the routes +// followed by each vehicle, the shipments which have been skipped and the +// overall cost of the solution. +message OptimizeToursResponse { + // Overall metrics, aggregated over all routes. + message Metrics { + // Aggregated over the routes. Each metric is the sum (or max, for loads) + // over all + // [ShipmentRoute.metrics][google.cloud.optimization.v1.ShipmentRoute.metrics] + // fields of the same name. + AggregatedMetrics aggregated_route_metrics = 1; + + // Number of mandatory shipments skipped. + int32 skipped_mandatory_shipment_count = 2; + + // Number of vehicles used. Note: if a vehicle route is empty and + // [Vehicle.used_if_route_is_empty][google.cloud.optimization.v1.Vehicle.used_if_route_is_empty] + // is true, the vehicle is considered used. + int32 used_vehicle_count = 3; + + // The earliest start time for a used vehicle, computed as the minimum over + // all used vehicles of + // [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]. + google.protobuf.Timestamp earliest_vehicle_start_time = 4; + + // The latest end time for a used vehicle, computed as the maximum over all + // used vehicles of + // [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]. + google.protobuf.Timestamp latest_vehicle_end_time = 5; + + // Cost of the solution, broken down by cost-related request fields. + // The keys are proto paths, relative to the input OptimizeToursRequest, + // e.g. "model.shipments.pickups.cost", and the values are the total cost + // generated by the corresponding cost field, aggregated over the whole + // solution. In other words, costs["model.shipments.pickups.cost"] is the + // sum of all pickup costs over the solution. All costs defined in the model + // are reported in detail here with the exception of costs related to + // TransitionAttributes that are only reported in an aggregated way as of + // 2022/01. + map costs = 10; + + // Total cost of the solution. The sum of all values in the costs map. + double total_cost = 6; + } + + // Routes computed for each vehicle; the i-th route corresponds to the i-th + // vehicle in the model. + repeated ShipmentRoute routes = 1; + + // Copy of the + // [OptimizeToursRequest.label][google.cloud.optimization.v1.OptimizeToursRequest.label], + // if a label was specified in the request. + string request_label = 3; + + // The list of all shipments skipped. + repeated SkippedShipment skipped_shipments = 4; + + // List of all the validation errors that we were able to detect + // independently. See the "MULTIPLE ERRORS" explanation for the + // [OptimizeToursValidationError][google.cloud.optimization.v1.OptimizeToursValidationError] + // message. + repeated OptimizeToursValidationError validation_errors = 5; + + // Duration, distance and usage metrics for this solution. + Metrics metrics = 6; + + // Deprecated: Use + // [Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost] + // instead. Total cost of the solution. This takes into account all costs: + // costs per per hour and travel hour, fixed vehicle costs, unperformed + // shipment penalty costs, global duration cost, etc. + double total_cost = 2 [deprecated = true]; +} + +// Request to batch optimize tours as an asynchronous operation. +// Each input file should contain one `OptimizeToursRequest`, and each output +// file will contain one `OptimizeToursResponse`. The request contains +// information to read/write and parse the files. All the input and output files +// should be under the same project. +message BatchOptimizeToursRequest { + // Information for solving one optimization model asynchronously. + message AsyncModelConfig { + // User defined model name, can be used as alias by users to keep track of + // models. + string display_name = 1; + + // Required. Information about the input model. + InputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The desired output location information. + OutputConfig output_config = 3 [(google.api.field_behavior) = REQUIRED]; + + // If this is set, the model will be solved in the checkpoint mode. In this + // mode, the input model can have a deadline longer than 30 mins without the + // risk of interruption. The model will be solved in multiple short-running + // stages. Each stage generates an intermediate checkpoint + // and stores it in the user's Cloud Storage buckets. The checkpoint + // mode should be preferred over + // allow_large_deadline_despite_interruption_risk since it prevents the risk + // of interruption. + bool enable_checkpoints = 4; + } + + // Required. Target project and location to make a call. + // + // Format: `projects/{project-id}/locations/{location-id}`. + // + // If no location is specified, a region will be chosen automatically. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Input/Output information each purchase model, such as file paths + // and data formats. + repeated AsyncModelConfig model_configs = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// Response to a `BatchOptimizeToursRequest`. This is returned in +// the LRO Operation after the operation is complete. +message BatchOptimizeToursResponse {} + +// A shipment model contains a set of shipments which must be performed by a +// set of vehicles, while minimizing the overall cost, which is the sum of: +// +// * the cost of routing the vehicles (sum of cost per total time, cost per +// travel time, and fixed cost over all vehicles). +// * the unperformed shipment penalties. +// * the cost of the global duration of the shipments +message ShipmentModel { + // Specifies a duration and distance matrix from visit and vehicle start + // locations to visit and vehicle end locations. + message DurationDistanceMatrix { + // Specifies a row of the duration and distance matrix. + message Row { + // Duration values for a given row. It must have as many elements as + // [ShipmentModel.duration_distance_matrix_dst_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_dst_tags]. + repeated google.protobuf.Duration durations = 1; + + // Distance values for a given row. If no costs or constraints refer to + // distances in the model, this can be left empty; otherwise it must have + // as many elements as `durations`. + repeated double meters = 2; + } + + // Specifies the rows of the duration and distance matrix. It must have as + // many elements as + // [ShipmentModel.duration_distance_matrix_src_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_src_tags]. + repeated Row rows = 1; + + // Tag defining to which vehicles this duration and distance matrix applies. + // If empty, this applies to all vehicles, and there can only be a single + // matrix. + // + // Each vehicle start must match exactly one matrix, i.e. exactly one of + // their `start_tags` field must match the `vehicle_start_tag` of a matrix + // (and of that matrix only). + // + // All matrices must have a different `vehicle_start_tag`. + string vehicle_start_tag = 2; + } + + // A precedence rule between two events (each event is the pickup or the + // delivery of a shipment): the "second" event has to start at least + // `offset_duration` after "first" has started. + // + // Several precedences can refer to the same (or related) events, e.g., + // "pickup of B happens after delivery of A" and "pickup of C happens after + // pickup of B". + // + // Furthermore, precedences only apply when both shipments are performed and + // are otherwise ignored. + message PrecedenceRule { + // Shipment index of the "first" event. This field must be specified. + optional int32 first_index = 1; + + // Indicates if the "first" event is a delivery. + bool first_is_delivery = 3; + + // Shipment index of the "second" event. This field must be specified. + optional int32 second_index = 2; + + // Indicates if the "second" event is a delivery. + bool second_is_delivery = 4; + + // The offset between the "first" and "second" event. It can be negative. + google.protobuf.Duration offset_duration = 5; + } + + // Deprecated: Use top level + // [BreakRule][google.cloud.optimization.v1.ShipmentModel.BreakRule] instead. + // Rules to generate time breaks for a vehicle (e.g. lunch + // breaks). A break is a contiguous period of time during which the vehicle + // remains idle at its current position and cannot perform any visit. A break + // may occur: + // + // * during the travel between two visits (which includes the time right + // before or right after a visit, but not in the middle of a visit), in + // which case it extends the corresponding transit time between the visits + // * before the vehicle start (the vehicle may not start in the middle of + // a break), in which case it does not affect the vehicle start time. + // * after the vehicle end (ditto, with the vehicle end time). + message BreakRule { + option deprecated = true; + + // The sequence of breaks (i.e. their number and order) that apply to each + // vehicle must be known beforehand. The repeated `BreakRequest`s define + // that sequence, in the order in which they must occur. Their time windows + // (`earliest_start_time` / `latest_start_time`) may overlap, but they must + // be compatible with the order (this is checked). + message BreakRequest { + // Required. Lower bound (inclusive) on the start of the break. + google.protobuf.Timestamp earliest_start_time = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Upper bound (inclusive) on the start of the break. + google.protobuf.Timestamp latest_start_time = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Minimum duration of the break. Must be positive. + google.protobuf.Duration min_duration = 3 + [(google.api.field_behavior) = REQUIRED]; + } + + // One may further constrain the frequency and duration of the breaks + // specified above, by enforcing a minimum break frequency, such as + // "There must be a break of at least 1 hour every 12 hours". Assuming that + // this can be interpreted as "Within any sliding time window of 12h, there + // must be at least one break of at least one hour", that example would + // translate to the following `FrequencyConstraint`: + // ``` + // { + // min_break_duration { seconds: 3600 } # 1 hour. + // max_inter_break_duration { seconds: 39600 } # 11 hours (12 - 1 = 11). + // } + // ``` + // + // The timing and duration of the breaks in the solution will respect all + // such constraints, in addition to the time windows and minimum durations + // already specified in the `BreakRequest`. + // + // A `FrequencyConstraint` may in practice apply to non-consecutive breaks. + // For example, the following schedule honors the "1h every 12h" example: + // ``` + // 04:00 vehicle start + // .. performing travel and visits .. + // 09:00 1 hour break + // 10:00 end of the break + // .. performing travel and visits .. + // 12:00 20-min lunch break + // 12:20 end of the break + // .. performing travel and visits .. + // 21:00 1 hour break + // 22:00 end of the break + // .. performing travel and visits .. + // 23:59 vehicle end + // ``` + message FrequencyConstraint { + // Required. Minimum break duration for this constraint. Nonnegative. + // See description of `FrequencyConstraint`. + google.protobuf.Duration min_break_duration = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Maximum allowed span of any interval of time in the route + // that does not include at least partially a break of `duration >= + // min_break_duration`. Must be positive. + google.protobuf.Duration max_inter_break_duration = 2 + [(google.api.field_behavior) = REQUIRED]; + } + + // Sequence of breaks. See the `BreakRequest` message. + repeated BreakRequest break_requests = 1; + + // Several `FrequencyConstraint` may apply. They must all be satisfied by + // the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`. + repeated FrequencyConstraint frequency_constraints = 2; + } + + // Set of shipments which must be performed in the model. + repeated Shipment shipments = 1; + + // Set of vehicles which can be used to perform visits. + repeated Vehicle vehicles = 2; + + // Constrains the maximum number of active vehicles. A vehicle is active if + // its route performs at least one shipment. This can be used to limit the + // number of routes in the case where there are fewer drivers than + // vehicles and that the fleet of vehicles is heterogeneous. The optimization + // will then select the best subset of vehicles to use. + // Must be strictly positive. + optional int32 max_active_vehicles = 4; + + // Global start and end time of the model: no times outside of this range + // can be considered valid. + // + // The model's time span must be less than a year, i.e. the `global_end_time` + // and the `global_start_time` must be within 31536000 seconds of each other. + // + // When using `cost_per_*hour` fields, you might want to set this window to a + // smaller interval to increase performance (eg. if you model a single day, + // you should set the global time limits to that day). + // If unset, 00:00:00 UTC, January 1, 1970 (i.e. seconds: 0, nanos: 0) is used + // as default. + google.protobuf.Timestamp global_start_time = 5; + + // If unset, 00:00:00 UTC, January 1, 1971 (i.e. seconds: 31536000, nanos: 0) + // is used as default. + google.protobuf.Timestamp global_end_time = 6; + + // The "global duration" of the overall plan is the difference between the + // earliest effective start time and the latest effective end time of + // all vehicles. Users can assign a cost per hour to that quantity to try + // and optimize for earliest job completion, for example. This cost must be in + // the same unit as + // [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost]. + double global_duration_cost_per_hour = 7; + + // Specifies duration and distance matrices used in the model. If this field + // is empty, Google Maps or geodesic distances will be used instead, depending + // on the value of the `use_geodesic_distances` field. If it is not empty, + // `use_geodesic_distances` cannot be true and neither + // `duration_distance_matrix_src_tags` nor `duration_distance_matrix_dst_tags` + // can be empty. + // + // Usage examples: + // + // * There are two locations: locA and locB. + // * 1 vehicle starting its route at locA and ending it at locA. + // * 1 pickup visit request at locB. + // + // ``` + // model { + // vehicles { start_tags: "locA" end_tags: "locA" } + // shipments { pickups { tags: "locB" } } + // duration_distance_matrix_src_tags: "locA" + // duration_distance_matrix_src_tags: "locB" + // duration_distance_matrix_dst_tags: "locA" + // duration_distance_matrix_dst_tags: "locB" + // duration_distance_matrices { + // rows { # from: locA + // durations { seconds: 0 } meters: 0 # to: locA + // durations { seconds: 100 } meters: 1000 # to: locB + // } + // rows { # from: locB + // durations { seconds: 102 } meters: 990 # to: locA + // durations { seconds: 0 } meters: 0 # to: locB + // } + // } + // } + // ``` + // + // + // * There are three locations: locA, locB and locC. + // * 1 vehicle starting its route at locA and ending it at locB, using + // matrix "fast". + // * 1 vehicle starting its route at locB and ending it at locB, using + // matrix "slow". + // * 1 vehicle starting its route at locB and ending it at locB, using + // matrix "fast". + // * 1 pickup visit request at locC. + // + // ``` + // model { + // vehicles { start_tags: "locA" end_tags: "locB" start_tags: "fast" } + // vehicles { start_tags: "locB" end_tags: "locB" start_tags: "slow" } + // vehicles { start_tags: "locB" end_tags: "locB" start_tags: "fast" } + // shipments { pickups { tags: "locC" } } + // duration_distance_matrix_src_tags: "locA" + // duration_distance_matrix_src_tags: "locB" + // duration_distance_matrix_src_tags: "locC" + // duration_distance_matrix_dst_tags: "locB" + // duration_distance_matrix_dst_tags: "locC" + // duration_distance_matrices { + // vehicle_start_tag: "fast" + // rows { # from: locA + // durations { seconds: 1000 } meters: 2000 # to: locB + // durations { seconds: 600 } meters: 1000 # to: locC + // } + // rows { # from: locB + // durations { seconds: 0 } meters: 0 # to: locB + // durations { seconds: 700 } meters: 1200 # to: locC + // } + // rows { # from: locC + // durations { seconds: 702 } meters: 1190 # to: locB + // durations { seconds: 0 } meters: 0 # to: locC + // } + // } + // duration_distance_matrices { + // vehicle_start_tag: "slow" + // rows { # from: locA + // durations { seconds: 1800 } meters: 2001 # to: locB + // durations { seconds: 900 } meters: 1002 # to: locC + // } + // rows { # from: locB + // durations { seconds: 0 } meters: 0 # to: locB + // durations { seconds: 1000 } meters: 1202 # to: locC + // } + // rows { # from: locC + // durations { seconds: 1001 } meters: 1195 # to: locB + // durations { seconds: 0 } meters: 0 # to: locC + // } + // } + // } + // ``` + repeated DurationDistanceMatrix duration_distance_matrices = 8; + + // Tags defining the sources of the duration and distance matrices; + // `duration_distance_matrices(i).rows(j)` defines durations and distances + // from visits with tag `duration_distance_matrix_src_tags(j)` to other visits + // in matrix i. + // + // Tags correspond to + // [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags] + // or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags]. + // A given `VisitRequest` or `Vehicle` must match exactly one tag in this + // field. Note that a `Vehicle`'s source, destination and matrix tags may be + // the same; similarly a `VisitRequest`'s source and destination tags may be + // the same. All tags must be different and cannot be empty strings. If this + // field is not empty, then `duration_distance_matrices` must not be empty. + repeated string duration_distance_matrix_src_tags = 9; + + // Tags defining the destinations of the duration and distance matrices; + // `duration_distance_matrices(i).rows(j).durations(k)` (resp. + // `duration_distance_matrices(i).rows(j).meters(k))` defines the duration + // (resp. the distance) of the travel from visits with tag + // `duration_distance_matrix_src_tags(j)` to visits with tag + // `duration_distance_matrix_dst_tags(k)` in matrix i. + // + // Tags correspond to + // [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags] + // or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags]. + // A given `VisitRequest` or `Vehicle` must match exactly one tag in this + // field. Note that a `Vehicle`'s source, destination and matrix tags may be + // the same; similarly a `VisitRequest`'s source and destination tags may be + // the same. All tags must be different and cannot be empty strings. If this + // field is not empty, then `duration_distance_matrices` must not be empty. + repeated string duration_distance_matrix_dst_tags = 10; + + // Transition attributes added to the model. + repeated TransitionAttributes transition_attributes = 11; + + // Sets of incompatible shipment_types (see `ShipmentTypeIncompatibility`). + repeated ShipmentTypeIncompatibility shipment_type_incompatibilities = 12; + + // Sets of `shipment_type` requirements (see `ShipmentTypeRequirement`). + repeated ShipmentTypeRequirement shipment_type_requirements = 13; + + // Set of precedence rules which must be enforced in the model. + repeated PrecedenceRule precedence_rules = 14; + + // Deprecated: No longer used. + // Set of break rules used in the model. + // Each vehicle specifies the `BreakRule` that applies to it via the + // [Vehicle.break_rule_indices][google.cloud.optimization.v1.Vehicle.break_rule_indices] + // field (which must be a singleton). + repeated BreakRule break_rules = 15 [deprecated = true]; +} + +// The shipment of a single item, from one of its pickups to one of its +// deliveries. For the shipment to be considered as performed, a unique vehicle +// must visit one of its pickup locations (and decrease its spare capacities +// accordingly), then visit one of its delivery locations later on (and +// therefore re-increase its spare capacities accordingly). +message Shipment { + // Request for a visit which can be done by a vehicle: it has a geo-location + // (or two, see below), opening and closing times represented by time windows, + // and a service duration time (time spent by the vehicle once it has arrived + // to pickup or drop off goods). + message VisitRequest { + // The geo-location where the vehicle arrives when performing this + // `VisitRequest`. If the shipment model has duration distance matrices, + // `arrival_location` must not be specified. + google.type.LatLng arrival_location = 1; + + // The waypoint where the vehicle arrives when performing this + // `VisitRequest`. If the shipment model has duration distance matrices, + // `arrival_waypoint` must not be specified. + Waypoint arrival_waypoint = 2; + + // The geo-location where the vehicle departs after completing this + // `VisitRequest`. Can be omitted if it is the same as `arrival_location`. + // If the shipment model has duration distance matrices, + // `departure_location` must not be specified. + google.type.LatLng departure_location = 3; + + // The waypoint where the vehicle departs after completing this + // `VisitRequest`. Can be omitted if it is the same as `arrival_waypoint`. + // If the shipment model has duration distance matrices, + // `departure_waypoint` must not be specified. + Waypoint departure_waypoint = 4; + + // Specifies tags attached to the visit request. + // Empty or duplicate strings are not allowed. + repeated string tags = 5; + + // Time windows which constrain the arrival time at a visit. + // Note that a vehicle may depart outside of the arrival time window, i.e. + // arrival time + duration do not need to be inside a time window. This can + // result in waiting time if the vehicle arrives before + // [TimeWindow.start_time][google.cloud.optimization.v1.TimeWindow.start_time]. + // + // The absence of `TimeWindow` means that the vehicle can perform this visit + // at any time. + // + // Time windows must be disjoint, i.e. no time window must overlap with or + // be adjacent to another, and they must be in increasing order. + // + // `cost_per_hour_after_soft_end_time` and `soft_end_time` can only + // be set if there is a single time window. + repeated TimeWindow time_windows = 6; + + // Duration of the visit, i.e. time spent by the vehicle between arrival + // and departure (to be added to the possible waiting time; see + // `time_windows`). + google.protobuf.Duration duration = 7; + + // Cost to service this visit request on a vehicle route. This can be used + // to pay different costs for each alternative pickup or delivery of a + // shipment. This cost must be in the same unit as `Shipment.penalty_cost` + // and must not be negative. + double cost = 8; + + // Load demands of this visit request. This is just like + // [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands] + // field, except that it only applies to this + // [VisitRequest][google.cloud.optimization.v1.Shipment.VisitRequest] + // instead of the whole [Shipment][google.cloud.optimization.v1.Shipment]. + // The demands listed here are added to the demands listed in + // [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]. + map load_demands = 12; + + // Specifies the types of the visit. This may be used to allocate additional + // time required for a vehicle to complete this visit (see + // [Vehicle.extra_visit_duration_for_visit_type][google.cloud.optimization.v1.Vehicle.extra_visit_duration_for_visit_type]). + // + // A type can only appear once. + repeated string visit_types = 10; + + // Specifies a label for this `VisitRequest`. This label is reported in the + // response as `visit_label` in the corresponding + // [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit]. + string label = 11; + + // Deprecated: Use + // [VisitRequest.load_demands][google.cloud.optimization.v1.Shipment.VisitRequest.load_demands] + // instead. + repeated CapacityQuantity demands = 9 [deprecated = true]; + } + + // When performing a visit, a predefined amount may be added to the vehicle + // load if it's a pickup, or subtracted if it's a delivery. This message + // defines such amount. See + // [load_demands][google.cloud.optimization.v1.Shipment.load_demands]. + message Load { + // The amount by which the load of the vehicle performing the corresponding + // visit will vary. Since it is an integer, users are advised to choose an + // appropriate unit to avoid loss of precision. Must be ≥ 0. + int64 amount = 2; + } + + // Set of pickup alternatives associated to the shipment. If not specified, + // the vehicle only needs to visit a location corresponding to the deliveries. + repeated VisitRequest pickups = 1; + + // Set of delivery alternatives associated to the shipment. If not specified, + // the vehicle only needs to visit a location corresponding to the pickups. + repeated VisitRequest deliveries = 2; + + // Load demands of the shipment (for example weight, volume, number of + // pallets etc). The keys in the map should be identifiers describing the type + // of the corresponding load, ideally also including the units. + // For example: "weight_kg", "volume_gallons", "pallet_count", etc. + // If a given key does not appear in the map, the corresponding load is + // considered as null. + map load_demands = 14; + + // If the shipment is not completed, this penalty is added to the overall + // cost of the routes. A shipment is considered completed if one of its pickup + // and delivery alternatives is visited. The cost may be expressed in the + // same unit used for all other cost-related fields in the model and must be + // positive. + // + // *IMPORTANT*: If this penalty is not specified, it is considered infinite, + // i.e. the shipment must be completed. + optional double penalty_cost = 4; + + // The set of vehicles that may perform this shipment. If empty, all vehicles + // may perform it. Vehicles are given by their index in the `ShipmentModel`'s + // `vehicles` list. + repeated int32 allowed_vehicle_indices = 5; + + // Specifies the cost that is incurred when this shipment is delivered by each + // vehicle. If specified, it must have EITHER: + // + // * the same number of elements as `costs_per_vehicle_indices`. + // `costs_per_vehicle[i]` corresponds to vehicle + // `costs_per_vehicle_indices[i]` of the model. + // * the same number of elements as there are vehicles in the model. The + // i-th element corresponds to vehicle #i of the model. + // + // These costs must be in the same unit as `penalty_cost` and must not be + // negative. Leave this field empty, if there are no such costs. + repeated double costs_per_vehicle = 6; + + // Indices of the vehicles to which `costs_per_vehicle` applies. If non-empty, + // it must have the same number of elements as `costs_per_vehicle`. A vehicle + // index may not be specified more than once. If a vehicle is excluded from + // `costs_per_vehicle_indices`, its cost is zero. + repeated int32 costs_per_vehicle_indices = 7; + + // Specifies the maximum relative detour time compared to the shortest path + // from pickup to delivery. If specified, it must be nonnegative, and the + // shipment must contain at least a pickup and a delivery. + // + // For example, let t be the shortest time taken to go from the selected + // pickup alternative directly to the selected delivery alternative. Then + // setting `pickup_to_delivery_relative_detour_limit` enforces: + // + // ``` + // start_time(delivery) - start_time(pickup) <= + // std::ceil(t * (1.0 + pickup_to_delivery_relative_detour_limit)) + // ``` + // + // If both relative and absolute limits are specified on the same shipment, + // the more constraining limit is used for each possible pickup/delivery pair. + // As of 2017/10, detours are only supported when travel durations do not + // depend on vehicles. + optional double pickup_to_delivery_relative_detour_limit = 8; + + // Specifies the maximum absolute detour time compared to the shortest path + // from pickup to delivery. If specified, it must be nonnegative, and the + // shipment must contain at least a pickup and a delivery. + // + // For example, let t be the shortest time taken to go from the selected + // pickup alternative directly to the selected delivery alternative. Then + // setting `pickup_to_delivery_absolute_detour_limit` enforces: + // + // ``` + // start_time(delivery) - start_time(pickup) <= + // t + pickup_to_delivery_absolute_detour_limit + // ``` + // + // If both relative and absolute limits are specified on the same shipment, + // the more constraining limit is used for each possible pickup/delivery pair. + // As of 2017/10, detours are only supported when travel durations do not + // depend on vehicles. + google.protobuf.Duration pickup_to_delivery_absolute_detour_limit = 9; + + // Specifies the maximum duration from start of pickup to start of delivery of + // a shipment. If specified, it must be nonnegative, and the shipment must + // contain at least a pickup and a delivery. This does not depend on which + // alternatives are selected for pickup and delivery, nor on vehicle speed. + // This can be specified alongside maximum detour constraints: the solution + // will respect both specifications. + google.protobuf.Duration pickup_to_delivery_time_limit = 10; + + // Non-empty string specifying a "type" for this shipment. + // This feature can be used to define incompatibilities or requirements + // between `shipment_types` (see `shipment_type_incompatibilities` and + // `shipment_type_requirements` in `ShipmentModel`). + // + // Differs from `visit_types` which is specified for a single visit: All + // pickup/deliveries belonging to the same shipment share the same + // `shipment_type`. + string shipment_type = 11; + + // Specifies a label for this shipment. This label is reported in the response + // in the `shipment_label` of the corresponding + // [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit]. + string label = 12; + + // If true, skip this shipment, but don't apply a `penalty_cost`. + // + // Ignoring a shipment results in a validation error when there are any + // `shipment_type_requirements` in the model. + // + // Ignoring a shipment that is performed in `injected_first_solution_routes` + // or `injected_solution_constraint` is permitted; the solver removes the + // related pickup/delivery visits from the performing route. + // `precedence_rules` that reference ignored shipments will also be ignored. + bool ignore = 13; + + // Deprecated: Use + // [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands] + // instead. + repeated CapacityQuantity demands = 3 [deprecated = true]; +} + +// Specifies incompatibilties between shipments depending on their +// shipment_type. The appearance of incompatible shipments on the same route is +// restricted based on the incompatibility mode. +message ShipmentTypeIncompatibility { + // Modes defining how the appearance of incompatible shipments are restricted + // on the same route. + enum IncompatibilityMode { + // Unspecified incompatibility mode. This value should never be used. + INCOMPATIBILITY_MODE_UNSPECIFIED = 0; + + // In this mode, two shipments with incompatible types can never share the + // same vehicle. + NOT_PERFORMED_BY_SAME_VEHICLE = 1; + + // For two shipments with incompatible types with the + // `NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY` incompatibility mode: + // + // * If both are pickups only (no deliveries) or deliveries only (no + // pickups), they cannot share the same vehicle at all. + // * If one of the shipments has a delivery and the other a pickup, the two + // shipments can share the same vehicle iff the former shipment is + // delivered before the latter is picked up. + NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY = 2; + } + + // List of incompatible types. Two shipments having different `shipment_types` + // among those listed are "incompatible". + repeated string types = 1; + + // Mode applied to the incompatibility. + IncompatibilityMode incompatibility_mode = 2; +} + +// Specifies requirements between shipments based on their shipment_type. +// The specifics of the requirement are defined by the requirement mode. +message ShipmentTypeRequirement { + // Modes defining the appearance of dependent shipments on a route. + enum RequirementMode { + // Unspecified requirement mode. This value should never be used. + REQUIREMENT_MODE_UNSPECIFIED = 0; + + // In this mode, all "dependent" shipments must share the same vehicle as at + // least one of their "required" shipments. + PERFORMED_BY_SAME_VEHICLE = 1; + + // With the `IN_SAME_VEHICLE_AT_PICKUP_TIME` mode, all "dependent" + // shipments need to have at least one "required" shipment on their vehicle + // at the time of their pickup. + // + // A "dependent" shipment pickup must therefore have either: + // + // * A delivery-only "required" shipment delivered on the route after, or + // * A "required" shipment picked up on the route before it, and if the + // "required" shipment has a delivery, this delivery must be performed + // after the "dependent" shipment's pickup. + IN_SAME_VEHICLE_AT_PICKUP_TIME = 2; + + // Same as before, except the "dependent" shipments need to have a + // "required" shipment on their vehicle at the time of their *delivery*. + IN_SAME_VEHICLE_AT_DELIVERY_TIME = 3; + } + + // List of alternative shipment types required by the + // `dependent_shipment_types`. + repeated string required_shipment_type_alternatives = 1; + + // All shipments with a type in the `dependent_shipment_types` field require + // at least one shipment of type `required_shipment_type_alternatives` to be + // visited on the same route. + // + // NOTE: Chains of requirements such that a `shipment_type` depends on itself + // are not allowed. + repeated string dependent_shipment_types = 2; + + // Mode applied to the requirement. + RequirementMode requirement_mode = 3; +} + +// Models a vehicle in a shipment problem. Solving a shipment problem will +// build a route starting from `start_location` and ending at `end_location` +// for this vehicle. A route is a sequence of visits (see `ShipmentRoute`). +message Vehicle { + // Travel modes which can be used by vehicles. + // + // These should be a subset of the Google Maps Platform Routes Preferred API + // travel modes, see: + // https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/RouteTravelMode. + enum TravelMode { + // Unspecified travel mode, equivalent to `DRIVING`. + TRAVEL_MODE_UNSPECIFIED = 0; + + // Travel mode corresponding to driving directions (car, ...). + DRIVING = 1; + } + + // Policy on how a vehicle can be unloaded. Applies only to shipments having + // both a pickup and a delivery. + // + // Other shipments are free to occur anywhere on the route independent of + // `unloading_policy`. + enum UnloadingPolicy { + // Unspecified unloading policy; deliveries must just occur after their + // corresponding pickups. + UNLOADING_POLICY_UNSPECIFIED = 0; + + // Deliveries must occur in reverse order of pickups + LAST_IN_FIRST_OUT = 1; + + // Deliveries must occur in the same order as pickups + FIRST_IN_FIRST_OUT = 2; + } + + // Defines a load limit applying to a vehicle, e.g. "this truck may only + // carry up to 3500 kg". See + // [load_limits][google.cloud.optimization.v1.Vehicle.load_limits]. + message LoadLimit { + // Interval of acceptable load amounts. + message Interval { + // A minimum acceptable load. Must be ≥ 0. + // If they're both specified, + // [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must + // be ≤ + // [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]. + int64 min = 1; + + // A maximum acceptable load. Must be ≥ 0. If unspecified, the maximum + // load is unrestricted by this message. + // If they're both specified, + // [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must + // be ≤ + // [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]. + optional int64 max = 2; + } + + // The maximum acceptable amount of load. + optional int64 max_load = 1; + + // A soft limit of the load. See + // [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]. + int64 soft_max_load = 2; + + // If the load ever exceeds + // [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load] + // along this vehicle's route, the following cost penalty applies (only once + // per vehicle): (load - + // [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load]) + // * [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]. All costs + // add up and must be in the same unit as + // [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost]. + double cost_per_unit_above_soft_max = 3; + + // The acceptable load interval of the vehicle at the start of the route. + Interval start_load_interval = 4; + + // The acceptable load interval of the vehicle at the end of the route. + Interval end_load_interval = 5; + } + + // A limit defining a maximum duration of the route of a vehicle. It can be + // either hard or soft. + // + // When a soft limit field is defined, both the soft max threshold and its + // associated cost must be defined together. + message DurationLimit { + // A hard limit constraining the duration to be at most max_duration. + google.protobuf.Duration max_duration = 1; + + // A soft limit not enforcing a maximum duration limit, but when violated + // makes the route incur a cost. This cost adds up to other costs defined in + // the model, with the same unit. + // + // If defined, `soft_max_duration` must be nonnegative. If max_duration is + // also defined, `soft_max_duration` must be less than max_duration. + google.protobuf.Duration soft_max_duration = 2; + + // Cost per hour incurred if the `soft_max_duration` threshold is violated. + // The additional cost is 0 if the duration is under the threshold, + // otherwise the cost depends on the duration as follows: + // ``` + // cost_per_hour_after_soft_max * (duration - soft_max_duration) + // ``` + // The cost must be nonnegative. + optional double cost_per_hour_after_soft_max = 3; + + // A soft limit not enforcing a maximum duration limit, but when violated + // makes the route incur a cost, quadratic in the duration. This cost adds + // up to other costs defined in the model, with the same unit. + // + // If defined, `quadratic_soft_max_duration` must be nonnegative. If + // `max_duration` is also defined, `quadratic_soft_max_duration` must be + // less than `max_duration`, and the difference must be no larger than one + // day: + // + // `max_duration - quadratic_soft_max_duration <= 86400 seconds` + google.protobuf.Duration quadratic_soft_max_duration = 4; + + // Cost per square hour incurred if the + // `quadratic_soft_max_duration` threshold is violated. + // + // The additional cost is 0 if the duration is under the threshold, + // otherwise the cost depends on the duration as follows: + // + // ``` + // cost_per_square_hour_after_quadratic_soft_max * + // (duration - quadratic_soft_max_duration)^2 + // ``` + // + // The cost must be nonnegative. + optional double cost_per_square_hour_after_quadratic_soft_max = 5; + } + + // The travel mode which affects the roads usable by the vehicle and its + // speed. See also `travel_duration_multiple`. + TravelMode travel_mode = 1; + + // Geographic location where the vehicle starts before picking up any + // shipments. If not specified, the vehicle starts at its first pickup. + // If the shipment model has duration and distance matrices, `start_location` + // must not be specified. + google.type.LatLng start_location = 3; + + // Waypoint representing a geographic location where the vehicle starts before + // picking up any shipments. If neither `start_waypoint` nor `start_location` + // is specified, the vehicle starts at its first pickup. + // If the shipment model has duration and distance matrices, `start_waypoint` + // must not be specified. + Waypoint start_waypoint = 4; + + // Geographic location where the vehicle ends after it has completed its last + // `VisitRequest`. If not specified the vehicle's `ShipmentRoute` ends + // immediately when it completes its last `VisitRequest`. + // If the shipment model has duration and distance matrices, `end_location` + // must not be specified. + google.type.LatLng end_location = 5; + + // Waypoint representing a geographic location where the vehicle ends after + // it has completed its last `VisitRequest`. If neither `end_waypoint` nor + // `end_location` is specified, the vehicle's `ShipmentRoute` ends immediately + // when it completes its last `VisitRequest`. + // If the shipment model has duration and distance matrices, `end_waypoint` + // must not be specified. + Waypoint end_waypoint = 6; + + // Specifies tags attached to the start of the vehicle's route. + // + // Empty or duplicate strings are not allowed. + repeated string start_tags = 7; + + // Specifies tags attached to the end of the vehicle's route. + // + // Empty or duplicate strings are not allowed. + repeated string end_tags = 8; + + // Time windows during which the vehicle may depart its start location. + // They must be within the global time limits (see + // [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time] + // fields). If unspecified, there is no limitation besides those global time + // limits. + // + // Time windows belonging to the same repeated field must be disjoint, i.e. no + // time window can overlap with or be adjacent to another, and they must be in + // chronological order. + // + // `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if + // there is a single time window. + repeated TimeWindow start_time_windows = 9; + + // Time windows during which the vehicle may arrive at its end location. + // They must be within the global time limits (see + // [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time] + // fields). If unspecified, there is no limitation besides those global time + // limits. + // + // Time windows belonging to the same repeated field must be disjoint, i.e. no + // time window can overlap with or be adjacent to another, and they must be in + // chronological order. + // + // `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if + // there is a single time window. + repeated TimeWindow end_time_windows = 10; + + // Specifies a multiplicative factor that can be used to increase or decrease + // travel times of this vehicle. For example, setting this to 2.0 means + // that this vehicle is slower and has travel times that are twice what they + // are for standard vehicles. This multiple does not affect visit durations. + // It does affect cost if `cost_per_hour` or `cost_per_traveled_hour` are + // specified. This must be in the range [0.001, 1000.0]. If unset, the vehicle + // is standard, and this multiple is considered 1.0. + // + // WARNING: Travel times will be rounded to the nearest second after this + // multiple is applied but before performing any numerical operations, thus, + // a small multiple may result in a loss of precision. + // + // See also `extra_visit_duration_for_visit_type` below. + optional double travel_duration_multiple = 11; + + // Unloading policy enforced on the vehicle. + UnloadingPolicy unloading_policy = 12; + + // Capacities of the vehicle (weight, volume, # of pallets for example). + // The keys in the map are the identifiers of the type of load, consistent + // with the keys of the + // [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands] + // field. If a given key is absent from this map, the corresponding capacity + // is considered to be limitless. + map load_limits = 30; + + // Vehicle costs: all costs add up and must be in the same unit as + // [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost]. + // + // Cost per hour of the vehicle route. This cost is applied to the total time + // taken by the route, and includes travel time, waiting time, and visit time. + // Using `cost_per_hour` instead of just `cost_per_traveled_hour` may result + // in additional latency. + double cost_per_hour = 16; + + // Cost per traveled hour of the vehicle route. This cost is applied only to + // travel time taken by the route (i.e., that reported in + // [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]), + // and excludes waiting time and visit time. + double cost_per_traveled_hour = 17; + + // Cost per kilometer of the vehicle route. This cost is applied to the + // distance reported in the + // [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions] + // and does not apply to any distance implicitly traveled from the + // `arrival_location` to the `departure_location` of a single `VisitRequest`. + double cost_per_kilometer = 18; + + // Fixed cost applied if this vehicle is used to handle a shipment. + double fixed_cost = 19; + + // This field only applies to vehicles when their route does not serve any + // shipments. It indicates if the vehicle should be considered as used or not + // in this case. + // + // If true, the vehicle goes from its start to its end location even if it + // doesn't serve any shipments, and time and distance costs resulting from its + // start --> end travel are taken into account. + // + // Otherwise, it doesn't travel from its start to its end location, and no + // `break_rule` or delay (from `TransitionAttributes`) are scheduled for this + // vehicle. In this case, the vehicle's `ShipmentRoute` doesn't contain any + // information except for the vehicle index and label. + bool used_if_route_is_empty = 20; + + // Limit applied to the total duration of the vehicle's route. In a given + // `OptimizeToursResponse`, the route duration of a vehicle is the + // difference between its `vehicle_end_time` and `vehicle_start_time`. + DurationLimit route_duration_limit = 21; + + // Limit applied to the travel duration of the vehicle's route. In a given + // `OptimizeToursResponse`, the route travel duration is the sum of all its + // [transitions.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration]. + DurationLimit travel_duration_limit = 22; + + // Limit applied to the total distance of the vehicle's route. In a given + // `OptimizeToursResponse`, the route distance is the sum of all its + // [transitions.travel_distance_meters][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_distance_meters]. + DistanceLimit route_distance_limit = 23; + + // Specifies a map from visit_types strings to durations. The duration is time + // in addition to + // [VisitRequest.duration][google.cloud.optimization.v1.Shipment.VisitRequest.duration] + // to be taken at visits with the specified `visit_types`. This extra visit + // duration adds cost if `cost_per_hour` is specified. Keys (i.e. + // `visit_types`) cannot be empty strings. + // + // If a visit request has multiple types, a duration will be added for each + // type in the map. + map extra_visit_duration_for_visit_type = + 24; + + // Describes the break schedule to be enforced on this vehicle. + // If empty, no breaks will be scheduled for this vehicle. + BreakRule break_rule = 25; + + // Specifies a label for this vehicle. This label is reported in the response + // as the `vehicle_label` of the corresponding + // [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute]. + string label = 27; + + // If true, `used_if_route_is_empty` must be false, and this vehicle will + // remain unused. + // + // If a shipment is performed by an ignored vehicle in + // `injected_first_solution_routes`, it is skipped in the first solution but + // is free to be performed in the response. + // + // If a shipment is performed by an ignored vehicle in + // `injected_solution_constraint` and any related pickup/delivery is + // constrained to remain on the vehicle (i.e., not relaxed to level + // `RELAX_ALL_AFTER_THRESHOLD`), it is skipped in the response. + // If a shipment has a non-empty `allowed_vehicle_indices` field and all of + // the allowed vehicles are ignored, it is skipped in the response. + bool ignore = 28; + + // Deprecated: No longer used. + // Indices in the `break_rule` field in the source + // [ShipmentModel][google.cloud.optimization.v1.ShipmentModel]. They + // correspond to break rules enforced on the vehicle. + // + // As of 2018/03, at most one rule index per vehicle can be specified. + repeated int32 break_rule_indices = 29 [deprecated = true]; + + // Deprecated: Use + // [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits] + // instead. + repeated CapacityQuantity capacities = 13 [deprecated = true]; + + // Deprecated: Use + // [Vehicle.LoadLimit.start_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.start_load_interval] + // instead. + repeated CapacityQuantityInterval start_load_intervals = 14 + [deprecated = true]; + + // Deprecated: Use + // [Vehicle.LoadLimit.end_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.end_load_interval] + // instead. + repeated CapacityQuantityInterval end_load_intervals = 15 [deprecated = true]; +} + +// Time windows constrain the time of an event, such as the arrival time at a +// visit, or the start and end time of a vehicle. +// +// Hard time window bounds, `start_time` and `end_time`, enforce the earliest +// and latest time of the event, such that `start_time <= event_time <= +// end_time`. The soft time window lower bound, `soft_start_time`, expresses a +// preference for the event to happen at or after `soft_start_time` by incurring +// a cost proportional to how long before soft_start_time the event occurs. The +// soft time window upper bound, `soft_end_time`, expresses a preference for the +// event to happen at or before `soft_end_time` by incurring a cost proportional +// to how long after `soft_end_time` the event occurs. `start_time`, `end_time`, +// `soft_start_time` and `soft_end_time` should be within the global time limits +// (see +// [ShipmentModel.global_start_time][google.cloud.optimization.v1.ShipmentModel.global_start_time] +// and +// [ShipmentModel.global_end_time][google.cloud.optimization.v1.ShipmentModel.global_end_time]) +// and should respect: +// ``` +// 0 <= `start_time` <= `soft_start_time` <= `end_time` and +// 0 <= `start_time` <= `soft_end_time` <= `end_time`. +// ``` +message TimeWindow { + // The hard time window start time. If unspecified it will be set to + // `ShipmentModel.global_start_time`. + google.protobuf.Timestamp start_time = 1; + + // The hard time window end time. If unspecified it will be set to + // `ShipmentModel.global_end_time`. + google.protobuf.Timestamp end_time = 2; + + // The soft start time of the time window. + google.protobuf.Timestamp soft_start_time = 3; + + // The soft end time of the time window. + google.protobuf.Timestamp soft_end_time = 4; + + // A cost per hour added to other costs in the model if the event occurs + // before soft_start_time, computed as: + // + // ``` + // max(0, soft_start_time - t.seconds) + // * cost_per_hour_before_soft_start_time / 3600, + // t being the time of the event. + // ``` + // + // This cost must be positive, and the field can only be set if + // soft_start_time has been set. + optional double cost_per_hour_before_soft_start_time = 5; + + // A cost per hour added to other costs in the model if the event occurs after + // `soft_end_time`, computed as: + // + // ``` + // max(0, t.seconds - soft_end_time.seconds) + // * cost_per_hour_after_soft_end_time / 3600, + // t being the time of the event. + // ``` + // + // This cost must be positive, and the field can only be set if + // `soft_end_time` has been set. + optional double cost_per_hour_after_soft_end_time = 6; +} + +// Deprecated: Use +// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval] +// instead. +message CapacityQuantity { + option deprecated = true; + + string type = 1; + + int64 value = 2; +} + +// Deprecated: Use +// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval] +// instead. +message CapacityQuantityInterval { + option deprecated = true; + + string type = 1; + + optional int64 min_value = 2; + + optional int64 max_value = 3; +} + +// A limit defining a maximum distance which can be traveled. It can be either +// hard or soft. +// +// If a soft limit is defined, both `soft_max_meters` and +// `cost_per_kilometer_above_soft_max` must be defined and be nonnegative. +message DistanceLimit { + // A hard limit constraining the distance to be at most max_meters. The limit + // must be nonnegative. + optional int64 max_meters = 1; + + // A soft limit not enforcing a maximum distance limit, but when violated + // results in a cost which adds up to other costs defined in the model, + // with the same unit. + // + // If defined soft_max_meters must be less than max_meters and must be + // nonnegative. + optional int64 soft_max_meters = 2; + + // Cost per kilometer incurred if distance is above `soft_max_meters` limit. + // The additional cost is 0 if the distance is under the limit, otherwise the + // formula used to compute the cost is the following: + // ``` + // (distance_meters - soft_max_meters) / 1000.0 * + // cost_per_kilometer_above_soft_max. + // ``` + // The cost must be nonnegative. + optional double cost_per_kilometer_above_soft_max = 3; +} + +// Specifies attributes of transitions between two consecutive visits on a +// route. Several `TransitionAttributes` may apply to the same transition: in +// that case, all extra costs add up and the strictest constraint or limit +// applies (following natural "AND" semantics). +message TransitionAttributes { + // Tags defining the set of (src->dst) transitions these attributes apply to. + // + // A source visit or vehicle start matches iff its + // [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags] + // or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags] + // either contains `src_tag` or does not contain `excluded_src_tag` (depending + // on which of these two fields is non-empty). + string src_tag = 1; + + // See `src_tag`. Exactly one of `src_tag` and `excluded_src_tag` must be + // non-empty. + string excluded_src_tag = 2; + + // A destination visit or vehicle end matches iff its + // [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags] + // or [Vehicle.end_tags][google.cloud.optimization.v1.Vehicle.end_tags] either + // contains `dst_tag` or does not contain `excluded_dst_tag` (depending on + // which of these two fields is non-empty). + string dst_tag = 3; + + // See `dst_tag`. Exactly one of `dst_tag` and `excluded_dst_tag` must be + // non-empty. + string excluded_dst_tag = 4; + + // Specifies a cost for performing this transition. This is in the same unit + // as all other costs in the model and must not be negative. It is applied on + // top of all other existing costs. + double cost = 5; + + // Specifies a cost per kilometer applied to the distance traveled while + // performing this transition. It adds up to any + // [Vehicle.cost_per_kilometer][google.cloud.optimization.v1.Vehicle.cost_per_kilometer] + // specified on vehicles. + double cost_per_kilometer = 6; + + // Specifies a limit on the distance traveled while performing this + // transition. + // + // As of 2021/06, only soft limits are supported. + DistanceLimit distance_limit = 7; + + // Specifies a delay incurred when performing this transition. + // + // This delay always occurs *after* finishing the source visit and *before* + // starting the destination visit. + google.protobuf.Duration delay = 8; +} + +// Encapsulates a waypoint. Waypoints mark arrival and departure locations of +// VisitRequests, and start and end locations of Vehicles. +message Waypoint { + // Different ways to represent a location. + oneof location_type { + // A point specified using geographic coordinates, including an optional + // heading. + Location location = 1; + + // The POI Place ID associated with the waypoint. + string place_id = 2; + } + + // Indicates that the location of this waypoint is meant to have a preference + // for the vehicle to stop at a particular side of road. When you set this + // value, the route will pass through the location so that the vehicle can + // stop at the side of road that the location is biased towards from the + // center of the road. This option works only for the 'DRIVING' travel mode, + // and when the 'location_type' is set to 'location'. + bool side_of_road = 3; +} + +// Encapsulates a location (a geographic point, and an optional heading). +message Location { + // The waypoint's geographic coordinates. + google.type.LatLng lat_lng = 1; + + // The compass heading associated with the direction of the flow of traffic. + // This value is used to specify the side of the road to use for pickup and + // drop-off. Heading values can be from 0 to 360, where 0 specifies a heading + // of due North, 90 specifies a heading of due East, etc. + optional int32 heading = 2; +} + +// Rules to generate time breaks for a vehicle (e.g. lunch breaks). A break +// is a contiguous period of time during which the vehicle remains idle at its +// current position and cannot perform any visit. A break may occur: +// +// * during the travel between two visits (which includes the time right +// before or right after a visit, but not in the middle of a visit), in +// which case it extends the corresponding transit time between the visits, +// * or before the vehicle start (the vehicle may not start in the middle of +// a break), in which case it does not affect the vehicle start time. +// * or after the vehicle end (ditto, with the vehicle end time). +message BreakRule { + // The sequence of breaks (i.e. their number and order) that apply to each + // vehicle must be known beforehand. The repeated `BreakRequest`s define + // that sequence, in the order in which they must occur. Their time windows + // (`earliest_start_time` / `latest_start_time`) may overlap, but they must + // be compatible with the order (this is checked). + message BreakRequest { + // Required. Lower bound (inclusive) on the start of the break. + google.protobuf.Timestamp earliest_start_time = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Upper bound (inclusive) on the start of the break. + google.protobuf.Timestamp latest_start_time = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Minimum duration of the break. Must be positive. + google.protobuf.Duration min_duration = 3 + [(google.api.field_behavior) = REQUIRED]; + } + + // One may further constrain the frequency and duration of the breaks + // specified above, by enforcing a minimum break frequency, such as + // "There must be a break of at least 1 hour every 12 hours". Assuming that + // this can be interpreted as "Within any sliding time window of 12h, there + // must be at least one break of at least one hour", that example would + // translate to the following `FrequencyConstraint`: + // ``` + // { + // min_break_duration { seconds: 3600 } # 1 hour. + // max_inter_break_duration { seconds: 39600 } # 11 hours (12 - 1 = 11). + // } + // ``` + // + // The timing and duration of the breaks in the solution will respect all + // such constraints, in addition to the time windows and minimum durations + // already specified in the `BreakRequest`. + // + // A `FrequencyConstraint` may in practice apply to non-consecutive breaks. + // For example, the following schedule honors the "1h every 12h" example: + // ``` + // 04:00 vehicle start + // .. performing travel and visits .. + // 09:00 1 hour break + // 10:00 end of the break + // .. performing travel and visits .. + // 12:00 20-min lunch break + // 12:20 end of the break + // .. performing travel and visits .. + // 21:00 1 hour break + // 22:00 end of the break + // .. performing travel and visits .. + // 23:59 vehicle end + // ``` + message FrequencyConstraint { + // Required. Minimum break duration for this constraint. Nonnegative. + // See description of `FrequencyConstraint`. + google.protobuf.Duration min_break_duration = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Maximum allowed span of any interval of time in the route that + // does not include at least partially a break of `duration >= + // min_break_duration`. Must be positive. + google.protobuf.Duration max_inter_break_duration = 2 + [(google.api.field_behavior) = REQUIRED]; + } + + // Sequence of breaks. See the `BreakRequest` message. + repeated BreakRequest break_requests = 1; + + // Several `FrequencyConstraint` may apply. They must all be satisfied by + // the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`. + repeated FrequencyConstraint frequency_constraints = 2; +} + +// A vehicle's route can be decomposed, along the time axis, like this (we +// assume there are n visits): +// ``` +// | | | | | T[2], | | | +// | Transition | Visit #0 | | | V[2], | | | +// | #0 | aka | T[1] | V[1] | ... | V[n-1] | T[n] | +// | aka T[0] | V[0] | | | V[n-2],| | | +// | | | | | T[n-1] | | | +// ^ ^ ^ ^ ^ ^ ^ ^ +// vehicle V[0].start V[0].end V[1]. V[1]. V[n]. V[n]. vehicle +// start (arrival) (departure) start end start end end +// ``` +// Note that we make a difference between: +// +// * "punctual events", such as the vehicle start and end and each visit's start +// and end (aka arrival and departure). They happen at a given second. +// * "time intervals", such as the visits themselves, and the transition between +// visits. Though time intervals can sometimes have zero duration, i.e. start +// and end at the same second, they often have a positive duration. +// +// Invariants: +// +// * If there are n visits, there are n+1 transitions. +// * A visit is always surrounded by a transition before it (same index) and a +// transition after it (index + 1). +// * The vehicle start is always followed by transition #0. +// * The vehicle end is always preceded by transition #n. +// +// Zooming in, here is what happens during a `Transition` and a `Visit`: +// ``` +// ---+-------------------------------------+-----------------------------+--> +// | TRANSITION[i] | VISIT[i] | +// | | | +// | * TRAVEL: the vehicle moves from | PERFORM the visit: | +// | VISIT[i-1].departure_location to | | +// | VISIT[i].arrival_location, which | * Spend some time: | +// | takes a given travel duration | the "visit duration". | +// | and distance | | +// | | * Load or unload | +// | * BREAKS: the driver may have | some quantities from the | +// | breaks (e.g. lunch break). | vehicle: the "demand". | +// | | | +// | * WAIT: the driver/vehicle does | | +// | nothing. This can happen for | | +// | many reasons, for example when | | +// | the vehicle reaches the next | | +// | event's destination before the | | +// | start of its time window | | +// | | | +// | * DELAY: *right before* the next | | +// | arrival. E.g. the vehicle and/or | | +// | driver spends time unloading. | | +// | | | +// ---+-------------------------------------+-----------------------------+--> +// ^ ^ ^ +// V[i-1].end V[i].start V[i].end +// ``` +// Lastly, here is how the TRAVEL, BREAKS, DELAY and WAIT can be arranged +// during a transition. +// +// * They don't overlap. +// * The DELAY is unique and *must* be a contiguous period of time right +// before the next visit (or vehicle end). Thus, it suffice to know the +// delay duration to know its start and end time. +// * The BREAKS are contiguous, non-overlapping periods of time. The +// response specifies the start time and duration of each break. +// * TRAVEL and WAIT are "preemptable": they can be interrupted several times +// during this transition. Clients can assume that travel happens "as soon as +// possible" and that "wait" fills the remaining time. +// +// A (complex) example: +// ``` +// TRANSITION[i] +// --++-----+-----------------------------------------------------------++--> +// || | | | | | | || +// || T | B | T | | B | | D || +// || r | r | r | W | r | W | e || +// || a | e | a | a | e | a | l || +// || v | a | v | i | a | i | a || +// || e | k | e | t | k | t | y || +// || l | | l | | | | || +// || | | | | | | || +// --++-----------------------------------------------------------------++--> +// ``` +message ShipmentRoute { + // Deprecated: Use + // [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration] + // instead. Time interval spent on the route resulting from a + // [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay]. + message Delay { + option deprecated = true; + + // Start of the delay. + google.protobuf.Timestamp start_time = 1; + + // Duration of the delay. + google.protobuf.Duration duration = 2; + } + + // A visit performed during a route. This visit corresponds to a pickup or a + // delivery of a `Shipment`. + message Visit { + // Index of the `shipments` field in the source + // [ShipmentModel][google.cloud.optimization.v1.ShipmentModel]. + int32 shipment_index = 1; + + // If true the visit corresponds to a pickup of a `Shipment`. Otherwise, it + // corresponds to a delivery. + bool is_pickup = 2; + + // Index of `VisitRequest` in either the pickup or delivery field of the + // `Shipment` (see `is_pickup`). + int32 visit_request_index = 3; + + // Time at which the visit starts. Note that the vehicle may arrive earlier + // than this at the visit location. Times are consistent with the + // `ShipmentModel`. + google.protobuf.Timestamp start_time = 4; + + // Total visit load demand as the sum of the shipment and the visit request + // `load_demands`. The values are negative if the visit is a delivery. + // Demands are reported for the same types as the + // [Transition.loads][google.cloud.optimization.v1.ShipmentRoute.Transition] + // (see this field). + map load_demands = 11; + + // Extra detour time due to the shipments visited on the route before the + // visit and to the potential waiting time induced by time windows. + // If the visit is a delivery, the detour is computed from the corresponding + // pickup visit and is equal to: + // ``` + // start_time(delivery) - start_time(pickup) + // - (duration(pickup) + travel duration from the pickup location + // to the delivery location). + // ``` + // Otherwise, it is computed from the vehicle `start_location` and is equal + // to: + // ``` + // start_time - vehicle_start_time - travel duration from + // the vehicle's `start_location` to the visit. + // ``` + google.protobuf.Duration detour = 6; + + // Copy of the corresponding `Shipment.label`, if specified in the + // `Shipment`. + string shipment_label = 7; + + // Copy of the corresponding + // [VisitRequest.label][google.cloud.optimization.v1.Shipment.VisitRequest.label], + // if specified in the `VisitRequest`. + string visit_label = 8; + + // Deprecated: Use + // [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads] + // instead. Vehicle loads upon arrival at the visit location, for each type + // specified in + // [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities], + // `start_load_intervals`, `end_load_intervals` or `demands`. + // + // Exception: we omit loads for quantity types unconstrained by intervals + // and that don't have any non-zero demand on the route. + repeated CapacityQuantity arrival_loads = 9 [deprecated = true]; + + // Deprecated: Use + // [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration] + // instead. Delay occurring before the visit starts. + Delay delay_before_start = 10 [deprecated = true]; + + // Deprecated: Use + // [Visit.load_demands][google.cloud.optimization.v1.ShipmentRoute.Visit.load_demands] + // instead. + repeated CapacityQuantity demands = 5 [deprecated = true]; + } + + // Transition between two events on the route. See the description of + // [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute]. + // + // If the vehicle does not have a `start_location` and/or `end_location`, the + // corresponding travel metrics are 0. + message Transition { + // Travel duration during this transition. + google.protobuf.Duration travel_duration = 1; + + // Distance traveled during the transition. + double travel_distance_meters = 2; + + // When traffic is requested via + // [OptimizeToursRequest.consider_road_traffic] + // [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic], + // and the traffic info couldn't be retrieved for a `Transition`, this + // boolean is set to true. This may be temporary (rare hiccup in the + // realtime traffic servers) or permanent (no data for this location). + bool traffic_info_unavailable = 3; + + // Sum of the delay durations applied to this transition. If any, the delay + // starts exactly `delay_duration` seconds before the next event (visit or + // vehicle end). See + // [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay]. + google.protobuf.Duration delay_duration = 4; + + // Sum of the duration of the breaks occurring during this transition, if + // any. Details about each break's start time and duration are stored in + // [ShipmentRoute.breaks][google.cloud.optimization.v1.ShipmentRoute.breaks]. + google.protobuf.Duration break_duration = 5; + + // Time spent waiting during this transition. Wait duration corresponds to + // idle time and does not include break time. Also note that this wait time + // may be split into several non-contiguous intervals. + google.protobuf.Duration wait_duration = 6; + + // Total duration of the transition, provided for convenience. It is equal + // to: + // + // * next visit `start_time` (or `vehicle_end_time` if this is the last + // transition) - this transition's `start_time`; + // * if `ShipmentRoute.has_traffic_infeasibilities` is false, the following + // additionally holds: `total_duration = travel_duration + delay_duration + // + break_duration + wait_duration`. + google.protobuf.Duration total_duration = 7; + + // Start time of this transition. + google.protobuf.Timestamp start_time = 8; + + // The encoded polyline representation of the route followed during the + // transition. + // This field is only populated if [populate_transition_polylines] + // [google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines] + // is set to true. + EncodedPolyline route_polyline = 9; + + // Vehicle loads during this transition, for each type that either appears + // in this vehicle's + // [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits], + // or that have non-zero + // [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands] + // on some shipment performed on this route. + // + // The loads during the first transition are the starting loads of the + // vehicle route. Then, after each visit, the visit's `load_demands` are + // either added or subtracted to get the next transition's loads, depending + // on whether the visit was a pickup or a delivery. + map vehicle_loads = 11; + + // Deprecated: Use + // [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads] + // instead. + repeated CapacityQuantity loads = 10 [deprecated = true]; + } + + // Reports the actual load of the vehicle at some point along the route, + // for a given type (see + // [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]). + message VehicleLoad { + // The amount of load on the vehicle, for the given type. The unit of load + // is usually indicated by the type. See + // [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]. + int64 amount = 1; + } + + // The encoded representation of a polyline. More information on polyline + // encoding can be found here: + // https://developers.google.com/maps/documentation/utilities/polylinealgorithm + // https://developers.google.com/maps/documentation/javascript/reference/geometry#encoding. + message EncodedPolyline { + // String representing encoded points of the polyline. + string points = 1; + } + + // Data representing the execution of a break. + message Break { + // Start time of a break. + google.protobuf.Timestamp start_time = 1; + + // Duration of a break. + google.protobuf.Duration duration = 2; + } + + // Deprecated: Use + // [ShipmentRoute.Transition][google.cloud.optimization.v1.ShipmentRoute.Transition] + // instead. Travel between each visit along the route: from the vehicle's + // `start_location` to the first visit's `arrival_location`, then from the + // first visit's `departure_location` to the second visit's + // `arrival_location`, and so on until the vehicle's `end_location`. This + // accounts only for the actual travel between visits, not counting the + // waiting time, the time spent performing a visit, nor the distance covered + // during a visit. + // + // Invariant: `travel_steps_size() == visits_size() + 1`. + // + // If the vehicle does not have a start_ and/or end_location, the + // corresponding travel metrics are 0 and/or empty. + message TravelStep { + option deprecated = true; + + // Duration of the travel step. + google.protobuf.Duration duration = 1; + + // Distance traveled during the step. + double distance_meters = 2; + + // When traffic is requested via + // [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic], + // and the traffic info couldn't be retrieved for a TravelStep, this boolean + // is set to true. This may be temporary (rare hiccup in the realtime + // traffic servers) or permanent (no data for this location). + bool traffic_info_unavailable = 3; + + // The encoded polyline representation of the route followed during the + // step. + // + // This field is only populated if + // [OptimizeToursRequest.populate_travel_step_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_travel_step_polylines] + // is set to true. + EncodedPolyline route_polyline = 4; + } + + // Vehicle performing the route, identified by its index in the source + // `ShipmentModel`. + int32 vehicle_index = 1; + + // Label of the vehicle performing this route, equal to + // `ShipmentModel.vehicles(vehicle_index).label`, if specified. + string vehicle_label = 2; + + // Time at which the vehicle starts its route. + google.protobuf.Timestamp vehicle_start_time = 5; + + // Time at which the vehicle finishes its route. + google.protobuf.Timestamp vehicle_end_time = 6; + + // Ordered sequence of visits representing a route. + // visits[i] is the i-th visit in the route. + // If this field is empty, the vehicle is considered as unused. + repeated Visit visits = 7; + + // Ordered list of transitions for the route. + repeated Transition transitions = 8; + + // When + // [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic], + // is set to true, this field indicates that inconsistencies in route timings + // are predicted using traffic-based travel duration estimates. There may be + // insufficient time to complete traffic-adjusted travel, delays, and breaks + // between visits, before the first visit, or after the last visit, while + // still satisfying the visit and vehicle time windows. For example, + // + // ``` + // start_time(previous_visit) + duration(previous_visit) + + // travel_duration(previous_visit, next_visit) > start_time(next_visit) + // ``` + // + // Arrival at next_visit will likely happen later than its current + // time window due the increased estimate of travel time + // `travel_duration(previous_visit, next_visit)` due to traffic. Also, a break + // may be forced to overlap with a visit due to an increase in travel time + // estimates and visit or break time window restrictions. + bool has_traffic_infeasibilities = 9; + + // The encoded polyline representation of the route. + // This field is only populated if + // [OptimizeToursRequest.populate_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_polylines] + // is set to true. + EncodedPolyline route_polyline = 10; + + // Breaks scheduled for the vehicle performing this route. + // The `breaks` sequence represents time intervals, each starting at the + // corresponding `start_time` and lasting `duration` seconds. + repeated Break breaks = 11; + + // Duration, distance and load metrics for this route. The fields of + // [AggregatedMetrics][google.cloud.optimization.v1.AggregatedMetrics] are + // summed over all + // [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions] + // or + // [ShipmentRoute.visits][google.cloud.optimization.v1.ShipmentRoute.visits], + // depending on the context. + AggregatedMetrics metrics = 12; + + // Cost of the route, broken down by cost-related request fields. + // The keys are proto paths, relative to the input OptimizeToursRequest, e.g. + // "model.shipments.pickups.cost", and the values are the total cost + // generated by the corresponding cost field, aggregated over the whole route. + // In other words, costs["model.shipments.pickups.cost"] is the sum of all + // pickup costs over the route. All costs defined in the model are reported in + // detail here with the exception of costs related to TransitionAttributes + // that are only reported in an aggregated way as of 2022/01. + map route_costs = 17; + + // Total cost of the route. The sum of all costs in the cost map. + double route_total_cost = 18; + + // Deprecated: Use + // [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads] + // instead. Vehicle loads upon arrival at its end location, for each type + // specified in + // [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities], + // `start_load_intervals`, `end_load_intervals` or demands. Exception: we omit + // loads for quantity types unconstrained by intervals and that don't have any + // non-zero demand on the route. + repeated CapacityQuantity end_loads = 13 [deprecated = true]; + + // Deprecated: Use + // [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions] + // instead. Ordered list of travel steps for the route. + repeated TravelStep travel_steps = 14 [deprecated = true]; + + // Deprecated: No longer used. + // This field will only be populated at the + // [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit] + // level. + // + // This field is the extra detour time due to the shipments visited on the + // route. + // + // It is equal to `vehicle_end_time` - `vehicle_start_time` - travel duration + // from the vehicle's start_location to its `end_location`. + google.protobuf.Duration vehicle_detour = 15 [deprecated = true]; + + // Deprecated: Delay occurring before the vehicle end. See + // [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay]. + Delay delay_before_vehicle_end = 16 [deprecated = true]; +} + +// Specifies details of unperformed shipments in a solution. For trivial cases +// and/or if we are able to identify the cause for skipping, we report the +// reason here. +message SkippedShipment { + // If we can explain why the shipment was skipped, reasons will be listed + // here. If the reason is not the same for all vehicles, `reason` will have + // more than 1 element. A skipped shipment cannot have duplicate reasons, + // i.e. where all fields are the same except for `example_vehicle_index`. + // Example: + // ``` + // reasons { + // code: DEMAND_EXCEEDS_VEHICLE_CAPACITY + // example_vehicle_index: 1 + // example_exceeded_capacity_type: "Apples" + // } + // reasons { + // code: DEMAND_EXCEEDS_VEHICLE_CAPACITY + // example_vehicle_index: 3 + // example_exceeded_capacity_type: "Pears" + // } + // reasons { + // code: CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT + // example_vehicle_index: 1 + // } + // ``` + // The skipped shipment is incompatible with all vehicles. The reasons may + // be different for all vehicles but at least one vehicle's "Apples" + // capacity would be exceeded (including vehicle 1), at least one vehicle's + // "Pears" capacity would be exceeded (including vehicle 3) and at least one + // vehicle's distance limit would be exceeded (including vehicle 1). + message Reason { + // Code identifying the reason type. The order here is meaningless. In + // particular, it gives no indication of whether a given reason will + // appear before another in the solution, if both apply. + enum Code { + // This should never be used. If we are unable to understand why a + // shipment was skipped, we simply return an empty set of reasons. + CODE_UNSPECIFIED = 0; + + // There is no vehicle in the model making all shipments infeasible. + NO_VEHICLE = 1; + + // The demand of the shipment exceeds a vehicle's capacity for some + // capacity types, one of which is `example_exceeded_capacity_type`. + DEMAND_EXCEEDS_VEHICLE_CAPACITY = 2; + + // The minimum distance necessary to perform this shipment, i.e. from + // the vehicle's `start_location` to the shipment's pickup and/or delivery + // locations and to the vehicle's end location exceeds the vehicle's + // `route_distance_limit`. + // + // Note that for this computation we use the geodesic distances. + CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT = 3; + + // The minimum time necessary to perform this shipment, including travel + // time, wait time and service time exceeds the vehicle's + // `route_duration_limit`. + // + // Note: travel time is computed in the best-case scenario, namely as + // geodesic distance x 36 m/s (roughly 130 km/hour). + CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT = 4; + + // Same as above but we only compare minimum travel time and the + // vehicle's `travel_duration_limit`. + CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT = 5; + + // The vehicle cannot perform this shipment in the best-case scenario + // (see `CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT` for time + // computation) if it starts at its earliest start time: the total time + // would make the vehicle end after its latest end time. + CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS = 6; + + // The `allowed_vehicle_indices` field of the shipment is not empty and + // this vehicle does not belong to it. + VEHICLE_NOT_ALLOWED = 7; + } + + // Refer to the comments of Code. + Code code = 1; + + // If the reason is related to a shipment-vehicle incompatibility, this + // field provides the index of one relevant vehicle. + optional int32 example_vehicle_index = 2; + + // If the reason code is `DEMAND_EXCEEDS_VEHICLE_CAPACITY`, documents one + // capacity type that is exceeded. + string example_exceeded_capacity_type = 3; + } + + // The index corresponds to the index of the shipment in the source + // `ShipmentModel`. + int32 index = 1; + + // Copy of the corresponding + // [Shipment.label][google.cloud.optimization.v1.Shipment.label], if specified + // in the `Shipment`. + string label = 2; + + // A list of reasons that explain why the shipment was skipped. See comment + // above `Reason`. + repeated Reason reasons = 3; +} + +// Aggregated metrics for +// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute] (resp. for +// [OptimizeToursResponse][google.cloud.optimization.v1.OptimizeToursResponse] +// over all [Transition][google.cloud.optimization.v1.ShipmentRoute.Transition] +// and/or [Visit][google.cloud.optimization.v1.ShipmentRoute.Visit] (resp. over +// all [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute]) elements. +message AggregatedMetrics { + // Number of shipments performed. Note that a pickup and delivery pair only + // counts once. + int32 performed_shipment_count = 1; + + // Total travel duration for a route or a solution. + google.protobuf.Duration travel_duration = 2; + + // Total wait duration for a route or a solution. + google.protobuf.Duration wait_duration = 3; + + // Total delay duration for a route or a solution. + google.protobuf.Duration delay_duration = 4; + + // Total break duration for a route or a solution. + google.protobuf.Duration break_duration = 5; + + // Total visit duration for a route or a solution. + google.protobuf.Duration visit_duration = 6; + + // The total duration should be equal to the sum of all durations above. + // For routes, it also corresponds to: + // [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time] + // `-` + // [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time] + google.protobuf.Duration total_duration = 7; + + // Total travel distance for a route or a solution. + double travel_distance_meters = 8; + + // Maximum load achieved over the entire route (resp. solution), for each of + // the quantities on this route (resp. solution), computed as the maximum over + // all + // [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads] + // (resp. + // [ShipmentRoute.metrics.max_loads][google.cloud.optimization.v1.AggregatedMetrics.max_loads]. + map max_loads = 9; + + // Deprecated: Use + // [ShipmentRoute.route_costs][google.cloud.optimization.v1.ShipmentRoute.route_costs] + // and + // [OptimizeToursResponse.Metrics.costs][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.costs] + // instead. + map costs = 10 [deprecated = true]; + + // Deprecated: Use + // [ShipmentRoute.route_total_cost][google.cloud.optimization.v1.ShipmentRoute.route_total_cost] + // and + // [OptimizeToursResponse.Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost] + // instead. + double total_cost = 11 [deprecated = true]; +} + +// Solution injected in the request including information about which visits +// must be constrained and how they must be constrained. +message InjectedSolutionConstraint { + // For a group of vehicles, specifies at what threshold(s) constraints on + // visits will be relaxed and to which level. Shipments listed in + // the `skipped_shipment` field are constrained to be skipped; i.e., they + // cannot be performed. + message ConstraintRelaxation { + // If `relaxations` is empty, the start time and sequence of all visits + // on `routes` are fully constrained and no new visits may be inserted or + // added to those routes. Also, a vehicle's start and end time in + // `routes` is fully constrained, unless the vehicle is empty (i.e., has no + // visits and has `used_if_route_is_empty` set to false in the model). + // + // `relaxations(i).level` specifies the constraint relaxation level applied + // to a visit #j that satisfies: + // + // * `route.visits(j).start_time >= relaxations(i).threshold_time` AND + // * `j + 1 >= relaxations(i).threshold_visit_count` + // + // Similarly, the vehicle start is relaxed to `relaxations(i).level` if it + // satisfies: + // + // * `vehicle_start_time >= relaxations(i).threshold_time` AND + // * `relaxations(i).threshold_visit_count == 0` + // and the vehicle end is relaxed to `relaxations(i).level` if it satisfies: + // * `vehicle_end_time >= relaxations(i).threshold_time` AND + // * `route.visits_size() + 1 >= relaxations(i).threshold_visit_count` + // + // To apply a relaxation level if a visit meets the `threshold_visit_count` + // OR the `threshold_time` add two `relaxations` with the same `level`: + // one with only `threshold_visit_count` set and the other with only + // `threshold_time` set. If a visit satisfies the conditions of multiple + // `relaxations`, the most relaxed level applies. As a result, from the + // vehicle start through the route visits in order to the vehicle end, the + // relaxation level becomes more relaxed: i.e., the relaxation level is + // non-decreasing as the route progresses. + // + // The timing and sequence of route visits that do not satisfy the + // threshold conditions of any `relaxations` are fully constrained + // and no visits may be inserted into these sequences. Also, if a + // vehicle start or end does not satisfy the conditions of any + // relaxation the time is fixed, unless the vehicle is empty. + message Relaxation { + // Expresses the different constraint relaxation levels, which are + // applied for a visit and those that follow when it satisfies the + // threshold conditions. + // + // The enumeration below is in order of increasing relaxation. + enum Level { + // Implicit default relaxation level: no constraints are relaxed, + // i.e., all visits are fully constrained. + // + // This value must not be explicitly used in `level`. + LEVEL_UNSPECIFIED = 0; + + // Visit start times and vehicle start/end times will be relaxed, but + // each visit remains bound to the same vehicle and the visit sequence + // must be observed: no visit can be inserted between them or before + // them. + RELAX_VISIT_TIMES_AFTER_THRESHOLD = 1; + + // Same as `RELAX_VISIT_TIMES_AFTER_THRESHOLD`, but the visit sequence + // is also relaxed: visits remain simply bound to their vehicle. + RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD = 2; + + // Same as `RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD`, but the + // vehicle is also relaxed: visits are completely free at or after the + // threshold time and can potentially become unperformed. + RELAX_ALL_AFTER_THRESHOLD = 3; + } + + // The constraint relaxation level that applies when the conditions + // at or after `threshold_time` AND at least `threshold_visit_count` are + // satisfied. + Level level = 1; + + // The time at or after which the relaxation `level` may be applied. + google.protobuf.Timestamp threshold_time = 2; + + // The number of visits at or after which the relaxation `level` may be + // applied. If `threshold_visit_count` is 0 (or unset), the `level` may be + // applied directly at the vehicle start. + // + // If it is `route.visits_size() + 1`, the `level` may only be applied to + // the vehicle end. If it is more than `route.visits_size() + 1`, + // `level` is not applied at all for that route. + int32 threshold_visit_count = 3; + } + + // All the visit constraint relaxations that will apply to visits on + // routes with vehicles in `vehicle_indices`. + repeated Relaxation relaxations = 1; + + // Specifies the vehicle indices to which the visit constraint + // `relaxations` apply. If empty, this is considered the default and the + // `relaxations` apply to all vehicles that are not specified in other + // `constraint_relaxations`. There can be at most one default, i.e., at + // most one constraint relaxation field is allowed empty + // `vehicle_indices`. A vehicle index can only be listed once, even within + // several `constraint_relaxations`. + // + // A vehicle index is mapped the same as + // [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index], + // if `interpret_injected_solutions_using_labels` is true (see `fields` + // comment). + repeated int32 vehicle_indices = 2; + } + + // Routes of the solution to inject. Some routes may be omitted from the + // original solution. The routes and skipped shipments must satisfy the basic + // validity assumptions listed for `injected_first_solution_routes`. + repeated ShipmentRoute routes = 1; + + // Skipped shipments of the solution to inject. Some may be omitted from the + // original solution. See the `routes` field. + repeated SkippedShipment skipped_shipments = 2; + + // For zero or more groups of vehicles, specifies when and how much to relax + // constraints. If this field is empty, all non-empty vehicle routes are + // fully constrained. + repeated ConstraintRelaxation constraint_relaxations = 3; +} + +// Describes an error encountered when validating an `OptimizeToursRequest`. +message OptimizeToursValidationError { + // Specifies a context for the validation error. A `FieldReference` always + // refers to a given field in this file and follows the same hierarchical + // structure. For example, we may specify element #2 of `start_time_windows` + // of vehicle #5 using: + // ``` + // name: "vehicles" index: 5 sub_field { name: "end_time_windows" index: 2 } + // ``` + // We however omit top-level entities such as `OptimizeToursRequest` or + // `ShipmentModel` to avoid crowding the message. + message FieldReference { + // Name of the field, e.g., "vehicles". + string name = 1; + + oneof index_or_key { + // Index of the field if repeated. + int32 index = 2; + + // Key if the field is a map. + string key = 4; + } + + // Recursively nested sub-field, if needed. + FieldReference sub_field = 3; + } + + // A validation error is defined by the pair (`code`, `display_name`) which + // are always present. + // + // Other fields (below) provide more context about the error. + // + // *MULTIPLE ERRORS*: + // When there are multiple errors, the validation process tries to output + // several of them. Much like a compiler, this is an imperfect process. Some + // validation errors will be "fatal", meaning that they stop the entire + // validation process. This is the case for `display_name="UNSPECIFIED"` + // errors, among others. Some may cause the validation process to skip other + // errors. + // + // *STABILITY*: + // `code` and `display_name` should be very stable. But new codes and + // display names may appear over time, which may cause a given (invalid) + // request to yield a different (`code`, `display_name`) pair because the new + // error hid the old one (see "MULTIPLE ERRORS"). + // + // *REFERENCE*: A list of all (code, name) pairs: + // + // * UNSPECIFIED = 0; + // * VALIDATION_TIMEOUT_ERROR = 10; Validation couldn't be completed within + // the deadline. + // + // * REQUEST_OPTIONS_ERROR = 12; + // * REQUEST_OPTIONS_INVALID_SOLVING_MODE = 1201; + // * REQUEST_OPTIONS_INVALID_MAX_VALIDATION_ERRORS = 1203; + // * REQUEST_OPTIONS_INVALID_GEODESIC_METERS_PER_SECOND = 1204; + // * REQUEST_OPTIONS_GEODESIC_METERS_PER_SECOND_TOO_SMALL = 1205; + // * REQUEST_OPTIONS_MISSING_GEODESIC_METERS_PER_SECOND = 1206; + // * REQUEST_OPTIONS_POPULATE_PATHFINDER_TRIPS_AND_GEODESIC_DISTANCE + // = 1207; + // * REQUEST_OPTIONS_COST_MODEL_OPTIONS_AND_GEODESIC_DISTANCE = 1208; + // * REQUEST_OPTIONS_TRAVEL_MODE_INCOMPATIBLE_WITH_TRAFFIC = 1211; + // * REQUEST_OPTIONS_MULTIPLE_TRAFFIC_FLAVORS = 1212; + // * REQUEST_OPTIONS_INVALID_TRAFFIC_FLAVOR = 1213; + // * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITHOUT_GLOBAL_START_TIME = 1214; + // * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITH_PRECEDENCES = 1215; + // * REQUEST_OPTIONS_TRAFFIC_PREFILL_MODE_INVALID = 1216; + // * REQUEST_OPTIONS_TRAFFIC_PREFILL_ENABLED_WITHOUT_TRAFFIC = 1217; + // * INJECTED_SOLUTION_ERROR = 20; + // * INJECTED_SOLUTION_MISSING_LABEL = 2000; + // * INJECTED_SOLUTION_DUPLICATE_LABEL = 2001; + // * INJECTED_SOLUTION_AMBIGUOUS_INDEX = 2002; + // * INJECTED_SOLUTION_INFEASIBLE_AFTER_GETTING_TRAVEL_TIMES = 2003; + // * INJECTED_SOLUTION_TRANSITION_INCONSISTENT_WITH_ACTUAL_TRAVEL = 2004; + // * INJECTED_SOLUTION_CONCURRENT_SOLUTION_TYPES = 2005; + // * INJECTED_SOLUTION_MORE_THAN_ONE_PER_TYPE = 2006; + // * INJECTED_SOLUTION_REFRESH_WITHOUT_POPULATE = 2008; + // * SHIPMENT_MODEL_ERROR = 22; + // * SHIPMENT_MODEL_TOO_LARGE = 2200; + // * SHIPMENT_MODEL_TOO_MANY_CAPACITY_TYPES = 2201; + // * SHIPMENT_MODEL_GLOBAL_START_TIME_NEGATIVE_OR_NAN = 2202; + // * SHIPMENT_MODEL_GLOBAL_END_TIME_TOO_LARGE_OR_NAN = 2203; + // * SHIPMENT_MODEL_GLOBAL_START_TIME_AFTER_GLOBAL_END_TIME = 2204; + // * SHIPMENT_MODEL_GLOBAL_DURATION_TOO_LONG = 2205; + // * SHIPMENT_MODEL_MAX_ACTIVE_VEHICLES_NOT_POSITIVE = 2206; + // * SHIPMENT_MODEL_DURATION_MATRIX_TOO_LARGE = 2207; + // * INDEX_ERROR = 24; + // * TAG_ERROR = 26; + // * TIME_WINDOW_ERROR = 28; + // * TIME_WINDOW_INVALID_START_TIME = 2800; + // * TIME_WINDOW_INVALID_END_TIME = 2801; + // * TIME_WINDOW_INVALID_SOFT_START_TIME = 2802; + // * TIME_WINDOW_INVALID_SOFT_END_TIME = 2803; + // * TIME_WINDOW_OUTSIDE_GLOBAL_TIME_WINDOW = 2804; + // * TIME_WINDOW_START_TIME_AFTER_END_TIME = 2805; + // * TIME_WINDOW_INVALID_COST_PER_HOUR_BEFORE_SOFT_START_TIME = 2806; + // * TIME_WINDOW_INVALID_COST_PER_HOUR_AFTER_SOFT_END_TIME = 2807; + // * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_WITHOUT_SOFT_START_TIME + // = 2808; + // * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_WITHOUT_SOFT_END_TIME = 2809; + // * TIME_WINDOW_SOFT_START_TIME_WITHOUT_COST_BEFORE_SOFT_START_TIME + // = 2810; + // * TIME_WINDOW_SOFT_END_TIME_WITHOUT_COST_AFTER_SOFT_END_TIME = 2811; + // * TIME_WINDOW_OVERLAPPING_ADJACENT_OR_EARLIER_THAN_PREVIOUS = 2812; + // * TIME_WINDOW_START_TIME_AFTER_SOFT_START_TIME = 2813; + // * TIME_WINDOW_SOFT_START_TIME_AFTER_END_TIME = 2814; + // * TIME_WINDOW_START_TIME_AFTER_SOFT_END_TIME = 2815; + // * TIME_WINDOW_SOFT_END_TIME_AFTER_END_TIME = 2816; + // * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_SET_AND_MULTIPLE_WINDOWS + // = 2817; + // * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_SET_AND_MULTIPLE_WINDOWS = 2818; + // * TRANSITION_ATTRIBUTES_ERROR = 30; + // * TRANSITION_ATTRIBUTES_INVALID_COST = 3000; + // * TRANSITION_ATTRIBUTES_INVALID_COST_PER_KILOMETER = 3001; + // * TRANSITION_ATTRIBUTES_DUPLICATE_TAG_PAIR = 3002; + // * TRANSITION_ATTRIBUTES_DISTANCE_LIMIT_MAX_METERS_UNSUPPORTED = 3003; + // * TRANSITION_ATTRIBUTES_UNSPECIFIED_SOURCE_TAGS = 3004; + // * TRANSITION_ATTRIBUTES_CONFLICTING_SOURCE_TAGS_FIELDS = 3005; + // * TRANSITION_ATTRIBUTES_UNSPECIFIED_DESTINATION_TAGS = 3006; + // * TRANSITION_ATTRIBUTES_CONFLICTING_DESTINATION_TAGS_FIELDS = 3007; + // * TRANSITION_ATTRIBUTES_DELAY_DURATION_NEGATIVE_OR_NAN = 3008; + // * TRANSITION_ATTRIBUTES_DELAY_DURATION_EXCEEDS_GLOBAL_DURATION = 3009; + // * AMOUNT_ERROR = 31; + // * AMOUNT_NEGATIVE_VALUE = 3100; + // * LOAD_LIMIT_ERROR = 33; + // * LOAD_LIMIT_INVALID_COST_ABOVE_SOFT_MAX = 3303; + // * LOAD_LIMIT_SOFT_MAX_WITHOUT_COST_ABOVE_SOFT_MAX = 3304; + // * LOAD_LIMIT_COST_ABOVE_SOFT_MAX_WITHOUT_SOFT_MAX = 3305; + // * LOAD_LIMIT_NEGATIVE_SOFT_MAX = 3306; + // * LOAD_LIMIT_MIXED_DEMAND_TYPE = 3307; + // * LOAD_LIMIT_MAX_LOAD_NEGATIVE_VALUE = 3308; + // * LOAD_LIMIT_SOFT_MAX_ABOVE_MAX = 3309; + // * INTERVAL_ERROR = 34; + // * INTERVAL_MIN_EXCEEDS_MAX = 3401; + // * INTERVAL_NEGATIVE_MIN = 3402; + // * INTERVAL_NEGATIVE_MAX = 3403; + // * INTERVAL_MIN_EXCEEDS_CAPACITY = 3404; + // * INTERVAL_MAX_EXCEEDS_CAPACITY = 3405; + // * DISTANCE_LIMIT_ERROR = 36; + // * DISTANCE_LIMIT_INVALID_COST_AFTER_SOFT_MAX = 3601; + // * DISTANCE_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3602; + // * DISTANCE_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3603; + // * DISTANCE_LIMIT_NEGATIVE_MAX = 3604; + // * DISTANCE_LIMIT_NEGATIVE_SOFT_MAX = 3605; + // * DISTANCE_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3606; + // * DURATION_LIMIT_ERROR = 38; + // * DURATION_LIMIT_MAX_DURATION_NEGATIVE_OR_NAN = 3800; + // * DURATION_LIMIT_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3801; + // * DURATION_LIMIT_INVALID_COST_PER_HOUR_AFTER_SOFT_MAX = 3802; + // * DURATION_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3803; + // * DURATION_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3804; + // * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3805; + // * DURATION_LIMIT_INVALID_COST_AFTER_QUADRATIC_SOFT_MAX = 3806; + // * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_COST_PER_SQUARE_HOUR + // = 3807; + // * DURATION_LIMIT_COST_PER_SQUARE_HOUR_WITHOUT_QUADRATIC_SOFT_MAX + // = 3808; + // * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_MAX = 3809; + // * DURATION_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3810; + // * DURATION_LIMIT_QUADRATIC_SOFT_MAX_LARGER_THAN_MAX = 3811; + // * DURATION_LIMIT_DIFF_BETWEEN_MAX_AND_QUADRATIC_SOFT_MAX_TOO_LARGE + // = 3812; + // * DURATION_LIMIT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3813; + // * DURATION_LIMIT_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3814; + // * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION + // = 3815; + // * SHIPMENT_ERROR = 40; + // * SHIPMENT_PD_LIMIT_WITHOUT_PICKUP_AND_DELIVERY = 4014; + // * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_NEGATIVE_OR_NAN = 4000; + // * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION + // = 4001; + // * SHIPMENT_PD_RELATIVE_DETOUR_LIMIT_INVALID = 4015; + // * SHIPMENT_PD_DETOUR_LIMIT_AND_EXTRA_VISIT_DURATION = 4016; + // * SHIPMENT_PD_TIME_LIMIT_DURATION_NEGATIVE_OR_NAN = 4002; + // * SHIPMENT_PD_TIME_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4003; + // * SHIPMENT_EMPTY_SHIPMENT_TYPE = 4004; + // * SHIPMENT_NO_PICKUP_NO_DELIVERY = 4005; + // * SHIPMENT_INVALID_PENALTY_COST = 4006; + // * SHIPMENT_ALLOWED_VEHICLE_INDEX_OUT_OF_BOUNDS = 4007; + // * SHIPMENT_DUPLICATE_ALLOWED_VEHICLE_INDEX = 4008; + // * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITHOUT_INDEX = 4009; + // * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITH_INDEX = 4010; + // * SHIPMENT_INVALID_COST_FOR_VEHICLE = 4011; + // * SHIPMENT_COST_FOR_VEHICLE_INDEX_OUT_OF_BOUNDS = 4012; + // * SHIPMENT_DUPLICATE_COST_FOR_VEHICLE_INDEX = 4013; + // * VEHICLE_ERROR = 42; + // * VEHICLE_EMPTY_REQUIRED_OPERATOR_TYPE = 4200; + // * VEHICLE_DUPLICATE_REQUIRED_OPERATOR_TYPE = 4201; + // * VEHICLE_NO_OPERATOR_WITH_REQUIRED_OPERATOR_TYPE = 4202; + // * VEHICLE_EMPTY_START_TAG = 4203; + // * VEHICLE_DUPLICATE_START_TAG = 4204; + // * VEHICLE_EMPTY_END_TAG = 4205; + // * VEHICLE_DUPLICATE_END_TAG = 4206; + // * VEHICLE_EXTRA_VISIT_DURATION_NEGATIVE_OR_NAN = 4207; + // * VEHICLE_EXTRA_VISIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4208; + // * VEHICLE_EXTRA_VISIT_DURATION_EMPTY_KEY = 4209; + // * VEHICLE_FIRST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4210; + // * VEHICLE_FIRST_SHIPMENT_IGNORED = 4211; + // * VEHICLE_FIRST_SHIPMENT_NOT_BOUND = 4212; + // * VEHICLE_LAST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4213; + // * VEHICLE_LAST_SHIPMENT_IGNORED = 4214; + // * VEHICLE_LAST_SHIPMENT_NOT_BOUND = 4215; + // * VEHICLE_IGNORED_WITH_USED_IF_ROUTE_IS_EMPTY = 4216; + // * VEHICLE_INVALID_COST_PER_KILOMETER = 4217; + // * VEHICLE_INVALID_COST_PER_HOUR = 4218; + // * VEHICLE_INVALID_COST_PER_TRAVELED_HOUR = 4219; + // * VEHICLE_INVALID_FIXED_COST = 4220; + // * VEHICLE_INVALID_TRAVEL_DURATION_MULTIPLE = 4221; + // * VEHICLE_TRAVEL_DURATION_MULTIPLE_WITH_SHIPMENT_PD_DETOUR_LIMITS + // = 4223; + // * VEHICLE_MATRIX_INDEX_WITH_SHIPMENT_PD_DETOUR_LIMITS = 4224; + // * VEHICLE_MINIMUM_DURATION_LONGER_THAN_DURATION_LIMIT = 4222; + // * VISIT_REQUEST_ERROR = 44; + // * VISIT_REQUEST_EMPTY_TAG = 4400; + // * VISIT_REQUEST_DUPLICATE_TAG = 4401; + // * VISIT_REQUEST_DURATION_NEGATIVE_OR_NAN = 4404; + // * VISIT_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4405; + // * PRECEDENCE_ERROR = 46; + // * BREAK_ERROR = 48; + // * BREAK_RULE_EMPTY = 4800; + // * BREAK_REQUEST_UNSPECIFIED_DURATION = 4801; + // * BREAK_REQUEST_UNSPECIFIED_EARLIEST_START_TIME = 4802; + // * BREAK_REQUEST_UNSPECIFIED_LATEST_START_TIME = 4803; + // * BREAK_REQUEST_DURATION_NEGATIVE_OR_NAN = 4804; = 4804; + // * BREAK_REQUEST_LATEST_START_TIME_BEFORE_EARLIEST_START_TIME = 4805; + // * BREAK_REQUEST_EARLIEST_START_TIME_BEFORE_GLOBAL_START_TIME = 4806; + // * BREAK_REQUEST_LATEST_END_TIME_AFTER_GLOBAL_END_TIME = 4807; + // * BREAK_REQUEST_NON_SCHEDULABLE = 4808; + // * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_NEGATIVE_OR_NAN = 4809; + // * BREAK_FREQUENCY_MIN_BREAK_DURATION_NEGATIVE_OR_NAN = 4810; + // * BREAK_FREQUENCY_MIN_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION = 4811; + // * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION + // = 4812; + // * BREAK_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4813; + // * BREAK_FREQUENCY_MISSING_MAX_INTER_BREAK_DURATION = 4814; + // * BREAK_FREQUENCY_MISSING_MIN_BREAK_DURATION = 4815; + // * SHIPMENT_TYPE_INCOMPATIBILITY_ERROR = 50; + // * SHIPMENT_TYPE_INCOMPATIBILITY_EMPTY_TYPE = 5001; + // * SHIPMENT_TYPE_INCOMPATIBILITY_LESS_THAN_TWO_TYPES = 5002; + // * SHIPMENT_TYPE_INCOMPATIBILITY_DUPLICATE_TYPE = 5003; + // * SHIPMENT_TYPE_INCOMPATIBILITY_INVALID_INCOMPATIBILITY_MODE = 5004; + // * SHIPMENT_TYPE_INCOMPATIBILITY_TOO_MANY_INCOMPATIBILITIES = 5005; + // * SHIPMENT_TYPE_REQUIREMENT_ERROR = 52; + // * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE = 52001; + // * SHIPMENT_TYPE_REQUIREMENT_NO_DEPENDENT_TYPE = 52002; + // * SHIPMENT_TYPE_REQUIREMENT_INVALID_REQUIREMENT_MODE = 52003; + // * SHIPMENT_TYPE_REQUIREMENT_TOO_MANY_REQUIREMENTS = 52004; + // * SHIPMENT_TYPE_REQUIREMENT_EMPTY_REQUIRED_TYPE = 52005; + // * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_REQUIRED_TYPE = 52006; + // * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE_FOUND = 52007; + // * SHIPMENT_TYPE_REQUIREMENT_EMPTY_DEPENDENT_TYPE = 52008; + // * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_DEPENDENT_TYPE = 52009; + // * SHIPMENT_TYPE_REQUIREMENT_SELF_DEPENDENT_TYPE = 52010; + // * SHIPMENT_TYPE_REQUIREMENT_GRAPH_HAS_CYCLES = 52011; + // * VEHICLE_OPERATOR_ERROR = 54; + // * VEHICLE_OPERATOR_EMPTY_TYPE = 5400; + // * VEHICLE_OPERATOR_MULTIPLE_START_TIME_WINDOWS = 5401; + // * VEHICLE_OPERATOR_SOFT_START_TIME_WINDOW = 5402; + // * VEHICLE_OPERATOR_MULTIPLE_END_TIME_WINDOWS = 5403; + // * VEHICLE_OPERATOR_SOFT_END_TIME_WINDOW = 5404; + // * DURATION_SECONDS_MATRIX_ERROR = 56; + // * DURATION_SECONDS_MATRIX_DURATION_NEGATIVE_OR_NAN = 5600; + // * DURATION_SECONDS_MATRIX_DURATION_EXCEEDS_GLOBAL_DURATION = 5601; + int32 code = 1; + + // The error display name. + string display_name = 2; + + // An error context may involve 0, 1 (most of the time) or more fields. For + // example, referring to vehicle #4 and shipment #2's first pickup can be + // done as follows: + // ``` + // fields { name: "vehicles" index: 4} + // fields { name: "shipments" index: 2 sub_field {name: "pickups" index: 0} } + // ``` + // Note, however, that the cardinality of `fields` should not change for a + // given error code. + repeated FieldReference fields = 3; + + // Human-readable string describing the error. There is a 1:1 mapping + // between `code` and `error_message` (when code != "UNSPECIFIED"). + // + // *STABILITY*: Not stable: the error message associated to a given `code` may + // change (hopefully to clarify it) over time. Please rely on the + // `display_name` and `code` instead. + string error_message = 4; + + // May contain the value(s) of the field(s). This is not always available. You + // should absolutely not rely on it and use it only for manual model + // debugging. + string offending_values = 5; +} diff --git a/owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/fleet_routing.batch_optimize_tours.js b/owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/fleet_routing.batch_optimize_tours.js new file mode 100644 index 00000000000..1570044fc50 --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/fleet_routing.batch_optimize_tours.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, modelConfigs) { + // [START cloudoptimization_v1_generated_FleetRouting_BatchOptimizeTours_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Target project and location to make a call. + * Format: `projects/{project-id}/locations/{location-id}`. + * If no location is specified, a region will be chosen automatically. + */ + // const parent = 'abc123' + /** + * Required. Input/Output information each purchase model, such as file paths + * and data formats. + */ + // const modelConfigs = [1,2,3,4] + + // Imports the Optimization library + const {FleetRoutingClient} = require('@google-cloud/optimization').v1; + + // Instantiates a client + const optimizationClient = new FleetRoutingClient(); + + async function callBatchOptimizeTours() { + // Construct request + const request = { + parent, + modelConfigs, + }; + + // Run request + const [operation] = await optimizationClient.batchOptimizeTours(request); + const [response] = await operation.promise(); + console.log(response); + } + + callBatchOptimizeTours(); + // [END cloudoptimization_v1_generated_FleetRouting_BatchOptimizeTours_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/fleet_routing.optimize_tours.js b/owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/fleet_routing.optimize_tours.js new file mode 100644 index 00000000000..0caaa8a2573 --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/fleet_routing.optimize_tours.js @@ -0,0 +1,254 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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 cloudoptimization_v1_generated_FleetRouting_OptimizeTours_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Target project and location to make a call. + * Format: `projects/{project-id}/locations/{location-id}`. + * If no location is specified, a region will be chosen automatically. + */ + // const parent = 'abc123' + /** + * If this timeout is set, the server returns a response before the timeout + * period has elapsed or the server deadline for synchronous requests is + * reached, whichever is sooner. + * For asynchronous requests, the server will generate a solution (if + * possible) before the timeout has elapsed. + */ + // const timeout = {} + /** + * Shipment model to solve. + */ + // const model = {} + /** + * By default, the solving mode is `DEFAULT_SOLVE` (0). + */ + // const solvingMode = {} + /** + * Truncates the number of validation errors returned. These errors are + * typically attached to an INVALID_ARGUMENT error payload as a BadRequest + * error detail (https://cloud.google.com/apis/design/errors#error_details), + * unless solving_mode=VALIDATE_ONLY: see the + * OptimizeToursResponse.validation_errors google.cloud.optimization.v1.OptimizeToursResponse.validation_errors + * field. + * This defaults to 100 and is capped at 10,000. + */ + // const maxValidationErrors = 1234 + /** + * Search mode used to solve the request. + */ + // const searchMode = {} + /** + * Guide the optimization algorithm in finding a first solution that is + * similar to a previous solution. + * The model is constrained when the first solution is built. + * Any shipments not performed on a route are implicitly skipped in the first + * solution, but they may be performed in successive solutions. + * The solution must satisfy some basic validity assumptions: + * * for all routes, `vehicle_index` must be in range and not be duplicated. + * * for all visits, `shipment_index` and `visit_request_index` must be + * in range. + * * a shipment may only be referenced on one route. + * * the pickup of a pickup-delivery shipment must be performed before + * the delivery. + * * no more than one pickup alternative or delivery alternative of + * a shipment may be performed. + * * for all routes, times are increasing (i.e., `vehicle_start_time + * <= visits0.start_time <= visits1.start_time ... + * <= vehicle_end_time`). + * * a shipment may only be performed on a vehicle that is allowed. A + * vehicle is allowed if + * Shipment.allowed_vehicle_indices google.cloud.optimization.v1.Shipment.allowed_vehicle_indices + * is empty or its `vehicle_index` is included in + * Shipment.allowed_vehicle_indices google.cloud.optimization.v1.Shipment.allowed_vehicle_indices. + * If the injected solution is not feasible, a validation error is not + * necessarily returned and an error indicating infeasibility may be returned + * instead. + */ + // const injectedFirstSolutionRoutes = [1,2,3,4] + /** + * Constrain the optimization algorithm to find a final solution that is + * similar to a previous solution. For example, this may be used to freeze + * portions of routes which have already been completed or which are to be + * completed but must not be modified. + * If the injected solution is not feasible, a validation error is not + * necessarily returned and an error indicating infeasibility may be returned + * instead. + */ + // const injectedSolutionConstraint = {} + /** + * If non-empty, the given routes will be refreshed, without modifying their + * underlying sequence of visits or travel times: only other details will be + * updated. This does not solve the model. + * As of 2020/11, this only populates the polylines of non-empty routes and + * requires that `populate_polylines` is true. + * The `route_polyline` fields of the passed-in routes may be inconsistent + * with route `transitions`. + * This field must not be used together with `injected_first_solution_routes` + * or `injected_solution_constraint`. + * `Shipment.ignore` and `Vehicle.ignore` have no effect on the behavior. + * Polylines are still populated between all visits in all non-empty routes + * regardless of whether the related shipments or vehicles are ignored. + */ + // const refreshDetailsRoutes = [1,2,3,4] + /** + * If true: + * * uses + * ShipmentRoute.vehicle_label google.cloud.optimization.v1.ShipmentRoute.vehicle_label + * instead of `vehicle_index` to + * match routes in an injected solution with vehicles in the request; + * reuses the mapping of original + * ShipmentRoute.vehicle_index google.cloud.optimization.v1.ShipmentRoute.vehicle_index + * to new + * ShipmentRoute.vehicle_index google.cloud.optimization.v1.ShipmentRoute.vehicle_index + * to update + * ConstraintRelaxation.vehicle_indices google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices + * if non-empty, but the mapping must be unambiguous (i.e., multiple + * `ShipmentRoute`s must not share the same original `vehicle_index`). + * * uses + * ShipmentRoute.Visit.shipment_label google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label + * instead of `shipment_index` + * to match visits in an injected solution with shipments in the request; + * * uses + * SkippedShipment.label google.cloud.optimization.v1.SkippedShipment.label + * instead of + * SkippedShipment.index google.cloud.optimization.v1.SkippedShipment.index + * to + * match skipped shipments in the injected solution with request + * shipments. + * This interpretation applies to the `injected_first_solution_routes`, + * `injected_solution_constraint`, and `refresh_details_routes` fields. + * It can be used when shipment or vehicle indices in the request have + * changed since the solution was created, perhaps because shipments or + * vehicles have been removed from or added to the request. + * If true, labels in the following categories must appear at most once in + * their category: + * * Vehicle.label google.cloud.optimization.v1.Vehicle.label in the + * request; + * * Shipment.label google.cloud.optimization.v1.Shipment.label in the + * request; + * * ShipmentRoute.vehicle_label google.cloud.optimization.v1.ShipmentRoute.vehicle_label in the injected solution; + * * SkippedShipment.label google.cloud.optimization.v1.SkippedShipment.label and ShipmentRoute.Visit.shipment_label google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label in + * the injected solution (except pickup/delivery visit pairs, whose + * `shipment_label` must appear twice). + * If a `vehicle_label` in the injected solution does not correspond to a + * request vehicle, the corresponding route is removed from the solution + * along with its visits. If a `shipment_label` in the injected solution does + * not correspond to a request shipment, the corresponding visit is removed + * from the solution. If a + * SkippedShipment.label google.cloud.optimization.v1.SkippedShipment.label + * in the injected solution does not correspond to a request shipment, the + * `SkippedShipment` is removed from the solution. + * Removing route visits or entire routes from an injected solution may + * have an effect on the implied constraints, which may lead to change in + * solution, validation errors, or infeasibility. + * NOTE: The caller must ensure that each + * Vehicle.label google.cloud.optimization.v1.Vehicle.label (resp. + * Shipment.label google.cloud.optimization.v1.Shipment.label) uniquely + * identifies a vehicle (resp. shipment) entity used across the two relevant + * requests: the past request that produced the `OptimizeToursResponse` used + * in the injected solution and the current request that includes the injected + * solution. The uniqueness checks described above are not enough to guarantee + * this requirement. + */ + // const interpretInjectedSolutionsUsingLabels = true + /** + * Consider traffic estimation in calculating `ShipmentRoute` fields + * Transition.travel_duration google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration, + * Visit.start_time google.cloud.optimization.v1.ShipmentRoute.Visit.start_time, + * and `vehicle_end_time`; in setting the + * ShipmentRoute.has_traffic_infeasibilities google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities + * field, and in calculating the + * OptimizeToursResponse.total_cost google.cloud.optimization.v1.OptimizeToursResponse.total_cost + * field. + */ + // const considerRoadTraffic = true + /** + * If true, polylines will be populated in response `ShipmentRoute`s. + */ + // const populatePolylines = true + /** + * If true, polylines will be populated in response + * ShipmentRoute.transitions google.cloud.optimization.v1.ShipmentRoute.transitions. + * Note that in this case, the polylines will also be populated in the + * deprecated `travel_steps`. + */ + // const populateTransitionPolylines = true + /** + * If this is set, then the request can have a deadline + * (see https://grpc.io/blog/deadlines) of up to 60 minutes. + * Otherwise, the maximum deadline is only 30 minutes. + * Note that long-lived requests have a significantly larger (but still small) + * risk of interruption. + */ + // const allowLargeDeadlineDespiteInterruptionRisk = true + /** + * If true, travel distances will be computed using geodesic distances instead + * of Google Maps distances, and travel times will be computed using geodesic + * distances with a speed defined by `geodesic_meters_per_second`. + */ + // const useGeodesicDistances = true + /** + * When `use_geodesic_distances` is true, this field must be set and defines + * the speed applied to compute travel times. Its value must be at least 1.0 + * meters/seconds. + */ + // const geodesicMetersPerSecond = 1234 + /** + * Label that may be used to identify this request, reported back in the + * OptimizeToursResponse.request_label google.cloud.optimization.v1.OptimizeToursResponse.request_label. + */ + // const label = 'abc123' + + // Imports the Optimization library + const {FleetRoutingClient} = require('@google-cloud/optimization').v1; + + // Instantiates a client + const optimizationClient = new FleetRoutingClient(); + + async function callOptimizeTours() { + // Construct request + const request = { + parent, + }; + + // Run request + const response = await optimizationClient.optimizeTours(request); + console.log(response); + } + + callOptimizeTours(); + // [END cloudoptimization_v1_generated_FleetRouting_OptimizeTours_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/snippet_metadata_google.cloud.optimization.v1.json b/owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/snippet_metadata_google.cloud.optimization.v1.json new file mode 100644 index 00000000000..e31dd183275 --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/snippet_metadata_google.cloud.optimization.v1.json @@ -0,0 +1,167 @@ +{ + "clientLibrary": { + "name": "nodejs-optimization", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.optimization.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "cloudoptimization_v1_generated_FleetRouting_OptimizeTours_async", + "title": "FleetRouting optimizeTours Sample", + "origin": "API_DEFINITION", + "description": " Sends an `OptimizeToursRequest` containing a `ShipmentModel` and returns an `OptimizeToursResponse` containing `ShipmentRoute`s, which are a set of routes to be performed by vehicles minimizing the overall cost. A `ShipmentModel` model consists mainly of `Shipment`s that need to be carried out and `Vehicle`s that can be used to transport the `Shipment`s. The `ShipmentRoute`s assign `Shipment`s to `Vehicle`s. More specifically, they assign a series of `Visit`s to each vehicle, where a `Visit` corresponds to a `VisitRequest`, which is a pickup or delivery for a `Shipment`. The goal is to provide an assignment of `ShipmentRoute`s to `Vehicle`s that minimizes the total cost where cost has many components defined in the `ShipmentModel`.", + "canonical": true, + "file": "fleet_routing.optimize_tours.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 246, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "OptimizeTours", + "fullName": "google.cloud.optimization.v1.FleetRouting.OptimizeTours", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "timeout", + "type": ".google.protobuf.Duration" + }, + { + "name": "model", + "type": ".google.cloud.optimization.v1.ShipmentModel" + }, + { + "name": "solving_mode", + "type": ".google.cloud.optimization.v1.OptimizeToursRequest.SolvingMode" + }, + { + "name": "max_validation_errors", + "type": "TYPE_INT32" + }, + { + "name": "search_mode", + "type": ".google.cloud.optimization.v1.OptimizeToursRequest.SearchMode" + }, + { + "name": "injected_first_solution_routes", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "injected_solution_constraint", + "type": ".google.cloud.optimization.v1.InjectedSolutionConstraint" + }, + { + "name": "refresh_details_routes", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "interpret_injected_solutions_using_labels", + "type": "TYPE_BOOL" + }, + { + "name": "consider_road_traffic", + "type": "TYPE_BOOL" + }, + { + "name": "populate_polylines", + "type": "TYPE_BOOL" + }, + { + "name": "populate_transition_polylines", + "type": "TYPE_BOOL" + }, + { + "name": "allow_large_deadline_despite_interruption_risk", + "type": "TYPE_BOOL" + }, + { + "name": "use_geodesic_distances", + "type": "TYPE_BOOL" + }, + { + "name": "geodesic_meters_per_second", + "type": "TYPE_DOUBLE" + }, + { + "name": "label", + "type": "TYPE_STRING" + }, + { + "name": "populate_travel_step_polylines", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.optimization.v1.OptimizeToursResponse", + "client": { + "shortName": "FleetRoutingClient", + "fullName": "google.cloud.optimization.v1.FleetRoutingClient" + }, + "method": { + "shortName": "OptimizeTours", + "fullName": "google.cloud.optimization.v1.FleetRouting.OptimizeTours", + "service": { + "shortName": "FleetRouting", + "fullName": "google.cloud.optimization.v1.FleetRouting" + } + } + } + }, + { + "regionTag": "cloudoptimization_v1_generated_FleetRouting_BatchOptimizeTours_async", + "title": "FleetRouting batchOptimizeTours Sample", + "origin": "API_DEFINITION", + "description": " Optimizes vehicle tours for one or more `OptimizeToursRequest` messages as a batch. This method is a Long Running Operation (LRO). The inputs for optimization (`OptimizeToursRequest` messages) and outputs (`OptimizeToursResponse` messages) are read/written from/to Cloud Storage in user-specified format. Like the `OptimizeTours` method, each `OptimizeToursRequest` contains a `ShipmentModel` and returns an `OptimizeToursResponse` containing `ShipmentRoute`s, which are a set of routes to be performed by vehicles minimizing the overall cost.", + "canonical": true, + "file": "fleet_routing.batch_optimize_tours.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchOptimizeTours", + "fullName": "google.cloud.optimization.v1.FleetRouting.BatchOptimizeTours", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "model_configs", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "FleetRoutingClient", + "fullName": "google.cloud.optimization.v1.FleetRoutingClient" + }, + "method": { + "shortName": "BatchOptimizeTours", + "fullName": "google.cloud.optimization.v1.FleetRouting.BatchOptimizeTours", + "service": { + "shortName": "FleetRouting", + "fullName": "google.cloud.optimization.v1.FleetRouting" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-optimization/v1/src/index.ts b/owl-bot-staging/google-cloud-optimization/v1/src/index.ts new file mode 100644 index 00000000000..377737cae6b --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const FleetRoutingClient = v1.FleetRoutingClient; +type FleetRoutingClient = v1.FleetRoutingClient; +export {v1, FleetRoutingClient}; +export default {v1, FleetRoutingClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_client.ts b/owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_client.ts new file mode 100644 index 00000000000..5a41957cc75 --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_client.ts @@ -0,0 +1,901 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/fleet_routing_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './fleet_routing_client_config.json'; +const version = require('../../../package.json').version; + +/** + * A service for optimizing vehicle tours. + * + * Validity of certain types of fields: + * + * * `google.protobuf.Timestamp` + * * Times are in Unix time: seconds since 1970-01-01T00:00:00+00:00. + * * seconds must be in [0, 253402300799], + * i.e. in [1970-01-01T00:00:00+00:00, 9999-12-31T23:59:59+00:00]. + * * nanos must be unset or set to 0. + * * `google.protobuf.Duration` + * * seconds must be in [0, 253402300799], + * i.e. in [1970-01-01T00:00:00+00:00, 9999-12-31T23:59:59+00:00]. + * * nanos must be unset or set to 0. + * * `google.type.LatLng` + * * latitude must be in [-90.0, 90.0]. + * * longitude must be in [-180.0, 180.0]. + * * at least one of latitude and longitude must be non-zero. + * @class + * @memberof v1 + */ +export class FleetRoutingClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + operationsClient: gax.OperationsClient; + fleetRoutingStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of FleetRoutingClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 FleetRoutingClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof FleetRoutingClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const batchOptimizeToursResponse = protoFilesRoot.lookup( + '.google.cloud.optimization.v1.BatchOptimizeToursResponse') as gax.protobuf.Type; + const batchOptimizeToursMetadata = protoFilesRoot.lookup( + '.google.cloud.optimization.v1.AsyncModelMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + batchOptimizeTours: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + batchOptimizeToursResponse.decode.bind(batchOptimizeToursResponse), + batchOptimizeToursMetadata.decode.bind(batchOptimizeToursMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.optimization.v1.FleetRouting', 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.fleetRoutingStub) { + return this.fleetRoutingStub; + } + + // Put together the "service stub" for + // google.cloud.optimization.v1.FleetRouting. + this.fleetRoutingStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.optimization.v1.FleetRouting') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.optimization.v1.FleetRouting, + 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 fleetRoutingStubMethods = + ['optimizeTours', 'batchOptimizeTours']; + for (const methodName of fleetRoutingStubMethods) { + const callPromise = this.fleetRoutingStub.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.fleetRoutingStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudoptimization.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 'cloudoptimization.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 -- + // ------------------- +/** + * Sends an `OptimizeToursRequest` containing a `ShipmentModel` and returns an + * `OptimizeToursResponse` containing `ShipmentRoute`s, which are a set of + * routes to be performed by vehicles minimizing the overall cost. + * + * A `ShipmentModel` model consists mainly of `Shipment`s that need to be + * carried out and `Vehicle`s that can be used to transport the `Shipment`s. + * The `ShipmentRoute`s assign `Shipment`s to `Vehicle`s. More specifically, + * they assign a series of `Visit`s to each vehicle, where a `Visit` + * corresponds to a `VisitRequest`, which is a pickup or delivery for a + * `Shipment`. + * + * The goal is to provide an assignment of `ShipmentRoute`s to `Vehicle`s that + * minimizes the total cost where cost has many components defined in the + * `ShipmentModel`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Target project and location to make a call. + * + * Format: `projects/{project-id}/locations/{location-id}`. + * + * If no location is specified, a region will be chosen automatically. + * @param {google.protobuf.Duration} request.timeout + * If this timeout is set, the server returns a response before the timeout + * period has elapsed or the server deadline for synchronous requests is + * reached, whichever is sooner. + * + * For asynchronous requests, the server will generate a solution (if + * possible) before the timeout has elapsed. + * @param {google.cloud.optimization.v1.ShipmentModel} request.model + * Shipment model to solve. + * @param {google.cloud.optimization.v1.OptimizeToursRequest.SolvingMode} request.solvingMode + * By default, the solving mode is `DEFAULT_SOLVE` (0). + * @param {number} request.maxValidationErrors + * Truncates the number of validation errors returned. These errors are + * typically attached to an INVALID_ARGUMENT error payload as a BadRequest + * error detail (https://cloud.google.com/apis/design/errors#error_details), + * unless solving_mode=VALIDATE_ONLY: see the + * {@link protos.google.cloud.optimization.v1.OptimizeToursResponse.validation_errors|OptimizeToursResponse.validation_errors} + * field. + * This defaults to 100 and is capped at 10,000. + * @param {google.cloud.optimization.v1.OptimizeToursRequest.SearchMode} request.searchMode + * Search mode used to solve the request. + * @param {number[]} request.injectedFirstSolutionRoutes + * Guide the optimization algorithm in finding a first solution that is + * similar to a previous solution. + * + * The model is constrained when the first solution is built. + * Any shipments not performed on a route are implicitly skipped in the first + * solution, but they may be performed in successive solutions. + * + * The solution must satisfy some basic validity assumptions: + * + * * for all routes, `vehicle_index` must be in range and not be duplicated. + * * for all visits, `shipment_index` and `visit_request_index` must be + * in range. + * * a shipment may only be referenced on one route. + * * the pickup of a pickup-delivery shipment must be performed before + * the delivery. + * * no more than one pickup alternative or delivery alternative of + * a shipment may be performed. + * * for all routes, times are increasing (i.e., `vehicle_start_time + * <= visits[0].start_time <= visits[1].start_time ... + * <= vehicle_end_time`). + * * a shipment may only be performed on a vehicle that is allowed. A + * vehicle is allowed if + * {@link protos.google.cloud.optimization.v1.Shipment.allowed_vehicle_indices|Shipment.allowed_vehicle_indices} + * is empty or its `vehicle_index` is included in + * {@link protos.google.cloud.optimization.v1.Shipment.allowed_vehicle_indices|Shipment.allowed_vehicle_indices}. + * + * If the injected solution is not feasible, a validation error is not + * necessarily returned and an error indicating infeasibility may be returned + * instead. + * @param {google.cloud.optimization.v1.InjectedSolutionConstraint} request.injectedSolutionConstraint + * Constrain the optimization algorithm to find a final solution that is + * similar to a previous solution. For example, this may be used to freeze + * portions of routes which have already been completed or which are to be + * completed but must not be modified. + * + * If the injected solution is not feasible, a validation error is not + * necessarily returned and an error indicating infeasibility may be returned + * instead. + * @param {number[]} request.refreshDetailsRoutes + * If non-empty, the given routes will be refreshed, without modifying their + * underlying sequence of visits or travel times: only other details will be + * updated. This does not solve the model. + * + * As of 2020/11, this only populates the polylines of non-empty routes and + * requires that `populate_polylines` is true. + * + * The `route_polyline` fields of the passed-in routes may be inconsistent + * with route `transitions`. + * + * This field must not be used together with `injected_first_solution_routes` + * or `injected_solution_constraint`. + * + * `Shipment.ignore` and `Vehicle.ignore` have no effect on the behavior. + * Polylines are still populated between all visits in all non-empty routes + * regardless of whether the related shipments or vehicles are ignored. + * @param {boolean} request.interpretInjectedSolutionsUsingLabels + * If true: + * + * * uses + * {@link protos.google.cloud.optimization.v1.ShipmentRoute.vehicle_label|ShipmentRoute.vehicle_label} + * instead of `vehicle_index` to + * match routes in an injected solution with vehicles in the request; + * reuses the mapping of original + * {@link protos.google.cloud.optimization.v1.ShipmentRoute.vehicle_index|ShipmentRoute.vehicle_index} + * to new + * {@link protos.google.cloud.optimization.v1.ShipmentRoute.vehicle_index|ShipmentRoute.vehicle_index} + * to update + * {@link protos.google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices|ConstraintRelaxation.vehicle_indices} + * if non-empty, but the mapping must be unambiguous (i.e., multiple + * `ShipmentRoute`s must not share the same original `vehicle_index`). + * * uses + * {@link protos.google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label|ShipmentRoute.Visit.shipment_label} + * instead of `shipment_index` + * to match visits in an injected solution with shipments in the request; + * * uses + * {@link protos.google.cloud.optimization.v1.SkippedShipment.label|SkippedShipment.label} + * instead of + * {@link protos.google.cloud.optimization.v1.SkippedShipment.index|SkippedShipment.index} + * to + * match skipped shipments in the injected solution with request + * shipments. + * + * This interpretation applies to the `injected_first_solution_routes`, + * `injected_solution_constraint`, and `refresh_details_routes` fields. + * It can be used when shipment or vehicle indices in the request have + * changed since the solution was created, perhaps because shipments or + * vehicles have been removed from or added to the request. + * + * If true, labels in the following categories must appear at most once in + * their category: + * + * * {@link protos.google.cloud.optimization.v1.Vehicle.label|Vehicle.label} in the + * request; + * * {@link protos.google.cloud.optimization.v1.Shipment.label|Shipment.label} in the + * request; + * * {@link protos.google.cloud.optimization.v1.ShipmentRoute.vehicle_label|ShipmentRoute.vehicle_label} in the injected solution; + * * {@link protos.google.cloud.optimization.v1.SkippedShipment.label|SkippedShipment.label} and {@link protos.google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label|ShipmentRoute.Visit.shipment_label} in + * the injected solution (except pickup/delivery visit pairs, whose + * `shipment_label` must appear twice). + * + * If a `vehicle_label` in the injected solution does not correspond to a + * request vehicle, the corresponding route is removed from the solution + * along with its visits. If a `shipment_label` in the injected solution does + * not correspond to a request shipment, the corresponding visit is removed + * from the solution. If a + * {@link protos.google.cloud.optimization.v1.SkippedShipment.label|SkippedShipment.label} + * in the injected solution does not correspond to a request shipment, the + * `SkippedShipment` is removed from the solution. + * + * Removing route visits or entire routes from an injected solution may + * have an effect on the implied constraints, which may lead to change in + * solution, validation errors, or infeasibility. + * + * NOTE: The caller must ensure that each + * {@link protos.google.cloud.optimization.v1.Vehicle.label|Vehicle.label} (resp. + * {@link protos.google.cloud.optimization.v1.Shipment.label|Shipment.label}) uniquely + * identifies a vehicle (resp. shipment) entity used across the two relevant + * requests: the past request that produced the `OptimizeToursResponse` used + * in the injected solution and the current request that includes the injected + * solution. The uniqueness checks described above are not enough to guarantee + * this requirement. + * @param {boolean} request.considerRoadTraffic + * Consider traffic estimation in calculating `ShipmentRoute` fields + * {@link protos.google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration|Transition.travel_duration}, + * {@link protos.google.cloud.optimization.v1.ShipmentRoute.Visit.start_time|Visit.start_time}, + * and `vehicle_end_time`; in setting the + * {@link protos.google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities|ShipmentRoute.has_traffic_infeasibilities} + * field, and in calculating the + * {@link protos.google.cloud.optimization.v1.OptimizeToursResponse.total_cost|OptimizeToursResponse.total_cost} + * field. + * @param {boolean} request.populatePolylines + * If true, polylines will be populated in response `ShipmentRoute`s. + * @param {boolean} request.populateTransitionPolylines + * If true, polylines will be populated in response + * {@link protos.google.cloud.optimization.v1.ShipmentRoute.transitions|ShipmentRoute.transitions}. + * Note that in this case, the polylines will also be populated in the + * deprecated `travel_steps`. + * @param {boolean} request.allowLargeDeadlineDespiteInterruptionRisk + * If this is set, then the request can have a deadline + * (see https://grpc.io/blog/deadlines) of up to 60 minutes. + * Otherwise, the maximum deadline is only 30 minutes. + * Note that long-lived requests have a significantly larger (but still small) + * risk of interruption. + * @param {boolean} request.useGeodesicDistances + * If true, travel distances will be computed using geodesic distances instead + * of Google Maps distances, and travel times will be computed using geodesic + * distances with a speed defined by `geodesic_meters_per_second`. + * @param {number} request.geodesicMetersPerSecond + * When `use_geodesic_distances` is true, this field must be set and defines + * the speed applied to compute travel times. Its value must be at least 1.0 + * meters/seconds. + * @param {string} request.label + * Label that may be used to identify this request, reported back in the + * {@link protos.google.cloud.optimization.v1.OptimizeToursResponse.request_label|OptimizeToursResponse.request_label}. + * @param {boolean} request.populateTravelStepPolylines + * Deprecated: Use + * {@link protos.google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines|OptimizeToursRequest.populate_transition_polylines} + * instead. If true, polylines will be populated in response + * {@link protos.google.cloud.optimization.v1.ShipmentRoute.transitions|ShipmentRoute.transitions}. + * Note that in this case, the polylines will also be populated in the + * deprecated `travel_steps`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.optimization.v1.OptimizeToursResponse|OptimizeToursResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/fleet_routing.optimize_tours.js + * region_tag:cloudoptimization_v1_generated_FleetRouting_OptimizeTours_async + */ + optimizeTours( + request?: protos.google.cloud.optimization.v1.IOptimizeToursRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.optimization.v1.IOptimizeToursResponse, + protos.google.cloud.optimization.v1.IOptimizeToursRequest|undefined, {}|undefined + ]>; + optimizeTours( + request: protos.google.cloud.optimization.v1.IOptimizeToursRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.optimization.v1.IOptimizeToursResponse, + protos.google.cloud.optimization.v1.IOptimizeToursRequest|null|undefined, + {}|null|undefined>): void; + optimizeTours( + request: protos.google.cloud.optimization.v1.IOptimizeToursRequest, + callback: Callback< + protos.google.cloud.optimization.v1.IOptimizeToursResponse, + protos.google.cloud.optimization.v1.IOptimizeToursRequest|null|undefined, + {}|null|undefined>): void; + optimizeTours( + request?: protos.google.cloud.optimization.v1.IOptimizeToursRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.optimization.v1.IOptimizeToursResponse, + protos.google.cloud.optimization.v1.IOptimizeToursRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.optimization.v1.IOptimizeToursResponse, + protos.google.cloud.optimization.v1.IOptimizeToursRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.optimization.v1.IOptimizeToursResponse, + protos.google.cloud.optimization.v1.IOptimizeToursRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.optimizeTours(request, options, callback); + } + +/** + * Optimizes vehicle tours for one or more `OptimizeToursRequest` + * messages as a batch. + * + * This method is a Long Running Operation (LRO). The inputs for optimization + * (`OptimizeToursRequest` messages) and outputs (`OptimizeToursResponse` + * messages) are read/written from/to Cloud Storage in user-specified + * format. Like the `OptimizeTours` method, each `OptimizeToursRequest` + * contains a `ShipmentModel` and returns an `OptimizeToursResponse` + * containing `ShipmentRoute`s, which are a set of routes to be performed by + * vehicles minimizing the overall cost. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Target project and location to make a call. + * + * Format: `projects/{project-id}/locations/{location-id}`. + * + * If no location is specified, a region will be chosen automatically. + * @param {number[]} request.modelConfigs + * Required. Input/Output information each purchase model, such as file paths + * and data formats. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/fleet_routing.batch_optimize_tours.js + * region_tag:cloudoptimization_v1_generated_FleetRouting_BatchOptimizeTours_async + */ + batchOptimizeTours( + request?: protos.google.cloud.optimization.v1.IBatchOptimizeToursRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + batchOptimizeTours( + request: protos.google.cloud.optimization.v1.IBatchOptimizeToursRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + batchOptimizeTours( + request: protos.google.cloud.optimization.v1.IBatchOptimizeToursRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + batchOptimizeTours( + request?: protos.google.cloud.optimization.v1.IBatchOptimizeToursRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.batchOptimizeTours(request, options, callback); + } +/** + * Check the status of the long running operation returned by `batchOptimizeTours()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/fleet_routing.batch_optimize_tours.js + * region_tag:cloudoptimization_v1_generated_FleetRouting_BatchOptimizeTours_async + */ + async checkBatchOptimizeToursProgress(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.batchOptimizeTours, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * 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); + } + + + /** + * 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.fleetRoutingStub && !this._terminated) { + return this.fleetRoutingStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_client_config.json b/owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_client_config.json new file mode 100644 index 00000000000..5ab463afe2f --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_client_config.json @@ -0,0 +1,48 @@ +{ + "interfaces": { + "google.cloud.optimization.v1.FleetRouting": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "OptimizeTours": { + "timeout_millis": 3600000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "BatchOptimizeTours": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_proto_list.json b/owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_proto_list.json new file mode 100644 index 00000000000..0c22e3cf34b --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_proto_list.json @@ -0,0 +1,4 @@ +[ + "../../protos/google/cloud/optimization/v1/async_model.proto", + "../../protos/google/cloud/optimization/v1/fleet_routing.proto" +] diff --git a/owl-bot-staging/google-cloud-optimization/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-optimization/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..85ace5d715c --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/src/v1/gapic_metadata.json @@ -0,0 +1,43 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.optimization.v1", + "libraryPackage": "@google-cloud/optimization", + "services": { + "FleetRouting": { + "clients": { + "grpc": { + "libraryClient": "FleetRoutingClient", + "rpcs": { + "OptimizeTours": { + "methods": [ + "optimizeTours" + ] + }, + "BatchOptimizeTours": { + "methods": [ + "batchOptimizeTours" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "FleetRoutingClient", + "rpcs": { + "OptimizeTours": { + "methods": [ + "optimizeTours" + ] + }, + "BatchOptimizeTours": { + "methods": [ + "batchOptimizeTours" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-optimization/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-optimization/v1/src/v1/index.ts new file mode 100644 index 00000000000..01c3381e53a --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {FleetRoutingClient} from './fleet_routing_client'; diff --git a/owl-bot-staging/google-cloud-optimization/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-optimization/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..63874cd148e --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const optimization = require('@google-cloud/optimization'); + +function main() { + const fleetRoutingClient = new optimization.FleetRoutingClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-optimization/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-optimization/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..df036f012d4 --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {FleetRoutingClient} from '@google-cloud/optimization'; + +// check that the client class type name can be used +function doStuffWithFleetRoutingClient(client: FleetRoutingClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const fleetRoutingClient = new FleetRoutingClient(); + doStuffWithFleetRoutingClient(fleetRoutingClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-optimization/v1/system-test/install.ts b/owl-bot-staging/google-cloud-optimization/v1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/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-optimization/v1/test/gapic_fleet_routing_v1.ts b/owl-bot-staging/google-cloud-optimization/v1/test/gapic_fleet_routing_v1.ts new file mode 100644 index 00000000000..cd0b1e4e588 --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/test/gapic_fleet_routing_v1.ts @@ -0,0 +1,703 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 fleetroutingModule from '../src'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.FleetRoutingClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = fleetroutingModule.v1.FleetRoutingClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = fleetroutingModule.v1.FleetRoutingClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = fleetroutingModule.v1.FleetRoutingClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new fleetroutingModule.v1.FleetRoutingClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new fleetroutingModule.v1.FleetRoutingClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new fleetroutingModule.v1.FleetRoutingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.fleetRoutingStub, undefined); + await client.initialize(); + assert(client.fleetRoutingStub); + }); + + it('has close method for the initialized client', done => { + const client = new fleetroutingModule.v1.FleetRoutingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.fleetRoutingStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new fleetroutingModule.v1.FleetRoutingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.fleetRoutingStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new fleetroutingModule.v1.FleetRoutingClient({ + 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 fleetroutingModule.v1.FleetRoutingClient({ + 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('optimizeTours', () => { + it('invokes optimizeTours without error', async () => { + const client = new fleetroutingModule.v1.FleetRoutingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.optimization.v1.OptimizeToursRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.optimization.v1.OptimizeToursRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.optimization.v1.OptimizeToursResponse() + ); + client.innerApiCalls.optimizeTours = stubSimpleCall(expectedResponse); + const [response] = await client.optimizeTours(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.optimizeTours as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.optimizeTours as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes optimizeTours without error using callback', async () => { + const client = new fleetroutingModule.v1.FleetRoutingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.optimization.v1.OptimizeToursRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.optimization.v1.OptimizeToursRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.optimization.v1.OptimizeToursResponse() + ); + client.innerApiCalls.optimizeTours = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.optimizeTours( + request, + (err?: Error|null, result?: protos.google.cloud.optimization.v1.IOptimizeToursResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.optimizeTours as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.optimizeTours as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes optimizeTours with error', async () => { + const client = new fleetroutingModule.v1.FleetRoutingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.optimization.v1.OptimizeToursRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.optimization.v1.OptimizeToursRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.optimizeTours = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.optimizeTours(request), expectedError); + const actualRequest = (client.innerApiCalls.optimizeTours as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.optimizeTours as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes optimizeTours with closed client', async () => { + const client = new fleetroutingModule.v1.FleetRoutingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.optimization.v1.OptimizeToursRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.optimization.v1.OptimizeToursRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.optimizeTours(request), expectedError); + }); + }); + + describe('batchOptimizeTours', () => { + it('invokes batchOptimizeTours without error', async () => { + const client = new fleetroutingModule.v1.FleetRoutingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.optimization.v1.BatchOptimizeToursRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.optimization.v1.BatchOptimizeToursRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.batchOptimizeTours = stubLongRunningCall(expectedResponse); + const [operation] = await client.batchOptimizeTours(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.batchOptimizeTours as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchOptimizeTours as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchOptimizeTours without error using callback', async () => { + const client = new fleetroutingModule.v1.FleetRoutingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.optimization.v1.BatchOptimizeToursRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.optimization.v1.BatchOptimizeToursRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.batchOptimizeTours = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchOptimizeTours( + request, + (err?: Error|null, + result?: 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.batchOptimizeTours as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchOptimizeTours as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchOptimizeTours with call error', async () => { + const client = new fleetroutingModule.v1.FleetRoutingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.optimization.v1.BatchOptimizeToursRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.optimization.v1.BatchOptimizeToursRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchOptimizeTours = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.batchOptimizeTours(request), expectedError); + const actualRequest = (client.innerApiCalls.batchOptimizeTours as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchOptimizeTours as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchOptimizeTours with LRO error', async () => { + const client = new fleetroutingModule.v1.FleetRoutingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.optimization.v1.BatchOptimizeToursRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.optimization.v1.BatchOptimizeToursRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchOptimizeTours = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.batchOptimizeTours(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.batchOptimizeTours as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchOptimizeTours as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkBatchOptimizeToursProgress without error', async () => { + const client = new fleetroutingModule.v1.FleetRoutingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkBatchOptimizeToursProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkBatchOptimizeToursProgress with error', async () => { + const client = new fleetroutingModule.v1.FleetRoutingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkBatchOptimizeToursProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new fleetroutingModule.v1.FleetRoutingClient({ + 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 fleetroutingModule.v1.FleetRoutingClient({ + 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 fleetroutingModule.v1.FleetRoutingClient({ + 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 fleetroutingModule.v1.FleetRoutingClient({ + 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 fleetroutingModule.v1.FleetRoutingClient({ + 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 fleetroutingModule.v1.FleetRoutingClient({ + 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 fleetroutingModule.v1.FleetRoutingClient({ + 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 fleetroutingModule.v1.FleetRoutingClient({ + 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 fleetroutingModule.v1.FleetRoutingClient({ + 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 fleetroutingModule.v1.FleetRoutingClient({ + 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 fleetroutingModule.v1.FleetRoutingClient({ + 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); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-optimization/v1/tsconfig.json b/owl-bot-staging/google-cloud-optimization/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-optimization/v1/webpack.config.js b/owl-bot-staging/google-cloud-optimization/v1/webpack.config.js new file mode 100644 index 00000000000..28740a021c3 --- /dev/null +++ b/owl-bot-staging/google-cloud-optimization/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'FleetRouting', + filename: './fleet-routing.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-orchestration-airflow-service/v1/.eslintignore b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.eslintrc.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.gitignore b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.jsdoc.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.jsdoc.js new file mode 100644 index 00000000000..1eacba42fba --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.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/orchestration-airflow', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.mocharc.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.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-orchestration-airflow-service/v1/.prettierrc.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.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-orchestration-airflow-service/v1/README.md b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/README.md new file mode 100644 index 00000000000..536af38a9bb --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/README.md @@ -0,0 +1 @@ +Service: Nodejs Client diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/package.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/package.json new file mode 100644 index 00000000000..42943d9c4a6 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/package.json @@ -0,0 +1,59 @@ +{ + "name": "@google-cloud/orchestration-airflow", + "version": "0.1.0", + "description": "Service client for Node.js", + "repository": "googleapis/nodejs-service", + "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 service", + "service", + "environments", + "image versions" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/environments.proto b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/environments.proto new file mode 100644 index 00000000000..e83af80a94a --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/environments.proto @@ -0,0 +1,1392 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.orchestration.airflow.service.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/orchestration/airflow/service/v1/operations.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "cloud.google.com/go/orchestration/airflow/service/apiv1/servicepb;servicepb"; +option java_multiple_files = true; +option java_package = "com.google.cloud.orchestration.airflow.service.v1"; + +// Managed Apache Airflow Environments. +service Environments { + option (google.api.default_host) = "composer.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Create a new environment. + rpc CreateEnvironment(CreateEnvironmentRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/environments" + body: "environment" + }; + option (google.api.method_signature) = "parent,environment"; + option (google.longrunning.operation_info) = { + response_type: "Environment" + metadata_type: "google.cloud.orchestration.airflow.service.v1.OperationMetadata" + }; + } + + // Get an existing environment. + rpc GetEnvironment(GetEnvironmentRequest) returns (Environment) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/environments/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List environments. + rpc ListEnvironments(ListEnvironmentsRequest) + returns (ListEnvironmentsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/environments" + }; + option (google.api.method_signature) = "parent"; + } + + // Update an environment. + rpc UpdateEnvironment(UpdateEnvironmentRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{name=projects/*/locations/*/environments/*}" + body: "environment" + }; + option (google.api.method_signature) = "name,environment,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "Environment" + metadata_type: "google.cloud.orchestration.airflow.service.v1.OperationMetadata" + }; + } + + // Delete an environment. + rpc DeleteEnvironment(DeleteEnvironmentRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/environments/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "google.cloud.orchestration.airflow.service.v1.OperationMetadata" + }; + } + + // Executes Airflow CLI command. + rpc ExecuteAirflowCommand(ExecuteAirflowCommandRequest) + returns (ExecuteAirflowCommandResponse) { + option (google.api.http) = { + post: "/v1/{environment=projects/*/locations/*/environments/*}:executeAirflowCommand" + body: "*" + }; + } + + // Stops Airflow CLI command execution. + rpc StopAirflowCommand(StopAirflowCommandRequest) + returns (StopAirflowCommandResponse) { + option (google.api.http) = { + post: "/v1/{environment=projects/*/locations/*/environments/*}:stopAirflowCommand" + body: "*" + }; + } + + // Polls Airflow CLI command execution and fetches logs. + rpc PollAirflowCommand(PollAirflowCommandRequest) + returns (PollAirflowCommandResponse) { + option (google.api.http) = { + post: "/v1/{environment=projects/*/locations/*/environments/*}:pollAirflowCommand" + body: "*" + }; + } + + // Creates a snapshots of a Cloud Composer environment. + // + // As a result of this operation, snapshot of environment's state is stored + // in a location specified in the SaveSnapshotRequest. + rpc SaveSnapshot(SaveSnapshotRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{environment=projects/*/locations/*/environments/*}:saveSnapshot" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.orchestration.airflow.service.v1.SaveSnapshotResponse" + metadata_type: "google.cloud.orchestration.airflow.service.v1.OperationMetadata" + }; + } + + // Loads a snapshot of a Cloud Composer environment. + // + // As a result of this operation, a snapshot of environment's specified in + // LoadSnapshotRequest is loaded into the environment. + rpc LoadSnapshot(LoadSnapshotRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{environment=projects/*/locations/*/environments/*}:loadSnapshot" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.orchestration.airflow.service.v1.LoadSnapshotResponse" + metadata_type: "google.cloud.orchestration.airflow.service.v1.OperationMetadata" + }; + } + + // Triggers database failover (only for highly resilient environments). + rpc DatabaseFailover(DatabaseFailoverRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{environment=projects/*/locations/*/environments/*}:databaseFailover" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.orchestration.airflow.service.v1.DatabaseFailoverResponse" + metadata_type: "google.cloud.orchestration.airflow.service.v1.OperationMetadata" + }; + } + + // Fetches database properties. + rpc FetchDatabaseProperties(FetchDatabasePropertiesRequest) + returns (FetchDatabasePropertiesResponse) { + option (google.api.http) = { + get: "/v1/{environment=projects/*/locations/*/environments/*}:fetchDatabaseProperties" + }; + } +} + +// Create a new environment. +message CreateEnvironmentRequest { + // The parent must be of the form + // "projects/{projectId}/locations/{locationId}". + string parent = 1; + + // The environment to create. + Environment environment = 2; +} + +// Get an environment. +message GetEnvironmentRequest { + // The resource name of the environment to get, in the form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + string name = 1; +} + +// List environments in a project and location. +message ListEnvironmentsRequest { + // List environments in the given project and location, in the form: + // "projects/{projectId}/locations/{locationId}" + string parent = 1; + + // The maximum number of environments to return. + int32 page_size = 2; + + // The next_page_token value returned from a previous List request, if any. + string page_token = 3; +} + +// The environments in a project and location. +message ListEnvironmentsResponse { + // The list of environments returned by a ListEnvironmentsRequest. + repeated Environment environments = 1; + + // The page token used to query for the next page if one exists. + string next_page_token = 2; +} + +// Delete an environment. +message DeleteEnvironmentRequest { + // The environment to delete, in the form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + string name = 1; +} + +// Update an environment. +message UpdateEnvironmentRequest { + // The relative resource name of the environment to update, in the form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + string name = 2; + + // A patch environment. Fields specified by the `updateMask` will be copied + // from the patch environment into the environment under update. + Environment environment = 1; + + // Required. A comma-separated list of paths, relative to `Environment`, of + // fields to update. + // For example, to set the version of scikit-learn to install in the + // environment to 0.19.0 and to remove an existing installation of + // numpy, the `updateMask` parameter would include the following two + // `paths` values: "config.softwareConfig.pypiPackages.scikit-learn" and + // "config.softwareConfig.pypiPackages.numpy". The included patch + // environment would specify the scikit-learn version as follows: + // + // { + // "config":{ + // "softwareConfig":{ + // "pypiPackages":{ + // "scikit-learn":"==0.19.0" + // } + // } + // } + // } + // + // Note that in the above example, any existing PyPI packages + // other than scikit-learn and numpy will be unaffected. + // + // Only one update type may be included in a single request's `updateMask`. + // For example, one cannot update both the PyPI packages and + // labels in the same request. However, it is possible to update multiple + // members of a map field simultaneously in the same request. For example, + // to set the labels "label1" and "label2" while clearing "label3" (assuming + // it already exists), one can + // provide the paths "labels.label1", "labels.label2", and "labels.label3" + // and populate the patch environment as follows: + // + // { + // "labels":{ + // "label1":"new-label1-value" + // "label2":"new-label2-value" + // } + // } + // + // Note that in the above example, any existing labels that are not + // included in the `updateMask` will be unaffected. + // + // It is also possible to replace an entire map field by providing the + // map field's path in the `updateMask`. The new value of the field will + // be that which is provided in the patch environment. For example, to + // delete all pre-existing user-specified PyPI packages and + // install botocore at version 1.7.14, the `updateMask` would contain + // the path "config.softwareConfig.pypiPackages", and + // the patch environment would be the following: + // + // { + // "config":{ + // "softwareConfig":{ + // "pypiPackages":{ + // "botocore":"==1.7.14" + // } + // } + // } + // } + // + // **Note:** Only the following fields can be updated: + // + // * `config.softwareConfig.pypiPackages` + // * Replace all custom custom PyPI packages. If a replacement + // package map is not included in `environment`, all custom + // PyPI packages are cleared. It is an error to provide both + // this mask and a mask specifying an individual package. + // * `config.softwareConfig.pypiPackages.`packagename + // * Update the custom PyPI package *packagename*, + // preserving other packages. To delete the package, include it in + // `updateMask`, and omit the mapping for it in + // `environment.config.softwareConfig.pypiPackages`. It is an error + // to provide both a mask of this form and the + // `config.softwareConfig.pypiPackages` mask. + // * `labels` + // * Replace all environment labels. If a replacement labels map is not + // included in `environment`, all labels are cleared. It is an error to + // provide both this mask and a mask specifying one or more individual + // labels. + // * `labels.`labelName + // * Set the label named *labelName*, while preserving other + // labels. To delete the label, include it in `updateMask` and omit its + // mapping in `environment.labels`. It is an error to provide both a + // mask of this form and the `labels` mask. + // * `config.nodeCount` + // * Horizontally scale the number of nodes in the environment. An integer + // greater than or equal to 3 must be provided in the `config.nodeCount` + // field. Supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + // * `config.webServerNetworkAccessControl` + // * Replace the environment's current `WebServerNetworkAccessControl`. + // * `config.softwareConfig.airflowConfigOverrides` + // * Replace all Apache Airflow config overrides. If a replacement config + // overrides map is not included in `environment`, all config overrides + // are cleared. + // It is an error to provide both this mask and a mask specifying one or + // more individual config overrides. + // * `config.softwareConfig.airflowConfigOverrides.`section-name + // * Override the Apache Airflow config property *name* in the + // section named *section*, preserving other properties. To + // delete the property override, include it in `updateMask` and omit its + // mapping in + // `environment.config.softwareConfig.airflowConfigOverrides`. + // It is an error to provide both a mask of this form and the + // `config.softwareConfig.airflowConfigOverrides` mask. + // * `config.softwareConfig.envVariables` + // * Replace all environment variables. If a replacement environment + // variable map is not included in `environment`, all custom environment + // variables are cleared. + // * `config.softwareConfig.schedulerCount` + // * Horizontally scale the number of schedulers in Airflow. A positive + // integer not greater than the number of nodes must be provided in the + // `config.softwareConfig.schedulerCount` field. Supported for Cloud + // Composer environments in versions composer-1.*.*-airflow-2.*.*. + // * `config.databaseConfig.machineType` + // * Cloud SQL machine type used by Airflow database. + // It has to be one of: db-n1-standard-2, db-n1-standard-4, + // db-n1-standard-8 or db-n1-standard-16. Supported for Cloud Composer + // environments in versions composer-1.*.*-airflow-*.*.*. + // * `config.webServerConfig.machineType` + // * Machine type on which Airflow web server is running. + // It has to be one of: composer-n1-webserver-2, composer-n1-webserver-4 + // or composer-n1-webserver-8. Supported for Cloud Composer environments + // in versions composer-1.*.*-airflow-*.*.*. + google.protobuf.FieldMask update_mask = 3; +} + +// Execute Airflow Command request. +message ExecuteAirflowCommandRequest { + // The resource name of the environment in the form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}". + string environment = 1; + + // Airflow command. + string command = 2; + + // Airflow subcommand. + string subcommand = 3; + + // Parameters for the Airflow command/subcommand as an array of arguments. + // It may contain positional arguments like `["my-dag-id"]`, key-value + // parameters like `["--foo=bar"]` or `["--foo","bar"]`, + // or other flags like `["-f"]`. + repeated string parameters = 4; +} + +// Response to ExecuteAirflowCommandRequest. +message ExecuteAirflowCommandResponse { + // The unique ID of the command execution for polling. + string execution_id = 1; + + // The name of the pod where the command is executed. + string pod = 2; + + // The namespace of the pod where the command is executed. + string pod_namespace = 3; + + // Error message. Empty if there was no error. + string error = 4; +} + +// Stop Airflow Command request. +message StopAirflowCommandRequest { + // The resource name of the environment in the form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}". + string environment = 1; + + // The unique ID of the command execution. + string execution_id = 2; + + // The name of the pod where the command is executed. + string pod = 3; + + // The namespace of the pod where the command is executed. + string pod_namespace = 4; + + // If true, the execution is terminated forcefully (SIGKILL). If false, the + // execution is stopped gracefully, giving it time for cleanup. + bool force = 5; +} + +// Response to StopAirflowCommandRequest. +message StopAirflowCommandResponse { + // Whether the execution is still running. + bool is_done = 1; + + // Output message from stopping execution request. + repeated string output = 2; +} + +// Poll Airflow Command request. +message PollAirflowCommandRequest { + // The resource name of the environment in the form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + string environment = 1; + + // The unique ID of the command execution. + string execution_id = 2; + + // The name of the pod where the command is executed. + string pod = 3; + + // The namespace of the pod where the command is executed. + string pod_namespace = 4; + + // Line number from which new logs should be fetched. + int32 next_line_number = 5; +} + +// Response to PollAirflowCommandRequest. +message PollAirflowCommandResponse { + // Contains information about a single line from logs. + message Line { + // Number of the line. + int32 line_number = 1; + + // Text content of the log line. + string content = 2; + } + + // Information about how a command ended. + message ExitInfo { + // The exit code from the command execution. + int32 exit_code = 1; + + // Error message. Empty if there was no error. + string error = 2; + } + + // Output from the command execution. It may not contain the full output + // and the caller may need to poll for more lines. + repeated Line output = 1; + + // Whether the command execution has finished and there is no more output. + bool output_end = 2; + + // The result exit status of the command. + ExitInfo exit_info = 3; +} + +// Request to create a snapshot of a Cloud Composer environment. +message SaveSnapshotRequest { + // The resource name of the source environment in the form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + string environment = 1; + + // Location in a Cloud Storage where the snapshot is going to be stored, e.g.: + // "gs://my-bucket/snapshots". + string snapshot_location = 2; +} + +// Response to SaveSnapshotRequest. +message SaveSnapshotResponse { + // The fully-resolved Cloud Storage path of the created snapshot, + // e.g.: + // "gs://my-bucket/snapshots/project_location_environment_timestamp". + // This field is populated only if the snapshot creation was successful. + string snapshot_path = 1; +} + +// Request to load a snapshot into a Cloud Composer environment. +message LoadSnapshotRequest { + // The resource name of the target environment in the form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + string environment = 1; + + // A Cloud Storage path to a snapshot to load, e.g.: + // "gs://my-bucket/snapshots/project_location_environment_timestamp". + string snapshot_path = 2; + + // Whether or not to skip installing Pypi packages when loading the + // environment's state. + bool skip_pypi_packages_installation = 3; + + // Whether or not to skip setting environment variables when loading the + // environment's state. + bool skip_environment_variables_setting = 4; + + // Whether or not to skip setting Airflow overrides when loading the + // environment's state. + bool skip_airflow_overrides_setting = 5; + + // Whether or not to skip copying Cloud Storage data when loading the + // environment's state. + bool skip_gcs_data_copying = 6; +} + +// Response to LoadSnapshotRequest. +message LoadSnapshotResponse {} + +// Request to trigger database failover (only for highly resilient +// environments). +message DatabaseFailoverRequest { + // Target environment: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + string environment = 1; +} + +// Response for DatabaseFailoverRequest. +message DatabaseFailoverResponse {} + +// Request to fetch properties of environment's database. +message FetchDatabasePropertiesRequest { + // Required. The resource name of the environment, in the form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + string environment = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "composer.googleapis.com/Environment" + } + ]; +} + +// Response for FetchDatabasePropertiesRequest. +message FetchDatabasePropertiesResponse { + // The Compute Engine zone that the instance is currently serving from. + string primary_gce_zone = 1; + + // The Compute Engine zone that the failover instance is currently serving + // from for a regional Cloud SQL instance. + string secondary_gce_zone = 2; + + // The availability status of the failover replica. A false status indicates + // that the failover replica is out of sync. The primary instance can only + // fail over to the failover replica when the status is true. + bool is_failover_replica_available = 3; +} + +// Configuration information for an environment. +message EnvironmentConfig { + // The size of the Cloud Composer environment. + enum EnvironmentSize { + // The size of the environment is unspecified. + ENVIRONMENT_SIZE_UNSPECIFIED = 0; + + // The environment size is small. + ENVIRONMENT_SIZE_SMALL = 1; + + // The environment size is medium. + ENVIRONMENT_SIZE_MEDIUM = 2; + + // The environment size is large. + ENVIRONMENT_SIZE_LARGE = 3; + } + + // Resilience mode of the Cloud Composer Environment. + enum ResilienceMode { + // Default mode doesn't change environment parameters. + RESILIENCE_MODE_UNSPECIFIED = 0; + + // Enabled High Resilience mode, including Cloud SQL HA. + HIGH_RESILIENCE = 1; + } + + // Output only. The Kubernetes Engine cluster used to run this environment. + string gke_cluster = 1; + + // Output only. The Cloud Storage prefix of the DAGs for this environment. + // Although Cloud Storage objects reside in a flat namespace, a hierarchical + // file tree can be simulated using "/"-delimited object name prefixes. DAG + // objects for this environment reside in a simulated directory with the given + // prefix. + string dag_gcs_prefix = 2; + + // The number of nodes in the Kubernetes Engine cluster that will be + // used to run this environment. + // + // This field is supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + int32 node_count = 3; + + // The configuration settings for software inside the environment. + SoftwareConfig software_config = 4; + + // The configuration used for the Kubernetes Engine cluster. + NodeConfig node_config = 5; + + // The configuration used for the Private IP Cloud Composer environment. + PrivateEnvironmentConfig private_environment_config = 7; + + // Optional. The network-level access control policy for the Airflow web + // server. If unspecified, no network-level access restrictions will be + // applied. + WebServerNetworkAccessControl web_server_network_access_control = 8 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The configuration settings for Cloud SQL instance used internally + // by Apache Airflow software. + DatabaseConfig database_config = 9 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The configuration settings for the Airflow web server App Engine + // instance. + WebServerConfig web_server_config = 10 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The encryption options for the Cloud Composer environment + // and its dependencies. Cannot be updated. + EncryptionConfig encryption_config = 11 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maintenance window is the period when Cloud Composer + // components may undergo maintenance. It is defined so that maintenance is + // not executed during peak hours or critical time periods. + // + // The system will not be under maintenance for every occurrence of this + // window, but when maintenance is planned, it will be scheduled + // during the window. + // + // The maintenance window period must encompass at least 12 hours per week. + // This may be split into multiple chunks, each with a size of + // at least 4 hours. + // + // If this value is omitted, the default value for maintenance window will be + // applied. The default value is Saturday and Sunday 00-06 GMT. + MaintenanceWindow maintenance_window = 12 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The workloads configuration settings for the GKE cluster + // associated with the Cloud Composer environment. The GKE cluster runs + // Airflow scheduler, web server and workers workloads. + // + // This field is supported for Cloud Composer environments in versions + // composer-2.*.*-airflow-*.*.* and newer. + WorkloadsConfig workloads_config = 15 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The size of the Cloud Composer environment. + // + // This field is supported for Cloud Composer environments in versions + // composer-2.*.*-airflow-*.*.* and newer. + EnvironmentSize environment_size = 16 + [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The URI of the Apache Airflow Web UI hosted within this + // environment (see [Airflow web + // interface](/composer/docs/how-to/accessing/airflow-web-interface)). + string airflow_uri = 6; + + // Output only. The 'bring your own identity' variant of the URI of the Apache + // Airflow Web UI hosted within this environment, to be accessed with external + // identities using workforce identity federation (see [Access environments + // with workforce identity + // federation](/composer/docs/composer-2/access-environments-with-workforce-identity-federation)). + string airflow_byoid_uri = 20 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. The configuration options for GKE cluster master authorized + // networks. By default master authorized networks feature is: + // - in case of private environment: enabled with no external networks + // allowlisted. + // - in case of public environment: disabled. + MasterAuthorizedNetworksConfig master_authorized_networks_config = 17 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The Recovery settings configuration of an environment. + // + // This field is supported for Cloud Composer environments in versions + // composer-2.*.*-airflow-*.*.* and newer. + RecoveryConfig recovery_config = 18 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Resilience mode of the Cloud Composer Environment. + // + // This field is supported for Cloud Composer environments in versions + // composer-2.2.0-airflow-*.*.* and newer. + ResilienceMode resilience_mode = 19 [(google.api.field_behavior) = OPTIONAL]; +} + +// Network-level access control policy for the Airflow web server. +message WebServerNetworkAccessControl { + // Allowed IP range with user-provided description. + message AllowedIpRange { + // IP address or range, defined using CIDR notation, of requests that this + // rule applies to. + // Examples: `192.168.1.1` or `192.168.0.0/16` or `2001:db8::/32` + // or `2001:0db8:0000:0042:0000:8a2e:0370:7334`. + // + // IP range prefixes should be properly truncated. For example, + // `1.2.3.4/24` should be truncated to `1.2.3.0/24`. Similarly, for IPv6, + // `2001:db8::1/32` should be truncated to `2001:db8::/32`. + string value = 1; + + // Optional. User-provided description. It must contain at most 300 + // characters. + string description = 2 [(google.api.field_behavior) = OPTIONAL]; + } + + // A collection of allowed IP ranges with descriptions. + repeated AllowedIpRange allowed_ip_ranges = 1; +} + +// The configuration of Cloud SQL instance that is used by the Apache Airflow +// software. +message DatabaseConfig { + // Optional. Cloud SQL machine type used by Airflow database. + // It has to be one of: db-n1-standard-2, db-n1-standard-4, db-n1-standard-8 + // or db-n1-standard-16. If not specified, db-n1-standard-2 will be used. + // Supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + string machine_type = 1 [(google.api.field_behavior) = OPTIONAL]; +} + +// The configuration settings for the Airflow web server App Engine instance. +// Supported for Cloud Composer environments in versions +// composer-1.*.*-airflow-*.*.* +message WebServerConfig { + // Optional. Machine type on which Airflow web server is running. + // It has to be one of: composer-n1-webserver-2, composer-n1-webserver-4 or + // composer-n1-webserver-8. + // If not specified, composer-n1-webserver-2 will be used. + // Value custom is returned only in response, if Airflow web server parameters + // were manually changed to a non-standard values. + string machine_type = 1 [(google.api.field_behavior) = OPTIONAL]; +} + +// The encryption options for the Cloud Composer environment +// and its dependencies.Supported for Cloud Composer environments in versions +// composer-1.*.*-airflow-*.*.*. +message EncryptionConfig { + // Optional. Customer-managed Encryption Key available through Google's Key + // Management Service. Cannot be updated. If not specified, Google-managed key + // will be used. + string kms_key_name = 1 [(google.api.field_behavior) = OPTIONAL]; +} + +// The configuration settings for Cloud Composer maintenance window. +// The following example: +// +// ``` +// { +// "startTime":"2019-08-01T01:00:00Z" +// "endTime":"2019-08-01T07:00:00Z" +// "recurrence":"FREQ=WEEKLY;BYDAY=TU,WE" +// } +// ``` +// +// would define a maintenance window between 01 and 07 hours UTC during +// each Tuesday and Wednesday. +message MaintenanceWindow { + // Required. Start time of the first recurrence of the maintenance window. + google.protobuf.Timestamp start_time = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Maintenance window end time. It is used only to calculate the + // duration of the maintenance window. The value for end-time must be in the + // future, relative to `start_time`. + google.protobuf.Timestamp end_time = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Maintenance window recurrence. Format is a subset of + // [RFC-5545](https://tools.ietf.org/html/rfc5545) `RRULE`. The only allowed + // values for `FREQ` field are `FREQ=DAILY` and `FREQ=WEEKLY;BYDAY=...` + // Example values: `FREQ=WEEKLY;BYDAY=TU,WE`, `FREQ=DAILY`. + string recurrence = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Specifies the selection and configuration of software inside the environment. +message SoftwareConfig { + // The version of the software running in the environment. + // This encapsulates both the version of Cloud Composer functionality and the + // version of Apache Airflow. It must match the regular expression + // `composer-([0-9]+(\.[0-9]+\.[0-9]+(-preview\.[0-9]+)?)?|latest)-airflow-([0-9]+(\.[0-9]+(\.[0-9]+)?)?)`. + // When used as input, the server also checks if the provided version is + // supported and denies the request for an unsupported version. + // + // The Cloud Composer portion of the image version is a full + // [semantic version](https://semver.org), or an alias in the form of major + // version number or `latest`. When an alias is provided, the server replaces + // it with the current Cloud Composer version that satisfies the alias. + // + // The Apache Airflow portion of the image version is a full semantic version + // that points to one of the supported Apache Airflow versions, or an alias in + // the form of only major or major.minor versions specified. When an alias is + // provided, the server replaces it with the latest Apache Airflow version + // that satisfies the alias and is supported in the given Cloud Composer + // version. + // + // In all cases, the resolved image version is stored in the same field. + // + // See also [version + // list](/composer/docs/concepts/versioning/composer-versions) and [versioning + // overview](/composer/docs/concepts/versioning/composer-versioning-overview). + string image_version = 1; + + // Optional. Apache Airflow configuration properties to override. + // + // Property keys contain the section and property names, separated by a + // hyphen, for example "core-dags_are_paused_at_creation". Section names must + // not contain hyphens ("-"), opening square brackets ("["), or closing + // square brackets ("]"). The property name must not be empty and must not + // contain an equals sign ("=") or semicolon (";"). Section and property names + // must not contain a period ("."). Apache Airflow configuration property + // names must be written in + // [snake_case](https://en.wikipedia.org/wiki/Snake_case). Property values can + // contain any character, and can be written in any lower/upper case format. + // + // Certain Apache Airflow configuration property values are + // [blocked](/composer/docs/concepts/airflow-configurations), + // and cannot be overridden. + map airflow_config_overrides = 2; + + // Optional. Custom Python Package Index (PyPI) packages to be installed in + // the environment. + // + // Keys refer to the lowercase package name such as "numpy" + // and values are the lowercase extras and version specifier such as + // "==1.12.0", "[devel,gcp_api]", or "[devel]>=1.8.2, <1.9.2". To specify a + // package without pinning it to a version specifier, use the empty string as + // the value. + map pypi_packages = 3; + + // Optional. Additional environment variables to provide to the Apache Airflow + // scheduler, worker, and webserver processes. + // + // Environment variable names must match the regular expression + // `[a-zA-Z_][a-zA-Z0-9_]*`. They cannot specify Apache Airflow + // software configuration overrides (they cannot match the regular expression + // `AIRFLOW__[A-Z0-9_]+__[A-Z0-9_]+`), and they cannot match any of the + // following reserved names: + // + // * `AIRFLOW_HOME` + // * `C_FORCE_ROOT` + // * `CONTAINER_NAME` + // * `DAGS_FOLDER` + // * `GCP_PROJECT` + // * `GCS_BUCKET` + // * `GKE_CLUSTER_NAME` + // * `SQL_DATABASE` + // * `SQL_INSTANCE` + // * `SQL_PASSWORD` + // * `SQL_PROJECT` + // * `SQL_REGION` + // * `SQL_USER` + map env_variables = 4; + + // Optional. The major version of Python used to run the Apache Airflow + // scheduler, worker, and webserver processes. + // + // Can be set to '2' or '3'. If not specified, the default is '3'. Cannot be + // updated. + // + // This field is only supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. Environments in newer versions always use + // Python major version 3. + string python_version = 6; + + // Optional. The number of schedulers for Airflow. + // + // This field is supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-2.*.*. + int32 scheduler_count = 7 [(google.api.field_behavior) = OPTIONAL]; +} + +// Configuration for controlling how IPs are allocated in the +// GKE cluster running the Apache Airflow software. +message IPAllocationPolicy { + // Optional. Whether or not to enable Alias IPs in the GKE cluster. + // If `true`, a VPC-native cluster is created. + // + // This field is only supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. Environments in newer versions always use + // VPC-native GKE clusters. + bool use_ip_aliases = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Configuration of allocating IP addresses for pods in the GKE cluster. + oneof cluster_ip_allocation { + // Optional. The name of the GKE cluster's secondary range used to allocate + // IP addresses to pods. + // + // For Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*, + // this field is applicable only when `use_ip_aliases` is true. + string cluster_secondary_range_name = 2 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The IP address range used to allocate IP addresses to pods in + // the GKE cluster. + // + // For Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*, + // this field is applicable only when `use_ip_aliases` is true. + // + // Set to blank to have GKE choose a range with the default size. + // + // Set to /netmask (e.g. `/14`) to have GKE choose a range with a specific + // netmask. + // + // Set to a + // [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) + // notation (e.g. `10.96.0.0/14`) from the RFC-1918 private networks (e.g. + // `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`) to pick a specific range + // to use. + string cluster_ipv4_cidr_block = 4 [(google.api.field_behavior) = OPTIONAL]; + } + + // Configuration of allocating IP addresses for services in the GKE cluster. + oneof services_ip_allocation { + // Optional. The name of the services' secondary range used to allocate + // IP addresses to the GKE cluster. + // + // For Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*, + // this field is applicable only when `use_ip_aliases` is true. + string services_secondary_range_name = 3 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The IP address range of the services IP addresses in this + // GKE cluster. + // + // For Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*, + // this field is applicable only when `use_ip_aliases` is true. + // + // Set to blank to have GKE choose a range with the default size. + // + // Set to /netmask (e.g. `/14`) to have GKE choose a range with a specific + // netmask. + // + // Set to a + // [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) + // notation (e.g. `10.96.0.0/14`) from the RFC-1918 private networks (e.g. + // `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`) to pick a specific range + // to use. + string services_ipv4_cidr_block = 5 + [(google.api.field_behavior) = OPTIONAL]; + } +} + +// The configuration information for the Kubernetes Engine nodes running +// the Apache Airflow software. +message NodeConfig { + // Optional. The Compute Engine [zone](/compute/docs/regions-zones) in which + // to deploy the VMs used to run the Apache Airflow software, specified as a + // [relative resource + // name](/apis/design/resource_names#relative_resource_name). For example: + // "projects/{projectId}/zones/{zoneId}". + // + // This `location` must belong to the enclosing environment's project and + // location. If both this field and `nodeConfig.machineType` are specified, + // `nodeConfig.machineType` must belong to this `location`; if both are + // unspecified, the service will pick a zone in the Compute Engine region + // corresponding to the Cloud Composer location, and propagate that choice to + // both fields. If only one field (`location` or `nodeConfig.machineType`) is + // specified, the location information from the specified field will be + // propagated to the unspecified field. + // + // This field is supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + string location = 1; + + // Optional. The Compute Engine + // [machine type](/compute/docs/machine-types) used for cluster instances, + // specified as a + // [relative resource + // name](/apis/design/resource_names#relative_resource_name). For example: + // "projects/{projectId}/zones/{zoneId}/machineTypes/{machineTypeId}". + // + // The `machineType` must belong to the enclosing environment's project and + // location. If both this field and `nodeConfig.location` are specified, + // this `machineType` must belong to the `nodeConfig.location`; if both are + // unspecified, the service will pick a zone in the Compute Engine region + // corresponding to the Cloud Composer location, and propagate that choice to + // both fields. If exactly one of this field and `nodeConfig.location` is + // specified, the location information from the specified field will be + // propagated to the unspecified field. + // + // The `machineTypeId` must not be a [shared-core machine + // type](/compute/docs/machine-types#sharedcore). + // + // If this field is unspecified, the `machineTypeId` defaults + // to "n1-standard-1". + // + // This field is supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + string machine_type = 2; + + // Optional. The Compute Engine network to be used for machine + // communications, specified as a + // [relative resource + // name](/apis/design/resource_names#relative_resource_name). For example: + // "projects/{projectId}/global/networks/{networkId}". + // + // If unspecified, the "default" network ID in the environment's project is + // used. If a [Custom Subnet Network](/vpc/docs/vpc#vpc_networks_and_subnets) + // is provided, `nodeConfig.subnetwork` must also be provided. For + // [Shared VPC](/vpc/docs/shared-vpc) subnetwork requirements, see + // `nodeConfig.subnetwork`. + string network = 3; + + // Optional. The Compute Engine subnetwork to be used for machine + // communications, specified as a + // [relative resource + // name](/apis/design/resource_names#relative_resource_name). For example: + // "projects/{projectId}/regions/{regionId}/subnetworks/{subnetworkId}" + // + // If a subnetwork is provided, `nodeConfig.network` must also be provided, + // and the subnetwork must belong to the enclosing environment's project and + // location. + string subnetwork = 4; + + // Optional. The disk size in GB used for node VMs. Minimum size is 30GB. + // If unspecified, defaults to 100GB. Cannot be updated. + // + // This field is supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + int32 disk_size_gb = 5; + + // Optional. The set of Google API scopes to be made available on all + // node VMs. If `oauth_scopes` is empty, defaults to + // ["https://www.googleapis.com/auth/cloud-platform"]. Cannot be updated. + // + // This field is supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + repeated string oauth_scopes = 6; + + // Optional. The Google Cloud Platform Service Account to be used by the node + // VMs. If a service account is not specified, the "default" Compute Engine + // service account is used. Cannot be updated. + string service_account = 7; + + // Optional. The list of instance tags applied to all node VMs. Tags are used + // to identify valid sources or targets for network firewalls. Each tag within + // the list must comply with [RFC1035](https://www.ietf.org/rfc/rfc1035.txt). + // Cannot be updated. + repeated string tags = 8; + + // Optional. The configuration for controlling how IPs are allocated in the + // GKE cluster. + IPAllocationPolicy ip_allocation_policy = 9 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Deploys 'ip-masq-agent' daemon set in the GKE cluster and defines + // nonMasqueradeCIDRs equals to pod IP range so IP masquerading is used for + // all destination addresses, except between pods traffic. + // + // See: + // https://cloud.google.com/kubernetes-engine/docs/how-to/ip-masquerade-agent + bool enable_ip_masq_agent = 11 [(google.api.field_behavior) = OPTIONAL]; +} + +// Configuration options for the private GKE cluster in a Cloud Composer +// environment. +message PrivateClusterConfig { + // Optional. If `true`, access to the public endpoint of the GKE cluster is + // denied. + bool enable_private_endpoint = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The CIDR block from which IPv4 range for GKE master will be + // reserved. If left blank, the default value of '172.16.0.0/23' is used. + string master_ipv4_cidr_block = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The IP range in CIDR notation to use for the hosted master + // network. This range is used for assigning internal IP addresses to the GKE + // cluster master or set of masters and to the internal load balancer virtual + // IP. This range must not overlap with any other ranges in use within the + // cluster's network. + string master_ipv4_reserved_range = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Configuration options for networking connections in the Composer 2 +// environment. +message NetworkingConfig { + // Represents connection type between Composer environment in Customer + // Project and the corresponding Tenant project, from a predefined list + // of available connection modes. + enum ConnectionType { + // No specific connection type was requested, so the environment uses + // the default value corresponding to the rest of its configuration. + CONNECTION_TYPE_UNSPECIFIED = 0; + + // Requests the use of VPC peerings for connecting the Customer and Tenant + // projects. + VPC_PEERING = 1; + + // Requests the use of Private Service Connect for connecting the Customer + // and Tenant projects. + PRIVATE_SERVICE_CONNECT = 2; + } + + // Optional. Indicates the user requested specifc connection type between + // Tenant and Customer projects. You cannot set networking connection type in + // public IP environment. + ConnectionType connection_type = 1 [(google.api.field_behavior) = OPTIONAL]; +} + +// The configuration information for configuring a Private IP Cloud Composer +// environment. +message PrivateEnvironmentConfig { + // Optional. If `true`, a Private IP Cloud Composer environment is created. + // If this field is set to true, `IPAllocationPolicy.use_ip_aliases` must be + // set to true for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + bool enable_private_environment = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Configuration for the private GKE cluster for a Private IP + // Cloud Composer environment. + PrivateClusterConfig private_cluster_config = 2 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The CIDR block from which IP range for web server will be + // reserved. Needs to be disjoint from + // `private_cluster_config.master_ipv4_cidr_block` and + // `cloud_sql_ipv4_cidr_block`. + // + // This field is supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + string web_server_ipv4_cidr_block = 3 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The CIDR block from which IP range in tenant project will be + // reserved for Cloud SQL. Needs to be disjoint from + // `web_server_ipv4_cidr_block`. + string cloud_sql_ipv4_cidr_block = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The IP range reserved for the tenant project's App Engine VMs. + // + // This field is supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + string web_server_ipv4_reserved_range = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. The CIDR block from which IP range for Cloud Composer Network in + // tenant project will be reserved. Needs to be disjoint from + // private_cluster_config.master_ipv4_cidr_block and + // cloud_sql_ipv4_cidr_block. + // + // This field is supported for Cloud Composer environments in versions + // composer-2.*.*-airflow-*.*.* and newer. + string cloud_composer_network_ipv4_cidr_block = 7 + [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The IP range reserved for the tenant project's Cloud Composer + // network. + // + // This field is supported for Cloud Composer environments in versions + // composer-2.*.*-airflow-*.*.* and newer. + string cloud_composer_network_ipv4_reserved_range = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. When enabled, IPs from public (non-RFC1918) ranges can be used + // for `IPAllocationPolicy.cluster_ipv4_cidr_block` and + // `IPAllocationPolicy.service_ipv4_cidr_block`. + bool enable_privately_used_public_ips = 6 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. When specified, the environment will use Private Service Connect + // instead of VPC peerings to connect to Cloud SQL in the Tenant Project, + // and the PSC endpoint in the Customer Project will use an IP address from + // this subnetwork. + string cloud_composer_connection_subnetwork = 9 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Configuration for the network connections configuration in the + // environment. + NetworkingConfig networking_config = 10 + [(google.api.field_behavior) = OPTIONAL]; +} + +// The Kubernetes workloads configuration for GKE cluster associated with the +// Cloud Composer environment. Supported for Cloud Composer environments in +// versions composer-2.*.*-airflow-*.*.* and newer. +message WorkloadsConfig { + // Configuration for resources used by Airflow schedulers. + message SchedulerResource { + // Optional. CPU request and limit for a single Airflow scheduler replica. + float cpu = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Memory (GB) request and limit for a single Airflow scheduler + // replica. + float memory_gb = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Storage (GB) request and limit for a single Airflow scheduler + // replica. + float storage_gb = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The number of schedulers. + int32 count = 4 [(google.api.field_behavior) = OPTIONAL]; + } + + // Configuration for resources used by Airflow web server. + message WebServerResource { + // Optional. CPU request and limit for Airflow web server. + float cpu = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Memory (GB) request and limit for Airflow web server. + float memory_gb = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Storage (GB) request and limit for Airflow web server. + float storage_gb = 3 [(google.api.field_behavior) = OPTIONAL]; + } + + // Configuration for resources used by Airflow workers. + message WorkerResource { + // Optional. CPU request and limit for a single Airflow worker replica. + float cpu = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Memory (GB) request and limit for a single Airflow worker + // replica. + float memory_gb = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Storage (GB) request and limit for a single Airflow worker + // replica. + float storage_gb = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Minimum number of workers for autoscaling. + int32 min_count = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Maximum number of workers for autoscaling. + int32 max_count = 5 [(google.api.field_behavior) = OPTIONAL]; + } + + // Optional. Resources used by Airflow schedulers. + SchedulerResource scheduler = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Resources used by Airflow web server. + WebServerResource web_server = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Resources used by Airflow workers. + WorkerResource worker = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The Recovery settings of an environment. +message RecoveryConfig { + // Optional. The configuration for scheduled snapshot creation mechanism. + ScheduledSnapshotsConfig scheduled_snapshots_config = 1 + [(google.api.field_behavior) = OPTIONAL]; +} + +// The configuration for scheduled snapshot creation mechanism. +message ScheduledSnapshotsConfig { + // Optional. Whether scheduled snapshots creation is enabled. + bool enabled = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The Cloud Storage location for storing automatically created + // snapshots. + string snapshot_location = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The cron expression representing the time when snapshots creation + // mechanism runs. This field is subject to additional validation around + // frequency of execution. + string snapshot_creation_schedule = 3 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Time zone that sets the context to interpret + // snapshot_creation_schedule. + string time_zone = 5 [(google.api.field_behavior) = OPTIONAL]; +} + +// Configuration options for the master authorized networks feature. Enabled +// master authorized networks will disallow all external traffic to access +// Kubernetes master through HTTPS except traffic from the given CIDR blocks, +// Google Compute Engine Public IPs and Google Prod IPs. +message MasterAuthorizedNetworksConfig { + // CIDR block with an optional name. + message CidrBlock { + // User-defined name that identifies the CIDR block. + string display_name = 1; + + // CIDR block that must be specified in CIDR notation. + string cidr_block = 2; + } + + // Whether or not master authorized networks feature is enabled. + bool enabled = 1; + + // Up to 50 external networks that could access Kubernetes master through + // HTTPS. + repeated CidrBlock cidr_blocks = 2; +} + +// An environment for running orchestration tasks. +message Environment { + option (google.api.resource) = { + type: "composer.googleapis.com/Environment" + pattern: "projects/{project}/locations/{location}/environments/{environment}" + }; + + // State of the environment. + enum State { + // The state of the environment is unknown. + STATE_UNSPECIFIED = 0; + + // The environment is in the process of being created. + CREATING = 1; + + // The environment is currently running and healthy. It is ready for use. + RUNNING = 2; + + // The environment is being updated. It remains usable but cannot receive + // additional update requests or be deleted at this time. + UPDATING = 3; + + // The environment is undergoing deletion. It cannot be used. + DELETING = 4; + + // The environment has encountered an error and cannot be used. + ERROR = 5; + } + + // The resource name of the environment, in the form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + // + // EnvironmentId must start with a lowercase letter followed by up to 63 + // lowercase letters, numbers, or hyphens, and cannot end with a hyphen. + string name = 1; + + // Configuration parameters for this environment. + EnvironmentConfig config = 2; + + // Output only. The UUID (Universally Unique IDentifier) associated with this + // environment. This value is generated when the environment is created. + string uuid = 3; + + // The current state of the environment. + State state = 4; + + // Output only. The time at which this environment was created. + google.protobuf.Timestamp create_time = 5; + + // Output only. The time at which this environment was last modified. + google.protobuf.Timestamp update_time = 6; + + // Optional. User-defined labels for this environment. + // The labels map can contain no more than 64 entries. Entries of the labels + // map are UTF8 strings that comply with the following restrictions: + // + // * Keys must conform to regexp: [\p{Ll}\p{Lo}][\p{Ll}\p{Lo}\p{N}_-]{0,62} + // * Values must conform to regexp: [\p{Ll}\p{Lo}\p{N}_-]{0,63} + // * Both keys and values are additionally constrained to be <= 128 bytes in + // size. + map labels = 7; +} + +// Message containing information about the result of an upgrade check +// operation. +message CheckUpgradeResponse { + // Whether there were python modules conflict during image build. + enum ConflictResult { + // It is unknown whether build had conflicts or not. + CONFLICT_RESULT_UNSPECIFIED = 0; + + // There were python packages conflicts. + CONFLICT = 1; + + // There were no python packages conflicts. + NO_CONFLICT = 2; + } + + // Output only. Url for a docker build log of an upgraded image. + string build_log_uri = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Whether build has succeeded or failed on modules conflicts. + ConflictResult contains_pypi_modules_conflict = 4 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Extract from a docker image build log containing information + // about pypi modules conflicts. + string pypi_conflict_build_log_extract = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Composer image for which the build was happening. + string image_version = 5; + + // Pypi dependencies specified in the environment configuration, at the time + // when the build was triggered. + map pypi_dependencies = 6; +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/image_versions.proto b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/image_versions.proto new file mode 100644 index 00000000000..0f458cc5c6f --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/image_versions.proto @@ -0,0 +1,90 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.orchestration.airflow.service.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/type/date.proto"; + +option go_package = "cloud.google.com/go/orchestration/airflow/service/apiv1/servicepb;servicepb"; +option java_multiple_files = true; +option java_package = "com.google.cloud.orchestration.airflow.service.v1"; + +// Readonly service to query available ImageVersions. +service ImageVersions { + option (google.api.default_host) = "composer.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // List ImageVersions for provided location. + rpc ListImageVersions(ListImageVersionsRequest) + returns (ListImageVersionsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/imageVersions" + }; + option (google.api.method_signature) = "parent"; + } +} + +// List ImageVersions in a project and location. +message ListImageVersionsRequest { + // List ImageVersions in the given project and location, in the form: + // "projects/{projectId}/locations/{locationId}" + string parent = 1; + + // The maximum number of image_versions to return. + int32 page_size = 2; + + // The next_page_token value returned from a previous List request, if any. + string page_token = 3; + + // Whether or not image versions from old releases should be included. + bool include_past_releases = 4; +} + +// The ImageVersions in a project and location. +message ListImageVersionsResponse { + // The list of supported ImageVersions in a location. + repeated ImageVersion image_versions = 1; + + // The page token used to query for the next page if one exists. + string next_page_token = 2; +} + +// ImageVersion information +message ImageVersion { + // The string identifier of the ImageVersion, in the form: + // "composer-x.y.z-airflow-a.b.c" + string image_version_id = 1; + + // Whether this is the default ImageVersion used by Composer during + // environment creation if no input ImageVersion is specified. + bool is_default = 2; + + // supported python versions + repeated string supported_python_versions = 3; + + // The date of the version release. + google.type.Date release_date = 4; + + // Whether it is impossible to create an environment with the image version. + bool creation_disabled = 5; + + // Whether it is impossible to upgrade an environment running with the image + // version. + bool upgrade_disabled = 6; +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/operations.proto b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/operations.proto new file mode 100644 index 00000000000..71672aa3c8e --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/operations.proto @@ -0,0 +1,97 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.orchestration.airflow.service.v1; + +import "google/protobuf/timestamp.proto"; + +option go_package = "cloud.google.com/go/orchestration/airflow/service/apiv1/servicepb;servicepb"; +option java_multiple_files = true; +option java_outer_classname = "OperationsProto"; +option java_package = "com.google.cloud.orchestration.airflow.service.v1"; + +// Metadata describing an operation. +message OperationMetadata { + // An enum describing the overall state of an operation. + enum State { + option allow_alias = true; + + // Unused. + STATE_UNSPECIFIED = 0; + + // The operation has been created but is not yet started. + PENDING = 1; + + // The operation is underway. + RUNNING = 2; + + // The operation completed successfully. + SUCCEEDED = 3; + + SUCCESSFUL = 3; + + // The operation is no longer running but did not succeed. + FAILED = 4; + } + + // Type of longrunning operation. + enum Type { + // Unused. + TYPE_UNSPECIFIED = 0; + + // A resource creation operation. + CREATE = 1; + + // A resource deletion operation. + DELETE = 2; + + // A resource update operation. + UPDATE = 3; + + // A resource check operation. + CHECK = 4; + + // Saves snapshot of the resource operation. + SAVE_SNAPSHOT = 5; + + // Loads snapshot of the resource operation. + LOAD_SNAPSHOT = 6; + + // Triggers failover of environment's Cloud SQL instance (only for highly + // resilient environments). + DATABASE_FAILOVER = 7; + } + + // Output only. The current operation state. + State state = 1; + + // Output only. The type of operation being performed. + Type operation_type = 2; + + // Output only. The resource being operated on, as a [relative resource name]( + // /apis/design/resource_names#relative_resource_name). + string resource = 3; + + // Output only. The UUID of the resource being operated on. + string resource_uuid = 4; + + // Output only. The time the operation was submitted to the server. + google.protobuf.Timestamp create_time = 5; + + // Output only. The time when the operation terminated, regardless of its + // success. This field is unset if the operation is still ongoing. + google.protobuf.Timestamp end_time = 6; +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.create_environment.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.create_environment.js new file mode 100644 index 00000000000..6f22fd302cb --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.create_environment.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() { + // [START composer_v1_generated_Environments_CreateEnvironment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 must be of the form + * "projects/{projectId}/locations/{locationId}". + */ + // const parent = 'abc123' + /** + * The environment to create. + */ + // const environment = {} + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callCreateEnvironment() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await serviceClient.createEnvironment(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateEnvironment(); + // [END composer_v1_generated_Environments_CreateEnvironment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.database_failover.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.database_failover.js new file mode 100644 index 00000000000..fa2c0df10a5 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.database_failover.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() { + // [START composer_v1_generated_Environments_DatabaseFailover_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Target environment: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + */ + // const environment = 'abc123' + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callDatabaseFailover() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await serviceClient.databaseFailover(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDatabaseFailover(); + // [END composer_v1_generated_Environments_DatabaseFailover_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.delete_environment.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.delete_environment.js new file mode 100644 index 00000000000..939b7fb7084 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.delete_environment.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() { + // [START composer_v1_generated_Environments_DeleteEnvironment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 environment to delete, in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + */ + // const name = 'abc123' + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callDeleteEnvironment() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await serviceClient.deleteEnvironment(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteEnvironment(); + // [END composer_v1_generated_Environments_DeleteEnvironment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.execute_airflow_command.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.execute_airflow_command.js new file mode 100644 index 00000000000..f997ed827e1 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.execute_airflow_command.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() { + // [START composer_v1_generated_Environments_ExecuteAirflowCommand_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 resource name of the environment in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}". + */ + // const environment = 'abc123' + /** + * Airflow command. + */ + // const command = 'abc123' + /** + * Airflow subcommand. + */ + // const subcommand = 'abc123' + /** + * Parameters for the Airflow command/subcommand as an array of arguments. + * It may contain positional arguments like `["my-dag-id"]`, key-value + * parameters like `["--foo=bar"]` or `["--foo","bar"]`, + * or other flags like `["-f"]`. + */ + // const parameters = ['abc','def'] + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callExecuteAirflowCommand() { + // Construct request + const request = { + }; + + // Run request + const response = await serviceClient.executeAirflowCommand(request); + console.log(response); + } + + callExecuteAirflowCommand(); + // [END composer_v1_generated_Environments_ExecuteAirflowCommand_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.fetch_database_properties.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.fetch_database_properties.js new file mode 100644 index 00000000000..53391a937d2 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.fetch_database_properties.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(environment) { + // [START composer_v1_generated_Environments_FetchDatabaseProperties_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 environment, in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + */ + // const environment = 'abc123' + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callFetchDatabaseProperties() { + // Construct request + const request = { + environment, + }; + + // Run request + const response = await serviceClient.fetchDatabaseProperties(request); + console.log(response); + } + + callFetchDatabaseProperties(); + // [END composer_v1_generated_Environments_FetchDatabaseProperties_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.get_environment.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.get_environment.js new file mode 100644 index 00000000000..7329b82691c --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.get_environment.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 composer_v1_generated_Environments_GetEnvironment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 resource name of the environment to get, in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + */ + // const name = 'abc123' + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callGetEnvironment() { + // Construct request + const request = { + }; + + // Run request + const response = await serviceClient.getEnvironment(request); + console.log(response); + } + + callGetEnvironment(); + // [END composer_v1_generated_Environments_GetEnvironment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.list_environments.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.list_environments.js new file mode 100644 index 00000000000..3300e3bfed1 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.list_environments.js @@ -0,0 +1,71 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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 composer_v1_generated_Environments_ListEnvironments_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * List environments in the given project and location, in the form: + * "projects/{projectId}/locations/{locationId}" + */ + // const parent = 'abc123' + /** + * The maximum number of environments to return. + */ + // const pageSize = 1234 + /** + * The next_page_token value returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callListEnvironments() { + // Construct request + const request = { + }; + + // Run request + const iterable = await serviceClient.listEnvironmentsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListEnvironments(); + // [END composer_v1_generated_Environments_ListEnvironments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.load_snapshot.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.load_snapshot.js new file mode 100644 index 00000000000..1bb1092893a --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.load_snapshot.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() { + // [START composer_v1_generated_Environments_LoadSnapshot_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 resource name of the target environment in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + */ + // const environment = 'abc123' + /** + * A Cloud Storage path to a snapshot to load, e.g.: + * "gs://my-bucket/snapshots/project_location_environment_timestamp". + */ + // const snapshotPath = 'abc123' + /** + * Whether or not to skip installing Pypi packages when loading the + * environment's state. + */ + // const skipPypiPackagesInstallation = true + /** + * Whether or not to skip setting environment variables when loading the + * environment's state. + */ + // const skipEnvironmentVariablesSetting = true + /** + * Whether or not to skip setting Airflow overrides when loading the + * environment's state. + */ + // const skipAirflowOverridesSetting = true + /** + * Whether or not to skip copying Cloud Storage data when loading the + * environment's state. + */ + // const skipGcsDataCopying = true + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callLoadSnapshot() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await serviceClient.loadSnapshot(request); + const [response] = await operation.promise(); + console.log(response); + } + + callLoadSnapshot(); + // [END composer_v1_generated_Environments_LoadSnapshot_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.poll_airflow_command.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.poll_airflow_command.js new file mode 100644 index 00000000000..13f8af79815 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.poll_airflow_command.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() { + // [START composer_v1_generated_Environments_PollAirflowCommand_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 resource name of the environment in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + */ + // const environment = 'abc123' + /** + * The unique ID of the command execution. + */ + // const executionId = 'abc123' + /** + * The name of the pod where the command is executed. + */ + // const pod = 'abc123' + /** + * The namespace of the pod where the command is executed. + */ + // const podNamespace = 'abc123' + /** + * Line number from which new logs should be fetched. + */ + // const nextLineNumber = 1234 + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callPollAirflowCommand() { + // Construct request + const request = { + }; + + // Run request + const response = await serviceClient.pollAirflowCommand(request); + console.log(response); + } + + callPollAirflowCommand(); + // [END composer_v1_generated_Environments_PollAirflowCommand_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.save_snapshot.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.save_snapshot.js new file mode 100644 index 00000000000..dcfce442272 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.save_snapshot.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() { + // [START composer_v1_generated_Environments_SaveSnapshot_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 resource name of the source environment in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + */ + // const environment = 'abc123' + /** + * Location in a Cloud Storage where the snapshot is going to be stored, e.g.: + * "gs://my-bucket/snapshots". + */ + // const snapshotLocation = 'abc123' + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callSaveSnapshot() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await serviceClient.saveSnapshot(request); + const [response] = await operation.promise(); + console.log(response); + } + + callSaveSnapshot(); + // [END composer_v1_generated_Environments_SaveSnapshot_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.stop_airflow_command.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.stop_airflow_command.js new file mode 100644 index 00000000000..82973bd018b --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.stop_airflow_command.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() { + // [START composer_v1_generated_Environments_StopAirflowCommand_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 resource name of the environment in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}". + */ + // const environment = 'abc123' + /** + * The unique ID of the command execution. + */ + // const executionId = 'abc123' + /** + * The name of the pod where the command is executed. + */ + // const pod = 'abc123' + /** + * The namespace of the pod where the command is executed. + */ + // const podNamespace = 'abc123' + /** + * If true, the execution is terminated forcefully (SIGKILL). If false, the + * execution is stopped gracefully, giving it time for cleanup. + */ + // const force = true + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callStopAirflowCommand() { + // Construct request + const request = { + }; + + // Run request + const response = await serviceClient.stopAirflowCommand(request); + console.log(response); + } + + callStopAirflowCommand(); + // [END composer_v1_generated_Environments_StopAirflowCommand_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.update_environment.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.update_environment.js new file mode 100644 index 00000000000..4f3b5d2da3c --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.update_environment.js @@ -0,0 +1,184 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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 composer_v1_generated_Environments_UpdateEnvironment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 relative resource name of the environment to update, in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + */ + // const name = 'abc123' + /** + * A patch environment. Fields specified by the `updateMask` will be copied + * from the patch environment into the environment under update. + */ + // const environment = {} + /** + * Required. A comma-separated list of paths, relative to `Environment`, of + * fields to update. + * For example, to set the version of scikit-learn to install in the + * environment to 0.19.0 and to remove an existing installation of + * numpy, the `updateMask` parameter would include the following two + * `paths` values: "config.softwareConfig.pypiPackages.scikit-learn" and + * "config.softwareConfig.pypiPackages.numpy". The included patch + * environment would specify the scikit-learn version as follows: + * { + * "config":{ + * "softwareConfig":{ + * "pypiPackages":{ + * "scikit-learn":"==0.19.0" + * } + * } + * } + * } + * Note that in the above example, any existing PyPI packages + * other than scikit-learn and numpy will be unaffected. + * Only one update type may be included in a single request's `updateMask`. + * For example, one cannot update both the PyPI packages and + * labels in the same request. However, it is possible to update multiple + * members of a map field simultaneously in the same request. For example, + * to set the labels "label1" and "label2" while clearing "label3" (assuming + * it already exists), one can + * provide the paths "labels.label1", "labels.label2", and "labels.label3" + * and populate the patch environment as follows: + * { + * "labels":{ + * "label1":"new-label1-value" + * "label2":"new-label2-value" + * } + * } + * Note that in the above example, any existing labels that are not + * included in the `updateMask` will be unaffected. + * It is also possible to replace an entire map field by providing the + * map field's path in the `updateMask`. The new value of the field will + * be that which is provided in the patch environment. For example, to + * delete all pre-existing user-specified PyPI packages and + * install botocore at version 1.7.14, the `updateMask` would contain + * the path "config.softwareConfig.pypiPackages", and + * the patch environment would be the following: + * { + * "config":{ + * "softwareConfig":{ + * "pypiPackages":{ + * "botocore":"==1.7.14" + * } + * } + * } + * } + * **Note:** Only the following fields can be updated: + * * `config.softwareConfig.pypiPackages` + * * Replace all custom custom PyPI packages. If a replacement + * package map is not included in `environment`, all custom + * PyPI packages are cleared. It is an error to provide both + * this mask and a mask specifying an individual package. + * * `config.softwareConfig.pypiPackages.`packagename + * * Update the custom PyPI package *packagename*, + * preserving other packages. To delete the package, include it in + * `updateMask`, and omit the mapping for it in + * `environment.config.softwareConfig.pypiPackages`. It is an error + * to provide both a mask of this form and the + * `config.softwareConfig.pypiPackages` mask. + * * `labels` + * * Replace all environment labels. If a replacement labels map is not + * included in `environment`, all labels are cleared. It is an error to + * provide both this mask and a mask specifying one or more individual + * labels. + * * `labels.`labelName + * * Set the label named *labelName*, while preserving other + * labels. To delete the label, include it in `updateMask` and omit its + * mapping in `environment.labels`. It is an error to provide both a + * mask of this form and the `labels` mask. + * * `config.nodeCount` + * * Horizontally scale the number of nodes in the environment. An integer + * greater than or equal to 3 must be provided in the `config.nodeCount` + * field. Supported for Cloud Composer environments in versions + * composer-1.*.*-airflow-*.*.*. + * * `config.webServerNetworkAccessControl` + * * Replace the environment's current `WebServerNetworkAccessControl`. + * * `config.softwareConfig.airflowConfigOverrides` + * * Replace all Apache Airflow config overrides. If a replacement config + * overrides map is not included in `environment`, all config overrides + * are cleared. + * It is an error to provide both this mask and a mask specifying one or + * more individual config overrides. + * * `config.softwareConfig.airflowConfigOverrides.`section-name + * * Override the Apache Airflow config property *name* in the + * section named *section*, preserving other properties. To + * delete the property override, include it in `updateMask` and omit its + * mapping in + * `environment.config.softwareConfig.airflowConfigOverrides`. + * It is an error to provide both a mask of this form and the + * `config.softwareConfig.airflowConfigOverrides` mask. + * * `config.softwareConfig.envVariables` + * * Replace all environment variables. If a replacement environment + * variable map is not included in `environment`, all custom environment + * variables are cleared. + * * `config.softwareConfig.schedulerCount` + * * Horizontally scale the number of schedulers in Airflow. A positive + * integer not greater than the number of nodes must be provided in the + * `config.softwareConfig.schedulerCount` field. Supported for Cloud + * Composer environments in versions composer-1.*.*-airflow-2.*.*. + * * `config.databaseConfig.machineType` + * * Cloud SQL machine type used by Airflow database. + * It has to be one of: db-n1-standard-2, db-n1-standard-4, + * db-n1-standard-8 or db-n1-standard-16. Supported for Cloud Composer + * environments in versions composer-1.*.*-airflow-*.*.*. + * * `config.webServerConfig.machineType` + * * Machine type on which Airflow web server is running. + * It has to be one of: composer-n1-webserver-2, composer-n1-webserver-4 + * or composer-n1-webserver-8. Supported for Cloud Composer environments + * in versions composer-1.*.*-airflow-*.*.*. + */ + // const updateMask = {} + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callUpdateEnvironment() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await serviceClient.updateEnvironment(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateEnvironment(); + // [END composer_v1_generated_Environments_UpdateEnvironment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/image_versions.list_image_versions.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/image_versions.list_image_versions.js new file mode 100644 index 00000000000..89c1b917345 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/image_versions.list_image_versions.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() { + // [START composer_v1_generated_ImageVersions_ListImageVersions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * List ImageVersions in the given project and location, in the form: + * "projects/{projectId}/locations/{locationId}" + */ + // const parent = 'abc123' + /** + * The maximum number of image_versions to return. + */ + // const pageSize = 1234 + /** + * The next_page_token value returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + /** + * Whether or not image versions from old releases should be included. + */ + // const includePastReleases = true + + // Imports the Service library + const {ImageVersionsClient} = require('@google-cloud/orchestration-airflow').v1; + + // Instantiates a client + const serviceClient = new ImageVersionsClient(); + + async function callListImageVersions() { + // Construct request + const request = { + }; + + // Run request + const iterable = await serviceClient.listImageVersionsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListImageVersions(); + // [END composer_v1_generated_ImageVersions_ListImageVersions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/snippet_metadata_google.cloud.orchestration.airflow.service.v1.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/snippet_metadata_google.cloud.orchestration.airflow.service.v1.json new file mode 100644 index 00000000000..90fa8df7f10 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/snippet_metadata_google.cloud.orchestration.airflow.service.v1.json @@ -0,0 +1,635 @@ +{ + "clientLibrary": { + "name": "nodejs-service", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.orchestration.airflow.service.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "composer_v1_generated_Environments_CreateEnvironment_async", + "title": "Environments createEnvironment Sample", + "origin": "API_DEFINITION", + "description": " Create a new environment.", + "canonical": true, + "file": "environments.create_environment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateEnvironment", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.CreateEnvironment", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "environment", + "type": ".google.cloud.orchestration.airflow.service.v1.Environment" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" + }, + "method": { + "shortName": "CreateEnvironment", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.CreateEnvironment", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1_generated_Environments_GetEnvironment_async", + "title": "Environments getEnvironment Sample", + "origin": "API_DEFINITION", + "description": " Get an existing environment.", + "canonical": true, + "file": "environments.get_environment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetEnvironment", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.GetEnvironment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.orchestration.airflow.service.v1.Environment", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" + }, + "method": { + "shortName": "GetEnvironment", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.GetEnvironment", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1_generated_Environments_ListEnvironments_async", + "title": "Environments listEnvironments Sample", + "origin": "API_DEFINITION", + "description": " List environments.", + "canonical": true, + "file": "environments.list_environments.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListEnvironments", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.ListEnvironments", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.orchestration.airflow.service.v1.ListEnvironmentsResponse", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" + }, + "method": { + "shortName": "ListEnvironments", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.ListEnvironments", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1_generated_Environments_UpdateEnvironment_async", + "title": "Environments updateEnvironment Sample", + "origin": "API_DEFINITION", + "description": " Update an environment.", + "canonical": true, + "file": "environments.update_environment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 176, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateEnvironment", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.UpdateEnvironment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "environment", + "type": ".google.cloud.orchestration.airflow.service.v1.Environment" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" + }, + "method": { + "shortName": "UpdateEnvironment", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.UpdateEnvironment", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1_generated_Environments_DeleteEnvironment_async", + "title": "Environments deleteEnvironment Sample", + "origin": "API_DEFINITION", + "description": " Delete an environment.", + "canonical": true, + "file": "environments.delete_environment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteEnvironment", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.DeleteEnvironment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" + }, + "method": { + "shortName": "DeleteEnvironment", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.DeleteEnvironment", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1_generated_Environments_ExecuteAirflowCommand_async", + "title": "Environments executeAirflowCommand Sample", + "origin": "API_DEFINITION", + "description": " Executes Airflow CLI command.", + "canonical": true, + "file": "environments.execute_airflow_command.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ExecuteAirflowCommand", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.ExecuteAirflowCommand", + "async": true, + "parameters": [ + { + "name": "environment", + "type": "TYPE_STRING" + }, + { + "name": "command", + "type": "TYPE_STRING" + }, + { + "name": "subcommand", + "type": "TYPE_STRING" + }, + { + "name": "parameters", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandResponse", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" + }, + "method": { + "shortName": "ExecuteAirflowCommand", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.ExecuteAirflowCommand", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1_generated_Environments_StopAirflowCommand_async", + "title": "Environments stopAirflowCommand Sample", + "origin": "API_DEFINITION", + "description": " Stops Airflow CLI command execution.", + "canonical": true, + "file": "environments.stop_airflow_command.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StopAirflowCommand", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.StopAirflowCommand", + "async": true, + "parameters": [ + { + "name": "environment", + "type": "TYPE_STRING" + }, + { + "name": "execution_id", + "type": "TYPE_STRING" + }, + { + "name": "pod", + "type": "TYPE_STRING" + }, + { + "name": "pod_namespace", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.orchestration.airflow.service.v1.StopAirflowCommandResponse", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" + }, + "method": { + "shortName": "StopAirflowCommand", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.StopAirflowCommand", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1_generated_Environments_PollAirflowCommand_async", + "title": "Environments pollAirflowCommand Sample", + "origin": "API_DEFINITION", + "description": " Polls Airflow CLI command execution and fetches logs.", + "canonical": true, + "file": "environments.poll_airflow_command.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PollAirflowCommand", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.PollAirflowCommand", + "async": true, + "parameters": [ + { + "name": "environment", + "type": "TYPE_STRING" + }, + { + "name": "execution_id", + "type": "TYPE_STRING" + }, + { + "name": "pod", + "type": "TYPE_STRING" + }, + { + "name": "pod_namespace", + "type": "TYPE_STRING" + }, + { + "name": "next_line_number", + "type": "TYPE_INT32" + } + ], + "resultType": ".google.cloud.orchestration.airflow.service.v1.PollAirflowCommandResponse", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" + }, + "method": { + "shortName": "PollAirflowCommand", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.PollAirflowCommand", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1_generated_Environments_SaveSnapshot_async", + "title": "Environments saveSnapshot Sample", + "origin": "API_DEFINITION", + "description": " Creates a snapshots of a Cloud Composer environment. As a result of this operation, snapshot of environment's state is stored in a location specified in the SaveSnapshotRequest.", + "canonical": true, + "file": "environments.save_snapshot.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SaveSnapshot", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.SaveSnapshot", + "async": true, + "parameters": [ + { + "name": "environment", + "type": "TYPE_STRING" + }, + { + "name": "snapshot_location", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" + }, + "method": { + "shortName": "SaveSnapshot", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.SaveSnapshot", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1_generated_Environments_LoadSnapshot_async", + "title": "Environments loadSnapshot Sample", + "origin": "API_DEFINITION", + "description": " Loads a snapshot of a Cloud Composer environment. As a result of this operation, a snapshot of environment's specified in LoadSnapshotRequest is loaded into the environment.", + "canonical": true, + "file": "environments.load_snapshot.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "LoadSnapshot", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.LoadSnapshot", + "async": true, + "parameters": [ + { + "name": "environment", + "type": "TYPE_STRING" + }, + { + "name": "snapshot_path", + "type": "TYPE_STRING" + }, + { + "name": "skip_pypi_packages_installation", + "type": "TYPE_BOOL" + }, + { + "name": "skip_environment_variables_setting", + "type": "TYPE_BOOL" + }, + { + "name": "skip_airflow_overrides_setting", + "type": "TYPE_BOOL" + }, + { + "name": "skip_gcs_data_copying", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" + }, + "method": { + "shortName": "LoadSnapshot", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.LoadSnapshot", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1_generated_Environments_DatabaseFailover_async", + "title": "Environments databaseFailover Sample", + "origin": "API_DEFINITION", + "description": " Triggers database failover (only for highly resilient environments).", + "canonical": true, + "file": "environments.database_failover.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DatabaseFailover", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.DatabaseFailover", + "async": true, + "parameters": [ + { + "name": "environment", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" + }, + "method": { + "shortName": "DatabaseFailover", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.DatabaseFailover", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1_generated_Environments_FetchDatabaseProperties_async", + "title": "Environments fetchDatabaseProperties Sample", + "origin": "API_DEFINITION", + "description": " Fetches database properties.", + "canonical": true, + "file": "environments.fetch_database_properties.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "FetchDatabaseProperties", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.FetchDatabaseProperties", + "async": true, + "parameters": [ + { + "name": "environment", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesResponse", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" + }, + "method": { + "shortName": "FetchDatabaseProperties", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.FetchDatabaseProperties", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1_generated_ImageVersions_ListImageVersions_async", + "title": "Environments listImageVersions Sample", + "origin": "API_DEFINITION", + "description": " List ImageVersions for provided location.", + "canonical": true, + "file": "image_versions.list_image_versions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListImageVersions", + "fullName": "google.cloud.orchestration.airflow.service.v1.ImageVersions.ListImageVersions", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "include_past_releases", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.orchestration.airflow.service.v1.ListImageVersionsResponse", + "client": { + "shortName": "ImageVersionsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1.ImageVersionsClient" + }, + "method": { + "shortName": "ListImageVersions", + "fullName": "google.cloud.orchestration.airflow.service.v1.ImageVersions.ListImageVersions", + "service": { + "shortName": "ImageVersions", + "fullName": "google.cloud.orchestration.airflow.service.v1.ImageVersions" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/index.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/index.ts new file mode 100644 index 00000000000..797920b268e --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/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. ** + +import * as v1 from './v1'; +const EnvironmentsClient = v1.EnvironmentsClient; +type EnvironmentsClient = v1.EnvironmentsClient; +const ImageVersionsClient = v1.ImageVersionsClient; +type ImageVersionsClient = v1.ImageVersionsClient; +export {v1, EnvironmentsClient, ImageVersionsClient}; +export default {v1, EnvironmentsClient, ImageVersionsClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_client.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_client.ts new file mode 100644 index 00000000000..7df3705e8a6 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_client.ts @@ -0,0 +1,1867 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/environments_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './environments_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Managed Apache Airflow Environments. + * @class + * @memberof v1 + */ +export class EnvironmentsClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + environmentsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of EnvironmentsClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 EnvironmentsClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof EnvironmentsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + environmentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/environments/{environment}' + ), + }; + + // 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 = { + listEnvironments: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'environments') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createEnvironmentResponse = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1.Environment') as gax.protobuf.Type; + const createEnvironmentMetadata = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1.OperationMetadata') as gax.protobuf.Type; + const updateEnvironmentResponse = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1.Environment') as gax.protobuf.Type; + const updateEnvironmentMetadata = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1.OperationMetadata') as gax.protobuf.Type; + const deleteEnvironmentResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteEnvironmentMetadata = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1.OperationMetadata') as gax.protobuf.Type; + const saveSnapshotResponse = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1.SaveSnapshotResponse') as gax.protobuf.Type; + const saveSnapshotMetadata = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1.OperationMetadata') as gax.protobuf.Type; + const loadSnapshotResponse = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1.LoadSnapshotResponse') as gax.protobuf.Type; + const loadSnapshotMetadata = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1.OperationMetadata') as gax.protobuf.Type; + const databaseFailoverResponse = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1.DatabaseFailoverResponse') as gax.protobuf.Type; + const databaseFailoverMetadata = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createEnvironment: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createEnvironmentResponse.decode.bind(createEnvironmentResponse), + createEnvironmentMetadata.decode.bind(createEnvironmentMetadata)), + updateEnvironment: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateEnvironmentResponse.decode.bind(updateEnvironmentResponse), + updateEnvironmentMetadata.decode.bind(updateEnvironmentMetadata)), + deleteEnvironment: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteEnvironmentResponse.decode.bind(deleteEnvironmentResponse), + deleteEnvironmentMetadata.decode.bind(deleteEnvironmentMetadata)), + saveSnapshot: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + saveSnapshotResponse.decode.bind(saveSnapshotResponse), + saveSnapshotMetadata.decode.bind(saveSnapshotMetadata)), + loadSnapshot: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + loadSnapshotResponse.decode.bind(loadSnapshotResponse), + loadSnapshotMetadata.decode.bind(loadSnapshotMetadata)), + databaseFailover: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + databaseFailoverResponse.decode.bind(databaseFailoverResponse), + databaseFailoverMetadata.decode.bind(databaseFailoverMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.orchestration.airflow.service.v1.Environments', 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.environmentsStub) { + return this.environmentsStub; + } + + // Put together the "service stub" for + // google.cloud.orchestration.airflow.service.v1.Environments. + this.environmentsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.orchestration.airflow.service.v1.Environments') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.orchestration.airflow.service.v1.Environments, + 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 environmentsStubMethods = + ['createEnvironment', 'getEnvironment', 'listEnvironments', 'updateEnvironment', 'deleteEnvironment', 'executeAirflowCommand', 'stopAirflowCommand', 'pollAirflowCommand', 'saveSnapshot', 'loadSnapshot', 'databaseFailover', 'fetchDatabaseProperties']; + for (const methodName of environmentsStubMethods) { + const callPromise = this.environmentsStub.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.environmentsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'composer.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 'composer.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 -- + // ------------------- +/** + * Get an existing environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource name of the environment to get, in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.orchestration.airflow.service.v1.Environment|Environment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/environments.get_environment.js + * region_tag:composer_v1_generated_Environments_GetEnvironment_async + */ + getEnvironment( + request?: protos.google.cloud.orchestration.airflow.service.v1.IGetEnvironmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1.IEnvironment, + protos.google.cloud.orchestration.airflow.service.v1.IGetEnvironmentRequest|undefined, {}|undefined + ]>; + getEnvironment( + request: protos.google.cloud.orchestration.airflow.service.v1.IGetEnvironmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.orchestration.airflow.service.v1.IEnvironment, + protos.google.cloud.orchestration.airflow.service.v1.IGetEnvironmentRequest|null|undefined, + {}|null|undefined>): void; + getEnvironment( + request: protos.google.cloud.orchestration.airflow.service.v1.IGetEnvironmentRequest, + callback: Callback< + protos.google.cloud.orchestration.airflow.service.v1.IEnvironment, + protos.google.cloud.orchestration.airflow.service.v1.IGetEnvironmentRequest|null|undefined, + {}|null|undefined>): void; + getEnvironment( + request?: protos.google.cloud.orchestration.airflow.service.v1.IGetEnvironmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.orchestration.airflow.service.v1.IEnvironment, + protos.google.cloud.orchestration.airflow.service.v1.IGetEnvironmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.orchestration.airflow.service.v1.IEnvironment, + protos.google.cloud.orchestration.airflow.service.v1.IGetEnvironmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1.IEnvironment, + protos.google.cloud.orchestration.airflow.service.v1.IGetEnvironmentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getEnvironment(request, options, callback); + } +/** + * Executes Airflow CLI command. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.environment + * The resource name of the environment in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}". + * @param {string} request.command + * Airflow command. + * @param {string} request.subcommand + * Airflow subcommand. + * @param {string[]} request.parameters + * Parameters for the Airflow command/subcommand as an array of arguments. + * It may contain positional arguments like `["my-dag-id"]`, key-value + * parameters like `["--foo=bar"]` or `["--foo","bar"]`, + * or other flags like `["-f"]`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandResponse|ExecuteAirflowCommandResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/environments.execute_airflow_command.js + * region_tag:composer_v1_generated_Environments_ExecuteAirflowCommand_async + */ + executeAirflowCommand( + request?: protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandRequest|undefined, {}|undefined + ]>; + executeAirflowCommand( + request: protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandRequest|null|undefined, + {}|null|undefined>): void; + executeAirflowCommand( + request: protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandRequest, + callback: Callback< + protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandRequest|null|undefined, + {}|null|undefined>): void; + executeAirflowCommand( + request?: protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'environment': request.environment ?? '', + }); + this.initialize(); + return this.innerApiCalls.executeAirflowCommand(request, options, callback); + } +/** + * Stops Airflow CLI command execution. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.environment + * The resource name of the environment in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}". + * @param {string} request.executionId + * The unique ID of the command execution. + * @param {string} request.pod + * The name of the pod where the command is executed. + * @param {string} request.podNamespace + * The namespace of the pod where the command is executed. + * @param {boolean} request.force + * If true, the execution is terminated forcefully (SIGKILL). If false, the + * execution is stopped gracefully, giving it time for cleanup. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandResponse|StopAirflowCommandResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/environments.stop_airflow_command.js + * region_tag:composer_v1_generated_Environments_StopAirflowCommand_async + */ + stopAirflowCommand( + request?: protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandRequest|undefined, {}|undefined + ]>; + stopAirflowCommand( + request: protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandRequest|null|undefined, + {}|null|undefined>): void; + stopAirflowCommand( + request: protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandRequest, + callback: Callback< + protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandRequest|null|undefined, + {}|null|undefined>): void; + stopAirflowCommand( + request?: protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'environment': request.environment ?? '', + }); + this.initialize(); + return this.innerApiCalls.stopAirflowCommand(request, options, callback); + } +/** + * Polls Airflow CLI command execution and fetches logs. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.environment + * The resource name of the environment in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + * @param {string} request.executionId + * The unique ID of the command execution. + * @param {string} request.pod + * The name of the pod where the command is executed. + * @param {string} request.podNamespace + * The namespace of the pod where the command is executed. + * @param {number} request.nextLineNumber + * Line number from which new logs should be fetched. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandResponse|PollAirflowCommandResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/environments.poll_airflow_command.js + * region_tag:composer_v1_generated_Environments_PollAirflowCommand_async + */ + pollAirflowCommand( + request?: protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandRequest|undefined, {}|undefined + ]>; + pollAirflowCommand( + request: protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandRequest|null|undefined, + {}|null|undefined>): void; + pollAirflowCommand( + request: protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandRequest, + callback: Callback< + protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandRequest|null|undefined, + {}|null|undefined>): void; + pollAirflowCommand( + request?: protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'environment': request.environment ?? '', + }); + this.initialize(); + return this.innerApiCalls.pollAirflowCommand(request, options, callback); + } +/** + * Fetches database properties. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.environment + * Required. The resource name of the environment, in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesResponse|FetchDatabasePropertiesResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/environments.fetch_database_properties.js + * region_tag:composer_v1_generated_Environments_FetchDatabaseProperties_async + */ + fetchDatabaseProperties( + request?: protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesResponse, + protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesRequest|undefined, {}|undefined + ]>; + fetchDatabaseProperties( + request: protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesResponse, + protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesRequest|null|undefined, + {}|null|undefined>): void; + fetchDatabaseProperties( + request: protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesRequest, + callback: Callback< + protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesResponse, + protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesRequest|null|undefined, + {}|null|undefined>): void; + fetchDatabaseProperties( + request?: protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesResponse, + protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesResponse, + protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesResponse, + protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'environment': request.environment ?? '', + }); + this.initialize(); + return this.innerApiCalls.fetchDatabaseProperties(request, options, callback); + } + +/** + * Create a new environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The parent must be of the form + * "projects/{projectId}/locations/{locationId}". + * @param {google.cloud.orchestration.airflow.service.v1.Environment} request.environment + * The environment to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/environments.create_environment.js + * region_tag:composer_v1_generated_Environments_CreateEnvironment_async + */ + createEnvironment( + request?: protos.google.cloud.orchestration.airflow.service.v1.ICreateEnvironmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createEnvironment( + request: protos.google.cloud.orchestration.airflow.service.v1.ICreateEnvironmentRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createEnvironment( + request: protos.google.cloud.orchestration.airflow.service.v1.ICreateEnvironmentRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createEnvironment( + request?: protos.google.cloud.orchestration.airflow.service.v1.ICreateEnvironmentRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createEnvironment(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createEnvironment()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/environments.create_environment.js + * region_tag:composer_v1_generated_Environments_CreateEnvironment_async + */ + async checkCreateEnvironmentProgress(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.createEnvironment, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Update an environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The relative resource name of the environment to update, in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + * @param {google.cloud.orchestration.airflow.service.v1.Environment} request.environment + * A patch environment. Fields specified by the `updateMask` will be copied + * from the patch environment into the environment under update. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. A comma-separated list of paths, relative to `Environment`, of + * fields to update. + * For example, to set the version of scikit-learn to install in the + * environment to 0.19.0 and to remove an existing installation of + * numpy, the `updateMask` parameter would include the following two + * `paths` values: "config.softwareConfig.pypiPackages.scikit-learn" and + * "config.softwareConfig.pypiPackages.numpy". The included patch + * environment would specify the scikit-learn version as follows: + * + * { + * "config":{ + * "softwareConfig":{ + * "pypiPackages":{ + * "scikit-learn":"==0.19.0" + * } + * } + * } + * } + * + * Note that in the above example, any existing PyPI packages + * other than scikit-learn and numpy will be unaffected. + * + * Only one update type may be included in a single request's `updateMask`. + * For example, one cannot update both the PyPI packages and + * labels in the same request. However, it is possible to update multiple + * members of a map field simultaneously in the same request. For example, + * to set the labels "label1" and "label2" while clearing "label3" (assuming + * it already exists), one can + * provide the paths "labels.label1", "labels.label2", and "labels.label3" + * and populate the patch environment as follows: + * + * { + * "labels":{ + * "label1":"new-label1-value" + * "label2":"new-label2-value" + * } + * } + * + * Note that in the above example, any existing labels that are not + * included in the `updateMask` will be unaffected. + * + * It is also possible to replace an entire map field by providing the + * map field's path in the `updateMask`. The new value of the field will + * be that which is provided in the patch environment. For example, to + * delete all pre-existing user-specified PyPI packages and + * install botocore at version 1.7.14, the `updateMask` would contain + * the path "config.softwareConfig.pypiPackages", and + * the patch environment would be the following: + * + * { + * "config":{ + * "softwareConfig":{ + * "pypiPackages":{ + * "botocore":"==1.7.14" + * } + * } + * } + * } + * + * **Note:** Only the following fields can be updated: + * + * * `config.softwareConfig.pypiPackages` + * * Replace all custom custom PyPI packages. If a replacement + * package map is not included in `environment`, all custom + * PyPI packages are cleared. It is an error to provide both + * this mask and a mask specifying an individual package. + * * `config.softwareConfig.pypiPackages.`packagename + * * Update the custom PyPI package *packagename*, + * preserving other packages. To delete the package, include it in + * `updateMask`, and omit the mapping for it in + * `environment.config.softwareConfig.pypiPackages`. It is an error + * to provide both a mask of this form and the + * `config.softwareConfig.pypiPackages` mask. + * * `labels` + * * Replace all environment labels. If a replacement labels map is not + * included in `environment`, all labels are cleared. It is an error to + * provide both this mask and a mask specifying one or more individual + * labels. + * * `labels.`labelName + * * Set the label named *labelName*, while preserving other + * labels. To delete the label, include it in `updateMask` and omit its + * mapping in `environment.labels`. It is an error to provide both a + * mask of this form and the `labels` mask. + * * `config.nodeCount` + * * Horizontally scale the number of nodes in the environment. An integer + * greater than or equal to 3 must be provided in the `config.nodeCount` + * field. Supported for Cloud Composer environments in versions + * composer-1.*.*-airflow-*.*.*. + * * `config.webServerNetworkAccessControl` + * * Replace the environment's current `WebServerNetworkAccessControl`. + * * `config.softwareConfig.airflowConfigOverrides` + * * Replace all Apache Airflow config overrides. If a replacement config + * overrides map is not included in `environment`, all config overrides + * are cleared. + * It is an error to provide both this mask and a mask specifying one or + * more individual config overrides. + * * `config.softwareConfig.airflowConfigOverrides.`section-name + * * Override the Apache Airflow config property *name* in the + * section named *section*, preserving other properties. To + * delete the property override, include it in `updateMask` and omit its + * mapping in + * `environment.config.softwareConfig.airflowConfigOverrides`. + * It is an error to provide both a mask of this form and the + * `config.softwareConfig.airflowConfigOverrides` mask. + * * `config.softwareConfig.envVariables` + * * Replace all environment variables. If a replacement environment + * variable map is not included in `environment`, all custom environment + * variables are cleared. + * * `config.softwareConfig.schedulerCount` + * * Horizontally scale the number of schedulers in Airflow. A positive + * integer not greater than the number of nodes must be provided in the + * `config.softwareConfig.schedulerCount` field. Supported for Cloud + * Composer environments in versions composer-1.*.*-airflow-2.*.*. + * * `config.databaseConfig.machineType` + * * Cloud SQL machine type used by Airflow database. + * It has to be one of: db-n1-standard-2, db-n1-standard-4, + * db-n1-standard-8 or db-n1-standard-16. Supported for Cloud Composer + * environments in versions composer-1.*.*-airflow-*.*.*. + * * `config.webServerConfig.machineType` + * * Machine type on which Airflow web server is running. + * It has to be one of: composer-n1-webserver-2, composer-n1-webserver-4 + * or composer-n1-webserver-8. Supported for Cloud Composer environments + * in versions composer-1.*.*-airflow-*.*.*. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/environments.update_environment.js + * region_tag:composer_v1_generated_Environments_UpdateEnvironment_async + */ + updateEnvironment( + request?: protos.google.cloud.orchestration.airflow.service.v1.IUpdateEnvironmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateEnvironment( + request: protos.google.cloud.orchestration.airflow.service.v1.IUpdateEnvironmentRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateEnvironment( + request: protos.google.cloud.orchestration.airflow.service.v1.IUpdateEnvironmentRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateEnvironment( + request?: protos.google.cloud.orchestration.airflow.service.v1.IUpdateEnvironmentRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateEnvironment(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateEnvironment()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/environments.update_environment.js + * region_tag:composer_v1_generated_Environments_UpdateEnvironment_async + */ + async checkUpdateEnvironmentProgress(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.updateEnvironment, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Delete an environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The environment to delete, in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/environments.delete_environment.js + * region_tag:composer_v1_generated_Environments_DeleteEnvironment_async + */ + deleteEnvironment( + request?: protos.google.cloud.orchestration.airflow.service.v1.IDeleteEnvironmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteEnvironment( + request: protos.google.cloud.orchestration.airflow.service.v1.IDeleteEnvironmentRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteEnvironment( + request: protos.google.cloud.orchestration.airflow.service.v1.IDeleteEnvironmentRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteEnvironment( + request?: protos.google.cloud.orchestration.airflow.service.v1.IDeleteEnvironmentRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteEnvironment(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteEnvironment()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/environments.delete_environment.js + * region_tag:composer_v1_generated_Environments_DeleteEnvironment_async + */ + async checkDeleteEnvironmentProgress(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.deleteEnvironment, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Creates a snapshots of a Cloud Composer environment. + * + * As a result of this operation, snapshot of environment's state is stored + * in a location specified in the SaveSnapshotRequest. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.environment + * The resource name of the source environment in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + * @param {string} request.snapshotLocation + * Location in a Cloud Storage where the snapshot is going to be stored, e.g.: + * "gs://my-bucket/snapshots". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/environments.save_snapshot.js + * region_tag:composer_v1_generated_Environments_SaveSnapshot_async + */ + saveSnapshot( + request?: protos.google.cloud.orchestration.airflow.service.v1.ISaveSnapshotRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + saveSnapshot( + request: protos.google.cloud.orchestration.airflow.service.v1.ISaveSnapshotRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + saveSnapshot( + request: protos.google.cloud.orchestration.airflow.service.v1.ISaveSnapshotRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + saveSnapshot( + request?: protos.google.cloud.orchestration.airflow.service.v1.ISaveSnapshotRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'environment': request.environment ?? '', + }); + this.initialize(); + return this.innerApiCalls.saveSnapshot(request, options, callback); + } +/** + * Check the status of the long running operation returned by `saveSnapshot()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/environments.save_snapshot.js + * region_tag:composer_v1_generated_Environments_SaveSnapshot_async + */ + async checkSaveSnapshotProgress(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.saveSnapshot, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Loads a snapshot of a Cloud Composer environment. + * + * As a result of this operation, a snapshot of environment's specified in + * LoadSnapshotRequest is loaded into the environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.environment + * The resource name of the target environment in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + * @param {string} request.snapshotPath + * A Cloud Storage path to a snapshot to load, e.g.: + * "gs://my-bucket/snapshots/project_location_environment_timestamp". + * @param {boolean} request.skipPypiPackagesInstallation + * Whether or not to skip installing Pypi packages when loading the + * environment's state. + * @param {boolean} request.skipEnvironmentVariablesSetting + * Whether or not to skip setting environment variables when loading the + * environment's state. + * @param {boolean} request.skipAirflowOverridesSetting + * Whether or not to skip setting Airflow overrides when loading the + * environment's state. + * @param {boolean} request.skipGcsDataCopying + * Whether or not to skip copying Cloud Storage data when loading the + * environment's state. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/environments.load_snapshot.js + * region_tag:composer_v1_generated_Environments_LoadSnapshot_async + */ + loadSnapshot( + request?: protos.google.cloud.orchestration.airflow.service.v1.ILoadSnapshotRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + loadSnapshot( + request: protos.google.cloud.orchestration.airflow.service.v1.ILoadSnapshotRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + loadSnapshot( + request: protos.google.cloud.orchestration.airflow.service.v1.ILoadSnapshotRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + loadSnapshot( + request?: protos.google.cloud.orchestration.airflow.service.v1.ILoadSnapshotRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'environment': request.environment ?? '', + }); + this.initialize(); + return this.innerApiCalls.loadSnapshot(request, options, callback); + } +/** + * Check the status of the long running operation returned by `loadSnapshot()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/environments.load_snapshot.js + * region_tag:composer_v1_generated_Environments_LoadSnapshot_async + */ + async checkLoadSnapshotProgress(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.loadSnapshot, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Triggers database failover (only for highly resilient environments). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.environment + * Target environment: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/environments.database_failover.js + * region_tag:composer_v1_generated_Environments_DatabaseFailover_async + */ + databaseFailover( + request?: protos.google.cloud.orchestration.airflow.service.v1.IDatabaseFailoverRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + databaseFailover( + request: protos.google.cloud.orchestration.airflow.service.v1.IDatabaseFailoverRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + databaseFailover( + request: protos.google.cloud.orchestration.airflow.service.v1.IDatabaseFailoverRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + databaseFailover( + request?: protos.google.cloud.orchestration.airflow.service.v1.IDatabaseFailoverRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'environment': request.environment ?? '', + }); + this.initialize(); + return this.innerApiCalls.databaseFailover(request, options, callback); + } +/** + * Check the status of the long running operation returned by `databaseFailover()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/environments.database_failover.js + * region_tag:composer_v1_generated_Environments_DatabaseFailover_async + */ + async checkDatabaseFailoverProgress(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.databaseFailover, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * List environments. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * List environments in the given project and location, in the form: + * "projects/{projectId}/locations/{locationId}" + * @param {number} request.pageSize + * The maximum number of environments to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.orchestration.airflow.service.v1.Environment|Environment}. + * 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 `listEnvironmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listEnvironments( + request?: protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1.IEnvironment[], + protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest|null, + protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsResponse + ]>; + listEnvironments( + request: protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest, + protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsResponse|null|undefined, + protos.google.cloud.orchestration.airflow.service.v1.IEnvironment>): void; + listEnvironments( + request: protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest, + callback: PaginationCallback< + protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest, + protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsResponse|null|undefined, + protos.google.cloud.orchestration.airflow.service.v1.IEnvironment>): void; + listEnvironments( + request?: protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest, + protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsResponse|null|undefined, + protos.google.cloud.orchestration.airflow.service.v1.IEnvironment>, + callback?: PaginationCallback< + protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest, + protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsResponse|null|undefined, + protos.google.cloud.orchestration.airflow.service.v1.IEnvironment>): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1.IEnvironment[], + protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest|null, + protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listEnvironments(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 + * List environments in the given project and location, in the form: + * "projects/{projectId}/locations/{locationId}" + * @param {number} request.pageSize + * The maximum number of environments to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.orchestration.airflow.service.v1.Environment|Environment} 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 `listEnvironmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listEnvironmentsStream( + request?: protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest, + 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['listEnvironments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listEnvironments.createStream( + this.innerApiCalls.listEnvironments as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listEnvironments`, 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 + * List environments in the given project and location, in the form: + * "projects/{projectId}/locations/{locationId}" + * @param {number} request.pageSize + * The maximum number of environments to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.orchestration.airflow.service.v1.Environment|Environment}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/environments.list_environments.js + * region_tag:composer_v1_generated_Environments_ListEnvironments_async + */ + listEnvironmentsAsync( + request?: protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest, + 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['listEnvironments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listEnvironments.asyncIterate( + this.innerApiCalls['listEnvironments'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * 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 environment resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} environment + * @returns {string} Resource name string. + */ + environmentPath(project:string,location:string,environment:string) { + return this.pathTemplates.environmentPathTemplate.render({ + project: project, + location: location, + environment: environment, + }); + } + + /** + * Parse the project from Environment resource. + * + * @param {string} environmentName + * A fully-qualified path representing Environment resource. + * @returns {string} A string representing the project. + */ + matchProjectFromEnvironmentName(environmentName: string) { + return this.pathTemplates.environmentPathTemplate.match(environmentName).project; + } + + /** + * Parse the location from Environment resource. + * + * @param {string} environmentName + * A fully-qualified path representing Environment resource. + * @returns {string} A string representing the location. + */ + matchLocationFromEnvironmentName(environmentName: string) { + return this.pathTemplates.environmentPathTemplate.match(environmentName).location; + } + + /** + * Parse the environment from Environment resource. + * + * @param {string} environmentName + * A fully-qualified path representing Environment resource. + * @returns {string} A string representing the environment. + */ + matchEnvironmentFromEnvironmentName(environmentName: string) { + return this.pathTemplates.environmentPathTemplate.match(environmentName).environment; + } + + /** + * 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.environmentsStub && !this._terminated) { + return this.environmentsStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_client_config.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_client_config.json new file mode 100644 index 00000000000..f6e68e30717 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_client_config.json @@ -0,0 +1,74 @@ +{ + "interfaces": { + "google.cloud.orchestration.airflow.service.v1.Environments": { + "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": { + "CreateEnvironment": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetEnvironment": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListEnvironments": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateEnvironment": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteEnvironment": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ExecuteAirflowCommand": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StopAirflowCommand": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "PollAirflowCommand": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SaveSnapshot": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "LoadSnapshot": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DatabaseFailover": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "FetchDatabaseProperties": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_proto_list.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_proto_list.json new file mode 100644 index 00000000000..674df9932cf --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_proto_list.json @@ -0,0 +1,5 @@ +[ + "../../protos/google/cloud/orchestration/airflow/service/v1/environments.proto", + "../../protos/google/cloud/orchestration/airflow/service/v1/image_versions.proto", + "../../protos/google/cloud/orchestration/airflow/service/v1/operations.proto" +] diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..0ab43de4e60 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/gapic_metadata.json @@ -0,0 +1,175 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.orchestration.airflow.service.v1", + "libraryPackage": "@google-cloud/orchestration-airflow", + "services": { + "Environments": { + "clients": { + "grpc": { + "libraryClient": "EnvironmentsClient", + "rpcs": { + "GetEnvironment": { + "methods": [ + "getEnvironment" + ] + }, + "ExecuteAirflowCommand": { + "methods": [ + "executeAirflowCommand" + ] + }, + "StopAirflowCommand": { + "methods": [ + "stopAirflowCommand" + ] + }, + "PollAirflowCommand": { + "methods": [ + "pollAirflowCommand" + ] + }, + "FetchDatabaseProperties": { + "methods": [ + "fetchDatabaseProperties" + ] + }, + "CreateEnvironment": { + "methods": [ + "createEnvironment" + ] + }, + "UpdateEnvironment": { + "methods": [ + "updateEnvironment" + ] + }, + "DeleteEnvironment": { + "methods": [ + "deleteEnvironment" + ] + }, + "SaveSnapshot": { + "methods": [ + "saveSnapshot" + ] + }, + "LoadSnapshot": { + "methods": [ + "loadSnapshot" + ] + }, + "DatabaseFailover": { + "methods": [ + "databaseFailover" + ] + }, + "ListEnvironments": { + "methods": [ + "listEnvironments", + "listEnvironmentsStream", + "listEnvironmentsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "EnvironmentsClient", + "rpcs": { + "GetEnvironment": { + "methods": [ + "getEnvironment" + ] + }, + "ExecuteAirflowCommand": { + "methods": [ + "executeAirflowCommand" + ] + }, + "StopAirflowCommand": { + "methods": [ + "stopAirflowCommand" + ] + }, + "PollAirflowCommand": { + "methods": [ + "pollAirflowCommand" + ] + }, + "FetchDatabaseProperties": { + "methods": [ + "fetchDatabaseProperties" + ] + }, + "CreateEnvironment": { + "methods": [ + "createEnvironment" + ] + }, + "UpdateEnvironment": { + "methods": [ + "updateEnvironment" + ] + }, + "DeleteEnvironment": { + "methods": [ + "deleteEnvironment" + ] + }, + "SaveSnapshot": { + "methods": [ + "saveSnapshot" + ] + }, + "LoadSnapshot": { + "methods": [ + "loadSnapshot" + ] + }, + "DatabaseFailover": { + "methods": [ + "databaseFailover" + ] + }, + "ListEnvironments": { + "methods": [ + "listEnvironments", + "listEnvironmentsStream", + "listEnvironmentsAsync" + ] + } + } + } + } + }, + "ImageVersions": { + "clients": { + "grpc": { + "libraryClient": "ImageVersionsClient", + "rpcs": { + "ListImageVersions": { + "methods": [ + "listImageVersions", + "listImageVersionsStream", + "listImageVersionsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageVersionsClient", + "rpcs": { + "ListImageVersions": { + "methods": [ + "listImageVersions", + "listImageVersionsStream", + "listImageVersionsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_client.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_client.ts new file mode 100644 index 00000000000..b5ec371ebed --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_client.ts @@ -0,0 +1,556 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/image_versions_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_versions_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Readonly service to query available ImageVersions. + * @class + * @memberof v1 + */ +export class ImageVersionsClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + imageVersionsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageVersionsClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 ImageVersionsClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ImageVersionsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + environmentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/environments/{environment}' + ), + }; + + // 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 = { + listImageVersions: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'imageVersions') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.orchestration.airflow.service.v1.ImageVersions', 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.imageVersionsStub) { + return this.imageVersionsStub; + } + + // Put together the "service stub" for + // google.cloud.orchestration.airflow.service.v1.ImageVersions. + this.imageVersionsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.orchestration.airflow.service.v1.ImageVersions') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.orchestration.airflow.service.v1.ImageVersions, + 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 imageVersionsStubMethods = + ['listImageVersions']; + for (const methodName of imageVersionsStubMethods) { + const callPromise = this.imageVersionsStub.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.imageVersionsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'composer.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 'composer.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 -- + // ------------------- + + /** + * List ImageVersions for provided location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * List ImageVersions in the given project and location, in the form: + * "projects/{projectId}/locations/{locationId}" + * @param {number} request.pageSize + * The maximum number of image_versions to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {boolean} request.includePastReleases + * Whether or not image versions from old releases should be included. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.orchestration.airflow.service.v1.ImageVersion|ImageVersion}. + * 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 `listImageVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listImageVersions( + request?: protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1.IImageVersion[], + protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest|null, + protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsResponse + ]>; + listImageVersions( + request: protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest, + protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsResponse|null|undefined, + protos.google.cloud.orchestration.airflow.service.v1.IImageVersion>): void; + listImageVersions( + request: protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest, + callback: PaginationCallback< + protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest, + protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsResponse|null|undefined, + protos.google.cloud.orchestration.airflow.service.v1.IImageVersion>): void; + listImageVersions( + request?: protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest, + protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsResponse|null|undefined, + protos.google.cloud.orchestration.airflow.service.v1.IImageVersion>, + callback?: PaginationCallback< + protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest, + protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsResponse|null|undefined, + protos.google.cloud.orchestration.airflow.service.v1.IImageVersion>): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1.IImageVersion[], + protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest|null, + protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listImageVersions(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 + * List ImageVersions in the given project and location, in the form: + * "projects/{projectId}/locations/{locationId}" + * @param {number} request.pageSize + * The maximum number of image_versions to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {boolean} request.includePastReleases + * Whether or not image versions from old releases should be included. + * @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 protos.google.cloud.orchestration.airflow.service.v1.ImageVersion|ImageVersion} 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 `listImageVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listImageVersionsStream( + request?: protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest, + 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['listImageVersions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listImageVersions.createStream( + this.innerApiCalls.listImageVersions as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listImageVersions`, 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 + * List ImageVersions in the given project and location, in the form: + * "projects/{projectId}/locations/{locationId}" + * @param {number} request.pageSize + * The maximum number of image_versions to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {boolean} request.includePastReleases + * Whether or not image versions from old releases should be included. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.orchestration.airflow.service.v1.ImageVersion|ImageVersion}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/image_versions.list_image_versions.js + * region_tag:composer_v1_generated_ImageVersions_ListImageVersions_async + */ + listImageVersionsAsync( + request?: protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest, + 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['listImageVersions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listImageVersions.asyncIterate( + this.innerApiCalls['listImageVersions'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified environment resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} environment + * @returns {string} Resource name string. + */ + environmentPath(project:string,location:string,environment:string) { + return this.pathTemplates.environmentPathTemplate.render({ + project: project, + location: location, + environment: environment, + }); + } + + /** + * Parse the project from Environment resource. + * + * @param {string} environmentName + * A fully-qualified path representing Environment resource. + * @returns {string} A string representing the project. + */ + matchProjectFromEnvironmentName(environmentName: string) { + return this.pathTemplates.environmentPathTemplate.match(environmentName).project; + } + + /** + * Parse the location from Environment resource. + * + * @param {string} environmentName + * A fully-qualified path representing Environment resource. + * @returns {string} A string representing the location. + */ + matchLocationFromEnvironmentName(environmentName: string) { + return this.pathTemplates.environmentPathTemplate.match(environmentName).location; + } + + /** + * Parse the environment from Environment resource. + * + * @param {string} environmentName + * A fully-qualified path representing Environment resource. + * @returns {string} A string representing the environment. + */ + matchEnvironmentFromEnvironmentName(environmentName: string) { + return this.pathTemplates.environmentPathTemplate.match(environmentName).environment; + } + + /** + * 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.imageVersionsStub && !this._terminated) { + return this.imageVersionsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_client_config.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_client_config.json new file mode 100644 index 00000000000..6ae2b5fc9c6 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_client_config.json @@ -0,0 +1,30 @@ +{ + "interfaces": { + "google.cloud.orchestration.airflow.service.v1.ImageVersions": { + "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": { + "ListImageVersions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_proto_list.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_proto_list.json new file mode 100644 index 00000000000..674df9932cf --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_proto_list.json @@ -0,0 +1,5 @@ +[ + "../../protos/google/cloud/orchestration/airflow/service/v1/environments.proto", + "../../protos/google/cloud/orchestration/airflow/service/v1/image_versions.proto", + "../../protos/google/cloud/orchestration/airflow/service/v1/operations.proto" +] diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/index.ts new file mode 100644 index 00000000000..f861aaef0c3 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {EnvironmentsClient} from './environments_client'; +export {ImageVersionsClient} from './image_versions_client'; diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..6621821e725 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const service = require('@google-cloud/orchestration-airflow'); + +function main() { + const environmentsClient = new service.EnvironmentsClient(); + const imageVersionsClient = new service.ImageVersionsClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..fe7224b8add --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {EnvironmentsClient, ImageVersionsClient} from '@google-cloud/orchestration-airflow'; + +// check that the client class type name can be used +function doStuffWithEnvironmentsClient(client: EnvironmentsClient) { + client.close(); +} +function doStuffWithImageVersionsClient(client: ImageVersionsClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const environmentsClient = new EnvironmentsClient(); + doStuffWithEnvironmentsClient(environmentsClient); + // check that the client instance can be created + const imageVersionsClient = new ImageVersionsClient(); + doStuffWithImageVersionsClient(imageVersionsClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/install.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/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-orchestration-airflow-service/v1/test/gapic_environments_v1.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/test/gapic_environments_v1.ts new file mode 100644 index 00000000000..7ded90c60b8 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/test/gapic_environments_v1.ts @@ -0,0 +1,2226 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 environmentsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.EnvironmentsClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = environmentsModule.v1.EnvironmentsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = environmentsModule.v1.EnvironmentsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = environmentsModule.v1.EnvironmentsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new environmentsModule.v1.EnvironmentsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.environmentsStub, undefined); + await client.initialize(); + assert(client.environmentsStub); + }); + + it('has close method for the initialized client', done => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.environmentsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.environmentsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new environmentsModule.v1.EnvironmentsClient({ + 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 environmentsModule.v1.EnvironmentsClient({ + 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('getEnvironment', () => { + it('invokes getEnvironment without error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.GetEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.GetEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.Environment() + ); + client.innerApiCalls.getEnvironment = stubSimpleCall(expectedResponse); + const [response] = await client.getEnvironment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEnvironment without error using callback', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.GetEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.GetEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.Environment() + ); + client.innerApiCalls.getEnvironment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getEnvironment( + request, + (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1.IEnvironment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEnvironment with error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.GetEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.GetEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getEnvironment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getEnvironment(request), expectedError); + const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEnvironment with closed client', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.GetEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.GetEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getEnvironment(request), expectedError); + }); + }); + + describe('executeAirflowCommand', () => { + it('invokes executeAirflowCommand without error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandResponse() + ); + client.innerApiCalls.executeAirflowCommand = stubSimpleCall(expectedResponse); + const [response] = await client.executeAirflowCommand(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.executeAirflowCommand as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.executeAirflowCommand as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executeAirflowCommand without error using callback', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandResponse() + ); + client.innerApiCalls.executeAirflowCommand = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.executeAirflowCommand( + request, + (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.executeAirflowCommand as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.executeAirflowCommand as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executeAirflowCommand with error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.executeAirflowCommand = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.executeAirflowCommand(request), expectedError); + const actualRequest = (client.innerApiCalls.executeAirflowCommand as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.executeAirflowCommand as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executeAirflowCommand with closed client', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.executeAirflowCommand(request), expectedError); + }); + }); + + describe('stopAirflowCommand', () => { + it('invokes stopAirflowCommand without error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandResponse() + ); + client.innerApiCalls.stopAirflowCommand = stubSimpleCall(expectedResponse); + const [response] = await client.stopAirflowCommand(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.stopAirflowCommand as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopAirflowCommand as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopAirflowCommand without error using callback', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandResponse() + ); + client.innerApiCalls.stopAirflowCommand = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.stopAirflowCommand( + request, + (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.stopAirflowCommand as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopAirflowCommand as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopAirflowCommand with error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopAirflowCommand = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.stopAirflowCommand(request), expectedError); + const actualRequest = (client.innerApiCalls.stopAirflowCommand as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopAirflowCommand as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopAirflowCommand with closed client', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.stopAirflowCommand(request), expectedError); + }); + }); + + describe('pollAirflowCommand', () => { + it('invokes pollAirflowCommand without error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandResponse() + ); + client.innerApiCalls.pollAirflowCommand = stubSimpleCall(expectedResponse); + const [response] = await client.pollAirflowCommand(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pollAirflowCommand as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pollAirflowCommand as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pollAirflowCommand without error using callback', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandResponse() + ); + client.innerApiCalls.pollAirflowCommand = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.pollAirflowCommand( + request, + (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pollAirflowCommand as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pollAirflowCommand as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pollAirflowCommand with error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.pollAirflowCommand = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.pollAirflowCommand(request), expectedError); + const actualRequest = (client.innerApiCalls.pollAirflowCommand as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pollAirflowCommand as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pollAirflowCommand with closed client', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.pollAirflowCommand(request), expectedError); + }); + }); + + describe('fetchDatabaseProperties', () => { + it('invokes fetchDatabaseProperties without error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesResponse() + ); + client.innerApiCalls.fetchDatabaseProperties = stubSimpleCall(expectedResponse); + const [response] = await client.fetchDatabaseProperties(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes fetchDatabaseProperties without error using callback', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesResponse() + ); + client.innerApiCalls.fetchDatabaseProperties = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.fetchDatabaseProperties( + request, + (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes fetchDatabaseProperties with error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.fetchDatabaseProperties = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.fetchDatabaseProperties(request), expectedError); + const actualRequest = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes fetchDatabaseProperties with closed client', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesRequest', ['environment']); + request.environment = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.fetchDatabaseProperties(request), expectedError); + }); + }); + + describe('createEnvironment', () => { + it('invokes createEnvironment without error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.CreateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.CreateEnvironmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createEnvironment = stubLongRunningCall(expectedResponse); + const [operation] = await client.createEnvironment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createEnvironment without error using callback', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.CreateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.CreateEnvironmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createEnvironment = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createEnvironment( + request, + (err?: Error|null, + result?: 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.createEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createEnvironment with call error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.CreateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.CreateEnvironmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEnvironment = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createEnvironment(request), expectedError); + const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createEnvironment with LRO error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.CreateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.CreateEnvironmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEnvironment = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createEnvironment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateEnvironmentProgress without error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateEnvironmentProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateEnvironmentProgress with error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateEnvironmentProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateEnvironment', () => { + it('invokes updateEnvironment without error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.UpdateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.UpdateEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateEnvironment = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateEnvironment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateEnvironment without error using callback', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.UpdateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.UpdateEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateEnvironment = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateEnvironment( + request, + (err?: Error|null, + result?: 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.updateEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateEnvironment with call error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.UpdateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.UpdateEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateEnvironment = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateEnvironment(request), expectedError); + const actualRequest = (client.innerApiCalls.updateEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateEnvironment with LRO error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.UpdateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.UpdateEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateEnvironment = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateEnvironment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateEnvironmentProgress without error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateEnvironmentProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateEnvironmentProgress with error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateEnvironmentProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteEnvironment', () => { + it('invokes deleteEnvironment without error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.DeleteEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.DeleteEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteEnvironment = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteEnvironment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteEnvironment without error using callback', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.DeleteEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.DeleteEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteEnvironment = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteEnvironment( + request, + (err?: Error|null, + result?: 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.deleteEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteEnvironment with call error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.DeleteEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.DeleteEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteEnvironment = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteEnvironment(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteEnvironment with LRO error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.DeleteEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.DeleteEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteEnvironment = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteEnvironment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteEnvironmentProgress without error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteEnvironmentProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteEnvironmentProgress with error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteEnvironmentProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('saveSnapshot', () => { + it('invokes saveSnapshot without error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.SaveSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.SaveSnapshotRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.saveSnapshot = stubLongRunningCall(expectedResponse); + const [operation] = await client.saveSnapshot(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.saveSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.saveSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes saveSnapshot without error using callback', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.SaveSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.SaveSnapshotRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.saveSnapshot = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.saveSnapshot( + request, + (err?: Error|null, + result?: 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.saveSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.saveSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes saveSnapshot with call error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.SaveSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.SaveSnapshotRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.saveSnapshot = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.saveSnapshot(request), expectedError); + const actualRequest = (client.innerApiCalls.saveSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.saveSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes saveSnapshot with LRO error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.SaveSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.SaveSnapshotRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.saveSnapshot = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.saveSnapshot(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.saveSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.saveSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkSaveSnapshotProgress without error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkSaveSnapshotProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkSaveSnapshotProgress with error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkSaveSnapshotProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('loadSnapshot', () => { + it('invokes loadSnapshot without error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.LoadSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.LoadSnapshotRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.loadSnapshot = stubLongRunningCall(expectedResponse); + const [operation] = await client.loadSnapshot(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.loadSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.loadSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes loadSnapshot without error using callback', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.LoadSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.LoadSnapshotRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.loadSnapshot = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.loadSnapshot( + request, + (err?: Error|null, + result?: 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.loadSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.loadSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes loadSnapshot with call error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.LoadSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.LoadSnapshotRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.loadSnapshot = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.loadSnapshot(request), expectedError); + const actualRequest = (client.innerApiCalls.loadSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.loadSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes loadSnapshot with LRO error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.LoadSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.LoadSnapshotRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.loadSnapshot = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.loadSnapshot(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.loadSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.loadSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkLoadSnapshotProgress without error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkLoadSnapshotProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkLoadSnapshotProgress with error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkLoadSnapshotProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('databaseFailover', () => { + it('invokes databaseFailover without error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.DatabaseFailoverRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.DatabaseFailoverRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.databaseFailover = stubLongRunningCall(expectedResponse); + const [operation] = await client.databaseFailover(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.databaseFailover as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.databaseFailover as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes databaseFailover without error using callback', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.DatabaseFailoverRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.DatabaseFailoverRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.databaseFailover = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.databaseFailover( + request, + (err?: Error|null, + result?: 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.databaseFailover as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.databaseFailover as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes databaseFailover with call error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.DatabaseFailoverRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.DatabaseFailoverRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.databaseFailover = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.databaseFailover(request), expectedError); + const actualRequest = (client.innerApiCalls.databaseFailover as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.databaseFailover as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes databaseFailover with LRO error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.DatabaseFailoverRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.DatabaseFailoverRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.databaseFailover = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.databaseFailover(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.databaseFailover as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.databaseFailover as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDatabaseFailoverProgress without error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDatabaseFailoverProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDatabaseFailoverProgress with error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDatabaseFailoverProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listEnvironments', () => { + it('invokes listEnvironments without error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), + ]; + client.innerApiCalls.listEnvironments = stubSimpleCall(expectedResponse); + const [response] = await client.listEnvironments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listEnvironments without error using callback', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), + ]; + client.innerApiCalls.listEnvironments = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listEnvironments( + request, + (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1.IEnvironment[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listEnvironments with error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listEnvironments = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listEnvironments(request), expectedError); + const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listEnvironmentsStream without error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), + ]; + client.descriptors.page.listEnvironments.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listEnvironmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.orchestration.airflow.service.v1.Environment[] = []; + stream.on('data', (response: protos.google.cloud.orchestration.airflow.service.v1.Environment) => { + 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.listEnvironments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listEnvironments, request)); + assert( + (client.descriptors.page.listEnvironments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listEnvironmentsStream with error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEnvironments.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listEnvironmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.orchestration.airflow.service.v1.Environment[] = []; + stream.on('data', (response: protos.google.cloud.orchestration.airflow.service.v1.Environment) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listEnvironments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listEnvironments, request)); + assert( + (client.descriptors.page.listEnvironments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listEnvironments without error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), + ]; + client.descriptors.page.listEnvironments.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.orchestration.airflow.service.v1.IEnvironment[] = []; + const iterable = client.listEnvironmentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listEnvironments with error', async () => { + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEnvironments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listEnvironmentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.orchestration.airflow.service.v1.IEnvironment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listEnvironments.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 environmentsModule.v1.EnvironmentsClient({ + 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 environmentsModule.v1.EnvironmentsClient({ + 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 environmentsModule.v1.EnvironmentsClient({ + 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 environmentsModule.v1.EnvironmentsClient({ + 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 environmentsModule.v1.EnvironmentsClient({ + 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 environmentsModule.v1.EnvironmentsClient({ + 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 environmentsModule.v1.EnvironmentsClient({ + 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 environmentsModule.v1.EnvironmentsClient({ + 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 environmentsModule.v1.EnvironmentsClient({ + 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 environmentsModule.v1.EnvironmentsClient({ + 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 environmentsModule.v1.EnvironmentsClient({ + 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('environment', () => { + const fakePath = "/rendered/path/environment"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + environment: "environmentValue", + }; + const client = new environmentsModule.v1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.environmentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.environmentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('environmentPath', () => { + const result = client.environmentPath("projectValue", "locationValue", "environmentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.environmentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromEnvironmentName', () => { + const result = client.matchProjectFromEnvironmentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromEnvironmentName', () => { + const result = client.matchLocationFromEnvironmentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchEnvironmentFromEnvironmentName', () => { + const result = client.matchEnvironmentFromEnvironmentName(fakePath); + assert.strictEqual(result, "environmentValue"); + assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/test/gapic_image_versions_v1.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/test/gapic_image_versions_v1.ts new file mode 100644 index 00000000000..ea0470ef6f0 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/test/gapic_image_versions_v1.ts @@ -0,0 +1,491 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 imageversionsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.ImageVersionsClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageversionsModule.v1.ImageVersionsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageversionsModule.v1.ImageVersionsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageversionsModule.v1.ImageVersionsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageversionsModule.v1.ImageVersionsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageversionsModule.v1.ImageVersionsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageversionsModule.v1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageVersionsStub, undefined); + await client.initialize(); + assert(client.imageVersionsStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageversionsModule.v1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageVersionsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageversionsModule.v1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageVersionsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageversionsModule.v1.ImageVersionsClient({ + 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 imageversionsModule.v1.ImageVersionsClient({ + 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('listImageVersions', () => { + it('invokes listImageVersions without error', async () => { + const client = new imageversionsModule.v1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), + ]; + client.innerApiCalls.listImageVersions = stubSimpleCall(expectedResponse); + const [response] = await client.listImageVersions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listImageVersions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listImageVersions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listImageVersions without error using callback', async () => { + const client = new imageversionsModule.v1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), + ]; + client.innerApiCalls.listImageVersions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listImageVersions( + request, + (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1.IImageVersion[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listImageVersions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listImageVersions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listImageVersions with error', async () => { + const client = new imageversionsModule.v1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listImageVersions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listImageVersions(request), expectedError); + const actualRequest = (client.innerApiCalls.listImageVersions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listImageVersions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listImageVersionsStream without error', async () => { + const client = new imageversionsModule.v1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), + ]; + client.descriptors.page.listImageVersions.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listImageVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.orchestration.airflow.service.v1.ImageVersion[] = []; + stream.on('data', (response: protos.google.cloud.orchestration.airflow.service.v1.ImageVersion) => { + 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.listImageVersions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listImageVersions, request)); + assert( + (client.descriptors.page.listImageVersions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listImageVersionsStream with error', async () => { + const client = new imageversionsModule.v1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listImageVersions.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listImageVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.orchestration.airflow.service.v1.ImageVersion[] = []; + stream.on('data', (response: protos.google.cloud.orchestration.airflow.service.v1.ImageVersion) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listImageVersions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listImageVersions, request)); + assert( + (client.descriptors.page.listImageVersions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listImageVersions without error', async () => { + const client = new imageversionsModule.v1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), + ]; + client.descriptors.page.listImageVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.orchestration.airflow.service.v1.IImageVersion[] = []; + const iterable = client.listImageVersionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listImageVersions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listImageVersions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listImageVersions with error', async () => { + const client = new imageversionsModule.v1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listImageVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listImageVersionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.orchestration.airflow.service.v1.IImageVersion[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listImageVersions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listImageVersions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('environment', () => { + const fakePath = "/rendered/path/environment"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + environment: "environmentValue", + }; + const client = new imageversionsModule.v1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.environmentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.environmentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('environmentPath', () => { + const result = client.environmentPath("projectValue", "locationValue", "environmentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.environmentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromEnvironmentName', () => { + const result = client.matchProjectFromEnvironmentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromEnvironmentName', () => { + const result = client.matchLocationFromEnvironmentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchEnvironmentFromEnvironmentName', () => { + const result = client.matchEnvironmentFromEnvironmentName(fakePath); + assert.strictEqual(result, "environmentValue"); + assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/tsconfig.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/webpack.config.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/webpack.config.js new file mode 100644 index 00000000000..9b7becac60a --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'Environments', + filename: './environments.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-orchestration-airflow-service/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.gitignore b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.jsdoc.js new file mode 100644 index 00000000000..1eacba42fba --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.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/orchestration-airflow', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.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-orchestration-airflow-service/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.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-orchestration-airflow-service/v1beta1/README.md b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/README.md new file mode 100644 index 00000000000..536af38a9bb --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/README.md @@ -0,0 +1 @@ +Service: Nodejs Client diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/package.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/package.json new file mode 100644 index 00000000000..42943d9c4a6 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/package.json @@ -0,0 +1,59 @@ +{ + "name": "@google-cloud/orchestration-airflow", + "version": "0.1.0", + "description": "Service client for Node.js", + "repository": "googleapis/nodejs-service", + "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 service", + "service", + "environments", + "image versions" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/environments.proto b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/environments.proto new file mode 100644 index 00000000000..51da9f3c152 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/environments.proto @@ -0,0 +1,1530 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.orchestration.airflow.service.v1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/orchestration/airflow/service/v1beta1/operations.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "cloud.google.com/go/orchestration/airflow/service/apiv1beta1/servicepb;servicepb"; +option java_multiple_files = true; +option java_package = "com.google.cloud.orchestration.airflow.service.v1beta1"; + +// Managed Apache Airflow Environments. +service Environments { + option (google.api.default_host) = "composer.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Create a new environment. + rpc CreateEnvironment(CreateEnvironmentRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*/locations/*}/environments" + body: "environment" + }; + option (google.api.method_signature) = "parent,environment"; + option (google.longrunning.operation_info) = { + response_type: "Environment" + metadata_type: "google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata" + }; + } + + // Get an existing environment. + rpc GetEnvironment(GetEnvironmentRequest) returns (Environment) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/locations/*/environments/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List environments. + rpc ListEnvironments(ListEnvironmentsRequest) + returns (ListEnvironmentsResponse) { + option (google.api.http) = { + get: "/v1beta1/{parent=projects/*/locations/*}/environments" + }; + option (google.api.method_signature) = "parent"; + } + + // Update an environment. + rpc UpdateEnvironment(UpdateEnvironmentRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1beta1/{name=projects/*/locations/*/environments/*}" + body: "environment" + }; + option (google.api.method_signature) = "name,environment,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "Environment" + metadata_type: "google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata" + }; + } + + // Delete an environment. + rpc DeleteEnvironment(DeleteEnvironmentRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1beta1/{name=projects/*/locations/*/environments/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata" + }; + } + + // Restart Airflow web server. + rpc RestartWebServer(RestartWebServerRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/environments/*}:restartWebServer" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Environment" + metadata_type: "google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata" + }; + } + + // Check if an upgrade operation on the environment will succeed. + // + // In case of problems detailed info can be found in the returned Operation. + rpc CheckUpgrade(CheckUpgradeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{environment=projects/*/locations/*/environments/*}:checkUpgrade" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeResponse" + metadata_type: "google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata" + }; + } + + // Executes Airflow CLI command. + rpc ExecuteAirflowCommand(ExecuteAirflowCommandRequest) + returns (ExecuteAirflowCommandResponse) { + option (google.api.http) = { + post: "/v1beta1/{environment=projects/*/locations/*/environments/*}:executeAirflowCommand" + body: "*" + }; + } + + // Stops Airflow CLI command execution. + rpc StopAirflowCommand(StopAirflowCommandRequest) + returns (StopAirflowCommandResponse) { + option (google.api.http) = { + post: "/v1beta1/{environment=projects/*/locations/*/environments/*}:stopAirflowCommand" + body: "*" + }; + } + + // Polls Airflow CLI command execution and fetches logs. + rpc PollAirflowCommand(PollAirflowCommandRequest) + returns (PollAirflowCommandResponse) { + option (google.api.http) = { + post: "/v1beta1/{environment=projects/*/locations/*/environments/*}:pollAirflowCommand" + body: "*" + }; + } + + // Creates a snapshots of a Cloud Composer environment. + // + // As a result of this operation, snapshot of environment's state is stored + // in a location specified in the SaveSnapshotRequest. + rpc SaveSnapshot(SaveSnapshotRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{environment=projects/*/locations/*/environments/*}:saveSnapshot" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.orchestration.airflow.service.v1beta1.SaveSnapshotResponse" + metadata_type: "google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata" + }; + } + + // Loads a snapshot of a Cloud Composer environment. + // + // As a result of this operation, a snapshot of environment's specified in + // LoadSnapshotRequest is loaded into the environment. + rpc LoadSnapshot(LoadSnapshotRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{environment=projects/*/locations/*/environments/*}:loadSnapshot" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.orchestration.airflow.service.v1beta1.LoadSnapshotResponse" + metadata_type: "google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata" + }; + } + + // Triggers database failover (only for highly resilient environments). + rpc DatabaseFailover(DatabaseFailoverRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{environment=projects/*/locations/*/environments/*}:databaseFailover" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverResponse" + metadata_type: "google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata" + }; + } + + // Fetches database properties. + rpc FetchDatabaseProperties(FetchDatabasePropertiesRequest) + returns (FetchDatabasePropertiesResponse) { + option (google.api.http) = { + get: "/v1beta1/{environment=projects/*/locations/*/environments/*}:fetchDatabaseProperties" + }; + } +} + +// Create a new environment. +message CreateEnvironmentRequest { + // The parent must be of the form + // "projects/{projectId}/locations/{locationId}". + string parent = 1; + + // The environment to create. + Environment environment = 2; +} + +// Get an environment. +message GetEnvironmentRequest { + // The resource name of the environment to get, in the form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + string name = 1; +} + +// List environments in a project and location. +message ListEnvironmentsRequest { + // List environments in the given project and location, in the form: + // "projects/{projectId}/locations/{locationId}" + string parent = 1; + + // The maximum number of environments to return. + int32 page_size = 2; + + // The next_page_token value returned from a previous List request, if any. + string page_token = 3; +} + +// The environments in a project and location. +message ListEnvironmentsResponse { + // The list of environments returned by a ListEnvironmentsRequest. + repeated Environment environments = 1; + + // The page token used to query for the next page if one exists. + string next_page_token = 2; +} + +// Delete an environment. +message DeleteEnvironmentRequest { + // The environment to delete, in the form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + string name = 1; +} + +// Update an environment. +message UpdateEnvironmentRequest { + // The relative resource name of the environment to update, in the form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + string name = 2; + + // A patch environment. Fields specified by the `updateMask` will be copied + // from the patch environment into the environment under update. + Environment environment = 1; + + // Required. A comma-separated list of paths, relative to `Environment`, of + // fields to update. + // For example, to set the version of scikit-learn to install in the + // environment to 0.19.0 and to remove an existing installation of + // argparse, the `updateMask` parameter would include the following two + // `paths` values: "config.softwareConfig.pypiPackages.scikit-learn" and + // "config.softwareConfig.pypiPackages.argparse". The included patch + // environment would specify the scikit-learn version as follows: + // + // { + // "config":{ + // "softwareConfig":{ + // "pypiPackages":{ + // "scikit-learn":"==0.19.0" + // } + // } + // } + // } + // + // Note that in the above example, any existing PyPI packages + // other than scikit-learn and argparse will be unaffected. + // + // Only one update type may be included in a single request's `updateMask`. + // For example, one cannot update both the PyPI packages and + // labels in the same request. However, it is possible to update multiple + // members of a map field simultaneously in the same request. For example, + // to set the labels "label1" and "label2" while clearing "label3" (assuming + // it already exists), one can + // provide the paths "labels.label1", "labels.label2", and "labels.label3" + // and populate the patch environment as follows: + // + // { + // "labels":{ + // "label1":"new-label1-value" + // "label2":"new-label2-value" + // } + // } + // + // Note that in the above example, any existing labels that are not + // included in the `updateMask` will be unaffected. + // + // It is also possible to replace an entire map field by providing the + // map field's path in the `updateMask`. The new value of the field will + // be that which is provided in the patch environment. For example, to + // delete all pre-existing user-specified PyPI packages and + // install botocore at version 1.7.14, the `updateMask` would contain + // the path "config.softwareConfig.pypiPackages", and + // the patch environment would be the following: + // + // { + // "config":{ + // "softwareConfig":{ + // "pypiPackages":{ + // "botocore":"==1.7.14" + // } + // } + // } + // } + // + // **Note:** Only the following fields can be updated: + // + // * `config.softwareConfig.pypiPackages` + // * Replace all custom custom PyPI packages. If a replacement + // package map is not included in `environment`, all custom + // PyPI packages are cleared. It is an error to provide both + // this mask and a mask specifying an individual package. + // * `config.softwareConfig.pypiPackages.`packagename + // * Update the custom PyPI package *packagename*, + // preserving other packages. To delete the package, include it in + // `updateMask`, and omit the mapping for it in + // `environment.config.softwareConfig.pypiPackages`. It is an error + // to provide both a mask of this form and the + // `config.softwareConfig.pypiPackages` mask. + // * `labels` + // * Replace all environment labels. If a replacement labels map is not + // included in `environment`, all labels are cleared. It is an error to + // provide both this mask and a mask specifying one or more individual + // labels. + // * `labels.`labelName + // * Set the label named *labelName*, while preserving other + // labels. To delete the label, include it in `updateMask` and omit its + // mapping in `environment.labels`. It is an error to provide both a + // mask of this form and the `labels` mask. + // * `config.nodeCount` + // * Horizontally scale the number of nodes in the environment. An integer + // greater than or equal to 3 must be provided in the `config.nodeCount` + // field. Supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + // * `config.webServerNetworkAccessControl` + // * Replace the environment's current WebServerNetworkAccessControl. + // * `config.softwareConfig.airflowConfigOverrides` + // * Replace all Apache Airflow config overrides. If a replacement config + // overrides map is not included in `environment`, all config overrides + // are cleared. + // It is an error to provide both this mask and a mask specifying one or + // more individual config overrides. + // * `config.softwareConfig.airflowConfigOverrides.`section-name + // * Override the Apache Airflow config property *name* in the + // section named *section*, preserving other properties. To + // delete the property override, include it in `updateMask` and omit its + // mapping in + // `environment.config.softwareConfig.airflowConfigOverrides`. + // It is an error to provide both a mask of this form and the + // `config.softwareConfig.airflowConfigOverrides` mask. + // * `config.softwareConfig.envVariables` + // * Replace all environment variables. If a replacement environment + // variable map is not included in `environment`, all custom environment + // variables are cleared. + // * `config.softwareConfig.imageVersion` + // * Upgrade the version of the environment in-place. Refer to + // `SoftwareConfig.image_version` for information on how to format the + // new image version. Additionally, the new image version cannot effect + // a version downgrade, and must match the current image version's + // Composer and Airflow major versions. Consult the [Cloud Composer + // version list](/composer/docs/concepts/versioning/composer-versions) + // for valid values. + // * `config.softwareConfig.schedulerCount` + // * Horizontally scale the number of schedulers in Airflow. A positive + // integer not greater than the number of nodes must be provided in the + // `config.softwareConfig.schedulerCount` field. Supported for Cloud + // Composer environments in versions composer-1.*.*-airflow-2.*.*. + // * `config.softwareConfig.cloudDataLineageIntegration` + // * Configuration for Cloud Data Lineage integration. + // * `config.databaseConfig.machineType` + // * Cloud SQL machine type used by Airflow database. + // It has to be one of: db-n1-standard-2, db-n1-standard-4, + // db-n1-standard-8 or db-n1-standard-16. Supported for Cloud Composer + // environments in versions composer-1.*.*-airflow-*.*.*. + // * `config.webServerConfig.machineType` + // * Machine type on which Airflow web server is running. + // It has to be one of: composer-n1-webserver-2, composer-n1-webserver-4 + // or composer-n1-webserver-8. Supported for Cloud Composer environments + // in versions composer-1.*.*-airflow-*.*.*. + // * `config.maintenanceWindow` + // * Maintenance window during which Cloud Composer components may be + // under maintenance. + // * `config.workloadsConfig` + // * The workloads configuration settings for the GKE cluster associated + // with the Cloud Composer environment. Supported for Cloud Composer + // environments in versions composer-2.*.*-airflow-*.*.* and newer. + // * `config.environmentSize` + // * The size of the Cloud Composer environment. Supported for Cloud + // Composer environments in versions composer-2.*.*-airflow-*.*.* and + // newer. + google.protobuf.FieldMask update_mask = 3 + [(google.api.field_behavior) = REQUIRED]; +} + +// Restart Airflow web server. +message RestartWebServerRequest { + // The resource name of the environment to restart the web server for, in the + // form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + string name = 1; +} + +// Execute Airflow Command request. +message ExecuteAirflowCommandRequest { + // The resource name of the environment in the form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}". + string environment = 1; + + // Airflow command. + string command = 2; + + // Airflow subcommand. + string subcommand = 3; + + // Parameters for the Airflow command/subcommand as an array of arguments. + // It may contain positional arguments like `["my-dag-id"]`, key-value + // parameters like `["--foo=bar"]` or `["--foo","bar"]`, + // or other flags like `["-f"]`. + repeated string parameters = 4; +} + +// Response to ExecuteAirflowCommandRequest. +message ExecuteAirflowCommandResponse { + // The unique ID of the command execution for polling. + string execution_id = 1; + + // The name of the pod where the command is executed. + string pod = 2; + + // The namespace of the pod where the command is executed. + string pod_namespace = 3; + + // Error message. Empty if there was no error. + string error = 4; +} + +// Stop Airflow Command request. +message StopAirflowCommandRequest { + // The resource name of the environment in the form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}". + string environment = 1; + + // The unique ID of the command execution. + string execution_id = 2; + + // The name of the pod where the command is executed. + string pod = 3; + + // The namespace of the pod where the command is executed. + string pod_namespace = 4; + + // If true, the execution is terminated forcefully (SIGKILL). If false, the + // execution is stopped gracefully, giving it time for cleanup. + bool force = 5; +} + +// Response to StopAirflowCommandRequest. +message StopAirflowCommandResponse { + // Whether the execution is still running. + bool is_done = 1; + + // Output message from stopping execution request. + repeated string output = 2; +} + +// Poll Airflow Command request. +message PollAirflowCommandRequest { + // The resource name of the environment in the form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + string environment = 1; + + // The unique ID of the command execution. + string execution_id = 2; + + // The name of the pod where the command is executed. + string pod = 3; + + // The namespace of the pod where the command is executed. + string pod_namespace = 4; + + // Line number from which new logs should be fetched. + int32 next_line_number = 5; +} + +// Response to PollAirflowCommandRequest. +message PollAirflowCommandResponse { + // Contains information about a single line from logs. + message Line { + // Number of the line. + int32 line_number = 1; + + // Text content of the log line. + string content = 2; + } + + // Information about how a command ended. + message ExitInfo { + // The exit code from the command execution. + int32 exit_code = 1; + + // Error message. Empty if there was no error. + string error = 2; + } + + // Output from the command execution. It may not contain the full output + // and the caller may need to poll for more lines. + repeated Line output = 1; + + // Whether the command execution has finished and there is no more output. + bool output_end = 2; + + // The result exit status of the command. + ExitInfo exit_info = 3; +} + +// Request to create a snapshot of a Cloud Composer environment. +message SaveSnapshotRequest { + // The resource name of the source environment in the form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + string environment = 1; + + // Location in a Cloud Storage where the snapshot is going to be stored, e.g.: + // "gs://my-bucket/snapshots". + string snapshot_location = 2; +} + +// Response to SaveSnapshotRequest. +message SaveSnapshotResponse { + // The fully-resolved Cloud Storage path of the created snapshot, + // e.g.: + // "gs://my-bucket/snapshots/project_location_environment_timestamp". + // This field is populated only if the snapshot creation was successful. + string snapshot_path = 1; +} + +// Request to load a snapshot into a Cloud Composer environment. +message LoadSnapshotRequest { + // The resource name of the target environment in the form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + string environment = 1; + + // A Cloud Storage path to a snapshot to load, e.g.: + // "gs://my-bucket/snapshots/project_location_environment_timestamp". + string snapshot_path = 2; + + // Whether or not to skip installing Pypi packages when loading the + // environment's state. + bool skip_pypi_packages_installation = 3; + + // Whether or not to skip setting environment variables when loading the + // environment's state. + bool skip_environment_variables_setting = 4; + + // Whether or not to skip setting Airflow overrides when loading the + // environment's state. + bool skip_airflow_overrides_setting = 5; + + // Whether or not to skip copying Cloud Storage data when loading the + // environment's state. + bool skip_gcs_data_copying = 6; +} + +// Response to LoadSnapshotRequest. +message LoadSnapshotResponse {} + +// Request to trigger database failover (only for highly resilient +// environments). +message DatabaseFailoverRequest { + // Target environment: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + string environment = 1; +} + +// Response for DatabaseFailoverRequest. +message DatabaseFailoverResponse {} + +// Request to fetch properties of environment's database. +message FetchDatabasePropertiesRequest { + // Required. The resource name of the environment, in the form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + string environment = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "composer.googleapis.com/Environment" + } + ]; +} + +// Response for FetchDatabasePropertiesRequest. +message FetchDatabasePropertiesResponse { + // The Compute Engine zone that the instance is currently serving from. + string primary_gce_zone = 1; + + // The Compute Engine zone that the failover instance is currently serving + // from for a regional Cloud SQL instance. + string secondary_gce_zone = 2; + + // The availability status of the failover replica. A false status indicates + // that the failover replica is out of sync. The primary instance can only + // fail over to the failover replica when the status is true. + bool is_failover_replica_available = 3; +} + +// Configuration information for an environment. +message EnvironmentConfig { + // The size of the Cloud Composer environment. + enum EnvironmentSize { + // The size of the environment is unspecified. + ENVIRONMENT_SIZE_UNSPECIFIED = 0; + + // The environment size is small. + ENVIRONMENT_SIZE_SMALL = 1; + + // The environment size is medium. + ENVIRONMENT_SIZE_MEDIUM = 2; + + // The environment size is large. + ENVIRONMENT_SIZE_LARGE = 3; + } + + // Resilience mode of the Cloud Composer Environment. + enum ResilienceMode { + // Default mode doesn't change environment parameters. + RESILIENCE_MODE_UNSPECIFIED = 0; + + // Enabled High Resilience mode, including Cloud SQL HA. + HIGH_RESILIENCE = 1; + } + + // Output only. The Kubernetes Engine cluster used to run this environment. + string gke_cluster = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Cloud Storage prefix of the DAGs for this environment. + // Although Cloud Storage objects reside in a flat namespace, a hierarchical + // file tree can be simulated using "/"-delimited object name prefixes. DAG + // objects for this environment reside in a simulated directory with the given + // prefix. + string dag_gcs_prefix = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The number of nodes in the Kubernetes Engine cluster that will be + // used to run this environment. + // + // This field is supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + int32 node_count = 3; + + // The configuration settings for software inside the environment. + SoftwareConfig software_config = 4; + + // The configuration used for the Kubernetes Engine cluster. + NodeConfig node_config = 5; + + // The configuration used for the Private IP Cloud Composer environment. + PrivateEnvironmentConfig private_environment_config = 7; + + // Optional. The network-level access control policy for the Airflow web + // server. If unspecified, no network-level access restrictions will be + // applied. + WebServerNetworkAccessControl web_server_network_access_control = 9 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The configuration settings for Cloud SQL instance used internally + // by Apache Airflow software. + DatabaseConfig database_config = 10 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The configuration settings for the Airflow web server App Engine + // instance. + // + // This field is supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + WebServerConfig web_server_config = 11 + [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The URI of the Apache Airflow Web UI hosted within this + // environment (see [Airflow web + // interface](/composer/docs/how-to/accessing/airflow-web-interface)). + string airflow_uri = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The 'bring your own identity' variant of the URI of the Apache + // Airflow Web UI hosted within this environment, to be accessed with external + // identities using workforce identity federation (see [Access environments + // with workforce identity + // federation](/composer/docs/composer-2/access-environments-with-workforce-identity-federation)). + string airflow_byoid_uri = 21 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. The encryption options for the Cloud Composer environment and its + // dependencies. Cannot be updated. + EncryptionConfig encryption_config = 12 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maintenance window is the period when Cloud Composer + // components may undergo maintenance. It is defined so that maintenance is + // not executed during peak hours or critical time periods. + // + // The system will not be under maintenance for every occurrence of this + // window, but when maintenance is planned, it will be scheduled + // during the window. + // + // The maintenance window period must encompass at least 12 hours per week. + // This may be split into multiple chunks, each with a size of + // at least 4 hours. + // + // If this value is omitted, Cloud Composer components may be subject to + // maintenance at any time. + MaintenanceWindow maintenance_window = 13 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The workloads configuration settings for the GKE cluster + // associated with the Cloud Composer environment. The GKE cluster runs + // Airflow scheduler, web server and workers workloads. + // + // This field is supported for Cloud Composer environments in versions + // composer-2.*.*-airflow-*.*.* and newer. + WorkloadsConfig workloads_config = 15 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The size of the Cloud Composer environment. + // + // This field is supported for Cloud Composer environments in versions + // composer-2.*.*-airflow-*.*.* and newer. + EnvironmentSize environment_size = 16 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The configuration options for GKE cluster master authorized + // networks. By default master authorized networks feature is: + // - in case of private environment: enabled with no external networks + // allowlisted. + // - in case of public environment: disabled. + MasterAuthorizedNetworksConfig master_authorized_networks_config = 17 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The Recovery settings configuration of an environment. + // + // This field is supported for Cloud Composer environments in versions + // composer-2.*.*-airflow-*.*.* and newer. + RecoveryConfig recovery_config = 18 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Resilience mode of the Cloud Composer Environment. + // + // This field is supported for Cloud Composer environments in versions + // composer-2.2.0-airflow-*.*.* and newer. + ResilienceMode resilience_mode = 20 [(google.api.field_behavior) = OPTIONAL]; +} + +// Network-level access control policy for the Airflow web server. +message WebServerNetworkAccessControl { + // Allowed IP range with user-provided description. + message AllowedIpRange { + // IP address or range, defined using CIDR notation, of requests that this + // rule applies to. + // Examples: `192.168.1.1` or `192.168.0.0/16` or `2001:db8::/32` + // or `2001:0db8:0000:0042:0000:8a2e:0370:7334`. + // + // IP range prefixes should be properly truncated. For example, + // `1.2.3.4/24` should be truncated to `1.2.3.0/24`. Similarly, for IPv6, + // `2001:db8::1/32` should be truncated to `2001:db8::/32`. + string value = 1; + + // Optional. User-provided description. It must contain at most 300 + // characters. + string description = 2 [(google.api.field_behavior) = OPTIONAL]; + } + + // A collection of allowed IP ranges with descriptions. + repeated AllowedIpRange allowed_ip_ranges = 1; +} + +// Specifies the selection and configuration of software inside the environment. +message SoftwareConfig { + // The version of the software running in the environment. + // This encapsulates both the version of Cloud Composer functionality and the + // version of Apache Airflow. It must match the regular expression + // `composer-([0-9]+(\.[0-9]+\.[0-9]+(-preview\.[0-9]+)?)?|latest)-airflow-([0-9]+(\.[0-9]+(\.[0-9]+)?)?)`. + // When used as input, the server also checks if the provided version is + // supported and denies the request for an unsupported version. + // + // The Cloud Composer portion of the image version is a full + // [semantic version](https://semver.org), or an alias in the form of major + // version number or `latest`. When an alias is provided, the server replaces + // it with the current Cloud Composer version that satisfies the alias. + // + // The Apache Airflow portion of the image version is a full semantic version + // that points to one of the supported Apache Airflow versions, or an alias in + // the form of only major or major.minor versions specified. When an alias is + // provided, the server replaces it with the latest Apache Airflow version + // that satisfies the alias and is supported in the given Cloud Composer + // version. + // + // In all cases, the resolved image version is stored in the same field. + // + // See also [version + // list](/composer/docs/concepts/versioning/composer-versions) and [versioning + // overview](/composer/docs/concepts/versioning/composer-versioning-overview). + string image_version = 1; + + // Optional. Apache Airflow configuration properties to override. + // + // Property keys contain the section and property names, separated by a + // hyphen, for example "core-dags_are_paused_at_creation". Section names must + // not contain hyphens ("-"), opening square brackets ("["), or closing + // square brackets ("]"). The property name must not be empty and must not + // contain an equals sign ("=") or semicolon (";"). Section and property names + // must not contain a period ("."). Apache Airflow configuration property + // names must be written in + // [snake_case](https://en.wikipedia.org/wiki/Snake_case). Property values can + // contain any character, and can be written in any lower/upper case format. + // + // Certain Apache Airflow configuration property values are + // [blocked](/composer/docs/concepts/airflow-configurations), + // and cannot be overridden. + map airflow_config_overrides = 2 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Custom Python Package Index (PyPI) packages to be installed in + // the environment. + // + // Keys refer to the lowercase package name such as "numpy" + // and values are the lowercase extras and version specifier such as + // "==1.12.0", "[devel,gcp_api]", or "[devel]>=1.8.2, <1.9.2". To specify a + // package without pinning it to a version specifier, use the empty string as + // the value. + map pypi_packages = 3 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Additional environment variables to provide to the Apache Airflow + // scheduler, worker, and webserver processes. + // + // Environment variable names must match the regular expression + // `[a-zA-Z_][a-zA-Z0-9_]*`. They cannot specify Apache Airflow + // software configuration overrides (they cannot match the regular expression + // `AIRFLOW__[A-Z0-9_]+__[A-Z0-9_]+`), and they cannot match any of the + // following reserved names: + // + // * `AIRFLOW_HOME` + // * `C_FORCE_ROOT` + // * `CONTAINER_NAME` + // * `DAGS_FOLDER` + // * `GCP_PROJECT` + // * `GCS_BUCKET` + // * `GKE_CLUSTER_NAME` + // * `SQL_DATABASE` + // * `SQL_INSTANCE` + // * `SQL_PASSWORD` + // * `SQL_PROJECT` + // * `SQL_REGION` + // * `SQL_USER` + map env_variables = 4 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The major version of Python used to run the Apache Airflow + // scheduler, worker, and webserver processes. + // + // Can be set to '2' or '3'. If not specified, the default is '3'. Cannot be + // updated. + // + // This field is only supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. Environments in newer versions always use + // Python major version 3. + string python_version = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The number of schedulers for Airflow. + // + // This field is supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-2.*.*. + int32 scheduler_count = 7 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The configuration for Cloud Data Lineage integration. + CloudDataLineageIntegration cloud_data_lineage_integration = 8 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Configuration for controlling how IPs are allocated in the +// GKE cluster. +message IPAllocationPolicy { + // Optional. Whether or not to enable Alias IPs in the GKE cluster. + // If `true`, a VPC-native cluster is created. + // + // This field is only supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. Environments in newer versions always use + // VPC-native GKE clusters. + bool use_ip_aliases = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The name of the cluster's secondary range used to allocate + // IP addresses to pods. Specify either `cluster_secondary_range_name` + // or `cluster_ipv4_cidr_block` but not both. + // + // For Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*, + // this field is applicable only when `use_ip_aliases` is true. + string cluster_secondary_range_name = 2 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The name of the services' secondary range used to allocate + // IP addresses to the cluster. Specify either `services_secondary_range_name` + // or `services_ipv4_cidr_block` but not both. + // + // For Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*, + // this field is applicable only when `use_ip_aliases` is true. + string services_secondary_range_name = 3 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The IP address range used to allocate IP addresses to pods in + // the cluster. + // + // For Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*, + // this field is applicable only when `use_ip_aliases` is true. + // + // Set to blank to have GKE choose a range with the default size. + // + // Set to /netmask (e.g. `/14`) to have GKE choose a range with a specific + // netmask. + // + // Set to a + // [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) + // notation (e.g. `10.96.0.0/14`) from the RFC-1918 private networks (e.g. + // `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`) to pick a specific range + // to use. + // Specify `cluster_secondary_range_name` or `cluster_ipv4_cidr_block` + // but not both. + string cluster_ipv4_cidr_block = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The IP address range of the services IP addresses in this + // cluster. + // + // For Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*, + // this field is applicable only when `use_ip_aliases` is true. + // + // Set to blank to have GKE choose a range with the default size. + // + // Set to /netmask (e.g. `/14`) to have GKE choose a range with a specific + // netmask. + // + // Set to a + // [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) + // notation (e.g. `10.96.0.0/14`) from the RFC-1918 private networks (e.g. + // `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`) to pick a specific range + // to use. + // Specify `services_secondary_range_name` or `services_ipv4_cidr_block` + // but not both. + string services_ipv4_cidr_block = 5 [(google.api.field_behavior) = OPTIONAL]; +} + +// The configuration information for the Kubernetes Engine nodes running +// the Apache Airflow software. +message NodeConfig { + // Optional. The Compute Engine [zone](/compute/docs/regions-zones) in which + // to deploy the VMs used to run the Apache Airflow software, specified as a + // [relative resource + // name](/apis/design/resource_names#relative_resource_name). For example: + // "projects/{projectId}/zones/{zoneId}". + // + // This `location` must belong to the enclosing environment's project and + // location. If both this field and `nodeConfig.machineType` are specified, + // `nodeConfig.machineType` must belong to this `location`; if both are + // unspecified, the service will pick a zone in the Compute Engine region + // corresponding to the Cloud Composer location, and propagate that choice to + // both fields. If only one field (`location` or `nodeConfig.machineType`) is + // specified, the location information from the specified field will be + // propagated to the unspecified field. + // + // This field is supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + string location = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The Compute Engine + // [machine type](/compute/docs/machine-types) used for cluster instances, + // specified as a + // [relative resource + // name](/apis/design/resource_names#relative_resource_name). For example: + // "projects/{projectId}/zones/{zoneId}/machineTypes/{machineTypeId}". + // + // The `machineType` must belong to the enclosing environment's project and + // location. If both this field and `nodeConfig.location` are specified, + // this `machineType` must belong to the `nodeConfig.location`; if both are + // unspecified, the service will pick a zone in the Compute Engine region + // corresponding to the Cloud Composer location, and propagate that choice to + // both fields. If exactly one of this field and `nodeConfig.location` is + // specified, the location information from the specified field will be + // propagated to the unspecified field. + // + // The `machineTypeId` must not be a [shared-core machine + // type](/compute/docs/machine-types#sharedcore). + // + // If this field is unspecified, the `machineTypeId` defaults + // to "n1-standard-1". + // + // This field is supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + string machine_type = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The Compute Engine network to be used for machine + // communications, specified as a + // [relative resource + // name](/apis/design/resource_names#relative_resource_name). For example: + // "projects/{projectId}/global/networks/{networkId}". + // + // If unspecified, the default network in the environment's project is used. + // If a [Custom Subnet Network](/vpc/docs/vpc#vpc_networks_and_subnets) + // is provided, `nodeConfig.subnetwork` must also be provided. For + // [Shared VPC](/vpc/docs/shared-vpc) subnetwork requirements, see + // `nodeConfig.subnetwork`. + string network = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The Compute Engine subnetwork to be used for machine + // communications, specified as a + // [relative resource + // name](/apis/design/resource_names#relative_resource_name). For example: + // "projects/{projectId}/regions/{regionId}/subnetworks/{subnetworkId}" + // + // If a subnetwork is provided, `nodeConfig.network` must also be provided, + // and the subnetwork must belong to the enclosing environment's project and + // location. + string subnetwork = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The disk size in GB used for node VMs. Minimum size is 30GB. + // If unspecified, defaults to 100GB. Cannot be updated. + // + // This field is supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + int32 disk_size_gb = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The set of Google API scopes to be made available on all + // node VMs. If `oauth_scopes` is empty, defaults to + // ["https://www.googleapis.com/auth/cloud-platform"]. Cannot be updated. + // + // This field is supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + repeated string oauth_scopes = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The Google Cloud Platform Service Account to be used by the + // workloads. If a service account is not specified, the "default" Compute + // Engine service account is used. Cannot be updated. + string service_account = 7 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The list of instance tags applied to all node VMs. Tags are used + // to identify valid sources or targets for network firewalls. Each tag within + // the list must comply with [RFC1035](https://www.ietf.org/rfc/rfc1035.txt). + // Cannot be updated. + repeated string tags = 8 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The IPAllocationPolicy fields for the GKE cluster. + IPAllocationPolicy ip_allocation_policy = 9 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maximum number of pods per node in the Cloud Composer GKE + // cluster. The value must be between 8 and 110 and it can be set only if the + // environment is VPC-native. The default value is 32. Values of this field + // will be propagated both to the `default-pool` node pool of the newly + // created GKE cluster, and to the default "Maximum Pods per Node" value which + // is used for newly created node pools if their value is not explicitly set + // during node pool creation. For more information, see [Optimizing IP address + // allocation] + // (https://cloud.google.com/kubernetes-engine/docs/how-to/flexible-pod-cidr). + // Cannot be updated. + // + // This field is supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + int32 max_pods_per_node = 10 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Deploys 'ip-masq-agent' daemon set in the GKE cluster and defines + // nonMasqueradeCIDRs equals to pod IP range so IP masquerading is used for + // all destination addresses, except between pods traffic. + // + // See: + // https://cloud.google.com/kubernetes-engine/docs/how-to/ip-masquerade-agent + bool enable_ip_masq_agent = 11 [(google.api.field_behavior) = OPTIONAL]; +} + +// Configuration options for the private GKE cluster in a Cloud Composer +// environment. +message PrivateClusterConfig { + // Optional. If `true`, access to the public endpoint of the GKE cluster is + // denied. + bool enable_private_endpoint = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The CIDR block from which IPv4 range for GKE master will be + // reserved. If left blank, the default value of '172.16.0.0/23' is used. + string master_ipv4_cidr_block = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The IP range in CIDR notation to use for the hosted master + // network. This range is used for assigning internal IP addresses to the + // cluster master or set of masters and to the internal load balancer virtual + // IP. This range must not overlap with any other ranges in use within the + // cluster's network. + string master_ipv4_reserved_range = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Configuration options for networking connections in the Composer 2 +// environment. +message NetworkingConfig { + // Represents connection type between Composer environment in Customer + // Project and the corresponding Tenant project, from a predefined list + // of available connection modes. + enum ConnectionType { + // No specific connection type was requested, so the environment uses + // the default value corresponding to the rest of its configuration. + CONNECTION_TYPE_UNSPECIFIED = 0; + + // Requests the use of VPC peerings for connecting the Customer and Tenant + // projects. + VPC_PEERING = 1; + + // Requests the use of Private Service Connect for connecting the Customer + // and Tenant projects. + PRIVATE_SERVICE_CONNECT = 2; + } + + // Optional. Indicates the user requested specifc connection type between + // Tenant and Customer projects. You cannot set networking connection type in + // public IP environment. + ConnectionType connection_type = 1 [(google.api.field_behavior) = OPTIONAL]; +} + +// The configuration information for configuring a Private IP Cloud Composer +// environment. +message PrivateEnvironmentConfig { + // Optional. If `true`, a Private IP Cloud Composer environment is created. + // If this field is set to true, `IPAllocationPolicy.use_ip_aliases` must be + // set to true for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + bool enable_private_environment = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Configuration for the private GKE cluster for a Private IP + // Cloud Composer environment. + PrivateClusterConfig private_cluster_config = 2 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The CIDR block from which IP range for web server will be + // reserved. Needs to be disjoint from + // private_cluster_config.master_ipv4_cidr_block and + // cloud_sql_ipv4_cidr_block. + // + // This field is supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + string web_server_ipv4_cidr_block = 3 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The CIDR block from which IP range in tenant project will be + // reserved for Cloud SQL. Needs to be disjoint from + // web_server_ipv4_cidr_block + string cloud_sql_ipv4_cidr_block = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The IP range reserved for the tenant project's App Engine VMs. + // + // This field is supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + string web_server_ipv4_reserved_range = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. The CIDR block from which IP range for Cloud Composer Network in + // tenant project will be reserved. Needs to be disjoint from + // private_cluster_config.master_ipv4_cidr_block and + // cloud_sql_ipv4_cidr_block. + // + // This field is supported for Cloud Composer environments in versions + // composer-2.*.*-airflow-*.*.* and newer. + string cloud_composer_network_ipv4_cidr_block = 7 + [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The IP range reserved for the tenant project's Cloud Composer + // network. + // + // This field is supported for Cloud Composer environments in versions + // composer-2.*.*-airflow-*.*.* and newer. + string cloud_composer_network_ipv4_reserved_range = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. When enabled, IPs from public (non-RFC1918) ranges can be used + // for `IPAllocationPolicy.cluster_ipv4_cidr_block` and + // `IPAllocationPolicy.service_ipv4_cidr_block`. + bool enable_privately_used_public_ips = 6 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. When specified, the environment will use Private Service Connect + // instead of VPC peerings to connect to Cloud SQL in the Tenant Project, + // and the PSC endpoint in the Customer Project will use an IP address from + // this subnetwork. + string cloud_composer_connection_subnetwork = 9 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Configuration for the network connections configuration in the + // environment. + NetworkingConfig networking_config = 10 + [(google.api.field_behavior) = OPTIONAL]; +} + +// The configuration of Cloud SQL instance that is used by the Apache Airflow +// software. +message DatabaseConfig { + // Optional. Cloud SQL machine type used by Airflow database. + // It has to be one of: db-n1-standard-2, db-n1-standard-4, db-n1-standard-8 + // or db-n1-standard-16. If not specified, db-n1-standard-2 will be used. + // Supported for Cloud Composer environments in versions + // composer-1.*.*-airflow-*.*.*. + string machine_type = 1 [(google.api.field_behavior) = OPTIONAL]; +} + +// The configuration settings for the Airflow web server App Engine instance. +// Supported for Cloud Composer environments in versions +// composer-1.*.*-airflow-*.*.*. +message WebServerConfig { + // Optional. Machine type on which Airflow web server is running. + // It has to be one of: composer-n1-webserver-2, composer-n1-webserver-4 or + // composer-n1-webserver-8. + // If not specified, composer-n1-webserver-2 will be used. + // Value custom is returned only in response, if Airflow web server parameters + // were manually changed to a non-standard values. + string machine_type = 1 [(google.api.field_behavior) = OPTIONAL]; +} + +// The encryption options for the Cloud Composer environment and its +// dependencies. Supported for Cloud Composer environments in versions +// composer-1.*.*-airflow-*.*.*. +message EncryptionConfig { + // Optional. Customer-managed Encryption Key available through Google's Key + // Management Service. Cannot be updated. If not specified, Google-managed key + // will be used. + string kms_key_name = 1 [(google.api.field_behavior) = OPTIONAL]; +} + +// The configuration settings for Cloud Composer maintenance window. +// The following example: +// +// ``` +// { +// "startTime":"2019-08-01T01:00:00Z" +// "endTime":"2019-08-01T07:00:00Z" +// "recurrence":"FREQ=WEEKLY;BYDAY=TU,WE" +// } +// ``` +// +// would define a maintenance window between 01 and 07 hours UTC during +// each Tuesday and Wednesday. +message MaintenanceWindow { + // Required. Start time of the first recurrence of the maintenance window. + google.protobuf.Timestamp start_time = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Maintenance window end time. It is used only to calculate the + // duration of the maintenance window. The value for end_time must be in the + // future, relative to `start_time`. + google.protobuf.Timestamp end_time = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Maintenance window recurrence. Format is a subset of + // [RFC-5545](https://tools.ietf.org/html/rfc5545) `RRULE`. The only allowed + // values for `FREQ` field are `FREQ=DAILY` and `FREQ=WEEKLY;BYDAY=...` + // Example values: `FREQ=WEEKLY;BYDAY=TU,WE`, `FREQ=DAILY`. + string recurrence = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// The Kubernetes workloads configuration for GKE cluster associated with the +// Cloud Composer environment. Supported for Cloud Composer environments in +// versions composer-2.*.*-airflow-*.*.* and newer. +message WorkloadsConfig { + // Configuration for resources used by Airflow schedulers. + message SchedulerResource { + // Optional. CPU request and limit for a single Airflow scheduler replica. + float cpu = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Memory (GB) request and limit for a single Airflow scheduler + // replica. + float memory_gb = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Storage (GB) request and limit for a single Airflow scheduler + // replica. + float storage_gb = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The number of schedulers. + int32 count = 4 [(google.api.field_behavior) = OPTIONAL]; + } + + // Configuration for resources used by Airflow web server. + message WebServerResource { + // Optional. CPU request and limit for Airflow web server. + float cpu = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Memory (GB) request and limit for Airflow web server. + float memory_gb = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Storage (GB) request and limit for Airflow web server. + float storage_gb = 3 [(google.api.field_behavior) = OPTIONAL]; + } + + // Configuration for resources used by Airflow workers. + message WorkerResource { + // Optional. CPU request and limit for a single Airflow worker replica. + float cpu = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Memory (GB) request and limit for a single Airflow worker + // replica. + float memory_gb = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Storage (GB) request and limit for a single Airflow worker + // replica. + float storage_gb = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Minimum number of workers for autoscaling. + int32 min_count = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Maximum number of workers for autoscaling. + int32 max_count = 5 [(google.api.field_behavior) = OPTIONAL]; + } + + // Configuration for resources used by Airflow triggerers. + message TriggererResource { + // Optional. The number of triggerers. + int32 count = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. CPU request and limit for a single Airflow triggerer replica. + float cpu = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Memory (GB) request and limit for a single Airflow triggerer + // replica. + float memory_gb = 3 [(google.api.field_behavior) = OPTIONAL]; + } + + // Optional. Resources used by Airflow schedulers. + SchedulerResource scheduler = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Resources used by Airflow web server. + WebServerResource web_server = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Resources used by Airflow workers. + WorkerResource worker = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Resources used by Airflow triggerers. + TriggererResource triggerer = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// The Recovery settings of an environment. +message RecoveryConfig { + // Optional. The configuration for scheduled snapshot creation mechanism. + ScheduledSnapshotsConfig scheduled_snapshots_config = 1 + [(google.api.field_behavior) = OPTIONAL]; +} + +// The configuration for scheduled snapshot creation mechanism. +message ScheduledSnapshotsConfig { + // Optional. Whether scheduled snapshots creation is enabled. + bool enabled = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The Cloud Storage location for storing automatically created + // snapshots. + string snapshot_location = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The cron expression representing the time when snapshots creation + // mechanism runs. This field is subject to additional validation around + // frequency of execution. + string snapshot_creation_schedule = 3 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Time zone that sets the context to interpret + // snapshot_creation_schedule. + string time_zone = 5 [(google.api.field_behavior) = OPTIONAL]; +} + +// Configuration options for the master authorized networks feature. Enabled +// master authorized networks will disallow all external traffic to access +// Kubernetes master through HTTPS except traffic from the given CIDR blocks, +// Google Compute Engine Public IPs and Google Prod IPs. +message MasterAuthorizedNetworksConfig { + // CIDR block with an optional name. + message CidrBlock { + // User-defined name that identifies the CIDR block. + string display_name = 1; + + // CIDR block that must be specified in CIDR notation. + string cidr_block = 2; + } + + // Whether or not master authorized networks feature is enabled. + bool enabled = 1; + + // Up to 50 external networks that could access Kubernetes master through + // HTTPS. + repeated CidrBlock cidr_blocks = 2; +} + +// Configuration for Cloud Data Lineage integration. +message CloudDataLineageIntegration { + // Optional. Whether or not Cloud Data Lineage integration is enabled. + bool enabled = 1 [(google.api.field_behavior) = OPTIONAL]; +} + +// An environment for running orchestration tasks. +message Environment { + option (google.api.resource) = { + type: "composer.googleapis.com/Environment" + pattern: "projects/{project}/locations/{location}/environments/{environment}" + }; + + // State of the environment. + enum State { + // The state of the environment is unknown. + STATE_UNSPECIFIED = 0; + + // The environment is in the process of being created. + CREATING = 1; + + // The environment is currently running and healthy. It is ready for use. + RUNNING = 2; + + // The environment is being updated. It remains usable but cannot receive + // additional update requests or be deleted at this time. + UPDATING = 3; + + // The environment is undergoing deletion. It cannot be used. + DELETING = 4; + + // The environment has encountered an error and cannot be used. + ERROR = 5; + } + + // The resource name of the environment, in the form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + // + // EnvironmentId must start with a lowercase letter followed by up to 63 + // lowercase letters, numbers, or hyphens, and cannot end with a hyphen. + string name = 1; + + // Configuration parameters for this environment. + EnvironmentConfig config = 2; + + // Output only. The UUID (Universally Unique IDentifier) associated with this + // environment. This value is generated when the environment is created. + string uuid = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The current state of the environment. + State state = 4; + + // Output only. The time at which this environment was created. + google.protobuf.Timestamp create_time = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time at which this environment was last modified. + google.protobuf.Timestamp update_time = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. User-defined labels for this environment. + // The labels map can contain no more than 64 entries. Entries of the labels + // map are UTF8 strings that comply with the following restrictions: + // + // * Keys must conform to regexp: [\p{Ll}\p{Lo}][\p{Ll}\p{Lo}\p{N}_-]{0,62} + // * Values must conform to regexp: [\p{Ll}\p{Lo}\p{N}_-]{0,63} + // * Both keys and values are additionally constrained to be <= 128 bytes in + // size. + map labels = 7 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request to check whether image upgrade will succeed. +message CheckUpgradeRequest { + // The resource name of the environment to check upgrade for, in the + // form: + // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + string environment = 1; + + // The version of the software running in the environment. + // This encapsulates both the version of Cloud Composer functionality and the + // version of Apache Airflow. It must match the regular expression + // `composer-([0-9]+(\.[0-9]+\.[0-9]+(-preview\.[0-9]+)?)?|latest)-airflow-([0-9]+(\.[0-9]+(\.[0-9]+)?)?)`. + // When used as input, the server also checks if the provided version is + // supported and denies the request for an unsupported version. + // + // The Cloud Composer portion of the image version is a full + // [semantic version](https://semver.org), or an alias in the form of major + // version number or `latest`. When an alias is provided, the server replaces + // it with the current Cloud Composer version that satisfies the alias. + // + // The Apache Airflow portion of the image version is a full semantic version + // that points to one of the supported Apache Airflow versions, or an alias in + // the form of only major or major.minor versions specified. When an alias is + // provided, the server replaces it with the latest Apache Airflow version + // that satisfies the alias and is supported in the given Cloud Composer + // version. + // + // In all cases, the resolved image version is stored in the same field. + // + // See also [version + // list](/composer/docs/concepts/versioning/composer-versions) and [versioning + // overview](/composer/docs/concepts/versioning/composer-versioning-overview). + string image_version = 2; +} + +// Message containing information about the result of an upgrade check +// operation. +message CheckUpgradeResponse { + // Whether there were python modules conflict during image build. + enum ConflictResult { + // It is unknown whether build had conflicts or not. + CONFLICT_RESULT_UNSPECIFIED = 0; + + // There were python packages conflicts. + CONFLICT = 1; + + // There were no python packages conflicts. + NO_CONFLICT = 2; + } + + // Output only. Url for a docker build log of an upgraded image. + string build_log_uri = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Whether build has succeeded or failed on modules conflicts. + ConflictResult contains_pypi_modules_conflict = 4 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Extract from a docker image build log containing information + // about pypi modules conflicts. + string pypi_conflict_build_log_extract = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Composer image for which the build was happening. + string image_version = 5; + + // Pypi dependencies specified in the environment configuration, at the time + // when the build was triggered. + map pypi_dependencies = 6; +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/image_versions.proto b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/image_versions.proto new file mode 100644 index 00000000000..e462bee578b --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/image_versions.proto @@ -0,0 +1,90 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.orchestration.airflow.service.v1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/type/date.proto"; + +option go_package = "cloud.google.com/go/orchestration/airflow/service/apiv1beta1/servicepb;servicepb"; +option java_multiple_files = true; +option java_package = "com.google.cloud.orchestration.airflow.service.v1beta1"; + +// Readonly service to query available ImageVersions. +service ImageVersions { + option (google.api.default_host) = "composer.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // List ImageVersions for provided location. + rpc ListImageVersions(ListImageVersionsRequest) + returns (ListImageVersionsResponse) { + option (google.api.http) = { + get: "/v1beta1/{parent=projects/*/locations/*}/imageVersions" + }; + option (google.api.method_signature) = "parent"; + } +} + +// List ImageVersions in a project and location. +message ListImageVersionsRequest { + // List ImageVersions in the given project and location, in the form: + // "projects/{projectId}/locations/{locationId}" + string parent = 1; + + // The maximum number of image_versions to return. + int32 page_size = 2; + + // The next_page_token value returned from a previous List request, if any. + string page_token = 3; + + // Whether or not image versions from old releases should be included. + bool include_past_releases = 4; +} + +// The ImageVersions in a project and location. +message ListImageVersionsResponse { + // The list of supported ImageVersions in a location. + repeated ImageVersion image_versions = 1; + + // The page token used to query for the next page if one exists. + string next_page_token = 2; +} + +// Image Version information +message ImageVersion { + // The string identifier of the ImageVersion, in the form: + // "composer-x.y.z-airflow-a.b.c" + string image_version_id = 1; + + // Whether this is the default ImageVersion used by Composer during + // environment creation if no input ImageVersion is specified. + bool is_default = 2; + + // supported python versions + repeated string supported_python_versions = 3; + + // The date of the version release. + google.type.Date release_date = 4; + + // Whether it is impossible to create an environment with the image version. + bool creation_disabled = 5; + + // Whether it is impossible to upgrade an environment running with the image + // version. + bool upgrade_disabled = 6; +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/operations.proto b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/operations.proto new file mode 100644 index 00000000000..6596658a0be --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/operations.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.orchestration.airflow.service.v1beta1; + +import "google/protobuf/timestamp.proto"; + +option go_package = "cloud.google.com/go/orchestration/airflow/service/apiv1beta1/servicepb;servicepb"; +option java_multiple_files = true; +option java_outer_classname = "OperationsProto"; +option java_package = "com.google.cloud.orchestration.airflow.service.v1beta1"; + +// Metadata describing an operation. +message OperationMetadata { + // An enum describing the overall state of an operation. + enum State { + // Unused. + STATE_UNSPECIFIED = 0; + + // The operation has been created but is not yet started. + PENDING = 1; + + // The operation is underway. + RUNNING = 2; + + // The operation completed successfully. + SUCCESSFUL = 3; + + // The operation is no longer running but did not succeed. + FAILED = 4; + } + + // Type of longrunning operation. + enum Type { + // Unused. + TYPE_UNSPECIFIED = 0; + + // A resource creation operation. + CREATE = 1; + + // A resource deletion operation. + DELETE = 2; + + // A resource update operation. + UPDATE = 3; + + // A resource check operation. + CHECK = 4; + + // Saves snapshot of the resource operation. + SAVE_SNAPSHOT = 5; + + // Loads snapshot of the resource operation. + LOAD_SNAPSHOT = 6; + + // Triggers failover of environment's Cloud SQL instance (only for highly + // resilient environments). + DATABASE_FAILOVER = 7; + } + + // Output only. The current operation state. + State state = 1; + + // Output only. The type of operation being performed. + Type operation_type = 2; + + // Output only. The resource being operated on, as a [relative resource name]( + // /apis/design/resource_names#relative_resource_name). + string resource = 3; + + // Output only. The UUID of the resource being operated on. + string resource_uuid = 4; + + // Output only. The time the operation was submitted to the server. + google.protobuf.Timestamp create_time = 5; + + // Output only. The time when the operation terminated, regardless of its + // success. This field is unset if the operation is still ongoing. + google.protobuf.Timestamp end_time = 6; +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.check_upgrade.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.check_upgrade.js new file mode 100644 index 00000000000..f3c78a96f03 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.check_upgrade.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() { + // [START composer_v1beta1_generated_Environments_CheckUpgrade_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 resource name of the environment to check upgrade for, in the + * form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + */ + // const environment = 'abc123' + /** + * The version of the software running in the environment. + * This encapsulates both the version of Cloud Composer functionality and the + * version of Apache Airflow. It must match the regular expression + * `composer-([0-9]+(\.[0-9]+\.[0-9]+(-preview\.[0-9]+)?)?|latest)-airflow-([0-9]+(\.[0-9]+(\.[0-9]+)?)?)`. + * When used as input, the server also checks if the provided version is + * supported and denies the request for an unsupported version. + * The Cloud Composer portion of the image version is a full + * semantic version (https://semver.org), or an alias in the form of major + * version number or `latest`. When an alias is provided, the server replaces + * it with the current Cloud Composer version that satisfies the alias. + * The Apache Airflow portion of the image version is a full semantic version + * that points to one of the supported Apache Airflow versions, or an alias in + * the form of only major or major.minor versions specified. When an alias is + * provided, the server replaces it with the latest Apache Airflow version + * that satisfies the alias and is supported in the given Cloud Composer + * version. + * In all cases, the resolved image version is stored in the same field. + * See also version + * list (/composer/docs/concepts/versioning/composer-versions) and versioning + * overview (/composer/docs/concepts/versioning/composer-versioning-overview). + */ + // const imageVersion = 'abc123' + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callCheckUpgrade() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await serviceClient.checkUpgrade(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCheckUpgrade(); + // [END composer_v1beta1_generated_Environments_CheckUpgrade_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.create_environment.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.create_environment.js new file mode 100644 index 00000000000..f04ffc54699 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.create_environment.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() { + // [START composer_v1beta1_generated_Environments_CreateEnvironment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 must be of the form + * "projects/{projectId}/locations/{locationId}". + */ + // const parent = 'abc123' + /** + * The environment to create. + */ + // const environment = {} + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callCreateEnvironment() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await serviceClient.createEnvironment(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateEnvironment(); + // [END composer_v1beta1_generated_Environments_CreateEnvironment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.database_failover.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.database_failover.js new file mode 100644 index 00000000000..bb558fa6504 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.database_failover.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() { + // [START composer_v1beta1_generated_Environments_DatabaseFailover_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Target environment: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + */ + // const environment = 'abc123' + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callDatabaseFailover() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await serviceClient.databaseFailover(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDatabaseFailover(); + // [END composer_v1beta1_generated_Environments_DatabaseFailover_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.delete_environment.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.delete_environment.js new file mode 100644 index 00000000000..68193b50961 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.delete_environment.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() { + // [START composer_v1beta1_generated_Environments_DeleteEnvironment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 environment to delete, in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + */ + // const name = 'abc123' + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callDeleteEnvironment() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await serviceClient.deleteEnvironment(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteEnvironment(); + // [END composer_v1beta1_generated_Environments_DeleteEnvironment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.execute_airflow_command.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.execute_airflow_command.js new file mode 100644 index 00000000000..896d2ec8e0d --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.execute_airflow_command.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() { + // [START composer_v1beta1_generated_Environments_ExecuteAirflowCommand_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 resource name of the environment in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}". + */ + // const environment = 'abc123' + /** + * Airflow command. + */ + // const command = 'abc123' + /** + * Airflow subcommand. + */ + // const subcommand = 'abc123' + /** + * Parameters for the Airflow command/subcommand as an array of arguments. + * It may contain positional arguments like `["my-dag-id"]`, key-value + * parameters like `["--foo=bar"]` or `["--foo","bar"]`, + * or other flags like `["-f"]`. + */ + // const parameters = ['abc','def'] + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callExecuteAirflowCommand() { + // Construct request + const request = { + }; + + // Run request + const response = await serviceClient.executeAirflowCommand(request); + console.log(response); + } + + callExecuteAirflowCommand(); + // [END composer_v1beta1_generated_Environments_ExecuteAirflowCommand_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.fetch_database_properties.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.fetch_database_properties.js new file mode 100644 index 00000000000..29d78af48ca --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.fetch_database_properties.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(environment) { + // [START composer_v1beta1_generated_Environments_FetchDatabaseProperties_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 environment, in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + */ + // const environment = 'abc123' + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callFetchDatabaseProperties() { + // Construct request + const request = { + environment, + }; + + // Run request + const response = await serviceClient.fetchDatabaseProperties(request); + console.log(response); + } + + callFetchDatabaseProperties(); + // [END composer_v1beta1_generated_Environments_FetchDatabaseProperties_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.get_environment.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.get_environment.js new file mode 100644 index 00000000000..10090e1abea --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.get_environment.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 composer_v1beta1_generated_Environments_GetEnvironment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 resource name of the environment to get, in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + */ + // const name = 'abc123' + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callGetEnvironment() { + // Construct request + const request = { + }; + + // Run request + const response = await serviceClient.getEnvironment(request); + console.log(response); + } + + callGetEnvironment(); + // [END composer_v1beta1_generated_Environments_GetEnvironment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.list_environments.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.list_environments.js new file mode 100644 index 00000000000..763992469ec --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.list_environments.js @@ -0,0 +1,71 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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 composer_v1beta1_generated_Environments_ListEnvironments_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * List environments in the given project and location, in the form: + * "projects/{projectId}/locations/{locationId}" + */ + // const parent = 'abc123' + /** + * The maximum number of environments to return. + */ + // const pageSize = 1234 + /** + * The next_page_token value returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callListEnvironments() { + // Construct request + const request = { + }; + + // Run request + const iterable = await serviceClient.listEnvironmentsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListEnvironments(); + // [END composer_v1beta1_generated_Environments_ListEnvironments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.load_snapshot.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.load_snapshot.js new file mode 100644 index 00000000000..c29bf688b73 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.load_snapshot.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() { + // [START composer_v1beta1_generated_Environments_LoadSnapshot_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 resource name of the target environment in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + */ + // const environment = 'abc123' + /** + * A Cloud Storage path to a snapshot to load, e.g.: + * "gs://my-bucket/snapshots/project_location_environment_timestamp". + */ + // const snapshotPath = 'abc123' + /** + * Whether or not to skip installing Pypi packages when loading the + * environment's state. + */ + // const skipPypiPackagesInstallation = true + /** + * Whether or not to skip setting environment variables when loading the + * environment's state. + */ + // const skipEnvironmentVariablesSetting = true + /** + * Whether or not to skip setting Airflow overrides when loading the + * environment's state. + */ + // const skipAirflowOverridesSetting = true + /** + * Whether or not to skip copying Cloud Storage data when loading the + * environment's state. + */ + // const skipGcsDataCopying = true + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callLoadSnapshot() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await serviceClient.loadSnapshot(request); + const [response] = await operation.promise(); + console.log(response); + } + + callLoadSnapshot(); + // [END composer_v1beta1_generated_Environments_LoadSnapshot_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.poll_airflow_command.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.poll_airflow_command.js new file mode 100644 index 00000000000..45909ccfdbc --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.poll_airflow_command.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() { + // [START composer_v1beta1_generated_Environments_PollAirflowCommand_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 resource name of the environment in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + */ + // const environment = 'abc123' + /** + * The unique ID of the command execution. + */ + // const executionId = 'abc123' + /** + * The name of the pod where the command is executed. + */ + // const pod = 'abc123' + /** + * The namespace of the pod where the command is executed. + */ + // const podNamespace = 'abc123' + /** + * Line number from which new logs should be fetched. + */ + // const nextLineNumber = 1234 + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callPollAirflowCommand() { + // Construct request + const request = { + }; + + // Run request + const response = await serviceClient.pollAirflowCommand(request); + console.log(response); + } + + callPollAirflowCommand(); + // [END composer_v1beta1_generated_Environments_PollAirflowCommand_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.restart_web_server.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.restart_web_server.js new file mode 100644 index 00000000000..92462671db2 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.restart_web_server.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() { + // [START composer_v1beta1_generated_Environments_RestartWebServer_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 resource name of the environment to restart the web server for, in the + * form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + */ + // const name = 'abc123' + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callRestartWebServer() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await serviceClient.restartWebServer(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRestartWebServer(); + // [END composer_v1beta1_generated_Environments_RestartWebServer_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.save_snapshot.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.save_snapshot.js new file mode 100644 index 00000000000..2b3dd3a816e --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.save_snapshot.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() { + // [START composer_v1beta1_generated_Environments_SaveSnapshot_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 resource name of the source environment in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + */ + // const environment = 'abc123' + /** + * Location in a Cloud Storage where the snapshot is going to be stored, e.g.: + * "gs://my-bucket/snapshots". + */ + // const snapshotLocation = 'abc123' + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callSaveSnapshot() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await serviceClient.saveSnapshot(request); + const [response] = await operation.promise(); + console.log(response); + } + + callSaveSnapshot(); + // [END composer_v1beta1_generated_Environments_SaveSnapshot_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.stop_airflow_command.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.stop_airflow_command.js new file mode 100644 index 00000000000..5a2140f7fef --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.stop_airflow_command.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() { + // [START composer_v1beta1_generated_Environments_StopAirflowCommand_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 resource name of the environment in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}". + */ + // const environment = 'abc123' + /** + * The unique ID of the command execution. + */ + // const executionId = 'abc123' + /** + * The name of the pod where the command is executed. + */ + // const pod = 'abc123' + /** + * The namespace of the pod where the command is executed. + */ + // const podNamespace = 'abc123' + /** + * If true, the execution is terminated forcefully (SIGKILL). If false, the + * execution is stopped gracefully, giving it time for cleanup. + */ + // const force = true + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callStopAirflowCommand() { + // Construct request + const request = { + }; + + // Run request + const response = await serviceClient.stopAirflowCommand(request); + console.log(response); + } + + callStopAirflowCommand(); + // [END composer_v1beta1_generated_Environments_StopAirflowCommand_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.update_environment.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.update_environment.js new file mode 100644 index 00000000000..4ac87ab1c36 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.update_environment.js @@ -0,0 +1,206 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(updateMask) { + // [START composer_v1beta1_generated_Environments_UpdateEnvironment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 relative resource name of the environment to update, in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + */ + // const name = 'abc123' + /** + * A patch environment. Fields specified by the `updateMask` will be copied + * from the patch environment into the environment under update. + */ + // const environment = {} + /** + * Required. A comma-separated list of paths, relative to `Environment`, of + * fields to update. + * For example, to set the version of scikit-learn to install in the + * environment to 0.19.0 and to remove an existing installation of + * argparse, the `updateMask` parameter would include the following two + * `paths` values: "config.softwareConfig.pypiPackages.scikit-learn" and + * "config.softwareConfig.pypiPackages.argparse". The included patch + * environment would specify the scikit-learn version as follows: + * { + * "config":{ + * "softwareConfig":{ + * "pypiPackages":{ + * "scikit-learn":"==0.19.0" + * } + * } + * } + * } + * Note that in the above example, any existing PyPI packages + * other than scikit-learn and argparse will be unaffected. + * Only one update type may be included in a single request's `updateMask`. + * For example, one cannot update both the PyPI packages and + * labels in the same request. However, it is possible to update multiple + * members of a map field simultaneously in the same request. For example, + * to set the labels "label1" and "label2" while clearing "label3" (assuming + * it already exists), one can + * provide the paths "labels.label1", "labels.label2", and "labels.label3" + * and populate the patch environment as follows: + * { + * "labels":{ + * "label1":"new-label1-value" + * "label2":"new-label2-value" + * } + * } + * Note that in the above example, any existing labels that are not + * included in the `updateMask` will be unaffected. + * It is also possible to replace an entire map field by providing the + * map field's path in the `updateMask`. The new value of the field will + * be that which is provided in the patch environment. For example, to + * delete all pre-existing user-specified PyPI packages and + * install botocore at version 1.7.14, the `updateMask` would contain + * the path "config.softwareConfig.pypiPackages", and + * the patch environment would be the following: + * { + * "config":{ + * "softwareConfig":{ + * "pypiPackages":{ + * "botocore":"==1.7.14" + * } + * } + * } + * } + * **Note:** Only the following fields can be updated: + * * `config.softwareConfig.pypiPackages` + * * Replace all custom custom PyPI packages. If a replacement + * package map is not included in `environment`, all custom + * PyPI packages are cleared. It is an error to provide both + * this mask and a mask specifying an individual package. + * * `config.softwareConfig.pypiPackages.`packagename + * * Update the custom PyPI package *packagename*, + * preserving other packages. To delete the package, include it in + * `updateMask`, and omit the mapping for it in + * `environment.config.softwareConfig.pypiPackages`. It is an error + * to provide both a mask of this form and the + * `config.softwareConfig.pypiPackages` mask. + * * `labels` + * * Replace all environment labels. If a replacement labels map is not + * included in `environment`, all labels are cleared. It is an error to + * provide both this mask and a mask specifying one or more individual + * labels. + * * `labels.`labelName + * * Set the label named *labelName*, while preserving other + * labels. To delete the label, include it in `updateMask` and omit its + * mapping in `environment.labels`. It is an error to provide both a + * mask of this form and the `labels` mask. + * * `config.nodeCount` + * * Horizontally scale the number of nodes in the environment. An integer + * greater than or equal to 3 must be provided in the `config.nodeCount` + * field. Supported for Cloud Composer environments in versions + * composer-1.*.*-airflow-*.*.*. + * * `config.webServerNetworkAccessControl` + * * Replace the environment's current WebServerNetworkAccessControl. + * * `config.softwareConfig.airflowConfigOverrides` + * * Replace all Apache Airflow config overrides. If a replacement config + * overrides map is not included in `environment`, all config overrides + * are cleared. + * It is an error to provide both this mask and a mask specifying one or + * more individual config overrides. + * * `config.softwareConfig.airflowConfigOverrides.`section-name + * * Override the Apache Airflow config property *name* in the + * section named *section*, preserving other properties. To + * delete the property override, include it in `updateMask` and omit its + * mapping in + * `environment.config.softwareConfig.airflowConfigOverrides`. + * It is an error to provide both a mask of this form and the + * `config.softwareConfig.airflowConfigOverrides` mask. + * * `config.softwareConfig.envVariables` + * * Replace all environment variables. If a replacement environment + * variable map is not included in `environment`, all custom environment + * variables are cleared. + * * `config.softwareConfig.imageVersion` + * * Upgrade the version of the environment in-place. Refer to + * `SoftwareConfig.image_version` for information on how to format the + * new image version. Additionally, the new image version cannot effect + * a version downgrade, and must match the current image version's + * Composer and Airflow major versions. Consult the Cloud Composer + * version list (/composer/docs/concepts/versioning/composer-versions) + * for valid values. + * * `config.softwareConfig.schedulerCount` + * * Horizontally scale the number of schedulers in Airflow. A positive + * integer not greater than the number of nodes must be provided in the + * `config.softwareConfig.schedulerCount` field. Supported for Cloud + * Composer environments in versions composer-1.*.*-airflow-2.*.*. + * * `config.softwareConfig.cloudDataLineageIntegration` + * * Configuration for Cloud Data Lineage integration. + * * `config.databaseConfig.machineType` + * * Cloud SQL machine type used by Airflow database. + * It has to be one of: db-n1-standard-2, db-n1-standard-4, + * db-n1-standard-8 or db-n1-standard-16. Supported for Cloud Composer + * environments in versions composer-1.*.*-airflow-*.*.*. + * * `config.webServerConfig.machineType` + * * Machine type on which Airflow web server is running. + * It has to be one of: composer-n1-webserver-2, composer-n1-webserver-4 + * or composer-n1-webserver-8. Supported for Cloud Composer environments + * in versions composer-1.*.*-airflow-*.*.*. + * * `config.maintenanceWindow` + * * Maintenance window during which Cloud Composer components may be + * under maintenance. + * * `config.workloadsConfig` + * * The workloads configuration settings for the GKE cluster associated + * with the Cloud Composer environment. Supported for Cloud Composer + * environments in versions composer-2.*.*-airflow-*.*.* and newer. + * * `config.environmentSize` + * * The size of the Cloud Composer environment. Supported for Cloud + * Composer environments in versions composer-2.*.*-airflow-*.*.* and + * newer. + */ + // const updateMask = {} + + // Imports the Service library + const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; + + // Instantiates a client + const serviceClient = new EnvironmentsClient(); + + async function callUpdateEnvironment() { + // Construct request + const request = { + updateMask, + }; + + // Run request + const [operation] = await serviceClient.updateEnvironment(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateEnvironment(); + // [END composer_v1beta1_generated_Environments_UpdateEnvironment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/image_versions.list_image_versions.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/image_versions.list_image_versions.js new file mode 100644 index 00000000000..7e62f694394 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/image_versions.list_image_versions.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() { + // [START composer_v1beta1_generated_ImageVersions_ListImageVersions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * List ImageVersions in the given project and location, in the form: + * "projects/{projectId}/locations/{locationId}" + */ + // const parent = 'abc123' + /** + * The maximum number of image_versions to return. + */ + // const pageSize = 1234 + /** + * The next_page_token value returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + /** + * Whether or not image versions from old releases should be included. + */ + // const includePastReleases = true + + // Imports the Service library + const {ImageVersionsClient} = require('@google-cloud/orchestration-airflow').v1beta1; + + // Instantiates a client + const serviceClient = new ImageVersionsClient(); + + async function callListImageVersions() { + // Construct request + const request = { + }; + + // Run request + const iterable = await serviceClient.listImageVersionsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListImageVersions(); + // [END composer_v1beta1_generated_ImageVersions_ListImageVersions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.orchestration.airflow.service.v1beta1.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.orchestration.airflow.service.v1beta1.json new file mode 100644 index 00000000000..5ee66b6b4a1 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.orchestration.airflow.service.v1beta1.json @@ -0,0 +1,719 @@ +{ + "clientLibrary": { + "name": "nodejs-service", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.orchestration.airflow.service.v1beta1", + "version": "v1beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "composer_v1beta1_generated_Environments_CreateEnvironment_async", + "title": "Environments createEnvironment Sample", + "origin": "API_DEFINITION", + "description": " Create a new environment.", + "canonical": true, + "file": "environments.create_environment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateEnvironment", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.CreateEnvironment", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "environment", + "type": ".google.cloud.orchestration.airflow.service.v1beta1.Environment" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" + }, + "method": { + "shortName": "CreateEnvironment", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.CreateEnvironment", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1beta1_generated_Environments_GetEnvironment_async", + "title": "Environments getEnvironment Sample", + "origin": "API_DEFINITION", + "description": " Get an existing environment.", + "canonical": true, + "file": "environments.get_environment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetEnvironment", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.GetEnvironment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.orchestration.airflow.service.v1beta1.Environment", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" + }, + "method": { + "shortName": "GetEnvironment", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.GetEnvironment", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1beta1_generated_Environments_ListEnvironments_async", + "title": "Environments listEnvironments Sample", + "origin": "API_DEFINITION", + "description": " List environments.", + "canonical": true, + "file": "environments.list_environments.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListEnvironments", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.ListEnvironments", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsResponse", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" + }, + "method": { + "shortName": "ListEnvironments", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.ListEnvironments", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1beta1_generated_Environments_UpdateEnvironment_async", + "title": "Environments updateEnvironment Sample", + "origin": "API_DEFINITION", + "description": " Update an environment.", + "canonical": true, + "file": "environments.update_environment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 198, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateEnvironment", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.UpdateEnvironment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "environment", + "type": ".google.cloud.orchestration.airflow.service.v1beta1.Environment" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" + }, + "method": { + "shortName": "UpdateEnvironment", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.UpdateEnvironment", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1beta1_generated_Environments_DeleteEnvironment_async", + "title": "Environments deleteEnvironment Sample", + "origin": "API_DEFINITION", + "description": " Delete an environment.", + "canonical": true, + "file": "environments.delete_environment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteEnvironment", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.DeleteEnvironment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" + }, + "method": { + "shortName": "DeleteEnvironment", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.DeleteEnvironment", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1beta1_generated_Environments_RestartWebServer_async", + "title": "Environments restartWebServer Sample", + "origin": "API_DEFINITION", + "description": " Restart Airflow web server.", + "canonical": true, + "file": "environments.restart_web_server.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RestartWebServer", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.RestartWebServer", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" + }, + "method": { + "shortName": "RestartWebServer", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.RestartWebServer", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1beta1_generated_Environments_CheckUpgrade_async", + "title": "Environments checkUpgrade Sample", + "origin": "API_DEFINITION", + "description": " Check if an upgrade operation on the environment will succeed. In case of problems detailed info can be found in the returned Operation.", + "canonical": true, + "file": "environments.check_upgrade.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 78, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CheckUpgrade", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.CheckUpgrade", + "async": true, + "parameters": [ + { + "name": "environment", + "type": "TYPE_STRING" + }, + { + "name": "image_version", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" + }, + "method": { + "shortName": "CheckUpgrade", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.CheckUpgrade", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1beta1_generated_Environments_ExecuteAirflowCommand_async", + "title": "Environments executeAirflowCommand Sample", + "origin": "API_DEFINITION", + "description": " Executes Airflow CLI command.", + "canonical": true, + "file": "environments.execute_airflow_command.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ExecuteAirflowCommand", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.ExecuteAirflowCommand", + "async": true, + "parameters": [ + { + "name": "environment", + "type": "TYPE_STRING" + }, + { + "name": "command", + "type": "TYPE_STRING" + }, + { + "name": "subcommand", + "type": "TYPE_STRING" + }, + { + "name": "parameters", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandResponse", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" + }, + "method": { + "shortName": "ExecuteAirflowCommand", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.ExecuteAirflowCommand", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1beta1_generated_Environments_StopAirflowCommand_async", + "title": "Environments stopAirflowCommand Sample", + "origin": "API_DEFINITION", + "description": " Stops Airflow CLI command execution.", + "canonical": true, + "file": "environments.stop_airflow_command.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StopAirflowCommand", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.StopAirflowCommand", + "async": true, + "parameters": [ + { + "name": "environment", + "type": "TYPE_STRING" + }, + { + "name": "execution_id", + "type": "TYPE_STRING" + }, + { + "name": "pod", + "type": "TYPE_STRING" + }, + { + "name": "pod_namespace", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandResponse", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" + }, + "method": { + "shortName": "StopAirflowCommand", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.StopAirflowCommand", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1beta1_generated_Environments_PollAirflowCommand_async", + "title": "Environments pollAirflowCommand Sample", + "origin": "API_DEFINITION", + "description": " Polls Airflow CLI command execution and fetches logs.", + "canonical": true, + "file": "environments.poll_airflow_command.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PollAirflowCommand", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.PollAirflowCommand", + "async": true, + "parameters": [ + { + "name": "environment", + "type": "TYPE_STRING" + }, + { + "name": "execution_id", + "type": "TYPE_STRING" + }, + { + "name": "pod", + "type": "TYPE_STRING" + }, + { + "name": "pod_namespace", + "type": "TYPE_STRING" + }, + { + "name": "next_line_number", + "type": "TYPE_INT32" + } + ], + "resultType": ".google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandResponse", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" + }, + "method": { + "shortName": "PollAirflowCommand", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.PollAirflowCommand", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1beta1_generated_Environments_SaveSnapshot_async", + "title": "Environments saveSnapshot Sample", + "origin": "API_DEFINITION", + "description": " Creates a snapshots of a Cloud Composer environment. As a result of this operation, snapshot of environment's state is stored in a location specified in the SaveSnapshotRequest.", + "canonical": true, + "file": "environments.save_snapshot.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SaveSnapshot", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.SaveSnapshot", + "async": true, + "parameters": [ + { + "name": "environment", + "type": "TYPE_STRING" + }, + { + "name": "snapshot_location", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" + }, + "method": { + "shortName": "SaveSnapshot", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.SaveSnapshot", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1beta1_generated_Environments_LoadSnapshot_async", + "title": "Environments loadSnapshot Sample", + "origin": "API_DEFINITION", + "description": " Loads a snapshot of a Cloud Composer environment. As a result of this operation, a snapshot of environment's specified in LoadSnapshotRequest is loaded into the environment.", + "canonical": true, + "file": "environments.load_snapshot.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "LoadSnapshot", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.LoadSnapshot", + "async": true, + "parameters": [ + { + "name": "environment", + "type": "TYPE_STRING" + }, + { + "name": "snapshot_path", + "type": "TYPE_STRING" + }, + { + "name": "skip_pypi_packages_installation", + "type": "TYPE_BOOL" + }, + { + "name": "skip_environment_variables_setting", + "type": "TYPE_BOOL" + }, + { + "name": "skip_airflow_overrides_setting", + "type": "TYPE_BOOL" + }, + { + "name": "skip_gcs_data_copying", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" + }, + "method": { + "shortName": "LoadSnapshot", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.LoadSnapshot", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1beta1_generated_Environments_DatabaseFailover_async", + "title": "Environments databaseFailover Sample", + "origin": "API_DEFINITION", + "description": " Triggers database failover (only for highly resilient environments).", + "canonical": true, + "file": "environments.database_failover.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DatabaseFailover", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.DatabaseFailover", + "async": true, + "parameters": [ + { + "name": "environment", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" + }, + "method": { + "shortName": "DatabaseFailover", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.DatabaseFailover", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1beta1_generated_Environments_FetchDatabaseProperties_async", + "title": "Environments fetchDatabaseProperties Sample", + "origin": "API_DEFINITION", + "description": " Fetches database properties.", + "canonical": true, + "file": "environments.fetch_database_properties.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "FetchDatabaseProperties", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.FetchDatabaseProperties", + "async": true, + "parameters": [ + { + "name": "environment", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesResponse", + "client": { + "shortName": "EnvironmentsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" + }, + "method": { + "shortName": "FetchDatabaseProperties", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.FetchDatabaseProperties", + "service": { + "shortName": "Environments", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" + } + } + } + }, + { + "regionTag": "composer_v1beta1_generated_ImageVersions_ListImageVersions_async", + "title": "Environments listImageVersions Sample", + "origin": "API_DEFINITION", + "description": " List ImageVersions for provided location.", + "canonical": true, + "file": "image_versions.list_image_versions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListImageVersions", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.ImageVersions.ListImageVersions", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "include_past_releases", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsResponse", + "client": { + "shortName": "ImageVersionsClient", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.ImageVersionsClient" + }, + "method": { + "shortName": "ListImageVersions", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.ImageVersions.ListImageVersions", + "service": { + "shortName": "ImageVersions", + "fullName": "google.cloud.orchestration.airflow.service.v1beta1.ImageVersions" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/index.ts new file mode 100644 index 00000000000..06b3dd52c3b --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/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. ** + +import * as v1beta1 from './v1beta1'; +const EnvironmentsClient = v1beta1.EnvironmentsClient; +type EnvironmentsClient = v1beta1.EnvironmentsClient; +const ImageVersionsClient = v1beta1.ImageVersionsClient; +type ImageVersionsClient = v1beta1.ImageVersionsClient; +export {v1beta1, EnvironmentsClient, ImageVersionsClient}; +export default {v1beta1, EnvironmentsClient, ImageVersionsClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_client.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_client.ts new file mode 100644 index 00000000000..3e37b62e07d --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_client.ts @@ -0,0 +1,2113 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta1/environments_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './environments_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Managed Apache Airflow Environments. + * @class + * @memberof v1beta1 + */ +export class EnvironmentsClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + environmentsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of EnvironmentsClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 EnvironmentsClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof EnvironmentsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + environmentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/environments/{environment}' + ), + }; + + // 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 = { + listEnvironments: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'environments') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta1/{name=projects/*/locations/*}/operations',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createEnvironmentResponse = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1beta1.Environment') as gax.protobuf.Type; + const createEnvironmentMetadata = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata') as gax.protobuf.Type; + const updateEnvironmentResponse = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1beta1.Environment') as gax.protobuf.Type; + const updateEnvironmentMetadata = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata') as gax.protobuf.Type; + const deleteEnvironmentResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteEnvironmentMetadata = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata') as gax.protobuf.Type; + const restartWebServerResponse = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1beta1.Environment') as gax.protobuf.Type; + const restartWebServerMetadata = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata') as gax.protobuf.Type; + const checkUpgradeResponse = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeResponse') as gax.protobuf.Type; + const checkUpgradeMetadata = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata') as gax.protobuf.Type; + const saveSnapshotResponse = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1beta1.SaveSnapshotResponse') as gax.protobuf.Type; + const saveSnapshotMetadata = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata') as gax.protobuf.Type; + const loadSnapshotResponse = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1beta1.LoadSnapshotResponse') as gax.protobuf.Type; + const loadSnapshotMetadata = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata') as gax.protobuf.Type; + const databaseFailoverResponse = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverResponse') as gax.protobuf.Type; + const databaseFailoverMetadata = protoFilesRoot.lookup( + '.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createEnvironment: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createEnvironmentResponse.decode.bind(createEnvironmentResponse), + createEnvironmentMetadata.decode.bind(createEnvironmentMetadata)), + updateEnvironment: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateEnvironmentResponse.decode.bind(updateEnvironmentResponse), + updateEnvironmentMetadata.decode.bind(updateEnvironmentMetadata)), + deleteEnvironment: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteEnvironmentResponse.decode.bind(deleteEnvironmentResponse), + deleteEnvironmentMetadata.decode.bind(deleteEnvironmentMetadata)), + restartWebServer: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + restartWebServerResponse.decode.bind(restartWebServerResponse), + restartWebServerMetadata.decode.bind(restartWebServerMetadata)), + checkUpgrade: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + checkUpgradeResponse.decode.bind(checkUpgradeResponse), + checkUpgradeMetadata.decode.bind(checkUpgradeMetadata)), + saveSnapshot: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + saveSnapshotResponse.decode.bind(saveSnapshotResponse), + saveSnapshotMetadata.decode.bind(saveSnapshotMetadata)), + loadSnapshot: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + loadSnapshotResponse.decode.bind(loadSnapshotResponse), + loadSnapshotMetadata.decode.bind(loadSnapshotMetadata)), + databaseFailover: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + databaseFailoverResponse.decode.bind(databaseFailoverResponse), + databaseFailoverMetadata.decode.bind(databaseFailoverMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.orchestration.airflow.service.v1beta1.Environments', 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.environmentsStub) { + return this.environmentsStub; + } + + // Put together the "service stub" for + // google.cloud.orchestration.airflow.service.v1beta1.Environments. + this.environmentsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.orchestration.airflow.service.v1beta1.Environments') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.orchestration.airflow.service.v1beta1.Environments, + 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 environmentsStubMethods = + ['createEnvironment', 'getEnvironment', 'listEnvironments', 'updateEnvironment', 'deleteEnvironment', 'restartWebServer', 'checkUpgrade', 'executeAirflowCommand', 'stopAirflowCommand', 'pollAirflowCommand', 'saveSnapshot', 'loadSnapshot', 'databaseFailover', 'fetchDatabaseProperties']; + for (const methodName of environmentsStubMethods) { + const callPromise = this.environmentsStub.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.environmentsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'composer.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 'composer.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 -- + // ------------------- +/** + * Get an existing environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource name of the environment to get, in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.orchestration.airflow.service.v1beta1.Environment|Environment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.get_environment.js + * region_tag:composer_v1beta1_generated_Environments_GetEnvironment_async + */ + getEnvironment( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IGetEnvironmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment, + protos.google.cloud.orchestration.airflow.service.v1beta1.IGetEnvironmentRequest|undefined, {}|undefined + ]>; + getEnvironment( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IGetEnvironmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment, + protos.google.cloud.orchestration.airflow.service.v1beta1.IGetEnvironmentRequest|null|undefined, + {}|null|undefined>): void; + getEnvironment( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IGetEnvironmentRequest, + callback: Callback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment, + protos.google.cloud.orchestration.airflow.service.v1beta1.IGetEnvironmentRequest|null|undefined, + {}|null|undefined>): void; + getEnvironment( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IGetEnvironmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment, + protos.google.cloud.orchestration.airflow.service.v1beta1.IGetEnvironmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment, + protos.google.cloud.orchestration.airflow.service.v1beta1.IGetEnvironmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment, + protos.google.cloud.orchestration.airflow.service.v1beta1.IGetEnvironmentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getEnvironment(request, options, callback); + } +/** + * Executes Airflow CLI command. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.environment + * The resource name of the environment in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}". + * @param {string} request.command + * Airflow command. + * @param {string} request.subcommand + * Airflow subcommand. + * @param {string[]} request.parameters + * Parameters for the Airflow command/subcommand as an array of arguments. + * It may contain positional arguments like `["my-dag-id"]`, key-value + * parameters like `["--foo=bar"]` or `["--foo","bar"]`, + * or other flags like `["-f"]`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandResponse|ExecuteAirflowCommandResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.execute_airflow_command.js + * region_tag:composer_v1beta1_generated_Environments_ExecuteAirflowCommand_async + */ + executeAirflowCommand( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandRequest|undefined, {}|undefined + ]>; + executeAirflowCommand( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandRequest|null|undefined, + {}|null|undefined>): void; + executeAirflowCommand( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandRequest, + callback: Callback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandRequest|null|undefined, + {}|null|undefined>): void; + executeAirflowCommand( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'environment': request.environment ?? '', + }); + this.initialize(); + return this.innerApiCalls.executeAirflowCommand(request, options, callback); + } +/** + * Stops Airflow CLI command execution. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.environment + * The resource name of the environment in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}". + * @param {string} request.executionId + * The unique ID of the command execution. + * @param {string} request.pod + * The name of the pod where the command is executed. + * @param {string} request.podNamespace + * The namespace of the pod where the command is executed. + * @param {boolean} request.force + * If true, the execution is terminated forcefully (SIGKILL). If false, the + * execution is stopped gracefully, giving it time for cleanup. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandResponse|StopAirflowCommandResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.stop_airflow_command.js + * region_tag:composer_v1beta1_generated_Environments_StopAirflowCommand_async + */ + stopAirflowCommand( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandRequest|undefined, {}|undefined + ]>; + stopAirflowCommand( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandRequest|null|undefined, + {}|null|undefined>): void; + stopAirflowCommand( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandRequest, + callback: Callback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandRequest|null|undefined, + {}|null|undefined>): void; + stopAirflowCommand( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'environment': request.environment ?? '', + }); + this.initialize(); + return this.innerApiCalls.stopAirflowCommand(request, options, callback); + } +/** + * Polls Airflow CLI command execution and fetches logs. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.environment + * The resource name of the environment in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + * @param {string} request.executionId + * The unique ID of the command execution. + * @param {string} request.pod + * The name of the pod where the command is executed. + * @param {string} request.podNamespace + * The namespace of the pod where the command is executed. + * @param {number} request.nextLineNumber + * Line number from which new logs should be fetched. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandResponse|PollAirflowCommandResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.poll_airflow_command.js + * region_tag:composer_v1beta1_generated_Environments_PollAirflowCommand_async + */ + pollAirflowCommand( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandRequest|undefined, {}|undefined + ]>; + pollAirflowCommand( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandRequest|null|undefined, + {}|null|undefined>): void; + pollAirflowCommand( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandRequest, + callback: Callback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandRequest|null|undefined, + {}|null|undefined>): void; + pollAirflowCommand( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'environment': request.environment ?? '', + }); + this.initialize(); + return this.innerApiCalls.pollAirflowCommand(request, options, callback); + } +/** + * Fetches database properties. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.environment + * Required. The resource name of the environment, in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesResponse|FetchDatabasePropertiesResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.fetch_database_properties.js + * region_tag:composer_v1beta1_generated_Environments_FetchDatabaseProperties_async + */ + fetchDatabaseProperties( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesRequest|undefined, {}|undefined + ]>; + fetchDatabaseProperties( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesRequest|null|undefined, + {}|null|undefined>): void; + fetchDatabaseProperties( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesRequest, + callback: Callback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesRequest|null|undefined, + {}|null|undefined>): void; + fetchDatabaseProperties( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesResponse, + protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'environment': request.environment ?? '', + }); + this.initialize(); + return this.innerApiCalls.fetchDatabaseProperties(request, options, callback); + } + +/** + * Create a new environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The parent must be of the form + * "projects/{projectId}/locations/{locationId}". + * @param {google.cloud.orchestration.airflow.service.v1beta1.Environment} request.environment + * The environment to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.create_environment.js + * region_tag:composer_v1beta1_generated_Environments_CreateEnvironment_async + */ + createEnvironment( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.ICreateEnvironmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createEnvironment( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.ICreateEnvironmentRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createEnvironment( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.ICreateEnvironmentRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createEnvironment( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.ICreateEnvironmentRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createEnvironment(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createEnvironment()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.create_environment.js + * region_tag:composer_v1beta1_generated_Environments_CreateEnvironment_async + */ + async checkCreateEnvironmentProgress(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.createEnvironment, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Update an environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The relative resource name of the environment to update, in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + * @param {google.cloud.orchestration.airflow.service.v1beta1.Environment} request.environment + * A patch environment. Fields specified by the `updateMask` will be copied + * from the patch environment into the environment under update. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. A comma-separated list of paths, relative to `Environment`, of + * fields to update. + * For example, to set the version of scikit-learn to install in the + * environment to 0.19.0 and to remove an existing installation of + * argparse, the `updateMask` parameter would include the following two + * `paths` values: "config.softwareConfig.pypiPackages.scikit-learn" and + * "config.softwareConfig.pypiPackages.argparse". The included patch + * environment would specify the scikit-learn version as follows: + * + * { + * "config":{ + * "softwareConfig":{ + * "pypiPackages":{ + * "scikit-learn":"==0.19.0" + * } + * } + * } + * } + * + * Note that in the above example, any existing PyPI packages + * other than scikit-learn and argparse will be unaffected. + * + * Only one update type may be included in a single request's `updateMask`. + * For example, one cannot update both the PyPI packages and + * labels in the same request. However, it is possible to update multiple + * members of a map field simultaneously in the same request. For example, + * to set the labels "label1" and "label2" while clearing "label3" (assuming + * it already exists), one can + * provide the paths "labels.label1", "labels.label2", and "labels.label3" + * and populate the patch environment as follows: + * + * { + * "labels":{ + * "label1":"new-label1-value" + * "label2":"new-label2-value" + * } + * } + * + * Note that in the above example, any existing labels that are not + * included in the `updateMask` will be unaffected. + * + * It is also possible to replace an entire map field by providing the + * map field's path in the `updateMask`. The new value of the field will + * be that which is provided in the patch environment. For example, to + * delete all pre-existing user-specified PyPI packages and + * install botocore at version 1.7.14, the `updateMask` would contain + * the path "config.softwareConfig.pypiPackages", and + * the patch environment would be the following: + * + * { + * "config":{ + * "softwareConfig":{ + * "pypiPackages":{ + * "botocore":"==1.7.14" + * } + * } + * } + * } + * + * **Note:** Only the following fields can be updated: + * + * * `config.softwareConfig.pypiPackages` + * * Replace all custom custom PyPI packages. If a replacement + * package map is not included in `environment`, all custom + * PyPI packages are cleared. It is an error to provide both + * this mask and a mask specifying an individual package. + * * `config.softwareConfig.pypiPackages.`packagename + * * Update the custom PyPI package *packagename*, + * preserving other packages. To delete the package, include it in + * `updateMask`, and omit the mapping for it in + * `environment.config.softwareConfig.pypiPackages`. It is an error + * to provide both a mask of this form and the + * `config.softwareConfig.pypiPackages` mask. + * * `labels` + * * Replace all environment labels. If a replacement labels map is not + * included in `environment`, all labels are cleared. It is an error to + * provide both this mask and a mask specifying one or more individual + * labels. + * * `labels.`labelName + * * Set the label named *labelName*, while preserving other + * labels. To delete the label, include it in `updateMask` and omit its + * mapping in `environment.labels`. It is an error to provide both a + * mask of this form and the `labels` mask. + * * `config.nodeCount` + * * Horizontally scale the number of nodes in the environment. An integer + * greater than or equal to 3 must be provided in the `config.nodeCount` + * field. Supported for Cloud Composer environments in versions + * composer-1.*.*-airflow-*.*.*. + * * `config.webServerNetworkAccessControl` + * * Replace the environment's current WebServerNetworkAccessControl. + * * `config.softwareConfig.airflowConfigOverrides` + * * Replace all Apache Airflow config overrides. If a replacement config + * overrides map is not included in `environment`, all config overrides + * are cleared. + * It is an error to provide both this mask and a mask specifying one or + * more individual config overrides. + * * `config.softwareConfig.airflowConfigOverrides.`section-name + * * Override the Apache Airflow config property *name* in the + * section named *section*, preserving other properties. To + * delete the property override, include it in `updateMask` and omit its + * mapping in + * `environment.config.softwareConfig.airflowConfigOverrides`. + * It is an error to provide both a mask of this form and the + * `config.softwareConfig.airflowConfigOverrides` mask. + * * `config.softwareConfig.envVariables` + * * Replace all environment variables. If a replacement environment + * variable map is not included in `environment`, all custom environment + * variables are cleared. + * * `config.softwareConfig.imageVersion` + * * Upgrade the version of the environment in-place. Refer to + * `SoftwareConfig.image_version` for information on how to format the + * new image version. Additionally, the new image version cannot effect + * a version downgrade, and must match the current image version's + * Composer and Airflow major versions. Consult the [Cloud Composer + * version list](/composer/docs/concepts/versioning/composer-versions) + * for valid values. + * * `config.softwareConfig.schedulerCount` + * * Horizontally scale the number of schedulers in Airflow. A positive + * integer not greater than the number of nodes must be provided in the + * `config.softwareConfig.schedulerCount` field. Supported for Cloud + * Composer environments in versions composer-1.*.*-airflow-2.*.*. + * * `config.softwareConfig.cloudDataLineageIntegration` + * * Configuration for Cloud Data Lineage integration. + * * `config.databaseConfig.machineType` + * * Cloud SQL machine type used by Airflow database. + * It has to be one of: db-n1-standard-2, db-n1-standard-4, + * db-n1-standard-8 or db-n1-standard-16. Supported for Cloud Composer + * environments in versions composer-1.*.*-airflow-*.*.*. + * * `config.webServerConfig.machineType` + * * Machine type on which Airflow web server is running. + * It has to be one of: composer-n1-webserver-2, composer-n1-webserver-4 + * or composer-n1-webserver-8. Supported for Cloud Composer environments + * in versions composer-1.*.*-airflow-*.*.*. + * * `config.maintenanceWindow` + * * Maintenance window during which Cloud Composer components may be + * under maintenance. + * * `config.workloadsConfig` + * * The workloads configuration settings for the GKE cluster associated + * with the Cloud Composer environment. Supported for Cloud Composer + * environments in versions composer-2.*.*-airflow-*.*.* and newer. + * * `config.environmentSize` + * * The size of the Cloud Composer environment. Supported for Cloud + * Composer environments in versions composer-2.*.*-airflow-*.*.* and + * newer. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.update_environment.js + * region_tag:composer_v1beta1_generated_Environments_UpdateEnvironment_async + */ + updateEnvironment( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IUpdateEnvironmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateEnvironment( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IUpdateEnvironmentRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateEnvironment( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IUpdateEnvironmentRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateEnvironment( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IUpdateEnvironmentRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateEnvironment(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateEnvironment()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.update_environment.js + * region_tag:composer_v1beta1_generated_Environments_UpdateEnvironment_async + */ + async checkUpdateEnvironmentProgress(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.updateEnvironment, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Delete an environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The environment to delete, in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.delete_environment.js + * region_tag:composer_v1beta1_generated_Environments_DeleteEnvironment_async + */ + deleteEnvironment( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IDeleteEnvironmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteEnvironment( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IDeleteEnvironmentRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteEnvironment( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IDeleteEnvironmentRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteEnvironment( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IDeleteEnvironmentRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteEnvironment(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteEnvironment()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.delete_environment.js + * region_tag:composer_v1beta1_generated_Environments_DeleteEnvironment_async + */ + async checkDeleteEnvironmentProgress(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.deleteEnvironment, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Restart Airflow web server. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource name of the environment to restart the web server for, in the + * form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.restart_web_server.js + * region_tag:composer_v1beta1_generated_Environments_RestartWebServer_async + */ + restartWebServer( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IRestartWebServerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + restartWebServer( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IRestartWebServerRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + restartWebServer( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IRestartWebServerRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + restartWebServer( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IRestartWebServerRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.restartWebServer(request, options, callback); + } +/** + * Check the status of the long running operation returned by `restartWebServer()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.restart_web_server.js + * region_tag:composer_v1beta1_generated_Environments_RestartWebServer_async + */ + async checkRestartWebServerProgress(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.restartWebServer, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Check if an upgrade operation on the environment will succeed. + * + * In case of problems detailed info can be found in the returned Operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.environment + * The resource name of the environment to check upgrade for, in the + * form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + * @param {string} request.imageVersion + * The version of the software running in the environment. + * This encapsulates both the version of Cloud Composer functionality and the + * version of Apache Airflow. It must match the regular expression + * `composer-([0-9]+(\.[0-9]+\.[0-9]+(-preview\.[0-9]+)?)?|latest)-airflow-([0-9]+(\.[0-9]+(\.[0-9]+)?)?)`. + * When used as input, the server also checks if the provided version is + * supported and denies the request for an unsupported version. + * + * The Cloud Composer portion of the image version is a full + * [semantic version](https://semver.org), or an alias in the form of major + * version number or `latest`. When an alias is provided, the server replaces + * it with the current Cloud Composer version that satisfies the alias. + * + * The Apache Airflow portion of the image version is a full semantic version + * that points to one of the supported Apache Airflow versions, or an alias in + * the form of only major or major.minor versions specified. When an alias is + * provided, the server replaces it with the latest Apache Airflow version + * that satisfies the alias and is supported in the given Cloud Composer + * version. + * + * In all cases, the resolved image version is stored in the same field. + * + * See also [version + * list](/composer/docs/concepts/versioning/composer-versions) and [versioning + * overview](/composer/docs/concepts/versioning/composer-versioning-overview). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.check_upgrade.js + * region_tag:composer_v1beta1_generated_Environments_CheckUpgrade_async + */ + checkUpgrade( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.ICheckUpgradeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + checkUpgrade( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.ICheckUpgradeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + checkUpgrade( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.ICheckUpgradeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + checkUpgrade( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.ICheckUpgradeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'environment': request.environment ?? '', + }); + this.initialize(); + return this.innerApiCalls.checkUpgrade(request, options, callback); + } +/** + * Check the status of the long running operation returned by `checkUpgrade()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.check_upgrade.js + * region_tag:composer_v1beta1_generated_Environments_CheckUpgrade_async + */ + async checkCheckUpgradeProgress(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.checkUpgrade, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Creates a snapshots of a Cloud Composer environment. + * + * As a result of this operation, snapshot of environment's state is stored + * in a location specified in the SaveSnapshotRequest. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.environment + * The resource name of the source environment in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + * @param {string} request.snapshotLocation + * Location in a Cloud Storage where the snapshot is going to be stored, e.g.: + * "gs://my-bucket/snapshots". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.save_snapshot.js + * region_tag:composer_v1beta1_generated_Environments_SaveSnapshot_async + */ + saveSnapshot( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.ISaveSnapshotRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + saveSnapshot( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.ISaveSnapshotRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + saveSnapshot( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.ISaveSnapshotRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + saveSnapshot( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.ISaveSnapshotRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'environment': request.environment ?? '', + }); + this.initialize(); + return this.innerApiCalls.saveSnapshot(request, options, callback); + } +/** + * Check the status of the long running operation returned by `saveSnapshot()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.save_snapshot.js + * region_tag:composer_v1beta1_generated_Environments_SaveSnapshot_async + */ + async checkSaveSnapshotProgress(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.saveSnapshot, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Loads a snapshot of a Cloud Composer environment. + * + * As a result of this operation, a snapshot of environment's specified in + * LoadSnapshotRequest is loaded into the environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.environment + * The resource name of the target environment in the form: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + * @param {string} request.snapshotPath + * A Cloud Storage path to a snapshot to load, e.g.: + * "gs://my-bucket/snapshots/project_location_environment_timestamp". + * @param {boolean} request.skipPypiPackagesInstallation + * Whether or not to skip installing Pypi packages when loading the + * environment's state. + * @param {boolean} request.skipEnvironmentVariablesSetting + * Whether or not to skip setting environment variables when loading the + * environment's state. + * @param {boolean} request.skipAirflowOverridesSetting + * Whether or not to skip setting Airflow overrides when loading the + * environment's state. + * @param {boolean} request.skipGcsDataCopying + * Whether or not to skip copying Cloud Storage data when loading the + * environment's state. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.load_snapshot.js + * region_tag:composer_v1beta1_generated_Environments_LoadSnapshot_async + */ + loadSnapshot( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.ILoadSnapshotRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + loadSnapshot( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.ILoadSnapshotRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + loadSnapshot( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.ILoadSnapshotRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + loadSnapshot( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.ILoadSnapshotRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'environment': request.environment ?? '', + }); + this.initialize(); + return this.innerApiCalls.loadSnapshot(request, options, callback); + } +/** + * Check the status of the long running operation returned by `loadSnapshot()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.load_snapshot.js + * region_tag:composer_v1beta1_generated_Environments_LoadSnapshot_async + */ + async checkLoadSnapshotProgress(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.loadSnapshot, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Triggers database failover (only for highly resilient environments). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.environment + * Target environment: + * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.database_failover.js + * region_tag:composer_v1beta1_generated_Environments_DatabaseFailover_async + */ + databaseFailover( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IDatabaseFailoverRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + databaseFailover( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IDatabaseFailoverRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + databaseFailover( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IDatabaseFailoverRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + databaseFailover( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IDatabaseFailoverRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'environment': request.environment ?? '', + }); + this.initialize(); + return this.innerApiCalls.databaseFailover(request, options, callback); + } +/** + * Check the status of the long running operation returned by `databaseFailover()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.database_failover.js + * region_tag:composer_v1beta1_generated_Environments_DatabaseFailover_async + */ + async checkDatabaseFailoverProgress(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.databaseFailover, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * List environments. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * List environments in the given project and location, in the form: + * "projects/{projectId}/locations/{locationId}" + * @param {number} request.pageSize + * The maximum number of environments to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.orchestration.airflow.service.v1beta1.Environment|Environment}. + * 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 `listEnvironmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listEnvironments( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment[], + protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest|null, + protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsResponse + ]>; + listEnvironments( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest, + protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsResponse|null|undefined, + protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment>): void; + listEnvironments( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest, + callback: PaginationCallback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest, + protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsResponse|null|undefined, + protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment>): void; + listEnvironments( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest, + protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsResponse|null|undefined, + protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment>, + callback?: PaginationCallback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest, + protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsResponse|null|undefined, + protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment>): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment[], + protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest|null, + protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listEnvironments(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 + * List environments in the given project and location, in the form: + * "projects/{projectId}/locations/{locationId}" + * @param {number} request.pageSize + * The maximum number of environments to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.orchestration.airflow.service.v1beta1.Environment|Environment} 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 `listEnvironmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listEnvironmentsStream( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest, + 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['listEnvironments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listEnvironments.createStream( + this.innerApiCalls.listEnvironments as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listEnvironments`, 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 + * List environments in the given project and location, in the form: + * "projects/{projectId}/locations/{locationId}" + * @param {number} request.pageSize + * The maximum number of environments to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.orchestration.airflow.service.v1beta1.Environment|Environment}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/environments.list_environments.js + * region_tag:composer_v1beta1_generated_Environments_ListEnvironments_async + */ + listEnvironmentsAsync( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest, + 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['listEnvironments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listEnvironments.asyncIterate( + this.innerApiCalls['listEnvironments'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * 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 environment resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} environment + * @returns {string} Resource name string. + */ + environmentPath(project:string,location:string,environment:string) { + return this.pathTemplates.environmentPathTemplate.render({ + project: project, + location: location, + environment: environment, + }); + } + + /** + * Parse the project from Environment resource. + * + * @param {string} environmentName + * A fully-qualified path representing Environment resource. + * @returns {string} A string representing the project. + */ + matchProjectFromEnvironmentName(environmentName: string) { + return this.pathTemplates.environmentPathTemplate.match(environmentName).project; + } + + /** + * Parse the location from Environment resource. + * + * @param {string} environmentName + * A fully-qualified path representing Environment resource. + * @returns {string} A string representing the location. + */ + matchLocationFromEnvironmentName(environmentName: string) { + return this.pathTemplates.environmentPathTemplate.match(environmentName).location; + } + + /** + * Parse the environment from Environment resource. + * + * @param {string} environmentName + * A fully-qualified path representing Environment resource. + * @returns {string} A string representing the environment. + */ + matchEnvironmentFromEnvironmentName(environmentName: string) { + return this.pathTemplates.environmentPathTemplate.match(environmentName).environment; + } + + /** + * 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.environmentsStub && !this._terminated) { + return this.environmentsStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_client_config.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_client_config.json new file mode 100644 index 00000000000..2e42d5f6001 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_client_config.json @@ -0,0 +1,82 @@ +{ + "interfaces": { + "google.cloud.orchestration.airflow.service.v1beta1.Environments": { + "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": { + "CreateEnvironment": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetEnvironment": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListEnvironments": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateEnvironment": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteEnvironment": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RestartWebServer": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CheckUpgrade": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ExecuteAirflowCommand": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StopAirflowCommand": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "PollAirflowCommand": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SaveSnapshot": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "LoadSnapshot": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DatabaseFailover": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "FetchDatabaseProperties": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_proto_list.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_proto_list.json new file mode 100644 index 00000000000..c854c306722 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_proto_list.json @@ -0,0 +1,5 @@ +[ + "../../protos/google/cloud/orchestration/airflow/service/v1beta1/environments.proto", + "../../protos/google/cloud/orchestration/airflow/service/v1beta1/image_versions.proto", + "../../protos/google/cloud/orchestration/airflow/service/v1beta1/operations.proto" +] diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/gapic_metadata.json new file mode 100644 index 00000000000..2271ff732a2 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/gapic_metadata.json @@ -0,0 +1,195 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.orchestration.airflow.service.v1beta1", + "libraryPackage": "@google-cloud/orchestration-airflow", + "services": { + "Environments": { + "clients": { + "grpc": { + "libraryClient": "EnvironmentsClient", + "rpcs": { + "GetEnvironment": { + "methods": [ + "getEnvironment" + ] + }, + "ExecuteAirflowCommand": { + "methods": [ + "executeAirflowCommand" + ] + }, + "StopAirflowCommand": { + "methods": [ + "stopAirflowCommand" + ] + }, + "PollAirflowCommand": { + "methods": [ + "pollAirflowCommand" + ] + }, + "FetchDatabaseProperties": { + "methods": [ + "fetchDatabaseProperties" + ] + }, + "CreateEnvironment": { + "methods": [ + "createEnvironment" + ] + }, + "UpdateEnvironment": { + "methods": [ + "updateEnvironment" + ] + }, + "DeleteEnvironment": { + "methods": [ + "deleteEnvironment" + ] + }, + "RestartWebServer": { + "methods": [ + "restartWebServer" + ] + }, + "CheckUpgrade": { + "methods": [ + "checkUpgrade" + ] + }, + "SaveSnapshot": { + "methods": [ + "saveSnapshot" + ] + }, + "LoadSnapshot": { + "methods": [ + "loadSnapshot" + ] + }, + "DatabaseFailover": { + "methods": [ + "databaseFailover" + ] + }, + "ListEnvironments": { + "methods": [ + "listEnvironments", + "listEnvironmentsStream", + "listEnvironmentsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "EnvironmentsClient", + "rpcs": { + "GetEnvironment": { + "methods": [ + "getEnvironment" + ] + }, + "ExecuteAirflowCommand": { + "methods": [ + "executeAirflowCommand" + ] + }, + "StopAirflowCommand": { + "methods": [ + "stopAirflowCommand" + ] + }, + "PollAirflowCommand": { + "methods": [ + "pollAirflowCommand" + ] + }, + "FetchDatabaseProperties": { + "methods": [ + "fetchDatabaseProperties" + ] + }, + "CreateEnvironment": { + "methods": [ + "createEnvironment" + ] + }, + "UpdateEnvironment": { + "methods": [ + "updateEnvironment" + ] + }, + "DeleteEnvironment": { + "methods": [ + "deleteEnvironment" + ] + }, + "RestartWebServer": { + "methods": [ + "restartWebServer" + ] + }, + "CheckUpgrade": { + "methods": [ + "checkUpgrade" + ] + }, + "SaveSnapshot": { + "methods": [ + "saveSnapshot" + ] + }, + "LoadSnapshot": { + "methods": [ + "loadSnapshot" + ] + }, + "DatabaseFailover": { + "methods": [ + "databaseFailover" + ] + }, + "ListEnvironments": { + "methods": [ + "listEnvironments", + "listEnvironmentsStream", + "listEnvironmentsAsync" + ] + } + } + } + } + }, + "ImageVersions": { + "clients": { + "grpc": { + "libraryClient": "ImageVersionsClient", + "rpcs": { + "ListImageVersions": { + "methods": [ + "listImageVersions", + "listImageVersionsStream", + "listImageVersionsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageVersionsClient", + "rpcs": { + "ListImageVersions": { + "methods": [ + "listImageVersions", + "listImageVersionsStream", + "listImageVersionsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_client.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_client.ts new file mode 100644 index 00000000000..21c51427c21 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_client.ts @@ -0,0 +1,556 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta1/image_versions_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_versions_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Readonly service to query available ImageVersions. + * @class + * @memberof v1beta1 + */ +export class ImageVersionsClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + imageVersionsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageVersionsClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 ImageVersionsClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ImageVersionsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + environmentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/environments/{environment}' + ), + }; + + // 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 = { + listImageVersions: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'imageVersions') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.orchestration.airflow.service.v1beta1.ImageVersions', 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.imageVersionsStub) { + return this.imageVersionsStub; + } + + // Put together the "service stub" for + // google.cloud.orchestration.airflow.service.v1beta1.ImageVersions. + this.imageVersionsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.orchestration.airflow.service.v1beta1.ImageVersions') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.orchestration.airflow.service.v1beta1.ImageVersions, + 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 imageVersionsStubMethods = + ['listImageVersions']; + for (const methodName of imageVersionsStubMethods) { + const callPromise = this.imageVersionsStub.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.imageVersionsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'composer.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 'composer.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 -- + // ------------------- + + /** + * List ImageVersions for provided location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * List ImageVersions in the given project and location, in the form: + * "projects/{projectId}/locations/{locationId}" + * @param {number} request.pageSize + * The maximum number of image_versions to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {boolean} request.includePastReleases + * Whether or not image versions from old releases should be included. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion|ImageVersion}. + * 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 `listImageVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listImageVersions( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1beta1.IImageVersion[], + protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest|null, + protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsResponse + ]>; + listImageVersions( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest, + protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsResponse|null|undefined, + protos.google.cloud.orchestration.airflow.service.v1beta1.IImageVersion>): void; + listImageVersions( + request: protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest, + callback: PaginationCallback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest, + protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsResponse|null|undefined, + protos.google.cloud.orchestration.airflow.service.v1beta1.IImageVersion>): void; + listImageVersions( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest, + protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsResponse|null|undefined, + protos.google.cloud.orchestration.airflow.service.v1beta1.IImageVersion>, + callback?: PaginationCallback< + protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest, + protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsResponse|null|undefined, + protos.google.cloud.orchestration.airflow.service.v1beta1.IImageVersion>): + Promise<[ + protos.google.cloud.orchestration.airflow.service.v1beta1.IImageVersion[], + protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest|null, + protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listImageVersions(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 + * List ImageVersions in the given project and location, in the form: + * "projects/{projectId}/locations/{locationId}" + * @param {number} request.pageSize + * The maximum number of image_versions to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {boolean} request.includePastReleases + * Whether or not image versions from old releases should be included. + * @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 protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion|ImageVersion} 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 `listImageVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listImageVersionsStream( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest, + 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['listImageVersions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listImageVersions.createStream( + this.innerApiCalls.listImageVersions as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listImageVersions`, 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 + * List ImageVersions in the given project and location, in the form: + * "projects/{projectId}/locations/{locationId}" + * @param {number} request.pageSize + * The maximum number of image_versions to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {boolean} request.includePastReleases + * Whether or not image versions from old releases should be included. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion|ImageVersion}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/image_versions.list_image_versions.js + * region_tag:composer_v1beta1_generated_ImageVersions_ListImageVersions_async + */ + listImageVersionsAsync( + request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest, + 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['listImageVersions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listImageVersions.asyncIterate( + this.innerApiCalls['listImageVersions'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified environment resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} environment + * @returns {string} Resource name string. + */ + environmentPath(project:string,location:string,environment:string) { + return this.pathTemplates.environmentPathTemplate.render({ + project: project, + location: location, + environment: environment, + }); + } + + /** + * Parse the project from Environment resource. + * + * @param {string} environmentName + * A fully-qualified path representing Environment resource. + * @returns {string} A string representing the project. + */ + matchProjectFromEnvironmentName(environmentName: string) { + return this.pathTemplates.environmentPathTemplate.match(environmentName).project; + } + + /** + * Parse the location from Environment resource. + * + * @param {string} environmentName + * A fully-qualified path representing Environment resource. + * @returns {string} A string representing the location. + */ + matchLocationFromEnvironmentName(environmentName: string) { + return this.pathTemplates.environmentPathTemplate.match(environmentName).location; + } + + /** + * Parse the environment from Environment resource. + * + * @param {string} environmentName + * A fully-qualified path representing Environment resource. + * @returns {string} A string representing the environment. + */ + matchEnvironmentFromEnvironmentName(environmentName: string) { + return this.pathTemplates.environmentPathTemplate.match(environmentName).environment; + } + + /** + * 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.imageVersionsStub && !this._terminated) { + return this.imageVersionsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_client_config.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_client_config.json new file mode 100644 index 00000000000..9db3275858a --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_client_config.json @@ -0,0 +1,30 @@ +{ + "interfaces": { + "google.cloud.orchestration.airflow.service.v1beta1.ImageVersions": { + "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": { + "ListImageVersions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_proto_list.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_proto_list.json new file mode 100644 index 00000000000..c854c306722 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_proto_list.json @@ -0,0 +1,5 @@ +[ + "../../protos/google/cloud/orchestration/airflow/service/v1beta1/environments.proto", + "../../protos/google/cloud/orchestration/airflow/service/v1beta1/image_versions.proto", + "../../protos/google/cloud/orchestration/airflow/service/v1beta1/operations.proto" +] diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/index.ts new file mode 100644 index 00000000000..f861aaef0c3 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {EnvironmentsClient} from './environments_client'; +export {ImageVersionsClient} from './image_versions_client'; diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..6621821e725 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const service = require('@google-cloud/orchestration-airflow'); + +function main() { + const environmentsClient = new service.EnvironmentsClient(); + const imageVersionsClient = new service.ImageVersionsClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..fe7224b8add --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {EnvironmentsClient, ImageVersionsClient} from '@google-cloud/orchestration-airflow'; + +// check that the client class type name can be used +function doStuffWithEnvironmentsClient(client: EnvironmentsClient) { + client.close(); +} +function doStuffWithImageVersionsClient(client: ImageVersionsClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const environmentsClient = new EnvironmentsClient(); + doStuffWithEnvironmentsClient(environmentsClient); + // check that the client instance can be created + const imageVersionsClient = new ImageVersionsClient(); + doStuffWithImageVersionsClient(imageVersionsClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/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-orchestration-airflow-service/v1beta1/test/gapic_environments_v1beta1.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/test/gapic_environments_v1beta1.ts new file mode 100644 index 00000000000..579b45d1bd6 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/test/gapic_environments_v1beta1.ts @@ -0,0 +1,2534 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 environmentsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1beta1.EnvironmentsClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = environmentsModule.v1beta1.EnvironmentsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = environmentsModule.v1beta1.EnvironmentsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = environmentsModule.v1beta1.EnvironmentsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.environmentsStub, undefined); + await client.initialize(); + assert(client.environmentsStub); + }); + + it('has close method for the initialized client', done => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.environmentsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.environmentsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + 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 environmentsModule.v1beta1.EnvironmentsClient({ + 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('getEnvironment', () => { + it('invokes getEnvironment without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.GetEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.GetEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment() + ); + client.innerApiCalls.getEnvironment = stubSimpleCall(expectedResponse); + const [response] = await client.getEnvironment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEnvironment without error using callback', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.GetEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.GetEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment() + ); + client.innerApiCalls.getEnvironment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getEnvironment( + request, + (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEnvironment with error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.GetEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.GetEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getEnvironment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getEnvironment(request), expectedError); + const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEnvironment with closed client', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.GetEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.GetEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getEnvironment(request), expectedError); + }); + }); + + describe('executeAirflowCommand', () => { + it('invokes executeAirflowCommand without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandResponse() + ); + client.innerApiCalls.executeAirflowCommand = stubSimpleCall(expectedResponse); + const [response] = await client.executeAirflowCommand(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.executeAirflowCommand as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.executeAirflowCommand as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executeAirflowCommand without error using callback', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandResponse() + ); + client.innerApiCalls.executeAirflowCommand = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.executeAirflowCommand( + request, + (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.executeAirflowCommand as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.executeAirflowCommand as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executeAirflowCommand with error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.executeAirflowCommand = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.executeAirflowCommand(request), expectedError); + const actualRequest = (client.innerApiCalls.executeAirflowCommand as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.executeAirflowCommand as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executeAirflowCommand with closed client', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.executeAirflowCommand(request), expectedError); + }); + }); + + describe('stopAirflowCommand', () => { + it('invokes stopAirflowCommand without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandResponse() + ); + client.innerApiCalls.stopAirflowCommand = stubSimpleCall(expectedResponse); + const [response] = await client.stopAirflowCommand(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.stopAirflowCommand as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopAirflowCommand as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopAirflowCommand without error using callback', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandResponse() + ); + client.innerApiCalls.stopAirflowCommand = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.stopAirflowCommand( + request, + (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.stopAirflowCommand as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopAirflowCommand as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopAirflowCommand with error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopAirflowCommand = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.stopAirflowCommand(request), expectedError); + const actualRequest = (client.innerApiCalls.stopAirflowCommand as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopAirflowCommand as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopAirflowCommand with closed client', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.stopAirflowCommand(request), expectedError); + }); + }); + + describe('pollAirflowCommand', () => { + it('invokes pollAirflowCommand without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandResponse() + ); + client.innerApiCalls.pollAirflowCommand = stubSimpleCall(expectedResponse); + const [response] = await client.pollAirflowCommand(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pollAirflowCommand as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pollAirflowCommand as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pollAirflowCommand without error using callback', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandResponse() + ); + client.innerApiCalls.pollAirflowCommand = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.pollAirflowCommand( + request, + (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pollAirflowCommand as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pollAirflowCommand as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pollAirflowCommand with error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.pollAirflowCommand = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.pollAirflowCommand(request), expectedError); + const actualRequest = (client.innerApiCalls.pollAirflowCommand as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pollAirflowCommand as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pollAirflowCommand with closed client', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandRequest', ['environment']); + request.environment = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.pollAirflowCommand(request), expectedError); + }); + }); + + describe('fetchDatabaseProperties', () => { + it('invokes fetchDatabaseProperties without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesResponse() + ); + client.innerApiCalls.fetchDatabaseProperties = stubSimpleCall(expectedResponse); + const [response] = await client.fetchDatabaseProperties(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes fetchDatabaseProperties without error using callback', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesResponse() + ); + client.innerApiCalls.fetchDatabaseProperties = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.fetchDatabaseProperties( + request, + (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes fetchDatabaseProperties with error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.fetchDatabaseProperties = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.fetchDatabaseProperties(request), expectedError); + const actualRequest = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes fetchDatabaseProperties with closed client', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesRequest', ['environment']); + request.environment = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.fetchDatabaseProperties(request), expectedError); + }); + }); + + describe('createEnvironment', () => { + it('invokes createEnvironment without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.CreateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.CreateEnvironmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createEnvironment = stubLongRunningCall(expectedResponse); + const [operation] = await client.createEnvironment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createEnvironment without error using callback', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.CreateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.CreateEnvironmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createEnvironment = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createEnvironment( + request, + (err?: Error|null, + result?: 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.createEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createEnvironment with call error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.CreateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.CreateEnvironmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEnvironment = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createEnvironment(request), expectedError); + const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createEnvironment with LRO error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.CreateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.CreateEnvironmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEnvironment = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createEnvironment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateEnvironmentProgress without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateEnvironmentProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateEnvironmentProgress with error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateEnvironmentProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateEnvironment', () => { + it('invokes updateEnvironment without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.UpdateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.UpdateEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateEnvironment = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateEnvironment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateEnvironment without error using callback', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.UpdateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.UpdateEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateEnvironment = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateEnvironment( + request, + (err?: Error|null, + result?: 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.updateEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateEnvironment with call error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.UpdateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.UpdateEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateEnvironment = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateEnvironment(request), expectedError); + const actualRequest = (client.innerApiCalls.updateEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateEnvironment with LRO error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.UpdateEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.UpdateEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateEnvironment = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateEnvironment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateEnvironmentProgress without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateEnvironmentProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateEnvironmentProgress with error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateEnvironmentProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteEnvironment', () => { + it('invokes deleteEnvironment without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.DeleteEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.DeleteEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteEnvironment = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteEnvironment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteEnvironment without error using callback', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.DeleteEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.DeleteEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteEnvironment = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteEnvironment( + request, + (err?: Error|null, + result?: 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.deleteEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteEnvironment with call error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.DeleteEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.DeleteEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteEnvironment = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteEnvironment(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteEnvironment with LRO error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.DeleteEnvironmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.DeleteEnvironmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteEnvironment = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteEnvironment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteEnvironmentProgress without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteEnvironmentProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteEnvironmentProgress with error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteEnvironmentProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('restartWebServer', () => { + it('invokes restartWebServer without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.RestartWebServerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.RestartWebServerRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.restartWebServer = stubLongRunningCall(expectedResponse); + const [operation] = await client.restartWebServer(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.restartWebServer as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.restartWebServer as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes restartWebServer without error using callback', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.RestartWebServerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.RestartWebServerRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.restartWebServer = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.restartWebServer( + request, + (err?: Error|null, + result?: 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.restartWebServer as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.restartWebServer as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes restartWebServer with call error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.RestartWebServerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.RestartWebServerRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.restartWebServer = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.restartWebServer(request), expectedError); + const actualRequest = (client.innerApiCalls.restartWebServer as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.restartWebServer as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes restartWebServer with LRO error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.RestartWebServerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.RestartWebServerRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.restartWebServer = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.restartWebServer(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.restartWebServer as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.restartWebServer as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkRestartWebServerProgress without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRestartWebServerProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRestartWebServerProgress with error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRestartWebServerProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('checkUpgrade', () => { + it('invokes checkUpgrade without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.checkUpgrade = stubLongRunningCall(expectedResponse); + const [operation] = await client.checkUpgrade(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.checkUpgrade as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.checkUpgrade as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpgrade without error using callback', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.checkUpgrade = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.checkUpgrade( + request, + (err?: Error|null, + result?: 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.checkUpgrade as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.checkUpgrade as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpgrade with call error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.checkUpgrade = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.checkUpgrade(request), expectedError); + const actualRequest = (client.innerApiCalls.checkUpgrade as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.checkUpgrade as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpgrade with LRO error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.checkUpgrade = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.checkUpgrade(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.checkUpgrade as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.checkUpgrade as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCheckUpgradeProgress without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCheckUpgradeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCheckUpgradeProgress with error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCheckUpgradeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('saveSnapshot', () => { + it('invokes saveSnapshot without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.SaveSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.SaveSnapshotRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.saveSnapshot = stubLongRunningCall(expectedResponse); + const [operation] = await client.saveSnapshot(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.saveSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.saveSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes saveSnapshot without error using callback', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.SaveSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.SaveSnapshotRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.saveSnapshot = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.saveSnapshot( + request, + (err?: Error|null, + result?: 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.saveSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.saveSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes saveSnapshot with call error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.SaveSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.SaveSnapshotRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.saveSnapshot = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.saveSnapshot(request), expectedError); + const actualRequest = (client.innerApiCalls.saveSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.saveSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes saveSnapshot with LRO error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.SaveSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.SaveSnapshotRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.saveSnapshot = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.saveSnapshot(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.saveSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.saveSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkSaveSnapshotProgress without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkSaveSnapshotProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkSaveSnapshotProgress with error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkSaveSnapshotProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('loadSnapshot', () => { + it('invokes loadSnapshot without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.LoadSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.LoadSnapshotRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.loadSnapshot = stubLongRunningCall(expectedResponse); + const [operation] = await client.loadSnapshot(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.loadSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.loadSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes loadSnapshot without error using callback', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.LoadSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.LoadSnapshotRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.loadSnapshot = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.loadSnapshot( + request, + (err?: Error|null, + result?: 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.loadSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.loadSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes loadSnapshot with call error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.LoadSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.LoadSnapshotRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.loadSnapshot = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.loadSnapshot(request), expectedError); + const actualRequest = (client.innerApiCalls.loadSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.loadSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes loadSnapshot with LRO error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.LoadSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.LoadSnapshotRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.loadSnapshot = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.loadSnapshot(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.loadSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.loadSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkLoadSnapshotProgress without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkLoadSnapshotProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkLoadSnapshotProgress with error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkLoadSnapshotProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('databaseFailover', () => { + it('invokes databaseFailover without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.databaseFailover = stubLongRunningCall(expectedResponse); + const [operation] = await client.databaseFailover(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.databaseFailover as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.databaseFailover as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes databaseFailover without error using callback', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.databaseFailover = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.databaseFailover( + request, + (err?: Error|null, + result?: 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.databaseFailover as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.databaseFailover as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes databaseFailover with call error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.databaseFailover = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.databaseFailover(request), expectedError); + const actualRequest = (client.innerApiCalls.databaseFailover as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.databaseFailover as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes databaseFailover with LRO error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverRequest', ['environment']); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.databaseFailover = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.databaseFailover(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.databaseFailover as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.databaseFailover as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDatabaseFailoverProgress without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDatabaseFailoverProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDatabaseFailoverProgress with error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDatabaseFailoverProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listEnvironments', () => { + it('invokes listEnvironments without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), + ]; + client.innerApiCalls.listEnvironments = stubSimpleCall(expectedResponse); + const [response] = await client.listEnvironments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listEnvironments without error using callback', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), + ]; + client.innerApiCalls.listEnvironments = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listEnvironments( + request, + (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listEnvironments with error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listEnvironments = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listEnvironments(request), expectedError); + const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listEnvironmentsStream without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), + ]; + client.descriptors.page.listEnvironments.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listEnvironmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.orchestration.airflow.service.v1beta1.Environment[] = []; + stream.on('data', (response: protos.google.cloud.orchestration.airflow.service.v1beta1.Environment) => { + 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.listEnvironments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listEnvironments, request)); + assert( + (client.descriptors.page.listEnvironments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listEnvironmentsStream with error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEnvironments.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listEnvironmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.orchestration.airflow.service.v1beta1.Environment[] = []; + stream.on('data', (response: protos.google.cloud.orchestration.airflow.service.v1beta1.Environment) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listEnvironments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listEnvironments, request)); + assert( + (client.descriptors.page.listEnvironments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listEnvironments without error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), + ]; + client.descriptors.page.listEnvironments.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment[] = []; + const iterable = client.listEnvironmentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listEnvironments with error', async () => { + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEnvironments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listEnvironmentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listEnvironments.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 environmentsModule.v1beta1.EnvironmentsClient({ + 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 environmentsModule.v1beta1.EnvironmentsClient({ + 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 environmentsModule.v1beta1.EnvironmentsClient({ + 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 environmentsModule.v1beta1.EnvironmentsClient({ + 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 environmentsModule.v1beta1.EnvironmentsClient({ + 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 environmentsModule.v1beta1.EnvironmentsClient({ + 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 environmentsModule.v1beta1.EnvironmentsClient({ + 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 environmentsModule.v1beta1.EnvironmentsClient({ + 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 environmentsModule.v1beta1.EnvironmentsClient({ + 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 environmentsModule.v1beta1.EnvironmentsClient({ + 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 environmentsModule.v1beta1.EnvironmentsClient({ + 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('environment', () => { + const fakePath = "/rendered/path/environment"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + environment: "environmentValue", + }; + const client = new environmentsModule.v1beta1.EnvironmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.environmentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.environmentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('environmentPath', () => { + const result = client.environmentPath("projectValue", "locationValue", "environmentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.environmentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromEnvironmentName', () => { + const result = client.matchProjectFromEnvironmentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromEnvironmentName', () => { + const result = client.matchLocationFromEnvironmentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchEnvironmentFromEnvironmentName', () => { + const result = client.matchEnvironmentFromEnvironmentName(fakePath); + assert.strictEqual(result, "environmentValue"); + assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/test/gapic_image_versions_v1beta1.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/test/gapic_image_versions_v1beta1.ts new file mode 100644 index 00000000000..43138056002 --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/test/gapic_image_versions_v1beta1.ts @@ -0,0 +1,491 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 imageversionsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +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('v1beta1.ImageVersionsClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageversionsModule.v1beta1.ImageVersionsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageversionsModule.v1beta1.ImageVersionsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageversionsModule.v1beta1.ImageVersionsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageversionsModule.v1beta1.ImageVersionsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageversionsModule.v1beta1.ImageVersionsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageversionsModule.v1beta1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageVersionsStub, undefined); + await client.initialize(); + assert(client.imageVersionsStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageversionsModule.v1beta1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageVersionsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageversionsModule.v1beta1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageVersionsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageversionsModule.v1beta1.ImageVersionsClient({ + 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 imageversionsModule.v1beta1.ImageVersionsClient({ + 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('listImageVersions', () => { + it('invokes listImageVersions without error', async () => { + const client = new imageversionsModule.v1beta1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), + ]; + client.innerApiCalls.listImageVersions = stubSimpleCall(expectedResponse); + const [response] = await client.listImageVersions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listImageVersions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listImageVersions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listImageVersions without error using callback', async () => { + const client = new imageversionsModule.v1beta1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), + ]; + client.innerApiCalls.listImageVersions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listImageVersions( + request, + (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1beta1.IImageVersion[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listImageVersions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listImageVersions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listImageVersions with error', async () => { + const client = new imageversionsModule.v1beta1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listImageVersions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listImageVersions(request), expectedError); + const actualRequest = (client.innerApiCalls.listImageVersions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listImageVersions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listImageVersionsStream without error', async () => { + const client = new imageversionsModule.v1beta1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), + ]; + client.descriptors.page.listImageVersions.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listImageVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion[] = []; + stream.on('data', (response: protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion) => { + 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.listImageVersions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listImageVersions, request)); + assert( + (client.descriptors.page.listImageVersions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listImageVersionsStream with error', async () => { + const client = new imageversionsModule.v1beta1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listImageVersions.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listImageVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion[] = []; + stream.on('data', (response: protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listImageVersions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listImageVersions, request)); + assert( + (client.descriptors.page.listImageVersions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listImageVersions without error', async () => { + const client = new imageversionsModule.v1beta1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), + generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), + ]; + client.descriptors.page.listImageVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.orchestration.airflow.service.v1beta1.IImageVersion[] = []; + const iterable = client.listImageVersionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listImageVersions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listImageVersions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listImageVersions with error', async () => { + const client = new imageversionsModule.v1beta1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listImageVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listImageVersionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.orchestration.airflow.service.v1beta1.IImageVersion[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listImageVersions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listImageVersions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('environment', () => { + const fakePath = "/rendered/path/environment"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + environment: "environmentValue", + }; + const client = new imageversionsModule.v1beta1.ImageVersionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.environmentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.environmentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('environmentPath', () => { + const result = client.environmentPath("projectValue", "locationValue", "environmentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.environmentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromEnvironmentName', () => { + const result = client.matchProjectFromEnvironmentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromEnvironmentName', () => { + const result = client.matchLocationFromEnvironmentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchEnvironmentFromEnvironmentName', () => { + const result = client.matchEnvironmentFromEnvironmentName(fakePath); + assert.strictEqual(result, "environmentValue"); + assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/webpack.config.js new file mode 100644 index 00000000000..9b7becac60a --- /dev/null +++ b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'Environments', + filename: './environments.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-orgpolicy/v2/.eslintignore b/owl-bot-staging/google-cloud-orgpolicy/v2/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/.eslintrc.json b/owl-bot-staging/google-cloud-orgpolicy/v2/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/.gitignore b/owl-bot-staging/google-cloud-orgpolicy/v2/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/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-orgpolicy/v2/.jsdoc.js b/owl-bot-staging/google-cloud-orgpolicy/v2/.jsdoc.js new file mode 100644 index 00000000000..3a6f96b968e --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/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/org-policy', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/.mocharc.js b/owl-bot-staging/google-cloud-orgpolicy/v2/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/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-orgpolicy/v2/.prettierrc.js b/owl-bot-staging/google-cloud-orgpolicy/v2/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/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-orgpolicy/v2/README.md b/owl-bot-staging/google-cloud-orgpolicy/v2/README.md new file mode 100644 index 00000000000..1c081c68780 --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/README.md @@ -0,0 +1 @@ +Orgpolicy: Nodejs Client diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/package.json b/owl-bot-staging/google-cloud-orgpolicy/v2/package.json new file mode 100644 index 00000000000..b824cf8d9cd --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/org-policy", + "version": "0.1.0", + "description": "Orgpolicy client for Node.js", + "repository": "googleapis/nodejs-orgpolicy", + "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 orgpolicy", + "orgpolicy", + "org policy" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/protos/google/cloud/orgpolicy/v2/constraint.proto b/owl-bot-staging/google-cloud-orgpolicy/v2/protos/google/cloud/orgpolicy/v2/constraint.proto new file mode 100644 index 00000000000..9a14e93fa87 --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/protos/google/cloud/orgpolicy/v2/constraint.proto @@ -0,0 +1,126 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.orgpolicy.v2; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.OrgPolicy.V2"; +option go_package = "cloud.google.com/go/orgpolicy/apiv2/orgpolicypb;orgpolicypb"; +option java_multiple_files = true; +option java_outer_classname = "ConstraintProto"; +option java_package = "com.google.cloud.orgpolicy.v2"; +option php_namespace = "Google\\Cloud\\OrgPolicy\\V2"; +option ruby_package = "Google::Cloud::OrgPolicy::V2"; + +// A `constraint` describes a way to restrict resource's configuration. For +// example, you could enforce a constraint that controls which cloud services +// can be activated across an organization, or whether a Compute Engine instance +// can have serial port connections established. `Constraints` can be configured +// by the organization's policy administrator to fit the needs of the +// organization by setting a `policy` that includes `constraints` at different +// locations in the organization's resource hierarchy. Policies are inherited +// down the resource hierarchy from higher levels, but can also be overridden. +// For details about the inheritance rules please read about +// [`policies`][google.cloud.OrgPolicy.v2.Policy]. +// +// `Constraints` have a default behavior determined by the `constraint_default` +// field, which is the enforcement behavior that is used in the absence of a +// `policy` being defined or inherited for the resource in question. +message Constraint { + option (google.api.resource) = { + type: "orgpolicy.googleapis.com/Constraint" + pattern: "projects/{project}/constraints/{constraint}" + pattern: "folders/{folder}/constraints/{constraint}" + pattern: "organizations/{organization}/constraints/{constraint}" + }; + + // Specifies the default behavior in the absence of any `Policy` for the + // `Constraint`. This must not be `CONSTRAINT_DEFAULT_UNSPECIFIED`. + // + // Immutable after creation. + enum ConstraintDefault { + // This is only used for distinguishing unset values and should never be + // used. + CONSTRAINT_DEFAULT_UNSPECIFIED = 0; + + // Indicate that all values are allowed for list constraints. + // Indicate that enforcement is off for boolean constraints. + ALLOW = 1; + + // Indicate that all values are denied for list constraints. + // Indicate that enforcement is on for boolean constraints. + DENY = 2; + } + + // A `Constraint` that allows or disallows a list of string values, which are + // configured by an Organization's policy administrator with a `Policy`. + message ListConstraint { + // Indicates whether values grouped into categories can be used in + // `Policy.allowed_values` and `Policy.denied_values`. For example, + // `"in:Python"` would match any value in the 'Python' group. + bool supports_in = 1; + + // Indicates whether subtrees of Cloud Resource Manager resource hierarchy + // can be used in `Policy.allowed_values` and `Policy.denied_values`. For + // example, `"under:folders/123"` would match any resource under the + // 'folders/123' folder. + bool supports_under = 2; + } + + // A `Constraint` that is either enforced or not. + // + // For example a constraint `constraints/compute.disableSerialPortAccess`. + // If it is enforced on a VM instance, serial port connections will not be + // opened to that instance. + message BooleanConstraint {} + + // Immutable. The resource name of the Constraint. Must be in one of + // the following forms: + // * `projects/{project_number}/constraints/{constraint_name}` + // * `folders/{folder_id}/constraints/{constraint_name}` + // * `organizations/{organization_id}/constraints/{constraint_name}` + // + // For example, "/projects/123/constraints/compute.disableSerialPortAccess". + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // The human readable name. + // + // Mutable. + string display_name = 2; + + // Detailed description of what this `Constraint` controls as well as how and + // where it is enforced. + // + // Mutable. + string description = 3; + + // The evaluation behavior of this constraint in the absence of 'Policy'. + ConstraintDefault constraint_default = 4; + + // The type of restrictions for this `Constraint`. + // + // Immutable after creation. + oneof constraint_type { + // Defines this constraint as being a ListConstraint. + ListConstraint list_constraint = 5; + + // Defines this constraint as being a BooleanConstraint. + BooleanConstraint boolean_constraint = 6; + } +} diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/protos/google/cloud/orgpolicy/v2/orgpolicy.proto b/owl-bot-staging/google-cloud-orgpolicy/v2/protos/google/cloud/orgpolicy/v2/orgpolicy.proto new file mode 100644 index 00000000000..0504d074824 --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/protos/google/cloud/orgpolicy/v2/orgpolicy.proto @@ -0,0 +1,478 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.orgpolicy.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/orgpolicy/v2/constraint.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/expr.proto"; + +option csharp_namespace = "Google.Cloud.OrgPolicy.V2"; +option go_package = "cloud.google.com/go/orgpolicy/apiv2/orgpolicypb;orgpolicypb"; +option java_multiple_files = true; +option java_outer_classname = "OrgPolicyProto"; +option java_package = "com.google.cloud.orgpolicy.v2"; +option php_namespace = "Google\\Cloud\\OrgPolicy\\V2"; +option ruby_package = "Google::Cloud::OrgPolicy::V2"; + +// An interface for managing organization policies. +// +// The Cloud Org Policy service provides a simple mechanism for organizations to +// restrict the allowed configurations across their entire Cloud Resource +// hierarchy. +// +// You can use a `policy` to configure restrictions in Cloud resources. For +// example, you can enforce a `policy` that restricts which Google +// Cloud Platform APIs can be activated in a certain part of your resource +// hierarchy, or prevents serial port access to VM instances in a particular +// folder. +// +// `Policies` are inherited down through the resource hierarchy. A `policy` +// applied to a parent resource automatically applies to all its child resources +// unless overridden with a `policy` lower in the hierarchy. +// +// A `constraint` defines an aspect of a resource's configuration that can be +// controlled by an organization's policy administrator. `Policies` are a +// collection of `constraints` that defines their allowable configuration on a +// particular resource and its child resources. +service OrgPolicy { + option (google.api.default_host) = "orgpolicy.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Lists `Constraints` that could be applied on the specified resource. + rpc ListConstraints(ListConstraintsRequest) + returns (ListConstraintsResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*}/constraints" + additional_bindings { get: "/v2/{parent=folders/*}/constraints" } + additional_bindings { get: "/v2/{parent=organizations/*}/constraints" } + }; + option (google.api.method_signature) = "parent"; + } + + // Retrieves all of the `Policies` that exist on a particular resource. + rpc ListPolicies(ListPoliciesRequest) returns (ListPoliciesResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*}/policies" + additional_bindings { get: "/v2/{parent=folders/*}/policies" } + additional_bindings { get: "/v2/{parent=organizations/*}/policies" } + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a `Policy` on a resource. + // + // If no `Policy` is set on the resource, NOT_FOUND is returned. The + // `etag` value can be used with `UpdatePolicy()` to update a + // `Policy` during read-modify-write. + rpc GetPolicy(GetPolicyRequest) returns (Policy) { + option (google.api.http) = { + get: "/v2/{name=projects/*/policies/*}" + additional_bindings { get: "/v2/{name=folders/*/policies/*}" } + additional_bindings { get: "/v2/{name=organizations/*/policies/*}" } + }; + option (google.api.method_signature) = "name"; + } + + // Gets the effective `Policy` on a resource. This is the result of merging + // `Policies` in the resource hierarchy and evaluating conditions. The + // returned `Policy` will not have an `etag` or `condition` set because it is + // a computed `Policy` across multiple resources. + // Subtrees of Resource Manager resource hierarchy with 'under:' prefix will + // not be expanded. + rpc GetEffectivePolicy(GetEffectivePolicyRequest) returns (Policy) { + option (google.api.http) = { + get: "/v2/{name=projects/*/policies/*}:getEffectivePolicy" + additional_bindings { + get: "/v2/{name=folders/*/policies/*}:getEffectivePolicy" + } + additional_bindings { + get: "/v2/{name=organizations/*/policies/*}:getEffectivePolicy" + } + }; + option (google.api.method_signature) = "name"; + } + + // Creates a Policy. + // + // Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the + // constraint does not exist. + // Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the + // policy already exists on the given Cloud resource. + rpc CreatePolicy(CreatePolicyRequest) returns (Policy) { + option (google.api.http) = { + post: "/v2/{parent=projects/*}/policies" + body: "policy" + additional_bindings { + post: "/v2/{parent=folders/*}/policies" + body: "policy" + } + additional_bindings { + post: "/v2/{parent=organizations/*}/policies" + body: "policy" + } + }; + option (google.api.method_signature) = "parent,policy"; + } + + // Updates a Policy. + // + // Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the + // constraint or the policy do not exist. + // Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag + // supplied in the request does not match the persisted etag of the policy + // + // Note: the supplied policy will perform a full overwrite of all + // fields. + rpc UpdatePolicy(UpdatePolicyRequest) returns (Policy) { + option (google.api.http) = { + patch: "/v2/{policy.name=projects/*/policies/*}" + body: "policy" + additional_bindings { + patch: "/v2/{policy.name=folders/*/policies/*}" + body: "policy" + } + additional_bindings { + patch: "/v2/{policy.name=organizations/*/policies/*}" + body: "policy" + } + }; + option (google.api.method_signature) = "policy"; + } + + // Deletes a Policy. + // + // Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the + // constraint or Org Policy does not exist. + rpc DeletePolicy(DeletePolicyRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/policies/*}" + additional_bindings { delete: "/v2/{name=folders/*/policies/*}" } + additional_bindings { delete: "/v2/{name=organizations/*/policies/*}" } + }; + option (google.api.method_signature) = "name"; + } +} + +// Defines a Cloud Organization `Policy` which is used to specify `Constraints` +// for configurations of Cloud Platform resources. +message Policy { + option (google.api.resource) = { + type: "orgpolicy.googleapis.com/Policy" + pattern: "projects/{project}/policies/{policy}" + pattern: "folders/{folder}/policies/{policy}" + pattern: "organizations/{organization}/policies/{policy}" + }; + + // Immutable. The resource name of the Policy. Must be one of the following + // forms, where constraint_name is the name of the constraint which this + // Policy configures: + // * `projects/{project_number}/policies/{constraint_name}` + // * `folders/{folder_id}/policies/{constraint_name}` + // * `organizations/{organization_id}/policies/{constraint_name}` + // + // For example, "projects/123/policies/compute.disableSerialPortAccess". + // + // Note: `projects/{project_id}/policies/{constraint_name}` is also an + // acceptable name for API requests, but responses will return the name using + // the equivalent project number. + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Basic information about the Organization Policy. + PolicySpec spec = 2; + + // Deprecated. + AlternatePolicySpec alternate = 3 [deprecated = true]; + + // dry-run policy. + // Audit-only policy, can be used to monitor how the policy would have + // impacted the existing and future resources if it's enforced. + PolicySpec dry_run_spec = 4; +} + +// Similar to PolicySpec but with an extra 'launch' field for launch reference. +// The PolicySpec here is specific for dry-run/darklaunch. +message AlternatePolicySpec { + // Reference to the launch that will be used while audit logging and to + // control the launch. + // Should be set only in the alternate policy. + string launch = 1; + + // Specify `Constraint` for configurations of Cloud Platform resources. + PolicySpec spec = 2; +} + +// Defines a Cloud Organization `PolicySpec` which is used to specify +// `Constraints` for configurations of Cloud Platform resources. +message PolicySpec { + // A rule used to express this policy. + message PolicyRule { + // A message that holds specific allowed and denied values. + // This message can define specific values and subtrees of Cloud Resource + // Manager resource hierarchy (`Organizations`, `Folders`, `Projects`) that + // are allowed or denied. This is achieved by using the `under:` and + // optional `is:` prefixes. + // The `under:` prefix is used to denote resource subtree values. + // The `is:` prefix is used to denote specific values, and is required only + // if the value contains a ":". Values prefixed with "is:" are treated the + // same as values with no prefix. + // Ancestry subtrees must be in one of the following formats: + // - "projects/", e.g. "projects/tokyo-rain-123" + // - "folders/", e.g. "folders/1234" + // - "organizations/", e.g. "organizations/1234" + // The `supports_under` field of the associated `Constraint` defines + // whether ancestry prefixes can be used. + message StringValues { + // List of values allowed at this resource. + repeated string allowed_values = 1; + + // List of values denied at this resource. + repeated string denied_values = 2; + } + + oneof kind { + // List of values to be used for this PolicyRule. This field can be set + // only in Policies for list constraints. + StringValues values = 1; + + // Setting this to true means that all values are allowed. This field can + // be set only in Policies for list constraints. + bool allow_all = 2; + + // Setting this to true means that all values are denied. This field can + // be set only in Policies for list constraints. + bool deny_all = 3; + + // If `true`, then the `Policy` is enforced. If `false`, then any + // configuration is acceptable. + // This field can be set only in Policies for boolean constraints. + bool enforce = 4; + } + + // A condition which determines whether this rule is used + // in the evaluation of the policy. When set, the `expression` field in + // the `Expr' must include from 1 to 10 subexpressions, joined by the "||" + // or "&&" operators. Each subexpression must be of the form + // "resource.matchTag('/tag_key_short_name, + // 'tag_value_short_name')". or "resource.matchTagId('tagKeys/key_id', + // 'tagValues/value_id')". where key_name and value_name are the resource + // names for Label Keys and Values. These names are available from the Tag + // Manager Service. An example expression is: + // "resource.matchTag('123456789/environment, + // 'prod')". or "resource.matchTagId('tagKeys/123', + // 'tagValues/456')". + google.type.Expr condition = 5; + } + + // An opaque tag indicating the current version of the `Policy`, used for + // concurrency control. + // + // This field is ignored if used in a `CreatePolicy` request. + // + // When the `Policy` is returned from either a `GetPolicy` or a + // `ListPolicies` request, this `etag` indicates the version of the + // current `Policy` to use when executing a read-modify-write loop. + // + // When the `Policy` is returned from a `GetEffectivePolicy` request, the + // `etag` will be unset. + string etag = 1; + + // Output only. The time stamp this was previously updated. This + // represents the last time a call to `CreatePolicy` or `UpdatePolicy` was + // made for that `Policy`. + google.protobuf.Timestamp update_time = 2 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Up to 10 PolicyRules are allowed. + // + // In Policies for boolean constraints, the following requirements apply: + // - There must be one and only one PolicyRule where condition is unset. + // - BooleanPolicyRules with conditions must set `enforced` to the opposite + // of the PolicyRule without a condition. + // - During policy evaluation, PolicyRules with conditions that are + // true for a target resource take precedence. + repeated PolicyRule rules = 3; + + // Determines the inheritance behavior for this `Policy`. + // + // If `inherit_from_parent` is true, PolicyRules set higher up in the + // hierarchy (up to the closest root) are inherited and present in the + // effective policy. If it is false, then no rules are inherited, and this + // Policy becomes the new root for evaluation. + // This field can be set only for Policies which configure list constraints. + bool inherit_from_parent = 4; + + // Ignores policies set above this resource and restores the + // `constraint_default` enforcement behavior of the specific `Constraint` at + // this resource. + // This field can be set in policies for either list or boolean + // constraints. If set, `rules` must be empty and `inherit_from_parent` + // must be set to false. + bool reset = 5; +} + +// The request sent to the [ListConstraints] +// [google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints] method. +message ListConstraintsRequest { + // Required. The Cloud resource that parents the constraint. Must be in one of + // the following forms: + // * `projects/{project_number}` + // * `projects/{project_id}` + // * `folders/{folder_id}` + // * `organizations/{organization_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "orgpolicy.googleapis.com/Constraint" + } + ]; + + // Size of the pages to be returned. This is currently unsupported and will + // be ignored. The server may at any point start using this field to limit + // page size. + int32 page_size = 2; + + // Page token used to retrieve the next page. This is currently unsupported + // and will be ignored. The server may at any point start using this field. + string page_token = 3; +} + +// The response returned from the [ListConstraints] +// [google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints] method. +message ListConstraintsResponse { + // The collection of constraints that are available on the targeted resource. + repeated Constraint constraints = 1; + + // Page token used to retrieve the next page. This is currently not used. + string next_page_token = 2; +} + +// The request sent to the [ListPolicies] +// [google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies] method. +message ListPoliciesRequest { + // Required. The target Cloud resource that parents the set of constraints and + // policies that will be returned from this call. Must be in one of the + // following forms: + // * `projects/{project_number}` + // * `projects/{project_id}` + // * `folders/{folder_id}` + // * `organizations/{organization_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "orgpolicy.googleapis.com/Policy" + } + ]; + + // Size of the pages to be returned. This is currently unsupported and will + // be ignored. The server may at any point start using this field to limit + // page size. + int32 page_size = 2; + + // Page token used to retrieve the next page. This is currently unsupported + // and will be ignored. The server may at any point start using this field. + string page_token = 3; +} + +// The response returned from the [ListPolicies] +// [google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies] method. It will be empty +// if no `Policies` are set on the resource. +message ListPoliciesResponse { + // All `Policies` that exist on the resource. It will be empty if no + // `Policies` are set. + repeated Policy policies = 1; + + // Page token used to retrieve the next page. This is currently not used, but + // the server may at any point start supplying a valid token. + string next_page_token = 2; +} + +// The request sent to the [GetPolicy] +// [google.cloud.orgpolicy.v2.OrgPolicy.GetPolicy] method. +message GetPolicyRequest { + // Required. Resource name of the policy. See `Policy` for naming + // requirements. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "orgpolicy.googleapis.com/Policy" + } + ]; +} + +// The request sent to the [GetEffectivePolicy] +// [google.cloud.orgpolicy.v2.OrgPolicy.GetEffectivePolicy] method. +message GetEffectivePolicyRequest { + // Required. The effective policy to compute. See `Policy` for naming rules. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "orgpolicy.googleapis.com/Policy" + } + ]; +} + +// The request sent to the [CreatePolicyRequest] +// [google.cloud.orgpolicy.v2.OrgPolicy.CreatePolicy] method. +message CreatePolicyRequest { + // Required. The Cloud resource that will parent the new Policy. Must be in + // one of the following forms: + // * `projects/{project_number}` + // * `projects/{project_id}` + // * `folders/{folder_id}` + // * `organizations/{organization_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "orgpolicy.googleapis.com/Policy" + } + ]; + + // Required. `Policy` to create. + Policy policy = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// The request sent to the [UpdatePolicyRequest] +// [google.cloud.orgpolicy.v2.OrgPolicy.UpdatePolicy] method. +message UpdatePolicyRequest { + // Required. `Policy` to update. + Policy policy = 1 [(google.api.field_behavior) = REQUIRED]; + + // Field mask used to specify the fields to be overwritten in the policy + // by the set. The fields specified in the update_mask are relative to the + // policy, not the full request. + google.protobuf.FieldMask update_mask = 3; +} + +// The request sent to the [DeletePolicy] +// [google.cloud.orgpolicy.v2.OrgPolicy.DeletePolicy] method. +message DeletePolicyRequest { + // Required. Name of the policy to delete. + // See `Policy` for naming rules. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "orgpolicy.googleapis.com/Policy" + } + ]; +} diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.create_policy.js b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.create_policy.js new file mode 100644 index 00000000000..9332ceeffea --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.create_policy.js @@ -0,0 +1,71 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, policy) { + // [START orgpolicy_v2_generated_OrgPolicy_CreatePolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Cloud resource that will parent the new Policy. Must be in + * one of the following forms: + * * `projects/{project_number}` + * * `projects/{project_id}` + * * `folders/{folder_id}` + * * `organizations/{organization_id}` + */ + // const parent = 'abc123' + /** + * Required. `Policy` to create. + */ + // const policy = {} + + // Imports the Orgpolicy library + const {OrgPolicyClient} = require('@google-cloud/org-policy').v2; + + // Instantiates a client + const orgpolicyClient = new OrgPolicyClient(); + + async function callCreatePolicy() { + // Construct request + const request = { + parent, + policy, + }; + + // Run request + const response = await orgpolicyClient.createPolicy(request); + console.log(response); + } + + callCreatePolicy(); + // [END orgpolicy_v2_generated_OrgPolicy_CreatePolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.delete_policy.js b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.delete_policy.js new file mode 100644 index 00000000000..412ca7ab8d6 --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.delete_policy.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 orgpolicy_v2_generated_OrgPolicy_DeletePolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the policy to delete. + * See `Policy` for naming rules. + */ + // const name = 'abc123' + + // Imports the Orgpolicy library + const {OrgPolicyClient} = require('@google-cloud/org-policy').v2; + + // Instantiates a client + const orgpolicyClient = new OrgPolicyClient(); + + async function callDeletePolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await orgpolicyClient.deletePolicy(request); + console.log(response); + } + + callDeletePolicy(); + // [END orgpolicy_v2_generated_OrgPolicy_DeletePolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.get_effective_policy.js b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.get_effective_policy.js new file mode 100644 index 00000000000..395162c82ef --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.get_effective_policy.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(name) { + // [START orgpolicy_v2_generated_OrgPolicy_GetEffectivePolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The effective policy to compute. See `Policy` for naming rules. + */ + // const name = 'abc123' + + // Imports the Orgpolicy library + const {OrgPolicyClient} = require('@google-cloud/org-policy').v2; + + // Instantiates a client + const orgpolicyClient = new OrgPolicyClient(); + + async function callGetEffectivePolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await orgpolicyClient.getEffectivePolicy(request); + console.log(response); + } + + callGetEffectivePolicy(); + // [END orgpolicy_v2_generated_OrgPolicy_GetEffectivePolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.get_policy.js b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.get_policy.js new file mode 100644 index 00000000000..532fe0441f7 --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.get_policy.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 orgpolicy_v2_generated_OrgPolicy_GetPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the policy. See `Policy` for naming + * requirements. + */ + // const name = 'abc123' + + // Imports the Orgpolicy library + const {OrgPolicyClient} = require('@google-cloud/org-policy').v2; + + // Instantiates a client + const orgpolicyClient = new OrgPolicyClient(); + + async function callGetPolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await orgpolicyClient.getPolicy(request); + console.log(response); + } + + callGetPolicy(); + // [END orgpolicy_v2_generated_OrgPolicy_GetPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.list_constraints.js b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.list_constraints.js new file mode 100644 index 00000000000..c65243b9610 --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.list_constraints.js @@ -0,0 +1,79 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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 orgpolicy_v2_generated_OrgPolicy_ListConstraints_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Cloud resource that parents the constraint. Must be in one of + * the following forms: + * * `projects/{project_number}` + * * `projects/{project_id}` + * * `folders/{folder_id}` + * * `organizations/{organization_id}` + */ + // const parent = 'abc123' + /** + * Size of the pages to be returned. This is currently unsupported and will + * be ignored. The server may at any point start using this field to limit + * page size. + */ + // const pageSize = 1234 + /** + * Page token used to retrieve the next page. This is currently unsupported + * and will be ignored. The server may at any point start using this field. + */ + // const pageToken = 'abc123' + + // Imports the Orgpolicy library + const {OrgPolicyClient} = require('@google-cloud/org-policy').v2; + + // Instantiates a client + const orgpolicyClient = new OrgPolicyClient(); + + async function callListConstraints() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await orgpolicyClient.listConstraintsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListConstraints(); + // [END orgpolicy_v2_generated_OrgPolicy_ListConstraints_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.list_policies.js b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.list_policies.js new file mode 100644 index 00000000000..37256b96f4f --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.list_policies.js @@ -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. ** + + + +'use strict'; + +function main(parent) { + // [START orgpolicy_v2_generated_OrgPolicy_ListPolicies_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The target Cloud resource that parents the set of constraints and + * policies that will be returned from this call. Must be in one of the + * following forms: + * * `projects/{project_number}` + * * `projects/{project_id}` + * * `folders/{folder_id}` + * * `organizations/{organization_id}` + */ + // const parent = 'abc123' + /** + * Size of the pages to be returned. This is currently unsupported and will + * be ignored. The server may at any point start using this field to limit + * page size. + */ + // const pageSize = 1234 + /** + * Page token used to retrieve the next page. This is currently unsupported + * and will be ignored. The server may at any point start using this field. + */ + // const pageToken = 'abc123' + + // Imports the Orgpolicy library + const {OrgPolicyClient} = require('@google-cloud/org-policy').v2; + + // Instantiates a client + const orgpolicyClient = new OrgPolicyClient(); + + async function callListPolicies() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await orgpolicyClient.listPoliciesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListPolicies(); + // [END orgpolicy_v2_generated_OrgPolicy_ListPolicies_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.update_policy.js b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.update_policy.js new file mode 100644 index 00000000000..3b91bf0d04a --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.update_policy.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(policy) { + // [START orgpolicy_v2_generated_OrgPolicy_UpdatePolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. `Policy` to update. + */ + // const policy = {} + /** + * Field mask used to specify the fields to be overwritten in the policy + * by the set. The fields specified in the update_mask are relative to the + * policy, not the full request. + */ + // const updateMask = {} + + // Imports the Orgpolicy library + const {OrgPolicyClient} = require('@google-cloud/org-policy').v2; + + // Instantiates a client + const orgpolicyClient = new OrgPolicyClient(); + + async function callUpdatePolicy() { + // Construct request + const request = { + policy, + }; + + // Run request + const response = await orgpolicyClient.updatePolicy(request); + console.log(response); + } + + callUpdatePolicy(); + // [END orgpolicy_v2_generated_OrgPolicy_UpdatePolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/snippet_metadata_google.cloud.orgpolicy.v2.json b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/snippet_metadata_google.cloud.orgpolicy.v2.json new file mode 100644 index 00000000000..8863c861327 --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/snippet_metadata_google.cloud.orgpolicy.v2.json @@ -0,0 +1,319 @@ +{ + "clientLibrary": { + "name": "nodejs-orgpolicy", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.orgpolicy.v2", + "version": "v2" + } + ] + }, + "snippets": [ + { + "regionTag": "orgpolicy_v2_generated_OrgPolicy_ListConstraints_async", + "title": "OrgPolicy listConstraints Sample", + "origin": "API_DEFINITION", + "description": " Lists `Constraints` that could be applied on the specified resource.", + "canonical": true, + "file": "org_policy.list_constraints.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListConstraints", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.orgpolicy.v2.ListConstraintsResponse", + "client": { + "shortName": "OrgPolicyClient", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicyClient" + }, + "method": { + "shortName": "ListConstraints", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints", + "service": { + "shortName": "OrgPolicy", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicy" + } + } + } + }, + { + "regionTag": "orgpolicy_v2_generated_OrgPolicy_ListPolicies_async", + "title": "OrgPolicy listPolicies Sample", + "origin": "API_DEFINITION", + "description": " Retrieves all of the `Policies` that exist on a particular resource.", + "canonical": true, + "file": "org_policy.list_policies.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListPolicies", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.orgpolicy.v2.ListPoliciesResponse", + "client": { + "shortName": "OrgPolicyClient", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicyClient" + }, + "method": { + "shortName": "ListPolicies", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies", + "service": { + "shortName": "OrgPolicy", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicy" + } + } + } + }, + { + "regionTag": "orgpolicy_v2_generated_OrgPolicy_GetPolicy_async", + "title": "OrgPolicy getPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets a `Policy` on a resource. If no `Policy` is set on the resource, NOT_FOUND is returned. The `etag` value can be used with `UpdatePolicy()` to update a `Policy` during read-modify-write.", + "canonical": true, + "file": "org_policy.get_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetPolicy", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.GetPolicy", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.orgpolicy.v2.Policy", + "client": { + "shortName": "OrgPolicyClient", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicyClient" + }, + "method": { + "shortName": "GetPolicy", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.GetPolicy", + "service": { + "shortName": "OrgPolicy", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicy" + } + } + } + }, + { + "regionTag": "orgpolicy_v2_generated_OrgPolicy_GetEffectivePolicy_async", + "title": "OrgPolicy getEffectivePolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the effective `Policy` on a resource. This is the result of merging `Policies` in the resource hierarchy and evaluating conditions. The returned `Policy` will not have an `etag` or `condition` set because it is a computed `Policy` across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.", + "canonical": true, + "file": "org_policy.get_effective_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetEffectivePolicy", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.GetEffectivePolicy", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.orgpolicy.v2.Policy", + "client": { + "shortName": "OrgPolicyClient", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicyClient" + }, + "method": { + "shortName": "GetEffectivePolicy", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.GetEffectivePolicy", + "service": { + "shortName": "OrgPolicy", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicy" + } + } + } + }, + { + "regionTag": "orgpolicy_v2_generated_OrgPolicy_CreatePolicy_async", + "title": "OrgPolicy createPolicy Sample", + "origin": "API_DEFINITION", + "description": " Creates a Policy. Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint does not exist. Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the policy already exists on the given Cloud resource.", + "canonical": true, + "file": "org_policy.create_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreatePolicy", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.CreatePolicy", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "policy", + "type": ".google.cloud.orgpolicy.v2.Policy" + } + ], + "resultType": ".google.cloud.orgpolicy.v2.Policy", + "client": { + "shortName": "OrgPolicyClient", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicyClient" + }, + "method": { + "shortName": "CreatePolicy", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.CreatePolicy", + "service": { + "shortName": "OrgPolicy", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicy" + } + } + } + }, + { + "regionTag": "orgpolicy_v2_generated_OrgPolicy_UpdatePolicy_async", + "title": "OrgPolicy updatePolicy Sample", + "origin": "API_DEFINITION", + "description": " Updates a Policy. Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or the policy do not exist. Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag supplied in the request does not match the persisted etag of the policy Note: the supplied policy will perform a full overwrite of all fields.", + "canonical": true, + "file": "org_policy.update_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdatePolicy", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.UpdatePolicy", + "async": true, + "parameters": [ + { + "name": "policy", + "type": ".google.cloud.orgpolicy.v2.Policy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.orgpolicy.v2.Policy", + "client": { + "shortName": "OrgPolicyClient", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicyClient" + }, + "method": { + "shortName": "UpdatePolicy", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.UpdatePolicy", + "service": { + "shortName": "OrgPolicy", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicy" + } + } + } + }, + { + "regionTag": "orgpolicy_v2_generated_OrgPolicy_DeletePolicy_async", + "title": "OrgPolicy deletePolicy Sample", + "origin": "API_DEFINITION", + "description": " Deletes a Policy. Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or Org Policy does not exist.", + "canonical": true, + "file": "org_policy.delete_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeletePolicy", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.DeletePolicy", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "OrgPolicyClient", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicyClient" + }, + "method": { + "shortName": "DeletePolicy", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.DeletePolicy", + "service": { + "shortName": "OrgPolicy", + "fullName": "google.cloud.orgpolicy.v2.OrgPolicy" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/src/index.ts b/owl-bot-staging/google-cloud-orgpolicy/v2/src/index.ts new file mode 100644 index 00000000000..cc6385df5ae --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 OrgPolicyClient = v2.OrgPolicyClient; +type OrgPolicyClient = v2.OrgPolicyClient; +export {v2, OrgPolicyClient}; +export default {v2, OrgPolicyClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/gapic_metadata.json b/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/gapic_metadata.json new file mode 100644 index 00000000000..3fd440b8082 --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/gapic_metadata.json @@ -0,0 +1,101 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.orgpolicy.v2", + "libraryPackage": "@google-cloud/org-policy", + "services": { + "OrgPolicy": { + "clients": { + "grpc": { + "libraryClient": "OrgPolicyClient", + "rpcs": { + "GetPolicy": { + "methods": [ + "getPolicy" + ] + }, + "GetEffectivePolicy": { + "methods": [ + "getEffectivePolicy" + ] + }, + "CreatePolicy": { + "methods": [ + "createPolicy" + ] + }, + "UpdatePolicy": { + "methods": [ + "updatePolicy" + ] + }, + "DeletePolicy": { + "methods": [ + "deletePolicy" + ] + }, + "ListConstraints": { + "methods": [ + "listConstraints", + "listConstraintsStream", + "listConstraintsAsync" + ] + }, + "ListPolicies": { + "methods": [ + "listPolicies", + "listPoliciesStream", + "listPoliciesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "OrgPolicyClient", + "rpcs": { + "GetPolicy": { + "methods": [ + "getPolicy" + ] + }, + "GetEffectivePolicy": { + "methods": [ + "getEffectivePolicy" + ] + }, + "CreatePolicy": { + "methods": [ + "createPolicy" + ] + }, + "UpdatePolicy": { + "methods": [ + "updatePolicy" + ] + }, + "DeletePolicy": { + "methods": [ + "deletePolicy" + ] + }, + "ListConstraints": { + "methods": [ + "listConstraints", + "listConstraintsStream", + "listConstraintsAsync" + ] + }, + "ListPolicies": { + "methods": [ + "listPolicies", + "listPoliciesStream", + "listPoliciesAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/index.ts b/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/index.ts new file mode 100644 index 00000000000..3b20fe25840 --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {OrgPolicyClient} from './org_policy_client'; diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_client.ts b/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_client.ts new file mode 100644 index 00000000000..8a0e6a89edf --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_client.ts @@ -0,0 +1,1385 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/org_policy_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './org_policy_client_config.json'; +const version = require('../../../package.json').version; + +/** + * An interface for managing organization policies. + * + * The Cloud Org Policy service provides a simple mechanism for organizations to + * restrict the allowed configurations across their entire Cloud Resource + * hierarchy. + * + * You can use a `policy` to configure restrictions in Cloud resources. For + * example, you can enforce a `policy` that restricts which Google + * Cloud Platform APIs can be activated in a certain part of your resource + * hierarchy, or prevents serial port access to VM instances in a particular + * folder. + * + * `Policies` are inherited down through the resource hierarchy. A `policy` + * applied to a parent resource automatically applies to all its child resources + * unless overridden with a `policy` lower in the hierarchy. + * + * A `constraint` defines an aspect of a resource's configuration that can be + * controlled by an organization's policy administrator. `Policies` are a + * collection of `constraints` that defines their allowable configuration on a + * particular resource and its child resources. + * @class + * @memberof v2 + */ +export class OrgPolicyClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + orgPolicyStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of OrgPolicyClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 OrgPolicyClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof OrgPolicyClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + folderConstraintPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/constraints/{constraint}' + ), + folderPolicyPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/policies/{policy}' + ), + organizationConstraintPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/constraints/{constraint}' + ), + organizationPolicyPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/policies/{policy}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + projectConstraintPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/constraints/{constraint}' + ), + projectPolicyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/policies/{policy}' + ), + }; + + // 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 = { + listConstraints: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'constraints'), + listPolicies: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'policies') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.orgpolicy.v2.OrgPolicy', 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.orgPolicyStub) { + return this.orgPolicyStub; + } + + // Put together the "service stub" for + // google.cloud.orgpolicy.v2.OrgPolicy. + this.orgPolicyStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.orgpolicy.v2.OrgPolicy') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.orgpolicy.v2.OrgPolicy, + 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 orgPolicyStubMethods = + ['listConstraints', 'listPolicies', 'getPolicy', 'getEffectivePolicy', 'createPolicy', 'updatePolicy', 'deletePolicy']; + for (const methodName of orgPolicyStubMethods) { + const callPromise = this.orgPolicyStub.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.orgPolicyStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'orgpolicy.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 'orgpolicy.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 `Policy` on a resource. + * + * If no `Policy` is set on the resource, NOT_FOUND is returned. The + * `etag` value can be used with `UpdatePolicy()` to update a + * `Policy` during read-modify-write. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the policy. See `Policy` for naming + * requirements. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.orgpolicy.v2.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/org_policy.get_policy.js + * region_tag:orgpolicy_v2_generated_OrgPolicy_GetPolicy_async + */ + getPolicy( + request?: protos.google.cloud.orgpolicy.v2.IGetPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.IGetPolicyRequest|undefined, {}|undefined + ]>; + getPolicy( + request: protos.google.cloud.orgpolicy.v2.IGetPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.IGetPolicyRequest|null|undefined, + {}|null|undefined>): void; + getPolicy( + request: protos.google.cloud.orgpolicy.v2.IGetPolicyRequest, + callback: Callback< + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.IGetPolicyRequest|null|undefined, + {}|null|undefined>): void; + getPolicy( + request?: protos.google.cloud.orgpolicy.v2.IGetPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.IGetPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.IGetPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.IGetPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getPolicy(request, options, callback); + } +/** + * Gets the effective `Policy` on a resource. This is the result of merging + * `Policies` in the resource hierarchy and evaluating conditions. The + * returned `Policy` will not have an `etag` or `condition` set because it is + * a computed `Policy` across multiple resources. + * Subtrees of Resource Manager resource hierarchy with 'under:' prefix will + * not be expanded. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The effective policy to compute. See `Policy` for naming rules. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.orgpolicy.v2.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/org_policy.get_effective_policy.js + * region_tag:orgpolicy_v2_generated_OrgPolicy_GetEffectivePolicy_async + */ + getEffectivePolicy( + request?: protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest|undefined, {}|undefined + ]>; + getEffectivePolicy( + request: protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest|null|undefined, + {}|null|undefined>): void; + getEffectivePolicy( + request: protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest, + callback: Callback< + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest|null|undefined, + {}|null|undefined>): void; + getEffectivePolicy( + request?: protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getEffectivePolicy(request, options, callback); + } +/** + * Creates a Policy. + * + * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the + * constraint does not exist. + * Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the + * policy already exists on the given Cloud resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The Cloud resource that will parent the new Policy. Must be in + * one of the following forms: + * * `projects/{project_number}` + * * `projects/{project_id}` + * * `folders/{folder_id}` + * * `organizations/{organization_id}` + * @param {google.cloud.orgpolicy.v2.Policy} request.policy + * Required. `Policy` to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.orgpolicy.v2.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/org_policy.create_policy.js + * region_tag:orgpolicy_v2_generated_OrgPolicy_CreatePolicy_async + */ + createPolicy( + request?: protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest|undefined, {}|undefined + ]>; + createPolicy( + request: protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest|null|undefined, + {}|null|undefined>): void; + createPolicy( + request: protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest, + callback: Callback< + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest|null|undefined, + {}|null|undefined>): void; + createPolicy( + request?: protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createPolicy(request, options, callback); + } +/** + * Updates a Policy. + * + * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the + * constraint or the policy do not exist. + * Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag + * supplied in the request does not match the persisted etag of the policy + * + * Note: the supplied policy will perform a full overwrite of all + * fields. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.orgpolicy.v2.Policy} request.policy + * Required. `Policy` to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Field mask used to specify the fields to be overwritten in the policy + * by the set. The fields specified in the update_mask are relative to the + * policy, not the full request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.orgpolicy.v2.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/org_policy.update_policy.js + * region_tag:orgpolicy_v2_generated_OrgPolicy_UpdatePolicy_async + */ + updatePolicy( + request?: protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest|undefined, {}|undefined + ]>; + updatePolicy( + request: protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest|null|undefined, + {}|null|undefined>): void; + updatePolicy( + request: protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest, + callback: Callback< + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest|null|undefined, + {}|null|undefined>): void; + updatePolicy( + request?: protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.orgpolicy.v2.IPolicy, + protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'policy.name': request.policy!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updatePolicy(request, options, callback); + } +/** + * Deletes a Policy. + * + * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the + * constraint or Org Policy does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the policy to delete. + * See `Policy` for naming rules. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/org_policy.delete_policy.js + * region_tag:orgpolicy_v2_generated_OrgPolicy_DeletePolicy_async + */ + deletePolicy( + request?: protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest|undefined, {}|undefined + ]>; + deletePolicy( + request: protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest|null|undefined, + {}|null|undefined>): void; + deletePolicy( + request: protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest|null|undefined, + {}|null|undefined>): void; + deletePolicy( + request?: protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deletePolicy(request, options, callback); + } + + /** + * Lists `Constraints` that could be applied on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The Cloud resource that parents the constraint. Must be in one of + * the following forms: + * * `projects/{project_number}` + * * `projects/{project_id}` + * * `folders/{folder_id}` + * * `organizations/{organization_id}` + * @param {number} request.pageSize + * Size of the pages to be returned. This is currently unsupported and will + * be ignored. The server may at any point start using this field to limit + * page size. + * @param {string} request.pageToken + * Page token used to retrieve the next page. This is currently unsupported + * and will be ignored. The server may at any point start using this field. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.orgpolicy.v2.Constraint|Constraint}. + * 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 `listConstraintsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listConstraints( + request?: protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.orgpolicy.v2.IConstraint[], + protos.google.cloud.orgpolicy.v2.IListConstraintsRequest|null, + protos.google.cloud.orgpolicy.v2.IListConstraintsResponse + ]>; + listConstraints( + request: protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, + protos.google.cloud.orgpolicy.v2.IListConstraintsResponse|null|undefined, + protos.google.cloud.orgpolicy.v2.IConstraint>): void; + listConstraints( + request: protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, + callback: PaginationCallback< + protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, + protos.google.cloud.orgpolicy.v2.IListConstraintsResponse|null|undefined, + protos.google.cloud.orgpolicy.v2.IConstraint>): void; + listConstraints( + request?: protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, + protos.google.cloud.orgpolicy.v2.IListConstraintsResponse|null|undefined, + protos.google.cloud.orgpolicy.v2.IConstraint>, + callback?: PaginationCallback< + protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, + protos.google.cloud.orgpolicy.v2.IListConstraintsResponse|null|undefined, + protos.google.cloud.orgpolicy.v2.IConstraint>): + Promise<[ + protos.google.cloud.orgpolicy.v2.IConstraint[], + protos.google.cloud.orgpolicy.v2.IListConstraintsRequest|null, + protos.google.cloud.orgpolicy.v2.IListConstraintsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listConstraints(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 Cloud resource that parents the constraint. Must be in one of + * the following forms: + * * `projects/{project_number}` + * * `projects/{project_id}` + * * `folders/{folder_id}` + * * `organizations/{organization_id}` + * @param {number} request.pageSize + * Size of the pages to be returned. This is currently unsupported and will + * be ignored. The server may at any point start using this field to limit + * page size. + * @param {string} request.pageToken + * Page token used to retrieve the next page. This is currently unsupported + * and will be ignored. The server may at any point start using this field. + * @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 protos.google.cloud.orgpolicy.v2.Constraint|Constraint} 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 `listConstraintsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listConstraintsStream( + request?: protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, + 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['listConstraints']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listConstraints.createStream( + this.innerApiCalls.listConstraints as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listConstraints`, 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 Cloud resource that parents the constraint. Must be in one of + * the following forms: + * * `projects/{project_number}` + * * `projects/{project_id}` + * * `folders/{folder_id}` + * * `organizations/{organization_id}` + * @param {number} request.pageSize + * Size of the pages to be returned. This is currently unsupported and will + * be ignored. The server may at any point start using this field to limit + * page size. + * @param {string} request.pageToken + * Page token used to retrieve the next page. This is currently unsupported + * and will be ignored. The server may at any point start using this field. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.orgpolicy.v2.Constraint|Constraint}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v2/org_policy.list_constraints.js + * region_tag:orgpolicy_v2_generated_OrgPolicy_ListConstraints_async + */ + listConstraintsAsync( + request?: protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, + 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['listConstraints']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listConstraints.asyncIterate( + this.innerApiCalls['listConstraints'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Retrieves all of the `Policies` that exist on a particular resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The target Cloud resource that parents the set of constraints and + * policies that will be returned from this call. Must be in one of the + * following forms: + * * `projects/{project_number}` + * * `projects/{project_id}` + * * `folders/{folder_id}` + * * `organizations/{organization_id}` + * @param {number} request.pageSize + * Size of the pages to be returned. This is currently unsupported and will + * be ignored. The server may at any point start using this field to limit + * page size. + * @param {string} request.pageToken + * Page token used to retrieve the next page. This is currently unsupported + * and will be ignored. The server may at any point start using this field. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.orgpolicy.v2.Policy|Policy}. + * 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 `listPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listPolicies( + request?: protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.orgpolicy.v2.IPolicy[], + protos.google.cloud.orgpolicy.v2.IListPoliciesRequest|null, + protos.google.cloud.orgpolicy.v2.IListPoliciesResponse + ]>; + listPolicies( + request: protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, + protos.google.cloud.orgpolicy.v2.IListPoliciesResponse|null|undefined, + protos.google.cloud.orgpolicy.v2.IPolicy>): void; + listPolicies( + request: protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, + protos.google.cloud.orgpolicy.v2.IListPoliciesResponse|null|undefined, + protos.google.cloud.orgpolicy.v2.IPolicy>): void; + listPolicies( + request?: protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, + protos.google.cloud.orgpolicy.v2.IListPoliciesResponse|null|undefined, + protos.google.cloud.orgpolicy.v2.IPolicy>, + callback?: PaginationCallback< + protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, + protos.google.cloud.orgpolicy.v2.IListPoliciesResponse|null|undefined, + protos.google.cloud.orgpolicy.v2.IPolicy>): + Promise<[ + protos.google.cloud.orgpolicy.v2.IPolicy[], + protos.google.cloud.orgpolicy.v2.IListPoliciesRequest|null, + protos.google.cloud.orgpolicy.v2.IListPoliciesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listPolicies(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 target Cloud resource that parents the set of constraints and + * policies that will be returned from this call. Must be in one of the + * following forms: + * * `projects/{project_number}` + * * `projects/{project_id}` + * * `folders/{folder_id}` + * * `organizations/{organization_id}` + * @param {number} request.pageSize + * Size of the pages to be returned. This is currently unsupported and will + * be ignored. The server may at any point start using this field to limit + * page size. + * @param {string} request.pageToken + * Page token used to retrieve the next page. This is currently unsupported + * and will be ignored. The server may at any point start using this field. + * @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 protos.google.cloud.orgpolicy.v2.Policy|Policy} 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 `listPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listPoliciesStream( + request?: protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, + 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['listPolicies']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPolicies.createStream( + this.innerApiCalls.listPolicies as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listPolicies`, 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 target Cloud resource that parents the set of constraints and + * policies that will be returned from this call. Must be in one of the + * following forms: + * * `projects/{project_number}` + * * `projects/{project_id}` + * * `folders/{folder_id}` + * * `organizations/{organization_id}` + * @param {number} request.pageSize + * Size of the pages to be returned. This is currently unsupported and will + * be ignored. The server may at any point start using this field to limit + * page size. + * @param {string} request.pageToken + * Page token used to retrieve the next page. This is currently unsupported + * and will be ignored. The server may at any point start using this field. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.orgpolicy.v2.Policy|Policy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v2/org_policy.list_policies.js + * region_tag:orgpolicy_v2_generated_OrgPolicy_ListPolicies_async + */ + listPoliciesAsync( + request?: protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, + 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['listPolicies']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPolicies.asyncIterate( + this.innerApiCalls['listPolicies'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified folderConstraint resource name string. + * + * @param {string} folder + * @param {string} constraint + * @returns {string} Resource name string. + */ + folderConstraintPath(folder:string,constraint:string) { + return this.pathTemplates.folderConstraintPathTemplate.render({ + folder: folder, + constraint: constraint, + }); + } + + /** + * Parse the folder from FolderConstraint resource. + * + * @param {string} folderConstraintName + * A fully-qualified path representing folder_constraint resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderConstraintName(folderConstraintName: string) { + return this.pathTemplates.folderConstraintPathTemplate.match(folderConstraintName).folder; + } + + /** + * Parse the constraint from FolderConstraint resource. + * + * @param {string} folderConstraintName + * A fully-qualified path representing folder_constraint resource. + * @returns {string} A string representing the constraint. + */ + matchConstraintFromFolderConstraintName(folderConstraintName: string) { + return this.pathTemplates.folderConstraintPathTemplate.match(folderConstraintName).constraint; + } + + /** + * Return a fully-qualified folderPolicy resource name string. + * + * @param {string} folder + * @param {string} policy + * @returns {string} Resource name string. + */ + folderPolicyPath(folder:string,policy:string) { + return this.pathTemplates.folderPolicyPathTemplate.render({ + folder: folder, + policy: policy, + }); + } + + /** + * Parse the folder from FolderPolicy resource. + * + * @param {string} folderPolicyName + * A fully-qualified path representing folder_policy resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderPolicyName(folderPolicyName: string) { + return this.pathTemplates.folderPolicyPathTemplate.match(folderPolicyName).folder; + } + + /** + * Parse the policy from FolderPolicy resource. + * + * @param {string} folderPolicyName + * A fully-qualified path representing folder_policy resource. + * @returns {string} A string representing the policy. + */ + matchPolicyFromFolderPolicyName(folderPolicyName: string) { + return this.pathTemplates.folderPolicyPathTemplate.match(folderPolicyName).policy; + } + + /** + * Return a fully-qualified organizationConstraint resource name string. + * + * @param {string} organization + * @param {string} constraint + * @returns {string} Resource name string. + */ + organizationConstraintPath(organization:string,constraint:string) { + return this.pathTemplates.organizationConstraintPathTemplate.render({ + organization: organization, + constraint: constraint, + }); + } + + /** + * Parse the organization from OrganizationConstraint resource. + * + * @param {string} organizationConstraintName + * A fully-qualified path representing organization_constraint resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationConstraintName(organizationConstraintName: string) { + return this.pathTemplates.organizationConstraintPathTemplate.match(organizationConstraintName).organization; + } + + /** + * Parse the constraint from OrganizationConstraint resource. + * + * @param {string} organizationConstraintName + * A fully-qualified path representing organization_constraint resource. + * @returns {string} A string representing the constraint. + */ + matchConstraintFromOrganizationConstraintName(organizationConstraintName: string) { + return this.pathTemplates.organizationConstraintPathTemplate.match(organizationConstraintName).constraint; + } + + /** + * Return a fully-qualified organizationPolicy resource name string. + * + * @param {string} organization + * @param {string} policy + * @returns {string} Resource name string. + */ + organizationPolicyPath(organization:string,policy:string) { + return this.pathTemplates.organizationPolicyPathTemplate.render({ + organization: organization, + policy: policy, + }); + } + + /** + * Parse the organization from OrganizationPolicy resource. + * + * @param {string} organizationPolicyName + * A fully-qualified path representing organization_policy resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationPolicyName(organizationPolicyName: string) { + return this.pathTemplates.organizationPolicyPathTemplate.match(organizationPolicyName).organization; + } + + /** + * Parse the policy from OrganizationPolicy resource. + * + * @param {string} organizationPolicyName + * A fully-qualified path representing organization_policy resource. + * @returns {string} A string representing the policy. + */ + matchPolicyFromOrganizationPolicyName(organizationPolicyName: string) { + return this.pathTemplates.organizationPolicyPathTemplate.match(organizationPolicyName).policy; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified projectConstraint resource name string. + * + * @param {string} project + * @param {string} constraint + * @returns {string} Resource name string. + */ + projectConstraintPath(project:string,constraint:string) { + return this.pathTemplates.projectConstraintPathTemplate.render({ + project: project, + constraint: constraint, + }); + } + + /** + * Parse the project from ProjectConstraint resource. + * + * @param {string} projectConstraintName + * A fully-qualified path representing project_constraint resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectConstraintName(projectConstraintName: string) { + return this.pathTemplates.projectConstraintPathTemplate.match(projectConstraintName).project; + } + + /** + * Parse the constraint from ProjectConstraint resource. + * + * @param {string} projectConstraintName + * A fully-qualified path representing project_constraint resource. + * @returns {string} A string representing the constraint. + */ + matchConstraintFromProjectConstraintName(projectConstraintName: string) { + return this.pathTemplates.projectConstraintPathTemplate.match(projectConstraintName).constraint; + } + + /** + * Return a fully-qualified projectPolicy resource name string. + * + * @param {string} project + * @param {string} policy + * @returns {string} Resource name string. + */ + projectPolicyPath(project:string,policy:string) { + return this.pathTemplates.projectPolicyPathTemplate.render({ + project: project, + policy: policy, + }); + } + + /** + * Parse the project from ProjectPolicy resource. + * + * @param {string} projectPolicyName + * A fully-qualified path representing project_policy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectPolicyName(projectPolicyName: string) { + return this.pathTemplates.projectPolicyPathTemplate.match(projectPolicyName).project; + } + + /** + * Parse the policy from ProjectPolicy resource. + * + * @param {string} projectPolicyName + * A fully-qualified path representing project_policy resource. + * @returns {string} A string representing the policy. + */ + matchPolicyFromProjectPolicyName(projectPolicyName: string) { + return this.pathTemplates.projectPolicyPathTemplate.match(projectPolicyName).policy; + } + + /** + * 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.orgPolicyStub && !this._terminated) { + return this.orgPolicyStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_client_config.json b/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_client_config.json new file mode 100644 index 00000000000..330aa9baa83 --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_client_config.json @@ -0,0 +1,70 @@ +{ + "interfaces": { + "google.cloud.orgpolicy.v2.OrgPolicy": { + "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 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListConstraints": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "ListPolicies": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "GetPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "GetEffectivePolicy": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "CreatePolicy": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "UpdatePolicy": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "DeletePolicy": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_proto_list.json b/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_proto_list.json new file mode 100644 index 00000000000..ad104eccb77 --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_proto_list.json @@ -0,0 +1,4 @@ +[ + "../../protos/google/cloud/orgpolicy/v2/constraint.proto", + "../../protos/google/cloud/orgpolicy/v2/orgpolicy.proto" +] diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-orgpolicy/v2/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..b2765310f0a --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const orgpolicy = require('@google-cloud/org-policy'); + +function main() { + const orgPolicyClient = new orgpolicy.OrgPolicyClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-orgpolicy/v2/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..ee617ef74fa --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {OrgPolicyClient} from '@google-cloud/org-policy'; + +// check that the client class type name can be used +function doStuffWithOrgPolicyClient(client: OrgPolicyClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const orgPolicyClient = new OrgPolicyClient(); + doStuffWithOrgPolicyClient(orgPolicyClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/system-test/install.ts b/owl-bot-staging/google-cloud-orgpolicy/v2/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/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-orgpolicy/v2/test/gapic_org_policy_v2.ts b/owl-bot-staging/google-cloud-orgpolicy/v2/test/gapic_org_policy_v2.ts new file mode 100644 index 00000000000..7e90a59df46 --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/v2/test/gapic_org_policy_v2.ts @@ -0,0 +1,1492 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 orgpolicyModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +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.OrgPolicyClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = orgpolicyModule.v2.OrgPolicyClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = orgpolicyModule.v2.OrgPolicyClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = orgpolicyModule.v2.OrgPolicyClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new orgpolicyModule.v2.OrgPolicyClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.orgPolicyStub, undefined); + await client.initialize(); + assert(client.orgPolicyStub); + }); + + it('has close method for the initialized client', done => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.orgPolicyStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.orgPolicyStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new orgpolicyModule.v2.OrgPolicyClient({ + 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 orgpolicyModule.v2.OrgPolicyClient({ + 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('getPolicy', () => { + it('invokes getPolicy without error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.GetPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.GetPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.Policy() + ); + client.innerApiCalls.getPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPolicy without error using callback', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.GetPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.GetPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.Policy() + ); + client.innerApiCalls.getPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.orgpolicy.v2.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPolicy with error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.GetPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.GetPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPolicy with closed client', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.GetPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.GetPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getPolicy(request), expectedError); + }); + }); + + describe('getEffectivePolicy', () => { + it('invokes getEffectivePolicy without error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.Policy() + ); + client.innerApiCalls.getEffectivePolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getEffectivePolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getEffectivePolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEffectivePolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEffectivePolicy without error using callback', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.Policy() + ); + client.innerApiCalls.getEffectivePolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getEffectivePolicy( + request, + (err?: Error|null, result?: protos.google.cloud.orgpolicy.v2.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getEffectivePolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEffectivePolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEffectivePolicy with error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getEffectivePolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getEffectivePolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getEffectivePolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEffectivePolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEffectivePolicy with closed client', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getEffectivePolicy(request), expectedError); + }); + }); + + describe('createPolicy', () => { + it('invokes createPolicy without error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.CreatePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.CreatePolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.Policy() + ); + client.innerApiCalls.createPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.createPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createPolicy without error using callback', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.CreatePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.CreatePolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.Policy() + ); + client.innerApiCalls.createPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.orgpolicy.v2.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createPolicy with error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.CreatePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.CreatePolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.createPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createPolicy with closed client', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.CreatePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.CreatePolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createPolicy(request), expectedError); + }); + }); + + describe('updatePolicy', () => { + it('invokes updatePolicy without error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.UpdatePolicyRequest() + ); + request.policy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.UpdatePolicyRequest', ['policy', 'name']); + request.policy.name = defaultValue1; + const expectedHeaderRequestParams = `policy.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.Policy() + ); + client.innerApiCalls.updatePolicy = stubSimpleCall(expectedResponse); + const [response] = await client.updatePolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updatePolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePolicy without error using callback', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.UpdatePolicyRequest() + ); + request.policy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.UpdatePolicyRequest', ['policy', 'name']); + request.policy.name = defaultValue1; + const expectedHeaderRequestParams = `policy.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.Policy() + ); + client.innerApiCalls.updatePolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updatePolicy( + request, + (err?: Error|null, result?: protos.google.cloud.orgpolicy.v2.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updatePolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePolicy with error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.UpdatePolicyRequest() + ); + request.policy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.UpdatePolicyRequest', ['policy', 'name']); + request.policy.name = defaultValue1; + const expectedHeaderRequestParams = `policy.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updatePolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updatePolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.updatePolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePolicy with closed client', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.UpdatePolicyRequest() + ); + request.policy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.UpdatePolicyRequest', ['policy', 'name']); + request.policy.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updatePolicy(request), expectedError); + }); + }); + + describe('deletePolicy', () => { + it('invokes deletePolicy without error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.DeletePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.DeletePolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deletePolicy = stubSimpleCall(expectedResponse); + const [response] = await client.deletePolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deletePolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePolicy without error using callback', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.DeletePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.DeletePolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deletePolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deletePolicy( + 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.deletePolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePolicy with error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.DeletePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.DeletePolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deletePolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.deletePolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePolicy with closed client', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.DeletePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.DeletePolicyRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deletePolicy(request), expectedError); + }); + }); + + describe('listConstraints', () => { + it('invokes listConstraints without error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.ListConstraintsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListConstraintsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), + ]; + client.innerApiCalls.listConstraints = stubSimpleCall(expectedResponse); + const [response] = await client.listConstraints(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listConstraints as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listConstraints as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listConstraints without error using callback', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.ListConstraintsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListConstraintsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), + ]; + client.innerApiCalls.listConstraints = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listConstraints( + request, + (err?: Error|null, result?: protos.google.cloud.orgpolicy.v2.IConstraint[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listConstraints as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listConstraints as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listConstraints with error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.ListConstraintsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListConstraintsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listConstraints = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listConstraints(request), expectedError); + const actualRequest = (client.innerApiCalls.listConstraints as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listConstraints as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listConstraintsStream without error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.ListConstraintsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListConstraintsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), + ]; + client.descriptors.page.listConstraints.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listConstraintsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.orgpolicy.v2.Constraint[] = []; + stream.on('data', (response: protos.google.cloud.orgpolicy.v2.Constraint) => { + 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.listConstraints.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listConstraints, request)); + assert( + (client.descriptors.page.listConstraints.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listConstraintsStream with error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.ListConstraintsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListConstraintsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listConstraints.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listConstraintsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.orgpolicy.v2.Constraint[] = []; + stream.on('data', (response: protos.google.cloud.orgpolicy.v2.Constraint) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listConstraints.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listConstraints, request)); + assert( + (client.descriptors.page.listConstraints.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listConstraints without error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.ListConstraintsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListConstraintsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), + ]; + client.descriptors.page.listConstraints.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.orgpolicy.v2.IConstraint[] = []; + const iterable = client.listConstraintsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listConstraints.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listConstraints.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listConstraints with error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.ListConstraintsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListConstraintsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listConstraints.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listConstraintsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.orgpolicy.v2.IConstraint[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listConstraints.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listConstraints.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listPolicies', () => { + it('invokes listPolicies without error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.ListPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), + ]; + client.innerApiCalls.listPolicies = stubSimpleCall(expectedResponse); + const [response] = await client.listPolicies(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPolicies without error using callback', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.ListPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), + ]; + client.innerApiCalls.listPolicies = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPolicies( + request, + (err?: Error|null, result?: protos.google.cloud.orgpolicy.v2.IPolicy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPolicies with error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.ListPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPolicies = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listPolicies(request), expectedError); + const actualRequest = (client.innerApiCalls.listPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPoliciesStream without error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.ListPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), + ]; + client.descriptors.page.listPolicies.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.orgpolicy.v2.Policy[] = []; + stream.on('data', (response: protos.google.cloud.orgpolicy.v2.Policy) => { + 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.listPolicies.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPolicies, request)); + assert( + (client.descriptors.page.listPolicies.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listPoliciesStream with error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.ListPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPolicies.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.orgpolicy.v2.Policy[] = []; + stream.on('data', (response: protos.google.cloud.orgpolicy.v2.Policy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listPolicies.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPolicies, request)); + assert( + (client.descriptors.page.listPolicies.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPolicies without error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.ListPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), + generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), + ]; + client.descriptors.page.listPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.orgpolicy.v2.IPolicy[] = []; + const iterable = client.listPoliciesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listPolicies.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPolicies.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPolicies with error', async () => { + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.orgpolicy.v2.ListPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listPoliciesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.orgpolicy.v2.IPolicy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listPolicies.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPolicies.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('folderConstraint', () => { + const fakePath = "/rendered/path/folderConstraint"; + const expectedParameters = { + folder: "folderValue", + constraint: "constraintValue", + }; + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderConstraintPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderConstraintPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderConstraintPath', () => { + const result = client.folderConstraintPath("folderValue", "constraintValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderConstraintPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderConstraintName', () => { + const result = client.matchFolderFromFolderConstraintName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderConstraintPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchConstraintFromFolderConstraintName', () => { + const result = client.matchConstraintFromFolderConstraintName(fakePath); + assert.strictEqual(result, "constraintValue"); + assert((client.pathTemplates.folderConstraintPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('folderPolicy', () => { + const fakePath = "/rendered/path/folderPolicy"; + const expectedParameters = { + folder: "folderValue", + policy: "policyValue", + }; + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderPolicyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderPolicyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderPolicyPath', () => { + const result = client.folderPolicyPath("folderValue", "policyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderPolicyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderPolicyName', () => { + const result = client.matchFolderFromFolderPolicyName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchPolicyFromFolderPolicyName', () => { + const result = client.matchPolicyFromFolderPolicyName(fakePath); + assert.strictEqual(result, "policyValue"); + assert((client.pathTemplates.folderPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organizationConstraint', () => { + const fakePath = "/rendered/path/organizationConstraint"; + const expectedParameters = { + organization: "organizationValue", + constraint: "constraintValue", + }; + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationConstraintPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationConstraintPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationConstraintPath', () => { + const result = client.organizationConstraintPath("organizationValue", "constraintValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationConstraintPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationConstraintName', () => { + const result = client.matchOrganizationFromOrganizationConstraintName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationConstraintPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchConstraintFromOrganizationConstraintName', () => { + const result = client.matchConstraintFromOrganizationConstraintName(fakePath); + assert.strictEqual(result, "constraintValue"); + assert((client.pathTemplates.organizationConstraintPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organizationPolicy', () => { + const fakePath = "/rendered/path/organizationPolicy"; + const expectedParameters = { + organization: "organizationValue", + policy: "policyValue", + }; + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationPolicyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationPolicyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationPolicyPath', () => { + const result = client.organizationPolicyPath("organizationValue", "policyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationPolicyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationPolicyName', () => { + const result = client.matchOrganizationFromOrganizationPolicyName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchPolicyFromOrganizationPolicyName', () => { + const result = client.matchPolicyFromOrganizationPolicyName(fakePath); + assert.strictEqual(result, "policyValue"); + assert((client.pathTemplates.organizationPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectConstraint', () => { + const fakePath = "/rendered/path/projectConstraint"; + const expectedParameters = { + project: "projectValue", + constraint: "constraintValue", + }; + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectConstraintPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectConstraintPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectConstraintPath', () => { + const result = client.projectConstraintPath("projectValue", "constraintValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectConstraintPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectConstraintName', () => { + const result = client.matchProjectFromProjectConstraintName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectConstraintPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchConstraintFromProjectConstraintName', () => { + const result = client.matchConstraintFromProjectConstraintName(fakePath); + assert.strictEqual(result, "constraintValue"); + assert((client.pathTemplates.projectConstraintPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectPolicy', () => { + const fakePath = "/rendered/path/projectPolicy"; + const expectedParameters = { + project: "projectValue", + policy: "policyValue", + }; + const client = new orgpolicyModule.v2.OrgPolicyClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPolicyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPolicyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPolicyPath', () => { + const result = client.projectPolicyPath("projectValue", "policyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPolicyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectPolicyName', () => { + const result = client.matchProjectFromProjectPolicyName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchPolicyFromProjectPolicyName', () => { + const result = client.matchPolicyFromProjectPolicyName(fakePath); + assert.strictEqual(result, "policyValue"); + assert((client.pathTemplates.projectPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/tsconfig.json b/owl-bot-staging/google-cloud-orgpolicy/v2/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/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-orgpolicy/v2/webpack.config.js b/owl-bot-staging/google-cloud-orgpolicy/v2/webpack.config.js new file mode 100644 index 00000000000..52ea261a3a1 --- /dev/null +++ b/owl-bot-staging/google-cloud-orgpolicy/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: 'OrgPolicy', + filename: './org-policy.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-osconfig/v1/.eslintignore b/owl-bot-staging/google-cloud-osconfig/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-osconfig/v1/.eslintrc.json b/owl-bot-staging/google-cloud-osconfig/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/.gitignore b/owl-bot-staging/google-cloud-osconfig/v1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-osconfig/v1/.jsdoc.js b/owl-bot-staging/google-cloud-osconfig/v1/.jsdoc.js new file mode 100644 index 00000000000..8b2a0523a45 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/.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/os-config', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-osconfig/v1/.mocharc.js b/owl-bot-staging/google-cloud-osconfig/v1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/.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-osconfig/v1/.prettierrc.js b/owl-bot-staging/google-cloud-osconfig/v1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/.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-osconfig/v1/README.md b/owl-bot-staging/google-cloud-osconfig/v1/README.md new file mode 100644 index 00000000000..94de5ca4cff --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/README.md @@ -0,0 +1 @@ +Osconfig: Nodejs Client diff --git a/owl-bot-staging/google-cloud-osconfig/v1/package.json b/owl-bot-staging/google-cloud-osconfig/v1/package.json new file mode 100644 index 00000000000..0c81d6e675d --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/package.json @@ -0,0 +1,59 @@ +{ + "name": "@google-cloud/os-config", + "version": "0.1.0", + "description": "Osconfig client for Node.js", + "repository": "googleapis/nodejs-osconfig", + "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 osconfig", + "osconfig", + "os config service", + "os config zonal service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/inventory.proto b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/inventory.proto new file mode 100644 index 00000000000..2807b85cb59 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/inventory.proto @@ -0,0 +1,384 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/date.proto"; + +option csharp_namespace = "Google.Cloud.OsConfig.V1"; +option go_package = "cloud.google.com/go/osconfig/apiv1/osconfigpb;osconfigpb"; +option java_multiple_files = true; +option java_outer_classname = "Inventories"; +option java_package = "com.google.cloud.osconfig.v1"; +option php_namespace = "Google\\Cloud\\OsConfig\\V1"; +option ruby_package = "Google::Cloud::OsConfig::V1"; + +// OS Config Inventory is a service for collecting and reporting operating +// system and package information on VM instances. + +// This API resource represents the available inventory data for a +// Compute Engine virtual machine (VM) instance at a given point in time. +// +// You can use this API resource to determine the inventory data of your VM. +// +// For more information, see [Information provided by OS inventory +// management](https://cloud.google.com/compute/docs/instances/os-inventory-management#data-collected). +message Inventory { + option (google.api.resource) = { + type: "osconfig.googleapis.com/Inventory" + pattern: "projects/{project}/locations/{location}/instances/{instance}/inventory" + }; + + // Operating system information for the VM. + message OsInfo { + // The VM hostname. + string hostname = 9; + + // The operating system long name. + // For example 'Debian GNU/Linux 9' or 'Microsoft Window Server 2019 + // Datacenter'. + string long_name = 2; + + // The operating system short name. + // For example, 'windows' or 'debian'. + string short_name = 3; + + // The version of the operating system. + string version = 4; + + // The system architecture of the operating system. + string architecture = 5; + + // The kernel version of the operating system. + string kernel_version = 6; + + // The kernel release of the operating system. + string kernel_release = 7; + + // The current version of the OS Config agent running on the VM. + string osconfig_agent_version = 8; + } + + // A single piece of inventory on a VM. + message Item { + // The origin of a specific inventory item. + enum OriginType { + // Invalid. An origin type must be specified. + ORIGIN_TYPE_UNSPECIFIED = 0; + + // This inventory item was discovered as the result of the agent + // reporting inventory via the reporting API. + INVENTORY_REPORT = 1; + } + + // The different types of inventory that are tracked on a VM. + enum Type { + // Invalid. An type must be specified. + TYPE_UNSPECIFIED = 0; + + // This represents a package that is installed on the VM. + INSTALLED_PACKAGE = 1; + + // This represents an update that is available for a package. + AVAILABLE_PACKAGE = 2; + } + + // Identifier for this item, unique across items for this VM. + string id = 1; + + // The origin of this inventory item. + OriginType origin_type = 2; + + // When this inventory item was first detected. + google.protobuf.Timestamp create_time = 8; + + // When this inventory item was last modified. + google.protobuf.Timestamp update_time = 9; + + // The specific type of inventory, correlating to its specific details. + Type type = 5; + + // Specific details of this inventory item based on its type. + oneof details { + // Software package present on the VM instance. + SoftwarePackage installed_package = 6; + + // Software package available to be installed on the VM instance. + SoftwarePackage available_package = 7; + } + } + + // Software package information of the operating system. + message SoftwarePackage { + // Information about the different types of software packages. + oneof details { + // Yum package info. + // For details about the yum package manager, see + // https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/ch-yum. + VersionedPackage yum_package = 1; + + // Details of an APT package. + // For details about the apt package manager, see + // https://wiki.debian.org/Apt. + VersionedPackage apt_package = 2; + + // Details of a Zypper package. + // For details about the Zypper package manager, see + // https://en.opensuse.org/SDB:Zypper_manual. + VersionedPackage zypper_package = 3; + + // Details of a Googet package. + // For details about the googet package manager, see + // https://github.com/google/googet. + VersionedPackage googet_package = 4; + + // Details of a Zypper patch. + // For details about the Zypper package manager, see + // https://en.opensuse.org/SDB:Zypper_manual. + ZypperPatch zypper_patch = 5; + + // Details of a Windows Update package. + // See https://docs.microsoft.com/en-us/windows/win32/api/_wua/ for + // information about Windows Update. + WindowsUpdatePackage wua_package = 6; + + // Details of a Windows Quick Fix engineering package. + // See + // https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-quickfixengineering + // for info in Windows Quick Fix Engineering. + WindowsQuickFixEngineeringPackage qfe_package = 7; + + // Details of a COS package. + VersionedPackage cos_package = 8; + + // Details of Windows Application. + WindowsApplication windows_application = 9; + } + } + + // Information related to the a standard versioned package. This includes + // package info for APT, Yum, Zypper, and Googet package managers. + message VersionedPackage { + // The name of the package. + string package_name = 4; + + // The system architecture this package is intended for. + string architecture = 2; + + // The version of the package. + string version = 3; + } + + // Details related to a Zypper Patch. + message ZypperPatch { + // The name of the patch. + string patch_name = 5; + + // The category of the patch. + string category = 2; + + // The severity specified for this patch + string severity = 3; + + // Any summary information provided about this patch. + string summary = 4; + } + + // Details related to a Windows Update package. + // Field data and names are taken from Windows Update API IUpdate Interface: + // https://docs.microsoft.com/en-us/windows/win32/api/_wua/ + // Descriptive fields like title, and description are localized based on + // the locale of the VM being updated. + message WindowsUpdatePackage { + // Categories specified by the Windows Update. + message WindowsUpdateCategory { + // The identifier of the windows update category. + string id = 1; + + // The name of the windows update category. + string name = 2; + } + + // The localized title of the update package. + string title = 1; + + // The localized description of the update package. + string description = 2; + + // The categories that are associated with this update package. + repeated WindowsUpdateCategory categories = 3; + + // A collection of Microsoft Knowledge Base article IDs that are associated + // with the update package. + repeated string kb_article_ids = 4; + + // A hyperlink to the language-specific support information for the update. + string support_url = 11; + + // A collection of URLs that provide more information about the update + // package. + repeated string more_info_urls = 5; + + // Gets the identifier of an update package. Stays the same across + // revisions. + string update_id = 6; + + // The revision number of this update package. + int32 revision_number = 7; + + // The last published date of the update, in (UTC) date and time. + google.protobuf.Timestamp last_deployment_change_time = 10; + } + + // Information related to a Quick Fix Engineering package. + // Fields are taken from Windows QuickFixEngineering Interface and match + // the source names: + // https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-quickfixengineering + message WindowsQuickFixEngineeringPackage { + // A short textual description of the QFE update. + string caption = 1; + + // A textual description of the QFE update. + string description = 2; + + // Unique identifier associated with a particular QFE update. + string hot_fix_id = 3; + + // Date that the QFE update was installed. Mapped from installed_on field. + google.protobuf.Timestamp install_time = 5; + } + + // Contains information about a Windows application that is retrieved from the + // Windows Registry. For more information about these fields, see: + // https://docs.microsoft.com/en-us/windows/win32/msi/uninstall-registry-key + message WindowsApplication { + // The name of the application or product. + string display_name = 1; + + // The version of the product or application in string format. + string display_version = 2; + + // The name of the manufacturer for the product or application. + string publisher = 3; + + // The last time this product received service. The value of this property + // is replaced each time a patch is applied or removed from the product or + // the command-line option is used to repair the product. + google.type.Date install_date = 4; + + // The internet address for technical support. + string help_link = 5; + } + + // Output only. The `Inventory` API resource name. + // + // Format: + // `projects/{project_number}/locations/{location}/instances/{instance_id}/inventory` + string name = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Base level operating system information for the VM. + OsInfo os_info = 1; + + // Inventory items related to the VM keyed by an opaque unique identifier for + // each inventory item. The identifier is unique to each distinct and + // addressable inventory item and will change, when there is a new package + // version. + map items = 2; + + // Output only. Timestamp of the last reported inventory for the VM. + google.protobuf.Timestamp update_time = 4 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A request message for getting inventory data for the specified VM. +message GetInventoryRequest { + // Required. API resource name for inventory resource. + // + // Format: + // `projects/{project}/locations/{location}/instances/{instance}/inventory` + // + // For `{project}`, either `project-number` or `project-id` can be provided. + // For `{instance}`, either Compute Engine `instance-id` or `instance-name` + // can be provided. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/Inventory" + } + ]; + + // Inventory view indicating what information should be included in the + // inventory resource. If unspecified, the default view is BASIC. + InventoryView view = 2; +} + +// A request message for listing inventory data for all VMs in the specified +// location. +message ListInventoriesRequest { + // Required. The parent resource name. + // + // Format: `projects/{project}/locations/{location}/instances/-` + // + // For `{project}`, either `project-number` or `project-id` can be provided. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "compute.googleapis.com/Instance" + } + ]; + + // Inventory view indicating what information should be included in the + // inventory resource. If unspecified, the default view is BASIC. + InventoryView view = 2; + + // The maximum number of results to return. + int32 page_size = 3; + + // A pagination token returned from a previous call to + // `ListInventories` that indicates where this listing + // should continue from. + string page_token = 4; + + // If provided, this field specifies the criteria that must be met by a + // `Inventory` API resource to be included in the response. + string filter = 5; +} + +// A response message for listing inventory data for all VMs in a specified +// location. +message ListInventoriesResponse { + // List of inventory objects. + repeated Inventory inventories = 1; + + // The pagination token to retrieve the next page of inventory objects. + string next_page_token = 2; +} + +// The view for inventory objects. +enum InventoryView { + // The default value. + // The API defaults to the BASIC view. + INVENTORY_VIEW_UNSPECIFIED = 0; + + // Returns the basic inventory information that includes `os_info`. + BASIC = 1; + + // Returns all fields. + FULL = 2; +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy.proto b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy.proto new file mode 100644 index 00000000000..f1911199686 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy.proto @@ -0,0 +1,548 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1; + +import "google/api/field_behavior.proto"; + +option csharp_namespace = "Google.Cloud.OsConfig.V1"; +option go_package = "cloud.google.com/go/osconfig/apiv1/osconfigpb;osconfigpb"; +option java_multiple_files = true; +option java_outer_classname = "OsPolicyProto"; +option java_package = "com.google.cloud.osconfig.v1"; +option php_namespace = "Google\\Cloud\\OsConfig\\V1"; +option ruby_package = "Google::Cloud::OsConfig::V1"; + +// An OS policy defines the desired state configuration for a VM. +message OSPolicy { + // Policy mode + enum Mode { + // Invalid mode + MODE_UNSPECIFIED = 0; + + // This mode checks if the configuration resources in the policy are in + // their desired state. No actions are performed if they are not in the + // desired state. This mode is used for reporting purposes. + VALIDATION = 1; + + // This mode checks if the configuration resources in the policy are in + // their desired state, and if not, enforces the desired state. + ENFORCEMENT = 2; + } + + // Filtering criteria to select VMs based on inventory details. + message InventoryFilter { + // Required. The OS short name + string os_short_name = 1 [(google.api.field_behavior) = REQUIRED]; + + // The OS version + // + // Prefix matches are supported if asterisk(*) is provided as the + // last character. For example, to match all versions with a major + // version of `7`, specify the following value for this field `7.*` + // + // An empty string matches all OS versions. + string os_version = 2; + } + + // An OS policy resource is used to define the desired state configuration + // and provides a specific functionality like installing/removing packages, + // executing a script etc. + // + // The system ensures that resources are always in their desired state by + // taking necessary actions if they have drifted from their desired state. + message Resource { + // A remote or local file. + message File { + // Specifies a file available via some URI. + message Remote { + // Required. URI from which to fetch the object. It should contain both + // the protocol and path following the format `{protocol}://{location}`. + string uri = 1 [(google.api.field_behavior) = REQUIRED]; + + // SHA256 checksum of the remote file. + string sha256_checksum = 2; + } + + // Specifies a file available as a Cloud Storage Object. + message Gcs { + // Required. Bucket of the Cloud Storage object. + string bucket = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Name of the Cloud Storage object. + string object = 2 [(google.api.field_behavior) = REQUIRED]; + + // Generation number of the Cloud Storage object. + int64 generation = 3; + } + + // A specific type of file. + oneof type { + // A generic remote file. + Remote remote = 1; + + // A Cloud Storage object. + Gcs gcs = 2; + + // A local path within the VM to use. + string local_path = 3; + } + + // Defaults to false. When false, files are subject to validations + // based on the file type: + // + // Remote: A checksum must be specified. + // Cloud Storage: An object generation number must be specified. + bool allow_insecure = 4; + } + + // A resource that manages a system package. + message PackageResource { + // The desired state that the OS Config agent maintains on the VM. + enum DesiredState { + // Unspecified is invalid. + DESIRED_STATE_UNSPECIFIED = 0; + + // Ensure that the package is installed. + INSTALLED = 1; + + // The agent ensures that the package is not installed and + // uninstalls it if detected. + REMOVED = 2; + } + + // A deb package file. dpkg packages only support INSTALLED state. + message Deb { + // Required. A deb package. + File source = 1 [(google.api.field_behavior) = REQUIRED]; + + // Whether dependencies should also be installed. + // - install when false: `dpkg -i package` + // - install when true: `apt-get update && apt-get -y install + // package.deb` + bool pull_deps = 2; + } + + // A package managed by APT. + // - install: `apt-get update && apt-get -y install [name]` + // - remove: `apt-get -y remove [name]` + message APT { + // Required. Package name. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + } + + // An RPM package file. RPM packages only support INSTALLED state. + message RPM { + // Required. An rpm package. + File source = 1 [(google.api.field_behavior) = REQUIRED]; + + // Whether dependencies should also be installed. + // - install when false: `rpm --upgrade --replacepkgs package.rpm` + // - install when true: `yum -y install package.rpm` or + // `zypper -y install package.rpm` + bool pull_deps = 2; + } + + // A package managed by YUM. + // - install: `yum -y install package` + // - remove: `yum -y remove package` + message YUM { + // Required. Package name. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + } + + // A package managed by Zypper. + // - install: `zypper -y install package` + // - remove: `zypper -y rm package` + message Zypper { + // Required. Package name. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + } + + // A package managed by GooGet. + // - install: `googet -noconfirm install package` + // - remove: `googet -noconfirm remove package` + message GooGet { + // Required. Package name. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + } + + // An MSI package. MSI packages only support INSTALLED state. + message MSI { + // Required. The MSI package. + File source = 1 [(google.api.field_behavior) = REQUIRED]; + + // Additional properties to use during installation. + // This should be in the format of Property=Setting. + // Appended to the defaults of `ACTION=INSTALL + // REBOOT=ReallySuppress`. + repeated string properties = 2; + } + + // Required. The desired state the agent should maintain for this package. + DesiredState desired_state = 1 [(google.api.field_behavior) = REQUIRED]; + + // A system package. + oneof system_package { + // A package managed by Apt. + APT apt = 2; + + // A deb package file. + Deb deb = 3; + + // A package managed by YUM. + YUM yum = 4; + + // A package managed by Zypper. + Zypper zypper = 5; + + // An rpm package file. + RPM rpm = 6; + + // A package managed by GooGet. + GooGet googet = 7; + + // An MSI package. + MSI msi = 8; + } + } + + // A resource that manages a package repository. + message RepositoryResource { + // Represents a single apt package repository. These will be added to + // a repo file that will be managed at + // `/etc/apt/sources.list.d/google_osconfig.list`. + message AptRepository { + // Type of archive. + enum ArchiveType { + // Unspecified is invalid. + ARCHIVE_TYPE_UNSPECIFIED = 0; + + // Deb indicates that the archive contains binary files. + DEB = 1; + + // Deb-src indicates that the archive contains source files. + DEB_SRC = 2; + } + + // Required. Type of archive files in this repository. + ArchiveType archive_type = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. URI for this repository. + string uri = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. Distribution of this repository. + string distribution = 3 [(google.api.field_behavior) = REQUIRED]; + + // Required. List of components for this repository. Must contain at + // least one item. + repeated string components = 4 [(google.api.field_behavior) = REQUIRED]; + + // URI of the key file for this repository. The agent maintains a + // keyring at `/etc/apt/trusted.gpg.d/osconfig_agent_managed.gpg`. + string gpg_key = 5; + } + + // Represents a single yum package repository. These are added to a + // repo file that is managed at + // `/etc/yum.repos.d/google_osconfig.repo`. + message YumRepository { + // Required. A one word, unique name for this repository. This is the + // `repo id` in the yum config file and also the `display_name` if + // `display_name` is omitted. This id is also used as the unique + // identifier when checking for resource conflicts. + string id = 1 [(google.api.field_behavior) = REQUIRED]; + + // The display name of the repository. + string display_name = 2; + + // Required. The location of the repository directory. + string base_url = 3 [(google.api.field_behavior) = REQUIRED]; + + // URIs of GPG keys. + repeated string gpg_keys = 4; + } + + // Represents a single zypper package repository. These are added to a + // repo file that is managed at + // `/etc/zypp/repos.d/google_osconfig.repo`. + message ZypperRepository { + // Required. A one word, unique name for this repository. This is the + // `repo id` in the zypper config file and also the `display_name` if + // `display_name` is omitted. This id is also used as the unique + // identifier when checking for GuestPolicy conflicts. + string id = 1 [(google.api.field_behavior) = REQUIRED]; + + // The display name of the repository. + string display_name = 2; + + // Required. The location of the repository directory. + string base_url = 3 [(google.api.field_behavior) = REQUIRED]; + + // URIs of GPG keys. + repeated string gpg_keys = 4; + } + + // Represents a Goo package repository. These are added to a repo file + // that is managed at + // `C:/ProgramData/GooGet/repos/google_osconfig.repo`. + message GooRepository { + // Required. The name of the repository. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The url of the repository. + string url = 2 [(google.api.field_behavior) = REQUIRED]; + } + + // A specific type of repository. + oneof repository { + // An Apt Repository. + AptRepository apt = 1; + + // A Yum Repository. + YumRepository yum = 2; + + // A Zypper Repository. + ZypperRepository zypper = 3; + + // A Goo Repository. + GooRepository goo = 4; + } + } + + // A resource that allows executing scripts on the VM. + // + // The `ExecResource` has 2 stages: `validate` and `enforce` and both stages + // accept a script as an argument to execute. + // + // When the `ExecResource` is applied by the agent, it first executes the + // script in the `validate` stage. The `validate` stage can signal that the + // `ExecResource` is already in the desired state by returning an exit code + // of `100`. If the `ExecResource` is not in the desired state, it should + // return an exit code of `101`. Any other exit code returned by this stage + // is considered an error. + // + // If the `ExecResource` is not in the desired state based on the exit code + // from the `validate` stage, the agent proceeds to execute the script from + // the `enforce` stage. If the `ExecResource` is already in the desired + // state, the `enforce` stage will not be run. + // Similar to `validate` stage, the `enforce` stage should return an exit + // code of `100` to indicate that the resource in now in its desired state. + // Any other exit code is considered an error. + // + // NOTE: An exit code of `100` was chosen over `0` (and `101` vs `1`) to + // have an explicit indicator of `in desired state`, `not in desired state` + // and errors. Because, for example, Powershell will always return an exit + // code of `0` unless an `exit` statement is provided in the script. So, for + // reasons of consistency and being explicit, exit codes `100` and `101` + // were chosen. + message ExecResource { + // A file or script to execute. + message Exec { + // The interpreter to use. + enum Interpreter { + // Invalid value, the request will return validation error. + INTERPRETER_UNSPECIFIED = 0; + + // If an interpreter is not specified, the + // source is executed directly. This execution, without an + // interpreter, only succeeds for executables and scripts that have shebang lines. + NONE = 1; + + // Indicates that the script runs with `/bin/sh` on Linux and + // `cmd.exe` on Windows. + SHELL = 2; + + // Indicates that the script runs with PowerShell. + POWERSHELL = 3; + } + + // What to execute. + oneof source { + // A remote or local file. + File file = 1; + + // An inline script. + // The size of the script is limited to 1024 characters. + string script = 2; + } + + // Optional arguments to pass to the source during execution. + repeated string args = 3; + + // Required. The script interpreter to use. + Interpreter interpreter = 4 [(google.api.field_behavior) = REQUIRED]; + + // Only recorded for enforce Exec. + // Path to an output file (that is created by this Exec) whose + // content will be recorded in OSPolicyResourceCompliance after a + // successful run. Absence or failure to read this file will result in + // this ExecResource being non-compliant. Output file size is limited to + // 100K bytes. + string output_file_path = 5; + } + + // Required. What to run to validate this resource is in the desired + // state. An exit code of 100 indicates "in desired state", and exit code + // of 101 indicates "not in desired state". Any other exit code indicates + // a failure running validate. + Exec validate = 1 [(google.api.field_behavior) = REQUIRED]; + + // What to run to bring this resource into the desired state. + // An exit code of 100 indicates "success", any other exit code indicates + // a failure running enforce. + Exec enforce = 2; + } + + // A resource that manages the state of a file. + message FileResource { + // Desired state of the file. + enum DesiredState { + // Unspecified is invalid. + DESIRED_STATE_UNSPECIFIED = 0; + + // Ensure file at path is present. + PRESENT = 1; + + // Ensure file at path is absent. + ABSENT = 2; + + // Ensure the contents of the file at path matches. If the file does + // not exist it will be created. + CONTENTS_MATCH = 3; + } + + // The source for the contents of the file. + oneof source { + // A remote or local source. + File file = 1; + + // A a file with this content. + // The size of the content is limited to 1024 characters. + string content = 2; + } + + // Required. The absolute path of the file within the VM. + string path = 3 [(google.api.field_behavior) = REQUIRED]; + + // Required. Desired state of the file. + DesiredState state = 4 [(google.api.field_behavior) = REQUIRED]; + + // Consists of three octal digits which represent, in + // order, the permissions of the owner, group, and other users for the + // file (similarly to the numeric mode used in the linux chmod + // utility). Each digit represents a three bit number with the 4 bit + // corresponding to the read permissions, the 2 bit corresponds to the + // write bit, and the one bit corresponds to the execute permission. + // Default behavior is 755. + // + // Below are some examples of permissions and their associated values: + // read, write, and execute: 7 + // read and execute: 5 + // read and write: 6 + // read only: 4 + string permissions = 5; + } + + // Required. The id of the resource with the following restrictions: + // + // * Must contain only lowercase letters, numbers, and hyphens. + // * Must start with a letter. + // * Must be between 1-63 characters. + // * Must end with a number or a letter. + // * Must be unique within the OS policy. + string id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Resource type. + oneof resource_type { + // Package resource + PackageResource pkg = 2; + + // Package repository resource + RepositoryResource repository = 3; + + // Exec resource + ExecResource exec = 4; + + // File resource + FileResource file = 5; + } + } + + // Resource groups provide a mechanism to group OS policy resources. + // + // Resource groups enable OS policy authors to create a single OS policy + // to be applied to VMs running different operating Systems. + // + // When the OS policy is applied to a target VM, the appropriate resource + // group within the OS policy is selected based on the `OSFilter` specified + // within the resource group. + message ResourceGroup { + // List of inventory filters for the resource group. + // + // The resources in this resource group are applied to the target VM if it + // satisfies at least one of the following inventory filters. + // + // For example, to apply this resource group to VMs running either `RHEL` or + // `CentOS` operating systems, specify 2 items for the list with following + // values: + // inventory_filters[0].os_short_name='rhel' and + // inventory_filters[1].os_short_name='centos' + // + // If the list is empty, this resource group will be applied to the target + // VM unconditionally. + repeated InventoryFilter inventory_filters = 1; + + // Required. List of resources configured for this resource group. + // The resources are executed in the exact order specified here. + repeated Resource resources = 2 [(google.api.field_behavior) = REQUIRED]; + } + + // Required. The id of the OS policy with the following restrictions: + // + // * Must contain only lowercase letters, numbers, and hyphens. + // * Must start with a letter. + // * Must be between 1-63 characters. + // * Must end with a number or a letter. + // * Must be unique within the assignment. + string id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Policy description. + // Length of the description is limited to 1024 characters. + string description = 2; + + // Required. Policy mode + Mode mode = 3 [(google.api.field_behavior) = REQUIRED]; + + // Required. List of resource groups for the policy. + // For a particular VM, resource groups are evaluated in the order specified + // and the first resource group that is applicable is selected and the rest + // are ignored. + // + // If none of the resource groups are applicable for a VM, the VM is + // considered to be non-compliant w.r.t this policy. This behavior can be + // toggled by the flag `allow_no_resource_group_match` + repeated ResourceGroup resource_groups = 4 + [(google.api.field_behavior) = REQUIRED]; + + // This flag determines the OS policy compliance status when none of the + // resource groups within the policy are applicable for a VM. Set this value + // to `true` if the policy needs to be reported as compliant even if the + // policy has nothing to validate or enforce. + bool allow_no_resource_group_match = 5; +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy_assignment_reports.proto b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy_assignment_reports.proto new file mode 100644 index 00000000000..c7f102b2d67 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy_assignment_reports.proto @@ -0,0 +1,296 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.OsConfig.V1"; +option go_package = "cloud.google.com/go/osconfig/apiv1/osconfigpb;osconfigpb"; +option java_multiple_files = true; +option java_outer_classname = "OSPolicyAssignmentReportsProto"; +option java_package = "com.google.cloud.osconfig.v1"; +option php_namespace = "Google\\Cloud\\OsConfig\\V1"; +option ruby_package = "Google::Cloud::OsConfig::V1"; +option (google.api.resource_definition) = { + type: "osconfig.googleapis.com/InstanceOSPolicyAssignment" + pattern: "projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}" +}; + +// Get a report of the OS policy assignment for a VM instance. +message GetOSPolicyAssignmentReportRequest { + // Required. API resource name for OS policy assignment report. + // + // Format: + // `/projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report` + // + // For `{project}`, either `project-number` or `project-id` can be provided. + // For `{instance_id}`, either Compute Engine `instance-id` or `instance-name` + // can be provided. + // For `{assignment_id}`, the OSPolicyAssignment id must be provided. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/OSPolicyAssignmentReport" + } + ]; +} + +// List the OS policy assignment reports for VM instances. +message ListOSPolicyAssignmentReportsRequest { + // Required. The parent resource name. + // + // Format: + // `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/reports` + // + // For `{project}`, either `project-number` or `project-id` can be provided. + // For `{instance}`, either `instance-name`, `instance-id`, or `-` can be + // provided. If '-' is provided, the response will include + // OSPolicyAssignmentReports for all instances in the project/location. + // For `{assignment}`, either `assignment-id` or `-` can be provided. If '-' + // is provided, the response will include OSPolicyAssignmentReports for all + // OSPolicyAssignments in the project/location. + // Either {instance} or {assignment} must be `-`. + // + // For example: + // `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/-/reports` + // returns all reports for the instance + // `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/{assignment-id}/reports` + // returns all the reports for the given assignment across all instances. + // `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/-/reports` + // returns all the reports for all assignments across all instances. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/InstanceOSPolicyAssignment" + } + ]; + + // The maximum number of results to return. + int32 page_size = 2; + + // If provided, this field specifies the criteria that must be met by the + // `OSPolicyAssignmentReport` API resource that is included in the response. + string filter = 3; + + // A pagination token returned from a previous call to the + // `ListOSPolicyAssignmentReports` method that indicates where this listing + // should continue from. + string page_token = 4; +} + +// A response message for listing OS Policy assignment reports including the +// page of results and page token. +message ListOSPolicyAssignmentReportsResponse { + // List of OS policy assignment reports. + repeated OSPolicyAssignmentReport os_policy_assignment_reports = 1; + + // The pagination token to retrieve the next page of OS policy assignment + // report objects. + string next_page_token = 2; +} + +// A report of the OS policy assignment status for a given instance. +message OSPolicyAssignmentReport { + option (google.api.resource) = { + type: "osconfig.googleapis.com/OSPolicyAssignmentReport" + pattern: "projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report" + }; + + // Compliance data for an OS policy + message OSPolicyCompliance { + // Possible compliance states for an os policy. + enum ComplianceState { + // The policy is in an unknown compliance state. + // + // Refer to the field `compliance_state_reason` to learn the exact reason + // for the policy to be in this compliance state. + UNKNOWN = 0; + + // Policy is compliant. + // + // The policy is compliant if all the underlying resources are also + // compliant. + COMPLIANT = 1; + + // Policy is non-compliant. + // + // The policy is non-compliant if one or more underlying resources are + // non-compliant. + NON_COMPLIANT = 2; + } + + // Compliance data for an OS policy resource. + message OSPolicyResourceCompliance { + // Step performed by the OS Config agent for configuring an + // `OSPolicy` resource to its desired state. + message OSPolicyResourceConfigStep { + // Supported configuration step types + enum Type { + // Default value. This value is unused. + TYPE_UNSPECIFIED = 0; + + // Checks for resource conflicts such as schema errors. + VALIDATION = 1; + + // Checks the current status of the desired state for a resource. + DESIRED_STATE_CHECK = 2; + + // Enforces the desired state for a resource that is not in desired + // state. + DESIRED_STATE_ENFORCEMENT = 3; + + // Re-checks the status of the desired state. This check is done + // for a resource after the enforcement of all OS policies. + // + // This step is used to determine the final desired state status for + // the resource. It accounts for any resources that might have drifted + // from their desired state due to side effects from executing other + // resources. + DESIRED_STATE_CHECK_POST_ENFORCEMENT = 4; + } + + // Configuration step type. + Type type = 1; + + // An error message recorded during the execution of this step. + // Only populated if errors were encountered during this step execution. + string error_message = 2; + } + + // Possible compliance states for a resource. + enum ComplianceState { + // The resource is in an unknown compliance state. + // + // To get more details about why the policy is in this state, review + // the output of the `compliance_state_reason` field. + UNKNOWN = 0; + + // Resource is compliant. + COMPLIANT = 1; + + // Resource is non-compliant. + NON_COMPLIANT = 2; + } + + // ExecResource specific output. + message ExecResourceOutput { + // Output from enforcement phase output file (if run). + // Output size is limited to 100K bytes. + bytes enforcement_output = 2; + } + + // The ID of the OS policy resource. + string os_policy_resource_id = 1; + + // Ordered list of configuration completed by the agent for the OS policy + // resource. + repeated OSPolicyResourceConfigStep config_steps = 2; + + // The compliance state of the resource. + ComplianceState compliance_state = 3; + + // A reason for the resource to be in the given compliance state. + // This field is always populated when `compliance_state` is `UNKNOWN`. + // + // The following values are supported when `compliance_state == UNKNOWN` + // + // * `execution-errors`: Errors were encountered by the agent while + // executing the resource and the compliance state couldn't be + // determined. + // * `execution-skipped-by-agent`: Resource execution was skipped by the + // agent because errors were encountered while executing prior resources + // in the OS policy. + // * `os-policy-execution-attempt-failed`: The execution of the OS policy + // containing this resource failed and the compliance state couldn't be + // determined. + string compliance_state_reason = 4; + + // Resource specific output. + oneof output { + // ExecResource specific output. + ExecResourceOutput exec_resource_output = 5; + } + } + + // The OS policy id + string os_policy_id = 1; + + // The compliance state of the OS policy. + ComplianceState compliance_state = 2; + + // The reason for the OS policy to be in an unknown compliance state. + // This field is always populated when `compliance_state` is `UNKNOWN`. + // + // If populated, the field can contain one of the following values: + // + // * `vm-not-running`: The VM was not running. + // * `os-policies-not-supported-by-agent`: The version of the OS Config + // agent running on the VM does not support running OS policies. + // * `no-agent-detected`: The OS Config agent is not detected for the VM. + // * `resource-execution-errors`: The OS Config agent encountered errors + // while executing one or more resources in the policy. See + // `os_policy_resource_compliances` for details. + // * `task-timeout`: The task sent to the agent to apply the policy timed + // out. + // * `unexpected-agent-state`: The OS Config agent did not report the final + // status of the task that attempted to apply the policy. Instead, the agent + // unexpectedly started working on a different task. This mostly happens + // when the agent or VM unexpectedly restarts while applying OS policies. + // * `internal-service-errors`: Internal service errors were encountered + // while attempting to apply the policy. + string compliance_state_reason = 3; + + // Compliance data for each resource within the policy that is applied to + // the VM. + repeated OSPolicyResourceCompliance os_policy_resource_compliances = 4; + } + + // The `OSPolicyAssignmentReport` API resource name. + // + // Format: + // `projects/{project_number}/locations/{location}/instances/{instance_id}/osPolicyAssignments/{os_policy_assignment_id}/report` + string name = 1; + + // The Compute Engine VM instance name. + string instance = 2; + + // Reference to the `OSPolicyAssignment` API resource that the `OSPolicy` + // belongs to. + // + // Format: + // `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id@revision_id}` + string os_policy_assignment = 3 [(google.api.resource_reference) = { + type: "osconfig.googleapis.com/OSPolicyAssignment" + }]; + + // Compliance data for each `OSPolicy` that is applied to the VM. + repeated OSPolicyCompliance os_policy_compliances = 4; + + // Timestamp for when the report was last generated. + google.protobuf.Timestamp update_time = 5; + + // Unique identifier of the last attempted run to apply the OS policies + // associated with this assignment on the VM. + // + // This ID is logged by the OS Config agent while applying the OS + // policies associated with this assignment on the VM. + // NOTE: If the service is unable to successfully connect to the agent for + // this run, then this id will not be available in the agent logs. + string last_run_id = 6; +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy_assignments.proto b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy_assignments.proto new file mode 100644 index 00000000000..73e10aeb6a3 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy_assignments.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.osconfig.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/osconfig/v1/os_policy.proto"; +import "google/cloud/osconfig/v1/osconfig_common.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.OsConfig.V1"; +option go_package = "cloud.google.com/go/osconfig/apiv1/osconfigpb;osconfigpb"; +option java_multiple_files = true; +option java_outer_classname = "OsPolicyAssignmentsProto"; +option java_package = "com.google.cloud.osconfig.v1"; +option php_namespace = "Google\\Cloud\\OsConfig\\V1"; +option ruby_package = "Google::Cloud::OsConfig::V1"; + +// OS policy assignment is an API resource that is used to +// apply a set of OS policies to a dynamically targeted group of Compute Engine +// VM instances. +// +// An OS policy is used to define the desired state configuration for a +// Compute Engine VM instance through a set of configuration resources that +// provide capabilities such as installing or removing software packages, or +// executing a script. +// +// For more information, see [OS policy and OS policy +// assignment](https://cloud.google.com/compute/docs/os-configuration-management/working-with-os-policies). +message OSPolicyAssignment { + option (google.api.resource) = { + type: "osconfig.googleapis.com/OSPolicyAssignment" + pattern: "projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}" + }; + + // Message representing label set. + // * A label is a key value pair set for a VM. + // * A LabelSet is a set of labels. + // * Labels within a LabelSet are ANDed. In other words, a LabelSet is + // applicable for a VM only if it matches all the labels in the + // LabelSet. + // * Example: A LabelSet with 2 labels: `env=prod` and `type=webserver` will + // only be applicable for those VMs with both labels + // present. + message LabelSet { + // Labels are identified by key/value pairs in this map. + // A VM should contain all the key/value pairs specified in this + // map to be selected. + map labels = 1; + } + + // Filters to select target VMs for an assignment. + // + // If more than one filter criteria is specified below, a VM will be selected + // if and only if it satisfies all of them. + message InstanceFilter { + // VM inventory details. + message Inventory { + // Required. The OS short name + string os_short_name = 1 [(google.api.field_behavior) = REQUIRED]; + + // The OS version + // + // Prefix matches are supported if asterisk(*) is provided as the + // last character. For example, to match all versions with a major + // version of `7`, specify the following value for this field `7.*` + // + // An empty string matches all OS versions. + string os_version = 2; + } + + // Target all VMs in the project. If true, no other criteria is + // permitted. + bool all = 1; + + // List of label sets used for VM inclusion. + // + // If the list has more than one `LabelSet`, the VM is included if any + // of the label sets are applicable for the VM. + repeated LabelSet inclusion_labels = 2; + + // List of label sets used for VM exclusion. + // + // If the list has more than one label set, the VM is excluded if any + // of the label sets are applicable for the VM. + repeated LabelSet exclusion_labels = 3; + + // List of inventories to select VMs. + // + // A VM is selected if its inventory data matches at least one of the + // following inventories. + repeated Inventory inventories = 4; + } + + // Message to configure the rollout at the zonal level for the OS policy + // assignment. + message Rollout { + // Required. The maximum number (or percentage) of VMs per zone to disrupt + // at any given moment. + FixedOrPercent disruption_budget = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. This determines the minimum duration of time to wait after the + // configuration changes are applied through the current rollout. A + // VM continues to count towards the `disruption_budget` at least + // until this duration of time has passed after configuration changes are + // applied. + google.protobuf.Duration min_wait_duration = 2 + [(google.api.field_behavior) = REQUIRED]; + } + + // OS policy assignment rollout state + enum RolloutState { + // Invalid value + ROLLOUT_STATE_UNSPECIFIED = 0; + + // The rollout is in progress. + IN_PROGRESS = 1; + + // The rollout is being cancelled. + CANCELLING = 2; + + // The rollout is cancelled. + CANCELLED = 3; + + // The rollout has completed successfully. + SUCCEEDED = 4; + } + + // Resource name. + // + // Format: + // `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id}` + // + // This field is ignored when you create an OS policy assignment. + string name = 1; + + // OS policy assignment description. + // Length of the description is limited to 1024 characters. + string description = 2; + + // Required. List of OS policies to be applied to the VMs. + repeated OSPolicy os_policies = 3 [(google.api.field_behavior) = REQUIRED]; + + // Required. Filter to select VMs. + InstanceFilter instance_filter = 4 [(google.api.field_behavior) = REQUIRED]; + + // Required. Rollout to deploy the OS policy assignment. + // A rollout is triggered in the following situations: + // 1) OSPolicyAssignment is created. + // 2) OSPolicyAssignment is updated and the update contains changes to one of + // the following fields: + // - instance_filter + // - os_policies + // 3) OSPolicyAssignment is deleted. + Rollout rollout = 5 [(google.api.field_behavior) = REQUIRED]; + + // Output only. The assignment revision ID + // A new revision is committed whenever a rollout is triggered for a OS policy + // assignment + string revision_id = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp that the revision was created. + google.protobuf.Timestamp revision_create_time = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The etag for this OS policy assignment. + // If this is provided on update, it must match the server's etag. + string etag = 8; + + // Output only. OS policy assignment rollout state + RolloutState rollout_state = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Indicates that this revision has been successfully rolled out + // in this zone and new VMs will be assigned OS policies from this revision. + // + // For a given OS policy assignment, there is only one revision with a value + // of `true` for this field. + bool baseline = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Indicates that this revision deletes the OS policy assignment. + bool deleted = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Indicates that reconciliation is in progress for the revision. + // This value is `true` when the `rollout_state` is one of: + // * IN_PROGRESS + // * CANCELLING + bool reconciling = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Server generated unique id for the OS policy assignment + // resource. + string uid = 13 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// OS policy assignment operation metadata provided by OS policy assignment API +// methods that return long running operations. +message OSPolicyAssignmentOperationMetadata { + // The OS policy assignment API method. + enum APIMethod { + // Invalid value + API_METHOD_UNSPECIFIED = 0; + + // Create OS policy assignment API method + CREATE = 1; + + // Update OS policy assignment API method + UPDATE = 2; + + // Delete OS policy assignment API method + DELETE = 3; + } + + // State of the rollout + enum RolloutState { + // Invalid value + ROLLOUT_STATE_UNSPECIFIED = 0; + + // The rollout is in progress. + IN_PROGRESS = 1; + + // The rollout is being cancelled. + CANCELLING = 2; + + // The rollout is cancelled. + CANCELLED = 3; + + // The rollout has completed successfully. + SUCCEEDED = 4; + } + + // Reference to the `OSPolicyAssignment` API resource. + // + // Format: + // `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id@revision_id}` + string os_policy_assignment = 1 [(google.api.resource_reference) = { + type: "osconfig.googleapis.com/OSPolicyAssignment" + }]; + + // The OS policy assignment API method. + APIMethod api_method = 2; + + // State of the rollout + RolloutState rollout_state = 3; + + // Rollout start time + google.protobuf.Timestamp rollout_start_time = 4; + + // Rollout update time + google.protobuf.Timestamp rollout_update_time = 5; +} + +// A request message to create an OS policy assignment +message CreateOSPolicyAssignmentRequest { + // Required. The parent resource name in the form: + // projects/{project}/locations/{location} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The OS policy assignment to be created. + OSPolicyAssignment os_policy_assignment = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Required. The logical name of the OS policy assignment in the project + // with the following restrictions: + // + // * Must contain only lowercase letters, numbers, and hyphens. + // * Must start with a letter. + // * Must be between 1-63 characters. + // * Must end with a number or a letter. + // * Must be unique within the project. + string os_policy_assignment_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// A request message to update an OS policy assignment +message UpdateOSPolicyAssignmentRequest { + // Required. The updated OS policy assignment. + OSPolicyAssignment os_policy_assignment = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Optional. Field mask that controls which fields of the assignment should be + // updated. + google.protobuf.FieldMask update_mask = 2 + [(google.api.field_behavior) = OPTIONAL]; +} + +// A request message to get an OS policy assignment +message GetOSPolicyAssignmentRequest { + // Required. The resource name of OS policy assignment. + // + // Format: + // `projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}@{revisionId}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/OSPolicyAssignment" + } + ]; +} + +// A request message to list OS policy assignments for a parent resource +message ListOSPolicyAssignmentsRequest { + // Required. The parent resource name. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of assignments to return. + int32 page_size = 2; + + // A pagination token returned from a previous call to + // `ListOSPolicyAssignments` that indicates where this listing should continue + // from. + string page_token = 3; +} + +// A response message for listing all assignments under given parent. +message ListOSPolicyAssignmentsResponse { + // The list of assignments + repeated OSPolicyAssignment os_policy_assignments = 1; + + // The pagination token to retrieve the next page of OS policy assignments. + string next_page_token = 2; +} + +// A request message to list revisions for a OS policy assignment +message ListOSPolicyAssignmentRevisionsRequest { + // Required. The name of the OS policy assignment to list revisions for. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/OSPolicyAssignment" + } + ]; + + // The maximum number of revisions to return. + int32 page_size = 2; + + // A pagination token returned from a previous call to + // `ListOSPolicyAssignmentRevisions` that indicates where this listing should + // continue from. + string page_token = 3; +} + +// A response message for listing all revisions for a OS policy assignment. +message ListOSPolicyAssignmentRevisionsResponse { + // The OS policy assignment revisions + repeated OSPolicyAssignment os_policy_assignments = 1; + + // The pagination token to retrieve the next page of OS policy assignment + // revisions. + string next_page_token = 2; +} + +// A request message for deleting a OS policy assignment. +message DeleteOSPolicyAssignmentRequest { + // Required. The name of the OS policy assignment to be deleted + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/OSPolicyAssignment" + } + ]; +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_common.proto b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_common.proto new file mode 100644 index 00000000000..baa6e37294b --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_common.proto @@ -0,0 +1,38 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1; + +option csharp_namespace = "Google.Cloud.OsConfig.V1"; +option go_package = "cloud.google.com/go/osconfig/apiv1/osconfigpb;osconfigpb"; +option java_outer_classname = "Common"; +option java_package = "com.google.cloud.osconfig.v1"; +option php_namespace = "Google\\Cloud\\OsConfig\\V1"; +option ruby_package = "Google::Cloud::OsConfig::V1"; + +// Message encapsulating a value that can be either absolute ("fixed") or +// relative ("percent") to a value. +message FixedOrPercent { + // Type of the value. + oneof mode { + // Specifies a fixed value. + int32 fixed = 1; + + // Specifies the relative value defined as a percentage, which will be + // multiplied by a reference value. + int32 percent = 2; + } +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_service.proto b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_service.proto new file mode 100644 index 00000000000..c6afe3fa5b6 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_service.proto @@ -0,0 +1,158 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1; + +import "google/api/client.proto"; +import "google/api/resource.proto"; +import "google/cloud/osconfig/v1/patch_deployments.proto"; +import "google/cloud/osconfig/v1/patch_jobs.proto"; +import "google/protobuf/empty.proto"; +import "google/api/annotations.proto"; + +option csharp_namespace = "Google.Cloud.OsConfig.V1"; +option go_package = "cloud.google.com/go/osconfig/apiv1/osconfigpb;osconfigpb"; +option java_outer_classname = "OsConfigProto"; +option java_package = "com.google.cloud.osconfig.v1"; +option php_namespace = "Google\\Cloud\\OsConfig\\V1"; +option ruby_package = "Google::Cloud::OsConfig::V1"; +option (google.api.resource_definition) = { + type: "compute.googleapis.com/Instance" + pattern: "projects/{project}/zones/{zone}/instances/{instance}" + pattern: "projects/{project}/locations/{location}/instances/{instance}" +}; + +// OS Config API +// +// The OS Config service is a server-side component that you can use to +// manage package installations and patch jobs for virtual machine instances. +service OsConfigService { + option (google.api.default_host) = "osconfig.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Patch VM instances by creating and running a patch job. + rpc ExecutePatchJob(ExecutePatchJobRequest) returns (PatchJob) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/patchJobs:execute" + body: "*" + }; + } + + // Get the patch job. This can be used to track the progress of an + // ongoing patch job or review the details of completed jobs. + rpc GetPatchJob(GetPatchJobRequest) returns (PatchJob) { + option (google.api.http) = { + get: "/v1/{name=projects/*/patchJobs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Cancel a patch job. The patch job must be active. Canceled patch jobs + // cannot be restarted. + rpc CancelPatchJob(CancelPatchJobRequest) returns (PatchJob) { + option (google.api.http) = { + post: "/v1/{name=projects/*/patchJobs/*}:cancel" + body: "*" + }; + } + + // Get a list of patch jobs. + rpc ListPatchJobs(ListPatchJobsRequest) returns (ListPatchJobsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*}/patchJobs" + }; + option (google.api.method_signature) = "parent"; + } + + // Get a list of instance details for a given patch job. + rpc ListPatchJobInstanceDetails(ListPatchJobInstanceDetailsRequest) + returns (ListPatchJobInstanceDetailsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/patchJobs/*}/instanceDetails" + }; + option (google.api.method_signature) = "parent"; + } + + // Create an OS Config patch deployment. + rpc CreatePatchDeployment(CreatePatchDeploymentRequest) + returns (PatchDeployment) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/patchDeployments" + body: "patch_deployment" + }; + option (google.api.method_signature) = + "parent,patch_deployment,patch_deployment_id"; + } + + // Get an OS Config patch deployment. + rpc GetPatchDeployment(GetPatchDeploymentRequest) returns (PatchDeployment) { + option (google.api.http) = { + get: "/v1/{name=projects/*/patchDeployments/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Get a page of OS Config patch deployments. + rpc ListPatchDeployments(ListPatchDeploymentsRequest) + returns (ListPatchDeploymentsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*}/patchDeployments" + }; + option (google.api.method_signature) = "parent"; + } + + // Delete an OS Config patch deployment. + rpc DeletePatchDeployment(DeletePatchDeploymentRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/patchDeployments/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Update an OS Config patch deployment. + rpc UpdatePatchDeployment(UpdatePatchDeploymentRequest) + returns (PatchDeployment) { + option (google.api.http) = { + patch: "/v1/{patch_deployment.name=projects/*/patchDeployments/*}" + body: "patch_deployment" + }; + option (google.api.method_signature) = "patch_deployment,update_mask"; + } + + // Change state of patch deployment to "PAUSED". + // Patch deployment in paused state doesn't generate patch jobs. + rpc PausePatchDeployment(PausePatchDeploymentRequest) + returns (PatchDeployment) { + option (google.api.http) = { + post: "/v1/{name=projects/*/patchDeployments/*}:pause" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Change state of patch deployment back to "ACTIVE". + // Patch deployment in active state continues to generate patch jobs. + rpc ResumePatchDeployment(ResumePatchDeploymentRequest) + returns (PatchDeployment) { + option (google.api.http) = { + post: "/v1/{name=projects/*/patchDeployments/*}:resume" + body: "*" + }; + option (google.api.method_signature) = "name"; + } +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_zonal_service.proto b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_zonal_service.proto new file mode 100644 index 00000000000..671ed3c0d93 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_zonal_service.proto @@ -0,0 +1,202 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/cloud/osconfig/v1/inventory.proto"; +import "google/cloud/osconfig/v1/os_policy_assignment_reports.proto"; +import "google/cloud/osconfig/v1/os_policy_assignments.proto"; +import "google/cloud/osconfig/v1/vulnerability.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.OsConfig.V1"; +option go_package = "cloud.google.com/go/osconfig/apiv1/osconfigpb;osconfigpb"; +option java_multiple_files = true; +option java_outer_classname = "OsConfigZonalServiceProto"; +option java_package = "com.google.cloud.osconfig.v1"; +option php_namespace = "Google\\Cloud\\OsConfig\\V1"; +option ruby_package = "Google::Cloud::OsConfig::V1"; + +// Zonal OS Config API +// +// The OS Config service is the server-side component that allows users to +// manage package installations and patch jobs for Compute Engine VM instances. +service OsConfigZonalService { + option (google.api.default_host) = "osconfig.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Create an OS policy assignment. + // + // This method also creates the first revision of the OS policy assignment. + // + // This method returns a long running operation (LRO) that contains the + // rollout details. The rollout can be cancelled by cancelling the LRO. + // + // For more information, see [Method: + // projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel). + rpc CreateOSPolicyAssignment(CreateOSPolicyAssignmentRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/osPolicyAssignments" + body: "os_policy_assignment" + }; + option (google.api.method_signature) = + "parent,os_policy_assignment,os_policy_assignment_id"; + option (google.longrunning.operation_info) = { + response_type: "OSPolicyAssignment" + metadata_type: "OSPolicyAssignmentOperationMetadata" + }; + } + + // Update an existing OS policy assignment. + // + // This method creates a new revision of the OS policy assignment. + // + // This method returns a long running operation (LRO) that contains the + // rollout details. The rollout can be cancelled by cancelling the LRO. + // + // For more information, see [Method: + // projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel). + rpc UpdateOSPolicyAssignment(UpdateOSPolicyAssignmentRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{os_policy_assignment.name=projects/*/locations/*/osPolicyAssignments/*}" + body: "os_policy_assignment" + }; + option (google.api.method_signature) = "os_policy_assignment,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "OSPolicyAssignment" + metadata_type: "OSPolicyAssignmentOperationMetadata" + }; + } + + // Retrieve an existing OS policy assignment. + // + // This method always returns the latest revision. In order to retrieve a + // previous revision of the assignment, also provide the revision ID in the + // `name` parameter. + rpc GetOSPolicyAssignment(GetOSPolicyAssignmentRequest) + returns (OSPolicyAssignment) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/osPolicyAssignments/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List the OS policy assignments under the parent resource. + // + // For each OS policy assignment, the latest revision is returned. + rpc ListOSPolicyAssignments(ListOSPolicyAssignmentsRequest) + returns (ListOSPolicyAssignmentsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/osPolicyAssignments" + }; + option (google.api.method_signature) = "parent"; + } + + // List the OS policy assignment revisions for a given OS policy assignment. + rpc ListOSPolicyAssignmentRevisions(ListOSPolicyAssignmentRevisionsRequest) + returns (ListOSPolicyAssignmentRevisionsResponse) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/osPolicyAssignments/*}:listRevisions" + }; + option (google.api.method_signature) = "name"; + } + + // Delete the OS policy assignment. + // + // This method creates a new revision of the OS policy assignment. + // + // This method returns a long running operation (LRO) that contains the + // rollout details. The rollout can be cancelled by cancelling the LRO. + // + // If the LRO completes and is not cancelled, all revisions associated with + // the OS policy assignment are deleted. + // + // For more information, see [Method: + // projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel). + rpc DeleteOSPolicyAssignment(DeleteOSPolicyAssignmentRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/osPolicyAssignments/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "OSPolicyAssignmentOperationMetadata" + }; + } + + // Get the OS policy asssignment report for the specified Compute Engine VM + // instance. + rpc GetOSPolicyAssignmentReport(GetOSPolicyAssignmentReportRequest) + returns (OSPolicyAssignmentReport) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/instances/*/osPolicyAssignments/*/report}" + }; + option (google.api.method_signature) = "name"; + } + + // List OS policy asssignment reports for all Compute Engine VM instances in + // the specified zone. + rpc ListOSPolicyAssignmentReports(ListOSPolicyAssignmentReportsRequest) + returns (ListOSPolicyAssignmentReportsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*/instances/*/osPolicyAssignments/*}/reports" + }; + option (google.api.method_signature) = "parent"; + } + + // Get inventory data for the specified VM instance. If the VM has no + // associated inventory, the message `NOT_FOUND` is returned. + rpc GetInventory(GetInventoryRequest) returns (Inventory) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/instances/*/inventory}" + }; + option (google.api.method_signature) = "name"; + } + + // List inventory data for all VM instances in the specified zone. + rpc ListInventories(ListInventoriesRequest) + returns (ListInventoriesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*/instances/*}/inventories" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets the vulnerability report for the specified VM instance. Only VMs with + // inventory data have vulnerability reports associated with them. + rpc GetVulnerabilityReport(GetVulnerabilityReportRequest) + returns (VulnerabilityReport) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/instances/*/vulnerabilityReport}" + }; + option (google.api.method_signature) = "name"; + } + + // List vulnerability reports for all VM instances in the specified zone. + rpc ListVulnerabilityReports(ListVulnerabilityReportsRequest) + returns (ListVulnerabilityReportsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*/instances/*}/vulnerabilityReports" + }; + option (google.api.method_signature) = "parent"; + } +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/patch_deployments.proto b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/patch_deployments.proto new file mode 100644 index 00000000000..ac45652d9d7 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/patch_deployments.proto @@ -0,0 +1,339 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/osconfig/v1/patch_jobs.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/datetime.proto"; +import "google/type/dayofweek.proto"; +import "google/type/timeofday.proto"; + +option csharp_namespace = "Google.Cloud.OsConfig.V1"; +option go_package = "cloud.google.com/go/osconfig/apiv1/osconfigpb;osconfigpb"; +option java_outer_classname = "PatchDeployments"; +option java_package = "com.google.cloud.osconfig.v1"; +option php_namespace = "Google\\Cloud\\OsConfig\\V1"; +option ruby_package = "Google::Cloud::OsConfig::V1"; + +// Patch deployments are configurations that individual patch jobs use to +// complete a patch. These configurations include instance filter, package +// repository settings, and a schedule. For more information about creating and +// managing patch deployments, see [Scheduling patch +// jobs](https://cloud.google.com/compute/docs/os-patch-management/schedule-patch-jobs). +message PatchDeployment { + option (google.api.resource) = { + type: "osconfig.googleapis.com/PatchDeployment" + pattern: "projects/{project}/patchDeployments/{patch_deployment}" + }; + + // Represents state of patch peployment. + enum State { + // The default value. This value is used if the state is omitted. + STATE_UNSPECIFIED = 0; + + // Active value means that patch deployment generates Patch Jobs. + ACTIVE = 1; + + // Paused value means that patch deployment does not generate + // Patch jobs. Requires user action to move in and out from this state. + PAUSED = 2; + } + + // Unique name for the patch deployment resource in a project. The patch + // deployment name is in the form: + // `projects/{project_id}/patchDeployments/{patch_deployment_id}`. + // This field is ignored when you create a new patch deployment. + string name = 1; + + // Optional. Description of the patch deployment. Length of the description is + // limited to 1024 characters. + string description = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Required. VM instances to patch. + PatchInstanceFilter instance_filter = 3 + [(google.api.field_behavior) = REQUIRED]; + + // Optional. Patch configuration that is applied. + PatchConfig patch_config = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Duration of the patch. After the duration ends, the patch times + // out. + google.protobuf.Duration duration = 5 + [(google.api.field_behavior) = OPTIONAL]; + + // Schedule for the patch. + oneof schedule { + // Required. Schedule a one-time execution. + OneTimeSchedule one_time_schedule = 6 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Schedule recurring executions. + RecurringSchedule recurring_schedule = 7 + [(google.api.field_behavior) = REQUIRED]; + } + + // Output only. Time the patch deployment was created. Timestamp is in + // [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text format. + google.protobuf.Timestamp create_time = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Time the patch deployment was last updated. Timestamp is in + // [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text format. + google.protobuf.Timestamp update_time = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last time a patch job was started by this deployment. + // Timestamp is in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text + // format. + google.protobuf.Timestamp last_execute_time = 10 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Rollout strategy of the patch job. + PatchRollout rollout = 11 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. Current state of the patch deployment. + State state = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Sets the time for a one time patch deployment. Timestamp is in +// [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text format. +message OneTimeSchedule { + // Required. The desired patch job execution time. + google.protobuf.Timestamp execute_time = 1 + [(google.api.field_behavior) = REQUIRED]; +} + +// Sets the time for recurring patch deployments. +message RecurringSchedule { + // Specifies the frequency of the recurring patch deployments. + enum Frequency { + // Invalid. A frequency must be specified. + FREQUENCY_UNSPECIFIED = 0; + + // Indicates that the frequency of recurrence should be expressed in terms + // of weeks. + WEEKLY = 1; + + // Indicates that the frequency of recurrence should be expressed in terms + // of months. + MONTHLY = 2; + + // Indicates that the frequency of recurrence should be expressed in terms + // of days. + DAILY = 3; + } + + // Required. Defines the time zone that `time_of_day` is relative to. + // The rules for daylight saving time are determined by the chosen time zone. + google.type.TimeZone time_zone = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The time that the recurring schedule becomes effective. + // Defaults to `create_time` of the patch deployment. + google.protobuf.Timestamp start_time = 2 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The end time at which a recurring patch deployment schedule is no + // longer active. + google.protobuf.Timestamp end_time = 3 + [(google.api.field_behavior) = OPTIONAL]; + + // Required. Time of the day to run a recurring deployment. + google.type.TimeOfDay time_of_day = 4 + [(google.api.field_behavior) = REQUIRED]; + + // Required. The frequency unit of this recurring schedule. + Frequency frequency = 5 [(google.api.field_behavior) = REQUIRED]; + + // Configurations for this recurring schedule. + // Configurations must match frequency. + oneof schedule_config { + // Required. Schedule with weekly executions. + WeeklySchedule weekly = 6 [(google.api.field_behavior) = REQUIRED]; + + // Required. Schedule with monthly executions. + MonthlySchedule monthly = 7 [(google.api.field_behavior) = REQUIRED]; + } + + // Output only. The time the last patch job ran successfully. + google.protobuf.Timestamp last_execute_time = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time the next patch job is scheduled to run. + google.protobuf.Timestamp next_execute_time = 10 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Represents a weekly schedule. +message WeeklySchedule { + // Required. Day of the week. + google.type.DayOfWeek day_of_week = 1 + [(google.api.field_behavior) = REQUIRED]; +} + +// Represents a monthly schedule. An example of a valid monthly schedule is +// "on the third Tuesday of the month" or "on the 15th of the month". +message MonthlySchedule { + // One day in a month. + oneof day_of_month { + // Required. Week day in a month. + WeekDayOfMonth week_day_of_month = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. One day of the month. 1-31 indicates the 1st to the 31st day. + // -1 indicates the last day of the month. Months without the target day + // will be skipped. For example, a schedule to run "every month on the 31st" + // will not run in February, April, June, etc. + int32 month_day = 2 [(google.api.field_behavior) = REQUIRED]; + } +} + +// Represents one week day in a month. An example is "the 4th Sunday". +message WeekDayOfMonth { + // Required. Week number in a month. 1-4 indicates the 1st to 4th week of the + // month. -1 indicates the last week of the month. + int32 week_ordinal = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. A day of the week. + google.type.DayOfWeek day_of_week = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Optional. Represents the number of days before or after the given week day + // of month that the patch deployment is scheduled for. For example if + // `week_ordinal` and `day_of_week` values point to the second day of the + // month and this `day_offset` value is set to `3`, the patch deployment takes + // place three days after the second Tuesday of the month. If this value is + // negative, for example -5, the patches are deployed five days before before + // the second Tuesday of the month. Allowed values are in range [-30, 30]. + int32 day_offset = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// A request message for creating a patch deployment. +message CreatePatchDeploymentRequest { + // Required. The project to apply this patch deployment to in the form + // `projects/*`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Required. A name for the patch deployment in the project. When creating a + // name the following rules apply: + // * Must contain only lowercase letters, numbers, and hyphens. + // * Must start with a letter. + // * Must be between 1-63 characters. + // * Must end with a number or a letter. + // * Must be unique within the project. + string patch_deployment_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The patch deployment to create. + PatchDeployment patch_deployment = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// A request message for retrieving a patch deployment. +message GetPatchDeploymentRequest { + // Required. The resource name of the patch deployment in the form + // `projects/*/patchDeployments/*`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/PatchDeployment" + } + ]; +} + +// A request message for listing patch deployments. +message ListPatchDeploymentsRequest { + // Required. The resource name of the parent in the form `projects/*`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Optional. The maximum number of patch deployments to return. Default is + // 100. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A pagination token returned from a previous call to + // ListPatchDeployments that indicates where this listing should continue + // from. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// A response message for listing patch deployments. +message ListPatchDeploymentsResponse { + // The list of patch deployments. + repeated PatchDeployment patch_deployments = 1; + + // A pagination token that can be used to get the next page of patch + // deployments. + string next_page_token = 2; +} + +// A request message for deleting a patch deployment. +message DeletePatchDeploymentRequest { + // Required. The resource name of the patch deployment in the form + // `projects/*/patchDeployments/*`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/PatchDeployment" + } + ]; +} + +// A request message for updating a patch deployment. +message UpdatePatchDeploymentRequest { + // Required. The patch deployment to Update. + PatchDeployment patch_deployment = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Field mask that controls which fields of the patch deployment + // should be updated. + google.protobuf.FieldMask update_mask = 2 + [(google.api.field_behavior) = OPTIONAL]; +} + +// A request message for pausing a patch deployment. +message PausePatchDeploymentRequest { + // Required. The resource name of the patch deployment in the form + // `projects/*/patchDeployments/*`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/PatchDeployment" + } + ]; +} + +// A request message for resuming a patch deployment. +message ResumePatchDeploymentRequest { + // Required. The resource name of the patch deployment in the form + // `projects/*/patchDeployments/*`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/PatchDeployment" + } + ]; +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/patch_jobs.proto b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/patch_jobs.proto new file mode 100644 index 00000000000..7c0b3400713 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/patch_jobs.proto @@ -0,0 +1,742 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/osconfig/v1/osconfig_common.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.OsConfig.V1"; +option go_package = "cloud.google.com/go/osconfig/apiv1/osconfigpb;osconfigpb"; +option java_outer_classname = "PatchJobs"; +option java_package = "com.google.cloud.osconfig.v1"; +option php_namespace = "Google\\Cloud\\OsConfig\\V1"; +option ruby_package = "Google::Cloud::OsConfig::V1"; + +// A request message to initiate patching across Compute Engine +// instances. +message ExecutePatchJobRequest { + // Required. The project in which to run this patch in the form `projects/*` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Description of the patch job. Length of the description is limited + // to 1024 characters. + string description = 2; + + // Required. Instances to patch, either explicitly or filtered by some + // criteria such as zone or labels. + PatchInstanceFilter instance_filter = 7 + [(google.api.field_behavior) = REQUIRED]; + + // Patch configuration being applied. If omitted, instances are + // patched using the default configurations. + PatchConfig patch_config = 4; + + // Duration of the patch job. After the duration ends, the patch job + // times out. + google.protobuf.Duration duration = 5; + + // If this patch is a dry-run only, instances are contacted but + // will do nothing. + bool dry_run = 6; + + // Display name for this patch job. This does not have to be unique. + string display_name = 8; + + // Rollout strategy of the patch job. + PatchRollout rollout = 9; +} + +// Request to get an active or completed patch job. +message GetPatchJobRequest { + // Required. Name of the patch in the form `projects/*/patchJobs/*` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/PatchJob" + } + ]; +} + +// Request to list details for all instances that are part of a patch job. +message ListPatchJobInstanceDetailsRequest { + // Required. The parent for the instances are in the form of + // `projects/*/patchJobs/*`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/PatchJob" + } + ]; + + // The maximum number of instance details records to return. Default is 100. + int32 page_size = 2; + + // A pagination token returned from a previous call + // that indicates where this listing should continue from. + string page_token = 3; + + // A filter expression that filters results listed in the response. This + // field supports filtering results by instance zone, name, state, or + // `failure_reason`. + string filter = 4; +} + +// A response message for listing the instances details for a patch job. +message ListPatchJobInstanceDetailsResponse { + // A list of instance status. + repeated PatchJobInstanceDetails patch_job_instance_details = 1; + + // A pagination token that can be used to get the next page of results. + string next_page_token = 2; +} + +// Patch details for a VM instance. For more information about reviewing VM +// instance details, see +// [Listing all VM instance details for a specific patch +// job](https://cloud.google.com/compute/docs/os-patch-management/manage-patch-jobs#list-instance-details). +message PatchJobInstanceDetails { + // The instance name in the form `projects/*/zones/*/instances/*` + string name = 1 [(google.api.resource_reference) = { + type: "compute.googleapis.com/Instance" + }]; + + // The unique identifier for the instance. This identifier is + // defined by the server. + string instance_system_id = 2; + + // Current state of instance patch. + Instance.PatchState state = 3; + + // If the patch fails, this field provides the reason. + string failure_reason = 4; + + // The number of times the agent that the agent attempts to apply the patch. + int64 attempt_count = 5; +} + +// A request message for listing patch jobs. +message ListPatchJobsRequest { + // Required. In the form of `projects/*` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // The maximum number of instance status to return. + int32 page_size = 2; + + // A pagination token returned from a previous call + // that indicates where this listing should continue from. + string page_token = 3; + + // If provided, this field specifies the criteria that must be met by patch + // jobs to be included in the response. + // Currently, filtering is only available on the patch_deployment field. + string filter = 4; +} + +// A response message for listing patch jobs. +message ListPatchJobsResponse { + // The list of patch jobs. + repeated PatchJob patch_jobs = 1; + + // A pagination token that can be used to get the next page of results. + string next_page_token = 2; +} + +// A high level representation of a patch job that is either in progress +// or has completed. +// +// Instance details are not included in the job. To paginate through instance +// details, use ListPatchJobInstanceDetails. +// +// For more information about patch jobs, see +// [Creating patch +// jobs](https://cloud.google.com/compute/docs/os-patch-management/create-patch-job). +message PatchJob { + option (google.api.resource) = { + type: "osconfig.googleapis.com/PatchJob" + pattern: "projects/{project}/patchJobs/{patch_job}" + }; + + // Enumeration of the various states a patch job passes through as it + // executes. + enum State { + // State must be specified. + STATE_UNSPECIFIED = 0; + + // The patch job was successfully initiated. + STARTED = 1; + + // The patch job is looking up instances to run the patch on. + INSTANCE_LOOKUP = 2; + + // Instances are being patched. + PATCHING = 3; + + // Patch job completed successfully. + SUCCEEDED = 4; + + // Patch job completed but there were errors. + COMPLETED_WITH_ERRORS = 5; + + // The patch job was canceled. + CANCELED = 6; + + // The patch job timed out. + TIMED_OUT = 7; + } + + // A summary of the current patch state across all instances that this patch + // job affects. Contains counts of instances in different states. These states + // map to `InstancePatchState`. List patch job instance details to see the + // specific states of each instance. + message InstanceDetailsSummary { + // Number of instances pending patch job. + int64 pending_instance_count = 1; + + // Number of instances that are inactive. + int64 inactive_instance_count = 2; + + // Number of instances notified about patch job. + int64 notified_instance_count = 3; + + // Number of instances that have started. + int64 started_instance_count = 4; + + // Number of instances that are downloading patches. + int64 downloading_patches_instance_count = 5; + + // Number of instances that are applying patches. + int64 applying_patches_instance_count = 6; + + // Number of instances rebooting. + int64 rebooting_instance_count = 7; + + // Number of instances that have completed successfully. + int64 succeeded_instance_count = 8; + + // Number of instances that require reboot. + int64 succeeded_reboot_required_instance_count = 9; + + // Number of instances that failed. + int64 failed_instance_count = 10; + + // Number of instances that have acked and will start shortly. + int64 acked_instance_count = 11; + + // Number of instances that exceeded the time out while applying the patch. + int64 timed_out_instance_count = 12; + + // Number of instances that are running the pre-patch step. + int64 pre_patch_step_instance_count = 13; + + // Number of instances that are running the post-patch step. + int64 post_patch_step_instance_count = 14; + + // Number of instances that do not appear to be running the agent. Check to + // ensure that the agent is installed, running, and able to communicate with + // the service. + int64 no_agent_detected_instance_count = 15; + } + + // Unique identifier for this patch job in the form + // `projects/*/patchJobs/*` + string name = 1; + + // Display name for this patch job. This is not a unique identifier. + string display_name = 14; + + // Description of the patch job. Length of the description is limited + // to 1024 characters. + string description = 2; + + // Time this patch job was created. + google.protobuf.Timestamp create_time = 3; + + // Last time this patch job was updated. + google.protobuf.Timestamp update_time = 4; + + // The current state of the PatchJob. + State state = 5; + + // Instances to patch. + PatchInstanceFilter instance_filter = 13; + + // Patch configuration being applied. + PatchConfig patch_config = 7; + + // Duration of the patch job. After the duration ends, the + // patch job times out. + google.protobuf.Duration duration = 8; + + // Summary of instance details. + InstanceDetailsSummary instance_details_summary = 9; + + // If this patch job is a dry run, the agent reports that it has + // finished without running any updates on the VM instance. + bool dry_run = 10; + + // If this patch job failed, this message provides information about the + // failure. + string error_message = 11; + + // Reflects the overall progress of the patch job in the range of + // 0.0 being no progress to 100.0 being complete. + double percent_complete = 12; + + // Output only. Name of the patch deployment that created this patch job. + string patch_deployment = 15 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/PatchDeployment" + } + ]; + + // Rollout strategy being applied. + PatchRollout rollout = 16; +} + +// Patch configuration specifications. Contains details on how to apply the +// patch(es) to a VM instance. +message PatchConfig { + // Post-patch reboot settings. + enum RebootConfig { + // The default behavior is DEFAULT. + REBOOT_CONFIG_UNSPECIFIED = 0; + + // The agent decides if a reboot is necessary by checking signals such as + // registry keys on Windows or `/var/run/reboot-required` on APT based + // systems. On RPM based systems, a set of core system package install times + // are compared with system boot time. + DEFAULT = 1; + + // Always reboot the machine after the update completes. + ALWAYS = 2; + + // Never reboot the machine after the update completes. + NEVER = 3; + } + + // Post-patch reboot settings. + RebootConfig reboot_config = 1; + + // Apt update settings. Use this setting to override the default `apt` patch + // rules. + AptSettings apt = 3; + + // Yum update settings. Use this setting to override the default `yum` patch + // rules. + YumSettings yum = 4; + + // Goo update settings. Use this setting to override the default `goo` patch + // rules. + GooSettings goo = 5; + + // Zypper update settings. Use this setting to override the default `zypper` + // patch rules. + ZypperSettings zypper = 6; + + // Windows update settings. Use this override the default windows patch rules. + WindowsUpdateSettings windows_update = 7; + + // The `ExecStep` to run before the patch update. + ExecStep pre_step = 8; + + // The `ExecStep` to run after the patch update. + ExecStep post_step = 9; + + // Allows the patch job to run on Managed instance groups (MIGs). + bool mig_instances_allowed = 10; +} + +// Namespace for instance state enums. +message Instance { + // Patch state of an instance. + enum PatchState { + // Unspecified. + PATCH_STATE_UNSPECIFIED = 0; + + // The instance is not yet notified. + PENDING = 1; + + // Instance is inactive and cannot be patched. + INACTIVE = 2; + + // The instance is notified that it should be patched. + NOTIFIED = 3; + + // The instance has started the patching process. + STARTED = 4; + + // The instance is downloading patches. + DOWNLOADING_PATCHES = 5; + + // The instance is applying patches. + APPLYING_PATCHES = 6; + + // The instance is rebooting. + REBOOTING = 7; + + // The instance has completed applying patches. + SUCCEEDED = 8; + + // The instance has completed applying patches but a reboot is required. + SUCCEEDED_REBOOT_REQUIRED = 9; + + // The instance has failed to apply the patch. + FAILED = 10; + + // The instance acked the notification and will start shortly. + ACKED = 11; + + // The instance exceeded the time out while applying the patch. + TIMED_OUT = 12; + + // The instance is running the pre-patch step. + RUNNING_PRE_PATCH_STEP = 13; + + // The instance is running the post-patch step. + RUNNING_POST_PATCH_STEP = 14; + + // The service could not detect the presence of the agent. Check to ensure + // that the agent is installed, running, and able to communicate with the + // service. + NO_AGENT_DETECTED = 15; + } +} + +// Message for canceling a patch job. +message CancelPatchJobRequest { + // Required. Name of the patch in the form `projects/*/patchJobs/*` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/PatchJob" + } + ]; +} + +// Apt patching is completed by executing `apt-get update && apt-get +// upgrade`. Additional options can be set to control how this is executed. +message AptSettings { + // Apt patch type. + enum Type { + // By default, upgrade will be performed. + TYPE_UNSPECIFIED = 0; + + // Runs `apt-get dist-upgrade`. + DIST = 1; + + // Runs `apt-get upgrade`. + UPGRADE = 2; + } + + // By changing the type to DIST, the patching is performed + // using `apt-get dist-upgrade` instead. + Type type = 1; + + // List of packages to exclude from update. These packages will be excluded + repeated string excludes = 2; + + // An exclusive list of packages to be updated. These are the only packages + // that will be updated. If these packages are not installed, they will be + // ignored. This field cannot be specified with any other patch configuration + // fields. + repeated string exclusive_packages = 3; +} + +// Yum patching is performed by executing `yum update`. Additional options +// can be set to control how this is executed. +// +// Note that not all settings are supported on all platforms. +message YumSettings { + // Adds the `--security` flag to `yum update`. Not supported on + // all platforms. + bool security = 1; + + // Will cause patch to run `yum update-minimal` instead. + bool minimal = 2; + + // List of packages to exclude from update. These packages are excluded by + // using the yum `--exclude` flag. + repeated string excludes = 3; + + // An exclusive list of packages to be updated. These are the only packages + // that will be updated. If these packages are not installed, they will be + // ignored. This field must not be specified with any other patch + // configuration fields. + repeated string exclusive_packages = 4; +} + +// Googet patching is performed by running `googet update`. +message GooSettings {} + +// Zypper patching is performed by running `zypper patch`. +// See also https://en.opensuse.org/SDB:Zypper_manual. +message ZypperSettings { + // Adds the `--with-optional` flag to `zypper patch`. + bool with_optional = 1; + + // Adds the `--with-update` flag, to `zypper patch`. + bool with_update = 2; + + // Install only patches with these categories. + // Common categories include security, recommended, and feature. + repeated string categories = 3; + + // Install only patches with these severities. + // Common severities include critical, important, moderate, and low. + repeated string severities = 4; + + // List of patches to exclude from update. + repeated string excludes = 5; + + // An exclusive list of patches to be updated. These are the only patches + // that will be installed using 'zypper patch patch:' command. + // This field must not be used with any other patch configuration fields. + repeated string exclusive_patches = 6; +} + +// Windows patching is performed using the Windows Update Agent. +message WindowsUpdateSettings { + // Microsoft Windows update classifications as defined in + // [1] + // https://support.microsoft.com/en-us/help/824684/description-of-the-standard-terminology-that-is-used-to-describe-micro + enum Classification { + // Invalid. If classifications are included, they must be specified. + CLASSIFICATION_UNSPECIFIED = 0; + + // "A widely released fix for a specific problem that addresses a critical, + // non-security-related bug." [1] + CRITICAL = 1; + + // "A widely released fix for a product-specific, security-related + // vulnerability. Security vulnerabilities are rated by their severity. The + // severity rating is indicated in the Microsoft security bulletin as + // critical, important, moderate, or low." [1] + SECURITY = 2; + + // "A widely released and frequent software update that contains additions + // to a product's definition database. Definition databases are often used + // to detect objects that have specific attributes, such as malicious code, + // phishing websites, or junk mail." [1] + DEFINITION = 3; + + // "Software that controls the input and output of a device." [1] + DRIVER = 4; + + // "New product functionality that is first distributed outside the context + // of a product release and that is typically included in the next full + // product release." [1] + FEATURE_PACK = 5; + + // "A tested, cumulative set of all hotfixes, security updates, critical + // updates, and updates. Additionally, service packs may contain additional + // fixes for problems that are found internally since the release of the + // product. Service packs my also contain a limited number of + // customer-requested design changes or features." [1] + SERVICE_PACK = 6; + + // "A utility or feature that helps complete a task or set of tasks." [1] + TOOL = 7; + + // "A tested, cumulative set of hotfixes, security updates, critical + // updates, and updates that are packaged together for easy deployment. A + // rollup generally targets a specific area, such as security, or a + // component of a product, such as Internet Information Services (IIS)." [1] + UPDATE_ROLLUP = 8; + + // "A widely released fix for a specific problem. An update addresses a + // noncritical, non-security-related bug." [1] + UPDATE = 9; + } + + // Only apply updates of these windows update classifications. If empty, all + // updates are applied. + repeated Classification classifications = 1; + + // List of KBs to exclude from update. + repeated string excludes = 2; + + // An exclusive list of kbs to be updated. These are the only patches + // that will be updated. This field must not be used with other + // patch configurations. + repeated string exclusive_patches = 3; +} + +// A step that runs an executable for a PatchJob. +message ExecStep { + // The ExecStepConfig for all Linux VMs targeted by the PatchJob. + ExecStepConfig linux_exec_step_config = 1; + + // The ExecStepConfig for all Windows VMs targeted by the PatchJob. + ExecStepConfig windows_exec_step_config = 2; +} + +// Common configurations for an ExecStep. +message ExecStepConfig { + // The interpreter used to execute the a file. + enum Interpreter { + // Invalid for a Windows ExecStepConfig. For a Linux ExecStepConfig, the + // interpreter will be parsed from the shebang line of the script if + // unspecified. + INTERPRETER_UNSPECIFIED = 0; + + // Indicates that the script is run with `/bin/sh` on Linux and `cmd` + // on Windows. + SHELL = 1; + + // Indicates that the file is run with PowerShell flags + // `-NonInteractive`, `-NoProfile`, and `-ExecutionPolicy Bypass`. + POWERSHELL = 2; + } + + // Location of the executable. + oneof executable { + // An absolute path to the executable on the VM. + string local_path = 1; + + // A Cloud Storage object containing the executable. + GcsObject gcs_object = 2; + } + + // Defaults to [0]. A list of possible return values that the + // execution can return to indicate a success. + repeated int32 allowed_success_codes = 3; + + // The script interpreter to use to run the script. If no interpreter is + // specified the script will be executed directly, which will likely + // only succeed for scripts with [shebang lines] + // (https://en.wikipedia.org/wiki/Shebang_\(Unix\)). + Interpreter interpreter = 4; +} + +// Cloud Storage object representation. +message GcsObject { + // Required. Bucket of the Cloud Storage object. + string bucket = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Name of the Cloud Storage object. + string object = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. Generation number of the Cloud Storage object. This is used to + // ensure that the ExecStep specified by this PatchJob does not change. + int64 generation_number = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// A filter to target VM instances for patching. The targeted +// VMs must meet all criteria specified. So if both labels and zones are +// specified, the patch job targets only VMs with those labels and in those +// zones. +message PatchInstanceFilter { + // Targets a group of VM instances by using their [assigned + // labels](https://cloud.google.com/compute/docs/labeling-resources). Labels + // are key-value pairs. A `GroupLabel` is a combination of labels + // that is used to target VMs for a patch job. + // + // For example, a patch job can target VMs that have the following + // `GroupLabel`: `{"env":"test", "app":"web"}`. This means that the patch job + // is applied to VMs that have both the labels `env=test` and `app=web`. + message GroupLabel { + // Compute Engine instance labels that must be present for a VM + // instance to be targeted by this filter. + map labels = 1; + } + + // Target all VM instances in the project. If true, no other criteria is + // permitted. + bool all = 1; + + // Targets VM instances matching ANY of these GroupLabels. This allows + // targeting of disparate groups of VM instances. + repeated GroupLabel group_labels = 2; + + // Targets VM instances in ANY of these zones. Leave empty to target VM + // instances in any zone. + repeated string zones = 3; + + // Targets any of the VM instances specified. Instances are specified by their + // URI in the form `zones/[ZONE]/instances/[INSTANCE_NAME]`, + // `projects/[PROJECT_ID]/zones/[ZONE]/instances/[INSTANCE_NAME]`, or + // `https://www.googleapis.com/compute/v1/projects/[PROJECT_ID]/zones/[ZONE]/instances/[INSTANCE_NAME]` + repeated string instances = 4; + + // Targets VMs whose name starts with one of these prefixes. Similar to + // labels, this is another way to group VMs when targeting configs, for + // example prefix="prod-". + repeated string instance_name_prefixes = 5; +} + +// Patch rollout configuration specifications. Contains details on the +// concurrency control when applying patch(es) to all targeted VMs. +message PatchRollout { + // Type of the rollout. + enum Mode { + // Mode must be specified. + MODE_UNSPECIFIED = 0; + + // Patches are applied one zone at a time. The patch job begins in the + // region with the lowest number of targeted VMs. Within the region, + // patching begins in the zone with the lowest number of targeted VMs. If + // multiple regions (or zones within a region) have the same number of + // targeted VMs, a tie-breaker is achieved by sorting the regions or zones + // in alphabetical order. + ZONE_BY_ZONE = 1; + + // Patches are applied to VMs in all zones at the same time. + CONCURRENT_ZONES = 2; + } + + // Mode of the patch rollout. + Mode mode = 1; + + // The maximum number (or percentage) of VMs per zone to disrupt at any given + // moment. The number of VMs calculated from multiplying the percentage by the + // total number of VMs in a zone is rounded up. + // + // During patching, a VM is considered disrupted from the time the agent is + // notified to begin until patching has completed. This disruption time + // includes the time to complete reboot and any post-patch steps. + // + // A VM contributes to the disruption budget if its patching operation fails + // either when applying the patches, running pre or post patch steps, or if it + // fails to respond with a success notification before timing out. VMs that + // are not running or do not have an active agent do not count toward this + // disruption budget. + // + // For zone-by-zone rollouts, if the disruption budget in a zone is exceeded, + // the patch job stops, because continuing to the next zone requires + // completion of the patch process in the previous zone. + // + // For example, if the disruption budget has a fixed value of `10`, and 8 VMs + // fail to patch in the current zone, the patch job continues to patch 2 VMs + // at a time until the zone is completed. When that zone is completed + // successfully, patching begins with 10 VMs at a time in the next zone. If 10 + // VMs in the next zone fail to patch, the patch job stops. + FixedOrPercent disruption_budget = 2; +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/vulnerability.proto b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/vulnerability.proto new file mode 100644 index 00000000000..b758df3bad0 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/vulnerability.proto @@ -0,0 +1,365 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.OsConfig.V1"; +option go_package = "cloud.google.com/go/osconfig/apiv1/osconfigpb;osconfigpb"; +option java_multiple_files = true; +option java_outer_classname = "VulnerabilityProto"; +option java_package = "com.google.cloud.osconfig.v1"; +option php_namespace = "Google\\Cloud\\OsConfig\\V1"; +option ruby_package = "Google::Cloud::OsConfig::V1"; + +// This API resource represents the vulnerability report for a specified +// Compute Engine virtual machine (VM) instance at a given point in time. +// +// For more information, see [Vulnerability +// reports](https://cloud.google.com/compute/docs/instances/os-inventory-management#vulnerability-reports). +message VulnerabilityReport { + option (google.api.resource) = { + type: "osconfig.googleapis.com/VulnerabilityReport" + pattern: "projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport" + }; + + // A vulnerability affecting the VM instance. + message Vulnerability { + // Contains metadata information for the vulnerability. This information is + // collected from the upstream feed of the operating system. + message Details { + // A reference for this vulnerability. + message Reference { + // The url of the reference. + string url = 1; + + // The source of the reference e.g. NVD. + string source = 2; + } + + // The CVE of the vulnerability. CVE cannot be + // empty and the combination of should be unique + // across vulnerabilities for a VM. + string cve = 1; + + // The CVSS V2 score of this vulnerability. CVSS V2 score is on a scale of + // 0 - 10 where 0 indicates low severity and 10 indicates high severity. + float cvss_v2_score = 2; + + // The full description of the CVSSv3 for this vulnerability from NVD. + CVSSv3 cvss_v3 = 3; + + // Assigned severity/impact ranking from the distro. + string severity = 4; + + // The note or description describing the vulnerability from the distro. + string description = 5; + + // Corresponds to the references attached to the `VulnerabilityDetails`. + repeated Reference references = 6; + } + + // OS inventory item that is affected by a vulnerability or fixed as a + // result of a vulnerability. + message Item { + // Corresponds to the `INSTALLED_PACKAGE` inventory item on the VM. + // This field displays the inventory items affected by this vulnerability. + // If the vulnerability report was not updated after the VM inventory + // update, these values might not display in VM inventory. For some + // operating systems, this field might be empty. + string installed_inventory_item_id = 1; + + // Corresponds to the `AVAILABLE_PACKAGE` inventory item on the VM. + // If the vulnerability report was not updated after the VM inventory + // update, these values might not display in VM inventory. If there is no + // available fix, the field is empty. The `inventory_item` value specifies + // the latest `SoftwarePackage` available to the VM that fixes the + // vulnerability. + string available_inventory_item_id = 2; + + // The recommended [CPE URI](https://cpe.mitre.org/specification/) update + // that contains a fix for this vulnerability. + string fixed_cpe_uri = 3; + + // The upstream OS patch, packages or KB that fixes the vulnerability. + string upstream_fix = 4; + } + + // Contains metadata as per the upstream feed of the operating system and + // NVD. + Details details = 1; + + // Corresponds to the `INSTALLED_PACKAGE` inventory item on the VM. + // This field displays the inventory items affected by this vulnerability. + // If the vulnerability report was not updated after the VM inventory + // update, these values might not display in VM inventory. For some distros, + // this field may be empty. + repeated string installed_inventory_item_ids = 2 [deprecated = true]; + + // Corresponds to the `AVAILABLE_PACKAGE` inventory item on the VM. + // If the vulnerability report was not updated after the VM inventory + // update, these values might not display in VM inventory. If there is no + // available fix, the field is empty. The `inventory_item` value specifies + // the latest `SoftwarePackage` available to the VM that fixes the + // vulnerability. + repeated string available_inventory_item_ids = 3 [deprecated = true]; + + // The timestamp for when the vulnerability was first detected. + google.protobuf.Timestamp create_time = 4; + + // The timestamp for when the vulnerability was last modified. + google.protobuf.Timestamp update_time = 5; + + // List of items affected by the vulnerability. + repeated Item items = 6; + } + + // Output only. The `vulnerabilityReport` API resource name. + // + // Format: + // `projects/{project_number}/locations/{location}/instances/{instance_id}/vulnerabilityReport` + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. List of vulnerabilities affecting the VM. + repeated Vulnerability vulnerabilities = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp for when the last vulnerability report was generated for the + // VM. + google.protobuf.Timestamp update_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A request message for getting the vulnerability report for the specified VM. +message GetVulnerabilityReportRequest { + // Required. API resource name for vulnerability resource. + // + // Format: + // `projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport` + // + // For `{project}`, either `project-number` or `project-id` can be provided. + // For `{instance}`, either Compute Engine `instance-id` or `instance-name` + // can be provided. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/VulnerabilityReport" + } + ]; +} + +// A request message for listing vulnerability reports for all VM instances in +// the specified location. +message ListVulnerabilityReportsRequest { + // Required. The parent resource name. + // + // Format: `projects/{project}/locations/{location}/instances/-` + // + // For `{project}`, either `project-number` or `project-id` can be provided. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "compute.googleapis.com/Instance" + } + ]; + + // The maximum number of results to return. + int32 page_size = 2; + + // A pagination token returned from a previous call to + // `ListVulnerabilityReports` that indicates where this listing + // should continue from. + string page_token = 3; + + // If provided, this field specifies the criteria that must be met by a + // `vulnerabilityReport` API resource to be included in the response. + string filter = 4; +} + +// A response message for listing vulnerability reports for all VM instances in +// the specified location. +message ListVulnerabilityReportsResponse { + // List of vulnerabilityReport objects. + repeated VulnerabilityReport vulnerability_reports = 1; + + // The pagination token to retrieve the next page of vulnerabilityReports + // object. + string next_page_token = 2; +} + +// Common Vulnerability Scoring System version 3. +// For details, see https://www.first.org/cvss/specification-document +message CVSSv3 { + // This metric reflects the context by which vulnerability exploitation is + // possible. + enum AttackVector { + // Invalid value. + ATTACK_VECTOR_UNSPECIFIED = 0; + + // The vulnerable component is bound to the network stack and the set of + // possible attackers extends beyond the other options listed below, up to + // and including the entire Internet. + ATTACK_VECTOR_NETWORK = 1; + + // The vulnerable component is bound to the network stack, but the attack is + // limited at the protocol level to a logically adjacent topology. + ATTACK_VECTOR_ADJACENT = 2; + + // The vulnerable component is not bound to the network stack and the + // attacker's path is via read/write/execute capabilities. + ATTACK_VECTOR_LOCAL = 3; + + // The attack requires the attacker to physically touch or manipulate the + // vulnerable component. + ATTACK_VECTOR_PHYSICAL = 4; + } + + // This metric describes the conditions beyond the attacker's control that + // must exist in order to exploit the vulnerability. + enum AttackComplexity { + // Invalid value. + ATTACK_COMPLEXITY_UNSPECIFIED = 0; + + // Specialized access conditions or extenuating circumstances do not exist. + // An attacker can expect repeatable success when attacking the vulnerable + // component. + ATTACK_COMPLEXITY_LOW = 1; + + // A successful attack depends on conditions beyond the attacker's control. + // That is, a successful attack cannot be accomplished at will, but requires + // the attacker to invest in some measurable amount of effort in preparation + // or execution against the vulnerable component before a successful attack + // can be expected. + ATTACK_COMPLEXITY_HIGH = 2; + } + + // This metric describes the level of privileges an attacker must possess + // before successfully exploiting the vulnerability. + enum PrivilegesRequired { + // Invalid value. + PRIVILEGES_REQUIRED_UNSPECIFIED = 0; + + // The attacker is unauthorized prior to attack, and therefore does not + // require any access to settings or files of the vulnerable system to + // carry out an attack. + PRIVILEGES_REQUIRED_NONE = 1; + + // The attacker requires privileges that provide basic user capabilities + // that could normally affect only settings and files owned by a user. + // Alternatively, an attacker with Low privileges has the ability to access + // only non-sensitive resources. + PRIVILEGES_REQUIRED_LOW = 2; + + // The attacker requires privileges that provide significant (e.g., + // administrative) control over the vulnerable component allowing access to + // component-wide settings and files. + PRIVILEGES_REQUIRED_HIGH = 3; + } + + // This metric captures the requirement for a human user, other than the + // attacker, to participate in the successful compromise of the vulnerable + // component. + enum UserInteraction { + // Invalid value. + USER_INTERACTION_UNSPECIFIED = 0; + + // The vulnerable system can be exploited without interaction from any user. + USER_INTERACTION_NONE = 1; + + // Successful exploitation of this vulnerability requires a user to take + // some action before the vulnerability can be exploited. + USER_INTERACTION_REQUIRED = 2; + } + + // The Scope metric captures whether a vulnerability in one vulnerable + // component impacts resources in components beyond its security scope. + enum Scope { + // Invalid value. + SCOPE_UNSPECIFIED = 0; + + // An exploited vulnerability can only affect resources managed by the same + // security authority. + SCOPE_UNCHANGED = 1; + + // An exploited vulnerability can affect resources beyond the security scope + // managed by the security authority of the vulnerable component. + SCOPE_CHANGED = 2; + } + + // The Impact metrics capture the effects of a successfully exploited + // vulnerability on the component that suffers the worst outcome that is most + // directly and predictably associated with the attack. + enum Impact { + // Invalid value. + IMPACT_UNSPECIFIED = 0; + + // High impact. + IMPACT_HIGH = 1; + + // Low impact. + IMPACT_LOW = 2; + + // No impact. + IMPACT_NONE = 3; + } + + // The base score is a function of the base metric scores. + // https://www.first.org/cvss/specification-document#Base-Metrics + float base_score = 1; + + // The Exploitability sub-score equation is derived from the Base + // Exploitability metrics. + // https://www.first.org/cvss/specification-document#2-1-Exploitability-Metrics + float exploitability_score = 2; + + // The Impact sub-score equation is derived from the Base Impact metrics. + float impact_score = 3; + + // This metric reflects the context by which vulnerability exploitation is + // possible. + AttackVector attack_vector = 5; + + // This metric describes the conditions beyond the attacker's control that + // must exist in order to exploit the vulnerability. + AttackComplexity attack_complexity = 6; + + // This metric describes the level of privileges an attacker must possess + // before successfully exploiting the vulnerability. + PrivilegesRequired privileges_required = 7; + + // This metric captures the requirement for a human user, other than the + // attacker, to participate in the successful compromise of the vulnerable + // component. + UserInteraction user_interaction = 8; + + // The Scope metric captures whether a vulnerability in one vulnerable + // component impacts resources in components beyond its security scope. + Scope scope = 9; + + // This metric measures the impact to the confidentiality of the information + // resources managed by a software component due to a successfully exploited + // vulnerability. + Impact confidentiality_impact = 10; + + // This metric measures the impact to integrity of a successfully exploited + // vulnerability. + Impact integrity_impact = 11; + + // This metric measures the impact to the availability of the impacted + // component resulting from a successfully exploited vulnerability. + Impact availability_impact = 12; +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.cancel_patch_job.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.cancel_patch_job.js new file mode 100644 index 00000000000..b9d729c0c60 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.cancel_patch_job.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(name) { + // [START osconfig_v1_generated_OsConfigService_CancelPatchJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the patch in the form `projects/* /patchJobs/*` + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callCancelPatchJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.cancelPatchJob(request); + console.log(response); + } + + callCancelPatchJob(); + // [END osconfig_v1_generated_OsConfigService_CancelPatchJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.create_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.create_patch_deployment.js new file mode 100644 index 00000000000..7fcba165f80 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.create_patch_deployment.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(parent, patchDeploymentId, patchDeployment) { + // [START osconfig_v1_generated_OsConfigService_CreatePatchDeployment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project to apply this patch deployment to in the form + * `projects/*`. + */ + // const parent = 'abc123' + /** + * Required. A name for the patch deployment in the project. When creating a + * name the following rules apply: + * * Must contain only lowercase letters, numbers, and hyphens. + * * Must start with a letter. + * * Must be between 1-63 characters. + * * Must end with a number or a letter. + * * Must be unique within the project. + */ + // const patchDeploymentId = 'abc123' + /** + * Required. The patch deployment to create. + */ + // const patchDeployment = {} + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callCreatePatchDeployment() { + // Construct request + const request = { + parent, + patchDeploymentId, + patchDeployment, + }; + + // Run request + const response = await osconfigClient.createPatchDeployment(request); + console.log(response); + } + + callCreatePatchDeployment(); + // [END osconfig_v1_generated_OsConfigService_CreatePatchDeployment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.delete_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.delete_patch_deployment.js new file mode 100644 index 00000000000..537f6e48d7c --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.delete_patch_deployment.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 osconfig_v1_generated_OsConfigService_DeletePatchDeployment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 patch deployment in the form + * `projects/* /patchDeployments/*`. + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callDeletePatchDeployment() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.deletePatchDeployment(request); + console.log(response); + } + + callDeletePatchDeployment(); + // [END osconfig_v1_generated_OsConfigService_DeletePatchDeployment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.execute_patch_job.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.execute_patch_job.js new file mode 100644 index 00000000000..2a8842423d3 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.execute_patch_job.js @@ -0,0 +1,95 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, instanceFilter) { + // [START osconfig_v1_generated_OsConfigService_ExecutePatchJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project in which to run this patch in the form `projects/*` + */ + // const parent = 'abc123' + /** + * Description of the patch job. Length of the description is limited + * to 1024 characters. + */ + // const description = 'abc123' + /** + * Required. Instances to patch, either explicitly or filtered by some + * criteria such as zone or labels. + */ + // const instanceFilter = {} + /** + * Patch configuration being applied. If omitted, instances are + * patched using the default configurations. + */ + // const patchConfig = {} + /** + * Duration of the patch job. After the duration ends, the patch job + * times out. + */ + // const duration = {} + /** + * If this patch is a dry-run only, instances are contacted but + * will do nothing. + */ + // const dryRun = true + /** + * Display name for this patch job. This does not have to be unique. + */ + // const displayName = 'abc123' + /** + * Rollout strategy of the patch job. + */ + // const rollout = {} + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callExecutePatchJob() { + // Construct request + const request = { + parent, + instanceFilter, + }; + + // Run request + const response = await osconfigClient.executePatchJob(request); + console.log(response); + } + + callExecutePatchJob(); + // [END osconfig_v1_generated_OsConfigService_ExecutePatchJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.get_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.get_patch_deployment.js new file mode 100644 index 00000000000..15ed3690f68 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.get_patch_deployment.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 osconfig_v1_generated_OsConfigService_GetPatchDeployment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 patch deployment in the form + * `projects/* /patchDeployments/*`. + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callGetPatchDeployment() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.getPatchDeployment(request); + console.log(response); + } + + callGetPatchDeployment(); + // [END osconfig_v1_generated_OsConfigService_GetPatchDeployment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.get_patch_job.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.get_patch_job.js new file mode 100644 index 00000000000..84e912df0f3 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.get_patch_job.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(name) { + // [START osconfig_v1_generated_OsConfigService_GetPatchJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the patch in the form `projects/* /patchJobs/*` + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callGetPatchJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.getPatchJob(request); + console.log(response); + } + + callGetPatchJob(); + // [END osconfig_v1_generated_OsConfigService_GetPatchJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_deployments.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_deployments.js new file mode 100644 index 00000000000..a989ab56e49 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_deployments.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) { + // [START osconfig_v1_generated_OsConfigService_ListPatchDeployments_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 parent in the form `projects/*`. + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of patch deployments to return. Default is + * 100. + */ + // const pageSize = 1234 + /** + * Optional. A pagination token returned from a previous call to + * ListPatchDeployments that indicates where this listing should continue + * from. + */ + // const pageToken = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callListPatchDeployments() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await osconfigClient.listPatchDeploymentsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListPatchDeployments(); + // [END osconfig_v1_generated_OsConfigService_ListPatchDeployments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_job_instance_details.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_job_instance_details.js new file mode 100644 index 00000000000..a4917b249e2 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_job_instance_details.js @@ -0,0 +1,79 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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 osconfig_v1_generated_OsConfigService_ListPatchJobInstanceDetails_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 the instances are in the form of + * `projects/* /patchJobs/*`. + */ + // const parent = 'abc123' + /** + * The maximum number of instance details records to return. Default is 100. + */ + // const pageSize = 1234 + /** + * A pagination token returned from a previous call + * that indicates where this listing should continue from. + */ + // const pageToken = 'abc123' + /** + * A filter expression that filters results listed in the response. This + * field supports filtering results by instance zone, name, state, or + * `failure_reason`. + */ + // const filter = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callListPatchJobInstanceDetails() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await osconfigClient.listPatchJobInstanceDetailsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListPatchJobInstanceDetails(); + // [END osconfig_v1_generated_OsConfigService_ListPatchJobInstanceDetails_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_jobs.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_jobs.js new file mode 100644 index 00000000000..58b11f4f54e --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_jobs.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(parent) { + // [START osconfig_v1_generated_OsConfigService_ListPatchJobs_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. In the form of `projects/*` + */ + // const parent = 'abc123' + /** + * The maximum number of instance status to return. + */ + // const pageSize = 1234 + /** + * A pagination token returned from a previous call + * that indicates where this listing should continue from. + */ + // const pageToken = 'abc123' + /** + * If provided, this field specifies the criteria that must be met by patch + * jobs to be included in the response. + * Currently, filtering is only available on the patch_deployment field. + */ + // const filter = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callListPatchJobs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await osconfigClient.listPatchJobsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListPatchJobs(); + // [END osconfig_v1_generated_OsConfigService_ListPatchJobs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.pause_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.pause_patch_deployment.js new file mode 100644 index 00000000000..a88e66cc65b --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.pause_patch_deployment.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 osconfig_v1_generated_OsConfigService_PausePatchDeployment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 patch deployment in the form + * `projects/* /patchDeployments/*`. + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callPausePatchDeployment() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.pausePatchDeployment(request); + console.log(response); + } + + callPausePatchDeployment(); + // [END osconfig_v1_generated_OsConfigService_PausePatchDeployment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.resume_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.resume_patch_deployment.js new file mode 100644 index 00000000000..83c2f051d49 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.resume_patch_deployment.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 osconfig_v1_generated_OsConfigService_ResumePatchDeployment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 patch deployment in the form + * `projects/* /patchDeployments/*`. + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callResumePatchDeployment() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.resumePatchDeployment(request); + console.log(response); + } + + callResumePatchDeployment(); + // [END osconfig_v1_generated_OsConfigService_ResumePatchDeployment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.update_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.update_patch_deployment.js new file mode 100644 index 00000000000..e32fa998d9c --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.update_patch_deployment.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(patchDeployment) { + // [START osconfig_v1_generated_OsConfigService_UpdatePatchDeployment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The patch deployment to Update. + */ + // const patchDeployment = {} + /** + * Optional. Field mask that controls which fields of the patch deployment + * should be updated. + */ + // const updateMask = {} + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callUpdatePatchDeployment() { + // Construct request + const request = { + patchDeployment, + }; + + // Run request + const response = await osconfigClient.updatePatchDeployment(request); + console.log(response); + } + + callUpdatePatchDeployment(); + // [END osconfig_v1_generated_OsConfigService_UpdatePatchDeployment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.create_o_s_policy_assignment.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.create_o_s_policy_assignment.js new file mode 100644 index 00000000000..3c3df85f187 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.create_o_s_policy_assignment.js @@ -0,0 +1,79 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, osPolicyAssignment, osPolicyAssignmentId) { + // [START osconfig_v1_generated_OsConfigZonalService_CreateOSPolicyAssignment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 name in the form: + * projects/{project}/locations/{location} + */ + // const parent = 'abc123' + /** + * Required. The OS policy assignment to be created. + */ + // const osPolicyAssignment = {} + /** + * Required. The logical name of the OS policy assignment in the project + * with the following restrictions: + * * Must contain only lowercase letters, numbers, and hyphens. + * * Must start with a letter. + * * Must be between 1-63 characters. + * * Must end with a number or a letter. + * * Must be unique within the project. + */ + // const osPolicyAssignmentId = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callCreateOSPolicyAssignment() { + // Construct request + const request = { + parent, + osPolicyAssignment, + osPolicyAssignmentId, + }; + + // Run request + const [operation] = await osconfigClient.createOSPolicyAssignment(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateOSPolicyAssignment(); + // [END osconfig_v1_generated_OsConfigZonalService_CreateOSPolicyAssignment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.delete_o_s_policy_assignment.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.delete_o_s_policy_assignment.js new file mode 100644 index 00000000000..76c61ae929c --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.delete_o_s_policy_assignment.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 osconfig_v1_generated_OsConfigZonalService_DeleteOSPolicyAssignment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 OS policy assignment to be deleted + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callDeleteOSPolicyAssignment() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await osconfigClient.deleteOSPolicyAssignment(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteOSPolicyAssignment(); + // [END osconfig_v1_generated_OsConfigZonalService_DeleteOSPolicyAssignment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_inventory.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_inventory.js new file mode 100644 index 00000000000..328ffd61766 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_inventory.js @@ -0,0 +1,71 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START osconfig_v1_generated_OsConfigZonalService_GetInventory_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. API resource name for inventory resource. + * Format: + * `projects/{project}/locations/{location}/instances/{instance}/inventory` + * For `{project}`, either `project-number` or `project-id` can be provided. + * For `{instance}`, either Compute Engine `instance-id` or `instance-name` + * can be provided. + */ + // const name = 'abc123' + /** + * Inventory view indicating what information should be included in the + * inventory resource. If unspecified, the default view is BASIC. + */ + // const view = {} + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callGetInventory() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.getInventory(request); + console.log(response); + } + + callGetInventory(); + // [END osconfig_v1_generated_OsConfigZonalService_GetInventory_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_o_s_policy_assignment.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_o_s_policy_assignment.js new file mode 100644 index 00000000000..8e63c0b595f --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_o_s_policy_assignment.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 osconfig_v1_generated_OsConfigZonalService_GetOSPolicyAssignment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 OS policy assignment. + * Format: + * `projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}@{revisionId}` + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callGetOSPolicyAssignment() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.getOSPolicyAssignment(request); + console.log(response); + } + + callGetOSPolicyAssignment(); + // [END osconfig_v1_generated_OsConfigZonalService_GetOSPolicyAssignment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_o_s_policy_assignment_report.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_o_s_policy_assignment_report.js new file mode 100644 index 00000000000..40a48f03380 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_o_s_policy_assignment_report.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(name) { + // [START osconfig_v1_generated_OsConfigZonalService_GetOSPolicyAssignmentReport_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. API resource name for OS policy assignment report. + * Format: + * `/projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report` + * For `{project}`, either `project-number` or `project-id` can be provided. + * For `{instance_id}`, either Compute Engine `instance-id` or `instance-name` + * can be provided. + * For `{assignment_id}`, the OSPolicyAssignment id must be provided. + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callGetOSPolicyAssignmentReport() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.getOSPolicyAssignmentReport(request); + console.log(response); + } + + callGetOSPolicyAssignmentReport(); + // [END osconfig_v1_generated_OsConfigZonalService_GetOSPolicyAssignmentReport_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_vulnerability_report.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_vulnerability_report.js new file mode 100644 index 00000000000..c66f01a4e4a --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_vulnerability_report.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(name) { + // [START osconfig_v1_generated_OsConfigZonalService_GetVulnerabilityReport_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. API resource name for vulnerability resource. + * Format: + * `projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport` + * For `{project}`, either `project-number` or `project-id` can be provided. + * For `{instance}`, either Compute Engine `instance-id` or `instance-name` + * can be provided. + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callGetVulnerabilityReport() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.getVulnerabilityReport(request); + console.log(response); + } + + callGetVulnerabilityReport(); + // [END osconfig_v1_generated_OsConfigZonalService_GetVulnerabilityReport_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_inventories.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_inventories.js new file mode 100644 index 00000000000..06e9b90425e --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_inventories.js @@ -0,0 +1,85 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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 osconfig_v1_generated_OsConfigZonalService_ListInventories_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 name. + * Format: `projects/{project}/locations/{location}/instances/-` + * For `{project}`, either `project-number` or `project-id` can be provided. + */ + // const parent = 'abc123' + /** + * Inventory view indicating what information should be included in the + * inventory resource. If unspecified, the default view is BASIC. + */ + // const view = {} + /** + * The maximum number of results to return. + */ + // const pageSize = 1234 + /** + * A pagination token returned from a previous call to + * `ListInventories` that indicates where this listing + * should continue from. + */ + // const pageToken = 'abc123' + /** + * If provided, this field specifies the criteria that must be met by a + * `Inventory` API resource to be included in the response. + */ + // const filter = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callListInventories() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await osconfigClient.listInventoriesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListInventories(); + // [END osconfig_v1_generated_OsConfigZonalService_ListInventories_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignment_reports.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignment_reports.js new file mode 100644 index 00000000000..e144aa4e272 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignment_reports.js @@ -0,0 +1,95 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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 osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignmentReports_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 name. + * Format: + * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/reports` + * For `{project}`, either `project-number` or `project-id` can be provided. + * For `{instance}`, either `instance-name`, `instance-id`, or `-` can be + * provided. If '-' is provided, the response will include + * OSPolicyAssignmentReports for all instances in the project/location. + * For `{assignment}`, either `assignment-id` or `-` can be provided. If '-' + * is provided, the response will include OSPolicyAssignmentReports for all + * OSPolicyAssignments in the project/location. + * Either {instance} or {assignment} must be `-`. + * For example: + * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/-/reports` + * returns all reports for the instance + * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/{assignment-id}/reports` + * returns all the reports for the given assignment across all instances. + * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/-/reports` + * returns all the reports for all assignments across all instances. + */ + // const parent = 'abc123' + /** + * The maximum number of results to return. + */ + // const pageSize = 1234 + /** + * If provided, this field specifies the criteria that must be met by the + * `OSPolicyAssignmentReport` API resource that is included in the response. + */ + // const filter = 'abc123' + /** + * A pagination token returned from a previous call to the + * `ListOSPolicyAssignmentReports` method that indicates where this listing + * should continue from. + */ + // const pageToken = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callListOSPolicyAssignmentReports() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await osconfigClient.listOSPolicyAssignmentReportsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListOSPolicyAssignmentReports(); + // [END osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignmentReports_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignment_revisions.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignment_revisions.js new file mode 100644 index 00000000000..a09e5e812ed --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignment_revisions.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(name) { + // [START osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignmentRevisions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 OS policy assignment to list revisions for. + */ + // const name = 'abc123' + /** + * The maximum number of revisions to return. + */ + // const pageSize = 1234 + /** + * A pagination token returned from a previous call to + * `ListOSPolicyAssignmentRevisions` that indicates where this listing should + * continue from. + */ + // const pageToken = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callListOSPolicyAssignmentRevisions() { + // Construct request + const request = { + name, + }; + + // Run request + const iterable = await osconfigClient.listOSPolicyAssignmentRevisionsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListOSPolicyAssignmentRevisions(); + // [END osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignmentRevisions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignments.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignments.js new file mode 100644 index 00000000000..7e18fc2ba10 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignments.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(parent) { + // [START osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignments_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 name. + */ + // const parent = 'abc123' + /** + * The maximum number of assignments to return. + */ + // const pageSize = 1234 + /** + * A pagination token returned from a previous call to + * `ListOSPolicyAssignments` that indicates where this listing should continue + * from. + */ + // const pageToken = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callListOSPolicyAssignments() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await osconfigClient.listOSPolicyAssignmentsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListOSPolicyAssignments(); + // [END osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_vulnerability_reports.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_vulnerability_reports.js new file mode 100644 index 00000000000..869997ad2d3 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_vulnerability_reports.js @@ -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. ** + + + +'use strict'; + +function main(parent) { + // [START osconfig_v1_generated_OsConfigZonalService_ListVulnerabilityReports_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 name. + * Format: `projects/{project}/locations/{location}/instances/-` + * For `{project}`, either `project-number` or `project-id` can be provided. + */ + // const parent = 'abc123' + /** + * The maximum number of results to return. + */ + // const pageSize = 1234 + /** + * A pagination token returned from a previous call to + * `ListVulnerabilityReports` that indicates where this listing + * should continue from. + */ + // const pageToken = 'abc123' + /** + * If provided, this field specifies the criteria that must be met by a + * `vulnerabilityReport` API resource to be included in the response. + */ + // const filter = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callListVulnerabilityReports() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await osconfigClient.listVulnerabilityReportsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListVulnerabilityReports(); + // [END osconfig_v1_generated_OsConfigZonalService_ListVulnerabilityReports_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.update_o_s_policy_assignment.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.update_o_s_policy_assignment.js new file mode 100644 index 00000000000..bc2d193410d --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.update_o_s_policy_assignment.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(osPolicyAssignment) { + // [START osconfig_v1_generated_OsConfigZonalService_UpdateOSPolicyAssignment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The updated OS policy assignment. + */ + // const osPolicyAssignment = {} + /** + * Optional. Field mask that controls which fields of the assignment should be + * updated. + */ + // const updateMask = {} + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callUpdateOSPolicyAssignment() { + // Construct request + const request = { + osPolicyAssignment, + }; + + // Run request + const [operation] = await osconfigClient.updateOSPolicyAssignment(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateOSPolicyAssignment(); + // [END osconfig_v1_generated_OsConfigZonalService_UpdateOSPolicyAssignment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/snippet_metadata_google.cloud.osconfig.v1.json b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/snippet_metadata_google.cloud.osconfig.v1.json new file mode 100644 index 00000000000..e874ee38a66 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/snippet_metadata_google.cloud.osconfig.v1.json @@ -0,0 +1,1119 @@ +{ + "clientLibrary": { + "name": "nodejs-osconfig", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.osconfig.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "osconfig_v1_generated_OsConfigService_ExecutePatchJob_async", + "title": "OsConfigServiceClient executePatchJob Sample", + "origin": "API_DEFINITION", + "description": " Patch VM instances by creating and running a patch job.", + "canonical": true, + "file": "os_config_service.execute_patch_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 87, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ExecutePatchJob", + "fullName": "google.cloud.osconfig.v1.OsConfigService.ExecutePatchJob", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "description", + "type": "TYPE_STRING" + }, + { + "name": "instance_filter", + "type": ".google.cloud.osconfig.v1.PatchInstanceFilter" + }, + { + "name": "patch_config", + "type": ".google.cloud.osconfig.v1.PatchConfig" + }, + { + "name": "duration", + "type": ".google.protobuf.Duration" + }, + { + "name": "dry_run", + "type": "TYPE_BOOL" + }, + { + "name": "display_name", + "type": "TYPE_STRING" + }, + { + "name": "rollout", + "type": ".google.cloud.osconfig.v1.PatchRollout" + } + ], + "resultType": ".google.cloud.osconfig.v1.PatchJob", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" + }, + "method": { + "shortName": "ExecutePatchJob", + "fullName": "google.cloud.osconfig.v1.OsConfigService.ExecutePatchJob", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigService_GetPatchJob_async", + "title": "OsConfigServiceClient getPatchJob Sample", + "origin": "API_DEFINITION", + "description": " Get the patch job. This can be used to track the progress of an ongoing patch job or review the details of completed jobs.", + "canonical": true, + "file": "os_config_service.get_patch_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetPatchJob", + "fullName": "google.cloud.osconfig.v1.OsConfigService.GetPatchJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1.PatchJob", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" + }, + "method": { + "shortName": "GetPatchJob", + "fullName": "google.cloud.osconfig.v1.OsConfigService.GetPatchJob", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigService_CancelPatchJob_async", + "title": "OsConfigServiceClient cancelPatchJob Sample", + "origin": "API_DEFINITION", + "description": " Cancel a patch job. The patch job must be active. Canceled patch jobs cannot be restarted.", + "canonical": true, + "file": "os_config_service.cancel_patch_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CancelPatchJob", + "fullName": "google.cloud.osconfig.v1.OsConfigService.CancelPatchJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1.PatchJob", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" + }, + "method": { + "shortName": "CancelPatchJob", + "fullName": "google.cloud.osconfig.v1.OsConfigService.CancelPatchJob", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigService_ListPatchJobs_async", + "title": "OsConfigServiceClient listPatchJobs Sample", + "origin": "API_DEFINITION", + "description": " Get a list of patch jobs.", + "canonical": true, + "file": "os_config_service.list_patch_jobs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListPatchJobs", + "fullName": "google.cloud.osconfig.v1.OsConfigService.ListPatchJobs", + "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.osconfig.v1.ListPatchJobsResponse", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" + }, + "method": { + "shortName": "ListPatchJobs", + "fullName": "google.cloud.osconfig.v1.OsConfigService.ListPatchJobs", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigService_ListPatchJobInstanceDetails_async", + "title": "OsConfigServiceClient listPatchJobInstanceDetails Sample", + "origin": "API_DEFINITION", + "description": " Get a list of instance details for a given patch job.", + "canonical": true, + "file": "os_config_service.list_patch_job_instance_details.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListPatchJobInstanceDetails", + "fullName": "google.cloud.osconfig.v1.OsConfigService.ListPatchJobInstanceDetails", + "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.osconfig.v1.ListPatchJobInstanceDetailsResponse", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" + }, + "method": { + "shortName": "ListPatchJobInstanceDetails", + "fullName": "google.cloud.osconfig.v1.OsConfigService.ListPatchJobInstanceDetails", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigService_CreatePatchDeployment_async", + "title": "OsConfigServiceClient createPatchDeployment Sample", + "origin": "API_DEFINITION", + "description": " Create an OS Config patch deployment.", + "canonical": true, + "file": "os_config_service.create_patch_deployment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreatePatchDeployment", + "fullName": "google.cloud.osconfig.v1.OsConfigService.CreatePatchDeployment", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "patch_deployment_id", + "type": "TYPE_STRING" + }, + { + "name": "patch_deployment", + "type": ".google.cloud.osconfig.v1.PatchDeployment" + } + ], + "resultType": ".google.cloud.osconfig.v1.PatchDeployment", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" + }, + "method": { + "shortName": "CreatePatchDeployment", + "fullName": "google.cloud.osconfig.v1.OsConfigService.CreatePatchDeployment", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigService_GetPatchDeployment_async", + "title": "OsConfigServiceClient getPatchDeployment Sample", + "origin": "API_DEFINITION", + "description": " Get an OS Config patch deployment.", + "canonical": true, + "file": "os_config_service.get_patch_deployment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetPatchDeployment", + "fullName": "google.cloud.osconfig.v1.OsConfigService.GetPatchDeployment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1.PatchDeployment", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" + }, + "method": { + "shortName": "GetPatchDeployment", + "fullName": "google.cloud.osconfig.v1.OsConfigService.GetPatchDeployment", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigService_ListPatchDeployments_async", + "title": "OsConfigServiceClient listPatchDeployments Sample", + "origin": "API_DEFINITION", + "description": " Get a page of OS Config patch deployments.", + "canonical": true, + "file": "os_config_service.list_patch_deployments.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListPatchDeployments", + "fullName": "google.cloud.osconfig.v1.OsConfigService.ListPatchDeployments", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1.ListPatchDeploymentsResponse", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" + }, + "method": { + "shortName": "ListPatchDeployments", + "fullName": "google.cloud.osconfig.v1.OsConfigService.ListPatchDeployments", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigService_DeletePatchDeployment_async", + "title": "OsConfigServiceClient deletePatchDeployment Sample", + "origin": "API_DEFINITION", + "description": " Delete an OS Config patch deployment.", + "canonical": true, + "file": "os_config_service.delete_patch_deployment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeletePatchDeployment", + "fullName": "google.cloud.osconfig.v1.OsConfigService.DeletePatchDeployment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" + }, + "method": { + "shortName": "DeletePatchDeployment", + "fullName": "google.cloud.osconfig.v1.OsConfigService.DeletePatchDeployment", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigService_UpdatePatchDeployment_async", + "title": "OsConfigServiceClient updatePatchDeployment Sample", + "origin": "API_DEFINITION", + "description": " Update an OS Config patch deployment.", + "canonical": true, + "file": "os_config_service.update_patch_deployment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdatePatchDeployment", + "fullName": "google.cloud.osconfig.v1.OsConfigService.UpdatePatchDeployment", + "async": true, + "parameters": [ + { + "name": "patch_deployment", + "type": ".google.cloud.osconfig.v1.PatchDeployment" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.osconfig.v1.PatchDeployment", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" + }, + "method": { + "shortName": "UpdatePatchDeployment", + "fullName": "google.cloud.osconfig.v1.OsConfigService.UpdatePatchDeployment", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigService_PausePatchDeployment_async", + "title": "OsConfigServiceClient pausePatchDeployment Sample", + "origin": "API_DEFINITION", + "description": " Change state of patch deployment to \"PAUSED\". Patch deployment in paused state doesn't generate patch jobs.", + "canonical": true, + "file": "os_config_service.pause_patch_deployment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PausePatchDeployment", + "fullName": "google.cloud.osconfig.v1.OsConfigService.PausePatchDeployment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1.PatchDeployment", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" + }, + "method": { + "shortName": "PausePatchDeployment", + "fullName": "google.cloud.osconfig.v1.OsConfigService.PausePatchDeployment", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigService_ResumePatchDeployment_async", + "title": "OsConfigServiceClient resumePatchDeployment Sample", + "origin": "API_DEFINITION", + "description": " Change state of patch deployment back to \"ACTIVE\". Patch deployment in active state continues to generate patch jobs.", + "canonical": true, + "file": "os_config_service.resume_patch_deployment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ResumePatchDeployment", + "fullName": "google.cloud.osconfig.v1.OsConfigService.ResumePatchDeployment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1.PatchDeployment", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" + }, + "method": { + "shortName": "ResumePatchDeployment", + "fullName": "google.cloud.osconfig.v1.OsConfigService.ResumePatchDeployment", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigZonalService_CreateOSPolicyAssignment_async", + "title": "OsConfigServiceClient createOSPolicyAssignment Sample", + "origin": "API_DEFINITION", + "description": " Create an OS policy assignment. This method also creates the first revision of the OS policy assignment. This method returns a long running operation (LRO) that contains the rollout details. The rollout can be cancelled by cancelling the LRO. For more information, see [Method: projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel).", + "canonical": true, + "file": "os_config_zonal_service.create_o_s_policy_assignment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateOSPolicyAssignment", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.CreateOSPolicyAssignment", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "os_policy_assignment", + "type": ".google.cloud.osconfig.v1.OSPolicyAssignment" + }, + { + "name": "os_policy_assignment_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "CreateOSPolicyAssignment", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.CreateOSPolicyAssignment", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigZonalService_UpdateOSPolicyAssignment_async", + "title": "OsConfigServiceClient updateOSPolicyAssignment Sample", + "origin": "API_DEFINITION", + "description": " Update an existing OS policy assignment. This method creates a new revision of the OS policy assignment. This method returns a long running operation (LRO) that contains the rollout details. The rollout can be cancelled by cancelling the LRO. For more information, see [Method: projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel).", + "canonical": true, + "file": "os_config_zonal_service.update_o_s_policy_assignment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateOSPolicyAssignment", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.UpdateOSPolicyAssignment", + "async": true, + "parameters": [ + { + "name": "os_policy_assignment", + "type": ".google.cloud.osconfig.v1.OSPolicyAssignment" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "UpdateOSPolicyAssignment", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.UpdateOSPolicyAssignment", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigZonalService_GetOSPolicyAssignment_async", + "title": "OsConfigServiceClient getOSPolicyAssignment Sample", + "origin": "API_DEFINITION", + "description": " Retrieve an existing OS policy assignment. This method always returns the latest revision. In order to retrieve a previous revision of the assignment, also provide the revision ID in the `name` parameter.", + "canonical": true, + "file": "os_config_zonal_service.get_o_s_policy_assignment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetOSPolicyAssignment", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.GetOSPolicyAssignment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1.OSPolicyAssignment", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "GetOSPolicyAssignment", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.GetOSPolicyAssignment", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignments_async", + "title": "OsConfigServiceClient listOSPolicyAssignments Sample", + "origin": "API_DEFINITION", + "description": " List the OS policy assignments under the parent resource. For each OS policy assignment, the latest revision is returned.", + "canonical": true, + "file": "os_config_zonal_service.list_o_s_policy_assignments.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListOSPolicyAssignments", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.ListOSPolicyAssignments", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1.ListOSPolicyAssignmentsResponse", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "ListOSPolicyAssignments", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.ListOSPolicyAssignments", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignmentRevisions_async", + "title": "OsConfigServiceClient listOSPolicyAssignmentRevisions Sample", + "origin": "API_DEFINITION", + "description": " List the OS policy assignment revisions for a given OS policy assignment.", + "canonical": true, + "file": "os_config_zonal_service.list_o_s_policy_assignment_revisions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListOSPolicyAssignmentRevisions", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.ListOSPolicyAssignmentRevisions", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsResponse", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "ListOSPolicyAssignmentRevisions", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.ListOSPolicyAssignmentRevisions", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigZonalService_DeleteOSPolicyAssignment_async", + "title": "OsConfigServiceClient deleteOSPolicyAssignment Sample", + "origin": "API_DEFINITION", + "description": " Delete the OS policy assignment. This method creates a new revision of the OS policy assignment. This method returns a long running operation (LRO) that contains the rollout details. The rollout can be cancelled by cancelling the LRO. If the LRO completes and is not cancelled, all revisions associated with the OS policy assignment are deleted. For more information, see [Method: projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel).", + "canonical": true, + "file": "os_config_zonal_service.delete_o_s_policy_assignment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteOSPolicyAssignment", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.DeleteOSPolicyAssignment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "DeleteOSPolicyAssignment", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.DeleteOSPolicyAssignment", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigZonalService_GetOSPolicyAssignmentReport_async", + "title": "OsConfigServiceClient getOSPolicyAssignmentReport Sample", + "origin": "API_DEFINITION", + "description": " Get the OS policy asssignment report for the specified Compute Engine VM instance.", + "canonical": true, + "file": "os_config_zonal_service.get_o_s_policy_assignment_report.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetOSPolicyAssignmentReport", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.GetOSPolicyAssignmentReport", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1.OSPolicyAssignmentReport", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "GetOSPolicyAssignmentReport", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.GetOSPolicyAssignmentReport", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignmentReports_async", + "title": "OsConfigServiceClient listOSPolicyAssignmentReports Sample", + "origin": "API_DEFINITION", + "description": " List OS policy asssignment reports for all Compute Engine VM instances in the specified zone.", + "canonical": true, + "file": "os_config_zonal_service.list_o_s_policy_assignment_reports.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 87, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListOSPolicyAssignmentReports", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.ListOSPolicyAssignmentReports", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsResponse", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "ListOSPolicyAssignmentReports", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.ListOSPolicyAssignmentReports", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigZonalService_GetInventory_async", + "title": "OsConfigServiceClient getInventory Sample", + "origin": "API_DEFINITION", + "description": " Get inventory data for the specified VM instance. If the VM has no associated inventory, the message `NOT_FOUND` is returned.", + "canonical": true, + "file": "os_config_zonal_service.get_inventory.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetInventory", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.GetInventory", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "view", + "type": ".google.cloud.osconfig.v1.InventoryView" + } + ], + "resultType": ".google.cloud.osconfig.v1.Inventory", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "GetInventory", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.GetInventory", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigZonalService_ListInventories_async", + "title": "OsConfigServiceClient listInventories Sample", + "origin": "API_DEFINITION", + "description": " List inventory data for all VM instances in the specified zone.", + "canonical": true, + "file": "os_config_zonal_service.list_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 77, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListInventories", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.ListInventories", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "view", + "type": ".google.cloud.osconfig.v1.InventoryView" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1.ListInventoriesResponse", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "ListInventories", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.ListInventories", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigZonalService_GetVulnerabilityReport_async", + "title": "OsConfigServiceClient getVulnerabilityReport Sample", + "origin": "API_DEFINITION", + "description": " Gets the vulnerability report for the specified VM instance. Only VMs with inventory data have vulnerability reports associated with them.", + "canonical": true, + "file": "os_config_zonal_service.get_vulnerability_report.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetVulnerabilityReport", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.GetVulnerabilityReport", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1.VulnerabilityReport", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "GetVulnerabilityReport", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.GetVulnerabilityReport", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1_generated_OsConfigZonalService_ListVulnerabilityReports_async", + "title": "OsConfigServiceClient listVulnerabilityReports Sample", + "origin": "API_DEFINITION", + "description": " List vulnerability reports for all VM instances in the specified zone.", + "canonical": true, + "file": "os_config_zonal_service.list_vulnerability_reports.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListVulnerabilityReports", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.ListVulnerabilityReports", + "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.osconfig.v1.ListVulnerabilityReportsResponse", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "ListVulnerabilityReports", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.ListVulnerabilityReports", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/src/index.ts b/owl-bot-staging/google-cloud-osconfig/v1/src/index.ts new file mode 100644 index 00000000000..47ed963f2d6 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/src/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. ** + +import * as v1 from './v1'; +const OsConfigServiceClient = v1.OsConfigServiceClient; +type OsConfigServiceClient = v1.OsConfigServiceClient; +const OsConfigZonalServiceClient = v1.OsConfigZonalServiceClient; +type OsConfigZonalServiceClient = v1.OsConfigZonalServiceClient; +export {v1, OsConfigServiceClient, OsConfigZonalServiceClient}; +export default {v1, OsConfigServiceClient, OsConfigZonalServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..f65f75e1fb0 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/gapic_metadata.json @@ -0,0 +1,309 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.osconfig.v1", + "libraryPackage": "@google-cloud/os-config", + "services": { + "OsConfigService": { + "clients": { + "grpc": { + "libraryClient": "OsConfigServiceClient", + "rpcs": { + "ExecutePatchJob": { + "methods": [ + "executePatchJob" + ] + }, + "GetPatchJob": { + "methods": [ + "getPatchJob" + ] + }, + "CancelPatchJob": { + "methods": [ + "cancelPatchJob" + ] + }, + "CreatePatchDeployment": { + "methods": [ + "createPatchDeployment" + ] + }, + "GetPatchDeployment": { + "methods": [ + "getPatchDeployment" + ] + }, + "DeletePatchDeployment": { + "methods": [ + "deletePatchDeployment" + ] + }, + "UpdatePatchDeployment": { + "methods": [ + "updatePatchDeployment" + ] + }, + "PausePatchDeployment": { + "methods": [ + "pausePatchDeployment" + ] + }, + "ResumePatchDeployment": { + "methods": [ + "resumePatchDeployment" + ] + }, + "ListPatchJobs": { + "methods": [ + "listPatchJobs", + "listPatchJobsStream", + "listPatchJobsAsync" + ] + }, + "ListPatchJobInstanceDetails": { + "methods": [ + "listPatchJobInstanceDetails", + "listPatchJobInstanceDetailsStream", + "listPatchJobInstanceDetailsAsync" + ] + }, + "ListPatchDeployments": { + "methods": [ + "listPatchDeployments", + "listPatchDeploymentsStream", + "listPatchDeploymentsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "OsConfigServiceClient", + "rpcs": { + "ExecutePatchJob": { + "methods": [ + "executePatchJob" + ] + }, + "GetPatchJob": { + "methods": [ + "getPatchJob" + ] + }, + "CancelPatchJob": { + "methods": [ + "cancelPatchJob" + ] + }, + "CreatePatchDeployment": { + "methods": [ + "createPatchDeployment" + ] + }, + "GetPatchDeployment": { + "methods": [ + "getPatchDeployment" + ] + }, + "DeletePatchDeployment": { + "methods": [ + "deletePatchDeployment" + ] + }, + "UpdatePatchDeployment": { + "methods": [ + "updatePatchDeployment" + ] + }, + "PausePatchDeployment": { + "methods": [ + "pausePatchDeployment" + ] + }, + "ResumePatchDeployment": { + "methods": [ + "resumePatchDeployment" + ] + }, + "ListPatchJobs": { + "methods": [ + "listPatchJobs", + "listPatchJobsStream", + "listPatchJobsAsync" + ] + }, + "ListPatchJobInstanceDetails": { + "methods": [ + "listPatchJobInstanceDetails", + "listPatchJobInstanceDetailsStream", + "listPatchJobInstanceDetailsAsync" + ] + }, + "ListPatchDeployments": { + "methods": [ + "listPatchDeployments", + "listPatchDeploymentsStream", + "listPatchDeploymentsAsync" + ] + } + } + } + } + }, + "OsConfigZonalService": { + "clients": { + "grpc": { + "libraryClient": "OsConfigZonalServiceClient", + "rpcs": { + "GetOSPolicyAssignment": { + "methods": [ + "getOSPolicyAssignment" + ] + }, + "GetOSPolicyAssignmentReport": { + "methods": [ + "getOSPolicyAssignmentReport" + ] + }, + "GetInventory": { + "methods": [ + "getInventory" + ] + }, + "GetVulnerabilityReport": { + "methods": [ + "getVulnerabilityReport" + ] + }, + "CreateOSPolicyAssignment": { + "methods": [ + "createOSPolicyAssignment" + ] + }, + "UpdateOSPolicyAssignment": { + "methods": [ + "updateOSPolicyAssignment" + ] + }, + "DeleteOSPolicyAssignment": { + "methods": [ + "deleteOSPolicyAssignment" + ] + }, + "ListOSPolicyAssignments": { + "methods": [ + "listOSPolicyAssignments", + "listOSPolicyAssignmentsStream", + "listOSPolicyAssignmentsAsync" + ] + }, + "ListOSPolicyAssignmentRevisions": { + "methods": [ + "listOSPolicyAssignmentRevisions", + "listOSPolicyAssignmentRevisionsStream", + "listOSPolicyAssignmentRevisionsAsync" + ] + }, + "ListOSPolicyAssignmentReports": { + "methods": [ + "listOSPolicyAssignmentReports", + "listOSPolicyAssignmentReportsStream", + "listOSPolicyAssignmentReportsAsync" + ] + }, + "ListInventories": { + "methods": [ + "listInventories", + "listInventoriesStream", + "listInventoriesAsync" + ] + }, + "ListVulnerabilityReports": { + "methods": [ + "listVulnerabilityReports", + "listVulnerabilityReportsStream", + "listVulnerabilityReportsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "OsConfigZonalServiceClient", + "rpcs": { + "GetOSPolicyAssignment": { + "methods": [ + "getOSPolicyAssignment" + ] + }, + "GetOSPolicyAssignmentReport": { + "methods": [ + "getOSPolicyAssignmentReport" + ] + }, + "GetInventory": { + "methods": [ + "getInventory" + ] + }, + "GetVulnerabilityReport": { + "methods": [ + "getVulnerabilityReport" + ] + }, + "CreateOSPolicyAssignment": { + "methods": [ + "createOSPolicyAssignment" + ] + }, + "UpdateOSPolicyAssignment": { + "methods": [ + "updateOSPolicyAssignment" + ] + }, + "DeleteOSPolicyAssignment": { + "methods": [ + "deleteOSPolicyAssignment" + ] + }, + "ListOSPolicyAssignments": { + "methods": [ + "listOSPolicyAssignments", + "listOSPolicyAssignmentsStream", + "listOSPolicyAssignmentsAsync" + ] + }, + "ListOSPolicyAssignmentRevisions": { + "methods": [ + "listOSPolicyAssignmentRevisions", + "listOSPolicyAssignmentRevisionsStream", + "listOSPolicyAssignmentRevisionsAsync" + ] + }, + "ListOSPolicyAssignmentReports": { + "methods": [ + "listOSPolicyAssignmentReports", + "listOSPolicyAssignmentReportsStream", + "listOSPolicyAssignmentReportsAsync" + ] + }, + "ListInventories": { + "methods": [ + "listInventories", + "listInventoriesStream", + "listInventoriesAsync" + ] + }, + "ListVulnerabilityReports": { + "methods": [ + "listVulnerabilityReports", + "listVulnerabilityReportsStream", + "listVulnerabilityReportsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/index.ts new file mode 100644 index 00000000000..db855abce5c --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {OsConfigServiceClient} from './os_config_service_client'; +export {OsConfigZonalServiceClient} from './os_config_zonal_service_client'; diff --git a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_client.ts b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_client.ts new file mode 100644 index 00000000000..561a2a62224 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_client.ts @@ -0,0 +1,1854 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/os_config_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './os_config_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * OS Config API + * + * The OS Config service is a server-side component that you can use to + * manage package installations and patch jobs for virtual machine instances. + * @class + * @memberof v1 + */ +export class OsConfigServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + osConfigServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of OsConfigServiceClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 OsConfigServiceClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof OsConfigServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + inventoryPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/instances/{instance}/inventory' + ), + oSPolicyAssignmentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}' + ), + oSPolicyAssignmentReportPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report' + ), + patchDeploymentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/patchDeployments/{patch_deployment}' + ), + patchJobPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/patchJobs/{patch_job}' + ), + vulnerabilityReportPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport' + ), + }; + + // 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 = { + listPatchJobs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'patchJobs'), + listPatchJobInstanceDetails: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'patchJobInstanceDetails'), + listPatchDeployments: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'patchDeployments') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.osconfig.v1.OsConfigService', 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.osConfigServiceStub) { + return this.osConfigServiceStub; + } + + // Put together the "service stub" for + // google.cloud.osconfig.v1.OsConfigService. + this.osConfigServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.osconfig.v1.OsConfigService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.osconfig.v1.OsConfigService, + 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 osConfigServiceStubMethods = + ['executePatchJob', 'getPatchJob', 'cancelPatchJob', 'listPatchJobs', 'listPatchJobInstanceDetails', 'createPatchDeployment', 'getPatchDeployment', 'listPatchDeployments', 'deletePatchDeployment', 'updatePatchDeployment', 'pausePatchDeployment', 'resumePatchDeployment']; + for (const methodName of osConfigServiceStubMethods) { + const callPromise = this.osConfigServiceStub.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.osConfigServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'osconfig.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 'osconfig.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 -- + // ------------------- +/** + * Patch VM instances by creating and running a patch job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which to run this patch in the form `projects/*` + * @param {string} request.description + * Description of the patch job. Length of the description is limited + * to 1024 characters. + * @param {google.cloud.osconfig.v1.PatchInstanceFilter} request.instanceFilter + * Required. Instances to patch, either explicitly or filtered by some + * criteria such as zone or labels. + * @param {google.cloud.osconfig.v1.PatchConfig} request.patchConfig + * Patch configuration being applied. If omitted, instances are + * patched using the default configurations. + * @param {google.protobuf.Duration} request.duration + * Duration of the patch job. After the duration ends, the patch job + * times out. + * @param {boolean} request.dryRun + * If this patch is a dry-run only, instances are contacted but + * will do nothing. + * @param {string} request.displayName + * Display name for this patch job. This does not have to be unique. + * @param {google.cloud.osconfig.v1.PatchRollout} request.rollout + * Rollout strategy of the patch job. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.PatchJob|PatchJob}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_service.execute_patch_job.js + * region_tag:osconfig_v1_generated_OsConfigService_ExecutePatchJob_async + */ + executePatchJob( + request?: protos.google.cloud.osconfig.v1.IExecutePatchJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchJob, + protos.google.cloud.osconfig.v1.IExecutePatchJobRequest|undefined, {}|undefined + ]>; + executePatchJob( + request: protos.google.cloud.osconfig.v1.IExecutePatchJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1.IPatchJob, + protos.google.cloud.osconfig.v1.IExecutePatchJobRequest|null|undefined, + {}|null|undefined>): void; + executePatchJob( + request: protos.google.cloud.osconfig.v1.IExecutePatchJobRequest, + callback: Callback< + protos.google.cloud.osconfig.v1.IPatchJob, + protos.google.cloud.osconfig.v1.IExecutePatchJobRequest|null|undefined, + {}|null|undefined>): void; + executePatchJob( + request?: protos.google.cloud.osconfig.v1.IExecutePatchJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1.IPatchJob, + protos.google.cloud.osconfig.v1.IExecutePatchJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1.IPatchJob, + protos.google.cloud.osconfig.v1.IExecutePatchJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchJob, + protos.google.cloud.osconfig.v1.IExecutePatchJobRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.executePatchJob(request, options, callback); + } +/** + * Get the patch job. This can be used to track the progress of an + * ongoing patch job or review the details of completed jobs. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the patch in the form `projects/* /patchJobs/*` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.PatchJob|PatchJob}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_service.get_patch_job.js + * region_tag:osconfig_v1_generated_OsConfigService_GetPatchJob_async + */ + getPatchJob( + request?: protos.google.cloud.osconfig.v1.IGetPatchJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchJob, + protos.google.cloud.osconfig.v1.IGetPatchJobRequest|undefined, {}|undefined + ]>; + getPatchJob( + request: protos.google.cloud.osconfig.v1.IGetPatchJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1.IPatchJob, + protos.google.cloud.osconfig.v1.IGetPatchJobRequest|null|undefined, + {}|null|undefined>): void; + getPatchJob( + request: protos.google.cloud.osconfig.v1.IGetPatchJobRequest, + callback: Callback< + protos.google.cloud.osconfig.v1.IPatchJob, + protos.google.cloud.osconfig.v1.IGetPatchJobRequest|null|undefined, + {}|null|undefined>): void; + getPatchJob( + request?: protos.google.cloud.osconfig.v1.IGetPatchJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1.IPatchJob, + protos.google.cloud.osconfig.v1.IGetPatchJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1.IPatchJob, + protos.google.cloud.osconfig.v1.IGetPatchJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchJob, + protos.google.cloud.osconfig.v1.IGetPatchJobRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getPatchJob(request, options, callback); + } +/** + * Cancel a patch job. The patch job must be active. Canceled patch jobs + * cannot be restarted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the patch in the form `projects/* /patchJobs/*` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.PatchJob|PatchJob}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_service.cancel_patch_job.js + * region_tag:osconfig_v1_generated_OsConfigService_CancelPatchJob_async + */ + cancelPatchJob( + request?: protos.google.cloud.osconfig.v1.ICancelPatchJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchJob, + protos.google.cloud.osconfig.v1.ICancelPatchJobRequest|undefined, {}|undefined + ]>; + cancelPatchJob( + request: protos.google.cloud.osconfig.v1.ICancelPatchJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1.IPatchJob, + protos.google.cloud.osconfig.v1.ICancelPatchJobRequest|null|undefined, + {}|null|undefined>): void; + cancelPatchJob( + request: protos.google.cloud.osconfig.v1.ICancelPatchJobRequest, + callback: Callback< + protos.google.cloud.osconfig.v1.IPatchJob, + protos.google.cloud.osconfig.v1.ICancelPatchJobRequest|null|undefined, + {}|null|undefined>): void; + cancelPatchJob( + request?: protos.google.cloud.osconfig.v1.ICancelPatchJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1.IPatchJob, + protos.google.cloud.osconfig.v1.ICancelPatchJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1.IPatchJob, + protos.google.cloud.osconfig.v1.ICancelPatchJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchJob, + protos.google.cloud.osconfig.v1.ICancelPatchJobRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.cancelPatchJob(request, options, callback); + } +/** + * Create an OS Config patch deployment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project to apply this patch deployment to in the form + * `projects/*`. + * @param {string} request.patchDeploymentId + * Required. A name for the patch deployment in the project. When creating a + * name the following rules apply: + * * Must contain only lowercase letters, numbers, and hyphens. + * * Must start with a letter. + * * Must be between 1-63 characters. + * * Must end with a number or a letter. + * * Must be unique within the project. + * @param {google.cloud.osconfig.v1.PatchDeployment} request.patchDeployment + * Required. The patch deployment to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.PatchDeployment|PatchDeployment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_service.create_patch_deployment.js + * region_tag:osconfig_v1_generated_OsConfigService_CreatePatchDeployment_async + */ + createPatchDeployment( + request?: protos.google.cloud.osconfig.v1.ICreatePatchDeploymentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.ICreatePatchDeploymentRequest|undefined, {}|undefined + ]>; + createPatchDeployment( + request: protos.google.cloud.osconfig.v1.ICreatePatchDeploymentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.ICreatePatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + createPatchDeployment( + request: protos.google.cloud.osconfig.v1.ICreatePatchDeploymentRequest, + callback: Callback< + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.ICreatePatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + createPatchDeployment( + request?: protos.google.cloud.osconfig.v1.ICreatePatchDeploymentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.ICreatePatchDeploymentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.ICreatePatchDeploymentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.ICreatePatchDeploymentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createPatchDeployment(request, options, callback); + } +/** + * Get an OS Config patch deployment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the patch deployment in the form + * `projects/* /patchDeployments/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.PatchDeployment|PatchDeployment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_service.get_patch_deployment.js + * region_tag:osconfig_v1_generated_OsConfigService_GetPatchDeployment_async + */ + getPatchDeployment( + request?: protos.google.cloud.osconfig.v1.IGetPatchDeploymentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IGetPatchDeploymentRequest|undefined, {}|undefined + ]>; + getPatchDeployment( + request: protos.google.cloud.osconfig.v1.IGetPatchDeploymentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IGetPatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + getPatchDeployment( + request: protos.google.cloud.osconfig.v1.IGetPatchDeploymentRequest, + callback: Callback< + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IGetPatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + getPatchDeployment( + request?: protos.google.cloud.osconfig.v1.IGetPatchDeploymentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IGetPatchDeploymentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IGetPatchDeploymentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IGetPatchDeploymentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getPatchDeployment(request, options, callback); + } +/** + * Delete an OS Config patch deployment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the patch deployment in the form + * `projects/* /patchDeployments/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_service.delete_patch_deployment.js + * region_tag:osconfig_v1_generated_OsConfigService_DeletePatchDeployment_async + */ + deletePatchDeployment( + request?: protos.google.cloud.osconfig.v1.IDeletePatchDeploymentRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.osconfig.v1.IDeletePatchDeploymentRequest|undefined, {}|undefined + ]>; + deletePatchDeployment( + request: protos.google.cloud.osconfig.v1.IDeletePatchDeploymentRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.osconfig.v1.IDeletePatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + deletePatchDeployment( + request: protos.google.cloud.osconfig.v1.IDeletePatchDeploymentRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.osconfig.v1.IDeletePatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + deletePatchDeployment( + request?: protos.google.cloud.osconfig.v1.IDeletePatchDeploymentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.osconfig.v1.IDeletePatchDeploymentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.osconfig.v1.IDeletePatchDeploymentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.osconfig.v1.IDeletePatchDeploymentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deletePatchDeployment(request, options, callback); + } +/** + * Update an OS Config patch deployment. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.osconfig.v1.PatchDeployment} request.patchDeployment + * Required. The patch deployment to Update. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask that controls which fields of the patch deployment + * should be 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 protos.google.cloud.osconfig.v1.PatchDeployment|PatchDeployment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_service.update_patch_deployment.js + * region_tag:osconfig_v1_generated_OsConfigService_UpdatePatchDeployment_async + */ + updatePatchDeployment( + request?: protos.google.cloud.osconfig.v1.IUpdatePatchDeploymentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IUpdatePatchDeploymentRequest|undefined, {}|undefined + ]>; + updatePatchDeployment( + request: protos.google.cloud.osconfig.v1.IUpdatePatchDeploymentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IUpdatePatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + updatePatchDeployment( + request: protos.google.cloud.osconfig.v1.IUpdatePatchDeploymentRequest, + callback: Callback< + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IUpdatePatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + updatePatchDeployment( + request?: protos.google.cloud.osconfig.v1.IUpdatePatchDeploymentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IUpdatePatchDeploymentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IUpdatePatchDeploymentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IUpdatePatchDeploymentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'patch_deployment.name': request.patchDeployment!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updatePatchDeployment(request, options, callback); + } +/** + * Change state of patch deployment to "PAUSED". + * Patch deployment in paused state doesn't generate patch jobs. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the patch deployment in the form + * `projects/* /patchDeployments/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.PatchDeployment|PatchDeployment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_service.pause_patch_deployment.js + * region_tag:osconfig_v1_generated_OsConfigService_PausePatchDeployment_async + */ + pausePatchDeployment( + request?: protos.google.cloud.osconfig.v1.IPausePatchDeploymentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IPausePatchDeploymentRequest|undefined, {}|undefined + ]>; + pausePatchDeployment( + request: protos.google.cloud.osconfig.v1.IPausePatchDeploymentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IPausePatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + pausePatchDeployment( + request: protos.google.cloud.osconfig.v1.IPausePatchDeploymentRequest, + callback: Callback< + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IPausePatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + pausePatchDeployment( + request?: protos.google.cloud.osconfig.v1.IPausePatchDeploymentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IPausePatchDeploymentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IPausePatchDeploymentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IPausePatchDeploymentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.pausePatchDeployment(request, options, callback); + } +/** + * Change state of patch deployment back to "ACTIVE". + * Patch deployment in active state continues to generate patch jobs. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the patch deployment in the form + * `projects/* /patchDeployments/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.PatchDeployment|PatchDeployment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_service.resume_patch_deployment.js + * region_tag:osconfig_v1_generated_OsConfigService_ResumePatchDeployment_async + */ + resumePatchDeployment( + request?: protos.google.cloud.osconfig.v1.IResumePatchDeploymentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IResumePatchDeploymentRequest|undefined, {}|undefined + ]>; + resumePatchDeployment( + request: protos.google.cloud.osconfig.v1.IResumePatchDeploymentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IResumePatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + resumePatchDeployment( + request: protos.google.cloud.osconfig.v1.IResumePatchDeploymentRequest, + callback: Callback< + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IResumePatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + resumePatchDeployment( + request?: protos.google.cloud.osconfig.v1.IResumePatchDeploymentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IResumePatchDeploymentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IResumePatchDeploymentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchDeployment, + protos.google.cloud.osconfig.v1.IResumePatchDeploymentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.resumePatchDeployment(request, options, callback); + } + + /** + * Get a list of patch jobs. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. In the form of `projects/*` + * @param {number} request.pageSize + * The maximum number of instance status to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call + * that indicates where this listing should continue from. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by patch + * jobs to be included in the response. + * Currently, filtering is only available on the patch_deployment field. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1.PatchJob|PatchJob}. + * 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 `listPatchJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listPatchJobs( + request?: protos.google.cloud.osconfig.v1.IListPatchJobsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchJob[], + protos.google.cloud.osconfig.v1.IListPatchJobsRequest|null, + protos.google.cloud.osconfig.v1.IListPatchJobsResponse + ]>; + listPatchJobs( + request: protos.google.cloud.osconfig.v1.IListPatchJobsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1.IListPatchJobsRequest, + protos.google.cloud.osconfig.v1.IListPatchJobsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IPatchJob>): void; + listPatchJobs( + request: protos.google.cloud.osconfig.v1.IListPatchJobsRequest, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1.IListPatchJobsRequest, + protos.google.cloud.osconfig.v1.IListPatchJobsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IPatchJob>): void; + listPatchJobs( + request?: protos.google.cloud.osconfig.v1.IListPatchJobsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.osconfig.v1.IListPatchJobsRequest, + protos.google.cloud.osconfig.v1.IListPatchJobsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IPatchJob>, + callback?: PaginationCallback< + protos.google.cloud.osconfig.v1.IListPatchJobsRequest, + protos.google.cloud.osconfig.v1.IListPatchJobsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IPatchJob>): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchJob[], + protos.google.cloud.osconfig.v1.IListPatchJobsRequest|null, + protos.google.cloud.osconfig.v1.IListPatchJobsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listPatchJobs(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. In the form of `projects/*` + * @param {number} request.pageSize + * The maximum number of instance status to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call + * that indicates where this listing should continue from. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by patch + * jobs to be included in the response. + * Currently, filtering is only available on the patch_deployment field. + * @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 protos.google.cloud.osconfig.v1.PatchJob|PatchJob} 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 `listPatchJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listPatchJobsStream( + request?: protos.google.cloud.osconfig.v1.IListPatchJobsRequest, + 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['listPatchJobs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPatchJobs.createStream( + this.innerApiCalls.listPatchJobs as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listPatchJobs`, 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. In the form of `projects/*` + * @param {number} request.pageSize + * The maximum number of instance status to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call + * that indicates where this listing should continue from. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by patch + * jobs to be included in the response. + * Currently, filtering is only available on the patch_deployment field. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.osconfig.v1.PatchJob|PatchJob}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_service.list_patch_jobs.js + * region_tag:osconfig_v1_generated_OsConfigService_ListPatchJobs_async + */ + listPatchJobsAsync( + request?: protos.google.cloud.osconfig.v1.IListPatchJobsRequest, + 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['listPatchJobs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPatchJobs.asyncIterate( + this.innerApiCalls['listPatchJobs'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Get a list of instance details for a given patch job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent for the instances are in the form of + * `projects/* /patchJobs/*`. + * @param {number} request.pageSize + * The maximum number of instance details records to return. Default is 100. + * @param {string} request.pageToken + * A pagination token returned from a previous call + * that indicates where this listing should continue from. + * @param {string} request.filter + * A filter expression that filters results listed in the response. This + * field supports filtering results by instance zone, name, state, or + * `failure_reason`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1.PatchJobInstanceDetails|PatchJobInstanceDetails}. + * 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 `listPatchJobInstanceDetailsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listPatchJobInstanceDetails( + request?: protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchJobInstanceDetails[], + protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest|null, + protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsResponse + ]>; + listPatchJobInstanceDetails( + request: protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest, + protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IPatchJobInstanceDetails>): void; + listPatchJobInstanceDetails( + request: protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest, + protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IPatchJobInstanceDetails>): void; + listPatchJobInstanceDetails( + request?: protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest, + protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IPatchJobInstanceDetails>, + callback?: PaginationCallback< + protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest, + protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IPatchJobInstanceDetails>): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchJobInstanceDetails[], + protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest|null, + protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listPatchJobInstanceDetails(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 the instances are in the form of + * `projects/* /patchJobs/*`. + * @param {number} request.pageSize + * The maximum number of instance details records to return. Default is 100. + * @param {string} request.pageToken + * A pagination token returned from a previous call + * that indicates where this listing should continue from. + * @param {string} request.filter + * A filter expression that filters results listed in the response. This + * field supports filtering results by instance zone, name, state, or + * `failure_reason`. + * @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 protos.google.cloud.osconfig.v1.PatchJobInstanceDetails|PatchJobInstanceDetails} 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 `listPatchJobInstanceDetailsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listPatchJobInstanceDetailsStream( + request?: protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest, + 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['listPatchJobInstanceDetails']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPatchJobInstanceDetails.createStream( + this.innerApiCalls.listPatchJobInstanceDetails as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listPatchJobInstanceDetails`, 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 the instances are in the form of + * `projects/* /patchJobs/*`. + * @param {number} request.pageSize + * The maximum number of instance details records to return. Default is 100. + * @param {string} request.pageToken + * A pagination token returned from a previous call + * that indicates where this listing should continue from. + * @param {string} request.filter + * A filter expression that filters results listed in the response. This + * field supports filtering results by instance zone, name, state, or + * `failure_reason`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.osconfig.v1.PatchJobInstanceDetails|PatchJobInstanceDetails}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_service.list_patch_job_instance_details.js + * region_tag:osconfig_v1_generated_OsConfigService_ListPatchJobInstanceDetails_async + */ + listPatchJobInstanceDetailsAsync( + request?: protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest, + 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['listPatchJobInstanceDetails']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPatchJobInstanceDetails.asyncIterate( + this.innerApiCalls['listPatchJobInstanceDetails'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Get a page of OS Config patch deployments. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the parent in the form `projects/*`. + * @param {number} [request.pageSize] + * Optional. The maximum number of patch deployments to return. Default is + * 100. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * ListPatchDeployments that indicates where this listing should continue + * from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1.PatchDeployment|PatchDeployment}. + * 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 `listPatchDeploymentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listPatchDeployments( + request?: protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchDeployment[], + protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest|null, + protos.google.cloud.osconfig.v1.IListPatchDeploymentsResponse + ]>; + listPatchDeployments( + request: protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest, + protos.google.cloud.osconfig.v1.IListPatchDeploymentsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IPatchDeployment>): void; + listPatchDeployments( + request: protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest, + protos.google.cloud.osconfig.v1.IListPatchDeploymentsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IPatchDeployment>): void; + listPatchDeployments( + request?: protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest, + protos.google.cloud.osconfig.v1.IListPatchDeploymentsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IPatchDeployment>, + callback?: PaginationCallback< + protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest, + protos.google.cloud.osconfig.v1.IListPatchDeploymentsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IPatchDeployment>): + Promise<[ + protos.google.cloud.osconfig.v1.IPatchDeployment[], + protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest|null, + protos.google.cloud.osconfig.v1.IListPatchDeploymentsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listPatchDeployments(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the parent in the form `projects/*`. + * @param {number} [request.pageSize] + * Optional. The maximum number of patch deployments to return. Default is + * 100. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * ListPatchDeployments that indicates where this listing should continue + * from. + * @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 protos.google.cloud.osconfig.v1.PatchDeployment|PatchDeployment} 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 `listPatchDeploymentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listPatchDeploymentsStream( + request?: protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest, + 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['listPatchDeployments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPatchDeployments.createStream( + this.innerApiCalls.listPatchDeployments as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listPatchDeployments`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the parent in the form `projects/*`. + * @param {number} [request.pageSize] + * Optional. The maximum number of patch deployments to return. Default is + * 100. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * ListPatchDeployments that indicates where this listing should continue + * from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.osconfig.v1.PatchDeployment|PatchDeployment}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_service.list_patch_deployments.js + * region_tag:osconfig_v1_generated_OsConfigService_ListPatchDeployments_async + */ + listPatchDeploymentsAsync( + request?: protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest, + 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['listPatchDeployments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPatchDeployments.asyncIterate( + this.innerApiCalls['listPatchDeployments'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified inventory resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} instance + * @returns {string} Resource name string. + */ + inventoryPath(project:string,location:string,instance:string) { + return this.pathTemplates.inventoryPathTemplate.render({ + project: project, + location: location, + instance: instance, + }); + } + + /** + * Parse the project from Inventory resource. + * + * @param {string} inventoryName + * A fully-qualified path representing Inventory resource. + * @returns {string} A string representing the project. + */ + matchProjectFromInventoryName(inventoryName: string) { + return this.pathTemplates.inventoryPathTemplate.match(inventoryName).project; + } + + /** + * Parse the location from Inventory resource. + * + * @param {string} inventoryName + * A fully-qualified path representing Inventory resource. + * @returns {string} A string representing the location. + */ + matchLocationFromInventoryName(inventoryName: string) { + return this.pathTemplates.inventoryPathTemplate.match(inventoryName).location; + } + + /** + * Parse the instance from Inventory resource. + * + * @param {string} inventoryName + * A fully-qualified path representing Inventory resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromInventoryName(inventoryName: string) { + return this.pathTemplates.inventoryPathTemplate.match(inventoryName).instance; + } + + /** + * Return a fully-qualified oSPolicyAssignment resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} os_policy_assignment + * @returns {string} Resource name string. + */ + oSPolicyAssignmentPath(project:string,location:string,osPolicyAssignment:string) { + return this.pathTemplates.oSPolicyAssignmentPathTemplate.render({ + project: project, + location: location, + os_policy_assignment: osPolicyAssignment, + }); + } + + /** + * Parse the project from OSPolicyAssignment resource. + * + * @param {string} oSPolicyAssignmentName + * A fully-qualified path representing OSPolicyAssignment resource. + * @returns {string} A string representing the project. + */ + matchProjectFromOSPolicyAssignmentName(oSPolicyAssignmentName: string) { + return this.pathTemplates.oSPolicyAssignmentPathTemplate.match(oSPolicyAssignmentName).project; + } + + /** + * Parse the location from OSPolicyAssignment resource. + * + * @param {string} oSPolicyAssignmentName + * A fully-qualified path representing OSPolicyAssignment resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOSPolicyAssignmentName(oSPolicyAssignmentName: string) { + return this.pathTemplates.oSPolicyAssignmentPathTemplate.match(oSPolicyAssignmentName).location; + } + + /** + * Parse the os_policy_assignment from OSPolicyAssignment resource. + * + * @param {string} oSPolicyAssignmentName + * A fully-qualified path representing OSPolicyAssignment resource. + * @returns {string} A string representing the os_policy_assignment. + */ + matchOsPolicyAssignmentFromOSPolicyAssignmentName(oSPolicyAssignmentName: string) { + return this.pathTemplates.oSPolicyAssignmentPathTemplate.match(oSPolicyAssignmentName).os_policy_assignment; + } + + /** + * Return a fully-qualified oSPolicyAssignmentReport resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} instance + * @param {string} assignment + * @returns {string} Resource name string. + */ + oSPolicyAssignmentReportPath(project:string,location:string,instance:string,assignment:string) { + return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.render({ + project: project, + location: location, + instance: instance, + assignment: assignment, + }); + } + + /** + * Parse the project from OSPolicyAssignmentReport resource. + * + * @param {string} oSPolicyAssignmentReportName + * A fully-qualified path representing OSPolicyAssignmentReport resource. + * @returns {string} A string representing the project. + */ + matchProjectFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { + return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).project; + } + + /** + * Parse the location from OSPolicyAssignmentReport resource. + * + * @param {string} oSPolicyAssignmentReportName + * A fully-qualified path representing OSPolicyAssignmentReport resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { + return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).location; + } + + /** + * Parse the instance from OSPolicyAssignmentReport resource. + * + * @param {string} oSPolicyAssignmentReportName + * A fully-qualified path representing OSPolicyAssignmentReport resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { + return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).instance; + } + + /** + * Parse the assignment from OSPolicyAssignmentReport resource. + * + * @param {string} oSPolicyAssignmentReportName + * A fully-qualified path representing OSPolicyAssignmentReport resource. + * @returns {string} A string representing the assignment. + */ + matchAssignmentFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { + return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).assignment; + } + + /** + * Return a fully-qualified patchDeployment resource name string. + * + * @param {string} project + * @param {string} patch_deployment + * @returns {string} Resource name string. + */ + patchDeploymentPath(project:string,patchDeployment:string) { + return this.pathTemplates.patchDeploymentPathTemplate.render({ + project: project, + patch_deployment: patchDeployment, + }); + } + + /** + * Parse the project from PatchDeployment resource. + * + * @param {string} patchDeploymentName + * A fully-qualified path representing PatchDeployment resource. + * @returns {string} A string representing the project. + */ + matchProjectFromPatchDeploymentName(patchDeploymentName: string) { + return this.pathTemplates.patchDeploymentPathTemplate.match(patchDeploymentName).project; + } + + /** + * Parse the patch_deployment from PatchDeployment resource. + * + * @param {string} patchDeploymentName + * A fully-qualified path representing PatchDeployment resource. + * @returns {string} A string representing the patch_deployment. + */ + matchPatchDeploymentFromPatchDeploymentName(patchDeploymentName: string) { + return this.pathTemplates.patchDeploymentPathTemplate.match(patchDeploymentName).patch_deployment; + } + + /** + * Return a fully-qualified patchJob resource name string. + * + * @param {string} project + * @param {string} patch_job + * @returns {string} Resource name string. + */ + patchJobPath(project:string,patchJob:string) { + return this.pathTemplates.patchJobPathTemplate.render({ + project: project, + patch_job: patchJob, + }); + } + + /** + * Parse the project from PatchJob resource. + * + * @param {string} patchJobName + * A fully-qualified path representing PatchJob resource. + * @returns {string} A string representing the project. + */ + matchProjectFromPatchJobName(patchJobName: string) { + return this.pathTemplates.patchJobPathTemplate.match(patchJobName).project; + } + + /** + * Parse the patch_job from PatchJob resource. + * + * @param {string} patchJobName + * A fully-qualified path representing PatchJob resource. + * @returns {string} A string representing the patch_job. + */ + matchPatchJobFromPatchJobName(patchJobName: string) { + return this.pathTemplates.patchJobPathTemplate.match(patchJobName).patch_job; + } + + /** + * Return a fully-qualified vulnerabilityReport resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} instance + * @returns {string} Resource name string. + */ + vulnerabilityReportPath(project:string,location:string,instance:string) { + return this.pathTemplates.vulnerabilityReportPathTemplate.render({ + project: project, + location: location, + instance: instance, + }); + } + + /** + * Parse the project from VulnerabilityReport resource. + * + * @param {string} vulnerabilityReportName + * A fully-qualified path representing VulnerabilityReport resource. + * @returns {string} A string representing the project. + */ + matchProjectFromVulnerabilityReportName(vulnerabilityReportName: string) { + return this.pathTemplates.vulnerabilityReportPathTemplate.match(vulnerabilityReportName).project; + } + + /** + * Parse the location from VulnerabilityReport resource. + * + * @param {string} vulnerabilityReportName + * A fully-qualified path representing VulnerabilityReport resource. + * @returns {string} A string representing the location. + */ + matchLocationFromVulnerabilityReportName(vulnerabilityReportName: string) { + return this.pathTemplates.vulnerabilityReportPathTemplate.match(vulnerabilityReportName).location; + } + + /** + * Parse the instance from VulnerabilityReport resource. + * + * @param {string} vulnerabilityReportName + * A fully-qualified path representing VulnerabilityReport resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromVulnerabilityReportName(vulnerabilityReportName: string) { + return this.pathTemplates.vulnerabilityReportPathTemplate.match(vulnerabilityReportName).instance; + } + + /** + * 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.osConfigServiceStub && !this._terminated) { + return this.osConfigServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_client_config.json b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_client_config.json new file mode 100644 index 00000000000..49ac0b9b644 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_client_config.json @@ -0,0 +1,98 @@ +{ + "interfaces": { + "google.cloud.osconfig.v1.OsConfigService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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 + }, + "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c": { + "initial_retry_delay_millis": 1000, + "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": { + "ExecutePatchJob": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "GetPatchJob": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "CancelPatchJob": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "ListPatchJobs": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "ListPatchJobInstanceDetails": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "CreatePatchDeployment": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "GetPatchDeployment": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "ListPatchDeployments": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "DeletePatchDeployment": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "UpdatePatchDeployment": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "PausePatchDeployment": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "ResumePatchDeployment": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_proto_list.json b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_proto_list.json new file mode 100644 index 00000000000..e074f70ca02 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_proto_list.json @@ -0,0 +1,12 @@ +[ + "../../protos/google/cloud/osconfig/v1/inventory.proto", + "../../protos/google/cloud/osconfig/v1/os_policy.proto", + "../../protos/google/cloud/osconfig/v1/os_policy_assignment_reports.proto", + "../../protos/google/cloud/osconfig/v1/os_policy_assignments.proto", + "../../protos/google/cloud/osconfig/v1/osconfig_common.proto", + "../../protos/google/cloud/osconfig/v1/osconfig_service.proto", + "../../protos/google/cloud/osconfig/v1/osconfig_zonal_service.proto", + "../../protos/google/cloud/osconfig/v1/patch_deployments.proto", + "../../protos/google/cloud/osconfig/v1/patch_jobs.proto", + "../../protos/google/cloud/osconfig/v1/vulnerability.proto" +] diff --git a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_client.ts b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_client.ts new file mode 100644 index 00000000000..0057e11204d --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_client.ts @@ -0,0 +1,2306 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/os_config_zonal_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './os_config_zonal_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Zonal OS Config API + * + * The OS Config service is the server-side component that allows users to + * manage package installations and patch jobs for Compute Engine VM instances. + * @class + * @memberof v1 + */ +export class OsConfigZonalServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + osConfigZonalServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of OsConfigZonalServiceClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 OsConfigZonalServiceClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof OsConfigZonalServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + inventoryPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/instances/{instance}/inventory' + ), + oSPolicyAssignmentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}' + ), + oSPolicyAssignmentReportPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report' + ), + patchDeploymentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/patchDeployments/{patch_deployment}' + ), + patchJobPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/patchJobs/{patch_job}' + ), + vulnerabilityReportPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport' + ), + }; + + // 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 = { + listOSPolicyAssignments: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'osPolicyAssignments'), + listOSPolicyAssignmentRevisions: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'osPolicyAssignments'), + listOSPolicyAssignmentReports: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'osPolicyAssignmentReports'), + listInventories: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'inventories'), + listVulnerabilityReports: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'vulnerabilityReports') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/osPolicyAssignments/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/osPolicyAssignments/*/operations/*}',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createOSPolicyAssignmentResponse = protoFilesRoot.lookup( + '.google.cloud.osconfig.v1.OSPolicyAssignment') as gax.protobuf.Type; + const createOSPolicyAssignmentMetadata = protoFilesRoot.lookup( + '.google.cloud.osconfig.v1.OSPolicyAssignmentOperationMetadata') as gax.protobuf.Type; + const updateOSPolicyAssignmentResponse = protoFilesRoot.lookup( + '.google.cloud.osconfig.v1.OSPolicyAssignment') as gax.protobuf.Type; + const updateOSPolicyAssignmentMetadata = protoFilesRoot.lookup( + '.google.cloud.osconfig.v1.OSPolicyAssignmentOperationMetadata') as gax.protobuf.Type; + const deleteOSPolicyAssignmentResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteOSPolicyAssignmentMetadata = protoFilesRoot.lookup( + '.google.cloud.osconfig.v1.OSPolicyAssignmentOperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createOSPolicyAssignment: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createOSPolicyAssignmentResponse.decode.bind(createOSPolicyAssignmentResponse), + createOSPolicyAssignmentMetadata.decode.bind(createOSPolicyAssignmentMetadata)), + updateOSPolicyAssignment: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateOSPolicyAssignmentResponse.decode.bind(updateOSPolicyAssignmentResponse), + updateOSPolicyAssignmentMetadata.decode.bind(updateOSPolicyAssignmentMetadata)), + deleteOSPolicyAssignment: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteOSPolicyAssignmentResponse.decode.bind(deleteOSPolicyAssignmentResponse), + deleteOSPolicyAssignmentMetadata.decode.bind(deleteOSPolicyAssignmentMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.osconfig.v1.OsConfigZonalService', 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.osConfigZonalServiceStub) { + return this.osConfigZonalServiceStub; + } + + // Put together the "service stub" for + // google.cloud.osconfig.v1.OsConfigZonalService. + this.osConfigZonalServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.osconfig.v1.OsConfigZonalService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.osconfig.v1.OsConfigZonalService, + 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 osConfigZonalServiceStubMethods = + ['createOsPolicyAssignment', 'updateOsPolicyAssignment', 'getOsPolicyAssignment', 'listOsPolicyAssignments', 'listOsPolicyAssignmentRevisions', 'deleteOsPolicyAssignment', 'getOsPolicyAssignmentReport', 'listOsPolicyAssignmentReports', 'getInventory', 'listInventories', 'getVulnerabilityReport', 'listVulnerabilityReports']; + for (const methodName of osConfigZonalServiceStubMethods) { + const callPromise = this.osConfigZonalServiceStub.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.osConfigZonalServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'osconfig.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 'osconfig.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 -- + // ------------------- +/** + * Retrieve an existing OS policy assignment. + * + * This method always returns the latest revision. In order to retrieve a + * previous revision of the assignment, also provide the revision ID in the + * `name` parameter. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of OS policy assignment. + * + * Format: + * `projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}@{revisionId}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.OSPolicyAssignment|OSPolicyAssignment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_zonal_service.get_o_s_policy_assignment.js + * region_tag:osconfig_v1_generated_OsConfigZonalService_GetOSPolicyAssignment_async + */ + getOSPolicyAssignment( + request?: protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1.IOSPolicyAssignment, + protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentRequest|undefined, {}|undefined + ]>; + getOSPolicyAssignment( + request: protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1.IOSPolicyAssignment, + protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentRequest|null|undefined, + {}|null|undefined>): void; + getOSPolicyAssignment( + request: protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentRequest, + callback: Callback< + protos.google.cloud.osconfig.v1.IOSPolicyAssignment, + protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentRequest|null|undefined, + {}|null|undefined>): void; + getOSPolicyAssignment( + request?: protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1.IOSPolicyAssignment, + protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1.IOSPolicyAssignment, + protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1.IOSPolicyAssignment, + protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getOsPolicyAssignment(request, options, callback); + } +/** + * Get the OS policy asssignment report for the specified Compute Engine VM + * instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. API resource name for OS policy assignment report. + * + * Format: + * `/projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * For `{instance_id}`, either Compute Engine `instance-id` or `instance-name` + * can be provided. + * For `{assignment_id}`, the OSPolicyAssignment id must be provided. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport|OSPolicyAssignmentReport}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_zonal_service.get_o_s_policy_assignment_report.js + * region_tag:osconfig_v1_generated_OsConfigZonalService_GetOSPolicyAssignmentReport_async + */ + getOSPolicyAssignmentReport( + request?: protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentReportRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport, + protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentReportRequest|undefined, {}|undefined + ]>; + getOSPolicyAssignmentReport( + request: protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentReportRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport, + protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentReportRequest|null|undefined, + {}|null|undefined>): void; + getOSPolicyAssignmentReport( + request: protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentReportRequest, + callback: Callback< + protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport, + protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentReportRequest|null|undefined, + {}|null|undefined>): void; + getOSPolicyAssignmentReport( + request?: protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentReportRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport, + protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentReportRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport, + protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentReportRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport, + protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentReportRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getOsPolicyAssignmentReport(request, options, callback); + } +/** + * Get inventory data for the specified VM instance. If the VM has no + * associated inventory, the message `NOT_FOUND` is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. API resource name for inventory resource. + * + * Format: + * `projects/{project}/locations/{location}/instances/{instance}/inventory` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * For `{instance}`, either Compute Engine `instance-id` or `instance-name` + * can be provided. + * @param {google.cloud.osconfig.v1.InventoryView} request.view + * Inventory view indicating what information should be included in the + * inventory resource. If unspecified, the default view is BASIC. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.Inventory|Inventory}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_zonal_service.get_inventory.js + * region_tag:osconfig_v1_generated_OsConfigZonalService_GetInventory_async + */ + getInventory( + request?: protos.google.cloud.osconfig.v1.IGetInventoryRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1.IInventory, + protos.google.cloud.osconfig.v1.IGetInventoryRequest|undefined, {}|undefined + ]>; + getInventory( + request: protos.google.cloud.osconfig.v1.IGetInventoryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1.IInventory, + protos.google.cloud.osconfig.v1.IGetInventoryRequest|null|undefined, + {}|null|undefined>): void; + getInventory( + request: protos.google.cloud.osconfig.v1.IGetInventoryRequest, + callback: Callback< + protos.google.cloud.osconfig.v1.IInventory, + protos.google.cloud.osconfig.v1.IGetInventoryRequest|null|undefined, + {}|null|undefined>): void; + getInventory( + request?: protos.google.cloud.osconfig.v1.IGetInventoryRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1.IInventory, + protos.google.cloud.osconfig.v1.IGetInventoryRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1.IInventory, + protos.google.cloud.osconfig.v1.IGetInventoryRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1.IInventory, + protos.google.cloud.osconfig.v1.IGetInventoryRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getInventory(request, options, callback); + } +/** + * Gets the vulnerability report for the specified VM instance. Only VMs with + * inventory data have vulnerability reports associated with them. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. API resource name for vulnerability resource. + * + * Format: + * `projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * For `{instance}`, either Compute Engine `instance-id` or `instance-name` + * can be provided. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.VulnerabilityReport|VulnerabilityReport}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_zonal_service.get_vulnerability_report.js + * region_tag:osconfig_v1_generated_OsConfigZonalService_GetVulnerabilityReport_async + */ + getVulnerabilityReport( + request?: protos.google.cloud.osconfig.v1.IGetVulnerabilityReportRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1.IVulnerabilityReport, + protos.google.cloud.osconfig.v1.IGetVulnerabilityReportRequest|undefined, {}|undefined + ]>; + getVulnerabilityReport( + request: protos.google.cloud.osconfig.v1.IGetVulnerabilityReportRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1.IVulnerabilityReport, + protos.google.cloud.osconfig.v1.IGetVulnerabilityReportRequest|null|undefined, + {}|null|undefined>): void; + getVulnerabilityReport( + request: protos.google.cloud.osconfig.v1.IGetVulnerabilityReportRequest, + callback: Callback< + protos.google.cloud.osconfig.v1.IVulnerabilityReport, + protos.google.cloud.osconfig.v1.IGetVulnerabilityReportRequest|null|undefined, + {}|null|undefined>): void; + getVulnerabilityReport( + request?: protos.google.cloud.osconfig.v1.IGetVulnerabilityReportRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1.IVulnerabilityReport, + protos.google.cloud.osconfig.v1.IGetVulnerabilityReportRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1.IVulnerabilityReport, + protos.google.cloud.osconfig.v1.IGetVulnerabilityReportRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1.IVulnerabilityReport, + protos.google.cloud.osconfig.v1.IGetVulnerabilityReportRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getVulnerabilityReport(request, options, callback); + } + +/** + * Create an OS policy assignment. + * + * This method also creates the first revision of the OS policy assignment. + * + * This method returns a long running operation (LRO) that contains the + * rollout details. The rollout can be cancelled by cancelling the LRO. + * + * For more information, see [Method: + * projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name in the form: + * projects/{project}/locations/{location} + * @param {google.cloud.osconfig.v1.OSPolicyAssignment} request.osPolicyAssignment + * Required. The OS policy assignment to be created. + * @param {string} request.osPolicyAssignmentId + * Required. The logical name of the OS policy assignment in the project + * with the following restrictions: + * + * * Must contain only lowercase letters, numbers, and hyphens. + * * Must start with a letter. + * * Must be between 1-63 characters. + * * Must end with a number or a letter. + * * Must be unique within the project. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_zonal_service.create_o_s_policy_assignment.js + * region_tag:osconfig_v1_generated_OsConfigZonalService_CreateOSPolicyAssignment_async + */ + createOSPolicyAssignment( + request?: protos.google.cloud.osconfig.v1.ICreateOSPolicyAssignmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createOSPolicyAssignment( + request: protos.google.cloud.osconfig.v1.ICreateOSPolicyAssignmentRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createOSPolicyAssignment( + request: protos.google.cloud.osconfig.v1.ICreateOSPolicyAssignmentRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createOSPolicyAssignment( + request?: protos.google.cloud.osconfig.v1.ICreateOSPolicyAssignmentRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createOsPolicyAssignment(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createOSPolicyAssignment()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_zonal_service.create_o_s_policy_assignment.js + * region_tag:osconfig_v1_generated_OsConfigZonalService_CreateOSPolicyAssignment_async + */ + async checkCreateOSPolicyAssignmentProgress(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.createOSPolicyAssignment, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Update an existing OS policy assignment. + * + * This method creates a new revision of the OS policy assignment. + * + * This method returns a long running operation (LRO) that contains the + * rollout details. The rollout can be cancelled by cancelling the LRO. + * + * For more information, see [Method: + * projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel). + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.osconfig.v1.OSPolicyAssignment} request.osPolicyAssignment + * Required. The updated OS policy assignment. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask that controls which fields of the assignment should be + * 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_zonal_service.update_o_s_policy_assignment.js + * region_tag:osconfig_v1_generated_OsConfigZonalService_UpdateOSPolicyAssignment_async + */ + updateOSPolicyAssignment( + request?: protos.google.cloud.osconfig.v1.IUpdateOSPolicyAssignmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateOSPolicyAssignment( + request: protos.google.cloud.osconfig.v1.IUpdateOSPolicyAssignmentRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateOSPolicyAssignment( + request: protos.google.cloud.osconfig.v1.IUpdateOSPolicyAssignmentRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateOSPolicyAssignment( + request?: protos.google.cloud.osconfig.v1.IUpdateOSPolicyAssignmentRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'os_policy_assignment.name': request.osPolicyAssignment!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateOsPolicyAssignment(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateOSPolicyAssignment()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_zonal_service.update_o_s_policy_assignment.js + * region_tag:osconfig_v1_generated_OsConfigZonalService_UpdateOSPolicyAssignment_async + */ + async checkUpdateOSPolicyAssignmentProgress(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.updateOSPolicyAssignment, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Delete the OS policy assignment. + * + * This method creates a new revision of the OS policy assignment. + * + * This method returns a long running operation (LRO) that contains the + * rollout details. The rollout can be cancelled by cancelling the LRO. + * + * If the LRO completes and is not cancelled, all revisions associated with + * the OS policy assignment are deleted. + * + * For more information, see [Method: + * projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the OS policy assignment to be deleted + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_zonal_service.delete_o_s_policy_assignment.js + * region_tag:osconfig_v1_generated_OsConfigZonalService_DeleteOSPolicyAssignment_async + */ + deleteOSPolicyAssignment( + request?: protos.google.cloud.osconfig.v1.IDeleteOSPolicyAssignmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteOSPolicyAssignment( + request: protos.google.cloud.osconfig.v1.IDeleteOSPolicyAssignmentRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteOSPolicyAssignment( + request: protos.google.cloud.osconfig.v1.IDeleteOSPolicyAssignmentRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteOSPolicyAssignment( + request?: protos.google.cloud.osconfig.v1.IDeleteOSPolicyAssignmentRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteOsPolicyAssignment(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteOSPolicyAssignment()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_zonal_service.delete_o_s_policy_assignment.js + * region_tag:osconfig_v1_generated_OsConfigZonalService_DeleteOSPolicyAssignment_async + */ + async checkDeleteOSPolicyAssignmentProgress(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.deleteOSPolicyAssignment, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * List the OS policy assignments under the parent resource. + * + * For each OS policy assignment, the latest revision is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {number} request.pageSize + * The maximum number of assignments to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListOSPolicyAssignments` that indicates where this listing should continue + * from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1.OSPolicyAssignment|OSPolicyAssignment}. + * 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 `listOSPolicyAssignmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listOSPolicyAssignments( + request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1.IOSPolicyAssignment[], + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest|null, + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsResponse + ]>; + listOSPolicyAssignments( + request: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest, + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IOSPolicyAssignment>): void; + listOSPolicyAssignments( + request: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest, + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IOSPolicyAssignment>): void; + listOSPolicyAssignments( + request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest, + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IOSPolicyAssignment>, + callback?: PaginationCallback< + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest, + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IOSPolicyAssignment>): + Promise<[ + protos.google.cloud.osconfig.v1.IOSPolicyAssignment[], + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest|null, + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listOsPolicyAssignments(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 resource name. + * @param {number} request.pageSize + * The maximum number of assignments to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListOSPolicyAssignments` that indicates where this listing should continue + * from. + * @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 protos.google.cloud.osconfig.v1.OSPolicyAssignment|OSPolicyAssignment} 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 `listOSPolicyAssignmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listOSPolicyAssignmentsStream( + request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest, + 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['listOsPolicyAssignments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listOSPolicyAssignments.createStream( + this.innerApiCalls.listOsPolicyAssignments as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listOSPolicyAssignments`, 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 resource name. + * @param {number} request.pageSize + * The maximum number of assignments to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListOSPolicyAssignments` that indicates where this listing should continue + * from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.osconfig.v1.OSPolicyAssignment|OSPolicyAssignment}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignments.js + * region_tag:osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignments_async + */ + listOSPolicyAssignmentsAsync( + request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest, + 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['listOsPolicyAssignments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listOSPolicyAssignments.asyncIterate( + this.innerApiCalls['listOsPolicyAssignments'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * List the OS policy assignment revisions for a given OS policy assignment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the OS policy assignment to list revisions for. + * @param {number} request.pageSize + * The maximum number of revisions to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListOSPolicyAssignmentRevisions` that indicates where this listing should + * continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1.OSPolicyAssignment|OSPolicyAssignment}. + * 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 `listOSPolicyAssignmentRevisionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listOSPolicyAssignmentRevisions( + request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1.IOSPolicyAssignment[], + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest|null, + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsResponse + ]>; + listOSPolicyAssignmentRevisions( + request: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest, + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IOSPolicyAssignment>): void; + listOSPolicyAssignmentRevisions( + request: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest, + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IOSPolicyAssignment>): void; + listOSPolicyAssignmentRevisions( + request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest, + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IOSPolicyAssignment>, + callback?: PaginationCallback< + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest, + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IOSPolicyAssignment>): + Promise<[ + protos.google.cloud.osconfig.v1.IOSPolicyAssignment[], + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest|null, + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.listOsPolicyAssignmentRevisions(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the OS policy assignment to list revisions for. + * @param {number} request.pageSize + * The maximum number of revisions to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListOSPolicyAssignmentRevisions` that indicates where this listing should + * continue from. + * @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 protos.google.cloud.osconfig.v1.OSPolicyAssignment|OSPolicyAssignment} 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 `listOSPolicyAssignmentRevisionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listOSPolicyAssignmentRevisionsStream( + request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listOsPolicyAssignmentRevisions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listOSPolicyAssignmentRevisions.createStream( + this.innerApiCalls.listOsPolicyAssignmentRevisions as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listOSPolicyAssignmentRevisions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the OS policy assignment to list revisions for. + * @param {number} request.pageSize + * The maximum number of revisions to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListOSPolicyAssignmentRevisions` that indicates where this listing should + * continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.osconfig.v1.OSPolicyAssignment|OSPolicyAssignment}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignment_revisions.js + * region_tag:osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignmentRevisions_async + */ + listOSPolicyAssignmentRevisionsAsync( + request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listOsPolicyAssignmentRevisions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate( + this.innerApiCalls['listOsPolicyAssignmentRevisions'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * List OS policy asssignment reports for all Compute Engine VM instances in + * the specified zone. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * + * Format: + * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/reports` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * For `{instance}`, either `instance-name`, `instance-id`, or `-` can be + * provided. If '-' is provided, the response will include + * OSPolicyAssignmentReports for all instances in the project/location. + * For `{assignment}`, either `assignment-id` or `-` can be provided. If '-' + * is provided, the response will include OSPolicyAssignmentReports for all + * OSPolicyAssignments in the project/location. + * Either {instance} or {assignment} must be `-`. + * + * For example: + * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/-/reports` + * returns all reports for the instance + * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/{assignment-id}/reports` + * returns all the reports for the given assignment across all instances. + * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/-/reports` + * returns all the reports for all assignments across all instances. + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by the + * `OSPolicyAssignmentReport` API resource that is included in the response. + * @param {string} request.pageToken + * A pagination token returned from a previous call to the + * `ListOSPolicyAssignmentReports` method that indicates where this listing + * should continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport|OSPolicyAssignmentReport}. + * 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 `listOSPolicyAssignmentReportsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listOSPolicyAssignmentReports( + request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport[], + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest|null, + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsResponse + ]>; + listOSPolicyAssignmentReports( + request: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest, + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport>): void; + listOSPolicyAssignmentReports( + request: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest, + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport>): void; + listOSPolicyAssignmentReports( + request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest, + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport>, + callback?: PaginationCallback< + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest, + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport>): + Promise<[ + protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport[], + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest|null, + protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listOsPolicyAssignmentReports(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 resource name. + * + * Format: + * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/reports` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * For `{instance}`, either `instance-name`, `instance-id`, or `-` can be + * provided. If '-' is provided, the response will include + * OSPolicyAssignmentReports for all instances in the project/location. + * For `{assignment}`, either `assignment-id` or `-` can be provided. If '-' + * is provided, the response will include OSPolicyAssignmentReports for all + * OSPolicyAssignments in the project/location. + * Either {instance} or {assignment} must be `-`. + * + * For example: + * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/-/reports` + * returns all reports for the instance + * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/{assignment-id}/reports` + * returns all the reports for the given assignment across all instances. + * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/-/reports` + * returns all the reports for all assignments across all instances. + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by the + * `OSPolicyAssignmentReport` API resource that is included in the response. + * @param {string} request.pageToken + * A pagination token returned from a previous call to the + * `ListOSPolicyAssignmentReports` method that indicates where this listing + * should continue from. + * @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 protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport|OSPolicyAssignmentReport} 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 `listOSPolicyAssignmentReportsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listOSPolicyAssignmentReportsStream( + request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest, + 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['listOsPolicyAssignmentReports']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listOSPolicyAssignmentReports.createStream( + this.innerApiCalls.listOsPolicyAssignmentReports as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listOSPolicyAssignmentReports`, 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 resource name. + * + * Format: + * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/reports` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * For `{instance}`, either `instance-name`, `instance-id`, or `-` can be + * provided. If '-' is provided, the response will include + * OSPolicyAssignmentReports for all instances in the project/location. + * For `{assignment}`, either `assignment-id` or `-` can be provided. If '-' + * is provided, the response will include OSPolicyAssignmentReports for all + * OSPolicyAssignments in the project/location. + * Either {instance} or {assignment} must be `-`. + * + * For example: + * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/-/reports` + * returns all reports for the instance + * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/{assignment-id}/reports` + * returns all the reports for the given assignment across all instances. + * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/-/reports` + * returns all the reports for all assignments across all instances. + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by the + * `OSPolicyAssignmentReport` API resource that is included in the response. + * @param {string} request.pageToken + * A pagination token returned from a previous call to the + * `ListOSPolicyAssignmentReports` method that indicates where this listing + * should continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport|OSPolicyAssignmentReport}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignment_reports.js + * region_tag:osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignmentReports_async + */ + listOSPolicyAssignmentReportsAsync( + request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest, + 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['listOsPolicyAssignmentReports']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listOSPolicyAssignmentReports.asyncIterate( + this.innerApiCalls['listOsPolicyAssignmentReports'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * List inventory data for all VM instances in the specified zone. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * + * Format: `projects/{project}/locations/{location}/instances/-` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * @param {google.cloud.osconfig.v1.InventoryView} request.view + * Inventory view indicating what information should be included in the + * inventory resource. If unspecified, the default view is BASIC. + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListInventories` that indicates where this listing + * should continue from. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by a + * `Inventory` API resource to be included in the response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1.Inventory|Inventory}. + * 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 `listInventoriesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listInventories( + request?: protos.google.cloud.osconfig.v1.IListInventoriesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1.IInventory[], + protos.google.cloud.osconfig.v1.IListInventoriesRequest|null, + protos.google.cloud.osconfig.v1.IListInventoriesResponse + ]>; + listInventories( + request: protos.google.cloud.osconfig.v1.IListInventoriesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1.IListInventoriesRequest, + protos.google.cloud.osconfig.v1.IListInventoriesResponse|null|undefined, + protos.google.cloud.osconfig.v1.IInventory>): void; + listInventories( + request: protos.google.cloud.osconfig.v1.IListInventoriesRequest, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1.IListInventoriesRequest, + protos.google.cloud.osconfig.v1.IListInventoriesResponse|null|undefined, + protos.google.cloud.osconfig.v1.IInventory>): void; + listInventories( + request?: protos.google.cloud.osconfig.v1.IListInventoriesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.osconfig.v1.IListInventoriesRequest, + protos.google.cloud.osconfig.v1.IListInventoriesResponse|null|undefined, + protos.google.cloud.osconfig.v1.IInventory>, + callback?: PaginationCallback< + protos.google.cloud.osconfig.v1.IListInventoriesRequest, + protos.google.cloud.osconfig.v1.IListInventoriesResponse|null|undefined, + protos.google.cloud.osconfig.v1.IInventory>): + Promise<[ + protos.google.cloud.osconfig.v1.IInventory[], + protos.google.cloud.osconfig.v1.IListInventoriesRequest|null, + protos.google.cloud.osconfig.v1.IListInventoriesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listInventories(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 resource name. + * + * Format: `projects/{project}/locations/{location}/instances/-` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * @param {google.cloud.osconfig.v1.InventoryView} request.view + * Inventory view indicating what information should be included in the + * inventory resource. If unspecified, the default view is BASIC. + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListInventories` that indicates where this listing + * should continue from. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by a + * `Inventory` API resource to be included in the response. + * @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 protos.google.cloud.osconfig.v1.Inventory|Inventory} 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 `listInventoriesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listInventoriesStream( + request?: protos.google.cloud.osconfig.v1.IListInventoriesRequest, + 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['listInventories']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInventories.createStream( + this.innerApiCalls.listInventories as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listInventories`, 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 resource name. + * + * Format: `projects/{project}/locations/{location}/instances/-` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * @param {google.cloud.osconfig.v1.InventoryView} request.view + * Inventory view indicating what information should be included in the + * inventory resource. If unspecified, the default view is BASIC. + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListInventories` that indicates where this listing + * should continue from. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by a + * `Inventory` API resource to be included in the response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.osconfig.v1.Inventory|Inventory}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_zonal_service.list_inventories.js + * region_tag:osconfig_v1_generated_OsConfigZonalService_ListInventories_async + */ + listInventoriesAsync( + request?: protos.google.cloud.osconfig.v1.IListInventoriesRequest, + 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['listInventories']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInventories.asyncIterate( + this.innerApiCalls['listInventories'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * List vulnerability reports for all VM instances in the specified zone. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * + * Format: `projects/{project}/locations/{location}/instances/-` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListVulnerabilityReports` that indicates where this listing + * should continue from. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by a + * `vulnerabilityReport` API resource to be included in the response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1.VulnerabilityReport|VulnerabilityReport}. + * 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 `listVulnerabilityReportsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listVulnerabilityReports( + request?: protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1.IVulnerabilityReport[], + protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest|null, + protos.google.cloud.osconfig.v1.IListVulnerabilityReportsResponse + ]>; + listVulnerabilityReports( + request: protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest, + protos.google.cloud.osconfig.v1.IListVulnerabilityReportsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IVulnerabilityReport>): void; + listVulnerabilityReports( + request: protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest, + protos.google.cloud.osconfig.v1.IListVulnerabilityReportsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IVulnerabilityReport>): void; + listVulnerabilityReports( + request?: protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest, + protos.google.cloud.osconfig.v1.IListVulnerabilityReportsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IVulnerabilityReport>, + callback?: PaginationCallback< + protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest, + protos.google.cloud.osconfig.v1.IListVulnerabilityReportsResponse|null|undefined, + protos.google.cloud.osconfig.v1.IVulnerabilityReport>): + Promise<[ + protos.google.cloud.osconfig.v1.IVulnerabilityReport[], + protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest|null, + protos.google.cloud.osconfig.v1.IListVulnerabilityReportsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listVulnerabilityReports(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 resource name. + * + * Format: `projects/{project}/locations/{location}/instances/-` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListVulnerabilityReports` that indicates where this listing + * should continue from. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by a + * `vulnerabilityReport` API resource to be included in the response. + * @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 protos.google.cloud.osconfig.v1.VulnerabilityReport|VulnerabilityReport} 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 `listVulnerabilityReportsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listVulnerabilityReportsStream( + request?: protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest, + 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['listVulnerabilityReports']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listVulnerabilityReports.createStream( + this.innerApiCalls.listVulnerabilityReports as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listVulnerabilityReports`, 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 resource name. + * + * Format: `projects/{project}/locations/{location}/instances/-` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListVulnerabilityReports` that indicates where this listing + * should continue from. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by a + * `vulnerabilityReport` API resource to be included in the response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.osconfig.v1.VulnerabilityReport|VulnerabilityReport}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_config_zonal_service.list_vulnerability_reports.js + * region_tag:osconfig_v1_generated_OsConfigZonalService_ListVulnerabilityReports_async + */ + listVulnerabilityReportsAsync( + request?: protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest, + 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['listVulnerabilityReports']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listVulnerabilityReports.asyncIterate( + this.innerApiCalls['listVulnerabilityReports'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified inventory resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} instance + * @returns {string} Resource name string. + */ + inventoryPath(project:string,location:string,instance:string) { + return this.pathTemplates.inventoryPathTemplate.render({ + project: project, + location: location, + instance: instance, + }); + } + + /** + * Parse the project from Inventory resource. + * + * @param {string} inventoryName + * A fully-qualified path representing Inventory resource. + * @returns {string} A string representing the project. + */ + matchProjectFromInventoryName(inventoryName: string) { + return this.pathTemplates.inventoryPathTemplate.match(inventoryName).project; + } + + /** + * Parse the location from Inventory resource. + * + * @param {string} inventoryName + * A fully-qualified path representing Inventory resource. + * @returns {string} A string representing the location. + */ + matchLocationFromInventoryName(inventoryName: string) { + return this.pathTemplates.inventoryPathTemplate.match(inventoryName).location; + } + + /** + * Parse the instance from Inventory resource. + * + * @param {string} inventoryName + * A fully-qualified path representing Inventory resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromInventoryName(inventoryName: string) { + return this.pathTemplates.inventoryPathTemplate.match(inventoryName).instance; + } + + /** + * Return a fully-qualified oSPolicyAssignment resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} os_policy_assignment + * @returns {string} Resource name string. + */ + oSPolicyAssignmentPath(project:string,location:string,osPolicyAssignment:string) { + return this.pathTemplates.oSPolicyAssignmentPathTemplate.render({ + project: project, + location: location, + os_policy_assignment: osPolicyAssignment, + }); + } + + /** + * Parse the project from OSPolicyAssignment resource. + * + * @param {string} oSPolicyAssignmentName + * A fully-qualified path representing OSPolicyAssignment resource. + * @returns {string} A string representing the project. + */ + matchProjectFromOSPolicyAssignmentName(oSPolicyAssignmentName: string) { + return this.pathTemplates.oSPolicyAssignmentPathTemplate.match(oSPolicyAssignmentName).project; + } + + /** + * Parse the location from OSPolicyAssignment resource. + * + * @param {string} oSPolicyAssignmentName + * A fully-qualified path representing OSPolicyAssignment resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOSPolicyAssignmentName(oSPolicyAssignmentName: string) { + return this.pathTemplates.oSPolicyAssignmentPathTemplate.match(oSPolicyAssignmentName).location; + } + + /** + * Parse the os_policy_assignment from OSPolicyAssignment resource. + * + * @param {string} oSPolicyAssignmentName + * A fully-qualified path representing OSPolicyAssignment resource. + * @returns {string} A string representing the os_policy_assignment. + */ + matchOsPolicyAssignmentFromOSPolicyAssignmentName(oSPolicyAssignmentName: string) { + return this.pathTemplates.oSPolicyAssignmentPathTemplate.match(oSPolicyAssignmentName).os_policy_assignment; + } + + /** + * Return a fully-qualified oSPolicyAssignmentReport resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} instance + * @param {string} assignment + * @returns {string} Resource name string. + */ + oSPolicyAssignmentReportPath(project:string,location:string,instance:string,assignment:string) { + return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.render({ + project: project, + location: location, + instance: instance, + assignment: assignment, + }); + } + + /** + * Parse the project from OSPolicyAssignmentReport resource. + * + * @param {string} oSPolicyAssignmentReportName + * A fully-qualified path representing OSPolicyAssignmentReport resource. + * @returns {string} A string representing the project. + */ + matchProjectFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { + return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).project; + } + + /** + * Parse the location from OSPolicyAssignmentReport resource. + * + * @param {string} oSPolicyAssignmentReportName + * A fully-qualified path representing OSPolicyAssignmentReport resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { + return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).location; + } + + /** + * Parse the instance from OSPolicyAssignmentReport resource. + * + * @param {string} oSPolicyAssignmentReportName + * A fully-qualified path representing OSPolicyAssignmentReport resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { + return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).instance; + } + + /** + * Parse the assignment from OSPolicyAssignmentReport resource. + * + * @param {string} oSPolicyAssignmentReportName + * A fully-qualified path representing OSPolicyAssignmentReport resource. + * @returns {string} A string representing the assignment. + */ + matchAssignmentFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { + return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).assignment; + } + + /** + * Return a fully-qualified patchDeployment resource name string. + * + * @param {string} project + * @param {string} patch_deployment + * @returns {string} Resource name string. + */ + patchDeploymentPath(project:string,patchDeployment:string) { + return this.pathTemplates.patchDeploymentPathTemplate.render({ + project: project, + patch_deployment: patchDeployment, + }); + } + + /** + * Parse the project from PatchDeployment resource. + * + * @param {string} patchDeploymentName + * A fully-qualified path representing PatchDeployment resource. + * @returns {string} A string representing the project. + */ + matchProjectFromPatchDeploymentName(patchDeploymentName: string) { + return this.pathTemplates.patchDeploymentPathTemplate.match(patchDeploymentName).project; + } + + /** + * Parse the patch_deployment from PatchDeployment resource. + * + * @param {string} patchDeploymentName + * A fully-qualified path representing PatchDeployment resource. + * @returns {string} A string representing the patch_deployment. + */ + matchPatchDeploymentFromPatchDeploymentName(patchDeploymentName: string) { + return this.pathTemplates.patchDeploymentPathTemplate.match(patchDeploymentName).patch_deployment; + } + + /** + * Return a fully-qualified patchJob resource name string. + * + * @param {string} project + * @param {string} patch_job + * @returns {string} Resource name string. + */ + patchJobPath(project:string,patchJob:string) { + return this.pathTemplates.patchJobPathTemplate.render({ + project: project, + patch_job: patchJob, + }); + } + + /** + * Parse the project from PatchJob resource. + * + * @param {string} patchJobName + * A fully-qualified path representing PatchJob resource. + * @returns {string} A string representing the project. + */ + matchProjectFromPatchJobName(patchJobName: string) { + return this.pathTemplates.patchJobPathTemplate.match(patchJobName).project; + } + + /** + * Parse the patch_job from PatchJob resource. + * + * @param {string} patchJobName + * A fully-qualified path representing PatchJob resource. + * @returns {string} A string representing the patch_job. + */ + matchPatchJobFromPatchJobName(patchJobName: string) { + return this.pathTemplates.patchJobPathTemplate.match(patchJobName).patch_job; + } + + /** + * Return a fully-qualified vulnerabilityReport resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} instance + * @returns {string} Resource name string. + */ + vulnerabilityReportPath(project:string,location:string,instance:string) { + return this.pathTemplates.vulnerabilityReportPathTemplate.render({ + project: project, + location: location, + instance: instance, + }); + } + + /** + * Parse the project from VulnerabilityReport resource. + * + * @param {string} vulnerabilityReportName + * A fully-qualified path representing VulnerabilityReport resource. + * @returns {string} A string representing the project. + */ + matchProjectFromVulnerabilityReportName(vulnerabilityReportName: string) { + return this.pathTemplates.vulnerabilityReportPathTemplate.match(vulnerabilityReportName).project; + } + + /** + * Parse the location from VulnerabilityReport resource. + * + * @param {string} vulnerabilityReportName + * A fully-qualified path representing VulnerabilityReport resource. + * @returns {string} A string representing the location. + */ + matchLocationFromVulnerabilityReportName(vulnerabilityReportName: string) { + return this.pathTemplates.vulnerabilityReportPathTemplate.match(vulnerabilityReportName).location; + } + + /** + * Parse the instance from VulnerabilityReport resource. + * + * @param {string} vulnerabilityReportName + * A fully-qualified path representing VulnerabilityReport resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromVulnerabilityReportName(vulnerabilityReportName: string) { + return this.pathTemplates.vulnerabilityReportPathTemplate.match(vulnerabilityReportName).instance; + } + + /** + * 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.osConfigZonalServiceStub && !this._terminated) { + return this.osConfigZonalServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_client_config.json b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_client_config.json new file mode 100644 index 00000000000..bb97e593101 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_client_config.json @@ -0,0 +1,98 @@ +{ + "interfaces": { + "google.cloud.osconfig.v1.OsConfigZonalService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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 + }, + "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c": { + "initial_retry_delay_millis": 1000, + "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": { + "CreateOSPolicyAssignment": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "UpdateOSPolicyAssignment": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "GetOSPolicyAssignment": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "ListOSPolicyAssignments": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "ListOSPolicyAssignmentRevisions": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "DeleteOSPolicyAssignment": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "GetOSPolicyAssignmentReport": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "ListOSPolicyAssignmentReports": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "GetInventory": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "ListInventories": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "GetVulnerabilityReport": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "ListVulnerabilityReports": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_proto_list.json b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_proto_list.json new file mode 100644 index 00000000000..e074f70ca02 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_proto_list.json @@ -0,0 +1,12 @@ +[ + "../../protos/google/cloud/osconfig/v1/inventory.proto", + "../../protos/google/cloud/osconfig/v1/os_policy.proto", + "../../protos/google/cloud/osconfig/v1/os_policy_assignment_reports.proto", + "../../protos/google/cloud/osconfig/v1/os_policy_assignments.proto", + "../../protos/google/cloud/osconfig/v1/osconfig_common.proto", + "../../protos/google/cloud/osconfig/v1/osconfig_service.proto", + "../../protos/google/cloud/osconfig/v1/osconfig_zonal_service.proto", + "../../protos/google/cloud/osconfig/v1/patch_deployments.proto", + "../../protos/google/cloud/osconfig/v1/patch_jobs.proto", + "../../protos/google/cloud/osconfig/v1/vulnerability.proto" +] diff --git a/owl-bot-staging/google-cloud-osconfig/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-osconfig/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..d31b72946ae --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const osconfig = require('@google-cloud/os-config'); + +function main() { + const osConfigServiceClient = new osconfig.OsConfigServiceClient(); + const osConfigZonalServiceClient = new osconfig.OsConfigZonalServiceClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-osconfig/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..bcff84a935f --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {OsConfigServiceClient, OsConfigZonalServiceClient} from '@google-cloud/os-config'; + +// check that the client class type name can be used +function doStuffWithOsConfigServiceClient(client: OsConfigServiceClient) { + client.close(); +} +function doStuffWithOsConfigZonalServiceClient(client: OsConfigZonalServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const osConfigServiceClient = new OsConfigServiceClient(); + doStuffWithOsConfigServiceClient(osConfigServiceClient); + // check that the client instance can be created + const osConfigZonalServiceClient = new OsConfigZonalServiceClient(); + doStuffWithOsConfigZonalServiceClient(osConfigZonalServiceClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/system-test/install.ts b/owl-bot-staging/google-cloud-osconfig/v1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/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-osconfig/v1/test/gapic_os_config_service_v1.ts b/owl-bot-staging/google-cloud-osconfig/v1/test/gapic_os_config_service_v1.ts new file mode 100644 index 00000000000..8cc6e4641d6 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/test/gapic_os_config_service_v1.ts @@ -0,0 +1,2179 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 osconfigserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.OsConfigServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = osconfigserviceModule.v1.OsConfigServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = osconfigserviceModule.v1.OsConfigServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = osconfigserviceModule.v1.OsConfigServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.osConfigServiceStub, undefined); + await client.initialize(); + assert(client.osConfigServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.osConfigServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.osConfigServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + 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 osconfigserviceModule.v1.OsConfigServiceClient({ + 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('executePatchJob', () => { + it('invokes executePatchJob without error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ExecutePatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ExecutePatchJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.PatchJob() + ); + client.innerApiCalls.executePatchJob = stubSimpleCall(expectedResponse); + const [response] = await client.executePatchJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.executePatchJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.executePatchJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executePatchJob without error using callback', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ExecutePatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ExecutePatchJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.PatchJob() + ); + client.innerApiCalls.executePatchJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.executePatchJob( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.executePatchJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.executePatchJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executePatchJob with error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ExecutePatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ExecutePatchJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.executePatchJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.executePatchJob(request), expectedError); + const actualRequest = (client.innerApiCalls.executePatchJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.executePatchJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executePatchJob with closed client', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ExecutePatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ExecutePatchJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.executePatchJob(request), expectedError); + }); + }); + + describe('getPatchJob', () => { + it('invokes getPatchJob without error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetPatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetPatchJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.PatchJob() + ); + client.innerApiCalls.getPatchJob = stubSimpleCall(expectedResponse); + const [response] = await client.getPatchJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getPatchJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getPatchJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPatchJob without error using callback', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetPatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetPatchJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.PatchJob() + ); + client.innerApiCalls.getPatchJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getPatchJob( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getPatchJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getPatchJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPatchJob with error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetPatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetPatchJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getPatchJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getPatchJob(request), expectedError); + const actualRequest = (client.innerApiCalls.getPatchJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getPatchJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPatchJob with closed client', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetPatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetPatchJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getPatchJob(request), expectedError); + }); + }); + + describe('cancelPatchJob', () => { + it('invokes cancelPatchJob without error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.CancelPatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.CancelPatchJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.PatchJob() + ); + client.innerApiCalls.cancelPatchJob = stubSimpleCall(expectedResponse); + const [response] = await client.cancelPatchJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.cancelPatchJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.cancelPatchJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cancelPatchJob without error using callback', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.CancelPatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.CancelPatchJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.PatchJob() + ); + client.innerApiCalls.cancelPatchJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.cancelPatchJob( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.cancelPatchJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.cancelPatchJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cancelPatchJob with error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.CancelPatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.CancelPatchJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.cancelPatchJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.cancelPatchJob(request), expectedError); + const actualRequest = (client.innerApiCalls.cancelPatchJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.cancelPatchJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cancelPatchJob with closed client', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.CancelPatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.CancelPatchJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.cancelPatchJob(request), expectedError); + }); + }); + + describe('createPatchDeployment', () => { + it('invokes createPatchDeployment without error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.CreatePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.CreatePatchDeploymentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.PatchDeployment() + ); + client.innerApiCalls.createPatchDeployment = stubSimpleCall(expectedResponse); + const [response] = await client.createPatchDeployment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createPatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createPatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createPatchDeployment without error using callback', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.CreatePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.CreatePatchDeploymentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.PatchDeployment() + ); + client.innerApiCalls.createPatchDeployment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createPatchDeployment( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchDeployment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createPatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createPatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createPatchDeployment with error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.CreatePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.CreatePatchDeploymentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createPatchDeployment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createPatchDeployment(request), expectedError); + const actualRequest = (client.innerApiCalls.createPatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createPatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createPatchDeployment with closed client', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.CreatePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.CreatePatchDeploymentRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createPatchDeployment(request), expectedError); + }); + }); + + describe('getPatchDeployment', () => { + it('invokes getPatchDeployment without error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetPatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetPatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.PatchDeployment() + ); + client.innerApiCalls.getPatchDeployment = stubSimpleCall(expectedResponse); + const [response] = await client.getPatchDeployment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getPatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getPatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPatchDeployment without error using callback', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetPatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetPatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.PatchDeployment() + ); + client.innerApiCalls.getPatchDeployment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getPatchDeployment( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchDeployment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getPatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getPatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPatchDeployment with error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetPatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetPatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getPatchDeployment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getPatchDeployment(request), expectedError); + const actualRequest = (client.innerApiCalls.getPatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getPatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPatchDeployment with closed client', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetPatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetPatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getPatchDeployment(request), expectedError); + }); + }); + + describe('deletePatchDeployment', () => { + it('invokes deletePatchDeployment without error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.DeletePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.DeletePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deletePatchDeployment = stubSimpleCall(expectedResponse); + const [response] = await client.deletePatchDeployment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deletePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePatchDeployment without error using callback', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.DeletePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.DeletePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deletePatchDeployment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deletePatchDeployment( + 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.deletePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePatchDeployment with error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.DeletePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.DeletePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePatchDeployment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deletePatchDeployment(request), expectedError); + const actualRequest = (client.innerApiCalls.deletePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePatchDeployment with closed client', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.DeletePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.DeletePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deletePatchDeployment(request), expectedError); + }); + }); + + describe('updatePatchDeployment', () => { + it('invokes updatePatchDeployment without error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.UpdatePatchDeploymentRequest() + ); + request.patchDeployment ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.UpdatePatchDeploymentRequest', ['patchDeployment', 'name']); + request.patchDeployment.name = defaultValue1; + const expectedHeaderRequestParams = `patch_deployment.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.PatchDeployment() + ); + client.innerApiCalls.updatePatchDeployment = stubSimpleCall(expectedResponse); + const [response] = await client.updatePatchDeployment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updatePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePatchDeployment without error using callback', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.UpdatePatchDeploymentRequest() + ); + request.patchDeployment ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.UpdatePatchDeploymentRequest', ['patchDeployment', 'name']); + request.patchDeployment.name = defaultValue1; + const expectedHeaderRequestParams = `patch_deployment.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.PatchDeployment() + ); + client.innerApiCalls.updatePatchDeployment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updatePatchDeployment( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchDeployment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updatePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePatchDeployment with error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.UpdatePatchDeploymentRequest() + ); + request.patchDeployment ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.UpdatePatchDeploymentRequest', ['patchDeployment', 'name']); + request.patchDeployment.name = defaultValue1; + const expectedHeaderRequestParams = `patch_deployment.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updatePatchDeployment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updatePatchDeployment(request), expectedError); + const actualRequest = (client.innerApiCalls.updatePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePatchDeployment with closed client', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.UpdatePatchDeploymentRequest() + ); + request.patchDeployment ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.UpdatePatchDeploymentRequest', ['patchDeployment', 'name']); + request.patchDeployment.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updatePatchDeployment(request), expectedError); + }); + }); + + describe('pausePatchDeployment', () => { + it('invokes pausePatchDeployment without error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.PausePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.PausePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.PatchDeployment() + ); + client.innerApiCalls.pausePatchDeployment = stubSimpleCall(expectedResponse); + const [response] = await client.pausePatchDeployment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pausePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pausePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pausePatchDeployment without error using callback', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.PausePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.PausePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.PatchDeployment() + ); + client.innerApiCalls.pausePatchDeployment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.pausePatchDeployment( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchDeployment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pausePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pausePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pausePatchDeployment with error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.PausePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.PausePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.pausePatchDeployment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.pausePatchDeployment(request), expectedError); + const actualRequest = (client.innerApiCalls.pausePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pausePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pausePatchDeployment with closed client', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.PausePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.PausePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.pausePatchDeployment(request), expectedError); + }); + }); + + describe('resumePatchDeployment', () => { + it('invokes resumePatchDeployment without error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ResumePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ResumePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.PatchDeployment() + ); + client.innerApiCalls.resumePatchDeployment = stubSimpleCall(expectedResponse); + const [response] = await client.resumePatchDeployment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resumePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumePatchDeployment without error using callback', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ResumePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ResumePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.PatchDeployment() + ); + client.innerApiCalls.resumePatchDeployment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resumePatchDeployment( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchDeployment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resumePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumePatchDeployment with error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ResumePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ResumePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resumePatchDeployment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.resumePatchDeployment(request), expectedError); + const actualRequest = (client.innerApiCalls.resumePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumePatchDeployment with closed client', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ResumePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ResumePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.resumePatchDeployment(request), expectedError); + }); + }); + + describe('listPatchJobs', () => { + it('invokes listPatchJobs without error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListPatchJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), + ]; + client.innerApiCalls.listPatchJobs = stubSimpleCall(expectedResponse); + const [response] = await client.listPatchJobs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPatchJobs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPatchJobs without error using callback', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListPatchJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), + ]; + client.innerApiCalls.listPatchJobs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPatchJobs( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchJob[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPatchJobs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPatchJobs with error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListPatchJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPatchJobs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listPatchJobs(request), expectedError); + const actualRequest = (client.innerApiCalls.listPatchJobs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPatchJobsStream without error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListPatchJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), + ]; + client.descriptors.page.listPatchJobs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listPatchJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1.PatchJob[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1.PatchJob) => { + 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.listPatchJobs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPatchJobs, request)); + assert( + (client.descriptors.page.listPatchJobs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listPatchJobsStream with error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListPatchJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPatchJobs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listPatchJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1.PatchJob[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1.PatchJob) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listPatchJobs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPatchJobs, request)); + assert( + (client.descriptors.page.listPatchJobs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPatchJobs without error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListPatchJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), + ]; + client.descriptors.page.listPatchJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.osconfig.v1.IPatchJob[] = []; + const iterable = client.listPatchJobsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listPatchJobs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPatchJobs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPatchJobs with error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListPatchJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPatchJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listPatchJobsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.osconfig.v1.IPatchJob[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listPatchJobs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPatchJobs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listPatchJobInstanceDetails', () => { + it('invokes listPatchJobInstanceDetails without error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), + ]; + client.innerApiCalls.listPatchJobInstanceDetails = stubSimpleCall(expectedResponse); + const [response] = await client.listPatchJobInstanceDetails(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPatchJobInstanceDetails without error using callback', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), + ]; + client.innerApiCalls.listPatchJobInstanceDetails = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPatchJobInstanceDetails( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchJobInstanceDetails[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPatchJobInstanceDetails with error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPatchJobInstanceDetails = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listPatchJobInstanceDetails(request), expectedError); + const actualRequest = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPatchJobInstanceDetailsStream without error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), + ]; + client.descriptors.page.listPatchJobInstanceDetails.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listPatchJobInstanceDetailsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1.PatchJobInstanceDetails[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1.PatchJobInstanceDetails) => { + 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.listPatchJobInstanceDetails.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPatchJobInstanceDetails, request)); + assert( + (client.descriptors.page.listPatchJobInstanceDetails.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listPatchJobInstanceDetailsStream with error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPatchJobInstanceDetails.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listPatchJobInstanceDetailsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1.PatchJobInstanceDetails[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1.PatchJobInstanceDetails) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listPatchJobInstanceDetails.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPatchJobInstanceDetails, request)); + assert( + (client.descriptors.page.listPatchJobInstanceDetails.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPatchJobInstanceDetails without error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), + ]; + client.descriptors.page.listPatchJobInstanceDetails.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.osconfig.v1.IPatchJobInstanceDetails[] = []; + const iterable = client.listPatchJobInstanceDetailsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listPatchJobInstanceDetails.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPatchJobInstanceDetails.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPatchJobInstanceDetails with error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPatchJobInstanceDetails.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listPatchJobInstanceDetailsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.osconfig.v1.IPatchJobInstanceDetails[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listPatchJobInstanceDetails.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPatchJobInstanceDetails.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listPatchDeployments', () => { + it('invokes listPatchDeployments without error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListPatchDeploymentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchDeploymentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), + ]; + client.innerApiCalls.listPatchDeployments = stubSimpleCall(expectedResponse); + const [response] = await client.listPatchDeployments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPatchDeployments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPatchDeployments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPatchDeployments without error using callback', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListPatchDeploymentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchDeploymentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), + ]; + client.innerApiCalls.listPatchDeployments = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPatchDeployments( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchDeployment[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPatchDeployments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPatchDeployments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPatchDeployments with error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListPatchDeploymentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchDeploymentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPatchDeployments = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listPatchDeployments(request), expectedError); + const actualRequest = (client.innerApiCalls.listPatchDeployments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPatchDeployments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPatchDeploymentsStream without error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListPatchDeploymentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchDeploymentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), + ]; + client.descriptors.page.listPatchDeployments.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listPatchDeploymentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1.PatchDeployment[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1.PatchDeployment) => { + 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.listPatchDeployments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPatchDeployments, request)); + assert( + (client.descriptors.page.listPatchDeployments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listPatchDeploymentsStream with error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListPatchDeploymentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchDeploymentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPatchDeployments.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listPatchDeploymentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1.PatchDeployment[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1.PatchDeployment) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listPatchDeployments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPatchDeployments, request)); + assert( + (client.descriptors.page.listPatchDeployments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPatchDeployments without error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListPatchDeploymentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchDeploymentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), + ]; + client.descriptors.page.listPatchDeployments.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.osconfig.v1.IPatchDeployment[] = []; + const iterable = client.listPatchDeploymentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listPatchDeployments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPatchDeployments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPatchDeployments with error', async () => { + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListPatchDeploymentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchDeploymentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPatchDeployments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listPatchDeploymentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.osconfig.v1.IPatchDeployment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listPatchDeployments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPatchDeployments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('inventory', () => { + const fakePath = "/rendered/path/inventory"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + instance: "instanceValue", + }; + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.inventoryPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.inventoryPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('inventoryPath', () => { + const result = client.inventoryPath("projectValue", "locationValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.inventoryPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromInventoryName', () => { + const result = client.matchProjectFromInventoryName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.inventoryPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromInventoryName', () => { + const result = client.matchLocationFromInventoryName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.inventoryPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromInventoryName', () => { + const result = client.matchInstanceFromInventoryName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.inventoryPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('oSPolicyAssignment', () => { + const fakePath = "/rendered/path/oSPolicyAssignment"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + os_policy_assignment: "osPolicyAssignmentValue", + }; + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.oSPolicyAssignmentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.oSPolicyAssignmentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('oSPolicyAssignmentPath', () => { + const result = client.oSPolicyAssignmentPath("projectValue", "locationValue", "osPolicyAssignmentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromOSPolicyAssignmentName', () => { + const result = client.matchProjectFromOSPolicyAssignmentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromOSPolicyAssignmentName', () => { + const result = client.matchLocationFromOSPolicyAssignmentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchOsPolicyAssignmentFromOSPolicyAssignmentName', () => { + const result = client.matchOsPolicyAssignmentFromOSPolicyAssignmentName(fakePath); + assert.strictEqual(result, "osPolicyAssignmentValue"); + assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('oSPolicyAssignmentReport', () => { + const fakePath = "/rendered/path/oSPolicyAssignmentReport"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + instance: "instanceValue", + assignment: "assignmentValue", + }; + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.oSPolicyAssignmentReportPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('oSPolicyAssignmentReportPath', () => { + const result = client.oSPolicyAssignmentReportPath("projectValue", "locationValue", "instanceValue", "assignmentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromOSPolicyAssignmentReportName', () => { + const result = client.matchProjectFromOSPolicyAssignmentReportName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromOSPolicyAssignmentReportName', () => { + const result = client.matchLocationFromOSPolicyAssignmentReportName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromOSPolicyAssignmentReportName', () => { + const result = client.matchInstanceFromOSPolicyAssignmentReportName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchAssignmentFromOSPolicyAssignmentReportName', () => { + const result = client.matchAssignmentFromOSPolicyAssignmentReportName(fakePath); + assert.strictEqual(result, "assignmentValue"); + assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('patchDeployment', () => { + const fakePath = "/rendered/path/patchDeployment"; + const expectedParameters = { + project: "projectValue", + patch_deployment: "patchDeploymentValue", + }; + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.patchDeploymentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.patchDeploymentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('patchDeploymentPath', () => { + const result = client.patchDeploymentPath("projectValue", "patchDeploymentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.patchDeploymentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromPatchDeploymentName', () => { + const result = client.matchProjectFromPatchDeploymentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.patchDeploymentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchPatchDeploymentFromPatchDeploymentName', () => { + const result = client.matchPatchDeploymentFromPatchDeploymentName(fakePath); + assert.strictEqual(result, "patchDeploymentValue"); + assert((client.pathTemplates.patchDeploymentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('patchJob', () => { + const fakePath = "/rendered/path/patchJob"; + const expectedParameters = { + project: "projectValue", + patch_job: "patchJobValue", + }; + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.patchJobPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.patchJobPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('patchJobPath', () => { + const result = client.patchJobPath("projectValue", "patchJobValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.patchJobPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromPatchJobName', () => { + const result = client.matchProjectFromPatchJobName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.patchJobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchPatchJobFromPatchJobName', () => { + const result = client.matchPatchJobFromPatchJobName(fakePath); + assert.strictEqual(result, "patchJobValue"); + assert((client.pathTemplates.patchJobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('vulnerabilityReport', () => { + const fakePath = "/rendered/path/vulnerabilityReport"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + instance: "instanceValue", + }; + const client = new osconfigserviceModule.v1.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.vulnerabilityReportPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.vulnerabilityReportPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('vulnerabilityReportPath', () => { + const result = client.vulnerabilityReportPath("projectValue", "locationValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.vulnerabilityReportPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromVulnerabilityReportName', () => { + const result = client.matchProjectFromVulnerabilityReportName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.vulnerabilityReportPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromVulnerabilityReportName', () => { + const result = client.matchLocationFromVulnerabilityReportName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.vulnerabilityReportPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromVulnerabilityReportName', () => { + const result = client.matchInstanceFromVulnerabilityReportName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.vulnerabilityReportPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/test/gapic_os_config_zonal_service_v1.ts b/owl-bot-staging/google-cloud-osconfig/v1/test/gapic_os_config_zonal_service_v1.ts new file mode 100644 index 00000000000..5c3524e7112 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/test/gapic_os_config_zonal_service_v1.ts @@ -0,0 +1,2607 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 osconfigzonalserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.OsConfigZonalServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = osconfigzonalserviceModule.v1.OsConfigZonalServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = osconfigzonalserviceModule.v1.OsConfigZonalServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = osconfigzonalserviceModule.v1.OsConfigZonalServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.osConfigZonalServiceStub, undefined); + await client.initialize(); + assert(client.osConfigZonalServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.osConfigZonalServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.osConfigZonalServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + 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 osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + 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('getOSPolicyAssignment', () => { + it('invokes getOSPolicyAssignment without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.OSPolicyAssignment() + ); + client.innerApiCalls.getOsPolicyAssignment = stubSimpleCall(expectedResponse); + const [response] = await client.getOSPolicyAssignment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getOSPolicyAssignment without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.OSPolicyAssignment() + ); + client.innerApiCalls.getOsPolicyAssignment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getOSPolicyAssignment( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IOSPolicyAssignment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getOSPolicyAssignment with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getOsPolicyAssignment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getOSPolicyAssignment(request), expectedError); + const actualRequest = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getOSPolicyAssignment with closed client', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getOSPolicyAssignment(request), expectedError); + }); + }); + + describe('getOSPolicyAssignmentReport', () => { + it('invokes getOSPolicyAssignmentReport without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport() + ); + client.innerApiCalls.getOsPolicyAssignmentReport = stubSimpleCall(expectedResponse); + const [response] = await client.getOSPolicyAssignmentReport(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getOSPolicyAssignmentReport without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport() + ); + client.innerApiCalls.getOsPolicyAssignmentReport = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getOSPolicyAssignmentReport( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getOSPolicyAssignmentReport with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getOsPolicyAssignmentReport = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getOSPolicyAssignmentReport(request), expectedError); + const actualRequest = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getOSPolicyAssignmentReport with closed client', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getOSPolicyAssignmentReport(request), expectedError); + }); + }); + + describe('getInventory', () => { + it('invokes getInventory without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetInventoryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetInventoryRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.Inventory() + ); + client.innerApiCalls.getInventory = stubSimpleCall(expectedResponse); + const [response] = await client.getInventory(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInventory as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInventory as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInventory without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetInventoryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetInventoryRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.Inventory() + ); + client.innerApiCalls.getInventory = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInventory( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IInventory|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInventory as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInventory as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInventory with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetInventoryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetInventoryRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInventory = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getInventory(request), expectedError); + const actualRequest = (client.innerApiCalls.getInventory as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInventory as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInventory with closed client', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetInventoryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetInventoryRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getInventory(request), expectedError); + }); + }); + + describe('getVulnerabilityReport', () => { + it('invokes getVulnerabilityReport without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetVulnerabilityReportRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetVulnerabilityReportRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.VulnerabilityReport() + ); + client.innerApiCalls.getVulnerabilityReport = stubSimpleCall(expectedResponse); + const [response] = await client.getVulnerabilityReport(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getVulnerabilityReport as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getVulnerabilityReport as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getVulnerabilityReport without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetVulnerabilityReportRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetVulnerabilityReportRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1.VulnerabilityReport() + ); + client.innerApiCalls.getVulnerabilityReport = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getVulnerabilityReport( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IVulnerabilityReport|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getVulnerabilityReport as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getVulnerabilityReport as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getVulnerabilityReport with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetVulnerabilityReportRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetVulnerabilityReportRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getVulnerabilityReport = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getVulnerabilityReport(request), expectedError); + const actualRequest = (client.innerApiCalls.getVulnerabilityReport as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getVulnerabilityReport as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getVulnerabilityReport with closed client', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.GetVulnerabilityReportRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.GetVulnerabilityReportRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getVulnerabilityReport(request), expectedError); + }); + }); + + describe('createOSPolicyAssignment', () => { + it('invokes createOSPolicyAssignment without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createOsPolicyAssignment = stubLongRunningCall(expectedResponse); + const [operation] = await client.createOSPolicyAssignment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createOSPolicyAssignment without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createOsPolicyAssignment = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createOSPolicyAssignment( + request, + (err?: Error|null, + result?: 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.createOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createOSPolicyAssignment with call error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createOsPolicyAssignment = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createOSPolicyAssignment(request), expectedError); + const actualRequest = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createOSPolicyAssignment with LRO error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createOsPolicyAssignment = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createOSPolicyAssignment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateOSPolicyAssignmentProgress without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateOSPolicyAssignmentProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateOSPolicyAssignmentProgress with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateOSPolicyAssignmentProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateOSPolicyAssignment', () => { + it('invokes updateOSPolicyAssignment without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest() + ); + request.osPolicyAssignment ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest', ['osPolicyAssignment', 'name']); + request.osPolicyAssignment.name = defaultValue1; + const expectedHeaderRequestParams = `os_policy_assignment.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateOsPolicyAssignment = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateOSPolicyAssignment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateOSPolicyAssignment without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest() + ); + request.osPolicyAssignment ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest', ['osPolicyAssignment', 'name']); + request.osPolicyAssignment.name = defaultValue1; + const expectedHeaderRequestParams = `os_policy_assignment.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateOsPolicyAssignment = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateOSPolicyAssignment( + request, + (err?: Error|null, + result?: 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.updateOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateOSPolicyAssignment with call error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest() + ); + request.osPolicyAssignment ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest', ['osPolicyAssignment', 'name']); + request.osPolicyAssignment.name = defaultValue1; + const expectedHeaderRequestParams = `os_policy_assignment.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateOsPolicyAssignment = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateOSPolicyAssignment(request), expectedError); + const actualRequest = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateOSPolicyAssignment with LRO error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest() + ); + request.osPolicyAssignment ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest', ['osPolicyAssignment', 'name']); + request.osPolicyAssignment.name = defaultValue1; + const expectedHeaderRequestParams = `os_policy_assignment.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateOsPolicyAssignment = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateOSPolicyAssignment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateOSPolicyAssignmentProgress without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateOSPolicyAssignmentProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateOSPolicyAssignmentProgress with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateOSPolicyAssignmentProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteOSPolicyAssignment', () => { + it('invokes deleteOSPolicyAssignment without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteOsPolicyAssignment = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteOSPolicyAssignment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteOSPolicyAssignment without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteOsPolicyAssignment = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteOSPolicyAssignment( + request, + (err?: Error|null, + result?: 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.deleteOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteOSPolicyAssignment with call error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteOsPolicyAssignment = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteOSPolicyAssignment(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteOSPolicyAssignment with LRO error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteOsPolicyAssignment = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteOSPolicyAssignment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteOSPolicyAssignmentProgress without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteOSPolicyAssignmentProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteOSPolicyAssignmentProgress with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteOSPolicyAssignmentProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listOSPolicyAssignments', () => { + it('invokes listOSPolicyAssignments without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + ]; + client.innerApiCalls.listOsPolicyAssignments = stubSimpleCall(expectedResponse); + const [response] = await client.listOSPolicyAssignments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listOSPolicyAssignments without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + ]; + client.innerApiCalls.listOsPolicyAssignments = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listOSPolicyAssignments( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IOSPolicyAssignment[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listOSPolicyAssignments with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listOsPolicyAssignments = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listOSPolicyAssignments(request), expectedError); + const actualRequest = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listOSPolicyAssignmentsStream without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + ]; + client.descriptors.page.listOSPolicyAssignments.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listOSPolicyAssignmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1.OSPolicyAssignment[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1.OSPolicyAssignment) => { + 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.listOSPolicyAssignments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignments, request)); + assert( + (client.descriptors.page.listOSPolicyAssignments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listOSPolicyAssignmentsStream with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listOSPolicyAssignments.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listOSPolicyAssignmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1.OSPolicyAssignment[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1.OSPolicyAssignment) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listOSPolicyAssignments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignments, request)); + assert( + (client.descriptors.page.listOSPolicyAssignments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listOSPolicyAssignments without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + ]; + client.descriptors.page.listOSPolicyAssignments.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.osconfig.v1.IOSPolicyAssignment[] = []; + const iterable = client.listOSPolicyAssignmentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listOSPolicyAssignments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listOSPolicyAssignments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listOSPolicyAssignments with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listOSPolicyAssignments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listOSPolicyAssignmentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.osconfig.v1.IOSPolicyAssignment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listOSPolicyAssignments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listOSPolicyAssignments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listOSPolicyAssignmentRevisions', () => { + it('invokes listOSPolicyAssignmentRevisions without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + ]; + client.innerApiCalls.listOsPolicyAssignmentRevisions = stubSimpleCall(expectedResponse); + const [response] = await client.listOSPolicyAssignmentRevisions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listOSPolicyAssignmentRevisions without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + ]; + client.innerApiCalls.listOsPolicyAssignmentRevisions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listOSPolicyAssignmentRevisions( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IOSPolicyAssignment[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listOSPolicyAssignmentRevisions with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listOsPolicyAssignmentRevisions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listOSPolicyAssignmentRevisions(request), expectedError); + const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listOSPolicyAssignmentRevisionsStream without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + ]; + client.descriptors.page.listOSPolicyAssignmentRevisions.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listOSPolicyAssignmentRevisionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1.OSPolicyAssignment[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1.OSPolicyAssignment) => { + 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.listOSPolicyAssignmentRevisions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignmentRevisions, request)); + assert( + (client.descriptors.page.listOSPolicyAssignmentRevisions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listOSPolicyAssignmentRevisionsStream with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listOSPolicyAssignmentRevisions.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listOSPolicyAssignmentRevisionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1.OSPolicyAssignment[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1.OSPolicyAssignment) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listOSPolicyAssignmentRevisions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignmentRevisions, request)); + assert( + (client.descriptors.page.listOSPolicyAssignmentRevisions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listOSPolicyAssignmentRevisions without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), + ]; + client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.osconfig.v1.IOSPolicyAssignment[] = []; + const iterable = client.listOSPolicyAssignmentRevisionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listOSPolicyAssignmentRevisions with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listOSPolicyAssignmentRevisionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.osconfig.v1.IOSPolicyAssignment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listOSPolicyAssignmentReports', () => { + it('invokes listOSPolicyAssignmentReports without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), + ]; + client.innerApiCalls.listOsPolicyAssignmentReports = stubSimpleCall(expectedResponse); + const [response] = await client.listOSPolicyAssignmentReports(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listOSPolicyAssignmentReports without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), + ]; + client.innerApiCalls.listOsPolicyAssignmentReports = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listOSPolicyAssignmentReports( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listOSPolicyAssignmentReports with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listOsPolicyAssignmentReports = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listOSPolicyAssignmentReports(request), expectedError); + const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listOSPolicyAssignmentReportsStream without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), + ]; + client.descriptors.page.listOSPolicyAssignmentReports.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listOSPolicyAssignmentReportsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport) => { + 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.listOSPolicyAssignmentReports.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignmentReports, request)); + assert( + (client.descriptors.page.listOSPolicyAssignmentReports.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listOSPolicyAssignmentReportsStream with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listOSPolicyAssignmentReports.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listOSPolicyAssignmentReportsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listOSPolicyAssignmentReports.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignmentReports, request)); + assert( + (client.descriptors.page.listOSPolicyAssignmentReports.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listOSPolicyAssignmentReports without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), + ]; + client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport[] = []; + const iterable = client.listOSPolicyAssignmentReportsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listOSPolicyAssignmentReports with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listOSPolicyAssignmentReportsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listInventories', () => { + it('invokes listInventories without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListInventoriesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListInventoriesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), + ]; + client.innerApiCalls.listInventories = stubSimpleCall(expectedResponse); + const [response] = await client.listInventories(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInventories without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListInventoriesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListInventoriesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), + ]; + client.innerApiCalls.listInventories = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInventories( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IInventory[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInventories with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListInventoriesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListInventoriesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInventories = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listInventories(request), expectedError); + const actualRequest = (client.innerApiCalls.listInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInventoriesStream without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListInventoriesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListInventoriesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), + ]; + client.descriptors.page.listInventories.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listInventoriesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1.Inventory[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1.Inventory) => { + 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.listInventories.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInventories, request)); + assert( + (client.descriptors.page.listInventories.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listInventoriesStream with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListInventoriesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListInventoriesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInventories.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listInventoriesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1.Inventory[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1.Inventory) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listInventories.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInventories, request)); + assert( + (client.descriptors.page.listInventories.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInventories without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListInventoriesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListInventoriesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), + ]; + client.descriptors.page.listInventories.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.osconfig.v1.IInventory[] = []; + const iterable = client.listInventoriesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listInventories.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInventories.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInventories with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListInventoriesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListInventoriesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInventories.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInventoriesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.osconfig.v1.IInventory[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listInventories.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInventories.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listVulnerabilityReports', () => { + it('invokes listVulnerabilityReports without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), + ]; + client.innerApiCalls.listVulnerabilityReports = stubSimpleCall(expectedResponse); + const [response] = await client.listVulnerabilityReports(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listVulnerabilityReports as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listVulnerabilityReports as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listVulnerabilityReports without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), + ]; + client.innerApiCalls.listVulnerabilityReports = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listVulnerabilityReports( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IVulnerabilityReport[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listVulnerabilityReports as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listVulnerabilityReports as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listVulnerabilityReports with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listVulnerabilityReports = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listVulnerabilityReports(request), expectedError); + const actualRequest = (client.innerApiCalls.listVulnerabilityReports as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listVulnerabilityReports as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listVulnerabilityReportsStream without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), + ]; + client.descriptors.page.listVulnerabilityReports.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listVulnerabilityReportsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1.VulnerabilityReport[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1.VulnerabilityReport) => { + 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.listVulnerabilityReports.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listVulnerabilityReports, request)); + assert( + (client.descriptors.page.listVulnerabilityReports.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listVulnerabilityReportsStream with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listVulnerabilityReports.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listVulnerabilityReportsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1.VulnerabilityReport[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1.VulnerabilityReport) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listVulnerabilityReports.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listVulnerabilityReports, request)); + assert( + (client.descriptors.page.listVulnerabilityReports.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listVulnerabilityReports without error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), + ]; + client.descriptors.page.listVulnerabilityReports.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.osconfig.v1.IVulnerabilityReport[] = []; + const iterable = client.listVulnerabilityReportsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listVulnerabilityReports.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listVulnerabilityReports.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listVulnerabilityReports with error', async () => { + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listVulnerabilityReports.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listVulnerabilityReportsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.osconfig.v1.IVulnerabilityReport[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listVulnerabilityReports.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listVulnerabilityReports.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('inventory', () => { + const fakePath = "/rendered/path/inventory"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + instance: "instanceValue", + }; + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.inventoryPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.inventoryPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('inventoryPath', () => { + const result = client.inventoryPath("projectValue", "locationValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.inventoryPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromInventoryName', () => { + const result = client.matchProjectFromInventoryName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.inventoryPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromInventoryName', () => { + const result = client.matchLocationFromInventoryName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.inventoryPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromInventoryName', () => { + const result = client.matchInstanceFromInventoryName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.inventoryPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('oSPolicyAssignment', () => { + const fakePath = "/rendered/path/oSPolicyAssignment"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + os_policy_assignment: "osPolicyAssignmentValue", + }; + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.oSPolicyAssignmentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.oSPolicyAssignmentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('oSPolicyAssignmentPath', () => { + const result = client.oSPolicyAssignmentPath("projectValue", "locationValue", "osPolicyAssignmentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromOSPolicyAssignmentName', () => { + const result = client.matchProjectFromOSPolicyAssignmentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromOSPolicyAssignmentName', () => { + const result = client.matchLocationFromOSPolicyAssignmentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchOsPolicyAssignmentFromOSPolicyAssignmentName', () => { + const result = client.matchOsPolicyAssignmentFromOSPolicyAssignmentName(fakePath); + assert.strictEqual(result, "osPolicyAssignmentValue"); + assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('oSPolicyAssignmentReport', () => { + const fakePath = "/rendered/path/oSPolicyAssignmentReport"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + instance: "instanceValue", + assignment: "assignmentValue", + }; + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.oSPolicyAssignmentReportPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('oSPolicyAssignmentReportPath', () => { + const result = client.oSPolicyAssignmentReportPath("projectValue", "locationValue", "instanceValue", "assignmentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromOSPolicyAssignmentReportName', () => { + const result = client.matchProjectFromOSPolicyAssignmentReportName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromOSPolicyAssignmentReportName', () => { + const result = client.matchLocationFromOSPolicyAssignmentReportName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromOSPolicyAssignmentReportName', () => { + const result = client.matchInstanceFromOSPolicyAssignmentReportName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchAssignmentFromOSPolicyAssignmentReportName', () => { + const result = client.matchAssignmentFromOSPolicyAssignmentReportName(fakePath); + assert.strictEqual(result, "assignmentValue"); + assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('patchDeployment', () => { + const fakePath = "/rendered/path/patchDeployment"; + const expectedParameters = { + project: "projectValue", + patch_deployment: "patchDeploymentValue", + }; + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.patchDeploymentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.patchDeploymentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('patchDeploymentPath', () => { + const result = client.patchDeploymentPath("projectValue", "patchDeploymentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.patchDeploymentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromPatchDeploymentName', () => { + const result = client.matchProjectFromPatchDeploymentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.patchDeploymentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchPatchDeploymentFromPatchDeploymentName', () => { + const result = client.matchPatchDeploymentFromPatchDeploymentName(fakePath); + assert.strictEqual(result, "patchDeploymentValue"); + assert((client.pathTemplates.patchDeploymentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('patchJob', () => { + const fakePath = "/rendered/path/patchJob"; + const expectedParameters = { + project: "projectValue", + patch_job: "patchJobValue", + }; + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.patchJobPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.patchJobPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('patchJobPath', () => { + const result = client.patchJobPath("projectValue", "patchJobValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.patchJobPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromPatchJobName', () => { + const result = client.matchProjectFromPatchJobName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.patchJobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchPatchJobFromPatchJobName', () => { + const result = client.matchPatchJobFromPatchJobName(fakePath); + assert.strictEqual(result, "patchJobValue"); + assert((client.pathTemplates.patchJobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('vulnerabilityReport', () => { + const fakePath = "/rendered/path/vulnerabilityReport"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + instance: "instanceValue", + }; + const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.vulnerabilityReportPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.vulnerabilityReportPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('vulnerabilityReportPath', () => { + const result = client.vulnerabilityReportPath("projectValue", "locationValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.vulnerabilityReportPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromVulnerabilityReportName', () => { + const result = client.matchProjectFromVulnerabilityReportName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.vulnerabilityReportPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromVulnerabilityReportName', () => { + const result = client.matchLocationFromVulnerabilityReportName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.vulnerabilityReportPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromVulnerabilityReportName', () => { + const result = client.matchInstanceFromVulnerabilityReportName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.vulnerabilityReportPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/tsconfig.json b/owl-bot-staging/google-cloud-osconfig/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/webpack.config.js b/owl-bot-staging/google-cloud-osconfig/v1/webpack.config.js new file mode 100644 index 00000000000..72e295d47e7 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'OsConfigServiceClient', + filename: './os-config-service-client.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-osconfig/v1alpha/.eslintignore b/owl-bot-staging/google-cloud-osconfig/v1alpha/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/.eslintrc.json b/owl-bot-staging/google-cloud-osconfig/v1alpha/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/.gitignore b/owl-bot-staging/google-cloud-osconfig/v1alpha/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/.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-osconfig/v1alpha/.jsdoc.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/.jsdoc.js new file mode 100644 index 00000000000..8b2a0523a45 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/.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/os-config', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/.mocharc.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/.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-osconfig/v1alpha/.prettierrc.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/.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-osconfig/v1alpha/README.md b/owl-bot-staging/google-cloud-osconfig/v1alpha/README.md new file mode 100644 index 00000000000..94de5ca4cff --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/README.md @@ -0,0 +1 @@ +Osconfig: Nodejs Client diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/package.json b/owl-bot-staging/google-cloud-osconfig/v1alpha/package.json new file mode 100644 index 00000000000..d826e86c7ee --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/os-config", + "version": "0.1.0", + "description": "Osconfig client for Node.js", + "repository": "googleapis/nodejs-osconfig", + "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 osconfig", + "osconfig", + "os config zonal service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/config_common.proto b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/config_common.proto new file mode 100644 index 00000000000..2fe52e14a66 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/config_common.proto @@ -0,0 +1,133 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1alpha; + + +option csharp_namespace = "Google.Cloud.OsConfig.V1Alpha"; +option go_package = "cloud.google.com/go/osconfig/apiv1alpha/osconfigpb;osconfigpb"; +option java_multiple_files = true; +option java_outer_classname = "ConfigCommonProto"; +option java_package = "com.google.cloud.osconfig.v1alpha"; +option php_namespace = "Google\\Cloud\\OsConfig\\V1alpha"; +option ruby_package = "Google::Cloud::OsConfig::V1alpha"; + +// Step performed by the OS Config agent for configuring an `OSPolicyResource` +// to its desired state. +message OSPolicyResourceConfigStep { + option deprecated = true; + + // Supported configuration step types + enum Type { + option deprecated = true; + + // Default value. This value is unused. + TYPE_UNSPECIFIED = 0; + + // Validation to detect resource conflicts, schema errors, etc. + VALIDATION = 1; + + // Check the current desired state status of the resource. + DESIRED_STATE_CHECK = 2; + + // Enforce the desired state for a resource that is not in desired state. + DESIRED_STATE_ENFORCEMENT = 3; + + // Re-check desired state status for a resource after enforcement of all + // resources in the current configuration run. + // + // This step is used to determine the final desired state status for the + // resource. It accounts for any resources that might have drifted from + // their desired state due to side effects from configuring other resources + // during the current configuration run. + DESIRED_STATE_CHECK_POST_ENFORCEMENT = 4; + } + + // Supported outcomes for a configuration step. + enum Outcome { + option deprecated = true; + + // Default value. This value is unused. + OUTCOME_UNSPECIFIED = 0; + + // The step succeeded. + SUCCEEDED = 1; + + // The step failed. + FAILED = 2; + } + + // Configuration step type. + Type type = 1; + + // Outcome of the configuration step. + Outcome outcome = 2; + + // An error message recorded during the execution of this step. + // Only populated when outcome is FAILED. + string error_message = 3; +} + +// Compliance data for an OS policy resource. +message OSPolicyResourceCompliance { + option deprecated = true; + + // ExecResource specific output. + message ExecResourceOutput { + option deprecated = true; + + // Output from Enforcement phase output file (if run). + // Output size is limited to 100K bytes. + bytes enforcement_output = 2; + } + + // The id of the OS policy resource. + string os_policy_resource_id = 1; + + // Ordered list of configuration steps taken by the agent for the OS policy + // resource. + repeated OSPolicyResourceConfigStep config_steps = 2; + + // Compliance state of the OS policy resource. + OSPolicyComplianceState state = 3; + + // Resource specific output. + oneof output { + // ExecResource specific output. + ExecResourceOutput exec_resource_output = 4; + } +} + +// Supported OSPolicy compliance states. +enum OSPolicyComplianceState { + option deprecated = true; + + // Default value. This value is unused. + OS_POLICY_COMPLIANCE_STATE_UNSPECIFIED = 0; + + // Compliant state. + COMPLIANT = 1; + + // Non-compliant state + NON_COMPLIANT = 2; + + // Unknown compliance state. + UNKNOWN = 3; + + // No applicable OS policies were found for the instance. + // This state is only applicable to the instance. + NO_OS_POLICIES_APPLICABLE = 4; +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/instance_os_policies_compliance.proto b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/instance_os_policies_compliance.proto new file mode 100644 index 00000000000..0d6eafc7fa2 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/instance_os_policies_compliance.proto @@ -0,0 +1,182 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/osconfig/v1alpha/config_common.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.OsConfig.V1Alpha"; +option go_package = "cloud.google.com/go/osconfig/apiv1alpha/osconfigpb;osconfigpb"; +option java_multiple_files = true; +option java_outer_classname = "InstanceOSPoliciesComplianceProto"; +option java_package = "com.google.cloud.osconfig.v1alpha"; +option php_namespace = "Google\\Cloud\\OsConfig\\V1alpha"; +option ruby_package = "Google::Cloud::OsConfig::V1alpha"; + +// This API resource represents the OS policies compliance data for a Compute +// Engine virtual machine (VM) instance at a given point in time. +// +// A Compute Engine VM can have multiple OS policy assignments, and each +// assignment can have multiple OS policies. As a result, multiple OS policies +// could be applied to a single VM. +// +// You can use this API resource to determine both the compliance state of your +// VM as well as the compliance state of an individual OS policy. +// +// For more information, see [View +// compliance](https://cloud.google.com/compute/docs/os-configuration-management/view-compliance). +message InstanceOSPoliciesCompliance { + option deprecated = true; + option (google.api.resource) = { + type: "osconfig.googleapis.com/InstanceOSPoliciesCompliance" + pattern: "projects/{project}/locations/{location}/instanceOSPoliciesCompliances/{instance}" + }; + + // Compliance data for an OS policy + message OSPolicyCompliance { + option deprecated = true; + + // The OS policy id + string os_policy_id = 1; + + // Reference to the `OSPolicyAssignment` API resource that the `OSPolicy` + // belongs to. + // + // Format: + // `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id@revision_id}` + string os_policy_assignment = 2 [(google.api.resource_reference) = { + type: "osconfig.googleapis.com/OSPolicyAssignment" + }]; + + // Compliance state of the OS policy. + OSPolicyComplianceState state = 4; + + // Compliance data for each `OSPolicyResource` that is applied to the + // VM. + repeated OSPolicyResourceCompliance os_policy_resource_compliances = 5; + } + + // Output only. The `InstanceOSPoliciesCompliance` API resource name. + // + // Format: + // `projects/{project_number}/locations/{location}/instanceOSPoliciesCompliances/{instance_id}` + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Compute Engine VM instance name. + string instance = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Compliance state of the VM. + OSPolicyComplianceState state = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Detailed compliance state of the VM. + // This field is populated only when compliance state is `UNKNOWN`. + // + // It may contain one of the following values: + // + // * `no-compliance-data`: Compliance data is not available for this VM. + // * `no-agent-detected`: OS Config agent is not detected for this VM. + // * `config-not-supported-by-agent`: The version of the OS Config agent + // running on this VM does not support configuration management. + // * `inactive`: VM is not running. + // * `internal-service-errors`: There were internal service errors encountered + // while enforcing compliance. + // * `agent-errors`: OS config agent encountered errors while enforcing + // compliance. + string detailed_state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The reason for the `detailed_state` of the VM (if any). + string detailed_state_reason = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Compliance data for each `OSPolicy` that is applied to the VM. + repeated OSPolicyCompliance os_policy_compliances = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp of the last compliance check for the VM. + google.protobuf.Timestamp last_compliance_check_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Unique identifier for the last compliance run. + // This id will be logged by the OS config agent during a compliance run and + // can be used for debugging and tracing purpose. + string last_compliance_run_id = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A request message for getting OS policies compliance data for the given +// Compute Engine VM instance. +message GetInstanceOSPoliciesComplianceRequest { + option deprecated = true; + + // Required. API resource name for instance OS policies compliance resource. + // + // Format: + // `projects/{project}/locations/{location}/instanceOSPoliciesCompliances/{instance}` + // + // For `{project}`, either Compute Engine project-number or project-id can be + // provided. + // For `{instance}`, either Compute Engine VM instance-id or instance-name can + // be provided. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/InstanceOSPoliciesCompliance" + } + ]; +} + +// A request message for listing OS policies compliance data for all Compute +// Engine VMs in the given location. +message ListInstanceOSPoliciesCompliancesRequest { + option deprecated = true; + + // Required. The parent resource name. + // + // Format: `projects/{project}/locations/{location}` + // + // For `{project}`, either Compute Engine project-number or project-id can be + // provided. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of results to return. + int32 page_size = 2; + + // A pagination token returned from a previous call to + // `ListInstanceOSPoliciesCompliances` that indicates where this listing + // should continue from. + string page_token = 3; + + // If provided, this field specifies the criteria that must be met by a + // `InstanceOSPoliciesCompliance` API resource to be included in the response. + string filter = 4; +} + +// A response message for listing OS policies compliance data for all Compute +// Engine VMs in the given location. +message ListInstanceOSPoliciesCompliancesResponse { + option deprecated = true; + + // List of instance OS policies compliance objects. + repeated InstanceOSPoliciesCompliance instance_os_policies_compliances = 1; + + // The pagination token to retrieve the next page of instance OS policies + // compliance objects. + string next_page_token = 2; +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/inventory.proto b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/inventory.proto new file mode 100644 index 00000000000..a63416ae1a6 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/inventory.proto @@ -0,0 +1,383 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/date.proto"; + +option csharp_namespace = "Google.Cloud.OsConfig.V1Alpha"; +option go_package = "cloud.google.com/go/osconfig/apiv1alpha/osconfigpb;osconfigpb"; +option java_multiple_files = true; +option java_outer_classname = "Inventories"; +option java_package = "com.google.cloud.osconfig.v1alpha"; +option php_namespace = "Google\\Cloud\\OsConfig\\V1alpha"; +option ruby_package = "Google::Cloud::OsConfig::V1alpha"; + +// OS Inventory is a service for collecting and reporting operating +// system and package information on VM instances. + +// This API resource represents the available inventory data for a +// Compute Engine virtual machine (VM) instance at a given point in time. +// +// You can use this API resource to determine the inventory data of your VM. +// +// For more information, see [Information provided by OS inventory +// management](https://cloud.google.com/compute/docs/instances/os-inventory-management#data-collected). +message Inventory { + option (google.api.resource) = { + type: "osconfig.googleapis.com/Inventory" + pattern: "projects/{project}/locations/{location}/instances/{instance}/inventory" + }; + + // Operating system information for the VM. + message OsInfo { + // The VM hostname. + string hostname = 9; + + // The operating system long name. + // For example 'Debian GNU/Linux 9' or 'Microsoft Window Server 2019 + // Datacenter'. + string long_name = 2; + + // The operating system short name. + // For example, 'windows' or 'debian'. + string short_name = 3; + + // The version of the operating system. + string version = 4; + + // The system architecture of the operating system. + string architecture = 5; + + // The kernel version of the operating system. + string kernel_version = 6; + + // The kernel release of the operating system. + string kernel_release = 7; + + // The current version of the OS Config agent running on the VM. + string osconfig_agent_version = 8; + } + + // A single piece of inventory on a VM. + message Item { + // The origin of a specific inventory item. + enum OriginType { + // Invalid. An origin type must be specified. + ORIGIN_TYPE_UNSPECIFIED = 0; + + // This inventory item was discovered as the result of the agent + // reporting inventory via the reporting API. + INVENTORY_REPORT = 1; + } + + // The different types of inventory that are tracked on a VM. + enum Type { + // Invalid. An type must be specified. + TYPE_UNSPECIFIED = 0; + + // This represents a package that is installed on the VM. + INSTALLED_PACKAGE = 1; + + // This represents an update that is available for a package. + AVAILABLE_PACKAGE = 2; + } + + // Identifier for this item, unique across items for this VM. + string id = 1; + + // The origin of this inventory item. + OriginType origin_type = 2; + + // When this inventory item was first detected. + google.protobuf.Timestamp create_time = 8; + + // When this inventory item was last modified. + google.protobuf.Timestamp update_time = 9; + + // The specific type of inventory, correlating to its specific details. + Type type = 5; + + // Specific details of this inventory item based on its type. + oneof details { + // Software package present on the VM instance. + SoftwarePackage installed_package = 6; + + // Software package available to be installed on the VM instance. + SoftwarePackage available_package = 7; + } + } + + // Software package information of the operating system. + message SoftwarePackage { + // Information about the different types of software packages. + oneof details { + // Yum package info. + // For details about the yum package manager, see + // https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/ch-yum. + VersionedPackage yum_package = 1; + + // Details of an APT package. + // For details about the apt package manager, see + // https://wiki.debian.org/Apt. + VersionedPackage apt_package = 2; + + // Details of a Zypper package. + // For details about the Zypper package manager, see + // https://en.opensuse.org/SDB:Zypper_manual. + VersionedPackage zypper_package = 3; + + // Details of a Googet package. + // For details about the googet package manager, see + // https://github.com/google/googet. + VersionedPackage googet_package = 4; + + // Details of a Zypper patch. + // For details about the Zypper package manager, see + // https://en.opensuse.org/SDB:Zypper_manual. + ZypperPatch zypper_patch = 5; + + // Details of a Windows Update package. + // See https://docs.microsoft.com/en-us/windows/win32/api/_wua/ for + // information about Windows Update. + WindowsUpdatePackage wua_package = 6; + + // Details of a Windows Quick Fix engineering package. + // See + // https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-quickfixengineering + // for info in Windows Quick Fix Engineering. + WindowsQuickFixEngineeringPackage qfe_package = 7; + + // Details of a COS package. + VersionedPackage cos_package = 8; + + // Details of Windows Application. + WindowsApplication windows_application = 9; + } + } + + // Information related to the a standard versioned package. This includes + // package info for APT, Yum, Zypper, and Googet package managers. + message VersionedPackage { + // The name of the package. + string package_name = 4; + + // The system architecture this package is intended for. + string architecture = 2; + + // The version of the package. + string version = 3; + } + + // Details related to a Zypper Patch. + message ZypperPatch { + // The name of the patch. + string patch_name = 5; + + // The category of the patch. + string category = 2; + + // The severity specified for this patch + string severity = 3; + + // Any summary information provided about this patch. + string summary = 4; + } + + // Details related to a Windows Update package. + // Field data and names are taken from Windows Update API IUpdate Interface: + // https://docs.microsoft.com/en-us/windows/win32/api/_wua/ + // Descriptive fields like title, and description are localized based on + // the locale of the VM being updated. + message WindowsUpdatePackage { + // Categories specified by the Windows Update. + message WindowsUpdateCategory { + // The identifier of the windows update category. + string id = 1; + + // The name of the windows update category. + string name = 2; + } + + // The localized title of the update package. + string title = 1; + + // The localized description of the update package. + string description = 2; + + // The categories that are associated with this update package. + repeated WindowsUpdateCategory categories = 3; + + // A collection of Microsoft Knowledge Base article IDs that are associated + // with the update package. + repeated string kb_article_ids = 4; + + // A hyperlink to the language-specific support information for the update. + string support_url = 11; + + // A collection of URLs that provide more information about the update + // package. + repeated string more_info_urls = 5; + + // Gets the identifier of an update package. Stays the same across + // revisions. + string update_id = 6; + + // The revision number of this update package. + int32 revision_number = 7; + + // The last published date of the update, in (UTC) date and time. + google.protobuf.Timestamp last_deployment_change_time = 10; + } + + // Information related to a Quick Fix Engineering package. + // Fields are taken from Windows QuickFixEngineering Interface and match + // the source names: + // https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-quickfixengineering + message WindowsQuickFixEngineeringPackage { + // A short textual description of the QFE update. + string caption = 1; + + // A textual description of the QFE update. + string description = 2; + + // Unique identifier associated with a particular QFE update. + string hot_fix_id = 3; + + // Date that the QFE update was installed. Mapped from installed_on field. + google.protobuf.Timestamp install_time = 5; + } + + // Contains information about a Windows application that is retrieved from the + // Windows Registry. For more information about these fields, see: + // https://docs.microsoft.com/en-us/windows/win32/msi/uninstall-registry-key + message WindowsApplication { + // The name of the application or product. + string display_name = 1; + + // The version of the product or application in string format. + string display_version = 2; + + // The name of the manufacturer for the product or application. + string publisher = 3; + + // The last time this product received service. The value of this property + // is replaced each time a patch is applied or removed from the product or + // the command-line option is used to repair the product. + google.type.Date install_date = 4; + + // The internet address for technical support. + string help_link = 5; + } + + // Output only. The `Inventory` API resource name. + // + // Format: + // `projects/{project_number}/locations/{location}/instances/{instance_id}/inventory` + string name = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Base level operating system information for the VM. + OsInfo os_info = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Inventory items related to the VM keyed by an opaque unique identifier for + // each inventory item. The identifier is unique to each distinct and + // addressable inventory item and will change, when there is a new package + // version. + map items = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp of the last reported inventory for the VM. + google.protobuf.Timestamp update_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A request message for getting inventory data for the specified VM. +message GetInventoryRequest { + // Required. API resource name for inventory resource. + // + // Format: + // `projects/{project}/locations/{location}/instances/{instance}/inventory` + // + // For `{project}`, either `project-number` or `project-id` can be provided. + // For `{instance}`, either Compute Engine `instance-id` or `instance-name` + // can be provided. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/Inventory" + } + ]; + + // Inventory view indicating what information should be included in the + // inventory resource. If unspecified, the default view is BASIC. + InventoryView view = 2; +} + +// A request message for listing inventory data for all VMs in the specified +// location. +message ListInventoriesRequest { + // Required. The parent resource name. + // + // Format: `projects/{project}/locations/{location}/instances/-` + // + // For `{project}`, either `project-number` or `project-id` can be provided. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "compute.googleapis.com/Instance" + } + ]; + + // Inventory view indicating what information should be included in the + // inventory resource. If unspecified, the default view is BASIC. + InventoryView view = 2; + + // The maximum number of results to return. + int32 page_size = 3; + + // A pagination token returned from a previous call to + // `ListInventories` that indicates where this listing + // should continue from. + string page_token = 4; + + // If provided, this field specifies the criteria that must be met by a + // `Inventory` API resource to be included in the response. + string filter = 5; +} + +// A response message for listing inventory data for all VMs in a specified +// location. +message ListInventoriesResponse { + // List of inventory objects. + repeated Inventory inventories = 1; + + // The pagination token to retrieve the next page of inventory objects. + string next_page_token = 2; +} + +// The view for inventory objects. +enum InventoryView { + // The default value. + // The API defaults to the BASIC view. + INVENTORY_VIEW_UNSPECIFIED = 0; + + // Returns the basic inventory information that includes `os_info`. + BASIC = 1; + + // Returns all fields. + FULL = 2; +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy.proto b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy.proto new file mode 100644 index 00000000000..f822ecb4cee --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy.proto @@ -0,0 +1,565 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1alpha; + +import "google/api/field_behavior.proto"; + +option csharp_namespace = "Google.Cloud.OsConfig.V1Alpha"; +option go_package = "cloud.google.com/go/osconfig/apiv1alpha/osconfigpb;osconfigpb"; +option java_multiple_files = true; +option java_outer_classname = "OsPolicyProto"; +option java_package = "com.google.cloud.osconfig.v1alpha"; +option php_namespace = "Google\\Cloud\\OsConfig\\V1alpha"; +option ruby_package = "Google::Cloud::OsConfig::V1alpha"; + +// An OS policy defines the desired state configuration for a VM. +message OSPolicy { + // Policy mode + enum Mode { + // Invalid mode + MODE_UNSPECIFIED = 0; + + // This mode checks if the configuration resources in the policy are in + // their desired state. No actions are performed if they are not in the + // desired state. This mode is used for reporting purposes. + VALIDATION = 1; + + // This mode checks if the configuration resources in the policy are in + // their desired state, and if not, enforces the desired state. + ENFORCEMENT = 2; + } + + // Filtering criteria to select VMs based on OS details. + message OSFilter { + // This should match OS short name emitted by the OS inventory agent. + // An empty value matches any OS. + string os_short_name = 1; + + // This value should match the version emitted by the OS inventory + // agent. + // Prefix matches are supported if asterisk(*) is provided as the + // last character. For example, to match all versions with a major + // version of `7`, specify the following value for this field `7.*` + string os_version = 2; + } + + // Filtering criteria to select VMs based on inventory details. + message InventoryFilter { + // Required. The OS short name + string os_short_name = 1 [(google.api.field_behavior) = REQUIRED]; + + // The OS version + // + // Prefix matches are supported if asterisk(*) is provided as the + // last character. For example, to match all versions with a major + // version of `7`, specify the following value for this field `7.*` + // + // An empty string matches all OS versions. + string os_version = 2; + } + + // An OS policy resource is used to define the desired state configuration + // and provides a specific functionality like installing/removing packages, + // executing a script etc. + // + // The system ensures that resources are always in their desired state by + // taking necessary actions if they have drifted from their desired state. + message Resource { + // A remote or local file. + message File { + // Specifies a file available via some URI. + message Remote { + // Required. URI from which to fetch the object. It should contain both the + // protocol and path following the format `{protocol}://{location}`. + string uri = 1 [(google.api.field_behavior) = REQUIRED]; + + // SHA256 checksum of the remote file. + string sha256_checksum = 2; + } + + // Specifies a file available as a Cloud Storage Object. + message Gcs { + // Required. Bucket of the Cloud Storage object. + string bucket = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Name of the Cloud Storage object. + string object = 2 [(google.api.field_behavior) = REQUIRED]; + + // Generation number of the Cloud Storage object. + int64 generation = 3; + } + + // A specific type of file. + oneof type { + // A generic remote file. + Remote remote = 1; + + // A Cloud Storage object. + Gcs gcs = 2; + + // A local path within the VM to use. + string local_path = 3; + } + + // Defaults to false. When false, files are subject to validations + // based on the file type: + // + // Remote: A checksum must be specified. + // Cloud Storage: An object generation number must be specified. + bool allow_insecure = 4; + } + + // A resource that manages a system package. + message PackageResource { + // The desired state that the OS Config agent maintains on the VM. + enum DesiredState { + // Unspecified is invalid. + DESIRED_STATE_UNSPECIFIED = 0; + + // Ensure that the package is installed. + INSTALLED = 1; + + // The agent ensures that the package is not installed and + // uninstalls it if detected. + REMOVED = 2; + } + + // A deb package file. dpkg packages only support INSTALLED state. + message Deb { + // Required. A deb package. + File source = 1 [(google.api.field_behavior) = REQUIRED]; + + // Whether dependencies should also be installed. + // - install when false: `dpkg -i package` + // - install when true: `apt-get update && apt-get -y install + // package.deb` + bool pull_deps = 2; + } + + // A package managed by APT. + // - install: `apt-get update && apt-get -y install [name]` + // - remove: `apt-get -y remove [name]` + message APT { + // Required. Package name. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + } + + // An RPM package file. RPM packages only support INSTALLED state. + message RPM { + // Required. An rpm package. + File source = 1 [(google.api.field_behavior) = REQUIRED]; + + // Whether dependencies should also be installed. + // - install when false: `rpm --upgrade --replacepkgs package.rpm` + // - install when true: `yum -y install package.rpm` or + // `zypper -y install package.rpm` + bool pull_deps = 2; + } + + // A package managed by YUM. + // - install: `yum -y install package` + // - remove: `yum -y remove package` + message YUM { + // Required. Package name. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + } + + // A package managed by Zypper. + // - install: `zypper -y install package` + // - remove: `zypper -y rm package` + message Zypper { + // Required. Package name. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + } + + // A package managed by GooGet. + // - install: `googet -noconfirm install package` + // - remove: `googet -noconfirm remove package` + message GooGet { + // Required. Package name. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + } + + // An MSI package. MSI packages only support INSTALLED state. + message MSI { + // Required. The MSI package. + File source = 1 [(google.api.field_behavior) = REQUIRED]; + + // Additional properties to use during installation. + // This should be in the format of Property=Setting. + // Appended to the defaults of `ACTION=INSTALL + // REBOOT=ReallySuppress`. + repeated string properties = 2; + } + + // Required. The desired state the agent should maintain for this package. + DesiredState desired_state = 1 [(google.api.field_behavior) = REQUIRED]; + + // A system package. + oneof system_package { + // A package managed by Apt. + APT apt = 2; + + // A deb package file. + Deb deb = 3; + + // A package managed by YUM. + YUM yum = 4; + + // A package managed by Zypper. + Zypper zypper = 5; + + // An rpm package file. + RPM rpm = 6; + + // A package managed by GooGet. + GooGet googet = 7; + + // An MSI package. + MSI msi = 8; + } + } + + // A resource that manages a package repository. + message RepositoryResource { + // Represents a single apt package repository. These will be added to + // a repo file that will be managed at + // `/etc/apt/sources.list.d/google_osconfig.list`. + message AptRepository { + // Type of archive. + enum ArchiveType { + // Unspecified is invalid. + ARCHIVE_TYPE_UNSPECIFIED = 0; + + // Deb indicates that the archive contains binary files. + DEB = 1; + + // Deb-src indicates that the archive contains source files. + DEB_SRC = 2; + } + + // Required. Type of archive files in this repository. + ArchiveType archive_type = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. URI for this repository. + string uri = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. Distribution of this repository. + string distribution = 3 [(google.api.field_behavior) = REQUIRED]; + + // Required. List of components for this repository. Must contain at least one + // item. + repeated string components = 4 [(google.api.field_behavior) = REQUIRED]; + + // URI of the key file for this repository. The agent maintains a + // keyring at `/etc/apt/trusted.gpg.d/osconfig_agent_managed.gpg`. + string gpg_key = 5; + } + + // Represents a single yum package repository. These are added to a + // repo file that is managed at + // `/etc/yum.repos.d/google_osconfig.repo`. + message YumRepository { + // Required. A one word, unique name for this repository. This is the `repo + // id` in the yum config file and also the `display_name` if + // `display_name` is omitted. This id is also used as the unique + // identifier when checking for resource conflicts. + string id = 1 [(google.api.field_behavior) = REQUIRED]; + + // The display name of the repository. + string display_name = 2; + + // Required. The location of the repository directory. + string base_url = 3 [(google.api.field_behavior) = REQUIRED]; + + // URIs of GPG keys. + repeated string gpg_keys = 4; + } + + // Represents a single zypper package repository. These are added to a + // repo file that is managed at + // `/etc/zypp/repos.d/google_osconfig.repo`. + message ZypperRepository { + // Required. A one word, unique name for this repository. This is the `repo + // id` in the zypper config file and also the `display_name` if + // `display_name` is omitted. This id is also used as the unique + // identifier when checking for GuestPolicy conflicts. + string id = 1 [(google.api.field_behavior) = REQUIRED]; + + // The display name of the repository. + string display_name = 2; + + // Required. The location of the repository directory. + string base_url = 3 [(google.api.field_behavior) = REQUIRED]; + + // URIs of GPG keys. + repeated string gpg_keys = 4; + } + + // Represents a Goo package repository. These are added to a repo file + // that is managed at + // `C:/ProgramData/GooGet/repos/google_osconfig.repo`. + message GooRepository { + // Required. The name of the repository. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The url of the repository. + string url = 2 [(google.api.field_behavior) = REQUIRED]; + } + + // A specific type of repository. + oneof repository { + // An Apt Repository. + AptRepository apt = 1; + + // A Yum Repository. + YumRepository yum = 2; + + // A Zypper Repository. + ZypperRepository zypper = 3; + + // A Goo Repository. + GooRepository goo = 4; + } + } + + // A resource that allows executing scripts on the VM. + // + // The `ExecResource` has 2 stages: `validate` and `enforce` and both stages + // accept a script as an argument to execute. + // + // When the `ExecResource` is applied by the agent, it first executes the + // script in the `validate` stage. The `validate` stage can signal that the + // `ExecResource` is already in the desired state by returning an exit code + // of `100`. If the `ExecResource` is not in the desired state, it should + // return an exit code of `101`. Any other exit code returned by this stage + // is considered an error. + // + // If the `ExecResource` is not in the desired state based on the exit code + // from the `validate` stage, the agent proceeds to execute the script from + // the `enforce` stage. If the `ExecResource` is already in the desired + // state, the `enforce` stage will not be run. + // Similar to `validate` stage, the `enforce` stage should return an exit + // code of `100` to indicate that the resource in now in its desired state. + // Any other exit code is considered an error. + // + // NOTE: An exit code of `100` was chosen over `0` (and `101` vs `1`) to + // have an explicit indicator of `in desired state`, `not in desired state` + // and errors. Because, for example, Powershell will always return an exit + // code of `0` unless an `exit` statement is provided in the script. So, for + // reasons of consistency and being explicit, exit codes `100` and `101` + // were chosen. + message ExecResource { + // A file or script to execute. + message Exec { + // The interpreter to use. + enum Interpreter { + // Invalid value, the request will return validation error. + INTERPRETER_UNSPECIFIED = 0; + + // If an interpreter is not specified, the + // source is executed directly. This execution, without an + // interpreter, only succeeds for executables and scripts that have shebang lines. + NONE = 1; + + // Indicates that the script runs with `/bin/sh` on Linux and + // `cmd.exe` on Windows. + SHELL = 2; + + // Indicates that the script runs with PowerShell. + POWERSHELL = 3; + } + + // What to execute. + oneof source { + // A remote or local file. + File file = 1; + + // An inline script. + // The size of the script is limited to 1024 characters. + string script = 2; + } + + // Optional arguments to pass to the source during execution. + repeated string args = 3; + + // Required. The script interpreter to use. + Interpreter interpreter = 4 [(google.api.field_behavior) = REQUIRED]; + + // Only recorded for enforce Exec. + // Path to an output file (that is created by this Exec) whose + // content will be recorded in OSPolicyResourceCompliance after a + // successful run. Absence or failure to read this file will result in + // this ExecResource being non-compliant. Output file size is limited to + // 100K bytes. + string output_file_path = 5; + } + + // Required. What to run to validate this resource is in the desired state. + // An exit code of 100 indicates "in desired state", and exit code of 101 + // indicates "not in desired state". Any other exit code indicates a + // failure running validate. + Exec validate = 1 [(google.api.field_behavior) = REQUIRED]; + + // What to run to bring this resource into the desired state. + // An exit code of 100 indicates "success", any other exit code indicates + // a failure running enforce. + Exec enforce = 2; + } + + // A resource that manages the state of a file. + message FileResource { + // Desired state of the file. + enum DesiredState { + // Unspecified is invalid. + DESIRED_STATE_UNSPECIFIED = 0; + + // Ensure file at path is present. + PRESENT = 1; + + // Ensure file at path is absent. + ABSENT = 2; + + // Ensure the contents of the file at path matches. If the file does + // not exist it will be created. + CONTENTS_MATCH = 3; + } + + // The source for the contents of the file. + oneof source { + // A remote or local source. + File file = 1; + + // A a file with this content. + // The size of the content is limited to 1024 characters. + string content = 2; + } + + // Required. The absolute path of the file within the VM. + string path = 3 [(google.api.field_behavior) = REQUIRED]; + + // Required. Desired state of the file. + DesiredState state = 4 [(google.api.field_behavior) = REQUIRED]; + + // Consists of three octal digits which represent, in + // order, the permissions of the owner, group, and other users for the + // file (similarly to the numeric mode used in the linux chmod + // utility). Each digit represents a three bit number with the 4 bit + // corresponding to the read permissions, the 2 bit corresponds to the + // write bit, and the one bit corresponds to the execute permission. + // Default behavior is 755. + // + // Below are some examples of permissions and their associated values: + // read, write, and execute: 7 + // read and execute: 5 + // read and write: 6 + // read only: 4 + string permissions = 5; + } + + // Required. The id of the resource with the following restrictions: + // + // * Must contain only lowercase letters, numbers, and hyphens. + // * Must start with a letter. + // * Must be between 1-63 characters. + // * Must end with a number or a letter. + // * Must be unique within the OS policy. + string id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Resource type. + oneof resource_type { + // Package resource + PackageResource pkg = 2; + + // Package repository resource + RepositoryResource repository = 3; + + // Exec resource + ExecResource exec = 4; + + // File resource + FileResource file = 5; + } + } + + // Resource groups provide a mechanism to group OS policy resources. + // + // Resource groups enable OS policy authors to create a single OS policy + // to be applied to VMs running different operating Systems. + // + // When the OS policy is applied to a target VM, the appropriate resource + // group within the OS policy is selected based on the `OSFilter` specified + // within the resource group. + message ResourceGroup { + // Deprecated. Use the `inventory_filters` field instead. + // Used to specify the OS filter for a resource group + OSFilter os_filter = 1 [deprecated = true]; + + // List of inventory filters for the resource group. + // + // The resources in this resource group are applied to the target VM if it + // satisfies at least one of the following inventory filters. + // + // For example, to apply this resource group to VMs running either `RHEL` or + // `CentOS` operating systems, specify 2 items for the list with following + // values: + // inventory_filters[0].os_short_name='rhel' and + // inventory_filters[1].os_short_name='centos' + // + // If the list is empty, this resource group will be applied to the target + // VM unconditionally. + repeated InventoryFilter inventory_filters = 3; + + // Required. List of resources configured for this resource group. + // The resources are executed in the exact order specified here. + repeated Resource resources = 2 [(google.api.field_behavior) = REQUIRED]; + } + + // Required. The id of the OS policy with the following restrictions: + // + // * Must contain only lowercase letters, numbers, and hyphens. + // * Must start with a letter. + // * Must be between 1-63 characters. + // * Must end with a number or a letter. + // * Must be unique within the assignment. + string id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Policy description. + // Length of the description is limited to 1024 characters. + string description = 2; + + // Required. Policy mode + Mode mode = 3 [(google.api.field_behavior) = REQUIRED]; + + // Required. List of resource groups for the policy. + // For a particular VM, resource groups are evaluated in the order specified + // and the first resource group that is applicable is selected and the rest + // are ignored. + // + // If none of the resource groups are applicable for a VM, the VM is + // considered to be non-compliant w.r.t this policy. This behavior can be + // toggled by the flag `allow_no_resource_group_match` + repeated ResourceGroup resource_groups = 4 [(google.api.field_behavior) = REQUIRED]; + + // This flag determines the OS policy compliance status when none of the + // resource groups within the policy are applicable for a VM. Set this value + // to `true` if the policy needs to be reported as compliant even if the + // policy has nothing to validate or enforce. + bool allow_no_resource_group_match = 5; +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy_assignment_reports.proto b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy_assignment_reports.proto new file mode 100644 index 00000000000..6b00fb9e0ca --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy_assignment_reports.proto @@ -0,0 +1,296 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.OsConfig.V1Alpha"; +option go_package = "cloud.google.com/go/osconfig/apiv1alpha/osconfigpb;osconfigpb"; +option java_multiple_files = true; +option java_outer_classname = "OSPolicyAssignmentReportsProto"; +option java_package = "com.google.cloud.osconfig.v1alpha"; +option php_namespace = "Google\\Cloud\\OsConfig\\V1alpha"; +option ruby_package = "Google::Cloud::OsConfig::V1alpha"; +option (google.api.resource_definition) = { + type: "compute.googleapis.com/InstanceOSPolicyAssignment" + pattern: "projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}" +}; + +// Get a report of the OS policy assignment for a VM instance. +message GetOSPolicyAssignmentReportRequest { + // Required. API resource name for OS policy assignment report. + // + // Format: + // `/projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report` + // + // For `{project}`, either `project-number` or `project-id` can be provided. + // For `{instance_id}`, either Compute Engine `instance-id` or `instance-name` + // can be provided. + // For `{assignment_id}`, the OSPolicyAssignment id must be provided. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/OSPolicyAssignmentReport" + } + ]; +} + +// List the OS policy assignment reports for VM instances. +message ListOSPolicyAssignmentReportsRequest { + // Required. The parent resource name. + // + // Format: + // `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/reports` + // + // For `{project}`, either `project-number` or `project-id` can be provided. + // For `{instance}`, either `instance-name`, `instance-id`, or `-` can be + // provided. If '-' is provided, the response will include + // OSPolicyAssignmentReports for all instances in the project/location. + // For `{assignment}`, either `assignment-id` or `-` can be provided. If '-' + // is provided, the response will include OSPolicyAssignmentReports for all + // OSPolicyAssignments in the project/location. + // Either {instance} or {assignment} must be `-`. + // + // For example: + // `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/-/reports` + // returns all reports for the instance + // `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/{assignment-id}/reports` + // returns all the reports for the given assignment across all instances. + // `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/-/reports` + // returns all the reports for all assignments across all instances. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "compute.googleapis.com/InstanceOSPolicyAssignment" + } + ]; + + // The maximum number of results to return. + int32 page_size = 2; + + // If provided, this field specifies the criteria that must be met by the + // `OSPolicyAssignmentReport` API resource that is included in the response. + string filter = 3; + + // A pagination token returned from a previous call to the + // `ListOSPolicyAssignmentReports` method that indicates where this listing + // should continue from. + string page_token = 4; +} + +// A response message for listing OS Policy assignment reports including the +// page of results and page token. +message ListOSPolicyAssignmentReportsResponse { + // List of OS policy assignment reports. + repeated OSPolicyAssignmentReport os_policy_assignment_reports = 1; + + // The pagination token to retrieve the next page of OS policy assignment + // report objects. + string next_page_token = 2; +} + +// A report of the OS policy assignment status for a given instance. +message OSPolicyAssignmentReport { + option (google.api.resource) = { + type: "osconfig.googleapis.com/OSPolicyAssignmentReport" + pattern: "projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report" + }; + + // Compliance data for an OS policy + message OSPolicyCompliance { + // Possible compliance states for an os policy. + enum ComplianceState { + // The policy is in an unknown compliance state. + // + // Refer to the field `compliance_state_reason` to learn the exact reason + // for the policy to be in this compliance state. + UNKNOWN = 0; + + // Policy is compliant. + // + // The policy is compliant if all the underlying resources are also + // compliant. + COMPLIANT = 1; + + // Policy is non-compliant. + // + // The policy is non-compliant if one or more underlying resources are + // non-compliant. + NON_COMPLIANT = 2; + } + + // Compliance data for an OS policy resource. + message OSPolicyResourceCompliance { + // Step performed by the OS Config agent for configuring an + // `OSPolicy` resource to its desired state. + message OSPolicyResourceConfigStep { + // Supported configuration step types + enum Type { + // Default value. This value is unused. + TYPE_UNSPECIFIED = 0; + + // Checks for resource conflicts such as schema errors. + VALIDATION = 1; + + // Checks the current status of the desired state for a resource. + DESIRED_STATE_CHECK = 2; + + // Enforces the desired state for a resource that is not in desired + // state. + DESIRED_STATE_ENFORCEMENT = 3; + + // Re-checks the status of the desired state. This check is done + // for a resource after the enforcement of all OS policies. + // + // This step is used to determine the final desired state status for + // the resource. It accounts for any resources that might have drifted + // from their desired state due to side effects from executing other + // resources. + DESIRED_STATE_CHECK_POST_ENFORCEMENT = 4; + } + + // Configuration step type. + Type type = 1; + + // An error message recorded during the execution of this step. + // Only populated if errors were encountered during this step execution. + string error_message = 2; + } + + // Possible compliance states for a resource. + enum ComplianceState { + // The resource is in an unknown compliance state. + // + // To get more details about why the policy is in this state, review + // the output of the `compliance_state_reason` field. + UNKNOWN = 0; + + // Resource is compliant. + COMPLIANT = 1; + + // Resource is non-compliant. + NON_COMPLIANT = 2; + } + + // ExecResource specific output. + message ExecResourceOutput { + // Output from enforcement phase output file (if run). + // Output size is limited to 100K bytes. + bytes enforcement_output = 2; + } + + // The ID of the OS policy resource. + string os_policy_resource_id = 1; + + // Ordered list of configuration completed by the agent for the OS policy + // resource. + repeated OSPolicyResourceConfigStep config_steps = 2; + + // The compliance state of the resource. + ComplianceState compliance_state = 3; + + // A reason for the resource to be in the given compliance state. + // This field is always populated when `compliance_state` is `UNKNOWN`. + // + // The following values are supported when `compliance_state == UNKNOWN` + // + // * `execution-errors`: Errors were encountered by the agent while + // executing the resource and the compliance state couldn't be + // determined. + // * `execution-skipped-by-agent`: Resource execution was skipped by the + // agent because errors were encountered while executing prior resources + // in the OS policy. + // * `os-policy-execution-attempt-failed`: The execution of the OS policy + // containing this resource failed and the compliance state couldn't be + // determined. + string compliance_state_reason = 4; + + // Resource specific output. + oneof output { + // ExecResource specific output. + ExecResourceOutput exec_resource_output = 5; + } + } + + // The OS policy id + string os_policy_id = 1; + + // The compliance state of the OS policy. + ComplianceState compliance_state = 2; + + // The reason for the OS policy to be in an unknown compliance state. + // This field is always populated when `compliance_state` is `UNKNOWN`. + // + // If populated, the field can contain one of the following values: + // + // * `vm-not-running`: The VM was not running. + // * `os-policies-not-supported-by-agent`: The version of the OS Config + // agent running on the VM does not support running OS policies. + // * `no-agent-detected`: The OS Config agent is not detected for the VM. + // * `resource-execution-errors`: The OS Config agent encountered errors + // while executing one or more resources in the policy. See + // `os_policy_resource_compliances` for details. + // * `task-timeout`: The task sent to the agent to apply the policy timed + // out. + // * `unexpected-agent-state`: The OS Config agent did not report the final + // status of the task that attempted to apply the policy. Instead, the agent + // unexpectedly started working on a different task. This mostly happens + // when the agent or VM unexpectedly restarts while applying OS policies. + // * `internal-service-errors`: Internal service errors were encountered + // while attempting to apply the policy. + string compliance_state_reason = 3; + + // Compliance data for each resource within the policy that is applied to + // the VM. + repeated OSPolicyResourceCompliance os_policy_resource_compliances = 4; + } + + // The `OSPolicyAssignmentReport` API resource name. + // + // Format: + // `projects/{project_number}/locations/{location}/instances/{instance_id}/osPolicyAssignments/{os_policy_assignment_id}/report` + string name = 1; + + // The Compute Engine VM instance name. + string instance = 2; + + // Reference to the `OSPolicyAssignment` API resource that the `OSPolicy` + // belongs to. + // + // Format: + // `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id@revision_id}` + string os_policy_assignment = 3 [(google.api.resource_reference) = { + type: "osconfig.googleapis.com/OSPolicyAssignment" + }]; + + // Compliance data for each `OSPolicy` that is applied to the VM. + repeated OSPolicyCompliance os_policy_compliances = 4; + + // Timestamp for when the report was last generated. + google.protobuf.Timestamp update_time = 5; + + // Unique identifier of the last attempted run to apply the OS policies + // associated with this assignment on the VM. + // + // This ID is logged by the OS Config agent while applying the OS + // policies associated with this assignment on the VM. + // NOTE: If the service is unable to successfully connect to the agent for + // this run, then this id will not be available in the agent logs. + string last_run_id = 6; +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy_assignments.proto b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy_assignments.proto new file mode 100644 index 00000000000..86b0cbb88d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy_assignments.proto @@ -0,0 +1,383 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/osconfig/v1alpha/os_policy.proto"; +import "google/cloud/osconfig/v1alpha/osconfig_common.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.OsConfig.V1Alpha"; +option go_package = "cloud.google.com/go/osconfig/apiv1alpha/osconfigpb;osconfigpb"; +option java_multiple_files = true; +option java_outer_classname = "OsPolicyAssignmentsProto"; +option java_package = "com.google.cloud.osconfig.v1alpha"; +option php_namespace = "Google\\Cloud\\OsConfig\\V1alpha"; +option ruby_package = "Google::Cloud::OsConfig::V1alpha"; + +// OS policy assignment is an API resource that is used to +// apply a set of OS policies to a dynamically targeted group of Compute Engine +// VM instances. +// +// An OS policy is used to define the desired state configuration for a +// Compute Engine VM instance through a set of configuration resources that +// provide capabilities such as installing or removing software packages, or +// executing a script. +// +// For more information, see [OS policy and OS policy +// assignment](https://cloud.google.com/compute/docs/os-configuration-management/working-with-os-policies). +message OSPolicyAssignment { + option (google.api.resource) = { + type: "osconfig.googleapis.com/OSPolicyAssignment" + pattern: "projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}" + }; + + // Message representing label set. + // * A label is a key value pair set for a VM. + // * A LabelSet is a set of labels. + // * Labels within a LabelSet are ANDed. In other words, a LabelSet is + // applicable for a VM only if it matches all the labels in the + // LabelSet. + // * Example: A LabelSet with 2 labels: `env=prod` and `type=webserver` will + // only be applicable for those VMs with both labels + // present. + message LabelSet { + // Labels are identified by key/value pairs in this map. + // A VM should contain all the key/value pairs specified in this + // map to be selected. + map labels = 1; + } + + // Filters to select target VMs for an assignment. + // + // If more than one filter criteria is specified below, a VM will be selected + // if and only if it satisfies all of them. + message InstanceFilter { + // VM inventory details. + message Inventory { + // Required. The OS short name + string os_short_name = 1 [(google.api.field_behavior) = REQUIRED]; + + // The OS version + // + // Prefix matches are supported if asterisk(*) is provided as the + // last character. For example, to match all versions with a major + // version of `7`, specify the following value for this field `7.*` + // + // An empty string matches all OS versions. + string os_version = 2; + } + + // Target all VMs in the project. If true, no other criteria is + // permitted. + bool all = 1; + + // Deprecated. Use the `inventories` field instead. + // A VM is selected if it's OS short name matches with any of the + // values provided in this list. + repeated string os_short_names = 2 [deprecated = true]; + + // List of label sets used for VM inclusion. + // + // If the list has more than one `LabelSet`, the VM is included if any + // of the label sets are applicable for the VM. + repeated LabelSet inclusion_labels = 3; + + // List of label sets used for VM exclusion. + // + // If the list has more than one label set, the VM is excluded if any + // of the label sets are applicable for the VM. + repeated LabelSet exclusion_labels = 4; + + // List of inventories to select VMs. + // + // A VM is selected if its inventory data matches at least one of the + // following inventories. + repeated Inventory inventories = 5; + } + + // Message to configure the rollout at the zonal level for the OS policy + // assignment. + message Rollout { + // Required. The maximum number (or percentage) of VMs per zone to disrupt at + // any given moment. + FixedOrPercent disruption_budget = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. This determines the minimum duration of time to wait after the + // configuration changes are applied through the current rollout. A + // VM continues to count towards the `disruption_budget` at least + // until this duration of time has passed after configuration changes are + // applied. + google.protobuf.Duration min_wait_duration = 2 [(google.api.field_behavior) = REQUIRED]; + } + + // OS policy assignment rollout state + enum RolloutState { + // Invalid value + ROLLOUT_STATE_UNSPECIFIED = 0; + + // The rollout is in progress. + IN_PROGRESS = 1; + + // The rollout is being cancelled. + CANCELLING = 2; + + // The rollout is cancelled. + CANCELLED = 3; + + // The rollout has completed successfully. + SUCCEEDED = 4; + } + + // Resource name. + // + // Format: + // `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id}` + // + // This field is ignored when you create an OS policy assignment. + string name = 1; + + // OS policy assignment description. + // Length of the description is limited to 1024 characters. + string description = 2; + + // Required. List of OS policies to be applied to the VMs. + repeated OSPolicy os_policies = 3 [(google.api.field_behavior) = REQUIRED]; + + // Required. Filter to select VMs. + InstanceFilter instance_filter = 4 [(google.api.field_behavior) = REQUIRED]; + + // Required. Rollout to deploy the OS policy assignment. + // A rollout is triggered in the following situations: + // 1) OSPolicyAssignment is created. + // 2) OSPolicyAssignment is updated and the update contains changes to one of + // the following fields: + // - instance_filter + // - os_policies + // 3) OSPolicyAssignment is deleted. + Rollout rollout = 5 [(google.api.field_behavior) = REQUIRED]; + + // Output only. The assignment revision ID + // A new revision is committed whenever a rollout is triggered for a OS policy + // assignment + string revision_id = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp that the revision was created. + google.protobuf.Timestamp revision_create_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The etag for this OS policy assignment. + // If this is provided on update, it must match the server's etag. + string etag = 8; + + // Output only. OS policy assignment rollout state + RolloutState rollout_state = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Indicates that this revision has been successfully rolled out in this zone + // and new VMs will be assigned OS policies from this revision. + // + // For a given OS policy assignment, there is only one revision with a value + // of `true` for this field. + bool baseline = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Indicates that this revision deletes the OS policy assignment. + bool deleted = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Indicates that reconciliation is in progress for the revision. + // This value is `true` when the `rollout_state` is one of: + // * IN_PROGRESS + // * CANCELLING + bool reconciling = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Server generated unique id for the OS policy assignment resource. + string uid = 13 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// OS policy assignment operation metadata provided by OS policy assignment API +// methods that return long running operations. +message OSPolicyAssignmentOperationMetadata { + // The OS policy assignment API method. + enum APIMethod { + // Invalid value + API_METHOD_UNSPECIFIED = 0; + + // Create OS policy assignment API method + CREATE = 1; + + // Update OS policy assignment API method + UPDATE = 2; + + // Delete OS policy assignment API method + DELETE = 3; + } + + // State of the rollout + enum RolloutState { + // Invalid value + ROLLOUT_STATE_UNSPECIFIED = 0; + + // The rollout is in progress. + IN_PROGRESS = 1; + + // The rollout is being cancelled. + CANCELLING = 2; + + // The rollout is cancelled. + CANCELLED = 3; + + // The rollout has completed successfully. + SUCCEEDED = 4; + } + + // Reference to the `OSPolicyAssignment` API resource. + // + // Format: + // `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id@revision_id}` + string os_policy_assignment = 1 [(google.api.resource_reference) = { + type: "osconfig.googleapis.com/OSPolicyAssignment" + }]; + + // The OS policy assignment API method. + APIMethod api_method = 2; + + // State of the rollout + RolloutState rollout_state = 3; + + // Rollout start time + google.protobuf.Timestamp rollout_start_time = 4; + + // Rollout update time + google.protobuf.Timestamp rollout_update_time = 5; +} + +// A request message to create an OS policy assignment +message CreateOSPolicyAssignmentRequest { + // Required. The parent resource name in the form: + // projects/{project}/locations/{location} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The OS policy assignment to be created. + OSPolicyAssignment os_policy_assignment = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The logical name of the OS policy assignment in the project + // with the following restrictions: + // + // * Must contain only lowercase letters, numbers, and hyphens. + // * Must start with a letter. + // * Must be between 1-63 characters. + // * Must end with a number or a letter. + // * Must be unique within the project. + string os_policy_assignment_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// A request message to update an OS policy assignment +message UpdateOSPolicyAssignmentRequest { + // Required. The updated OS policy assignment. + OSPolicyAssignment os_policy_assignment = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Field mask that controls which fields of the assignment should be updated. + google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// A request message to get an OS policy assignment +message GetOSPolicyAssignmentRequest { + // Required. The resource name of OS policy assignment. + // + // Format: + // `projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}@{revisionId}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/OSPolicyAssignment" + } + ]; +} + +// A request message to list OS policy assignments for a parent resource +message ListOSPolicyAssignmentsRequest { + // Required. The parent resource name. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of assignments to return. + int32 page_size = 2; + + // A pagination token returned from a previous call to + // `ListOSPolicyAssignments` that indicates where this listing should continue + // from. + string page_token = 3; +} + +// A response message for listing all assignments under given parent. +message ListOSPolicyAssignmentsResponse { + // The list of assignments + repeated OSPolicyAssignment os_policy_assignments = 1; + + // The pagination token to retrieve the next page of OS policy assignments. + string next_page_token = 2; +} + +// A request message to list revisions for a OS policy assignment +message ListOSPolicyAssignmentRevisionsRequest { + // Required. The name of the OS policy assignment to list revisions for. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/OSPolicyAssignment" + } + ]; + + // The maximum number of revisions to return. + int32 page_size = 2; + + // A pagination token returned from a previous call to + // `ListOSPolicyAssignmentRevisions` that indicates where this listing should + // continue from. + string page_token = 3; +} + +// A response message for listing all revisions for a OS policy assignment. +message ListOSPolicyAssignmentRevisionsResponse { + // The OS policy assignment revisions + repeated OSPolicyAssignment os_policy_assignments = 1; + + // The pagination token to retrieve the next page of OS policy assignment + // revisions. + string next_page_token = 2; +} + +// A request message for deleting a OS policy assignment. +message DeleteOSPolicyAssignmentRequest { + // Required. The name of the OS policy assignment to be deleted + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/OSPolicyAssignment" + } + ]; +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/osconfig_common.proto b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/osconfig_common.proto new file mode 100644 index 00000000000..49bfeca0c34 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/osconfig_common.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.osconfig.v1alpha; + + +option csharp_namespace = "Google.Cloud.OsConfig.V1Alpha"; +option go_package = "cloud.google.com/go/osconfig/apiv1alpha/osconfigpb;osconfigpb"; +option java_multiple_files = true; +option java_outer_classname = "Common"; +option java_package = "com.google.cloud.osconfig.v1alpha"; +option php_namespace = "Google\\Cloud\\OsConfig\\V1alpha"; +option ruby_package = "Google::Cloud::OsConfig::V1alpha"; + +// Message encapsulating a value that can be either absolute ("fixed") or +// relative ("percent") to a value. +message FixedOrPercent { + // Type of the value. + oneof mode { + // Specifies a fixed value. + int32 fixed = 1; + + // Specifies the relative value defined as a percentage, which will be + // multiplied by a reference value. + int32 percent = 2; + } +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/osconfig_zonal_service.proto b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/osconfig_zonal_service.proto new file mode 100644 index 00000000000..439efa9d78f --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/osconfig_zonal_service.proto @@ -0,0 +1,215 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/resource.proto"; +import "google/cloud/osconfig/v1alpha/instance_os_policies_compliance.proto"; +import "google/cloud/osconfig/v1alpha/inventory.proto"; +import "google/cloud/osconfig/v1alpha/os_policy_assignment_reports.proto"; +import "google/cloud/osconfig/v1alpha/os_policy_assignments.proto"; +import "google/cloud/osconfig/v1alpha/vulnerability.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.OsConfig.V1Alpha"; +option go_package = "cloud.google.com/go/osconfig/apiv1alpha/osconfigpb;osconfigpb"; +option java_multiple_files = true; +option java_outer_classname = "OsConfigZonalServiceProto"; +option java_package = "com.google.cloud.osconfig.v1alpha"; +option php_namespace = "Google\\Cloud\\OsConfig\\V1alpha"; +option ruby_package = "Google::Cloud::OsConfig::V1alpha"; +option (google.api.resource_definition) = { + type: "compute.googleapis.com/Instance" + pattern: "projects/{project}/locations/{location}/instances/{instance}" +}; + +// Zonal OS Config API +// +// The OS Config service is the server-side component that allows users to +// manage package installations and patch jobs for Compute Engine VM instances. +service OsConfigZonalService { + option (google.api.default_host) = "osconfig.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Create an OS policy assignment. + // + // This method also creates the first revision of the OS policy assignment. + // + // This method returns a long running operation (LRO) that contains the + // rollout details. The rollout can be cancelled by cancelling the LRO. + // + // For more information, see [Method: + // projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1alpha/projects.locations.osPolicyAssignments.operations/cancel). + rpc CreateOSPolicyAssignment(CreateOSPolicyAssignmentRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1alpha/{parent=projects/*/locations/*}/osPolicyAssignments" + body: "os_policy_assignment" + }; + option (google.api.method_signature) = "parent,os_policy_assignment,os_policy_assignment_id"; + option (google.longrunning.operation_info) = { + response_type: "OSPolicyAssignment" + metadata_type: "OSPolicyAssignmentOperationMetadata" + }; + } + + // Update an existing OS policy assignment. + // + // This method creates a new revision of the OS policy assignment. + // + // This method returns a long running operation (LRO) that contains the + // rollout details. The rollout can be cancelled by cancelling the LRO. + // + // For more information, see [Method: + // projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1alpha/projects.locations.osPolicyAssignments.operations/cancel). + rpc UpdateOSPolicyAssignment(UpdateOSPolicyAssignmentRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1alpha/{os_policy_assignment.name=projects/*/locations/*/osPolicyAssignments/*}" + body: "os_policy_assignment" + }; + option (google.api.method_signature) = "os_policy_assignment,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "OSPolicyAssignment" + metadata_type: "OSPolicyAssignmentOperationMetadata" + }; + } + + // Retrieve an existing OS policy assignment. + // + // This method always returns the latest revision. In order to retrieve a + // previous revision of the assignment, also provide the revision ID in the + // `name` parameter. + rpc GetOSPolicyAssignment(GetOSPolicyAssignmentRequest) returns (OSPolicyAssignment) { + option (google.api.http) = { + get: "/v1alpha/{name=projects/*/locations/*/osPolicyAssignments/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List the OS policy assignments under the parent resource. + // + // For each OS policy assignment, the latest revision is returned. + rpc ListOSPolicyAssignments(ListOSPolicyAssignmentsRequest) returns (ListOSPolicyAssignmentsResponse) { + option (google.api.http) = { + get: "/v1alpha/{parent=projects/*/locations/*}/osPolicyAssignments" + }; + option (google.api.method_signature) = "parent"; + } + + // List the OS policy assignment revisions for a given OS policy assignment. + rpc ListOSPolicyAssignmentRevisions(ListOSPolicyAssignmentRevisionsRequest) returns (ListOSPolicyAssignmentRevisionsResponse) { + option (google.api.http) = { + get: "/v1alpha/{name=projects/*/locations/*/osPolicyAssignments/*}:listRevisions" + }; + option (google.api.method_signature) = "name"; + } + + // Delete the OS policy assignment. + // + // This method creates a new revision of the OS policy assignment. + // + // This method returns a long running operation (LRO) that contains the + // rollout details. The rollout can be cancelled by cancelling the LRO. + // + // If the LRO completes and is not cancelled, all revisions associated with + // the OS policy assignment are deleted. + // + // For more information, see [Method: + // projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1alpha/projects.locations.osPolicyAssignments.operations/cancel). + rpc DeleteOSPolicyAssignment(DeleteOSPolicyAssignmentRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1alpha/{name=projects/*/locations/*/osPolicyAssignments/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "OSPolicyAssignmentOperationMetadata" + }; + } + + // Get OS policies compliance data for the specified Compute Engine VM + // instance. + rpc GetInstanceOSPoliciesCompliance(GetInstanceOSPoliciesComplianceRequest) returns (InstanceOSPoliciesCompliance) { + option deprecated = true; + option (google.api.http) = { + get: "/v1alpha/{name=projects/*/locations/*/instanceOSPoliciesCompliances/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List OS policies compliance data for all Compute Engine VM instances in the + // specified zone. + rpc ListInstanceOSPoliciesCompliances(ListInstanceOSPoliciesCompliancesRequest) returns (ListInstanceOSPoliciesCompliancesResponse) { + option deprecated = true; + option (google.api.http) = { + get: "/v1alpha/{parent=projects/*/locations/*}/instanceOSPoliciesCompliances" + }; + option (google.api.method_signature) = "parent"; + } + + // Get the OS policy asssignment report for the specified Compute Engine VM + // instance. + rpc GetOSPolicyAssignmentReport(GetOSPolicyAssignmentReportRequest) returns (OSPolicyAssignmentReport) { + option (google.api.http) = { + get: "/v1alpha/{name=projects/*/locations/*/instances/*/osPolicyAssignments/*/report}" + }; + option (google.api.method_signature) = "name"; + } + + // List OS policy asssignment reports for all Compute Engine VM instances in + // the specified zone. + rpc ListOSPolicyAssignmentReports(ListOSPolicyAssignmentReportsRequest) returns (ListOSPolicyAssignmentReportsResponse) { + option (google.api.http) = { + get: "/v1alpha/{parent=projects/*/locations/*/instances/*/osPolicyAssignments/*}/reports" + }; + option (google.api.method_signature) = "parent"; + } + + // Get inventory data for the specified VM instance. If the VM has no + // associated inventory, the message `NOT_FOUND` is returned. + rpc GetInventory(GetInventoryRequest) returns (Inventory) { + option (google.api.http) = { + get: "/v1alpha/{name=projects/*/locations/*/instances/*/inventory}" + }; + option (google.api.method_signature) = "name"; + } + + // List inventory data for all VM instances in the specified zone. + rpc ListInventories(ListInventoriesRequest) returns (ListInventoriesResponse) { + option (google.api.http) = { + get: "/v1alpha/{parent=projects/*/locations/*/instances/*}/inventories" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets the vulnerability report for the specified VM instance. Only VMs with + // inventory data have vulnerability reports associated with them. + rpc GetVulnerabilityReport(GetVulnerabilityReportRequest) returns (VulnerabilityReport) { + option (google.api.http) = { + get: "/v1alpha/{name=projects/*/locations/*/instances/*/vulnerabilityReport}" + }; + option (google.api.method_signature) = "name"; + } + + // List vulnerability reports for all VM instances in the specified zone. + rpc ListVulnerabilityReports(ListVulnerabilityReportsRequest) returns (ListVulnerabilityReportsResponse) { + option (google.api.http) = { + get: "/v1alpha/{parent=projects/*/locations/*/instances/*}/vulnerabilityReports" + }; + option (google.api.method_signature) = "parent"; + } +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/vulnerability.proto b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/vulnerability.proto new file mode 100644 index 00000000000..2ea9784fd85 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/vulnerability.proto @@ -0,0 +1,365 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.OsConfig.V1Alpha"; +option go_package = "cloud.google.com/go/osconfig/apiv1alpha/osconfigpb;osconfigpb"; +option java_multiple_files = true; +option java_outer_classname = "VulnerabilityProto"; +option java_package = "com.google.cloud.osconfig.v1alpha"; +option php_namespace = "Google\\Cloud\\OsConfig\\V1alpha"; +option ruby_package = "Google::Cloud::OsConfig::V1alpha"; + +// This API resource represents the vulnerability report for a specified +// Compute Engine virtual machine (VM) instance at a given point in time. +// +// For more information, see [Vulnerability +// reports](https://cloud.google.com/compute/docs/instances/os-inventory-management#vulnerability-reports). +message VulnerabilityReport { + option (google.api.resource) = { + type: "osconfig.googleapis.com/VulnerabilityReport" + pattern: "projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport" + }; + + // A vulnerability affecting the VM instance. + message Vulnerability { + // Contains metadata information for the vulnerability. This information is + // collected from the upstream feed of the operating system. + message Details { + // A reference for this vulnerability. + message Reference { + // The url of the reference. + string url = 1; + + // The source of the reference e.g. NVD. + string source = 2; + } + + // The CVE of the vulnerability. CVE cannot be + // empty and the combination of should be unique + // across vulnerabilities for a VM. + string cve = 1; + + // The CVSS V2 score of this vulnerability. CVSS V2 score is on a scale of + // 0 - 10 where 0 indicates low severity and 10 indicates high severity. + float cvss_v2_score = 2; + + // The full description of the CVSSv3 for this vulnerability from NVD. + CVSSv3 cvss_v3 = 3; + + // Assigned severity/impact ranking from the distro. + string severity = 4; + + // The note or description describing the vulnerability from the distro. + string description = 5; + + // Corresponds to the references attached to the `VulnerabilityDetails`. + repeated Reference references = 6; + } + + // OS inventory item that is affected by a vulnerability or fixed as a + // result of a vulnerability. + message Item { + // Corresponds to the `INSTALLED_PACKAGE` inventory item on the VM. + // This field displays the inventory items affected by this vulnerability. + // If the vulnerability report was not updated after the VM inventory + // update, these values might not display in VM inventory. For some + // operating systems, this field might be empty. + string installed_inventory_item_id = 1; + + // Corresponds to the `AVAILABLE_PACKAGE` inventory item on the VM. + // If the vulnerability report was not updated after the VM inventory + // update, these values might not display in VM inventory. If there is no + // available fix, the field is empty. The `inventory_item` value specifies + // the latest `SoftwarePackage` available to the VM that fixes the + // vulnerability. + string available_inventory_item_id = 2; + + // The recommended [CPE URI](https://cpe.mitre.org/specification/) update + // that contains a fix for this vulnerability. + string fixed_cpe_uri = 3; + + // The upstream OS patch, packages or KB that fixes the vulnerability. + string upstream_fix = 4; + } + + // Contains metadata as per the upstream feed of the operating system and + // NVD. + Details details = 1; + + // Corresponds to the `INSTALLED_PACKAGE` inventory item on the VM. + // This field displays the inventory items affected by this vulnerability. + // If the vulnerability report was not updated after the VM inventory + // update, these values might not display in VM inventory. For some distros, + // this field may be empty. + repeated string installed_inventory_item_ids = 2 [deprecated = true]; + + // Corresponds to the `AVAILABLE_PACKAGE` inventory item on the VM. + // If the vulnerability report was not updated after the VM inventory + // update, these values might not display in VM inventory. If there is no + // available fix, the field is empty. The `inventory_item` value specifies + // the latest `SoftwarePackage` available to the VM that fixes the + // vulnerability. + repeated string available_inventory_item_ids = 3 [deprecated = true]; + + // The timestamp for when the vulnerability was first detected. + google.protobuf.Timestamp create_time = 4; + + // The timestamp for when the vulnerability was last modified. + google.protobuf.Timestamp update_time = 5; + + // List of items affected by the vulnerability. + repeated Item items = 6; + } + + // Output only. The `vulnerabilityReport` API resource name. + // + // Format: + // `projects/{project_number}/locations/{location}/instances/{instance_id}/vulnerabilityReport` + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. List of vulnerabilities affecting the VM. + repeated Vulnerability vulnerabilities = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp for when the last vulnerability report was generated for the + // VM. + google.protobuf.Timestamp update_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A request message for getting the vulnerability report for the specified VM. +message GetVulnerabilityReportRequest { + // Required. API resource name for vulnerability resource. + // + // Format: + // `projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport` + // + // For `{project}`, either `project-number` or `project-id` can be provided. + // For `{instance}`, either Compute Engine `instance-id` or `instance-name` + // can be provided. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/VulnerabilityReport" + } + ]; +} + +// A request message for listing vulnerability reports for all VM instances in +// the specified location. +message ListVulnerabilityReportsRequest { + // Required. The parent resource name. + // + // Format: `projects/{project}/locations/{location}/instances/-` + // + // For `{project}`, either `project-number` or `project-id` can be provided. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "compute.googleapis.com/Instance" + } + ]; + + // The maximum number of results to return. + int32 page_size = 2; + + // A pagination token returned from a previous call to + // `ListVulnerabilityReports` that indicates where this listing + // should continue from. + string page_token = 3; + + // If provided, this field specifies the criteria that must be met by a + // `vulnerabilityReport` API resource to be included in the response. + string filter = 4; +} + +// A response message for listing vulnerability reports for all VM instances in +// the specified location. +message ListVulnerabilityReportsResponse { + // List of vulnerabilityReport objects. + repeated VulnerabilityReport vulnerability_reports = 1; + + // The pagination token to retrieve the next page of vulnerabilityReports + // object. + string next_page_token = 2; +} + +// Common Vulnerability Scoring System version 3. +// For details, see https://www.first.org/cvss/specification-document +message CVSSv3 { + // This metric reflects the context by which vulnerability exploitation is + // possible. + enum AttackVector { + // Invalid value. + ATTACK_VECTOR_UNSPECIFIED = 0; + + // The vulnerable component is bound to the network stack and the set of + // possible attackers extends beyond the other options listed below, up to + // and including the entire Internet. + ATTACK_VECTOR_NETWORK = 1; + + // The vulnerable component is bound to the network stack, but the attack is + // limited at the protocol level to a logically adjacent topology. + ATTACK_VECTOR_ADJACENT = 2; + + // The vulnerable component is not bound to the network stack and the + // attacker's path is via read/write/execute capabilities. + ATTACK_VECTOR_LOCAL = 3; + + // The attack requires the attacker to physically touch or manipulate the + // vulnerable component. + ATTACK_VECTOR_PHYSICAL = 4; + } + + // This metric describes the conditions beyond the attacker's control that + // must exist in order to exploit the vulnerability. + enum AttackComplexity { + // Invalid value. + ATTACK_COMPLEXITY_UNSPECIFIED = 0; + + // Specialized access conditions or extenuating circumstances do not exist. + // An attacker can expect repeatable success when attacking the vulnerable + // component. + ATTACK_COMPLEXITY_LOW = 1; + + // A successful attack depends on conditions beyond the attacker's control. + // That is, a successful attack cannot be accomplished at will, but requires + // the attacker to invest in some measurable amount of effort in preparation + // or execution against the vulnerable component before a successful attack + // can be expected. + ATTACK_COMPLEXITY_HIGH = 2; + } + + // This metric describes the level of privileges an attacker must possess + // before successfully exploiting the vulnerability. + enum PrivilegesRequired { + // Invalid value. + PRIVILEGES_REQUIRED_UNSPECIFIED = 0; + + // The attacker is unauthorized prior to attack, and therefore does not + // require any access to settings or files of the vulnerable system to + // carry out an attack. + PRIVILEGES_REQUIRED_NONE = 1; + + // The attacker requires privileges that provide basic user capabilities + // that could normally affect only settings and files owned by a user. + // Alternatively, an attacker with Low privileges has the ability to access + // only non-sensitive resources. + PRIVILEGES_REQUIRED_LOW = 2; + + // The attacker requires privileges that provide significant (e.g., + // administrative) control over the vulnerable component allowing access to + // component-wide settings and files. + PRIVILEGES_REQUIRED_HIGH = 3; + } + + // This metric captures the requirement for a human user, other than the + // attacker, to participate in the successful compromise of the vulnerable + // component. + enum UserInteraction { + // Invalid value. + USER_INTERACTION_UNSPECIFIED = 0; + + // The vulnerable system can be exploited without interaction from any user. + USER_INTERACTION_NONE = 1; + + // Successful exploitation of this vulnerability requires a user to take + // some action before the vulnerability can be exploited. + USER_INTERACTION_REQUIRED = 2; + } + + // The Scope metric captures whether a vulnerability in one vulnerable + // component impacts resources in components beyond its security scope. + enum Scope { + // Invalid value. + SCOPE_UNSPECIFIED = 0; + + // An exploited vulnerability can only affect resources managed by the same + // security authority. + SCOPE_UNCHANGED = 1; + + // An exploited vulnerability can affect resources beyond the security scope + // managed by the security authority of the vulnerable component. + SCOPE_CHANGED = 2; + } + + // The Impact metrics capture the effects of a successfully exploited + // vulnerability on the component that suffers the worst outcome that is most + // directly and predictably associated with the attack. + enum Impact { + // Invalid value. + IMPACT_UNSPECIFIED = 0; + + // High impact. + IMPACT_HIGH = 1; + + // Low impact. + IMPACT_LOW = 2; + + // No impact. + IMPACT_NONE = 3; + } + + // The base score is a function of the base metric scores. + // https://www.first.org/cvss/specification-document#Base-Metrics + float base_score = 1; + + // The Exploitability sub-score equation is derived from the Base + // Exploitability metrics. + // https://www.first.org/cvss/specification-document#2-1-Exploitability-Metrics + float exploitability_score = 2; + + // The Impact sub-score equation is derived from the Base Impact metrics. + float impact_score = 3; + + // This metric reflects the context by which vulnerability exploitation is + // possible. + AttackVector attack_vector = 5; + + // This metric describes the conditions beyond the attacker's control that + // must exist in order to exploit the vulnerability. + AttackComplexity attack_complexity = 6; + + // This metric describes the level of privileges an attacker must possess + // before successfully exploiting the vulnerability. + PrivilegesRequired privileges_required = 7; + + // This metric captures the requirement for a human user, other than the + // attacker, to participate in the successful compromise of the vulnerable + // component. + UserInteraction user_interaction = 8; + + // The Scope metric captures whether a vulnerability in one vulnerable + // component impacts resources in components beyond its security scope. + Scope scope = 9; + + // This metric measures the impact to the confidentiality of the information + // resources managed by a software component due to a successfully exploited + // vulnerability. + Impact confidentiality_impact = 10; + + // This metric measures the impact to integrity of a successfully exploited + // vulnerability. + Impact integrity_impact = 11; + + // This metric measures the impact to the availability of the impacted + // component resulting from a successfully exploited vulnerability. + Impact availability_impact = 12; +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.create_o_s_policy_assignment.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.create_o_s_policy_assignment.js new file mode 100644 index 00000000000..7646ded6809 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.create_o_s_policy_assignment.js @@ -0,0 +1,79 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, osPolicyAssignment, osPolicyAssignmentId) { + // [START osconfig_v1alpha_generated_OsConfigZonalService_CreateOSPolicyAssignment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 name in the form: + * projects/{project}/locations/{location} + */ + // const parent = 'abc123' + /** + * Required. The OS policy assignment to be created. + */ + // const osPolicyAssignment = {} + /** + * Required. The logical name of the OS policy assignment in the project + * with the following restrictions: + * * Must contain only lowercase letters, numbers, and hyphens. + * * Must start with a letter. + * * Must be between 1-63 characters. + * * Must end with a number or a letter. + * * Must be unique within the project. + */ + // const osPolicyAssignmentId = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callCreateOSPolicyAssignment() { + // Construct request + const request = { + parent, + osPolicyAssignment, + osPolicyAssignmentId, + }; + + // Run request + const [operation] = await osconfigClient.createOSPolicyAssignment(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateOSPolicyAssignment(); + // [END osconfig_v1alpha_generated_OsConfigZonalService_CreateOSPolicyAssignment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.delete_o_s_policy_assignment.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.delete_o_s_policy_assignment.js new file mode 100644 index 00000000000..3b4e222de3b --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.delete_o_s_policy_assignment.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 osconfig_v1alpha_generated_OsConfigZonalService_DeleteOSPolicyAssignment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 OS policy assignment to be deleted + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callDeleteOSPolicyAssignment() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await osconfigClient.deleteOSPolicyAssignment(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteOSPolicyAssignment(); + // [END osconfig_v1alpha_generated_OsConfigZonalService_DeleteOSPolicyAssignment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_instance_o_s_policies_compliance.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_instance_o_s_policies_compliance.js new file mode 100644 index 00000000000..f12054ce1ca --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_instance_o_s_policies_compliance.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(name) { + // [START osconfig_v1alpha_generated_OsConfigZonalService_GetInstanceOSPoliciesCompliance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. API resource name for instance OS policies compliance resource. + * Format: + * `projects/{project}/locations/{location}/instanceOSPoliciesCompliances/{instance}` + * For `{project}`, either Compute Engine project-number or project-id can be + * provided. + * For `{instance}`, either Compute Engine VM instance-id or instance-name can + * be provided. + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callGetInstanceOSPoliciesCompliance() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.getInstanceOSPoliciesCompliance(request); + console.log(response); + } + + callGetInstanceOSPoliciesCompliance(); + // [END osconfig_v1alpha_generated_OsConfigZonalService_GetInstanceOSPoliciesCompliance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_inventory.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_inventory.js new file mode 100644 index 00000000000..76184efb4e6 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_inventory.js @@ -0,0 +1,71 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START osconfig_v1alpha_generated_OsConfigZonalService_GetInventory_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. API resource name for inventory resource. + * Format: + * `projects/{project}/locations/{location}/instances/{instance}/inventory` + * For `{project}`, either `project-number` or `project-id` can be provided. + * For `{instance}`, either Compute Engine `instance-id` or `instance-name` + * can be provided. + */ + // const name = 'abc123' + /** + * Inventory view indicating what information should be included in the + * inventory resource. If unspecified, the default view is BASIC. + */ + // const view = {} + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callGetInventory() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.getInventory(request); + console.log(response); + } + + callGetInventory(); + // [END osconfig_v1alpha_generated_OsConfigZonalService_GetInventory_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_o_s_policy_assignment.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_o_s_policy_assignment.js new file mode 100644 index 00000000000..47f7f786a0e --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_o_s_policy_assignment.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 osconfig_v1alpha_generated_OsConfigZonalService_GetOSPolicyAssignment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 OS policy assignment. + * Format: + * `projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}@{revisionId}` + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callGetOSPolicyAssignment() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.getOSPolicyAssignment(request); + console.log(response); + } + + callGetOSPolicyAssignment(); + // [END osconfig_v1alpha_generated_OsConfigZonalService_GetOSPolicyAssignment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_o_s_policy_assignment_report.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_o_s_policy_assignment_report.js new file mode 100644 index 00000000000..bce36f54492 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_o_s_policy_assignment_report.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(name) { + // [START osconfig_v1alpha_generated_OsConfigZonalService_GetOSPolicyAssignmentReport_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. API resource name for OS policy assignment report. + * Format: + * `/projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report` + * For `{project}`, either `project-number` or `project-id` can be provided. + * For `{instance_id}`, either Compute Engine `instance-id` or `instance-name` + * can be provided. + * For `{assignment_id}`, the OSPolicyAssignment id must be provided. + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callGetOSPolicyAssignmentReport() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.getOSPolicyAssignmentReport(request); + console.log(response); + } + + callGetOSPolicyAssignmentReport(); + // [END osconfig_v1alpha_generated_OsConfigZonalService_GetOSPolicyAssignmentReport_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_vulnerability_report.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_vulnerability_report.js new file mode 100644 index 00000000000..b1623dc2e95 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_vulnerability_report.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(name) { + // [START osconfig_v1alpha_generated_OsConfigZonalService_GetVulnerabilityReport_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. API resource name for vulnerability resource. + * Format: + * `projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport` + * For `{project}`, either `project-number` or `project-id` can be provided. + * For `{instance}`, either Compute Engine `instance-id` or `instance-name` + * can be provided. + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callGetVulnerabilityReport() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.getVulnerabilityReport(request); + console.log(response); + } + + callGetVulnerabilityReport(); + // [END osconfig_v1alpha_generated_OsConfigZonalService_GetVulnerabilityReport_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_instance_o_s_policies_compliances.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_instance_o_s_policies_compliances.js new file mode 100644 index 00000000000..6e6dd476e87 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_instance_o_s_policies_compliances.js @@ -0,0 +1,81 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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 osconfig_v1alpha_generated_OsConfigZonalService_ListInstanceOSPoliciesCompliances_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 name. + * Format: `projects/{project}/locations/{location}` + * For `{project}`, either Compute Engine project-number or project-id can be + * provided. + */ + // const parent = 'abc123' + /** + * The maximum number of results to return. + */ + // const pageSize = 1234 + /** + * A pagination token returned from a previous call to + * `ListInstanceOSPoliciesCompliances` that indicates where this listing + * should continue from. + */ + // const pageToken = 'abc123' + /** + * If provided, this field specifies the criteria that must be met by a + * `InstanceOSPoliciesCompliance` API resource to be included in the response. + */ + // const filter = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callListInstanceOSPoliciesCompliances() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await osconfigClient.listInstanceOSPoliciesCompliancesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListInstanceOSPoliciesCompliances(); + // [END osconfig_v1alpha_generated_OsConfigZonalService_ListInstanceOSPoliciesCompliances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_inventories.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_inventories.js new file mode 100644 index 00000000000..f894670e4a2 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_inventories.js @@ -0,0 +1,85 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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 osconfig_v1alpha_generated_OsConfigZonalService_ListInventories_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 name. + * Format: `projects/{project}/locations/{location}/instances/-` + * For `{project}`, either `project-number` or `project-id` can be provided. + */ + // const parent = 'abc123' + /** + * Inventory view indicating what information should be included in the + * inventory resource. If unspecified, the default view is BASIC. + */ + // const view = {} + /** + * The maximum number of results to return. + */ + // const pageSize = 1234 + /** + * A pagination token returned from a previous call to + * `ListInventories` that indicates where this listing + * should continue from. + */ + // const pageToken = 'abc123' + /** + * If provided, this field specifies the criteria that must be met by a + * `Inventory` API resource to be included in the response. + */ + // const filter = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callListInventories() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await osconfigClient.listInventoriesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListInventories(); + // [END osconfig_v1alpha_generated_OsConfigZonalService_ListInventories_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignment_reports.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignment_reports.js new file mode 100644 index 00000000000..f0554660729 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignment_reports.js @@ -0,0 +1,95 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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 osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignmentReports_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 name. + * Format: + * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/reports` + * For `{project}`, either `project-number` or `project-id` can be provided. + * For `{instance}`, either `instance-name`, `instance-id`, or `-` can be + * provided. If '-' is provided, the response will include + * OSPolicyAssignmentReports for all instances in the project/location. + * For `{assignment}`, either `assignment-id` or `-` can be provided. If '-' + * is provided, the response will include OSPolicyAssignmentReports for all + * OSPolicyAssignments in the project/location. + * Either {instance} or {assignment} must be `-`. + * For example: + * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/-/reports` + * returns all reports for the instance + * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/{assignment-id}/reports` + * returns all the reports for the given assignment across all instances. + * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/-/reports` + * returns all the reports for all assignments across all instances. + */ + // const parent = 'abc123' + /** + * The maximum number of results to return. + */ + // const pageSize = 1234 + /** + * If provided, this field specifies the criteria that must be met by the + * `OSPolicyAssignmentReport` API resource that is included in the response. + */ + // const filter = 'abc123' + /** + * A pagination token returned from a previous call to the + * `ListOSPolicyAssignmentReports` method that indicates where this listing + * should continue from. + */ + // const pageToken = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callListOSPolicyAssignmentReports() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await osconfigClient.listOSPolicyAssignmentReportsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListOSPolicyAssignmentReports(); + // [END osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignmentReports_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignment_revisions.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignment_revisions.js new file mode 100644 index 00000000000..74735c6c8db --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignment_revisions.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(name) { + // [START osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignmentRevisions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 OS policy assignment to list revisions for. + */ + // const name = 'abc123' + /** + * The maximum number of revisions to return. + */ + // const pageSize = 1234 + /** + * A pagination token returned from a previous call to + * `ListOSPolicyAssignmentRevisions` that indicates where this listing should + * continue from. + */ + // const pageToken = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callListOSPolicyAssignmentRevisions() { + // Construct request + const request = { + name, + }; + + // Run request + const iterable = await osconfigClient.listOSPolicyAssignmentRevisionsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListOSPolicyAssignmentRevisions(); + // [END osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignmentRevisions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignments.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignments.js new file mode 100644 index 00000000000..d5e7b75adf8 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignments.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(parent) { + // [START osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignments_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 name. + */ + // const parent = 'abc123' + /** + * The maximum number of assignments to return. + */ + // const pageSize = 1234 + /** + * A pagination token returned from a previous call to + * `ListOSPolicyAssignments` that indicates where this listing should continue + * from. + */ + // const pageToken = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callListOSPolicyAssignments() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await osconfigClient.listOSPolicyAssignmentsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListOSPolicyAssignments(); + // [END osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_vulnerability_reports.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_vulnerability_reports.js new file mode 100644 index 00000000000..a59010acbb5 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_vulnerability_reports.js @@ -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. ** + + + +'use strict'; + +function main(parent) { + // [START osconfig_v1alpha_generated_OsConfigZonalService_ListVulnerabilityReports_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 name. + * Format: `projects/{project}/locations/{location}/instances/-` + * For `{project}`, either `project-number` or `project-id` can be provided. + */ + // const parent = 'abc123' + /** + * The maximum number of results to return. + */ + // const pageSize = 1234 + /** + * A pagination token returned from a previous call to + * `ListVulnerabilityReports` that indicates where this listing + * should continue from. + */ + // const pageToken = 'abc123' + /** + * If provided, this field specifies the criteria that must be met by a + * `vulnerabilityReport` API resource to be included in the response. + */ + // const filter = 'abc123' + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callListVulnerabilityReports() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await osconfigClient.listVulnerabilityReportsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListVulnerabilityReports(); + // [END osconfig_v1alpha_generated_OsConfigZonalService_ListVulnerabilityReports_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.update_o_s_policy_assignment.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.update_o_s_policy_assignment.js new file mode 100644 index 00000000000..0c54f433ccb --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.update_o_s_policy_assignment.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(osPolicyAssignment) { + // [START osconfig_v1alpha_generated_OsConfigZonalService_UpdateOSPolicyAssignment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The updated OS policy assignment. + */ + // const osPolicyAssignment = {} + /** + * Optional. Field mask that controls which fields of the assignment should be updated. + */ + // const updateMask = {} + + // Imports the Osconfig library + const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; + + // Instantiates a client + const osconfigClient = new OsConfigZonalServiceClient(); + + async function callUpdateOSPolicyAssignment() { + // Construct request + const request = { + osPolicyAssignment, + }; + + // Run request + const [operation] = await osconfigClient.updateOSPolicyAssignment(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateOSPolicyAssignment(); + // [END osconfig_v1alpha_generated_OsConfigZonalService_UpdateOSPolicyAssignment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/snippet_metadata_google.cloud.osconfig.v1alpha.json b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/snippet_metadata_google.cloud.osconfig.v1alpha.json new file mode 100644 index 00000000000..b0be93478a9 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/snippet_metadata_google.cloud.osconfig.v1alpha.json @@ -0,0 +1,659 @@ +{ + "clientLibrary": { + "name": "nodejs-osconfig", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.osconfig.v1alpha", + "version": "v1alpha" + } + ] + }, + "snippets": [ + { + "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_CreateOSPolicyAssignment_async", + "title": "OsConfigZonalService createOSPolicyAssignment Sample", + "origin": "API_DEFINITION", + "description": " Create an OS policy assignment. This method also creates the first revision of the OS policy assignment. This method returns a long running operation (LRO) that contains the rollout details. The rollout can be cancelled by cancelling the LRO. For more information, see [Method: projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1alpha/projects.locations.osPolicyAssignments.operations/cancel).", + "canonical": true, + "file": "os_config_zonal_service.create_o_s_policy_assignment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateOSPolicyAssignment", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.CreateOSPolicyAssignment", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "os_policy_assignment", + "type": ".google.cloud.osconfig.v1alpha.OSPolicyAssignment" + }, + { + "name": "os_policy_assignment_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "CreateOSPolicyAssignment", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.CreateOSPolicyAssignment", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_UpdateOSPolicyAssignment_async", + "title": "OsConfigZonalService updateOSPolicyAssignment Sample", + "origin": "API_DEFINITION", + "description": " Update an existing OS policy assignment. This method creates a new revision of the OS policy assignment. This method returns a long running operation (LRO) that contains the rollout details. The rollout can be cancelled by cancelling the LRO. For more information, see [Method: projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1alpha/projects.locations.osPolicyAssignments.operations/cancel).", + "canonical": true, + "file": "os_config_zonal_service.update_o_s_policy_assignment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateOSPolicyAssignment", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.UpdateOSPolicyAssignment", + "async": true, + "parameters": [ + { + "name": "os_policy_assignment", + "type": ".google.cloud.osconfig.v1alpha.OSPolicyAssignment" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "UpdateOSPolicyAssignment", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.UpdateOSPolicyAssignment", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_GetOSPolicyAssignment_async", + "title": "OsConfigZonalService getOSPolicyAssignment Sample", + "origin": "API_DEFINITION", + "description": " Retrieve an existing OS policy assignment. This method always returns the latest revision. In order to retrieve a previous revision of the assignment, also provide the revision ID in the `name` parameter.", + "canonical": true, + "file": "os_config_zonal_service.get_o_s_policy_assignment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetOSPolicyAssignment", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.GetOSPolicyAssignment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1alpha.OSPolicyAssignment", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "GetOSPolicyAssignment", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.GetOSPolicyAssignment", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignments_async", + "title": "OsConfigZonalService listOSPolicyAssignments Sample", + "origin": "API_DEFINITION", + "description": " List the OS policy assignments under the parent resource. For each OS policy assignment, the latest revision is returned.", + "canonical": true, + "file": "os_config_zonal_service.list_o_s_policy_assignments.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListOSPolicyAssignments", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListOSPolicyAssignments", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsResponse", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "ListOSPolicyAssignments", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListOSPolicyAssignments", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignmentRevisions_async", + "title": "OsConfigZonalService listOSPolicyAssignmentRevisions Sample", + "origin": "API_DEFINITION", + "description": " List the OS policy assignment revisions for a given OS policy assignment.", + "canonical": true, + "file": "os_config_zonal_service.list_o_s_policy_assignment_revisions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListOSPolicyAssignmentRevisions", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListOSPolicyAssignmentRevisions", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsResponse", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "ListOSPolicyAssignmentRevisions", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListOSPolicyAssignmentRevisions", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_DeleteOSPolicyAssignment_async", + "title": "OsConfigZonalService deleteOSPolicyAssignment Sample", + "origin": "API_DEFINITION", + "description": " Delete the OS policy assignment. This method creates a new revision of the OS policy assignment. This method returns a long running operation (LRO) that contains the rollout details. The rollout can be cancelled by cancelling the LRO. If the LRO completes and is not cancelled, all revisions associated with the OS policy assignment are deleted. For more information, see [Method: projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1alpha/projects.locations.osPolicyAssignments.operations/cancel).", + "canonical": true, + "file": "os_config_zonal_service.delete_o_s_policy_assignment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteOSPolicyAssignment", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.DeleteOSPolicyAssignment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "DeleteOSPolicyAssignment", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.DeleteOSPolicyAssignment", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_GetInstanceOSPoliciesCompliance_async", + "title": "OsConfigZonalService getInstanceOSPoliciesCompliance Sample", + "origin": "API_DEFINITION", + "description": " Get OS policies compliance data for the specified Compute Engine VM instance.", + "canonical": true, + "file": "os_config_zonal_service.get_instance_o_s_policies_compliance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetInstanceOSPoliciesCompliance", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.GetInstanceOSPoliciesCompliance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "GetInstanceOSPoliciesCompliance", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.GetInstanceOSPoliciesCompliance", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_ListInstanceOSPoliciesCompliances_async", + "title": "OsConfigZonalService listInstanceOSPoliciesCompliances Sample", + "origin": "API_DEFINITION", + "description": " List OS policies compliance data for all Compute Engine VM instances in the specified zone.", + "canonical": true, + "file": "os_config_zonal_service.list_instance_o_s_policies_compliances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 73, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListInstanceOSPoliciesCompliances", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListInstanceOSPoliciesCompliances", + "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.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesResponse", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "ListInstanceOSPoliciesCompliances", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListInstanceOSPoliciesCompliances", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_GetOSPolicyAssignmentReport_async", + "title": "OsConfigZonalService getOSPolicyAssignmentReport Sample", + "origin": "API_DEFINITION", + "description": " Get the OS policy asssignment report for the specified Compute Engine VM instance.", + "canonical": true, + "file": "os_config_zonal_service.get_o_s_policy_assignment_report.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetOSPolicyAssignmentReport", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.GetOSPolicyAssignmentReport", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "GetOSPolicyAssignmentReport", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.GetOSPolicyAssignmentReport", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignmentReports_async", + "title": "OsConfigZonalService listOSPolicyAssignmentReports Sample", + "origin": "API_DEFINITION", + "description": " List OS policy asssignment reports for all Compute Engine VM instances in the specified zone.", + "canonical": true, + "file": "os_config_zonal_service.list_o_s_policy_assignment_reports.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 87, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListOSPolicyAssignmentReports", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListOSPolicyAssignmentReports", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsResponse", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "ListOSPolicyAssignmentReports", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListOSPolicyAssignmentReports", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_GetInventory_async", + "title": "OsConfigZonalService getInventory Sample", + "origin": "API_DEFINITION", + "description": " Get inventory data for the specified VM instance. If the VM has no associated inventory, the message `NOT_FOUND` is returned.", + "canonical": true, + "file": "os_config_zonal_service.get_inventory.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetInventory", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.GetInventory", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "view", + "type": ".google.cloud.osconfig.v1alpha.InventoryView" + } + ], + "resultType": ".google.cloud.osconfig.v1alpha.Inventory", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "GetInventory", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.GetInventory", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_ListInventories_async", + "title": "OsConfigZonalService listInventories Sample", + "origin": "API_DEFINITION", + "description": " List inventory data for all VM instances in the specified zone.", + "canonical": true, + "file": "os_config_zonal_service.list_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 77, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListInventories", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListInventories", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "view", + "type": ".google.cloud.osconfig.v1alpha.InventoryView" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1alpha.ListInventoriesResponse", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "ListInventories", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListInventories", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_GetVulnerabilityReport_async", + "title": "OsConfigZonalService getVulnerabilityReport Sample", + "origin": "API_DEFINITION", + "description": " Gets the vulnerability report for the specified VM instance. Only VMs with inventory data have vulnerability reports associated with them.", + "canonical": true, + "file": "os_config_zonal_service.get_vulnerability_report.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetVulnerabilityReport", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.GetVulnerabilityReport", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1alpha.VulnerabilityReport", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "GetVulnerabilityReport", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.GetVulnerabilityReport", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" + } + } + } + }, + { + "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_ListVulnerabilityReports_async", + "title": "OsConfigZonalService listVulnerabilityReports Sample", + "origin": "API_DEFINITION", + "description": " List vulnerability reports for all VM instances in the specified zone.", + "canonical": true, + "file": "os_config_zonal_service.list_vulnerability_reports.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListVulnerabilityReports", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListVulnerabilityReports", + "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.osconfig.v1alpha.ListVulnerabilityReportsResponse", + "client": { + "shortName": "OsConfigZonalServiceClient", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" + }, + "method": { + "shortName": "ListVulnerabilityReports", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListVulnerabilityReports", + "service": { + "shortName": "OsConfigZonalService", + "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/src/index.ts b/owl-bot-staging/google-cloud-osconfig/v1alpha/src/index.ts new file mode 100644 index 00000000000..92937ca2d3c --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1alpha from './v1alpha'; +const OsConfigZonalServiceClient = v1alpha.OsConfigZonalServiceClient; +type OsConfigZonalServiceClient = v1alpha.OsConfigZonalServiceClient; +export {v1alpha, OsConfigZonalServiceClient}; +export default {v1alpha, OsConfigZonalServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/gapic_metadata.json b/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/gapic_metadata.json new file mode 100644 index 00000000000..014b66375b8 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/gapic_metadata.json @@ -0,0 +1,187 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.osconfig.v1alpha", + "libraryPackage": "@google-cloud/os-config", + "services": { + "OsConfigZonalService": { + "clients": { + "grpc": { + "libraryClient": "OsConfigZonalServiceClient", + "rpcs": { + "GetOSPolicyAssignment": { + "methods": [ + "getOSPolicyAssignment" + ] + }, + "GetInstanceOSPoliciesCompliance": { + "methods": [ + "getInstanceOSPoliciesCompliance" + ] + }, + "GetOSPolicyAssignmentReport": { + "methods": [ + "getOSPolicyAssignmentReport" + ] + }, + "GetInventory": { + "methods": [ + "getInventory" + ] + }, + "GetVulnerabilityReport": { + "methods": [ + "getVulnerabilityReport" + ] + }, + "CreateOSPolicyAssignment": { + "methods": [ + "createOSPolicyAssignment" + ] + }, + "UpdateOSPolicyAssignment": { + "methods": [ + "updateOSPolicyAssignment" + ] + }, + "DeleteOSPolicyAssignment": { + "methods": [ + "deleteOSPolicyAssignment" + ] + }, + "ListOSPolicyAssignments": { + "methods": [ + "listOSPolicyAssignments", + "listOSPolicyAssignmentsStream", + "listOSPolicyAssignmentsAsync" + ] + }, + "ListOSPolicyAssignmentRevisions": { + "methods": [ + "listOSPolicyAssignmentRevisions", + "listOSPolicyAssignmentRevisionsStream", + "listOSPolicyAssignmentRevisionsAsync" + ] + }, + "ListInstanceOSPoliciesCompliances": { + "methods": [ + "listInstanceOSPoliciesCompliances", + "listInstanceOSPoliciesCompliancesStream", + "listInstanceOSPoliciesCompliancesAsync" + ] + }, + "ListOSPolicyAssignmentReports": { + "methods": [ + "listOSPolicyAssignmentReports", + "listOSPolicyAssignmentReportsStream", + "listOSPolicyAssignmentReportsAsync" + ] + }, + "ListInventories": { + "methods": [ + "listInventories", + "listInventoriesStream", + "listInventoriesAsync" + ] + }, + "ListVulnerabilityReports": { + "methods": [ + "listVulnerabilityReports", + "listVulnerabilityReportsStream", + "listVulnerabilityReportsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "OsConfigZonalServiceClient", + "rpcs": { + "GetOSPolicyAssignment": { + "methods": [ + "getOSPolicyAssignment" + ] + }, + "GetInstanceOSPoliciesCompliance": { + "methods": [ + "getInstanceOSPoliciesCompliance" + ] + }, + "GetOSPolicyAssignmentReport": { + "methods": [ + "getOSPolicyAssignmentReport" + ] + }, + "GetInventory": { + "methods": [ + "getInventory" + ] + }, + "GetVulnerabilityReport": { + "methods": [ + "getVulnerabilityReport" + ] + }, + "CreateOSPolicyAssignment": { + "methods": [ + "createOSPolicyAssignment" + ] + }, + "UpdateOSPolicyAssignment": { + "methods": [ + "updateOSPolicyAssignment" + ] + }, + "DeleteOSPolicyAssignment": { + "methods": [ + "deleteOSPolicyAssignment" + ] + }, + "ListOSPolicyAssignments": { + "methods": [ + "listOSPolicyAssignments", + "listOSPolicyAssignmentsStream", + "listOSPolicyAssignmentsAsync" + ] + }, + "ListOSPolicyAssignmentRevisions": { + "methods": [ + "listOSPolicyAssignmentRevisions", + "listOSPolicyAssignmentRevisionsStream", + "listOSPolicyAssignmentRevisionsAsync" + ] + }, + "ListInstanceOSPoliciesCompliances": { + "methods": [ + "listInstanceOSPoliciesCompliances", + "listInstanceOSPoliciesCompliancesStream", + "listInstanceOSPoliciesCompliancesAsync" + ] + }, + "ListOSPolicyAssignmentReports": { + "methods": [ + "listOSPolicyAssignmentReports", + "listOSPolicyAssignmentReportsStream", + "listOSPolicyAssignmentReportsAsync" + ] + }, + "ListInventories": { + "methods": [ + "listInventories", + "listInventoriesStream", + "listInventoriesAsync" + ] + }, + "ListVulnerabilityReports": { + "methods": [ + "listVulnerabilityReports", + "listVulnerabilityReportsStream", + "listVulnerabilityReportsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/index.ts b/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/index.ts new file mode 100644 index 00000000000..953da1ab403 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {OsConfigZonalServiceClient} from './os_config_zonal_service_client'; diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_client.ts b/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_client.ts new file mode 100644 index 00000000000..3e9c71c4260 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_client.ts @@ -0,0 +1,2569 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1alpha/os_config_zonal_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './os_config_zonal_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Zonal OS Config API + * + * The OS Config service is the server-side component that allows users to + * manage package installations and patch jobs for Compute Engine VM instances. + * @class + * @memberof v1alpha + */ +export class OsConfigZonalServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + osConfigZonalServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of OsConfigZonalServiceClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 OsConfigZonalServiceClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof OsConfigZonalServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + instanceOSPoliciesCompliancePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/instanceOSPoliciesCompliances/{instance}' + ), + inventoryPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/instances/{instance}/inventory' + ), + oSPolicyAssignmentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}' + ), + oSPolicyAssignmentReportPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report' + ), + vulnerabilityReportPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport' + ), + }; + + // 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 = { + listOSPolicyAssignments: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'osPolicyAssignments'), + listOSPolicyAssignmentRevisions: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'osPolicyAssignments'), + listInstanceOSPoliciesCompliances: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instanceOsPoliciesCompliances'), + listOSPolicyAssignmentReports: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'osPolicyAssignmentReports'), + listInventories: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'inventories'), + listVulnerabilityReports: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'vulnerabilityReports') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1alpha/{name=projects/*/locations/*/osPolicyAssignments/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1alpha/{name=projects/*/locations/*/osPolicyAssignments/*/operations/*}',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createOSPolicyAssignmentResponse = protoFilesRoot.lookup( + '.google.cloud.osconfig.v1alpha.OSPolicyAssignment') as gax.protobuf.Type; + const createOSPolicyAssignmentMetadata = protoFilesRoot.lookup( + '.google.cloud.osconfig.v1alpha.OSPolicyAssignmentOperationMetadata') as gax.protobuf.Type; + const updateOSPolicyAssignmentResponse = protoFilesRoot.lookup( + '.google.cloud.osconfig.v1alpha.OSPolicyAssignment') as gax.protobuf.Type; + const updateOSPolicyAssignmentMetadata = protoFilesRoot.lookup( + '.google.cloud.osconfig.v1alpha.OSPolicyAssignmentOperationMetadata') as gax.protobuf.Type; + const deleteOSPolicyAssignmentResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteOSPolicyAssignmentMetadata = protoFilesRoot.lookup( + '.google.cloud.osconfig.v1alpha.OSPolicyAssignmentOperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createOSPolicyAssignment: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createOSPolicyAssignmentResponse.decode.bind(createOSPolicyAssignmentResponse), + createOSPolicyAssignmentMetadata.decode.bind(createOSPolicyAssignmentMetadata)), + updateOSPolicyAssignment: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateOSPolicyAssignmentResponse.decode.bind(updateOSPolicyAssignmentResponse), + updateOSPolicyAssignmentMetadata.decode.bind(updateOSPolicyAssignmentMetadata)), + deleteOSPolicyAssignment: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteOSPolicyAssignmentResponse.decode.bind(deleteOSPolicyAssignmentResponse), + deleteOSPolicyAssignmentMetadata.decode.bind(deleteOSPolicyAssignmentMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.osconfig.v1alpha.OsConfigZonalService', 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.osConfigZonalServiceStub) { + return this.osConfigZonalServiceStub; + } + + // Put together the "service stub" for + // google.cloud.osconfig.v1alpha.OsConfigZonalService. + this.osConfigZonalServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.osconfig.v1alpha.OsConfigZonalService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.osconfig.v1alpha.OsConfigZonalService, + 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 osConfigZonalServiceStubMethods = + ['createOsPolicyAssignment', 'updateOsPolicyAssignment', 'getOsPolicyAssignment', 'listOsPolicyAssignments', 'listOsPolicyAssignmentRevisions', 'deleteOsPolicyAssignment', 'getInstanceOsPoliciesCompliance', 'listInstanceOsPoliciesCompliances', 'getOsPolicyAssignmentReport', 'listOsPolicyAssignmentReports', 'getInventory', 'listInventories', 'getVulnerabilityReport', 'listVulnerabilityReports']; + for (const methodName of osConfigZonalServiceStubMethods) { + const callPromise = this.osConfigZonalServiceStub.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.osConfigZonalServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'osconfig.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 'osconfig.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 -- + // ------------------- +/** + * Retrieve an existing OS policy assignment. + * + * This method always returns the latest revision. In order to retrieve a + * previous revision of the assignment, also provide the revision ID in the + * `name` parameter. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of OS policy assignment. + * + * Format: + * `projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}@{revisionId}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment|OSPolicyAssignment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/os_config_zonal_service.get_o_s_policy_assignment.js + * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_GetOSPolicyAssignment_async + */ + getOSPolicyAssignment( + request?: protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment, + protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentRequest|undefined, {}|undefined + ]>; + getOSPolicyAssignment( + request: protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment, + protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentRequest|null|undefined, + {}|null|undefined>): void; + getOSPolicyAssignment( + request: protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentRequest, + callback: Callback< + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment, + protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentRequest|null|undefined, + {}|null|undefined>): void; + getOSPolicyAssignment( + request?: protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment, + protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment, + protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment, + protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getOsPolicyAssignment(request, options, callback); + } +/** + * Get OS policies compliance data for the specified Compute Engine VM + * instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. API resource name for instance OS policies compliance resource. + * + * Format: + * `projects/{project}/locations/{location}/instanceOSPoliciesCompliances/{instance}` + * + * For `{project}`, either Compute Engine project-number or project-id can be + * provided. + * For `{instance}`, either Compute Engine VM instance-id or instance-name can + * be provided. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance|InstanceOSPoliciesCompliance}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/os_config_zonal_service.get_instance_o_s_policies_compliance.js + * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_GetInstanceOSPoliciesCompliance_async + * @deprecated GetInstanceOSPoliciesCompliance is deprecated and may be removed in a future version. + */ + getInstanceOSPoliciesCompliance( + request?: protos.google.cloud.osconfig.v1alpha.IGetInstanceOSPoliciesComplianceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance, + protos.google.cloud.osconfig.v1alpha.IGetInstanceOSPoliciesComplianceRequest|undefined, {}|undefined + ]>; + getInstanceOSPoliciesCompliance( + request: protos.google.cloud.osconfig.v1alpha.IGetInstanceOSPoliciesComplianceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance, + protos.google.cloud.osconfig.v1alpha.IGetInstanceOSPoliciesComplianceRequest|null|undefined, + {}|null|undefined>): void; + getInstanceOSPoliciesCompliance( + request: protos.google.cloud.osconfig.v1alpha.IGetInstanceOSPoliciesComplianceRequest, + callback: Callback< + protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance, + protos.google.cloud.osconfig.v1alpha.IGetInstanceOSPoliciesComplianceRequest|null|undefined, + {}|null|undefined>): void; + getInstanceOSPoliciesCompliance( + request?: protos.google.cloud.osconfig.v1alpha.IGetInstanceOSPoliciesComplianceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance, + protos.google.cloud.osconfig.v1alpha.IGetInstanceOSPoliciesComplianceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance, + protos.google.cloud.osconfig.v1alpha.IGetInstanceOSPoliciesComplianceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance, + protos.google.cloud.osconfig.v1alpha.IGetInstanceOSPoliciesComplianceRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + this.warn('DEP$OsConfigZonalService-$GetInstanceOSPoliciesCompliance','GetInstanceOSPoliciesCompliance is deprecated and may be removed in a future version.', 'DeprecationWarning'); + return this.innerApiCalls.getInstanceOsPoliciesCompliance(request, options, callback); + } +/** + * Get the OS policy asssignment report for the specified Compute Engine VM + * instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. API resource name for OS policy assignment report. + * + * Format: + * `/projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * For `{instance_id}`, either Compute Engine `instance-id` or `instance-name` + * can be provided. + * For `{assignment_id}`, the OSPolicyAssignment id must be provided. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport|OSPolicyAssignmentReport}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/os_config_zonal_service.get_o_s_policy_assignment_report.js + * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_GetOSPolicyAssignmentReport_async + */ + getOSPolicyAssignmentReport( + request?: protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentReportRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport, + protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentReportRequest|undefined, {}|undefined + ]>; + getOSPolicyAssignmentReport( + request: protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentReportRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport, + protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentReportRequest|null|undefined, + {}|null|undefined>): void; + getOSPolicyAssignmentReport( + request: protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentReportRequest, + callback: Callback< + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport, + protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentReportRequest|null|undefined, + {}|null|undefined>): void; + getOSPolicyAssignmentReport( + request?: protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentReportRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport, + protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentReportRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport, + protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentReportRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport, + protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentReportRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getOsPolicyAssignmentReport(request, options, callback); + } +/** + * Get inventory data for the specified VM instance. If the VM has no + * associated inventory, the message `NOT_FOUND` is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. API resource name for inventory resource. + * + * Format: + * `projects/{project}/locations/{location}/instances/{instance}/inventory` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * For `{instance}`, either Compute Engine `instance-id` or `instance-name` + * can be provided. + * @param {google.cloud.osconfig.v1alpha.InventoryView} request.view + * Inventory view indicating what information should be included in the + * inventory resource. If unspecified, the default view is BASIC. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1alpha.Inventory|Inventory}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/os_config_zonal_service.get_inventory.js + * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_GetInventory_async + */ + getInventory( + request?: protos.google.cloud.osconfig.v1alpha.IGetInventoryRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IInventory, + protos.google.cloud.osconfig.v1alpha.IGetInventoryRequest|undefined, {}|undefined + ]>; + getInventory( + request: protos.google.cloud.osconfig.v1alpha.IGetInventoryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1alpha.IInventory, + protos.google.cloud.osconfig.v1alpha.IGetInventoryRequest|null|undefined, + {}|null|undefined>): void; + getInventory( + request: protos.google.cloud.osconfig.v1alpha.IGetInventoryRequest, + callback: Callback< + protos.google.cloud.osconfig.v1alpha.IInventory, + protos.google.cloud.osconfig.v1alpha.IGetInventoryRequest|null|undefined, + {}|null|undefined>): void; + getInventory( + request?: protos.google.cloud.osconfig.v1alpha.IGetInventoryRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1alpha.IInventory, + protos.google.cloud.osconfig.v1alpha.IGetInventoryRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1alpha.IInventory, + protos.google.cloud.osconfig.v1alpha.IGetInventoryRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IInventory, + protos.google.cloud.osconfig.v1alpha.IGetInventoryRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getInventory(request, options, callback); + } +/** + * Gets the vulnerability report for the specified VM instance. Only VMs with + * inventory data have vulnerability reports associated with them. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. API resource name for vulnerability resource. + * + * Format: + * `projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * For `{instance}`, either Compute Engine `instance-id` or `instance-name` + * can be provided. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1alpha.VulnerabilityReport|VulnerabilityReport}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/os_config_zonal_service.get_vulnerability_report.js + * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_GetVulnerabilityReport_async + */ + getVulnerabilityReport( + request?: protos.google.cloud.osconfig.v1alpha.IGetVulnerabilityReportRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport, + protos.google.cloud.osconfig.v1alpha.IGetVulnerabilityReportRequest|undefined, {}|undefined + ]>; + getVulnerabilityReport( + request: protos.google.cloud.osconfig.v1alpha.IGetVulnerabilityReportRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport, + protos.google.cloud.osconfig.v1alpha.IGetVulnerabilityReportRequest|null|undefined, + {}|null|undefined>): void; + getVulnerabilityReport( + request: protos.google.cloud.osconfig.v1alpha.IGetVulnerabilityReportRequest, + callback: Callback< + protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport, + protos.google.cloud.osconfig.v1alpha.IGetVulnerabilityReportRequest|null|undefined, + {}|null|undefined>): void; + getVulnerabilityReport( + request?: protos.google.cloud.osconfig.v1alpha.IGetVulnerabilityReportRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport, + protos.google.cloud.osconfig.v1alpha.IGetVulnerabilityReportRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport, + protos.google.cloud.osconfig.v1alpha.IGetVulnerabilityReportRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport, + protos.google.cloud.osconfig.v1alpha.IGetVulnerabilityReportRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getVulnerabilityReport(request, options, callback); + } + +/** + * Create an OS policy assignment. + * + * This method also creates the first revision of the OS policy assignment. + * + * This method returns a long running operation (LRO) that contains the + * rollout details. The rollout can be cancelled by cancelling the LRO. + * + * For more information, see [Method: + * projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1alpha/projects.locations.osPolicyAssignments.operations/cancel). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name in the form: + * projects/{project}/locations/{location} + * @param {google.cloud.osconfig.v1alpha.OSPolicyAssignment} request.osPolicyAssignment + * Required. The OS policy assignment to be created. + * @param {string} request.osPolicyAssignmentId + * Required. The logical name of the OS policy assignment in the project + * with the following restrictions: + * + * * Must contain only lowercase letters, numbers, and hyphens. + * * Must start with a letter. + * * Must be between 1-63 characters. + * * Must end with a number or a letter. + * * Must be unique within the project. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/os_config_zonal_service.create_o_s_policy_assignment.js + * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_CreateOSPolicyAssignment_async + */ + createOSPolicyAssignment( + request?: protos.google.cloud.osconfig.v1alpha.ICreateOSPolicyAssignmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createOSPolicyAssignment( + request: protos.google.cloud.osconfig.v1alpha.ICreateOSPolicyAssignmentRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createOSPolicyAssignment( + request: protos.google.cloud.osconfig.v1alpha.ICreateOSPolicyAssignmentRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createOSPolicyAssignment( + request?: protos.google.cloud.osconfig.v1alpha.ICreateOSPolicyAssignmentRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createOsPolicyAssignment(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createOSPolicyAssignment()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/os_config_zonal_service.create_o_s_policy_assignment.js + * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_CreateOSPolicyAssignment_async + */ + async checkCreateOSPolicyAssignmentProgress(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.createOSPolicyAssignment, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Update an existing OS policy assignment. + * + * This method creates a new revision of the OS policy assignment. + * + * This method returns a long running operation (LRO) that contains the + * rollout details. The rollout can be cancelled by cancelling the LRO. + * + * For more information, see [Method: + * projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1alpha/projects.locations.osPolicyAssignments.operations/cancel). + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.osconfig.v1alpha.OSPolicyAssignment} request.osPolicyAssignment + * Required. The updated OS policy assignment. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask that controls which fields of the assignment should be 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/os_config_zonal_service.update_o_s_policy_assignment.js + * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_UpdateOSPolicyAssignment_async + */ + updateOSPolicyAssignment( + request?: protos.google.cloud.osconfig.v1alpha.IUpdateOSPolicyAssignmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateOSPolicyAssignment( + request: protos.google.cloud.osconfig.v1alpha.IUpdateOSPolicyAssignmentRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateOSPolicyAssignment( + request: protos.google.cloud.osconfig.v1alpha.IUpdateOSPolicyAssignmentRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateOSPolicyAssignment( + request?: protos.google.cloud.osconfig.v1alpha.IUpdateOSPolicyAssignmentRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'os_policy_assignment.name': request.osPolicyAssignment!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateOsPolicyAssignment(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateOSPolicyAssignment()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/os_config_zonal_service.update_o_s_policy_assignment.js + * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_UpdateOSPolicyAssignment_async + */ + async checkUpdateOSPolicyAssignmentProgress(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.updateOSPolicyAssignment, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Delete the OS policy assignment. + * + * This method creates a new revision of the OS policy assignment. + * + * This method returns a long running operation (LRO) that contains the + * rollout details. The rollout can be cancelled by cancelling the LRO. + * + * If the LRO completes and is not cancelled, all revisions associated with + * the OS policy assignment are deleted. + * + * For more information, see [Method: + * projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1alpha/projects.locations.osPolicyAssignments.operations/cancel). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the OS policy assignment to be deleted + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/os_config_zonal_service.delete_o_s_policy_assignment.js + * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_DeleteOSPolicyAssignment_async + */ + deleteOSPolicyAssignment( + request?: protos.google.cloud.osconfig.v1alpha.IDeleteOSPolicyAssignmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteOSPolicyAssignment( + request: protos.google.cloud.osconfig.v1alpha.IDeleteOSPolicyAssignmentRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteOSPolicyAssignment( + request: protos.google.cloud.osconfig.v1alpha.IDeleteOSPolicyAssignmentRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteOSPolicyAssignment( + request?: protos.google.cloud.osconfig.v1alpha.IDeleteOSPolicyAssignmentRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteOsPolicyAssignment(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteOSPolicyAssignment()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/os_config_zonal_service.delete_o_s_policy_assignment.js + * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_DeleteOSPolicyAssignment_async + */ + async checkDeleteOSPolicyAssignmentProgress(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.deleteOSPolicyAssignment, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * List the OS policy assignments under the parent resource. + * + * For each OS policy assignment, the latest revision is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {number} request.pageSize + * The maximum number of assignments to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListOSPolicyAssignments` that indicates where this listing should continue + * from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment|OSPolicyAssignment}. + * 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 `listOSPolicyAssignmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listOSPolicyAssignments( + request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment[], + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest|null, + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsResponse + ]>; + listOSPolicyAssignments( + request: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest, + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment>): void; + listOSPolicyAssignments( + request: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest, + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment>): void; + listOSPolicyAssignments( + request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest, + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment>, + callback?: PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest, + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment>): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment[], + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest|null, + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listOsPolicyAssignments(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 resource name. + * @param {number} request.pageSize + * The maximum number of assignments to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListOSPolicyAssignments` that indicates where this listing should continue + * from. + * @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 protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment|OSPolicyAssignment} 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 `listOSPolicyAssignmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listOSPolicyAssignmentsStream( + request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest, + 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['listOsPolicyAssignments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listOSPolicyAssignments.createStream( + this.innerApiCalls.listOsPolicyAssignments as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listOSPolicyAssignments`, 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 resource name. + * @param {number} request.pageSize + * The maximum number of assignments to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListOSPolicyAssignments` that indicates where this listing should continue + * from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment|OSPolicyAssignment}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignments.js + * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignments_async + */ + listOSPolicyAssignmentsAsync( + request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest, + 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['listOsPolicyAssignments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listOSPolicyAssignments.asyncIterate( + this.innerApiCalls['listOsPolicyAssignments'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * List the OS policy assignment revisions for a given OS policy assignment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the OS policy assignment to list revisions for. + * @param {number} request.pageSize + * The maximum number of revisions to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListOSPolicyAssignmentRevisions` that indicates where this listing should + * continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment|OSPolicyAssignment}. + * 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 `listOSPolicyAssignmentRevisionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listOSPolicyAssignmentRevisions( + request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment[], + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest|null, + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsResponse + ]>; + listOSPolicyAssignmentRevisions( + request: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest, + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment>): void; + listOSPolicyAssignmentRevisions( + request: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest, + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment>): void; + listOSPolicyAssignmentRevisions( + request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest, + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment>, + callback?: PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest, + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment>): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment[], + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest|null, + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.listOsPolicyAssignmentRevisions(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the OS policy assignment to list revisions for. + * @param {number} request.pageSize + * The maximum number of revisions to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListOSPolicyAssignmentRevisions` that indicates where this listing should + * continue from. + * @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 protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment|OSPolicyAssignment} 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 `listOSPolicyAssignmentRevisionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listOSPolicyAssignmentRevisionsStream( + request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listOsPolicyAssignmentRevisions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listOSPolicyAssignmentRevisions.createStream( + this.innerApiCalls.listOsPolicyAssignmentRevisions as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listOSPolicyAssignmentRevisions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the OS policy assignment to list revisions for. + * @param {number} request.pageSize + * The maximum number of revisions to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListOSPolicyAssignmentRevisions` that indicates where this listing should + * continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment|OSPolicyAssignment}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignment_revisions.js + * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignmentRevisions_async + */ + listOSPolicyAssignmentRevisionsAsync( + request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listOsPolicyAssignmentRevisions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate( + this.innerApiCalls['listOsPolicyAssignmentRevisions'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * List OS policies compliance data for all Compute Engine VM instances in the + * specified zone. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * + * Format: `projects/{project}/locations/{location}` + * + * For `{project}`, either Compute Engine project-number or project-id can be + * provided. + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListInstanceOSPoliciesCompliances` that indicates where this listing + * should continue from. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by a + * `InstanceOSPoliciesCompliance` API resource to be included in the response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance|InstanceOSPoliciesCompliance}. + * 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 `listInstanceOSPoliciesCompliancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @deprecated ListInstanceOSPoliciesCompliances is deprecated and may be removed in a future version. + */ + listInstanceOSPoliciesCompliances( + request?: protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance[], + protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest|null, + protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesResponse + ]>; + listInstanceOSPoliciesCompliances( + request: protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest, + protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance>): void; + listInstanceOSPoliciesCompliances( + request: protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest, + protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance>): void; + listInstanceOSPoliciesCompliances( + request?: protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest, + protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance>, + callback?: PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest, + protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance>): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance[], + protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest|null, + protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + this.warn('DEP$OsConfigZonalService-$ListInstanceOSPoliciesCompliances','ListInstanceOSPoliciesCompliances is deprecated and may be removed in a future version.', 'DeprecationWarning'); + return this.innerApiCalls.listInstanceOsPoliciesCompliances(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 resource name. + * + * Format: `projects/{project}/locations/{location}` + * + * For `{project}`, either Compute Engine project-number or project-id can be + * provided. + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListInstanceOSPoliciesCompliances` that indicates where this listing + * should continue from. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by a + * `InstanceOSPoliciesCompliance` API resource to be included in the response. + * @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 protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance|InstanceOSPoliciesCompliance} 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 `listInstanceOSPoliciesCompliancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @deprecated ListInstanceOSPoliciesCompliances is deprecated and may be removed in a future version. + */ + listInstanceOSPoliciesCompliancesStream( + request?: protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest, + 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['listInstanceOsPoliciesCompliances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + this.warn('DEP$OsConfigZonalService-$ListInstanceOSPoliciesCompliances','ListInstanceOSPoliciesCompliances is deprecated and may be removed in a future version.', 'DeprecationWarning'); + return this.descriptors.page.listInstanceOSPoliciesCompliances.createStream( + this.innerApiCalls.listInstanceOsPoliciesCompliances as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listInstanceOSPoliciesCompliances`, 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 resource name. + * + * Format: `projects/{project}/locations/{location}` + * + * For `{project}`, either Compute Engine project-number or project-id can be + * provided. + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListInstanceOSPoliciesCompliances` that indicates where this listing + * should continue from. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by a + * `InstanceOSPoliciesCompliance` API resource to be included in the response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance|InstanceOSPoliciesCompliance}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/os_config_zonal_service.list_instance_o_s_policies_compliances.js + * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_ListInstanceOSPoliciesCompliances_async + * @deprecated ListInstanceOSPoliciesCompliances is deprecated and may be removed in a future version. + */ + listInstanceOSPoliciesCompliancesAsync( + request?: protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest, + 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['listInstanceOsPoliciesCompliances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + this.warn('DEP$OsConfigZonalService-$ListInstanceOSPoliciesCompliances','ListInstanceOSPoliciesCompliances is deprecated and may be removed in a future version.', 'DeprecationWarning'); + return this.descriptors.page.listInstanceOSPoliciesCompliances.asyncIterate( + this.innerApiCalls['listInstanceOsPoliciesCompliances'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * List OS policy asssignment reports for all Compute Engine VM instances in + * the specified zone. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * + * Format: + * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/reports` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * For `{instance}`, either `instance-name`, `instance-id`, or `-` can be + * provided. If '-' is provided, the response will include + * OSPolicyAssignmentReports for all instances in the project/location. + * For `{assignment}`, either `assignment-id` or `-` can be provided. If '-' + * is provided, the response will include OSPolicyAssignmentReports for all + * OSPolicyAssignments in the project/location. + * Either {instance} or {assignment} must be `-`. + * + * For example: + * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/-/reports` + * returns all reports for the instance + * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/{assignment-id}/reports` + * returns all the reports for the given assignment across all instances. + * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/-/reports` + * returns all the reports for all assignments across all instances. + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by the + * `OSPolicyAssignmentReport` API resource that is included in the response. + * @param {string} request.pageToken + * A pagination token returned from a previous call to the + * `ListOSPolicyAssignmentReports` method that indicates where this listing + * should continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport|OSPolicyAssignmentReport}. + * 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 `listOSPolicyAssignmentReportsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listOSPolicyAssignmentReports( + request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport[], + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest|null, + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsResponse + ]>; + listOSPolicyAssignmentReports( + request: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest, + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport>): void; + listOSPolicyAssignmentReports( + request: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest, + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport>): void; + listOSPolicyAssignmentReports( + request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest, + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport>, + callback?: PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest, + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport>): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport[], + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest|null, + protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listOsPolicyAssignmentReports(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 resource name. + * + * Format: + * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/reports` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * For `{instance}`, either `instance-name`, `instance-id`, or `-` can be + * provided. If '-' is provided, the response will include + * OSPolicyAssignmentReports for all instances in the project/location. + * For `{assignment}`, either `assignment-id` or `-` can be provided. If '-' + * is provided, the response will include OSPolicyAssignmentReports for all + * OSPolicyAssignments in the project/location. + * Either {instance} or {assignment} must be `-`. + * + * For example: + * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/-/reports` + * returns all reports for the instance + * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/{assignment-id}/reports` + * returns all the reports for the given assignment across all instances. + * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/-/reports` + * returns all the reports for all assignments across all instances. + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by the + * `OSPolicyAssignmentReport` API resource that is included in the response. + * @param {string} request.pageToken + * A pagination token returned from a previous call to the + * `ListOSPolicyAssignmentReports` method that indicates where this listing + * should continue from. + * @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 protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport|OSPolicyAssignmentReport} 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 `listOSPolicyAssignmentReportsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listOSPolicyAssignmentReportsStream( + request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest, + 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['listOsPolicyAssignmentReports']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listOSPolicyAssignmentReports.createStream( + this.innerApiCalls.listOsPolicyAssignmentReports as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listOSPolicyAssignmentReports`, 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 resource name. + * + * Format: + * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/reports` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * For `{instance}`, either `instance-name`, `instance-id`, or `-` can be + * provided. If '-' is provided, the response will include + * OSPolicyAssignmentReports for all instances in the project/location. + * For `{assignment}`, either `assignment-id` or `-` can be provided. If '-' + * is provided, the response will include OSPolicyAssignmentReports for all + * OSPolicyAssignments in the project/location. + * Either {instance} or {assignment} must be `-`. + * + * For example: + * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/-/reports` + * returns all reports for the instance + * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/{assignment-id}/reports` + * returns all the reports for the given assignment across all instances. + * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/-/reports` + * returns all the reports for all assignments across all instances. + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by the + * `OSPolicyAssignmentReport` API resource that is included in the response. + * @param {string} request.pageToken + * A pagination token returned from a previous call to the + * `ListOSPolicyAssignmentReports` method that indicates where this listing + * should continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport|OSPolicyAssignmentReport}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignment_reports.js + * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignmentReports_async + */ + listOSPolicyAssignmentReportsAsync( + request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest, + 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['listOsPolicyAssignmentReports']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listOSPolicyAssignmentReports.asyncIterate( + this.innerApiCalls['listOsPolicyAssignmentReports'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * List inventory data for all VM instances in the specified zone. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * + * Format: `projects/{project}/locations/{location}/instances/-` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * @param {google.cloud.osconfig.v1alpha.InventoryView} request.view + * Inventory view indicating what information should be included in the + * inventory resource. If unspecified, the default view is BASIC. + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListInventories` that indicates where this listing + * should continue from. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by a + * `Inventory` API resource to be included in the response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1alpha.Inventory|Inventory}. + * 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 `listInventoriesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listInventories( + request?: protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IInventory[], + protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest|null, + protos.google.cloud.osconfig.v1alpha.IListInventoriesResponse + ]>; + listInventories( + request: protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest, + protos.google.cloud.osconfig.v1alpha.IListInventoriesResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IInventory>): void; + listInventories( + request: protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest, + protos.google.cloud.osconfig.v1alpha.IListInventoriesResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IInventory>): void; + listInventories( + request?: protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest, + protos.google.cloud.osconfig.v1alpha.IListInventoriesResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IInventory>, + callback?: PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest, + protos.google.cloud.osconfig.v1alpha.IListInventoriesResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IInventory>): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IInventory[], + protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest|null, + protos.google.cloud.osconfig.v1alpha.IListInventoriesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listInventories(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 resource name. + * + * Format: `projects/{project}/locations/{location}/instances/-` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * @param {google.cloud.osconfig.v1alpha.InventoryView} request.view + * Inventory view indicating what information should be included in the + * inventory resource. If unspecified, the default view is BASIC. + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListInventories` that indicates where this listing + * should continue from. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by a + * `Inventory` API resource to be included in the response. + * @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 protos.google.cloud.osconfig.v1alpha.Inventory|Inventory} 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 `listInventoriesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listInventoriesStream( + request?: protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest, + 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['listInventories']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInventories.createStream( + this.innerApiCalls.listInventories as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listInventories`, 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 resource name. + * + * Format: `projects/{project}/locations/{location}/instances/-` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * @param {google.cloud.osconfig.v1alpha.InventoryView} request.view + * Inventory view indicating what information should be included in the + * inventory resource. If unspecified, the default view is BASIC. + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListInventories` that indicates where this listing + * should continue from. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by a + * `Inventory` API resource to be included in the response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.osconfig.v1alpha.Inventory|Inventory}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/os_config_zonal_service.list_inventories.js + * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_ListInventories_async + */ + listInventoriesAsync( + request?: protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest, + 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['listInventories']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInventories.asyncIterate( + this.innerApiCalls['listInventories'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * List vulnerability reports for all VM instances in the specified zone. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * + * Format: `projects/{project}/locations/{location}/instances/-` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListVulnerabilityReports` that indicates where this listing + * should continue from. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by a + * `vulnerabilityReport` API resource to be included in the response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1alpha.VulnerabilityReport|VulnerabilityReport}. + * 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 `listVulnerabilityReportsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listVulnerabilityReports( + request?: protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport[], + protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest|null, + protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsResponse + ]>; + listVulnerabilityReports( + request: protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest, + protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport>): void; + listVulnerabilityReports( + request: protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest, + protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport>): void; + listVulnerabilityReports( + request?: protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest, + protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport>, + callback?: PaginationCallback< + protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest, + protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsResponse|null|undefined, + protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport>): + Promise<[ + protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport[], + protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest|null, + protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listVulnerabilityReports(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 resource name. + * + * Format: `projects/{project}/locations/{location}/instances/-` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListVulnerabilityReports` that indicates where this listing + * should continue from. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by a + * `vulnerabilityReport` API resource to be included in the response. + * @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 protos.google.cloud.osconfig.v1alpha.VulnerabilityReport|VulnerabilityReport} 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 `listVulnerabilityReportsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listVulnerabilityReportsStream( + request?: protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest, + 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['listVulnerabilityReports']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listVulnerabilityReports.createStream( + this.innerApiCalls.listVulnerabilityReports as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listVulnerabilityReports`, 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 resource name. + * + * Format: `projects/{project}/locations/{location}/instances/-` + * + * For `{project}`, either `project-number` or `project-id` can be provided. + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to + * `ListVulnerabilityReports` that indicates where this listing + * should continue from. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by a + * `vulnerabilityReport` API resource to be included in the response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.osconfig.v1alpha.VulnerabilityReport|VulnerabilityReport}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/os_config_zonal_service.list_vulnerability_reports.js + * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_ListVulnerabilityReports_async + */ + listVulnerabilityReportsAsync( + request?: protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest, + 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['listVulnerabilityReports']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listVulnerabilityReports.asyncIterate( + this.innerApiCalls['listVulnerabilityReports'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified instanceOSPoliciesCompliance resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} instance + * @returns {string} Resource name string. + */ + instanceOSPoliciesCompliancePath(project:string,location:string,instance:string) { + return this.pathTemplates.instanceOSPoliciesCompliancePathTemplate.render({ + project: project, + location: location, + instance: instance, + }); + } + + /** + * Parse the project from InstanceOSPoliciesCompliance resource. + * + * @param {string} instanceOSPoliciesComplianceName + * A fully-qualified path representing InstanceOSPoliciesCompliance resource. + * @returns {string} A string representing the project. + */ + matchProjectFromInstanceOSPoliciesComplianceName(instanceOSPoliciesComplianceName: string) { + return this.pathTemplates.instanceOSPoliciesCompliancePathTemplate.match(instanceOSPoliciesComplianceName).project; + } + + /** + * Parse the location from InstanceOSPoliciesCompliance resource. + * + * @param {string} instanceOSPoliciesComplianceName + * A fully-qualified path representing InstanceOSPoliciesCompliance resource. + * @returns {string} A string representing the location. + */ + matchLocationFromInstanceOSPoliciesComplianceName(instanceOSPoliciesComplianceName: string) { + return this.pathTemplates.instanceOSPoliciesCompliancePathTemplate.match(instanceOSPoliciesComplianceName).location; + } + + /** + * Parse the instance from InstanceOSPoliciesCompliance resource. + * + * @param {string} instanceOSPoliciesComplianceName + * A fully-qualified path representing InstanceOSPoliciesCompliance resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromInstanceOSPoliciesComplianceName(instanceOSPoliciesComplianceName: string) { + return this.pathTemplates.instanceOSPoliciesCompliancePathTemplate.match(instanceOSPoliciesComplianceName).instance; + } + + /** + * Return a fully-qualified inventory resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} instance + * @returns {string} Resource name string. + */ + inventoryPath(project:string,location:string,instance:string) { + return this.pathTemplates.inventoryPathTemplate.render({ + project: project, + location: location, + instance: instance, + }); + } + + /** + * Parse the project from Inventory resource. + * + * @param {string} inventoryName + * A fully-qualified path representing Inventory resource. + * @returns {string} A string representing the project. + */ + matchProjectFromInventoryName(inventoryName: string) { + return this.pathTemplates.inventoryPathTemplate.match(inventoryName).project; + } + + /** + * Parse the location from Inventory resource. + * + * @param {string} inventoryName + * A fully-qualified path representing Inventory resource. + * @returns {string} A string representing the location. + */ + matchLocationFromInventoryName(inventoryName: string) { + return this.pathTemplates.inventoryPathTemplate.match(inventoryName).location; + } + + /** + * Parse the instance from Inventory resource. + * + * @param {string} inventoryName + * A fully-qualified path representing Inventory resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromInventoryName(inventoryName: string) { + return this.pathTemplates.inventoryPathTemplate.match(inventoryName).instance; + } + + /** + * Return a fully-qualified oSPolicyAssignment resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} os_policy_assignment + * @returns {string} Resource name string. + */ + oSPolicyAssignmentPath(project:string,location:string,osPolicyAssignment:string) { + return this.pathTemplates.oSPolicyAssignmentPathTemplate.render({ + project: project, + location: location, + os_policy_assignment: osPolicyAssignment, + }); + } + + /** + * Parse the project from OSPolicyAssignment resource. + * + * @param {string} oSPolicyAssignmentName + * A fully-qualified path representing OSPolicyAssignment resource. + * @returns {string} A string representing the project. + */ + matchProjectFromOSPolicyAssignmentName(oSPolicyAssignmentName: string) { + return this.pathTemplates.oSPolicyAssignmentPathTemplate.match(oSPolicyAssignmentName).project; + } + + /** + * Parse the location from OSPolicyAssignment resource. + * + * @param {string} oSPolicyAssignmentName + * A fully-qualified path representing OSPolicyAssignment resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOSPolicyAssignmentName(oSPolicyAssignmentName: string) { + return this.pathTemplates.oSPolicyAssignmentPathTemplate.match(oSPolicyAssignmentName).location; + } + + /** + * Parse the os_policy_assignment from OSPolicyAssignment resource. + * + * @param {string} oSPolicyAssignmentName + * A fully-qualified path representing OSPolicyAssignment resource. + * @returns {string} A string representing the os_policy_assignment. + */ + matchOsPolicyAssignmentFromOSPolicyAssignmentName(oSPolicyAssignmentName: string) { + return this.pathTemplates.oSPolicyAssignmentPathTemplate.match(oSPolicyAssignmentName).os_policy_assignment; + } + + /** + * Return a fully-qualified oSPolicyAssignmentReport resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} instance + * @param {string} assignment + * @returns {string} Resource name string. + */ + oSPolicyAssignmentReportPath(project:string,location:string,instance:string,assignment:string) { + return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.render({ + project: project, + location: location, + instance: instance, + assignment: assignment, + }); + } + + /** + * Parse the project from OSPolicyAssignmentReport resource. + * + * @param {string} oSPolicyAssignmentReportName + * A fully-qualified path representing OSPolicyAssignmentReport resource. + * @returns {string} A string representing the project. + */ + matchProjectFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { + return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).project; + } + + /** + * Parse the location from OSPolicyAssignmentReport resource. + * + * @param {string} oSPolicyAssignmentReportName + * A fully-qualified path representing OSPolicyAssignmentReport resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { + return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).location; + } + + /** + * Parse the instance from OSPolicyAssignmentReport resource. + * + * @param {string} oSPolicyAssignmentReportName + * A fully-qualified path representing OSPolicyAssignmentReport resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { + return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).instance; + } + + /** + * Parse the assignment from OSPolicyAssignmentReport resource. + * + * @param {string} oSPolicyAssignmentReportName + * A fully-qualified path representing OSPolicyAssignmentReport resource. + * @returns {string} A string representing the assignment. + */ + matchAssignmentFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { + return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).assignment; + } + + /** + * Return a fully-qualified vulnerabilityReport resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} instance + * @returns {string} Resource name string. + */ + vulnerabilityReportPath(project:string,location:string,instance:string) { + return this.pathTemplates.vulnerabilityReportPathTemplate.render({ + project: project, + location: location, + instance: instance, + }); + } + + /** + * Parse the project from VulnerabilityReport resource. + * + * @param {string} vulnerabilityReportName + * A fully-qualified path representing VulnerabilityReport resource. + * @returns {string} A string representing the project. + */ + matchProjectFromVulnerabilityReportName(vulnerabilityReportName: string) { + return this.pathTemplates.vulnerabilityReportPathTemplate.match(vulnerabilityReportName).project; + } + + /** + * Parse the location from VulnerabilityReport resource. + * + * @param {string} vulnerabilityReportName + * A fully-qualified path representing VulnerabilityReport resource. + * @returns {string} A string representing the location. + */ + matchLocationFromVulnerabilityReportName(vulnerabilityReportName: string) { + return this.pathTemplates.vulnerabilityReportPathTemplate.match(vulnerabilityReportName).location; + } + + /** + * Parse the instance from VulnerabilityReport resource. + * + * @param {string} vulnerabilityReportName + * A fully-qualified path representing VulnerabilityReport resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromVulnerabilityReportName(vulnerabilityReportName: string) { + return this.pathTemplates.vulnerabilityReportPathTemplate.match(vulnerabilityReportName).instance; + } + + /** + * 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.osConfigZonalServiceStub && !this._terminated) { + return this.osConfigZonalServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_client_config.json b/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_client_config.json new file mode 100644 index 00000000000..130d4b4af17 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_client_config.json @@ -0,0 +1,108 @@ +{ + "interfaces": { + "google.cloud.osconfig.v1alpha.OsConfigZonalService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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 + }, + "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c": { + "initial_retry_delay_millis": 1000, + "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": { + "CreateOSPolicyAssignment": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "UpdateOSPolicyAssignment": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "GetOSPolicyAssignment": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "ListOSPolicyAssignments": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "ListOSPolicyAssignmentRevisions": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "DeleteOSPolicyAssignment": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "GetInstanceOSPoliciesCompliance": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "ListInstanceOSPoliciesCompliances": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "GetOSPolicyAssignmentReport": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "ListOSPolicyAssignmentReports": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "GetInventory": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "ListInventories": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "GetVulnerabilityReport": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "ListVulnerabilityReports": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_proto_list.json b/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_proto_list.json new file mode 100644 index 00000000000..8cf88654436 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_proto_list.json @@ -0,0 +1,11 @@ +[ + "../../protos/google/cloud/osconfig/v1alpha/config_common.proto", + "../../protos/google/cloud/osconfig/v1alpha/instance_os_policies_compliance.proto", + "../../protos/google/cloud/osconfig/v1alpha/inventory.proto", + "../../protos/google/cloud/osconfig/v1alpha/os_policy.proto", + "../../protos/google/cloud/osconfig/v1alpha/os_policy_assignment_reports.proto", + "../../protos/google/cloud/osconfig/v1alpha/os_policy_assignments.proto", + "../../protos/google/cloud/osconfig/v1alpha/osconfig_common.proto", + "../../protos/google/cloud/osconfig/v1alpha/osconfig_zonal_service.proto", + "../../protos/google/cloud/osconfig/v1alpha/vulnerability.proto" +] diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..e75225b1b68 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const osconfig = require('@google-cloud/os-config'); + +function main() { + const osConfigZonalServiceClient = new osconfig.OsConfigZonalServiceClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..b1559446972 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {OsConfigZonalServiceClient} from '@google-cloud/os-config'; + +// check that the client class type name can be used +function doStuffWithOsConfigZonalServiceClient(client: OsConfigZonalServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const osConfigZonalServiceClient = new OsConfigZonalServiceClient(); + doStuffWithOsConfigZonalServiceClient(osConfigZonalServiceClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/install.ts b/owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/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-osconfig/v1alpha/test/gapic_os_config_zonal_service_v1alpha.ts b/owl-bot-staging/google-cloud-osconfig/v1alpha/test/gapic_os_config_zonal_service_v1alpha.ts new file mode 100644 index 00000000000..83fe79116a9 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/test/gapic_os_config_zonal_service_v1alpha.ts @@ -0,0 +1,2952 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 osconfigzonalserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1alpha.OsConfigZonalServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.osConfigZonalServiceStub, undefined); + await client.initialize(); + assert(client.osConfigZonalServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.osConfigZonalServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.osConfigZonalServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + 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 osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + 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('getOSPolicyAssignment', () => { + it('invokes getOSPolicyAssignment without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment() + ); + client.innerApiCalls.getOsPolicyAssignment = stubSimpleCall(expectedResponse); + const [response] = await client.getOSPolicyAssignment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getOSPolicyAssignment without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment() + ); + client.innerApiCalls.getOsPolicyAssignment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getOSPolicyAssignment( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getOSPolicyAssignment with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getOsPolicyAssignment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getOSPolicyAssignment(request), expectedError); + const actualRequest = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getOSPolicyAssignment with closed client', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getOSPolicyAssignment(request), expectedError); + }); + }); + + describe('getInstanceOSPoliciesCompliance', () => { + it('invokes getInstanceOSPoliciesCompliance without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance() + ); + client.innerApiCalls.getInstanceOsPoliciesCompliance = stubSimpleCall(expectedResponse); + const [response] = await client.getInstanceOSPoliciesCompliance(request); + assert(stub.calledOnce); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstanceOsPoliciesCompliance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstanceOsPoliciesCompliance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstanceOSPoliciesCompliance without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance() + ); + client.innerApiCalls.getInstanceOsPoliciesCompliance = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstanceOSPoliciesCompliance( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert(stub.calledOnce); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstanceOsPoliciesCompliance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstanceOsPoliciesCompliance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstanceOSPoliciesCompliance with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstanceOsPoliciesCompliance = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getInstanceOSPoliciesCompliance(request), expectedError); + assert(stub.calledOnce); + const actualRequest = (client.innerApiCalls.getInstanceOsPoliciesCompliance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstanceOsPoliciesCompliance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstanceOSPoliciesCompliance with closed client', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getInstanceOSPoliciesCompliance(request), expectedError); + assert(stub.calledOnce); + }); + }); + + describe('getOSPolicyAssignmentReport', () => { + it('invokes getOSPolicyAssignmentReport without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport() + ); + client.innerApiCalls.getOsPolicyAssignmentReport = stubSimpleCall(expectedResponse); + const [response] = await client.getOSPolicyAssignmentReport(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getOSPolicyAssignmentReport without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport() + ); + client.innerApiCalls.getOsPolicyAssignmentReport = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getOSPolicyAssignmentReport( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getOSPolicyAssignmentReport with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getOsPolicyAssignmentReport = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getOSPolicyAssignmentReport(request), expectedError); + const actualRequest = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getOSPolicyAssignmentReport with closed client', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getOSPolicyAssignmentReport(request), expectedError); + }); + }); + + describe('getInventory', () => { + it('invokes getInventory without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.GetInventoryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetInventoryRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.Inventory() + ); + client.innerApiCalls.getInventory = stubSimpleCall(expectedResponse); + const [response] = await client.getInventory(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInventory as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInventory as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInventory without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.GetInventoryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetInventoryRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.Inventory() + ); + client.innerApiCalls.getInventory = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInventory( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IInventory|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInventory as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInventory as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInventory with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.GetInventoryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetInventoryRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInventory = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getInventory(request), expectedError); + const actualRequest = (client.innerApiCalls.getInventory as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInventory as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInventory with closed client', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.GetInventoryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetInventoryRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getInventory(request), expectedError); + }); + }); + + describe('getVulnerabilityReport', () => { + it('invokes getVulnerabilityReport without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport() + ); + client.innerApiCalls.getVulnerabilityReport = stubSimpleCall(expectedResponse); + const [response] = await client.getVulnerabilityReport(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getVulnerabilityReport as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getVulnerabilityReport as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getVulnerabilityReport without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport() + ); + client.innerApiCalls.getVulnerabilityReport = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getVulnerabilityReport( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getVulnerabilityReport as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getVulnerabilityReport as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getVulnerabilityReport with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getVulnerabilityReport = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getVulnerabilityReport(request), expectedError); + const actualRequest = (client.innerApiCalls.getVulnerabilityReport as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getVulnerabilityReport as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getVulnerabilityReport with closed client', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getVulnerabilityReport(request), expectedError); + }); + }); + + describe('createOSPolicyAssignment', () => { + it('invokes createOSPolicyAssignment without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createOsPolicyAssignment = stubLongRunningCall(expectedResponse); + const [operation] = await client.createOSPolicyAssignment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createOSPolicyAssignment without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createOsPolicyAssignment = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createOSPolicyAssignment( + request, + (err?: Error|null, + result?: 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.createOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createOSPolicyAssignment with call error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createOsPolicyAssignment = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createOSPolicyAssignment(request), expectedError); + const actualRequest = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createOSPolicyAssignment with LRO error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createOsPolicyAssignment = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createOSPolicyAssignment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateOSPolicyAssignmentProgress without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateOSPolicyAssignmentProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateOSPolicyAssignmentProgress with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateOSPolicyAssignmentProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateOSPolicyAssignment', () => { + it('invokes updateOSPolicyAssignment without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest() + ); + request.osPolicyAssignment ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest', ['osPolicyAssignment', 'name']); + request.osPolicyAssignment.name = defaultValue1; + const expectedHeaderRequestParams = `os_policy_assignment.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateOsPolicyAssignment = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateOSPolicyAssignment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateOSPolicyAssignment without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest() + ); + request.osPolicyAssignment ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest', ['osPolicyAssignment', 'name']); + request.osPolicyAssignment.name = defaultValue1; + const expectedHeaderRequestParams = `os_policy_assignment.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateOsPolicyAssignment = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateOSPolicyAssignment( + request, + (err?: Error|null, + result?: 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.updateOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateOSPolicyAssignment with call error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest() + ); + request.osPolicyAssignment ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest', ['osPolicyAssignment', 'name']); + request.osPolicyAssignment.name = defaultValue1; + const expectedHeaderRequestParams = `os_policy_assignment.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateOsPolicyAssignment = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateOSPolicyAssignment(request), expectedError); + const actualRequest = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateOSPolicyAssignment with LRO error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest() + ); + request.osPolicyAssignment ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest', ['osPolicyAssignment', 'name']); + request.osPolicyAssignment.name = defaultValue1; + const expectedHeaderRequestParams = `os_policy_assignment.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateOsPolicyAssignment = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateOSPolicyAssignment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateOSPolicyAssignmentProgress without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateOSPolicyAssignmentProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateOSPolicyAssignmentProgress with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateOSPolicyAssignmentProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteOSPolicyAssignment', () => { + it('invokes deleteOSPolicyAssignment without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteOsPolicyAssignment = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteOSPolicyAssignment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteOSPolicyAssignment without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteOsPolicyAssignment = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteOSPolicyAssignment( + request, + (err?: Error|null, + result?: 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.deleteOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteOSPolicyAssignment with call error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteOsPolicyAssignment = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteOSPolicyAssignment(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteOSPolicyAssignment with LRO error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteOsPolicyAssignment = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteOSPolicyAssignment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteOSPolicyAssignmentProgress without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteOSPolicyAssignmentProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteOSPolicyAssignmentProgress with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteOSPolicyAssignmentProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listOSPolicyAssignments', () => { + it('invokes listOSPolicyAssignments without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + ]; + client.innerApiCalls.listOsPolicyAssignments = stubSimpleCall(expectedResponse); + const [response] = await client.listOSPolicyAssignments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listOSPolicyAssignments without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + ]; + client.innerApiCalls.listOsPolicyAssignments = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listOSPolicyAssignments( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listOSPolicyAssignments with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listOsPolicyAssignments = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listOSPolicyAssignments(request), expectedError); + const actualRequest = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listOSPolicyAssignmentsStream without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + ]; + client.descriptors.page.listOSPolicyAssignments.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listOSPolicyAssignmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment) => { + 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.listOSPolicyAssignments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignments, request)); + assert( + (client.descriptors.page.listOSPolicyAssignments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listOSPolicyAssignmentsStream with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listOSPolicyAssignments.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listOSPolicyAssignmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listOSPolicyAssignments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignments, request)); + assert( + (client.descriptors.page.listOSPolicyAssignments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listOSPolicyAssignments without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + ]; + client.descriptors.page.listOSPolicyAssignments.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment[] = []; + const iterable = client.listOSPolicyAssignmentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listOSPolicyAssignments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listOSPolicyAssignments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listOSPolicyAssignments with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listOSPolicyAssignments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listOSPolicyAssignmentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listOSPolicyAssignments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listOSPolicyAssignments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listOSPolicyAssignmentRevisions', () => { + it('invokes listOSPolicyAssignmentRevisions without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + ]; + client.innerApiCalls.listOsPolicyAssignmentRevisions = stubSimpleCall(expectedResponse); + const [response] = await client.listOSPolicyAssignmentRevisions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listOSPolicyAssignmentRevisions without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + ]; + client.innerApiCalls.listOsPolicyAssignmentRevisions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listOSPolicyAssignmentRevisions( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listOSPolicyAssignmentRevisions with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listOsPolicyAssignmentRevisions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listOSPolicyAssignmentRevisions(request), expectedError); + const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listOSPolicyAssignmentRevisionsStream without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + ]; + client.descriptors.page.listOSPolicyAssignmentRevisions.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listOSPolicyAssignmentRevisionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment) => { + 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.listOSPolicyAssignmentRevisions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignmentRevisions, request)); + assert( + (client.descriptors.page.listOSPolicyAssignmentRevisions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listOSPolicyAssignmentRevisionsStream with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listOSPolicyAssignmentRevisions.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listOSPolicyAssignmentRevisionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listOSPolicyAssignmentRevisions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignmentRevisions, request)); + assert( + (client.descriptors.page.listOSPolicyAssignmentRevisions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listOSPolicyAssignmentRevisions without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), + ]; + client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment[] = []; + const iterable = client.listOSPolicyAssignmentRevisionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listOSPolicyAssignmentRevisions with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listOSPolicyAssignmentRevisionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listInstanceOSPoliciesCompliances', () => { + it('invokes listInstanceOSPoliciesCompliances without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), + ]; + client.innerApiCalls.listInstanceOsPoliciesCompliances = stubSimpleCall(expectedResponse); + const [response] = await client.listInstanceOSPoliciesCompliances(request); + assert(stub.calledOnce); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInstanceOsPoliciesCompliances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstanceOsPoliciesCompliances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstanceOSPoliciesCompliances without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), + ]; + client.innerApiCalls.listInstanceOsPoliciesCompliances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstanceOSPoliciesCompliances( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert(stub.calledOnce); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInstanceOsPoliciesCompliances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstanceOsPoliciesCompliances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstanceOSPoliciesCompliances with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInstanceOsPoliciesCompliances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listInstanceOSPoliciesCompliances(request), expectedError); + assert(stub.calledOnce); + const actualRequest = (client.innerApiCalls.listInstanceOsPoliciesCompliances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstanceOsPoliciesCompliances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstanceOSPoliciesCompliancesStream without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), + ]; + client.descriptors.page.listInstanceOSPoliciesCompliances.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listInstanceOSPoliciesCompliancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert(stub.calledOnce); + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listInstanceOSPoliciesCompliances.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInstanceOsPoliciesCompliances, request)); + assert( + (client.descriptors.page.listInstanceOSPoliciesCompliances.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listInstanceOSPoliciesCompliancesStream with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstanceOSPoliciesCompliances.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listInstanceOSPoliciesCompliancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert(stub.calledOnce); + assert((client.descriptors.page.listInstanceOSPoliciesCompliances.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInstanceOsPoliciesCompliances, request)); + assert( + (client.descriptors.page.listInstanceOSPoliciesCompliances.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstanceOSPoliciesCompliances without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), + ]; + client.descriptors.page.listInstanceOSPoliciesCompliances.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance[] = []; + const iterable = client.listInstanceOSPoliciesCompliancesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert(stub.calledOnce); + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listInstanceOSPoliciesCompliances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInstanceOSPoliciesCompliances.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstanceOSPoliciesCompliances with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstanceOSPoliciesCompliances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInstanceOSPoliciesCompliancesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert(stub.calledOnce); + assert.deepStrictEqual( + (client.descriptors.page.listInstanceOSPoliciesCompliances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInstanceOSPoliciesCompliances.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listOSPolicyAssignmentReports', () => { + it('invokes listOSPolicyAssignmentReports without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), + ]; + client.innerApiCalls.listOsPolicyAssignmentReports = stubSimpleCall(expectedResponse); + const [response] = await client.listOSPolicyAssignmentReports(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listOSPolicyAssignmentReports without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), + ]; + client.innerApiCalls.listOsPolicyAssignmentReports = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listOSPolicyAssignmentReports( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listOSPolicyAssignmentReports with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listOsPolicyAssignmentReports = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listOSPolicyAssignmentReports(request), expectedError); + const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listOSPolicyAssignmentReportsStream without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), + ]; + client.descriptors.page.listOSPolicyAssignmentReports.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listOSPolicyAssignmentReportsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport) => { + 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.listOSPolicyAssignmentReports.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignmentReports, request)); + assert( + (client.descriptors.page.listOSPolicyAssignmentReports.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listOSPolicyAssignmentReportsStream with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listOSPolicyAssignmentReports.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listOSPolicyAssignmentReportsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listOSPolicyAssignmentReports.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignmentReports, request)); + assert( + (client.descriptors.page.listOSPolicyAssignmentReports.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listOSPolicyAssignmentReports without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), + ]; + client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport[] = []; + const iterable = client.listOSPolicyAssignmentReportsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listOSPolicyAssignmentReports with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listOSPolicyAssignmentReportsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listInventories', () => { + it('invokes listInventories without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListInventoriesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInventoriesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), + ]; + client.innerApiCalls.listInventories = stubSimpleCall(expectedResponse); + const [response] = await client.listInventories(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInventories without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListInventoriesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInventoriesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), + ]; + client.innerApiCalls.listInventories = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInventories( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IInventory[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInventories with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListInventoriesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInventoriesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInventories = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listInventories(request), expectedError); + const actualRequest = (client.innerApiCalls.listInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInventoriesStream without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListInventoriesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInventoriesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), + ]; + client.descriptors.page.listInventories.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listInventoriesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1alpha.Inventory[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.Inventory) => { + 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.listInventories.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInventories, request)); + assert( + (client.descriptors.page.listInventories.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listInventoriesStream with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListInventoriesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInventoriesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInventories.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listInventoriesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1alpha.Inventory[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.Inventory) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listInventories.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInventories, request)); + assert( + (client.descriptors.page.listInventories.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInventories without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListInventoriesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInventoriesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), + ]; + client.descriptors.page.listInventories.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.osconfig.v1alpha.IInventory[] = []; + const iterable = client.listInventoriesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listInventories.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInventories.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInventories with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListInventoriesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInventoriesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInventories.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInventoriesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.osconfig.v1alpha.IInventory[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listInventories.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInventories.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listVulnerabilityReports', () => { + it('invokes listVulnerabilityReports without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), + ]; + client.innerApiCalls.listVulnerabilityReports = stubSimpleCall(expectedResponse); + const [response] = await client.listVulnerabilityReports(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listVulnerabilityReports as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listVulnerabilityReports as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listVulnerabilityReports without error using callback', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), + ]; + client.innerApiCalls.listVulnerabilityReports = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listVulnerabilityReports( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listVulnerabilityReports as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listVulnerabilityReports as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listVulnerabilityReports with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listVulnerabilityReports = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listVulnerabilityReports(request), expectedError); + const actualRequest = (client.innerApiCalls.listVulnerabilityReports as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listVulnerabilityReports as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listVulnerabilityReportsStream without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), + ]; + client.descriptors.page.listVulnerabilityReports.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listVulnerabilityReportsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1alpha.VulnerabilityReport[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.VulnerabilityReport) => { + 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.listVulnerabilityReports.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listVulnerabilityReports, request)); + assert( + (client.descriptors.page.listVulnerabilityReports.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listVulnerabilityReportsStream with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listVulnerabilityReports.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listVulnerabilityReportsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1alpha.VulnerabilityReport[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.VulnerabilityReport) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listVulnerabilityReports.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listVulnerabilityReports, request)); + assert( + (client.descriptors.page.listVulnerabilityReports.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listVulnerabilityReports without error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), + generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), + ]; + client.descriptors.page.listVulnerabilityReports.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport[] = []; + const iterable = client.listVulnerabilityReportsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listVulnerabilityReports.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listVulnerabilityReports.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listVulnerabilityReports with error', async () => { + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listVulnerabilityReports.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listVulnerabilityReportsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listVulnerabilityReports.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listVulnerabilityReports.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('instanceOSPoliciesCompliance', () => { + const fakePath = "/rendered/path/instanceOSPoliciesCompliance"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + instance: "instanceValue", + }; + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.instanceOSPoliciesCompliancePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.instanceOSPoliciesCompliancePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('instanceOSPoliciesCompliancePath', () => { + const result = client.instanceOSPoliciesCompliancePath("projectValue", "locationValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.instanceOSPoliciesCompliancePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromInstanceOSPoliciesComplianceName', () => { + const result = client.matchProjectFromInstanceOSPoliciesComplianceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.instanceOSPoliciesCompliancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromInstanceOSPoliciesComplianceName', () => { + const result = client.matchLocationFromInstanceOSPoliciesComplianceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.instanceOSPoliciesCompliancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromInstanceOSPoliciesComplianceName', () => { + const result = client.matchInstanceFromInstanceOSPoliciesComplianceName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.instanceOSPoliciesCompliancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('inventory', () => { + const fakePath = "/rendered/path/inventory"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + instance: "instanceValue", + }; + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.inventoryPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.inventoryPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('inventoryPath', () => { + const result = client.inventoryPath("projectValue", "locationValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.inventoryPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromInventoryName', () => { + const result = client.matchProjectFromInventoryName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.inventoryPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromInventoryName', () => { + const result = client.matchLocationFromInventoryName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.inventoryPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromInventoryName', () => { + const result = client.matchInstanceFromInventoryName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.inventoryPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('oSPolicyAssignment', () => { + const fakePath = "/rendered/path/oSPolicyAssignment"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + os_policy_assignment: "osPolicyAssignmentValue", + }; + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.oSPolicyAssignmentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.oSPolicyAssignmentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('oSPolicyAssignmentPath', () => { + const result = client.oSPolicyAssignmentPath("projectValue", "locationValue", "osPolicyAssignmentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromOSPolicyAssignmentName', () => { + const result = client.matchProjectFromOSPolicyAssignmentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromOSPolicyAssignmentName', () => { + const result = client.matchLocationFromOSPolicyAssignmentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchOsPolicyAssignmentFromOSPolicyAssignmentName', () => { + const result = client.matchOsPolicyAssignmentFromOSPolicyAssignmentName(fakePath); + assert.strictEqual(result, "osPolicyAssignmentValue"); + assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('oSPolicyAssignmentReport', () => { + const fakePath = "/rendered/path/oSPolicyAssignmentReport"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + instance: "instanceValue", + assignment: "assignmentValue", + }; + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.oSPolicyAssignmentReportPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('oSPolicyAssignmentReportPath', () => { + const result = client.oSPolicyAssignmentReportPath("projectValue", "locationValue", "instanceValue", "assignmentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromOSPolicyAssignmentReportName', () => { + const result = client.matchProjectFromOSPolicyAssignmentReportName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromOSPolicyAssignmentReportName', () => { + const result = client.matchLocationFromOSPolicyAssignmentReportName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromOSPolicyAssignmentReportName', () => { + const result = client.matchInstanceFromOSPolicyAssignmentReportName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchAssignmentFromOSPolicyAssignmentReportName', () => { + const result = client.matchAssignmentFromOSPolicyAssignmentReportName(fakePath); + assert.strictEqual(result, "assignmentValue"); + assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('vulnerabilityReport', () => { + const fakePath = "/rendered/path/vulnerabilityReport"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + instance: "instanceValue", + }; + const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.vulnerabilityReportPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.vulnerabilityReportPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('vulnerabilityReportPath', () => { + const result = client.vulnerabilityReportPath("projectValue", "locationValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.vulnerabilityReportPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromVulnerabilityReportName', () => { + const result = client.matchProjectFromVulnerabilityReportName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.vulnerabilityReportPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromVulnerabilityReportName', () => { + const result = client.matchLocationFromVulnerabilityReportName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.vulnerabilityReportPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromVulnerabilityReportName', () => { + const result = client.matchInstanceFromVulnerabilityReportName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.vulnerabilityReportPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/tsconfig.json b/owl-bot-staging/google-cloud-osconfig/v1alpha/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/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-osconfig/v1alpha/webpack.config.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/webpack.config.js new file mode 100644 index 00000000000..3b39c422834 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1alpha/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: 'OsConfigZonalService', + filename: './os-config-zonal-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-osconfig/v1beta/.eslintignore b/owl-bot-staging/google-cloud-osconfig/v1beta/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/.eslintrc.json b/owl-bot-staging/google-cloud-osconfig/v1beta/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/.gitignore b/owl-bot-staging/google-cloud-osconfig/v1beta/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/.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-osconfig/v1beta/.jsdoc.js b/owl-bot-staging/google-cloud-osconfig/v1beta/.jsdoc.js new file mode 100644 index 00000000000..7889031cbe8 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/.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/osconfig', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/.mocharc.js b/owl-bot-staging/google-cloud-osconfig/v1beta/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/.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-osconfig/v1beta/.prettierrc.js b/owl-bot-staging/google-cloud-osconfig/v1beta/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/.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-osconfig/v1beta/README.md b/owl-bot-staging/google-cloud-osconfig/v1beta/README.md new file mode 100644 index 00000000000..94de5ca4cff --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/README.md @@ -0,0 +1 @@ +Osconfig: Nodejs Client diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/package.json b/owl-bot-staging/google-cloud-osconfig/v1beta/package.json new file mode 100644 index 00000000000..b88b28ee578 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/osconfig", + "version": "0.1.0", + "description": "Osconfig client for Node.js", + "repository": "googleapis/nodejs-osconfig", + "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 osconfig", + "osconfig", + "os config service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/guest_policies.proto b/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/guest_policies.proto new file mode 100644 index 00000000000..5534bb9d89f --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/guest_policies.proto @@ -0,0 +1,772 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "cloud.google.com/go/osconfig/apiv1beta/osconfigpb;osconfigpb"; +option java_outer_classname = "GuestPolicies"; +option java_package = "com.google.cloud.osconfig.v1beta"; + +// An OS Config resource representing a guest configuration policy. These +// policies represent the desired state for VM instance guest environments +// including packages to install or remove, package repository configurations, +// and software to install. +message GuestPolicy { + option (google.api.resource) = { + type: "osconfig.googleapis.com/GuestPolicy" + pattern: "projects/{project}/guestPolicies/{guest_policy}" + }; + + // Required. Unique name of the resource in this project using one of the following + // forms: + // `projects/{project_number}/guestPolicies/{guest_policy_id}`. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Description of the guest policy. Length of the description is limited + // to 1024 characters. + string description = 2; + + // Output only. Time this guest policy was created. + google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Last time this guest policy was updated. + google.protobuf.Timestamp update_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. Specifies the VM instances that are assigned to this policy. This allows + // you to target sets or groups of VM instances by different parameters such + // as labels, names, OS, or zones. + // + // If left empty, all VM instances underneath this policy are targeted. + // + // At the same level in the resource hierarchy (that is within a project), the + // service prevents the creation of multiple policies that conflict with + // each other. For more information, see how the service [handles assignment + // conflicts](/compute/docs/os-config-management/create-guest-policy#handle-conflicts). + Assignment assignment = 6 [(google.api.field_behavior) = REQUIRED]; + + // The software packages to be managed by this policy. + repeated Package packages = 7; + + // A list of package repositories to configure on the VM instance. This is + // done before any other configs are applied so they can use these repos. + // Package repositories are only configured if the corresponding package + // manager(s) are available. + repeated PackageRepository package_repositories = 8; + + // A list of Recipes to install on the VM instance. + repeated SoftwareRecipe recipes = 9; + + // The etag for this guest policy. + // If this is provided on update, it must match the server's etag. + string etag = 10; +} + +// An assignment represents the group or groups of VM instances that the policy +// applies to. +// +// If an assignment is empty, it applies to all VM instances. Otherwise, the +// targeted VM instances must meet all the criteria specified. So if both +// labels and zones are specified, the policy applies to VM instances with those +// labels and in those zones. +message Assignment { + // Represents a group of VM intances that can be identified as having all + // these labels, for example "env=prod and app=web". + message GroupLabel { + // Google Compute Engine instance labels that must be present for an + // instance to be included in this assignment group. + map labels = 1; + } + + // Defines the criteria for selecting VM Instances by OS type. + message OsType { + // Targets VM instances with OS Inventory enabled and having the following + // OS short name, for example "debian" or "windows". + string os_short_name = 1; + + // Targets VM instances with OS Inventory enabled and having the following + // following OS version. + string os_version = 2; + + // Targets VM instances with OS Inventory enabled and having the following + // OS architecture. + string os_architecture = 3; + } + + // Targets instances matching at least one of these label sets. This allows + // an assignment to target disparate groups, for example "env=prod or + // env=staging". + repeated GroupLabel group_labels = 1; + + // Targets instances in any of these zones. Leave empty to target instances + // in any zone. + // + // Zonal targeting is uncommon and is supported to facilitate the management + // of changes by zone. + repeated string zones = 2; + + // Targets any of the instances specified. Instances are specified by their + // URI in the form `zones/[ZONE]/instances/[INSTANCE_NAME]`. + // + // Instance targeting is uncommon and is supported to facilitate the + // management of changes by the instance or to target specific VM instances + // for development and testing. + // + // Only supported for project-level policies and must reference instances + // within this project. + repeated string instances = 3; + + // Targets VM instances whose name starts with one of these prefixes. + // + // Like labels, this is another way to group VM instances when targeting + // configs, for example prefix="prod-". + // + // Only supported for project-level policies. + repeated string instance_name_prefixes = 4; + + // Targets VM instances matching at least one of the following OS types. + // + // VM instances must match all supplied criteria for a given OsType to be + // included. + repeated OsType os_types = 5; +} + +// The desired state that the OS Config agent maintains on the VM instance. +enum DesiredState { + // The default is to ensure the package is installed. + DESIRED_STATE_UNSPECIFIED = 0; + + // The agent ensures that the package is installed. + INSTALLED = 1; + + // The agent ensures that the package is installed and + // periodically checks for and install any updates. + UPDATED = 2; + + // The agent ensures that the package is not installed and uninstall it + // if detected. + REMOVED = 3; +} + +// Package is a reference to the software package to be installed or removed. +// The agent on the VM instance uses the system package manager to apply the +// config. +// +// +// These are the commands that the agent uses to install or remove +// packages. +// +// Apt +// install: `apt-get update && apt-get -y install package1 package2 package3` +// remove: `apt-get -y remove package1 package2 package3` +// +// Yum +// install: `yum -y install package1 package2 package3` +// remove: `yum -y remove package1 package2 package3` +// +// Zypper +// install: `zypper install package1 package2 package3` +// remove: `zypper rm package1 package2` +// +// Googet +// install: `googet -noconfirm install package1 package2 package3` +// remove: `googet -noconfirm remove package1 package2 package3` +message Package { + // Types of package managers that may be used to manage this package. + enum Manager { + // The default behavior is ANY. + MANAGER_UNSPECIFIED = 0; + + // Apply this package config using the default system package manager. + ANY = 1; + + // Apply this package config only if Apt is available on the system. + APT = 2; + + // Apply this package config only if Yum is available on the system. + YUM = 3; + + // Apply this package config only if Zypper is available on the system. + ZYPPER = 4; + + // Apply this package config only if GooGet is available on the system. + GOO = 5; + } + + // Required. The name of the package. A package is uniquely identified for conflict + // validation by checking the package name and the manager(s) that the + // package targets. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // The desired_state the agent should maintain for this package. The + // default is to ensure the package is installed. + DesiredState desired_state = 2; + + // Type of package manager that can be used to install this package. + // If a system does not have the package manager, the package is not + // installed or removed no error message is returned. By default, + // or if you specify `ANY`, + // the agent attempts to install and remove this package using the default + // package manager. This is useful when creating a policy that applies to + // different types of systems. + // + // The default behavior is ANY. + Manager manager = 3; +} + +// Represents a single Apt package repository. This repository is added to +// a repo file that is stored at +// `/etc/apt/sources.list.d/google_osconfig.list`. +message AptRepository { + // Type of archive. + enum ArchiveType { + // Unspecified. + ARCHIVE_TYPE_UNSPECIFIED = 0; + + // DEB indicates that the archive contains binary files. + DEB = 1; + + // DEB_SRC indicates that the archive contains source files. + DEB_SRC = 2; + } + + // Type of archive files in this repository. The default behavior is DEB. + ArchiveType archive_type = 1; + + // Required. URI for this repository. + string uri = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. Distribution of this repository. + string distribution = 3 [(google.api.field_behavior) = REQUIRED]; + + // Required. List of components for this repository. Must contain at least one item. + repeated string components = 4 [(google.api.field_behavior) = REQUIRED]; + + // URI of the key file for this repository. The agent maintains + // a keyring at `/etc/apt/trusted.gpg.d/osconfig_agent_managed.gpg` containing + // all the keys in any applied guest policy. + string gpg_key = 5; +} + +// Represents a single Yum package repository. This repository is added to a +// repo file that is stored at `/etc/yum.repos.d/google_osconfig.repo`. +message YumRepository { + // Required. A one word, unique name for this repository. This is + // the `repo id` in the Yum config file and also the `display_name` if + // `display_name` is omitted. This id is also used as the unique identifier + // when checking for guest policy conflicts. + string id = 1 [(google.api.field_behavior) = REQUIRED]; + + // The display name of the repository. + string display_name = 2; + + // Required. The location of the repository directory. + string base_url = 3 [(google.api.field_behavior) = REQUIRED]; + + // URIs of GPG keys. + repeated string gpg_keys = 4; +} + +// Represents a single Zypper package repository. This repository is added to a +// repo file that is stored at `/etc/zypp/repos.d/google_osconfig.repo`. +message ZypperRepository { + // Required. A one word, unique name for this repository. This is + // the `repo id` in the zypper config file and also the `display_name` if + // `display_name` is omitted. This id is also used as the unique identifier + // when checking for guest policy conflicts. + string id = 1 [(google.api.field_behavior) = REQUIRED]; + + // The display name of the repository. + string display_name = 2; + + // Required. The location of the repository directory. + string base_url = 3 [(google.api.field_behavior) = REQUIRED]; + + // URIs of GPG keys. + repeated string gpg_keys = 4; +} + +// Represents a Goo package repository. These is added to a repo file +// that is stored at C:/ProgramData/GooGet/repos/google_osconfig.repo. +message GooRepository { + // Required. The name of the repository. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The url of the repository. + string url = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// A package repository. +message PackageRepository { + // A specific type of repository. + oneof repository { + // An Apt Repository. + AptRepository apt = 1; + + // A Yum Repository. + YumRepository yum = 2; + + // A Zypper Repository. + ZypperRepository zypper = 3; + + // A Goo Repository. + GooRepository goo = 4; + } +} + +// A software recipe is a set of instructions for installing and configuring a +// piece of software. It consists of a set of artifacts that are +// downloaded, and a set of steps that install, configure, and/or update the +// software. +// +// Recipes support installing and updating software from artifacts in the +// following formats: +// Zip archive, Tar archive, Windows MSI, Debian package, and RPM package. +// +// Additionally, recipes support executing a script (either defined in a file or +// directly in this api) in bash, sh, cmd, and powershell. +// +// Updating a software recipe +// +// If a recipe is assigned to an instance and there is a recipe with the same +// name but a lower version already installed and the assigned state +// of the recipe is `UPDATED`, then the recipe is updated to +// the new version. +// +// Script Working Directories +// +// Each script or execution step is run in its own temporary directory which +// is deleted after completing the step. +message SoftwareRecipe { + // Specifies a resource to be used in the recipe. + message Artifact { + // Specifies an artifact available via some URI. + message Remote { + // URI from which to fetch the object. It should contain both the protocol + // and path following the format {protocol}://{location}. + string uri = 1; + + // Must be provided if `allow_insecure` is `false`. + // SHA256 checksum in hex format, to compare to the checksum of the + // artifact. If the checksum is not empty and it doesn't match the + // artifact then the recipe installation fails before running any of the + // steps. + string checksum = 2; + } + + // Specifies an artifact available as a Google Cloud Storage object. + message Gcs { + // Bucket of the Google Cloud Storage object. + // Given an example URL: + // `https://storage.googleapis.com/my-bucket/foo/bar#1234567` + // this value would be `my-bucket`. + string bucket = 1; + + // Name of the Google Cloud Storage object. + // As specified [here] + // (https://cloud.google.com/storage/docs/naming#objectnames) + // Given an example URL: + // `https://storage.googleapis.com/my-bucket/foo/bar#1234567` + // this value would be `foo/bar`. + string object = 2; + + // Must be provided if allow_insecure is false. + // Generation number of the Google Cloud Storage object. + // `https://storage.googleapis.com/my-bucket/foo/bar#1234567` + // this value would be `1234567`. + int64 generation = 3; + } + + // Required. Id of the artifact, which the installation and update steps of this + // recipe can reference. Artifacts in a recipe cannot have the same id. + string id = 1 [(google.api.field_behavior) = REQUIRED]; + + // A specific type of artifact. + oneof artifact { + // A generic remote artifact. + Remote remote = 2; + + // A Google Cloud Storage artifact. + Gcs gcs = 3; + } + + // Defaults to false. When false, recipes are subject to validations + // based on the artifact type: + // + // Remote: A checksum must be specified, and only protocols with + // transport-layer security are permitted. + // GCS: An object generation number must be specified. + bool allow_insecure = 4; + } + + // An action that can be taken as part of installing or updating a recipe. + message Step { + // Copies the artifact to the specified path on the instance. + message CopyFile { + // Required. The id of the relevant artifact in the recipe. + string artifact_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The absolute path on the instance to put the file. + string destination = 2 [(google.api.field_behavior) = REQUIRED]; + + // Whether to allow this step to overwrite existing files. If this is + // false and the file already exists the file is not overwritten + // and the step is considered a success. Defaults to false. + bool overwrite = 3; + + // Consists of three octal digits which represent, in + // order, the permissions of the owner, group, and other users for the + // file (similarly to the numeric mode used in the linux chmod utility). + // Each digit represents a three bit number with the 4 bit + // corresponding to the read permissions, the 2 bit corresponds to the + // write bit, and the one bit corresponds to the execute permission. + // Default behavior is 755. + // + // Below are some examples of permissions and their associated values: + // read, write, and execute: 7 + // read and execute: 5 + // read and write: 6 + // read only: 4 + string permissions = 4; + } + + // Extracts an archive of the type specified in the specified directory. + message ExtractArchive { + // Specifying the type of archive. + enum ArchiveType { + // Indicates that the archive type isn't specified. + ARCHIVE_TYPE_UNSPECIFIED = 0; + + // Indicates that the archive is a tar archive with no encryption. + TAR = 1; + + // Indicates that the archive is a tar archive with gzip encryption. + TAR_GZIP = 2; + + // Indicates that the archive is a tar archive with bzip encryption. + TAR_BZIP = 3; + + // Indicates that the archive is a tar archive with lzma encryption. + TAR_LZMA = 4; + + // Indicates that the archive is a tar archive with xz encryption. + TAR_XZ = 5; + + // Indicates that the archive is a zip archive. + ZIP = 11; + } + + // Required. The id of the relevant artifact in the recipe. + string artifact_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Directory to extract archive to. + // Defaults to `/` on Linux or `C:\` on Windows. + string destination = 2; + + // Required. The type of the archive to extract. + ArchiveType type = 3 [(google.api.field_behavior) = REQUIRED]; + } + + // Installs an MSI file. + message InstallMsi { + // Required. The id of the relevant artifact in the recipe. + string artifact_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // The flags to use when installing the MSI + // defaults to ["/i"] (i.e. the install flag). + repeated string flags = 2; + + // Return codes that indicate that the software installed or updated + // successfully. Behaviour defaults to [0] + repeated int32 allowed_exit_codes = 3; + } + + // Installs a deb via dpkg. + message InstallDpkg { + // Required. The id of the relevant artifact in the recipe. + string artifact_id = 1 [(google.api.field_behavior) = REQUIRED]; + } + + // Installs an rpm file via the rpm utility. + message InstallRpm { + // Required. The id of the relevant artifact in the recipe. + string artifact_id = 1 [(google.api.field_behavior) = REQUIRED]; + } + + // Executes an artifact or local file. + message ExecFile { + // Location of the file to execute. + oneof location_type { + // The id of the relevant artifact in the recipe. + string artifact_id = 1; + + // The absolute path of the file on the local filesystem. + string local_path = 2; + } + + // Arguments to be passed to the provided executable. + repeated string args = 3; + + // Defaults to [0]. A list of possible return values that the program + // can return to indicate a success. + repeated int32 allowed_exit_codes = 4; + } + + // Runs a script through an interpreter. + message RunScript { + // The interpreter used to execute a script. + enum Interpreter { + // Default value for ScriptType. + INTERPRETER_UNSPECIFIED = 0; + + // Indicates that the script is run with `/bin/sh` on Linux and `cmd` + // on windows. + SHELL = 1; + + // Indicates that the script is run with powershell. + POWERSHELL = 3; + } + + // Required. The shell script to be executed. + string script = 1 [(google.api.field_behavior) = REQUIRED]; + + // Return codes that indicate that the software installed or updated + // successfully. Behaviour defaults to [0] + repeated int32 allowed_exit_codes = 2; + + // The script interpreter to use to run the script. If no interpreter is + // specified the script is executed directly, which likely + // only succeed for scripts with + // [shebang lines](https://en.wikipedia.org/wiki/Shebang_\(Unix\)). + Interpreter interpreter = 3; + } + + // A specific type of step. + oneof step { + // Copies a file onto the instance. + CopyFile file_copy = 1; + + // Extracts an archive into the specified directory. + ExtractArchive archive_extraction = 2; + + // Installs an MSI file. + InstallMsi msi_installation = 3; + + // Installs a deb file via dpkg. + InstallDpkg dpkg_installation = 4; + + // Installs an rpm file via the rpm utility. + InstallRpm rpm_installation = 5; + + // Executes an artifact or local file. + ExecFile file_exec = 6; + + // Runs commands in a shell. + RunScript script_run = 7; + } + } + + // Required. Unique identifier for the recipe. Only one recipe with a given name is + // installed on an instance. + // + // Names are also used to identify resources which helps to determine whether + // guest policies have conflicts. This means that requests to create multiple + // recipes with the same name and version are rejected since they + // could potentially have conflicting assignments. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // The version of this software recipe. Version can be up to 4 period + // separated numbers (e.g. 12.34.56.78). + string version = 2; + + // Resources available to be used in the steps in the recipe. + repeated Artifact artifacts = 3; + + // Actions to be taken for installing this recipe. On failure it stops + // executing steps and does not attempt another installation. Any steps taken + // (including partially completed steps) are not rolled back. + repeated Step install_steps = 4; + + // Actions to be taken for updating this recipe. On failure it stops + // executing steps and does not attempt another update for this recipe. Any + // steps taken (including partially completed steps) are not rolled back. + repeated Step update_steps = 5; + + // Default is INSTALLED. The desired state the agent should maintain for this + // recipe. + // + // INSTALLED: The software recipe is installed on the instance but + // won't be updated to new versions. + // UPDATED: The software recipe is installed on the instance. The recipe is + // updated to a higher version, if a higher version of the recipe is + // assigned to this instance. + // REMOVE: Remove is unsupported for software recipes and attempts to + // create or update a recipe to the REMOVE state is rejected. + DesiredState desired_state = 6; +} + +// A request message for creating a guest policy. +message CreateGuestPolicyRequest { + // Required. The resource name of the parent using one of the following forms: + // `projects/{project_number}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "osconfig.googleapis.com/GuestPolicy" + } + ]; + + // Required. The logical name of the guest policy in the project + // with the following restrictions: + // + // * Must contain only lowercase letters, numbers, and hyphens. + // * Must start with a letter. + // * Must be between 1-63 characters. + // * Must end with a number or a letter. + // * Must be unique within the project. + string guest_policy_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The GuestPolicy to create. + GuestPolicy guest_policy = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// A request message for retrieving a guest policy. +message GetGuestPolicyRequest { + // Required. The resource name of the guest policy using one of the following forms: + // `projects/{project_number}/guestPolicies/{guest_policy_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/GuestPolicy" + } + ]; +} + +// A request message for listing guest policies. +message ListGuestPoliciesRequest { + // Required. The resource name of the parent using one of the following forms: + // `projects/{project_number}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "osconfig.googleapis.com/GuestPolicy" + } + ]; + + // The maximum number of guest policies to return. + int32 page_size = 2; + + // A pagination token returned from a previous call to `ListGuestPolicies` + // that indicates where this listing should continue from. + string page_token = 3; +} + +// A response message for listing guest policies. +message ListGuestPoliciesResponse { + // The list of GuestPolicies. + repeated GuestPolicy guest_policies = 1; + + // A pagination token that can be used to get the next page + // of guest policies. + string next_page_token = 2; +} + +// A request message for updating a guest policy. +message UpdateGuestPolicyRequest { + // Required. The updated GuestPolicy. + GuestPolicy guest_policy = 1 [(google.api.field_behavior) = REQUIRED]; + + // Field mask that controls which fields of the guest policy should be + // updated. + google.protobuf.FieldMask update_mask = 2; +} + +// A request message for deleting a guest policy. +message DeleteGuestPolicyRequest { + // Required. The resource name of the guest policy using one of the following forms: + // `projects/{project_number}/guestPolicies/{guest_policy_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/GuestPolicy" + } + ]; +} + +// A request message for getting the effective guest policy assigned to the +// instance. +message LookupEffectiveGuestPolicyRequest { + // Required. The VM instance whose policies are being looked up. + string instance = 1 [(google.api.field_behavior) = REQUIRED]; + + // Short name of the OS running on the instance. The OS Config agent only + // provides this field for targeting if OS Inventory is enabled for that + // instance. + string os_short_name = 2; + + // Version of the OS running on the instance. The OS Config agent only + // provides this field for targeting if OS Inventory is enabled for that + // VM instance. + string os_version = 3; + + // Architecture of OS running on the instance. The OS Config agent only + // provides this field for targeting if OS Inventory is enabled for that + // instance. + string os_architecture = 4; +} + +// The effective guest policy that applies to a VM instance. +message EffectiveGuestPolicy { + // A guest policy package including its source. + message SourcedPackage { + // Name of the guest policy providing this config. + string source = 1; + + // A software package to configure on the VM instance. + Package package = 2; + } + + // A guest policy package repository including its source. + message SourcedPackageRepository { + // Name of the guest policy providing this config. + string source = 1; + + // A software package repository to configure on the VM instance. + PackageRepository package_repository = 2; + } + + // A guest policy recipe including its source. + message SourcedSoftwareRecipe { + // Name of the guest policy providing this config. + string source = 1; + + // A software recipe to configure on the VM instance. + SoftwareRecipe software_recipe = 2; + } + + // List of package configurations assigned to the VM instance. + repeated SourcedPackage packages = 1; + + // List of package repository configurations assigned to the VM instance. + repeated SourcedPackageRepository package_repositories = 2; + + // List of recipes assigned to the VM instance. + repeated SourcedSoftwareRecipe software_recipes = 3; +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/osconfig_common.proto b/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/osconfig_common.proto new file mode 100644 index 00000000000..959b39c51fb --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/osconfig_common.proto @@ -0,0 +1,36 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1beta; + + +option go_package = "cloud.google.com/go/osconfig/apiv1beta/osconfigpb;osconfigpb"; +option java_outer_classname = "Common"; +option java_package = "com.google.cloud.osconfig.v1beta"; + +// Message encapsulating a value that can be either absolute ("fixed") or +// relative ("percent") to a value. +message FixedOrPercent { + // Type of the value. + oneof mode { + // Specifies a fixed value. + int32 fixed = 1; + + // Specifies the relative value defined as a percentage, which will be + // multiplied by a reference value. + int32 percent = 2; + } +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/osconfig_service.proto b/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/osconfig_service.proto new file mode 100644 index 00000000000..8882f2314d6 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/osconfig_service.proto @@ -0,0 +1,186 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/cloud/osconfig/v1beta/guest_policies.proto"; +import "google/cloud/osconfig/v1beta/patch_deployments.proto"; +import "google/cloud/osconfig/v1beta/patch_jobs.proto"; +import "google/protobuf/empty.proto"; + +option go_package = "cloud.google.com/go/osconfig/apiv1beta/osconfigpb;osconfigpb"; +option java_outer_classname = "OsConfigProto"; +option java_package = "com.google.cloud.osconfig.v1beta"; + +// OS Config API +// +// The OS Config service is a server-side component that you can use to +// manage package installations and patch jobs for virtual machine instances. +service OsConfigService { + option (google.api.default_host) = "osconfig.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Patch VM instances by creating and running a patch job. + rpc ExecutePatchJob(ExecutePatchJobRequest) returns (PatchJob) { + option (google.api.http) = { + post: "/v1beta/{parent=projects/*}/patchJobs:execute" + body: "*" + }; + } + + // Get the patch job. This can be used to track the progress of an + // ongoing patch job or review the details of completed jobs. + rpc GetPatchJob(GetPatchJobRequest) returns (PatchJob) { + option (google.api.http) = { + get: "/v1beta/{name=projects/*/patchJobs/*}" + }; + } + + // Cancel a patch job. The patch job must be active. Canceled patch jobs + // cannot be restarted. + rpc CancelPatchJob(CancelPatchJobRequest) returns (PatchJob) { + option (google.api.http) = { + post: "/v1beta/{name=projects/*/patchJobs/*}:cancel" + body: "*" + }; + } + + // Get a list of patch jobs. + rpc ListPatchJobs(ListPatchJobsRequest) returns (ListPatchJobsResponse) { + option (google.api.http) = { + get: "/v1beta/{parent=projects/*}/patchJobs" + }; + } + + // Get a list of instance details for a given patch job. + rpc ListPatchJobInstanceDetails(ListPatchJobInstanceDetailsRequest) returns (ListPatchJobInstanceDetailsResponse) { + option (google.api.http) = { + get: "/v1beta/{parent=projects/*/patchJobs/*}/instanceDetails" + }; + option (google.api.method_signature) = "parent"; + } + + // Create an OS Config patch deployment. + rpc CreatePatchDeployment(CreatePatchDeploymentRequest) returns (PatchDeployment) { + option (google.api.http) = { + post: "/v1beta/{parent=projects/*}/patchDeployments" + body: "patch_deployment" + }; + } + + // Get an OS Config patch deployment. + rpc GetPatchDeployment(GetPatchDeploymentRequest) returns (PatchDeployment) { + option (google.api.http) = { + get: "/v1beta/{name=projects/*/patchDeployments/*}" + }; + } + + // Get a page of OS Config patch deployments. + rpc ListPatchDeployments(ListPatchDeploymentsRequest) returns (ListPatchDeploymentsResponse) { + option (google.api.http) = { + get: "/v1beta/{parent=projects/*}/patchDeployments" + }; + } + + // Delete an OS Config patch deployment. + rpc DeletePatchDeployment(DeletePatchDeploymentRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1beta/{name=projects/*/patchDeployments/*}" + }; + } + + // Update an OS Config patch deployment. + rpc UpdatePatchDeployment(UpdatePatchDeploymentRequest) returns (PatchDeployment) { + option (google.api.http) = { + patch: "/v1beta/{patch_deployment.name=projects/*/patchDeployments/*}" + body: "patch_deployment" + }; + option (google.api.method_signature) = "patch_deployment,update_mask"; + } + + // Change state of patch deployment to "PAUSED". + // Patch deployment in paused state doesn't generate patch jobs. + rpc PausePatchDeployment(PausePatchDeploymentRequest) returns (PatchDeployment) { + option (google.api.http) = { + post: "/v1beta/{name=projects/*/patchDeployments/*}:pause" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Change state of patch deployment back to "ACTIVE". + // Patch deployment in active state continues to generate patch jobs. + rpc ResumePatchDeployment(ResumePatchDeploymentRequest) returns (PatchDeployment) { + option (google.api.http) = { + post: "/v1beta/{name=projects/*/patchDeployments/*}:resume" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Create an OS Config guest policy. + rpc CreateGuestPolicy(CreateGuestPolicyRequest) returns (GuestPolicy) { + option (google.api.http) = { + post: "/v1beta/{parent=projects/*}/guestPolicies" + body: "guest_policy" + }; + option (google.api.method_signature) = "parent, guest_policy"; + } + + // Get an OS Config guest policy. + rpc GetGuestPolicy(GetGuestPolicyRequest) returns (GuestPolicy) { + option (google.api.http) = { + get: "/v1beta/{name=projects/*/guestPolicies/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Get a page of OS Config guest policies. + rpc ListGuestPolicies(ListGuestPoliciesRequest) returns (ListGuestPoliciesResponse) { + option (google.api.http) = { + get: "/v1beta/{parent=projects/*}/guestPolicies" + }; + option (google.api.method_signature) = "parent"; + } + + // Update an OS Config guest policy. + rpc UpdateGuestPolicy(UpdateGuestPolicyRequest) returns (GuestPolicy) { + option (google.api.http) = { + patch: "/v1beta/{guest_policy.name=projects/*/guestPolicies/*}" + body: "guest_policy" + }; + option (google.api.method_signature) = "guest_policy,update_mask"; + } + + // Delete an OS Config guest policy. + rpc DeleteGuestPolicy(DeleteGuestPolicyRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1beta/{name=projects/*/guestPolicies/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lookup the effective guest policy that applies to a VM instance. This + // lookup merges all policies that are assigned to the instance ancestry. + rpc LookupEffectiveGuestPolicy(LookupEffectiveGuestPolicyRequest) returns (EffectiveGuestPolicy) { + option (google.api.http) = { + post: "/v1beta/{instance=projects/*/zones/*/instances/*}:lookupEffectiveGuestPolicy" + body: "*" + }; + } +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/patch_deployments.proto b/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/patch_deployments.proto new file mode 100644 index 00000000000..127cc6a2c42 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/patch_deployments.proto @@ -0,0 +1,295 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/osconfig/v1beta/patch_jobs.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/datetime.proto"; +import "google/type/dayofweek.proto"; +import "google/type/timeofday.proto"; + +option go_package = "cloud.google.com/go/osconfig/apiv1beta/osconfigpb;osconfigpb"; +option java_outer_classname = "PatchDeployments"; +option java_package = "com.google.cloud.osconfig.v1beta"; + +// Patch deployments are configurations that individual patch jobs use to +// complete a patch. These configurations include instance filter, package +// repository settings, and a schedule. For more information about creating and +// managing patch deployments, see [Scheduling patch +// jobs](https://cloud.google.com/compute/docs/os-patch-management/schedule-patch-jobs). +message PatchDeployment { + option (google.api.resource) = { + type: "osconfig.googleapis.com/PatchDeployment" + pattern: "projects/{project}/patchDeployments/{patch_deployment}" + }; + + // Represents state of patch peployment. + enum State { + // The default value. This value is used if the state is omitted. + STATE_UNSPECIFIED = 0; + + // Active value means that patch deployment generates Patch Jobs. + ACTIVE = 1; + + // Paused value means that patch deployment does not generate + // Patch jobs. Requires user action to move in and out from this state. + PAUSED = 2; + } + + // Unique name for the patch deployment resource in a project. The patch + // deployment name is in the form: + // `projects/{project_id}/patchDeployments/{patch_deployment_id}`. + // This field is ignored when you create a new patch deployment. + string name = 1; + + // Optional. Description of the patch deployment. Length of the description is limited + // to 1024 characters. + string description = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Required. VM instances to patch. + PatchInstanceFilter instance_filter = 3 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Patch configuration that is applied. + PatchConfig patch_config = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Duration of the patch. After the duration ends, the patch times out. + google.protobuf.Duration duration = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Schedule for the patch. + oneof schedule { + // Required. Schedule a one-time execution. + OneTimeSchedule one_time_schedule = 6 [(google.api.field_behavior) = REQUIRED]; + + // Required. Schedule recurring executions. + RecurringSchedule recurring_schedule = 7 [(google.api.field_behavior) = REQUIRED]; + } + + // Output only. Time the patch deployment was created. Timestamp is in + // [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text format. + google.protobuf.Timestamp create_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Time the patch deployment was last updated. Timestamp is in + // [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text format. + google.protobuf.Timestamp update_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last time a patch job was started by this deployment. + // Timestamp is in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text + // format. + google.protobuf.Timestamp last_execute_time = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Rollout strategy of the patch job. + PatchRollout rollout = 11 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. Current state of the patch deployment. + State state = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Sets the time for a one time patch deployment. Timestamp is in +// [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text format. +message OneTimeSchedule { + // Required. The desired patch job execution time. + google.protobuf.Timestamp execute_time = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Sets the time for recurring patch deployments. +message RecurringSchedule { + // Specifies the frequency of the recurring patch deployments. + enum Frequency { + // Invalid. A frequency must be specified. + FREQUENCY_UNSPECIFIED = 0; + + // Indicates that the frequency of recurrence should be expressed in terms + // of weeks. + WEEKLY = 1; + + // Indicates that the frequency of recurrence should be expressed in terms + // of months. + MONTHLY = 2; + + // Indicates that the frequency of recurrence should be expressed in terms + // of days. + DAILY = 3; + } + + // Required. Defines the time zone that `time_of_day` is relative to. + // The rules for daylight saving time are determined by the chosen time zone. + google.type.TimeZone time_zone = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The time that the recurring schedule becomes effective. + // Defaults to `create_time` of the patch deployment. + google.protobuf.Timestamp start_time = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The end time at which a recurring patch deployment schedule is no longer + // active. + google.protobuf.Timestamp end_time = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Required. Time of the day to run a recurring deployment. + google.type.TimeOfDay time_of_day = 4 [(google.api.field_behavior) = REQUIRED]; + + // Required. The frequency unit of this recurring schedule. + Frequency frequency = 5 [(google.api.field_behavior) = REQUIRED]; + + // Configurations for this recurring schedule. + // Configurations must match frequency. + oneof schedule_config { + // Required. Schedule with weekly executions. + WeeklySchedule weekly = 6 [(google.api.field_behavior) = REQUIRED]; + + // Required. Schedule with monthly executions. + MonthlySchedule monthly = 7 [(google.api.field_behavior) = REQUIRED]; + } + + // Output only. The time the last patch job ran successfully. + google.protobuf.Timestamp last_execute_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time the next patch job is scheduled to run. + google.protobuf.Timestamp next_execute_time = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Represents a weekly schedule. +message WeeklySchedule { + // Required. Day of the week. + google.type.DayOfWeek day_of_week = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Represents a monthly schedule. An example of a valid monthly schedule is +// "on the third Tuesday of the month" or "on the 15th of the month". +message MonthlySchedule { + // One day in a month. + oneof day_of_month { + // Required. Week day in a month. + WeekDayOfMonth week_day_of_month = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. One day of the month. 1-31 indicates the 1st to the 31st day. -1 + // indicates the last day of the month. + // Months without the target day will be skipped. For example, a schedule to + // run "every month on the 31st" will not run in February, April, June, etc. + int32 month_day = 2 [(google.api.field_behavior) = REQUIRED]; + } +} + +// Represents one week day in a month. An example is "the 4th Sunday". +message WeekDayOfMonth { + // Required. Week number in a month. 1-4 indicates the 1st to 4th week of the month. -1 + // indicates the last week of the month. + int32 week_ordinal = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. A day of the week. + google.type.DayOfWeek day_of_week = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Represents the number of days before or after the given week day of month + // that the patch deployment is scheduled for. For example if `week_ordinal` + // and `day_of_week` values point to the second day of the month and this + // `day_offset` value is set to `3`, the patch deployment takes place three + // days after the second Tuesday of the month. If this value is negative, for + // example -5, the patches are deployed five days before before the second + // Tuesday of the month. Allowed values are in range `[-30, 30]`. + int32 day_offset = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// A request message for creating a patch deployment. +message CreatePatchDeploymentRequest { + // Required. The project to apply this patch deployment to in the form `projects/*`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. A name for the patch deployment in the project. When creating a name + // the following rules apply: + // * Must contain only lowercase letters, numbers, and hyphens. + // * Must start with a letter. + // * Must be between 1-63 characters. + // * Must end with a number or a letter. + // * Must be unique within the project. + string patch_deployment_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The patch deployment to create. + PatchDeployment patch_deployment = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// A request message for retrieving a patch deployment. +message GetPatchDeploymentRequest { + // Required. The resource name of the patch deployment in the form + // `projects/*/patchDeployments/*`. + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// A request message for listing patch deployments. +message ListPatchDeploymentsRequest { + // Required. The resource name of the parent in the form `projects/*`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The maximum number of patch deployments to return. Default is 100. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A pagination token returned from a previous call to ListPatchDeployments + // that indicates where this listing should continue from. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// A response message for listing patch deployments. +message ListPatchDeploymentsResponse { + // The list of patch deployments. + repeated PatchDeployment patch_deployments = 1; + + // A pagination token that can be used to get the next page of patch + // deployments. + string next_page_token = 2; +} + +// A request message for deleting a patch deployment. +message DeletePatchDeploymentRequest { + // Required. The resource name of the patch deployment in the form + // `projects/*/patchDeployments/*`. + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// A request message for updating a patch deployment. +message UpdatePatchDeploymentRequest { + // Required. The patch deployment to Update. + PatchDeployment patch_deployment = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Field mask that controls which fields of the patch deployment should be + // updated. + google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// A request message for pausing a patch deployment. +message PausePatchDeploymentRequest { + // Required. The resource name of the patch deployment in the form + // `projects/*/patchDeployments/*`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/PatchDeployment" + } + ]; +} + +// A request message for resuming a patch deployment. +message ResumePatchDeploymentRequest { + // Required. The resource name of the patch deployment in the form + // `projects/*/patchDeployments/*`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "osconfig.googleapis.com/PatchDeployment" + } + ]; +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/patch_jobs.proto b/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/patch_jobs.proto new file mode 100644 index 00000000000..c691bc7e6a7 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/patch_jobs.proto @@ -0,0 +1,702 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.osconfig.v1beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/osconfig/v1beta/osconfig_common.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "cloud.google.com/go/osconfig/apiv1beta/osconfigpb;osconfigpb"; +option java_outer_classname = "PatchJobs"; +option java_package = "com.google.cloud.osconfig.v1beta"; + +// A request message to initiate patching across Compute Engine instances. +message ExecutePatchJobRequest { + // Required. The project in which to run this patch in the form `projects/*` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Description of the patch job. Length of the description is limited + // to 1024 characters. + string description = 2; + + // Required. Instances to patch, either explicitly or filtered by some criteria such + // as zone or labels. + PatchInstanceFilter instance_filter = 7 [(google.api.field_behavior) = REQUIRED]; + + // Patch configuration being applied. If omitted, instances are + // patched using the default configurations. + PatchConfig patch_config = 4; + + // Duration of the patch job. After the duration ends, the patch job + // times out. + google.protobuf.Duration duration = 5; + + // If this patch is a dry-run only, instances are contacted but + // will do nothing. + bool dry_run = 6; + + // Display name for this patch job. This does not have to be unique. + string display_name = 8; + + // Rollout strategy of the patch job. + PatchRollout rollout = 9; +} + +// Request to get an active or completed patch job. +message GetPatchJobRequest { + // Required. Name of the patch in the form `projects/*/patchJobs/*` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request to list details for all instances that are part of a patch job. +message ListPatchJobInstanceDetailsRequest { + // Required. The parent for the instances are in the form of `projects/*/patchJobs/*`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The maximum number of instance details records to return. Default is 100. + int32 page_size = 2; + + // A pagination token returned from a previous call + // that indicates where this listing should continue from. + string page_token = 3; + + // A filter expression that filters results listed in the response. This + // field supports filtering results by instance zone, name, state, or + // `failure_reason`. + string filter = 4; +} + +// A response message for listing the instances details for a patch job. +message ListPatchJobInstanceDetailsResponse { + // A list of instance status. + repeated PatchJobInstanceDetails patch_job_instance_details = 1; + + // A pagination token that can be used to get the next page of results. + string next_page_token = 2; +} + +// Patch details for a VM instance. For more information about reviewing VM +// instance details, see +// [Listing all VM instance details for a specific patch +// job](https://cloud.google.com/compute/docs/os-patch-management/manage-patch-jobs#list-instance-details). +message PatchJobInstanceDetails { + // The instance name in the form `projects/*/zones/*/instances/*` + string name = 1; + + // The unique identifier for the instance. This identifier is + // defined by the server. + string instance_system_id = 2; + + // Current state of instance patch. + Instance.PatchState state = 3; + + // If the patch fails, this field provides the reason. + string failure_reason = 4; + + // The number of times the agent that the agent attempts to apply the patch. + int64 attempt_count = 5; +} + +// A request message for listing patch jobs. +message ListPatchJobsRequest { + // Required. In the form of `projects/*` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The maximum number of instance status to return. + int32 page_size = 2; + + // A pagination token returned from a previous call + // that indicates where this listing should continue from. + string page_token = 3; + + // If provided, this field specifies the criteria that must be met by patch + // jobs to be included in the response. + // Currently, filtering is only available on the patch_deployment field. + string filter = 4; +} + +// A response message for listing patch jobs. +message ListPatchJobsResponse { + // The list of patch jobs. + repeated PatchJob patch_jobs = 1; + + // A pagination token that can be used to get the next page of results. + string next_page_token = 2; +} + +// A high level representation of a patch job that is either in progress +// or has completed. +// +// Instance details are not included in the job. To paginate through instance +// details, use `ListPatchJobInstanceDetails`. +// +// For more information about patch jobs, see +// [Creating patch +// jobs](https://cloud.google.com/compute/docs/os-patch-management/create-patch-job). +message PatchJob { + option (google.api.resource) = { + type: "osconfig.googleapis.com/PatchJob" + pattern: "projects/{project}/patchJobs/{patch_job}" + }; + + // Enumeration of the various states a patch job passes through as it + // executes. + enum State { + // State must be specified. + STATE_UNSPECIFIED = 0; + + // The patch job was successfully initiated. + STARTED = 1; + + // The patch job is looking up instances to run the patch on. + INSTANCE_LOOKUP = 2; + + // Instances are being patched. + PATCHING = 3; + + // Patch job completed successfully. + SUCCEEDED = 4; + + // Patch job completed but there were errors. + COMPLETED_WITH_ERRORS = 5; + + // The patch job was canceled. + CANCELED = 6; + + // The patch job timed out. + TIMED_OUT = 7; + } + + // A summary of the current patch state across all instances that this patch + // job affects. Contains counts of instances in different states. These states + // map to `InstancePatchState`. List patch job instance details to see the + // specific states of each instance. + message InstanceDetailsSummary { + // Number of instances pending patch job. + int64 pending_instance_count = 1; + + // Number of instances that are inactive. + int64 inactive_instance_count = 2; + + // Number of instances notified about patch job. + int64 notified_instance_count = 3; + + // Number of instances that have started. + int64 started_instance_count = 4; + + // Number of instances that are downloading patches. + int64 downloading_patches_instance_count = 5; + + // Number of instances that are applying patches. + int64 applying_patches_instance_count = 6; + + // Number of instances rebooting. + int64 rebooting_instance_count = 7; + + // Number of instances that have completed successfully. + int64 succeeded_instance_count = 8; + + // Number of instances that require reboot. + int64 succeeded_reboot_required_instance_count = 9; + + // Number of instances that failed. + int64 failed_instance_count = 10; + + // Number of instances that have acked and will start shortly. + int64 acked_instance_count = 11; + + // Number of instances that exceeded the time out while applying the patch. + int64 timed_out_instance_count = 12; + + // Number of instances that are running the pre-patch step. + int64 pre_patch_step_instance_count = 13; + + // Number of instances that are running the post-patch step. + int64 post_patch_step_instance_count = 14; + + // Number of instances that do not appear to be running the agent. Check to + // ensure that the agent is installed, running, and able to communicate with + // the service. + int64 no_agent_detected_instance_count = 15; + } + + // Unique identifier for this patch job in the form + // `projects/*/patchJobs/*` + string name = 1; + + // Display name for this patch job. This is not a unique identifier. + string display_name = 14; + + // Description of the patch job. Length of the description is limited + // to 1024 characters. + string description = 2; + + // Time this patch job was created. + google.protobuf.Timestamp create_time = 3; + + // Last time this patch job was updated. + google.protobuf.Timestamp update_time = 4; + + // The current state of the PatchJob. + State state = 5; + + // Instances to patch. + PatchInstanceFilter instance_filter = 13; + + // Patch configuration being applied. + PatchConfig patch_config = 7; + + // Duration of the patch job. After the duration ends, the + // patch job times out. + google.protobuf.Duration duration = 8; + + // Summary of instance details. + InstanceDetailsSummary instance_details_summary = 9; + + // If this patch job is a dry run, the agent reports that it has + // finished without running any updates on the VM instance. + bool dry_run = 10; + + // If this patch job failed, this message provides information about the + // failure. + string error_message = 11; + + // Reflects the overall progress of the patch job in the range of + // 0.0 being no progress to 100.0 being complete. + double percent_complete = 12; + + // Output only. Name of the patch deployment that created this patch job. + string patch_deployment = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Rollout strategy being applied. + PatchRollout rollout = 16; +} + +// Patch configuration specifications. Contains details on how to apply the +// patch(es) to a VM instance. +message PatchConfig { + // Post-patch reboot settings. + enum RebootConfig { + // The default behavior is DEFAULT. + REBOOT_CONFIG_UNSPECIFIED = 0; + + // The agent decides if a reboot is necessary by checking signals such as + // registry keys on Windows or `/var/run/reboot-required` on APT based + // systems. On RPM based systems, a set of core system package install times + // are compared with system boot time. + DEFAULT = 1; + + // Always reboot the machine after the update completes. + ALWAYS = 2; + + // Never reboot the machine after the update completes. + NEVER = 3; + } + + // Post-patch reboot settings. + RebootConfig reboot_config = 1; + + // Apt update settings. Use this setting to override the default `apt` patch + // rules. + AptSettings apt = 3; + + // Yum update settings. Use this setting to override the default `yum` patch + // rules. + YumSettings yum = 4; + + // Goo update settings. Use this setting to override the default `goo` patch + // rules. + GooSettings goo = 5; + + // Zypper update settings. Use this setting to override the default `zypper` + // patch rules. + ZypperSettings zypper = 6; + + // Windows update settings. Use this override the default windows patch rules. + WindowsUpdateSettings windows_update = 7; + + // The `ExecStep` to run before the patch update. + ExecStep pre_step = 8; + + // The `ExecStep` to run after the patch update. + ExecStep post_step = 9; + + // Allows the patch job to run on Managed instance groups (MIGs). + bool mig_instances_allowed = 10; +} + +// Namespace for instance state enums. +message Instance { + // Patch state of an instance. + enum PatchState { + // Unspecified. + PATCH_STATE_UNSPECIFIED = 0; + + // The instance is not yet notified. + PENDING = 1; + + // Instance is inactive and cannot be patched. + INACTIVE = 2; + + // The instance is notified that it should be patched. + NOTIFIED = 3; + + // The instance has started the patching process. + STARTED = 4; + + // The instance is downloading patches. + DOWNLOADING_PATCHES = 5; + + // The instance is applying patches. + APPLYING_PATCHES = 6; + + // The instance is rebooting. + REBOOTING = 7; + + // The instance has completed applying patches. + SUCCEEDED = 8; + + // The instance has completed applying patches but a reboot is required. + SUCCEEDED_REBOOT_REQUIRED = 9; + + // The instance has failed to apply the patch. + FAILED = 10; + + // The instance acked the notification and will start shortly. + ACKED = 11; + + // The instance exceeded the time out while applying the patch. + TIMED_OUT = 12; + + // The instance is running the pre-patch step. + RUNNING_PRE_PATCH_STEP = 13; + + // The instance is running the post-patch step. + RUNNING_POST_PATCH_STEP = 14; + + // The service could not detect the presence of the agent. Check to ensure + // that the agent is installed, running, and able to communicate with the + // service. + NO_AGENT_DETECTED = 15; + } + + +} + +// Message for canceling a patch job. +message CancelPatchJobRequest { + // Required. Name of the patch in the form `projects/*/patchJobs/*` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Apt patching is completed by executing `apt-get update && apt-get +// upgrade`. Additional options can be set to control how this is executed. +message AptSettings { + // Apt patch type. + enum Type { + // By default, upgrade will be performed. + TYPE_UNSPECIFIED = 0; + + // Runs `apt-get dist-upgrade`. + DIST = 1; + + // Runs `apt-get upgrade`. + UPGRADE = 2; + } + + // By changing the type to DIST, the patching is performed + // using `apt-get dist-upgrade` instead. + Type type = 1; + + // List of packages to exclude from update. These packages will be excluded + repeated string excludes = 2; + + // An exclusive list of packages to be updated. These are the only packages + // that will be updated. If these packages are not installed, they will be + // ignored. This field cannot be specified with any other patch configuration + // fields. + repeated string exclusive_packages = 3; +} + +// Yum patching is performed by executing `yum update`. Additional options +// can be set to control how this is executed. +// +// Note that not all settings are supported on all platforms. +message YumSettings { + // Adds the `--security` flag to `yum update`. Not supported on + // all platforms. + bool security = 1; + + // Will cause patch to run `yum update-minimal` instead. + bool minimal = 2; + + // List of packages to exclude from update. These packages are excluded by + // using the yum `--exclude` flag. + repeated string excludes = 3; + + // An exclusive list of packages to be updated. These are the only packages + // that will be updated. If these packages are not installed, they will be + // ignored. This field must not be specified with any other patch + // configuration fields. + repeated string exclusive_packages = 4; +} + +// Googet patching is performed by running `googet update`. +message GooSettings { + +} + +// Zypper patching is performed by running `zypper patch`. +// See also https://en.opensuse.org/SDB:Zypper_manual. +message ZypperSettings { + // Adds the `--with-optional` flag to `zypper patch`. + bool with_optional = 1; + + // Adds the `--with-update` flag, to `zypper patch`. + bool with_update = 2; + + // Install only patches with these categories. + // Common categories include security, recommended, and feature. + repeated string categories = 3; + + // Install only patches with these severities. + // Common severities include critical, important, moderate, and low. + repeated string severities = 4; + + // List of patches to exclude from update. + repeated string excludes = 5; + + // An exclusive list of patches to be updated. These are the only patches + // that will be installed using 'zypper patch patch:' command. + // This field must not be used with any other patch configuration fields. + repeated string exclusive_patches = 6; +} + +// Windows patching is performed using the Windows Update Agent. +message WindowsUpdateSettings { + // Microsoft Windows update classifications as defined in + // [1] + // https://support.microsoft.com/en-us/help/824684/description-of-the-standard-terminology-that-is-used-to-describe-micro + enum Classification { + // Invalid. If classifications are included, they must be specified. + CLASSIFICATION_UNSPECIFIED = 0; + + // "A widely released fix for a specific problem that addresses a critical, + // non-security-related bug." [1] + CRITICAL = 1; + + // "A widely released fix for a product-specific, security-related + // vulnerability. Security vulnerabilities are rated by their severity. The + // severity rating is indicated in the Microsoft security bulletin as + // critical, important, moderate, or low." [1] + SECURITY = 2; + + // "A widely released and frequent software update that contains additions + // to a product's definition database. Definition databases are often used + // to detect objects that have specific attributes, such as malicious code, + // phishing websites, or junk mail." [1] + DEFINITION = 3; + + // "Software that controls the input and output of a device." [1] + DRIVER = 4; + + // "New product functionality that is first distributed outside the context + // of a product release and that is typically included in the next full + // product release." [1] + FEATURE_PACK = 5; + + // "A tested, cumulative set of all hotfixes, security updates, critical + // updates, and updates. Additionally, service packs may contain additional + // fixes for problems that are found internally since the release of the + // product. Service packs my also contain a limited number of + // customer-requested design changes or features." [1] + SERVICE_PACK = 6; + + // "A utility or feature that helps complete a task or set of tasks." [1] + TOOL = 7; + + // "A tested, cumulative set of hotfixes, security updates, critical + // updates, and updates that are packaged together for easy deployment. A + // rollup generally targets a specific area, such as security, or a + // component of a product, such as Internet Information Services (IIS)." [1] + UPDATE_ROLLUP = 8; + + // "A widely released fix for a specific problem. An update addresses a + // noncritical, non-security-related bug." [1] + UPDATE = 9; + } + + // Only apply updates of these windows update classifications. If empty, all + // updates are applied. + repeated Classification classifications = 1; + + // List of KBs to exclude from update. + repeated string excludes = 2; + + // An exclusive list of kbs to be updated. These are the only patches + // that will be updated. This field must not be used with other + // patch configurations. + repeated string exclusive_patches = 3; +} + +// A step that runs an executable for a PatchJob. +message ExecStep { + // The ExecStepConfig for all Linux VMs targeted by the PatchJob. + ExecStepConfig linux_exec_step_config = 1; + + // The ExecStepConfig for all Windows VMs targeted by the PatchJob. + ExecStepConfig windows_exec_step_config = 2; +} + +// Common configurations for an ExecStep. +message ExecStepConfig { + // The interpreter used to execute the a file. + enum Interpreter { + // Invalid for a Windows ExecStepConfig. For a Linux ExecStepConfig, the + // interpreter will be parsed from the shebang line of the script if + // unspecified. + INTERPRETER_UNSPECIFIED = 0; + + // Indicates that the script is run with `/bin/sh` on Linux and `cmd` + // on Windows. + SHELL = 1; + + // Indicates that the file is run with PowerShell flags + // `-NonInteractive`, `-NoProfile`, and `-ExecutionPolicy Bypass`. + POWERSHELL = 2; + } + + // Location of the executable. + oneof executable { + // An absolute path to the executable on the VM. + string local_path = 1; + + // A Google Cloud Storage object containing the executable. + GcsObject gcs_object = 2; + } + + // Defaults to [0]. A list of possible return values that the + // execution can return to indicate a success. + repeated int32 allowed_success_codes = 3; + + // The script interpreter to use to run the script. If no interpreter is + // specified the script will be executed directly, which will likely + // only succeed for scripts with [shebang lines] + // (https://en.wikipedia.org/wiki/Shebang_\(Unix\)). + Interpreter interpreter = 4; +} + +// Google Cloud Storage object representation. +message GcsObject { + // Required. Bucket of the Google Cloud Storage object. + string bucket = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Name of the Google Cloud Storage object. + string object = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. Generation number of the Google Cloud Storage object. This is used to + // ensure that the ExecStep specified by this PatchJob does not change. + int64 generation_number = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// A filter to target VM instances for patching. The targeted +// VMs must meet all criteria specified. So if both labels and zones are +// specified, the patch job targets only VMs with those labels and in those +// zones. +message PatchInstanceFilter { + // Represents a group of VMs that can be identified as having all these + // labels, for example "env=prod and app=web". + message GroupLabel { + // Compute Engine instance labels that must be present for a VM instance to + // be targeted by this filter. + map labels = 1; + } + + // Target all VM instances in the project. If true, no other criteria is + // permitted. + bool all = 1; + + // Targets VM instances matching at least one of these label sets. This allows + // targeting of disparate groups, for example "env=prod or env=staging". + repeated GroupLabel group_labels = 2; + + // Targets VM instances in ANY of these zones. Leave empty to target VM + // instances in any zone. + repeated string zones = 3; + + // Targets any of the VM instances specified. Instances are specified by their + // URI in the form `zones/[ZONE]/instances/[INSTANCE_NAME]`, + // `projects/[PROJECT_ID]/zones/[ZONE]/instances/[INSTANCE_NAME]`, or + // `https://www.googleapis.com/compute/v1/projects/[PROJECT_ID]/zones/[ZONE]/instances/[INSTANCE_NAME]` + repeated string instances = 4; + + // Targets VMs whose name starts with one of these prefixes. Similar to + // labels, this is another way to group VMs when targeting configs, for + // example prefix="prod-". + repeated string instance_name_prefixes = 5; +} + +// Patch rollout configuration specifications. Contains details on the +// concurrency control when applying patch(es) to all targeted VMs. +message PatchRollout { + // Type of the rollout. + enum Mode { + // Mode must be specified. + MODE_UNSPECIFIED = 0; + + // Patches are applied one zone at a time. The patch job begins in the + // region with the lowest number of targeted VMs. Within the region, + // patching begins in the zone with the lowest number of targeted VMs. If + // multiple regions (or zones within a region) have the same number of + // targeted VMs, a tie-breaker is achieved by sorting the regions or zones + // in alphabetical order. + ZONE_BY_ZONE = 1; + + // Patches are applied to VMs in all zones at the same time. + CONCURRENT_ZONES = 2; + } + + // Mode of the patch rollout. + Mode mode = 1; + + // The maximum number (or percentage) of VMs per zone to disrupt at any given + // moment. The number of VMs calculated from multiplying the percentage by the + // total number of VMs in a zone is rounded up. + // + // During patching, a VM is considered disrupted from the time the agent is + // notified to begin until patching has completed. This disruption time + // includes the time to complete reboot and any post-patch steps. + // + // A VM contributes to the disruption budget if its patching operation fails + // either when applying the patches, running pre or post patch steps, or if it + // fails to respond with a success notification before timing out. VMs that + // are not running or do not have an active agent do not count toward this + // disruption budget. + // + // For zone-by-zone rollouts, if the disruption budget in a zone is exceeded, + // the patch job stops, because continuing to the next zone requires + // completion of the patch process in the previous zone. + // + // For example, if the disruption budget has a fixed value of `10`, and 8 VMs + // fail to patch in the current zone, the patch job continues to patch 2 VMs + // at a time until the zone is completed. When that zone is completed + // successfully, patching begins with 10 VMs at a time in the next zone. If 10 + // VMs in the next zone fail to patch, the patch job stops. + FixedOrPercent disruption_budget = 2; +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.cancel_patch_job.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.cancel_patch_job.js new file mode 100644 index 00000000000..f416929f363 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.cancel_patch_job.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(name) { + // [START osconfig_v1beta_generated_OsConfigService_CancelPatchJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the patch in the form `projects/* /patchJobs/*` + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callCancelPatchJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.cancelPatchJob(request); + console.log(response); + } + + callCancelPatchJob(); + // [END osconfig_v1beta_generated_OsConfigService_CancelPatchJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.create_guest_policy.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.create_guest_policy.js new file mode 100644 index 00000000000..2ef34afce6f --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.create_guest_policy.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(parent, guestPolicyId, guestPolicy) { + // [START osconfig_v1beta_generated_OsConfigService_CreateGuestPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 parent using one of the following forms: + * `projects/{project_number}`. + */ + // const parent = 'abc123' + /** + * Required. The logical name of the guest policy in the project + * with the following restrictions: + * * Must contain only lowercase letters, numbers, and hyphens. + * * Must start with a letter. + * * Must be between 1-63 characters. + * * Must end with a number or a letter. + * * Must be unique within the project. + */ + // const guestPolicyId = 'abc123' + /** + * Required. The GuestPolicy to create. + */ + // const guestPolicy = {} + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callCreateGuestPolicy() { + // Construct request + const request = { + parent, + guestPolicyId, + guestPolicy, + }; + + // Run request + const response = await osconfigClient.createGuestPolicy(request); + console.log(response); + } + + callCreateGuestPolicy(); + // [END osconfig_v1beta_generated_OsConfigService_CreateGuestPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.create_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.create_patch_deployment.js new file mode 100644 index 00000000000..a072db41e61 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.create_patch_deployment.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(parent, patchDeploymentId, patchDeployment) { + // [START osconfig_v1beta_generated_OsConfigService_CreatePatchDeployment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project to apply this patch deployment to in the form `projects/*`. + */ + // const parent = 'abc123' + /** + * Required. A name for the patch deployment in the project. When creating a name + * the following rules apply: + * * Must contain only lowercase letters, numbers, and hyphens. + * * Must start with a letter. + * * Must be between 1-63 characters. + * * Must end with a number or a letter. + * * Must be unique within the project. + */ + // const patchDeploymentId = 'abc123' + /** + * Required. The patch deployment to create. + */ + // const patchDeployment = {} + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callCreatePatchDeployment() { + // Construct request + const request = { + parent, + patchDeploymentId, + patchDeployment, + }; + + // Run request + const response = await osconfigClient.createPatchDeployment(request); + console.log(response); + } + + callCreatePatchDeployment(); + // [END osconfig_v1beta_generated_OsConfigService_CreatePatchDeployment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.delete_guest_policy.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.delete_guest_policy.js new file mode 100644 index 00000000000..6166760d8b7 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.delete_guest_policy.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 osconfig_v1beta_generated_OsConfigService_DeleteGuestPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 guest policy using one of the following forms: + * `projects/{project_number}/guestPolicies/{guest_policy_id}`. + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callDeleteGuestPolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.deleteGuestPolicy(request); + console.log(response); + } + + callDeleteGuestPolicy(); + // [END osconfig_v1beta_generated_OsConfigService_DeleteGuestPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.delete_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.delete_patch_deployment.js new file mode 100644 index 00000000000..9cd6977fc63 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.delete_patch_deployment.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 osconfig_v1beta_generated_OsConfigService_DeletePatchDeployment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 patch deployment in the form + * `projects/* /patchDeployments/*`. + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callDeletePatchDeployment() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.deletePatchDeployment(request); + console.log(response); + } + + callDeletePatchDeployment(); + // [END osconfig_v1beta_generated_OsConfigService_DeletePatchDeployment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.execute_patch_job.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.execute_patch_job.js new file mode 100644 index 00000000000..e7960e492b5 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.execute_patch_job.js @@ -0,0 +1,95 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, instanceFilter) { + // [START osconfig_v1beta_generated_OsConfigService_ExecutePatchJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project in which to run this patch in the form `projects/*` + */ + // const parent = 'abc123' + /** + * Description of the patch job. Length of the description is limited + * to 1024 characters. + */ + // const description = 'abc123' + /** + * Required. Instances to patch, either explicitly or filtered by some criteria such + * as zone or labels. + */ + // const instanceFilter = {} + /** + * Patch configuration being applied. If omitted, instances are + * patched using the default configurations. + */ + // const patchConfig = {} + /** + * Duration of the patch job. After the duration ends, the patch job + * times out. + */ + // const duration = {} + /** + * If this patch is a dry-run only, instances are contacted but + * will do nothing. + */ + // const dryRun = true + /** + * Display name for this patch job. This does not have to be unique. + */ + // const displayName = 'abc123' + /** + * Rollout strategy of the patch job. + */ + // const rollout = {} + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callExecutePatchJob() { + // Construct request + const request = { + parent, + instanceFilter, + }; + + // Run request + const response = await osconfigClient.executePatchJob(request); + console.log(response); + } + + callExecutePatchJob(); + // [END osconfig_v1beta_generated_OsConfigService_ExecutePatchJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_guest_policy.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_guest_policy.js new file mode 100644 index 00000000000..08fac67b889 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_guest_policy.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 osconfig_v1beta_generated_OsConfigService_GetGuestPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 guest policy using one of the following forms: + * `projects/{project_number}/guestPolicies/{guest_policy_id}`. + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callGetGuestPolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.getGuestPolicy(request); + console.log(response); + } + + callGetGuestPolicy(); + // [END osconfig_v1beta_generated_OsConfigService_GetGuestPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_patch_deployment.js new file mode 100644 index 00000000000..8e8b7411017 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_patch_deployment.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 osconfig_v1beta_generated_OsConfigService_GetPatchDeployment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 patch deployment in the form + * `projects/* /patchDeployments/*`. + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callGetPatchDeployment() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.getPatchDeployment(request); + console.log(response); + } + + callGetPatchDeployment(); + // [END osconfig_v1beta_generated_OsConfigService_GetPatchDeployment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_patch_job.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_patch_job.js new file mode 100644 index 00000000000..c5f93158ce3 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_patch_job.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(name) { + // [START osconfig_v1beta_generated_OsConfigService_GetPatchJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the patch in the form `projects/* /patchJobs/*` + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callGetPatchJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.getPatchJob(request); + console.log(response); + } + + callGetPatchJob(); + // [END osconfig_v1beta_generated_OsConfigService_GetPatchJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_guest_policies.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_guest_policies.js new file mode 100644 index 00000000000..4a740ddd7ce --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_guest_policies.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(parent) { + // [START osconfig_v1beta_generated_OsConfigService_ListGuestPolicies_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 parent using one of the following forms: + * `projects/{project_number}`. + */ + // const parent = 'abc123' + /** + * The maximum number of guest policies to return. + */ + // const pageSize = 1234 + /** + * A pagination token returned from a previous call to `ListGuestPolicies` + * that indicates where this listing should continue from. + */ + // const pageToken = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callListGuestPolicies() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await osconfigClient.listGuestPoliciesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListGuestPolicies(); + // [END osconfig_v1beta_generated_OsConfigService_ListGuestPolicies_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_deployments.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_deployments.js new file mode 100644 index 00000000000..cf3091a217c --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_deployments.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) { + // [START osconfig_v1beta_generated_OsConfigService_ListPatchDeployments_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 parent in the form `projects/*`. + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of patch deployments to return. Default is 100. + */ + // const pageSize = 1234 + /** + * Optional. A pagination token returned from a previous call to ListPatchDeployments + * that indicates where this listing should continue from. + */ + // const pageToken = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callListPatchDeployments() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await osconfigClient.listPatchDeploymentsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListPatchDeployments(); + // [END osconfig_v1beta_generated_OsConfigService_ListPatchDeployments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_job_instance_details.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_job_instance_details.js new file mode 100644 index 00000000000..1e8432ab112 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_job_instance_details.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(parent) { + // [START osconfig_v1beta_generated_OsConfigService_ListPatchJobInstanceDetails_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 the instances are in the form of `projects/* /patchJobs/*`. + */ + // const parent = 'abc123' + /** + * The maximum number of instance details records to return. Default is 100. + */ + // const pageSize = 1234 + /** + * A pagination token returned from a previous call + * that indicates where this listing should continue from. + */ + // const pageToken = 'abc123' + /** + * A filter expression that filters results listed in the response. This + * field supports filtering results by instance zone, name, state, or + * `failure_reason`. + */ + // const filter = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callListPatchJobInstanceDetails() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await osconfigClient.listPatchJobInstanceDetailsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListPatchJobInstanceDetails(); + // [END osconfig_v1beta_generated_OsConfigService_ListPatchJobInstanceDetails_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_jobs.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_jobs.js new file mode 100644 index 00000000000..e98fe909908 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_jobs.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(parent) { + // [START osconfig_v1beta_generated_OsConfigService_ListPatchJobs_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. In the form of `projects/*` + */ + // const parent = 'abc123' + /** + * The maximum number of instance status to return. + */ + // const pageSize = 1234 + /** + * A pagination token returned from a previous call + * that indicates where this listing should continue from. + */ + // const pageToken = 'abc123' + /** + * If provided, this field specifies the criteria that must be met by patch + * jobs to be included in the response. + * Currently, filtering is only available on the patch_deployment field. + */ + // const filter = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callListPatchJobs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await osconfigClient.listPatchJobsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListPatchJobs(); + // [END osconfig_v1beta_generated_OsConfigService_ListPatchJobs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.lookup_effective_guest_policy.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.lookup_effective_guest_policy.js new file mode 100644 index 00000000000..a5138559ad5 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.lookup_effective_guest_policy.js @@ -0,0 +1,79 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(instance) { + // [START osconfig_v1beta_generated_OsConfigService_LookupEffectiveGuestPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The VM instance whose policies are being looked up. + */ + // const instance = 'abc123' + /** + * Short name of the OS running on the instance. The OS Config agent only + * provides this field for targeting if OS Inventory is enabled for that + * instance. + */ + // const osShortName = 'abc123' + /** + * Version of the OS running on the instance. The OS Config agent only + * provides this field for targeting if OS Inventory is enabled for that + * VM instance. + */ + // const osVersion = 'abc123' + /** + * Architecture of OS running on the instance. The OS Config agent only + * provides this field for targeting if OS Inventory is enabled for that + * instance. + */ + // const osArchitecture = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callLookupEffectiveGuestPolicy() { + // Construct request + const request = { + instance, + }; + + // Run request + const response = await osconfigClient.lookupEffectiveGuestPolicy(request); + console.log(response); + } + + callLookupEffectiveGuestPolicy(); + // [END osconfig_v1beta_generated_OsConfigService_LookupEffectiveGuestPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.pause_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.pause_patch_deployment.js new file mode 100644 index 00000000000..753963b0889 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.pause_patch_deployment.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 osconfig_v1beta_generated_OsConfigService_PausePatchDeployment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 patch deployment in the form + * `projects/* /patchDeployments/*`. + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callPausePatchDeployment() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.pausePatchDeployment(request); + console.log(response); + } + + callPausePatchDeployment(); + // [END osconfig_v1beta_generated_OsConfigService_PausePatchDeployment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.resume_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.resume_patch_deployment.js new file mode 100644 index 00000000000..b5931c32425 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.resume_patch_deployment.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 osconfig_v1beta_generated_OsConfigService_ResumePatchDeployment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 patch deployment in the form + * `projects/* /patchDeployments/*`. + */ + // const name = 'abc123' + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callResumePatchDeployment() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osconfigClient.resumePatchDeployment(request); + console.log(response); + } + + callResumePatchDeployment(); + // [END osconfig_v1beta_generated_OsConfigService_ResumePatchDeployment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.update_guest_policy.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.update_guest_policy.js new file mode 100644 index 00000000000..9401f59c262 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.update_guest_policy.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(guestPolicy) { + // [START osconfig_v1beta_generated_OsConfigService_UpdateGuestPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The updated GuestPolicy. + */ + // const guestPolicy = {} + /** + * Field mask that controls which fields of the guest policy should be + * updated. + */ + // const updateMask = {} + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callUpdateGuestPolicy() { + // Construct request + const request = { + guestPolicy, + }; + + // Run request + const response = await osconfigClient.updateGuestPolicy(request); + console.log(response); + } + + callUpdateGuestPolicy(); + // [END osconfig_v1beta_generated_OsConfigService_UpdateGuestPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.update_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.update_patch_deployment.js new file mode 100644 index 00000000000..25038517953 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.update_patch_deployment.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(patchDeployment) { + // [START osconfig_v1beta_generated_OsConfigService_UpdatePatchDeployment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The patch deployment to Update. + */ + // const patchDeployment = {} + /** + * Optional. Field mask that controls which fields of the patch deployment should be + * updated. + */ + // const updateMask = {} + + // Imports the Osconfig library + const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; + + // Instantiates a client + const osconfigClient = new OsConfigServiceClient(); + + async function callUpdatePatchDeployment() { + // Construct request + const request = { + patchDeployment, + }; + + // Run request + const response = await osconfigClient.updatePatchDeployment(request); + console.log(response); + } + + callUpdatePatchDeployment(); + // [END osconfig_v1beta_generated_OsConfigService_UpdatePatchDeployment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/snippet_metadata_google.cloud.osconfig.v1beta.json b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/snippet_metadata_google.cloud.osconfig.v1beta.json new file mode 100644 index 00000000000..d845a650eac --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/snippet_metadata_google.cloud.osconfig.v1beta.json @@ -0,0 +1,839 @@ +{ + "clientLibrary": { + "name": "nodejs-osconfig", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.osconfig.v1beta", + "version": "v1beta" + } + ] + }, + "snippets": [ + { + "regionTag": "osconfig_v1beta_generated_OsConfigService_ExecutePatchJob_async", + "title": "OsConfigService executePatchJob Sample", + "origin": "API_DEFINITION", + "description": " Patch VM instances by creating and running a patch job.", + "canonical": true, + "file": "os_config_service.execute_patch_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 87, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ExecutePatchJob", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ExecutePatchJob", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "description", + "type": "TYPE_STRING" + }, + { + "name": "instance_filter", + "type": ".google.cloud.osconfig.v1beta.PatchInstanceFilter" + }, + { + "name": "patch_config", + "type": ".google.cloud.osconfig.v1beta.PatchConfig" + }, + { + "name": "duration", + "type": ".google.protobuf.Duration" + }, + { + "name": "dry_run", + "type": "TYPE_BOOL" + }, + { + "name": "display_name", + "type": "TYPE_STRING" + }, + { + "name": "rollout", + "type": ".google.cloud.osconfig.v1beta.PatchRollout" + } + ], + "resultType": ".google.cloud.osconfig.v1beta.PatchJob", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" + }, + "method": { + "shortName": "ExecutePatchJob", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ExecutePatchJob", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1beta_generated_OsConfigService_GetPatchJob_async", + "title": "OsConfigService getPatchJob Sample", + "origin": "API_DEFINITION", + "description": " Get the patch job. This can be used to track the progress of an ongoing patch job or review the details of completed jobs.", + "canonical": true, + "file": "os_config_service.get_patch_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetPatchJob", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.GetPatchJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1beta.PatchJob", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" + }, + "method": { + "shortName": "GetPatchJob", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.GetPatchJob", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1beta_generated_OsConfigService_CancelPatchJob_async", + "title": "OsConfigService cancelPatchJob Sample", + "origin": "API_DEFINITION", + "description": " Cancel a patch job. The patch job must be active. Canceled patch jobs cannot be restarted.", + "canonical": true, + "file": "os_config_service.cancel_patch_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CancelPatchJob", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.CancelPatchJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1beta.PatchJob", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" + }, + "method": { + "shortName": "CancelPatchJob", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.CancelPatchJob", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1beta_generated_OsConfigService_ListPatchJobs_async", + "title": "OsConfigService listPatchJobs Sample", + "origin": "API_DEFINITION", + "description": " Get a list of patch jobs.", + "canonical": true, + "file": "os_config_service.list_patch_jobs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListPatchJobs", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ListPatchJobs", + "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.osconfig.v1beta.ListPatchJobsResponse", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" + }, + "method": { + "shortName": "ListPatchJobs", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ListPatchJobs", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1beta_generated_OsConfigService_ListPatchJobInstanceDetails_async", + "title": "OsConfigService listPatchJobInstanceDetails Sample", + "origin": "API_DEFINITION", + "description": " Get a list of instance details for a given patch job.", + "canonical": true, + "file": "os_config_service.list_patch_job_instance_details.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListPatchJobInstanceDetails", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ListPatchJobInstanceDetails", + "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.osconfig.v1beta.ListPatchJobInstanceDetailsResponse", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" + }, + "method": { + "shortName": "ListPatchJobInstanceDetails", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ListPatchJobInstanceDetails", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1beta_generated_OsConfigService_CreatePatchDeployment_async", + "title": "OsConfigService createPatchDeployment Sample", + "origin": "API_DEFINITION", + "description": " Create an OS Config patch deployment.", + "canonical": true, + "file": "os_config_service.create_patch_deployment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreatePatchDeployment", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.CreatePatchDeployment", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "patch_deployment_id", + "type": "TYPE_STRING" + }, + { + "name": "patch_deployment", + "type": ".google.cloud.osconfig.v1beta.PatchDeployment" + } + ], + "resultType": ".google.cloud.osconfig.v1beta.PatchDeployment", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" + }, + "method": { + "shortName": "CreatePatchDeployment", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.CreatePatchDeployment", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1beta_generated_OsConfigService_GetPatchDeployment_async", + "title": "OsConfigService getPatchDeployment Sample", + "origin": "API_DEFINITION", + "description": " Get an OS Config patch deployment.", + "canonical": true, + "file": "os_config_service.get_patch_deployment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetPatchDeployment", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.GetPatchDeployment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1beta.PatchDeployment", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" + }, + "method": { + "shortName": "GetPatchDeployment", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.GetPatchDeployment", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1beta_generated_OsConfigService_ListPatchDeployments_async", + "title": "OsConfigService listPatchDeployments Sample", + "origin": "API_DEFINITION", + "description": " Get a page of OS Config patch deployments.", + "canonical": true, + "file": "os_config_service.list_patch_deployments.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListPatchDeployments", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ListPatchDeployments", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1beta.ListPatchDeploymentsResponse", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" + }, + "method": { + "shortName": "ListPatchDeployments", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ListPatchDeployments", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1beta_generated_OsConfigService_DeletePatchDeployment_async", + "title": "OsConfigService deletePatchDeployment Sample", + "origin": "API_DEFINITION", + "description": " Delete an OS Config patch deployment.", + "canonical": true, + "file": "os_config_service.delete_patch_deployment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeletePatchDeployment", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.DeletePatchDeployment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" + }, + "method": { + "shortName": "DeletePatchDeployment", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.DeletePatchDeployment", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1beta_generated_OsConfigService_UpdatePatchDeployment_async", + "title": "OsConfigService updatePatchDeployment Sample", + "origin": "API_DEFINITION", + "description": " Update an OS Config patch deployment.", + "canonical": true, + "file": "os_config_service.update_patch_deployment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdatePatchDeployment", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.UpdatePatchDeployment", + "async": true, + "parameters": [ + { + "name": "patch_deployment", + "type": ".google.cloud.osconfig.v1beta.PatchDeployment" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.osconfig.v1beta.PatchDeployment", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" + }, + "method": { + "shortName": "UpdatePatchDeployment", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.UpdatePatchDeployment", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1beta_generated_OsConfigService_PausePatchDeployment_async", + "title": "OsConfigService pausePatchDeployment Sample", + "origin": "API_DEFINITION", + "description": " Change state of patch deployment to \"PAUSED\". Patch deployment in paused state doesn't generate patch jobs.", + "canonical": true, + "file": "os_config_service.pause_patch_deployment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PausePatchDeployment", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.PausePatchDeployment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1beta.PatchDeployment", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" + }, + "method": { + "shortName": "PausePatchDeployment", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.PausePatchDeployment", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1beta_generated_OsConfigService_ResumePatchDeployment_async", + "title": "OsConfigService resumePatchDeployment Sample", + "origin": "API_DEFINITION", + "description": " Change state of patch deployment back to \"ACTIVE\". Patch deployment in active state continues to generate patch jobs.", + "canonical": true, + "file": "os_config_service.resume_patch_deployment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ResumePatchDeployment", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ResumePatchDeployment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1beta.PatchDeployment", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" + }, + "method": { + "shortName": "ResumePatchDeployment", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ResumePatchDeployment", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1beta_generated_OsConfigService_CreateGuestPolicy_async", + "title": "OsConfigService createGuestPolicy Sample", + "origin": "API_DEFINITION", + "description": " Create an OS Config guest policy.", + "canonical": true, + "file": "os_config_service.create_guest_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateGuestPolicy", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.CreateGuestPolicy", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "guest_policy_id", + "type": "TYPE_STRING" + }, + { + "name": "guest_policy", + "type": ".google.cloud.osconfig.v1beta.GuestPolicy" + } + ], + "resultType": ".google.cloud.osconfig.v1beta.GuestPolicy", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" + }, + "method": { + "shortName": "CreateGuestPolicy", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.CreateGuestPolicy", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1beta_generated_OsConfigService_GetGuestPolicy_async", + "title": "OsConfigService getGuestPolicy Sample", + "origin": "API_DEFINITION", + "description": " Get an OS Config guest policy.", + "canonical": true, + "file": "os_config_service.get_guest_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetGuestPolicy", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.GetGuestPolicy", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1beta.GuestPolicy", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" + }, + "method": { + "shortName": "GetGuestPolicy", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.GetGuestPolicy", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1beta_generated_OsConfigService_ListGuestPolicies_async", + "title": "OsConfigService listGuestPolicies Sample", + "origin": "API_DEFINITION", + "description": " Get a page of OS Config guest policies.", + "canonical": true, + "file": "os_config_service.list_guest_policies.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListGuestPolicies", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ListGuestPolicies", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1beta.ListGuestPoliciesResponse", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" + }, + "method": { + "shortName": "ListGuestPolicies", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ListGuestPolicies", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1beta_generated_OsConfigService_UpdateGuestPolicy_async", + "title": "OsConfigService updateGuestPolicy Sample", + "origin": "API_DEFINITION", + "description": " Update an OS Config guest policy.", + "canonical": true, + "file": "os_config_service.update_guest_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateGuestPolicy", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.UpdateGuestPolicy", + "async": true, + "parameters": [ + { + "name": "guest_policy", + "type": ".google.cloud.osconfig.v1beta.GuestPolicy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.osconfig.v1beta.GuestPolicy", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" + }, + "method": { + "shortName": "UpdateGuestPolicy", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.UpdateGuestPolicy", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1beta_generated_OsConfigService_DeleteGuestPolicy_async", + "title": "OsConfigService deleteGuestPolicy Sample", + "origin": "API_DEFINITION", + "description": " Delete an OS Config guest policy.", + "canonical": true, + "file": "os_config_service.delete_guest_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteGuestPolicy", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.DeleteGuestPolicy", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" + }, + "method": { + "shortName": "DeleteGuestPolicy", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.DeleteGuestPolicy", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService" + } + } + } + }, + { + "regionTag": "osconfig_v1beta_generated_OsConfigService_LookupEffectiveGuestPolicy_async", + "title": "OsConfigService lookupEffectiveGuestPolicy Sample", + "origin": "API_DEFINITION", + "description": " Lookup the effective guest policy that applies to a VM instance. This lookup merges all policies that are assigned to the instance ancestry.", + "canonical": true, + "file": "os_config_service.lookup_effective_guest_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "LookupEffectiveGuestPolicy", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.LookupEffectiveGuestPolicy", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "os_short_name", + "type": "TYPE_STRING" + }, + { + "name": "os_version", + "type": "TYPE_STRING" + }, + { + "name": "os_architecture", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.osconfig.v1beta.EffectiveGuestPolicy", + "client": { + "shortName": "OsConfigServiceClient", + "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" + }, + "method": { + "shortName": "LookupEffectiveGuestPolicy", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService.LookupEffectiveGuestPolicy", + "service": { + "shortName": "OsConfigService", + "fullName": "google.cloud.osconfig.v1beta.OsConfigService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/src/index.ts b/owl-bot-staging/google-cloud-osconfig/v1beta/src/index.ts new file mode 100644 index 00000000000..4ed09a037fc --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1beta from './v1beta'; +const OsConfigServiceClient = v1beta.OsConfigServiceClient; +type OsConfigServiceClient = v1beta.OsConfigServiceClient; +export {v1beta, OsConfigServiceClient}; +export default {v1beta, OsConfigServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/gapic_metadata.json b/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/gapic_metadata.json new file mode 100644 index 00000000000..1a1c7998335 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/gapic_metadata.json @@ -0,0 +1,219 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.osconfig.v1beta", + "libraryPackage": "@google-cloud/osconfig", + "services": { + "OsConfigService": { + "clients": { + "grpc": { + "libraryClient": "OsConfigServiceClient", + "rpcs": { + "ExecutePatchJob": { + "methods": [ + "executePatchJob" + ] + }, + "GetPatchJob": { + "methods": [ + "getPatchJob" + ] + }, + "CancelPatchJob": { + "methods": [ + "cancelPatchJob" + ] + }, + "CreatePatchDeployment": { + "methods": [ + "createPatchDeployment" + ] + }, + "GetPatchDeployment": { + "methods": [ + "getPatchDeployment" + ] + }, + "DeletePatchDeployment": { + "methods": [ + "deletePatchDeployment" + ] + }, + "UpdatePatchDeployment": { + "methods": [ + "updatePatchDeployment" + ] + }, + "PausePatchDeployment": { + "methods": [ + "pausePatchDeployment" + ] + }, + "ResumePatchDeployment": { + "methods": [ + "resumePatchDeployment" + ] + }, + "CreateGuestPolicy": { + "methods": [ + "createGuestPolicy" + ] + }, + "GetGuestPolicy": { + "methods": [ + "getGuestPolicy" + ] + }, + "UpdateGuestPolicy": { + "methods": [ + "updateGuestPolicy" + ] + }, + "DeleteGuestPolicy": { + "methods": [ + "deleteGuestPolicy" + ] + }, + "LookupEffectiveGuestPolicy": { + "methods": [ + "lookupEffectiveGuestPolicy" + ] + }, + "ListPatchJobs": { + "methods": [ + "listPatchJobs", + "listPatchJobsStream", + "listPatchJobsAsync" + ] + }, + "ListPatchJobInstanceDetails": { + "methods": [ + "listPatchJobInstanceDetails", + "listPatchJobInstanceDetailsStream", + "listPatchJobInstanceDetailsAsync" + ] + }, + "ListPatchDeployments": { + "methods": [ + "listPatchDeployments", + "listPatchDeploymentsStream", + "listPatchDeploymentsAsync" + ] + }, + "ListGuestPolicies": { + "methods": [ + "listGuestPolicies", + "listGuestPoliciesStream", + "listGuestPoliciesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "OsConfigServiceClient", + "rpcs": { + "ExecutePatchJob": { + "methods": [ + "executePatchJob" + ] + }, + "GetPatchJob": { + "methods": [ + "getPatchJob" + ] + }, + "CancelPatchJob": { + "methods": [ + "cancelPatchJob" + ] + }, + "CreatePatchDeployment": { + "methods": [ + "createPatchDeployment" + ] + }, + "GetPatchDeployment": { + "methods": [ + "getPatchDeployment" + ] + }, + "DeletePatchDeployment": { + "methods": [ + "deletePatchDeployment" + ] + }, + "UpdatePatchDeployment": { + "methods": [ + "updatePatchDeployment" + ] + }, + "PausePatchDeployment": { + "methods": [ + "pausePatchDeployment" + ] + }, + "ResumePatchDeployment": { + "methods": [ + "resumePatchDeployment" + ] + }, + "CreateGuestPolicy": { + "methods": [ + "createGuestPolicy" + ] + }, + "GetGuestPolicy": { + "methods": [ + "getGuestPolicy" + ] + }, + "UpdateGuestPolicy": { + "methods": [ + "updateGuestPolicy" + ] + }, + "DeleteGuestPolicy": { + "methods": [ + "deleteGuestPolicy" + ] + }, + "LookupEffectiveGuestPolicy": { + "methods": [ + "lookupEffectiveGuestPolicy" + ] + }, + "ListPatchJobs": { + "methods": [ + "listPatchJobs", + "listPatchJobsStream", + "listPatchJobsAsync" + ] + }, + "ListPatchJobInstanceDetails": { + "methods": [ + "listPatchJobInstanceDetails", + "listPatchJobInstanceDetailsStream", + "listPatchJobInstanceDetailsAsync" + ] + }, + "ListPatchDeployments": { + "methods": [ + "listPatchDeployments", + "listPatchDeploymentsStream", + "listPatchDeploymentsAsync" + ] + }, + "ListGuestPolicies": { + "methods": [ + "listGuestPolicies", + "listGuestPoliciesStream", + "listGuestPoliciesAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/index.ts b/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/index.ts new file mode 100644 index 00000000000..e16a0985eee --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {OsConfigServiceClient} from './os_config_service_client'; diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_client.ts b/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_client.ts new file mode 100644 index 00000000000..4550aed1a0c --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_client.ts @@ -0,0 +1,2220 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta/os_config_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './os_config_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * OS Config API + * + * The OS Config service is a server-side component that you can use to + * manage package installations and patch jobs for virtual machine instances. + * @class + * @memberof v1beta + */ +export class OsConfigServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + osConfigServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of OsConfigServiceClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 OsConfigServiceClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof OsConfigServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + guestPolicyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/guestPolicies/{guest_policy}' + ), + patchDeploymentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/patchDeployments/{patch_deployment}' + ), + patchJobPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/patchJobs/{patch_job}' + ), + }; + + // 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 = { + listPatchJobs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'patchJobs'), + listPatchJobInstanceDetails: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'patchJobInstanceDetails'), + listPatchDeployments: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'patchDeployments'), + listGuestPolicies: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'guestPolicies') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.osconfig.v1beta.OsConfigService', 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.osConfigServiceStub) { + return this.osConfigServiceStub; + } + + // Put together the "service stub" for + // google.cloud.osconfig.v1beta.OsConfigService. + this.osConfigServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.osconfig.v1beta.OsConfigService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.osconfig.v1beta.OsConfigService, + 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 osConfigServiceStubMethods = + ['executePatchJob', 'getPatchJob', 'cancelPatchJob', 'listPatchJobs', 'listPatchJobInstanceDetails', 'createPatchDeployment', 'getPatchDeployment', 'listPatchDeployments', 'deletePatchDeployment', 'updatePatchDeployment', 'pausePatchDeployment', 'resumePatchDeployment', 'createGuestPolicy', 'getGuestPolicy', 'listGuestPolicies', 'updateGuestPolicy', 'deleteGuestPolicy', 'lookupEffectiveGuestPolicy']; + for (const methodName of osConfigServiceStubMethods) { + const callPromise = this.osConfigServiceStub.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.osConfigServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'osconfig.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 'osconfig.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 -- + // ------------------- +/** + * Patch VM instances by creating and running a patch job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which to run this patch in the form `projects/*` + * @param {string} request.description + * Description of the patch job. Length of the description is limited + * to 1024 characters. + * @param {google.cloud.osconfig.v1beta.PatchInstanceFilter} request.instanceFilter + * Required. Instances to patch, either explicitly or filtered by some criteria such + * as zone or labels. + * @param {google.cloud.osconfig.v1beta.PatchConfig} request.patchConfig + * Patch configuration being applied. If omitted, instances are + * patched using the default configurations. + * @param {google.protobuf.Duration} request.duration + * Duration of the patch job. After the duration ends, the patch job + * times out. + * @param {boolean} request.dryRun + * If this patch is a dry-run only, instances are contacted but + * will do nothing. + * @param {string} request.displayName + * Display name for this patch job. This does not have to be unique. + * @param {google.cloud.osconfig.v1beta.PatchRollout} request.rollout + * Rollout strategy of the patch job. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1beta.PatchJob|PatchJob}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_config_service.execute_patch_job.js + * region_tag:osconfig_v1beta_generated_OsConfigService_ExecutePatchJob_async + */ + executePatchJob( + request?: protos.google.cloud.osconfig.v1beta.IExecutePatchJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchJob, + protos.google.cloud.osconfig.v1beta.IExecutePatchJobRequest|undefined, {}|undefined + ]>; + executePatchJob( + request: protos.google.cloud.osconfig.v1beta.IExecutePatchJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IPatchJob, + protos.google.cloud.osconfig.v1beta.IExecutePatchJobRequest|null|undefined, + {}|null|undefined>): void; + executePatchJob( + request: protos.google.cloud.osconfig.v1beta.IExecutePatchJobRequest, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IPatchJob, + protos.google.cloud.osconfig.v1beta.IExecutePatchJobRequest|null|undefined, + {}|null|undefined>): void; + executePatchJob( + request?: protos.google.cloud.osconfig.v1beta.IExecutePatchJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1beta.IPatchJob, + protos.google.cloud.osconfig.v1beta.IExecutePatchJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1beta.IPatchJob, + protos.google.cloud.osconfig.v1beta.IExecutePatchJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchJob, + protos.google.cloud.osconfig.v1beta.IExecutePatchJobRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.executePatchJob(request, options, callback); + } +/** + * Get the patch job. This can be used to track the progress of an + * ongoing patch job or review the details of completed jobs. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the patch in the form `projects/* /patchJobs/*` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1beta.PatchJob|PatchJob}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_config_service.get_patch_job.js + * region_tag:osconfig_v1beta_generated_OsConfigService_GetPatchJob_async + */ + getPatchJob( + request?: protos.google.cloud.osconfig.v1beta.IGetPatchJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchJob, + protos.google.cloud.osconfig.v1beta.IGetPatchJobRequest|undefined, {}|undefined + ]>; + getPatchJob( + request: protos.google.cloud.osconfig.v1beta.IGetPatchJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IPatchJob, + protos.google.cloud.osconfig.v1beta.IGetPatchJobRequest|null|undefined, + {}|null|undefined>): void; + getPatchJob( + request: protos.google.cloud.osconfig.v1beta.IGetPatchJobRequest, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IPatchJob, + protos.google.cloud.osconfig.v1beta.IGetPatchJobRequest|null|undefined, + {}|null|undefined>): void; + getPatchJob( + request?: protos.google.cloud.osconfig.v1beta.IGetPatchJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1beta.IPatchJob, + protos.google.cloud.osconfig.v1beta.IGetPatchJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1beta.IPatchJob, + protos.google.cloud.osconfig.v1beta.IGetPatchJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchJob, + protos.google.cloud.osconfig.v1beta.IGetPatchJobRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getPatchJob(request, options, callback); + } +/** + * Cancel a patch job. The patch job must be active. Canceled patch jobs + * cannot be restarted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the patch in the form `projects/* /patchJobs/*` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1beta.PatchJob|PatchJob}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_config_service.cancel_patch_job.js + * region_tag:osconfig_v1beta_generated_OsConfigService_CancelPatchJob_async + */ + cancelPatchJob( + request?: protos.google.cloud.osconfig.v1beta.ICancelPatchJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchJob, + protos.google.cloud.osconfig.v1beta.ICancelPatchJobRequest|undefined, {}|undefined + ]>; + cancelPatchJob( + request: protos.google.cloud.osconfig.v1beta.ICancelPatchJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IPatchJob, + protos.google.cloud.osconfig.v1beta.ICancelPatchJobRequest|null|undefined, + {}|null|undefined>): void; + cancelPatchJob( + request: protos.google.cloud.osconfig.v1beta.ICancelPatchJobRequest, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IPatchJob, + protos.google.cloud.osconfig.v1beta.ICancelPatchJobRequest|null|undefined, + {}|null|undefined>): void; + cancelPatchJob( + request?: protos.google.cloud.osconfig.v1beta.ICancelPatchJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1beta.IPatchJob, + protos.google.cloud.osconfig.v1beta.ICancelPatchJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1beta.IPatchJob, + protos.google.cloud.osconfig.v1beta.ICancelPatchJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchJob, + protos.google.cloud.osconfig.v1beta.ICancelPatchJobRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.cancelPatchJob(request, options, callback); + } +/** + * Create an OS Config patch deployment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project to apply this patch deployment to in the form `projects/*`. + * @param {string} request.patchDeploymentId + * Required. A name for the patch deployment in the project. When creating a name + * the following rules apply: + * * Must contain only lowercase letters, numbers, and hyphens. + * * Must start with a letter. + * * Must be between 1-63 characters. + * * Must end with a number or a letter. + * * Must be unique within the project. + * @param {google.cloud.osconfig.v1beta.PatchDeployment} request.patchDeployment + * Required. The patch deployment to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1beta.PatchDeployment|PatchDeployment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_config_service.create_patch_deployment.js + * region_tag:osconfig_v1beta_generated_OsConfigService_CreatePatchDeployment_async + */ + createPatchDeployment( + request?: protos.google.cloud.osconfig.v1beta.ICreatePatchDeploymentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.ICreatePatchDeploymentRequest|undefined, {}|undefined + ]>; + createPatchDeployment( + request: protos.google.cloud.osconfig.v1beta.ICreatePatchDeploymentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.ICreatePatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + createPatchDeployment( + request: protos.google.cloud.osconfig.v1beta.ICreatePatchDeploymentRequest, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.ICreatePatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + createPatchDeployment( + request?: protos.google.cloud.osconfig.v1beta.ICreatePatchDeploymentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.ICreatePatchDeploymentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.ICreatePatchDeploymentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.ICreatePatchDeploymentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createPatchDeployment(request, options, callback); + } +/** + * Get an OS Config patch deployment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the patch deployment in the form + * `projects/* /patchDeployments/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1beta.PatchDeployment|PatchDeployment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_config_service.get_patch_deployment.js + * region_tag:osconfig_v1beta_generated_OsConfigService_GetPatchDeployment_async + */ + getPatchDeployment( + request?: protos.google.cloud.osconfig.v1beta.IGetPatchDeploymentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IGetPatchDeploymentRequest|undefined, {}|undefined + ]>; + getPatchDeployment( + request: protos.google.cloud.osconfig.v1beta.IGetPatchDeploymentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IGetPatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + getPatchDeployment( + request: protos.google.cloud.osconfig.v1beta.IGetPatchDeploymentRequest, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IGetPatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + getPatchDeployment( + request?: protos.google.cloud.osconfig.v1beta.IGetPatchDeploymentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IGetPatchDeploymentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IGetPatchDeploymentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IGetPatchDeploymentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getPatchDeployment(request, options, callback); + } +/** + * Delete an OS Config patch deployment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the patch deployment in the form + * `projects/* /patchDeployments/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_config_service.delete_patch_deployment.js + * region_tag:osconfig_v1beta_generated_OsConfigService_DeletePatchDeployment_async + */ + deletePatchDeployment( + request?: protos.google.cloud.osconfig.v1beta.IDeletePatchDeploymentRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.osconfig.v1beta.IDeletePatchDeploymentRequest|undefined, {}|undefined + ]>; + deletePatchDeployment( + request: protos.google.cloud.osconfig.v1beta.IDeletePatchDeploymentRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.osconfig.v1beta.IDeletePatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + deletePatchDeployment( + request: protos.google.cloud.osconfig.v1beta.IDeletePatchDeploymentRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.osconfig.v1beta.IDeletePatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + deletePatchDeployment( + request?: protos.google.cloud.osconfig.v1beta.IDeletePatchDeploymentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.osconfig.v1beta.IDeletePatchDeploymentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.osconfig.v1beta.IDeletePatchDeploymentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.osconfig.v1beta.IDeletePatchDeploymentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deletePatchDeployment(request, options, callback); + } +/** + * Update an OS Config patch deployment. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.osconfig.v1beta.PatchDeployment} request.patchDeployment + * Required. The patch deployment to Update. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask that controls which fields of the patch deployment should be + * 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 protos.google.cloud.osconfig.v1beta.PatchDeployment|PatchDeployment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_config_service.update_patch_deployment.js + * region_tag:osconfig_v1beta_generated_OsConfigService_UpdatePatchDeployment_async + */ + updatePatchDeployment( + request?: protos.google.cloud.osconfig.v1beta.IUpdatePatchDeploymentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IUpdatePatchDeploymentRequest|undefined, {}|undefined + ]>; + updatePatchDeployment( + request: protos.google.cloud.osconfig.v1beta.IUpdatePatchDeploymentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IUpdatePatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + updatePatchDeployment( + request: protos.google.cloud.osconfig.v1beta.IUpdatePatchDeploymentRequest, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IUpdatePatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + updatePatchDeployment( + request?: protos.google.cloud.osconfig.v1beta.IUpdatePatchDeploymentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IUpdatePatchDeploymentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IUpdatePatchDeploymentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IUpdatePatchDeploymentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'patch_deployment.name': request.patchDeployment!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updatePatchDeployment(request, options, callback); + } +/** + * Change state of patch deployment to "PAUSED". + * Patch deployment in paused state doesn't generate patch jobs. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the patch deployment in the form + * `projects/* /patchDeployments/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1beta.PatchDeployment|PatchDeployment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_config_service.pause_patch_deployment.js + * region_tag:osconfig_v1beta_generated_OsConfigService_PausePatchDeployment_async + */ + pausePatchDeployment( + request?: protos.google.cloud.osconfig.v1beta.IPausePatchDeploymentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IPausePatchDeploymentRequest|undefined, {}|undefined + ]>; + pausePatchDeployment( + request: protos.google.cloud.osconfig.v1beta.IPausePatchDeploymentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IPausePatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + pausePatchDeployment( + request: protos.google.cloud.osconfig.v1beta.IPausePatchDeploymentRequest, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IPausePatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + pausePatchDeployment( + request?: protos.google.cloud.osconfig.v1beta.IPausePatchDeploymentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IPausePatchDeploymentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IPausePatchDeploymentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IPausePatchDeploymentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.pausePatchDeployment(request, options, callback); + } +/** + * Change state of patch deployment back to "ACTIVE". + * Patch deployment in active state continues to generate patch jobs. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the patch deployment in the form + * `projects/* /patchDeployments/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1beta.PatchDeployment|PatchDeployment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_config_service.resume_patch_deployment.js + * region_tag:osconfig_v1beta_generated_OsConfigService_ResumePatchDeployment_async + */ + resumePatchDeployment( + request?: protos.google.cloud.osconfig.v1beta.IResumePatchDeploymentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IResumePatchDeploymentRequest|undefined, {}|undefined + ]>; + resumePatchDeployment( + request: protos.google.cloud.osconfig.v1beta.IResumePatchDeploymentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IResumePatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + resumePatchDeployment( + request: protos.google.cloud.osconfig.v1beta.IResumePatchDeploymentRequest, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IResumePatchDeploymentRequest|null|undefined, + {}|null|undefined>): void; + resumePatchDeployment( + request?: protos.google.cloud.osconfig.v1beta.IResumePatchDeploymentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IResumePatchDeploymentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IResumePatchDeploymentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchDeployment, + protos.google.cloud.osconfig.v1beta.IResumePatchDeploymentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.resumePatchDeployment(request, options, callback); + } +/** + * Create an OS Config guest policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the parent using one of the following forms: + * `projects/{project_number}`. + * @param {string} request.guestPolicyId + * Required. The logical name of the guest policy in the project + * with the following restrictions: + * + * * Must contain only lowercase letters, numbers, and hyphens. + * * Must start with a letter. + * * Must be between 1-63 characters. + * * Must end with a number or a letter. + * * Must be unique within the project. + * @param {google.cloud.osconfig.v1beta.GuestPolicy} request.guestPolicy + * Required. The GuestPolicy to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1beta.GuestPolicy|GuestPolicy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_config_service.create_guest_policy.js + * region_tag:osconfig_v1beta_generated_OsConfigService_CreateGuestPolicy_async + */ + createGuestPolicy( + request?: protos.google.cloud.osconfig.v1beta.ICreateGuestPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1beta.IGuestPolicy, + protos.google.cloud.osconfig.v1beta.ICreateGuestPolicyRequest|undefined, {}|undefined + ]>; + createGuestPolicy( + request: protos.google.cloud.osconfig.v1beta.ICreateGuestPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IGuestPolicy, + protos.google.cloud.osconfig.v1beta.ICreateGuestPolicyRequest|null|undefined, + {}|null|undefined>): void; + createGuestPolicy( + request: protos.google.cloud.osconfig.v1beta.ICreateGuestPolicyRequest, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IGuestPolicy, + protos.google.cloud.osconfig.v1beta.ICreateGuestPolicyRequest|null|undefined, + {}|null|undefined>): void; + createGuestPolicy( + request?: protos.google.cloud.osconfig.v1beta.ICreateGuestPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1beta.IGuestPolicy, + protos.google.cloud.osconfig.v1beta.ICreateGuestPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1beta.IGuestPolicy, + protos.google.cloud.osconfig.v1beta.ICreateGuestPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1beta.IGuestPolicy, + protos.google.cloud.osconfig.v1beta.ICreateGuestPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createGuestPolicy(request, options, callback); + } +/** + * Get an OS Config guest policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the guest policy using one of the following forms: + * `projects/{project_number}/guestPolicies/{guest_policy_id}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1beta.GuestPolicy|GuestPolicy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_config_service.get_guest_policy.js + * region_tag:osconfig_v1beta_generated_OsConfigService_GetGuestPolicy_async + */ + getGuestPolicy( + request?: protos.google.cloud.osconfig.v1beta.IGetGuestPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1beta.IGuestPolicy, + protos.google.cloud.osconfig.v1beta.IGetGuestPolicyRequest|undefined, {}|undefined + ]>; + getGuestPolicy( + request: protos.google.cloud.osconfig.v1beta.IGetGuestPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IGuestPolicy, + protos.google.cloud.osconfig.v1beta.IGetGuestPolicyRequest|null|undefined, + {}|null|undefined>): void; + getGuestPolicy( + request: protos.google.cloud.osconfig.v1beta.IGetGuestPolicyRequest, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IGuestPolicy, + protos.google.cloud.osconfig.v1beta.IGetGuestPolicyRequest|null|undefined, + {}|null|undefined>): void; + getGuestPolicy( + request?: protos.google.cloud.osconfig.v1beta.IGetGuestPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1beta.IGuestPolicy, + protos.google.cloud.osconfig.v1beta.IGetGuestPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1beta.IGuestPolicy, + protos.google.cloud.osconfig.v1beta.IGetGuestPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1beta.IGuestPolicy, + protos.google.cloud.osconfig.v1beta.IGetGuestPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getGuestPolicy(request, options, callback); + } +/** + * Update an OS Config guest policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.osconfig.v1beta.GuestPolicy} request.guestPolicy + * Required. The updated GuestPolicy. + * @param {google.protobuf.FieldMask} request.updateMask + * Field mask that controls which fields of the guest policy should be + * 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 protos.google.cloud.osconfig.v1beta.GuestPolicy|GuestPolicy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_config_service.update_guest_policy.js + * region_tag:osconfig_v1beta_generated_OsConfigService_UpdateGuestPolicy_async + */ + updateGuestPolicy( + request?: protos.google.cloud.osconfig.v1beta.IUpdateGuestPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1beta.IGuestPolicy, + protos.google.cloud.osconfig.v1beta.IUpdateGuestPolicyRequest|undefined, {}|undefined + ]>; + updateGuestPolicy( + request: protos.google.cloud.osconfig.v1beta.IUpdateGuestPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IGuestPolicy, + protos.google.cloud.osconfig.v1beta.IUpdateGuestPolicyRequest|null|undefined, + {}|null|undefined>): void; + updateGuestPolicy( + request: protos.google.cloud.osconfig.v1beta.IUpdateGuestPolicyRequest, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IGuestPolicy, + protos.google.cloud.osconfig.v1beta.IUpdateGuestPolicyRequest|null|undefined, + {}|null|undefined>): void; + updateGuestPolicy( + request?: protos.google.cloud.osconfig.v1beta.IUpdateGuestPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1beta.IGuestPolicy, + protos.google.cloud.osconfig.v1beta.IUpdateGuestPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1beta.IGuestPolicy, + protos.google.cloud.osconfig.v1beta.IUpdateGuestPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1beta.IGuestPolicy, + protos.google.cloud.osconfig.v1beta.IUpdateGuestPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'guest_policy.name': request.guestPolicy!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateGuestPolicy(request, options, callback); + } +/** + * Delete an OS Config guest policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the guest policy using one of the following forms: + * `projects/{project_number}/guestPolicies/{guest_policy_id}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_config_service.delete_guest_policy.js + * region_tag:osconfig_v1beta_generated_OsConfigService_DeleteGuestPolicy_async + */ + deleteGuestPolicy( + request?: protos.google.cloud.osconfig.v1beta.IDeleteGuestPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.osconfig.v1beta.IDeleteGuestPolicyRequest|undefined, {}|undefined + ]>; + deleteGuestPolicy( + request: protos.google.cloud.osconfig.v1beta.IDeleteGuestPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.osconfig.v1beta.IDeleteGuestPolicyRequest|null|undefined, + {}|null|undefined>): void; + deleteGuestPolicy( + request: protos.google.cloud.osconfig.v1beta.IDeleteGuestPolicyRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.osconfig.v1beta.IDeleteGuestPolicyRequest|null|undefined, + {}|null|undefined>): void; + deleteGuestPolicy( + request?: protos.google.cloud.osconfig.v1beta.IDeleteGuestPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.osconfig.v1beta.IDeleteGuestPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.osconfig.v1beta.IDeleteGuestPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.osconfig.v1beta.IDeleteGuestPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteGuestPolicy(request, options, callback); + } +/** + * Lookup the effective guest policy that applies to a VM instance. This + * lookup merges all policies that are assigned to the instance ancestry. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. The VM instance whose policies are being looked up. + * @param {string} request.osShortName + * Short name of the OS running on the instance. The OS Config agent only + * provides this field for targeting if OS Inventory is enabled for that + * instance. + * @param {string} request.osVersion + * Version of the OS running on the instance. The OS Config agent only + * provides this field for targeting if OS Inventory is enabled for that + * VM instance. + * @param {string} request.osArchitecture + * Architecture of OS running on the instance. The OS Config agent only + * provides this field for targeting if OS Inventory is enabled for that + * instance. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1beta.EffectiveGuestPolicy|EffectiveGuestPolicy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_config_service.lookup_effective_guest_policy.js + * region_tag:osconfig_v1beta_generated_OsConfigService_LookupEffectiveGuestPolicy_async + */ + lookupEffectiveGuestPolicy( + request?: protos.google.cloud.osconfig.v1beta.ILookupEffectiveGuestPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1beta.IEffectiveGuestPolicy, + protos.google.cloud.osconfig.v1beta.ILookupEffectiveGuestPolicyRequest|undefined, {}|undefined + ]>; + lookupEffectiveGuestPolicy( + request: protos.google.cloud.osconfig.v1beta.ILookupEffectiveGuestPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IEffectiveGuestPolicy, + protos.google.cloud.osconfig.v1beta.ILookupEffectiveGuestPolicyRequest|null|undefined, + {}|null|undefined>): void; + lookupEffectiveGuestPolicy( + request: protos.google.cloud.osconfig.v1beta.ILookupEffectiveGuestPolicyRequest, + callback: Callback< + protos.google.cloud.osconfig.v1beta.IEffectiveGuestPolicy, + protos.google.cloud.osconfig.v1beta.ILookupEffectiveGuestPolicyRequest|null|undefined, + {}|null|undefined>): void; + lookupEffectiveGuestPolicy( + request?: protos.google.cloud.osconfig.v1beta.ILookupEffectiveGuestPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.osconfig.v1beta.IEffectiveGuestPolicy, + protos.google.cloud.osconfig.v1beta.ILookupEffectiveGuestPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.osconfig.v1beta.IEffectiveGuestPolicy, + protos.google.cloud.osconfig.v1beta.ILookupEffectiveGuestPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.osconfig.v1beta.IEffectiveGuestPolicy, + protos.google.cloud.osconfig.v1beta.ILookupEffectiveGuestPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.lookupEffectiveGuestPolicy(request, options, callback); + } + + /** + * Get a list of patch jobs. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. In the form of `projects/*` + * @param {number} request.pageSize + * The maximum number of instance status to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call + * that indicates where this listing should continue from. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by patch + * jobs to be included in the response. + * Currently, filtering is only available on the patch_deployment field. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1beta.PatchJob|PatchJob}. + * 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 `listPatchJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listPatchJobs( + request?: protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchJob[], + protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest|null, + protos.google.cloud.osconfig.v1beta.IListPatchJobsResponse + ]>; + listPatchJobs( + request: protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest, + protos.google.cloud.osconfig.v1beta.IListPatchJobsResponse|null|undefined, + protos.google.cloud.osconfig.v1beta.IPatchJob>): void; + listPatchJobs( + request: protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest, + protos.google.cloud.osconfig.v1beta.IListPatchJobsResponse|null|undefined, + protos.google.cloud.osconfig.v1beta.IPatchJob>): void; + listPatchJobs( + request?: protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest, + protos.google.cloud.osconfig.v1beta.IListPatchJobsResponse|null|undefined, + protos.google.cloud.osconfig.v1beta.IPatchJob>, + callback?: PaginationCallback< + protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest, + protos.google.cloud.osconfig.v1beta.IListPatchJobsResponse|null|undefined, + protos.google.cloud.osconfig.v1beta.IPatchJob>): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchJob[], + protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest|null, + protos.google.cloud.osconfig.v1beta.IListPatchJobsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listPatchJobs(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. In the form of `projects/*` + * @param {number} request.pageSize + * The maximum number of instance status to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call + * that indicates where this listing should continue from. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by patch + * jobs to be included in the response. + * Currently, filtering is only available on the patch_deployment field. + * @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 protos.google.cloud.osconfig.v1beta.PatchJob|PatchJob} 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 `listPatchJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listPatchJobsStream( + request?: protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest, + 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['listPatchJobs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPatchJobs.createStream( + this.innerApiCalls.listPatchJobs as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listPatchJobs`, 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. In the form of `projects/*` + * @param {number} request.pageSize + * The maximum number of instance status to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call + * that indicates where this listing should continue from. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by patch + * jobs to be included in the response. + * Currently, filtering is only available on the patch_deployment field. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.osconfig.v1beta.PatchJob|PatchJob}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_config_service.list_patch_jobs.js + * region_tag:osconfig_v1beta_generated_OsConfigService_ListPatchJobs_async + */ + listPatchJobsAsync( + request?: protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest, + 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['listPatchJobs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPatchJobs.asyncIterate( + this.innerApiCalls['listPatchJobs'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Get a list of instance details for a given patch job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent for the instances are in the form of `projects/* /patchJobs/*`. + * @param {number} request.pageSize + * The maximum number of instance details records to return. Default is 100. + * @param {string} request.pageToken + * A pagination token returned from a previous call + * that indicates where this listing should continue from. + * @param {string} request.filter + * A filter expression that filters results listed in the response. This + * field supports filtering results by instance zone, name, state, or + * `failure_reason`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails|PatchJobInstanceDetails}. + * 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 `listPatchJobInstanceDetailsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listPatchJobInstanceDetails( + request?: protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchJobInstanceDetails[], + protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest|null, + protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsResponse + ]>; + listPatchJobInstanceDetails( + request: protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest, + protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsResponse|null|undefined, + protos.google.cloud.osconfig.v1beta.IPatchJobInstanceDetails>): void; + listPatchJobInstanceDetails( + request: protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest, + protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsResponse|null|undefined, + protos.google.cloud.osconfig.v1beta.IPatchJobInstanceDetails>): void; + listPatchJobInstanceDetails( + request?: protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest, + protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsResponse|null|undefined, + protos.google.cloud.osconfig.v1beta.IPatchJobInstanceDetails>, + callback?: PaginationCallback< + protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest, + protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsResponse|null|undefined, + protos.google.cloud.osconfig.v1beta.IPatchJobInstanceDetails>): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchJobInstanceDetails[], + protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest|null, + protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listPatchJobInstanceDetails(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 the instances are in the form of `projects/* /patchJobs/*`. + * @param {number} request.pageSize + * The maximum number of instance details records to return. Default is 100. + * @param {string} request.pageToken + * A pagination token returned from a previous call + * that indicates where this listing should continue from. + * @param {string} request.filter + * A filter expression that filters results listed in the response. This + * field supports filtering results by instance zone, name, state, or + * `failure_reason`. + * @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 protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails|PatchJobInstanceDetails} 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 `listPatchJobInstanceDetailsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listPatchJobInstanceDetailsStream( + request?: protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest, + 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['listPatchJobInstanceDetails']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPatchJobInstanceDetails.createStream( + this.innerApiCalls.listPatchJobInstanceDetails as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listPatchJobInstanceDetails`, 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 the instances are in the form of `projects/* /patchJobs/*`. + * @param {number} request.pageSize + * The maximum number of instance details records to return. Default is 100. + * @param {string} request.pageToken + * A pagination token returned from a previous call + * that indicates where this listing should continue from. + * @param {string} request.filter + * A filter expression that filters results listed in the response. This + * field supports filtering results by instance zone, name, state, or + * `failure_reason`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails|PatchJobInstanceDetails}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_config_service.list_patch_job_instance_details.js + * region_tag:osconfig_v1beta_generated_OsConfigService_ListPatchJobInstanceDetails_async + */ + listPatchJobInstanceDetailsAsync( + request?: protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest, + 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['listPatchJobInstanceDetails']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPatchJobInstanceDetails.asyncIterate( + this.innerApiCalls['listPatchJobInstanceDetails'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Get a page of OS Config patch deployments. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the parent in the form `projects/*`. + * @param {number} [request.pageSize] + * Optional. The maximum number of patch deployments to return. Default is 100. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to ListPatchDeployments + * that indicates where this listing should continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1beta.PatchDeployment|PatchDeployment}. + * 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 `listPatchDeploymentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listPatchDeployments( + request?: protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchDeployment[], + protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest|null, + protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsResponse + ]>; + listPatchDeployments( + request: protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest, + protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsResponse|null|undefined, + protos.google.cloud.osconfig.v1beta.IPatchDeployment>): void; + listPatchDeployments( + request: protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest, + protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsResponse|null|undefined, + protos.google.cloud.osconfig.v1beta.IPatchDeployment>): void; + listPatchDeployments( + request?: protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest, + protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsResponse|null|undefined, + protos.google.cloud.osconfig.v1beta.IPatchDeployment>, + callback?: PaginationCallback< + protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest, + protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsResponse|null|undefined, + protos.google.cloud.osconfig.v1beta.IPatchDeployment>): + Promise<[ + protos.google.cloud.osconfig.v1beta.IPatchDeployment[], + protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest|null, + protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listPatchDeployments(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the parent in the form `projects/*`. + * @param {number} [request.pageSize] + * Optional. The maximum number of patch deployments to return. Default is 100. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to ListPatchDeployments + * that indicates where this listing should continue from. + * @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 protos.google.cloud.osconfig.v1beta.PatchDeployment|PatchDeployment} 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 `listPatchDeploymentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listPatchDeploymentsStream( + request?: protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest, + 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['listPatchDeployments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPatchDeployments.createStream( + this.innerApiCalls.listPatchDeployments as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listPatchDeployments`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the parent in the form `projects/*`. + * @param {number} [request.pageSize] + * Optional. The maximum number of patch deployments to return. Default is 100. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to ListPatchDeployments + * that indicates where this listing should continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.osconfig.v1beta.PatchDeployment|PatchDeployment}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_config_service.list_patch_deployments.js + * region_tag:osconfig_v1beta_generated_OsConfigService_ListPatchDeployments_async + */ + listPatchDeploymentsAsync( + request?: protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest, + 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['listPatchDeployments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPatchDeployments.asyncIterate( + this.innerApiCalls['listPatchDeployments'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Get a page of OS Config guest policies. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the parent using one of the following forms: + * `projects/{project_number}`. + * @param {number} request.pageSize + * The maximum number of guest policies to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to `ListGuestPolicies` + * that indicates where this listing should continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1beta.GuestPolicy|GuestPolicy}. + * 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 `listGuestPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listGuestPolicies( + request?: protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.osconfig.v1beta.IGuestPolicy[], + protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest|null, + protos.google.cloud.osconfig.v1beta.IListGuestPoliciesResponse + ]>; + listGuestPolicies( + request: protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest, + protos.google.cloud.osconfig.v1beta.IListGuestPoliciesResponse|null|undefined, + protos.google.cloud.osconfig.v1beta.IGuestPolicy>): void; + listGuestPolicies( + request: protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest, + protos.google.cloud.osconfig.v1beta.IListGuestPoliciesResponse|null|undefined, + protos.google.cloud.osconfig.v1beta.IGuestPolicy>): void; + listGuestPolicies( + request?: protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest, + protos.google.cloud.osconfig.v1beta.IListGuestPoliciesResponse|null|undefined, + protos.google.cloud.osconfig.v1beta.IGuestPolicy>, + callback?: PaginationCallback< + protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest, + protos.google.cloud.osconfig.v1beta.IListGuestPoliciesResponse|null|undefined, + protos.google.cloud.osconfig.v1beta.IGuestPolicy>): + Promise<[ + protos.google.cloud.osconfig.v1beta.IGuestPolicy[], + protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest|null, + protos.google.cloud.osconfig.v1beta.IListGuestPoliciesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listGuestPolicies(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the parent using one of the following forms: + * `projects/{project_number}`. + * @param {number} request.pageSize + * The maximum number of guest policies to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to `ListGuestPolicies` + * that indicates where this listing should continue from. + * @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 protos.google.cloud.osconfig.v1beta.GuestPolicy|GuestPolicy} 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 `listGuestPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listGuestPoliciesStream( + request?: protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest, + 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['listGuestPolicies']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listGuestPolicies.createStream( + this.innerApiCalls.listGuestPolicies as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listGuestPolicies`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the parent using one of the following forms: + * `projects/{project_number}`. + * @param {number} request.pageSize + * The maximum number of guest policies to return. + * @param {string} request.pageToken + * A pagination token returned from a previous call to `ListGuestPolicies` + * that indicates where this listing should continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.osconfig.v1beta.GuestPolicy|GuestPolicy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_config_service.list_guest_policies.js + * region_tag:osconfig_v1beta_generated_OsConfigService_ListGuestPolicies_async + */ + listGuestPoliciesAsync( + request?: protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest, + 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['listGuestPolicies']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listGuestPolicies.asyncIterate( + this.innerApiCalls['listGuestPolicies'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified guestPolicy resource name string. + * + * @param {string} project + * @param {string} guest_policy + * @returns {string} Resource name string. + */ + guestPolicyPath(project:string,guestPolicy:string) { + return this.pathTemplates.guestPolicyPathTemplate.render({ + project: project, + guest_policy: guestPolicy, + }); + } + + /** + * Parse the project from GuestPolicy resource. + * + * @param {string} guestPolicyName + * A fully-qualified path representing GuestPolicy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromGuestPolicyName(guestPolicyName: string) { + return this.pathTemplates.guestPolicyPathTemplate.match(guestPolicyName).project; + } + + /** + * Parse the guest_policy from GuestPolicy resource. + * + * @param {string} guestPolicyName + * A fully-qualified path representing GuestPolicy resource. + * @returns {string} A string representing the guest_policy. + */ + matchGuestPolicyFromGuestPolicyName(guestPolicyName: string) { + return this.pathTemplates.guestPolicyPathTemplate.match(guestPolicyName).guest_policy; + } + + /** + * Return a fully-qualified patchDeployment resource name string. + * + * @param {string} project + * @param {string} patch_deployment + * @returns {string} Resource name string. + */ + patchDeploymentPath(project:string,patchDeployment:string) { + return this.pathTemplates.patchDeploymentPathTemplate.render({ + project: project, + patch_deployment: patchDeployment, + }); + } + + /** + * Parse the project from PatchDeployment resource. + * + * @param {string} patchDeploymentName + * A fully-qualified path representing PatchDeployment resource. + * @returns {string} A string representing the project. + */ + matchProjectFromPatchDeploymentName(patchDeploymentName: string) { + return this.pathTemplates.patchDeploymentPathTemplate.match(patchDeploymentName).project; + } + + /** + * Parse the patch_deployment from PatchDeployment resource. + * + * @param {string} patchDeploymentName + * A fully-qualified path representing PatchDeployment resource. + * @returns {string} A string representing the patch_deployment. + */ + matchPatchDeploymentFromPatchDeploymentName(patchDeploymentName: string) { + return this.pathTemplates.patchDeploymentPathTemplate.match(patchDeploymentName).patch_deployment; + } + + /** + * Return a fully-qualified patchJob resource name string. + * + * @param {string} project + * @param {string} patch_job + * @returns {string} Resource name string. + */ + patchJobPath(project:string,patchJob:string) { + return this.pathTemplates.patchJobPathTemplate.render({ + project: project, + patch_job: patchJob, + }); + } + + /** + * Parse the project from PatchJob resource. + * + * @param {string} patchJobName + * A fully-qualified path representing PatchJob resource. + * @returns {string} A string representing the project. + */ + matchProjectFromPatchJobName(patchJobName: string) { + return this.pathTemplates.patchJobPathTemplate.match(patchJobName).project; + } + + /** + * Parse the patch_job from PatchJob resource. + * + * @param {string} patchJobName + * A fully-qualified path representing PatchJob resource. + * @returns {string} A string representing the patch_job. + */ + matchPatchJobFromPatchJobName(patchJobName: string) { + return this.pathTemplates.patchJobPathTemplate.match(patchJobName).patch_job; + } + + /** + * 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.osConfigServiceStub && !this._terminated) { + return this.osConfigServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_client_config.json b/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_client_config.json new file mode 100644 index 00000000000..6e870f1df46 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_client_config.json @@ -0,0 +1,128 @@ +{ + "interfaces": { + "google.cloud.osconfig.v1beta.OsConfigService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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 + }, + "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c": { + "initial_retry_delay_millis": 1000, + "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": { + "ExecutePatchJob": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "GetPatchJob": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "CancelPatchJob": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "ListPatchJobs": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "ListPatchJobInstanceDetails": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "CreatePatchDeployment": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "GetPatchDeployment": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "ListPatchDeployments": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "DeletePatchDeployment": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "UpdatePatchDeployment": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "PausePatchDeployment": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "ResumePatchDeployment": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "CreateGuestPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "GetGuestPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "ListGuestPolicies": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "UpdateGuestPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "DeleteGuestPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "LookupEffectiveGuestPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_proto_list.json b/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_proto_list.json new file mode 100644 index 00000000000..284bb75475e --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_proto_list.json @@ -0,0 +1,7 @@ +[ + "../../protos/google/cloud/osconfig/v1beta/guest_policies.proto", + "../../protos/google/cloud/osconfig/v1beta/osconfig_common.proto", + "../../protos/google/cloud/osconfig/v1beta/osconfig_service.proto", + "../../protos/google/cloud/osconfig/v1beta/patch_deployments.proto", + "../../protos/google/cloud/osconfig/v1beta/patch_jobs.proto" +] diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-osconfig/v1beta/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..f94ced51b90 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const osconfig = require('@google-cloud/osconfig'); + +function main() { + const osConfigServiceClient = new osconfig.OsConfigServiceClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-osconfig/v1beta/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..38bffb0af57 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {OsConfigServiceClient} from '@google-cloud/osconfig'; + +// check that the client class type name can be used +function doStuffWithOsConfigServiceClient(client: OsConfigServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const osConfigServiceClient = new OsConfigServiceClient(); + doStuffWithOsConfigServiceClient(osConfigServiceClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/system-test/install.ts b/owl-bot-staging/google-cloud-osconfig/v1beta/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/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-osconfig/v1beta/test/gapic_os_config_service_v1beta.ts b/owl-bot-staging/google-cloud-osconfig/v1beta/test/gapic_os_config_service_v1beta.ts new file mode 100644 index 00000000000..bc233a36428 --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/test/gapic_os_config_service_v1beta.ts @@ -0,0 +1,2814 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 osconfigserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +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('v1beta.OsConfigServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = osconfigserviceModule.v1beta.OsConfigServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = osconfigserviceModule.v1beta.OsConfigServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = osconfigserviceModule.v1beta.OsConfigServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.osConfigServiceStub, undefined); + await client.initialize(); + assert(client.osConfigServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.osConfigServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.osConfigServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + 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 osconfigserviceModule.v1beta.OsConfigServiceClient({ + 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('executePatchJob', () => { + it('invokes executePatchJob without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ExecutePatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ExecutePatchJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.PatchJob() + ); + client.innerApiCalls.executePatchJob = stubSimpleCall(expectedResponse); + const [response] = await client.executePatchJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.executePatchJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.executePatchJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executePatchJob without error using callback', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ExecutePatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ExecutePatchJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.PatchJob() + ); + client.innerApiCalls.executePatchJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.executePatchJob( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.executePatchJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.executePatchJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executePatchJob with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ExecutePatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ExecutePatchJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.executePatchJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.executePatchJob(request), expectedError); + const actualRequest = (client.innerApiCalls.executePatchJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.executePatchJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executePatchJob with closed client', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ExecutePatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ExecutePatchJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.executePatchJob(request), expectedError); + }); + }); + + describe('getPatchJob', () => { + it('invokes getPatchJob without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.GetPatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetPatchJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.PatchJob() + ); + client.innerApiCalls.getPatchJob = stubSimpleCall(expectedResponse); + const [response] = await client.getPatchJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getPatchJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getPatchJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPatchJob without error using callback', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.GetPatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetPatchJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.PatchJob() + ); + client.innerApiCalls.getPatchJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getPatchJob( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getPatchJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getPatchJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPatchJob with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.GetPatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetPatchJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getPatchJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getPatchJob(request), expectedError); + const actualRequest = (client.innerApiCalls.getPatchJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getPatchJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPatchJob with closed client', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.GetPatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetPatchJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getPatchJob(request), expectedError); + }); + }); + + describe('cancelPatchJob', () => { + it('invokes cancelPatchJob without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.CancelPatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.CancelPatchJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.PatchJob() + ); + client.innerApiCalls.cancelPatchJob = stubSimpleCall(expectedResponse); + const [response] = await client.cancelPatchJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.cancelPatchJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.cancelPatchJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cancelPatchJob without error using callback', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.CancelPatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.CancelPatchJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.PatchJob() + ); + client.innerApiCalls.cancelPatchJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.cancelPatchJob( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.cancelPatchJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.cancelPatchJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cancelPatchJob with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.CancelPatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.CancelPatchJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.cancelPatchJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.cancelPatchJob(request), expectedError); + const actualRequest = (client.innerApiCalls.cancelPatchJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.cancelPatchJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cancelPatchJob with closed client', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.CancelPatchJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.CancelPatchJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.cancelPatchJob(request), expectedError); + }); + }); + + describe('createPatchDeployment', () => { + it('invokes createPatchDeployment without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.CreatePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.CreatePatchDeploymentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.PatchDeployment() + ); + client.innerApiCalls.createPatchDeployment = stubSimpleCall(expectedResponse); + const [response] = await client.createPatchDeployment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createPatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createPatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createPatchDeployment without error using callback', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.CreatePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.CreatePatchDeploymentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.PatchDeployment() + ); + client.innerApiCalls.createPatchDeployment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createPatchDeployment( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchDeployment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createPatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createPatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createPatchDeployment with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.CreatePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.CreatePatchDeploymentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createPatchDeployment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createPatchDeployment(request), expectedError); + const actualRequest = (client.innerApiCalls.createPatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createPatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createPatchDeployment with closed client', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.CreatePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.CreatePatchDeploymentRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createPatchDeployment(request), expectedError); + }); + }); + + describe('getPatchDeployment', () => { + it('invokes getPatchDeployment without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.GetPatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetPatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.PatchDeployment() + ); + client.innerApiCalls.getPatchDeployment = stubSimpleCall(expectedResponse); + const [response] = await client.getPatchDeployment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getPatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getPatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPatchDeployment without error using callback', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.GetPatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetPatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.PatchDeployment() + ); + client.innerApiCalls.getPatchDeployment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getPatchDeployment( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchDeployment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getPatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getPatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPatchDeployment with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.GetPatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetPatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getPatchDeployment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getPatchDeployment(request), expectedError); + const actualRequest = (client.innerApiCalls.getPatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getPatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPatchDeployment with closed client', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.GetPatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetPatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getPatchDeployment(request), expectedError); + }); + }); + + describe('deletePatchDeployment', () => { + it('invokes deletePatchDeployment without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.DeletePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.DeletePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deletePatchDeployment = stubSimpleCall(expectedResponse); + const [response] = await client.deletePatchDeployment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deletePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePatchDeployment without error using callback', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.DeletePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.DeletePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deletePatchDeployment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deletePatchDeployment( + 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.deletePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePatchDeployment with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.DeletePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.DeletePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePatchDeployment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deletePatchDeployment(request), expectedError); + const actualRequest = (client.innerApiCalls.deletePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePatchDeployment with closed client', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.DeletePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.DeletePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deletePatchDeployment(request), expectedError); + }); + }); + + describe('updatePatchDeployment', () => { + it('invokes updatePatchDeployment without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.UpdatePatchDeploymentRequest() + ); + request.patchDeployment ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.UpdatePatchDeploymentRequest', ['patchDeployment', 'name']); + request.patchDeployment.name = defaultValue1; + const expectedHeaderRequestParams = `patch_deployment.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.PatchDeployment() + ); + client.innerApiCalls.updatePatchDeployment = stubSimpleCall(expectedResponse); + const [response] = await client.updatePatchDeployment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updatePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePatchDeployment without error using callback', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.UpdatePatchDeploymentRequest() + ); + request.patchDeployment ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.UpdatePatchDeploymentRequest', ['patchDeployment', 'name']); + request.patchDeployment.name = defaultValue1; + const expectedHeaderRequestParams = `patch_deployment.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.PatchDeployment() + ); + client.innerApiCalls.updatePatchDeployment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updatePatchDeployment( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchDeployment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updatePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePatchDeployment with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.UpdatePatchDeploymentRequest() + ); + request.patchDeployment ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.UpdatePatchDeploymentRequest', ['patchDeployment', 'name']); + request.patchDeployment.name = defaultValue1; + const expectedHeaderRequestParams = `patch_deployment.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updatePatchDeployment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updatePatchDeployment(request), expectedError); + const actualRequest = (client.innerApiCalls.updatePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePatchDeployment with closed client', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.UpdatePatchDeploymentRequest() + ); + request.patchDeployment ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.UpdatePatchDeploymentRequest', ['patchDeployment', 'name']); + request.patchDeployment.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updatePatchDeployment(request), expectedError); + }); + }); + + describe('pausePatchDeployment', () => { + it('invokes pausePatchDeployment without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.PausePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.PausePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.PatchDeployment() + ); + client.innerApiCalls.pausePatchDeployment = stubSimpleCall(expectedResponse); + const [response] = await client.pausePatchDeployment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pausePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pausePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pausePatchDeployment without error using callback', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.PausePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.PausePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.PatchDeployment() + ); + client.innerApiCalls.pausePatchDeployment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.pausePatchDeployment( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchDeployment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pausePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pausePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pausePatchDeployment with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.PausePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.PausePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.pausePatchDeployment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.pausePatchDeployment(request), expectedError); + const actualRequest = (client.innerApiCalls.pausePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pausePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pausePatchDeployment with closed client', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.PausePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.PausePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.pausePatchDeployment(request), expectedError); + }); + }); + + describe('resumePatchDeployment', () => { + it('invokes resumePatchDeployment without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ResumePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ResumePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.PatchDeployment() + ); + client.innerApiCalls.resumePatchDeployment = stubSimpleCall(expectedResponse); + const [response] = await client.resumePatchDeployment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resumePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumePatchDeployment without error using callback', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ResumePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ResumePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.PatchDeployment() + ); + client.innerApiCalls.resumePatchDeployment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resumePatchDeployment( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchDeployment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resumePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumePatchDeployment with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ResumePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ResumePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resumePatchDeployment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.resumePatchDeployment(request), expectedError); + const actualRequest = (client.innerApiCalls.resumePatchDeployment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumePatchDeployment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumePatchDeployment with closed client', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ResumePatchDeploymentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ResumePatchDeploymentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.resumePatchDeployment(request), expectedError); + }); + }); + + describe('createGuestPolicy', () => { + it('invokes createGuestPolicy without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.CreateGuestPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.CreateGuestPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.GuestPolicy() + ); + client.innerApiCalls.createGuestPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.createGuestPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createGuestPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createGuestPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createGuestPolicy without error using callback', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.CreateGuestPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.CreateGuestPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.GuestPolicy() + ); + client.innerApiCalls.createGuestPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createGuestPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IGuestPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createGuestPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createGuestPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createGuestPolicy with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.CreateGuestPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.CreateGuestPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createGuestPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createGuestPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.createGuestPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createGuestPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createGuestPolicy with closed client', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.CreateGuestPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.CreateGuestPolicyRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createGuestPolicy(request), expectedError); + }); + }); + + describe('getGuestPolicy', () => { + it('invokes getGuestPolicy without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.GetGuestPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetGuestPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.GuestPolicy() + ); + client.innerApiCalls.getGuestPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getGuestPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getGuestPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getGuestPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getGuestPolicy without error using callback', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.GetGuestPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetGuestPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.GuestPolicy() + ); + client.innerApiCalls.getGuestPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getGuestPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IGuestPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getGuestPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getGuestPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getGuestPolicy with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.GetGuestPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetGuestPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getGuestPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getGuestPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getGuestPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getGuestPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getGuestPolicy with closed client', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.GetGuestPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetGuestPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getGuestPolicy(request), expectedError); + }); + }); + + describe('updateGuestPolicy', () => { + it('invokes updateGuestPolicy without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.UpdateGuestPolicyRequest() + ); + request.guestPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.UpdateGuestPolicyRequest', ['guestPolicy', 'name']); + request.guestPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `guest_policy.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.GuestPolicy() + ); + client.innerApiCalls.updateGuestPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.updateGuestPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateGuestPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateGuestPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateGuestPolicy without error using callback', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.UpdateGuestPolicyRequest() + ); + request.guestPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.UpdateGuestPolicyRequest', ['guestPolicy', 'name']); + request.guestPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `guest_policy.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.GuestPolicy() + ); + client.innerApiCalls.updateGuestPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateGuestPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IGuestPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateGuestPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateGuestPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateGuestPolicy with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.UpdateGuestPolicyRequest() + ); + request.guestPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.UpdateGuestPolicyRequest', ['guestPolicy', 'name']); + request.guestPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `guest_policy.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateGuestPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateGuestPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.updateGuestPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateGuestPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateGuestPolicy with closed client', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.UpdateGuestPolicyRequest() + ); + request.guestPolicy ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.UpdateGuestPolicyRequest', ['guestPolicy', 'name']); + request.guestPolicy.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateGuestPolicy(request), expectedError); + }); + }); + + describe('deleteGuestPolicy', () => { + it('invokes deleteGuestPolicy without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.DeleteGuestPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.DeleteGuestPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteGuestPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.deleteGuestPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteGuestPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteGuestPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteGuestPolicy without error using callback', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.DeleteGuestPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.DeleteGuestPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteGuestPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteGuestPolicy( + 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.deleteGuestPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteGuestPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteGuestPolicy with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.DeleteGuestPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.DeleteGuestPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteGuestPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteGuestPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteGuestPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteGuestPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteGuestPolicy with closed client', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.DeleteGuestPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.DeleteGuestPolicyRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteGuestPolicy(request), expectedError); + }); + }); + + describe('lookupEffectiveGuestPolicy', () => { + it('invokes lookupEffectiveGuestPolicy without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.LookupEffectiveGuestPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.LookupEffectiveGuestPolicyRequest', ['instance']); + request.instance = defaultValue1; + const expectedHeaderRequestParams = `instance=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.EffectiveGuestPolicy() + ); + client.innerApiCalls.lookupEffectiveGuestPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.lookupEffectiveGuestPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.lookupEffectiveGuestPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.lookupEffectiveGuestPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes lookupEffectiveGuestPolicy without error using callback', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.LookupEffectiveGuestPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.LookupEffectiveGuestPolicyRequest', ['instance']); + request.instance = defaultValue1; + const expectedHeaderRequestParams = `instance=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.EffectiveGuestPolicy() + ); + client.innerApiCalls.lookupEffectiveGuestPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.lookupEffectiveGuestPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IEffectiveGuestPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.lookupEffectiveGuestPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.lookupEffectiveGuestPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes lookupEffectiveGuestPolicy with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.LookupEffectiveGuestPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.LookupEffectiveGuestPolicyRequest', ['instance']); + request.instance = defaultValue1; + const expectedHeaderRequestParams = `instance=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.lookupEffectiveGuestPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.lookupEffectiveGuestPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.lookupEffectiveGuestPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.lookupEffectiveGuestPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes lookupEffectiveGuestPolicy with closed client', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.LookupEffectiveGuestPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.LookupEffectiveGuestPolicyRequest', ['instance']); + request.instance = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.lookupEffectiveGuestPolicy(request), expectedError); + }); + }); + + describe('listPatchJobs', () => { + it('invokes listPatchJobs without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListPatchJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), + ]; + client.innerApiCalls.listPatchJobs = stubSimpleCall(expectedResponse); + const [response] = await client.listPatchJobs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPatchJobs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPatchJobs without error using callback', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListPatchJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), + ]; + client.innerApiCalls.listPatchJobs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPatchJobs( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchJob[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPatchJobs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPatchJobs with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListPatchJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPatchJobs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listPatchJobs(request), expectedError); + const actualRequest = (client.innerApiCalls.listPatchJobs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPatchJobsStream without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListPatchJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), + ]; + client.descriptors.page.listPatchJobs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listPatchJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1beta.PatchJob[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1beta.PatchJob) => { + 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.listPatchJobs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPatchJobs, request)); + assert( + (client.descriptors.page.listPatchJobs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listPatchJobsStream with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListPatchJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPatchJobs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listPatchJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1beta.PatchJob[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1beta.PatchJob) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listPatchJobs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPatchJobs, request)); + assert( + (client.descriptors.page.listPatchJobs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPatchJobs without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListPatchJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), + ]; + client.descriptors.page.listPatchJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.osconfig.v1beta.IPatchJob[] = []; + const iterable = client.listPatchJobsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listPatchJobs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPatchJobs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPatchJobs with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListPatchJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPatchJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listPatchJobsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.osconfig.v1beta.IPatchJob[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listPatchJobs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPatchJobs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listPatchJobInstanceDetails', () => { + it('invokes listPatchJobInstanceDetails without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), + ]; + client.innerApiCalls.listPatchJobInstanceDetails = stubSimpleCall(expectedResponse); + const [response] = await client.listPatchJobInstanceDetails(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPatchJobInstanceDetails without error using callback', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), + ]; + client.innerApiCalls.listPatchJobInstanceDetails = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPatchJobInstanceDetails( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchJobInstanceDetails[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPatchJobInstanceDetails with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPatchJobInstanceDetails = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listPatchJobInstanceDetails(request), expectedError); + const actualRequest = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPatchJobInstanceDetailsStream without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), + ]; + client.descriptors.page.listPatchJobInstanceDetails.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listPatchJobInstanceDetailsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails) => { + 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.listPatchJobInstanceDetails.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPatchJobInstanceDetails, request)); + assert( + (client.descriptors.page.listPatchJobInstanceDetails.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listPatchJobInstanceDetailsStream with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPatchJobInstanceDetails.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listPatchJobInstanceDetailsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listPatchJobInstanceDetails.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPatchJobInstanceDetails, request)); + assert( + (client.descriptors.page.listPatchJobInstanceDetails.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPatchJobInstanceDetails without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), + ]; + client.descriptors.page.listPatchJobInstanceDetails.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.osconfig.v1beta.IPatchJobInstanceDetails[] = []; + const iterable = client.listPatchJobInstanceDetailsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listPatchJobInstanceDetails.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPatchJobInstanceDetails.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPatchJobInstanceDetails with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPatchJobInstanceDetails.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listPatchJobInstanceDetailsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.osconfig.v1beta.IPatchJobInstanceDetails[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listPatchJobInstanceDetails.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPatchJobInstanceDetails.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listPatchDeployments', () => { + it('invokes listPatchDeployments without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), + ]; + client.innerApiCalls.listPatchDeployments = stubSimpleCall(expectedResponse); + const [response] = await client.listPatchDeployments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPatchDeployments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPatchDeployments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPatchDeployments without error using callback', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), + ]; + client.innerApiCalls.listPatchDeployments = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPatchDeployments( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchDeployment[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPatchDeployments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPatchDeployments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPatchDeployments with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPatchDeployments = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listPatchDeployments(request), expectedError); + const actualRequest = (client.innerApiCalls.listPatchDeployments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPatchDeployments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPatchDeploymentsStream without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), + ]; + client.descriptors.page.listPatchDeployments.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listPatchDeploymentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1beta.PatchDeployment[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1beta.PatchDeployment) => { + 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.listPatchDeployments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPatchDeployments, request)); + assert( + (client.descriptors.page.listPatchDeployments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listPatchDeploymentsStream with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPatchDeployments.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listPatchDeploymentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1beta.PatchDeployment[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1beta.PatchDeployment) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listPatchDeployments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPatchDeployments, request)); + assert( + (client.descriptors.page.listPatchDeployments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPatchDeployments without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), + ]; + client.descriptors.page.listPatchDeployments.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.osconfig.v1beta.IPatchDeployment[] = []; + const iterable = client.listPatchDeploymentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listPatchDeployments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPatchDeployments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPatchDeployments with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPatchDeployments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listPatchDeploymentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.osconfig.v1beta.IPatchDeployment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listPatchDeployments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPatchDeployments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listGuestPolicies', () => { + it('invokes listGuestPolicies without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), + ]; + client.innerApiCalls.listGuestPolicies = stubSimpleCall(expectedResponse); + const [response] = await client.listGuestPolicies(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listGuestPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listGuestPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listGuestPolicies without error using callback', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), + ]; + client.innerApiCalls.listGuestPolicies = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listGuestPolicies( + request, + (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IGuestPolicy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listGuestPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listGuestPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listGuestPolicies with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listGuestPolicies = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listGuestPolicies(request), expectedError); + const actualRequest = (client.innerApiCalls.listGuestPolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listGuestPolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listGuestPoliciesStream without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), + ]; + client.descriptors.page.listGuestPolicies.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listGuestPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1beta.GuestPolicy[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1beta.GuestPolicy) => { + 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.listGuestPolicies.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listGuestPolicies, request)); + assert( + (client.descriptors.page.listGuestPolicies.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listGuestPoliciesStream with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listGuestPolicies.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listGuestPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.osconfig.v1beta.GuestPolicy[] = []; + stream.on('data', (response: protos.google.cloud.osconfig.v1beta.GuestPolicy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listGuestPolicies.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listGuestPolicies, request)); + assert( + (client.descriptors.page.listGuestPolicies.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listGuestPolicies without error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), + generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), + ]; + client.descriptors.page.listGuestPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.osconfig.v1beta.IGuestPolicy[] = []; + const iterable = client.listGuestPoliciesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listGuestPolicies.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listGuestPolicies.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listGuestPolicies with error', async () => { + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listGuestPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listGuestPoliciesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.osconfig.v1beta.IGuestPolicy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listGuestPolicies.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listGuestPolicies.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('guestPolicy', () => { + const fakePath = "/rendered/path/guestPolicy"; + const expectedParameters = { + project: "projectValue", + guest_policy: "guestPolicyValue", + }; + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.guestPolicyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.guestPolicyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('guestPolicyPath', () => { + const result = client.guestPolicyPath("projectValue", "guestPolicyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.guestPolicyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromGuestPolicyName', () => { + const result = client.matchProjectFromGuestPolicyName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.guestPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchGuestPolicyFromGuestPolicyName', () => { + const result = client.matchGuestPolicyFromGuestPolicyName(fakePath); + assert.strictEqual(result, "guestPolicyValue"); + assert((client.pathTemplates.guestPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('patchDeployment', () => { + const fakePath = "/rendered/path/patchDeployment"; + const expectedParameters = { + project: "projectValue", + patch_deployment: "patchDeploymentValue", + }; + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.patchDeploymentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.patchDeploymentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('patchDeploymentPath', () => { + const result = client.patchDeploymentPath("projectValue", "patchDeploymentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.patchDeploymentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromPatchDeploymentName', () => { + const result = client.matchProjectFromPatchDeploymentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.patchDeploymentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchPatchDeploymentFromPatchDeploymentName', () => { + const result = client.matchPatchDeploymentFromPatchDeploymentName(fakePath); + assert.strictEqual(result, "patchDeploymentValue"); + assert((client.pathTemplates.patchDeploymentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('patchJob', () => { + const fakePath = "/rendered/path/patchJob"; + const expectedParameters = { + project: "projectValue", + patch_job: "patchJobValue", + }; + const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.patchJobPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.patchJobPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('patchJobPath', () => { + const result = client.patchJobPath("projectValue", "patchJobValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.patchJobPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromPatchJobName', () => { + const result = client.matchProjectFromPatchJobName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.patchJobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchPatchJobFromPatchJobName', () => { + const result = client.matchPatchJobFromPatchJobName(fakePath); + assert.strictEqual(result, "patchJobValue"); + assert((client.pathTemplates.patchJobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/tsconfig.json b/owl-bot-staging/google-cloud-osconfig/v1beta/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/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-osconfig/v1beta/webpack.config.js b/owl-bot-staging/google-cloud-osconfig/v1beta/webpack.config.js new file mode 100644 index 00000000000..def8ac29a1c --- /dev/null +++ b/owl-bot-staging/google-cloud-osconfig/v1beta/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: 'OsConfigService', + filename: './os-config-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-oslogin/v1/.eslintignore b/owl-bot-staging/google-cloud-oslogin/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-oslogin/v1/.eslintrc.json b/owl-bot-staging/google-cloud-oslogin/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-oslogin/v1/.gitignore b/owl-bot-staging/google-cloud-oslogin/v1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-oslogin/v1/.jsdoc.js b/owl-bot-staging/google-cloud-oslogin/v1/.jsdoc.js new file mode 100644 index 00000000000..f945dc1e9e4 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/.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/os-login', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-oslogin/v1/.mocharc.js b/owl-bot-staging/google-cloud-oslogin/v1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/.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-oslogin/v1/.prettierrc.js b/owl-bot-staging/google-cloud-oslogin/v1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/.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-oslogin/v1/README.md b/owl-bot-staging/google-cloud-oslogin/v1/README.md new file mode 100644 index 00000000000..f7acdc89a3a --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/README.md @@ -0,0 +1 @@ +Oslogin: Nodejs Client diff --git a/owl-bot-staging/google-cloud-oslogin/v1/package.json b/owl-bot-staging/google-cloud-oslogin/v1/package.json new file mode 100644 index 00000000000..7dc97d13da3 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/os-login", + "version": "0.1.0", + "description": "Oslogin client for Node.js", + "repository": "googleapis/nodejs-oslogin", + "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 oslogin", + "oslogin", + "os login service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-oslogin/v1/protos/google/cloud/oslogin/common/common.proto b/owl-bot-staging/google-cloud-oslogin/v1/protos/google/cloud/oslogin/common/common.proto new file mode 100644 index 00000000000..c0a15cc71fd --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/protos/google/cloud/oslogin/common/common.proto @@ -0,0 +1,108 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.oslogin.common; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option csharp_namespace = "Google.Cloud.OsLogin.Common"; +option go_package = "cloud.google.com/go/oslogin/common/commonpb;commonpb"; +option java_outer_classname = "OsLoginProto"; +option java_package = "com.google.cloud.oslogin.common"; +option php_namespace = "Google\\Cloud\\OsLogin\\Common"; +option ruby_package = "Google::Cloud::OsLogin::Common"; +option (google.api.resource_definition) = { + type: "oslogin.googleapis.com/User" + pattern: "users/{user}" +}; + +// The operating system options for account entries. +enum OperatingSystemType { + // The operating system type associated with the user account information is + // unspecified. + OPERATING_SYSTEM_TYPE_UNSPECIFIED = 0; + + // Linux user account information. + LINUX = 1; + + // Windows user account information. + WINDOWS = 2; +} + +// The POSIX account information associated with a Google account. +message PosixAccount { + option (google.api.resource) = { + type: "oslogin.googleapis.com/PosixAccount" + pattern: "users/{user}/projects/{project}" + }; + + // Only one POSIX account can be marked as primary. + bool primary = 1; + + // The username of the POSIX account. + string username = 2; + + // The user ID. + int64 uid = 3; + + // The default group ID. + int64 gid = 4; + + // The path to the home directory for this account. + string home_directory = 5; + + // The path to the logic shell for this account. + string shell = 6; + + // The GECOS (user information) entry for this account. + string gecos = 7; + + // System identifier for which account the username or uid applies to. + // By default, the empty value is used. + string system_id = 8; + + // Output only. A POSIX account identifier. + string account_id = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The operating system type where this account applies. + OperatingSystemType operating_system_type = 10; + + // Output only. The canonical resource name. + string name = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The SSH public key information associated with a Google account. +message SshPublicKey { + option (google.api.resource) = { + type: "oslogin.googleapis.com/SshPublicKey" + pattern: "users/{user}/sshPublicKeys/{fingerprint}" + }; + + // Public key text in SSH format, defined by + // RFC4253 + // section 6.6. + string key = 1; + + // An expiration time in microseconds since epoch. + int64 expiration_time_usec = 2; + + // Output only. The SHA-256 fingerprint of the SSH public key. + string fingerprint = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The canonical resource name. + string name = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-oslogin/v1/protos/google/cloud/oslogin/v1/oslogin.proto b/owl-bot-staging/google-cloud-oslogin/v1/protos/google/cloud/oslogin/v1/oslogin.proto new file mode 100644 index 00000000000..ca890654b62 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/protos/google/cloud/oslogin/v1/oslogin.proto @@ -0,0 +1,248 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.oslogin.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/oslogin/common/common.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.OsLogin.V1"; +option go_package = "cloud.google.com/go/oslogin/apiv1/osloginpb;osloginpb"; +option java_multiple_files = true; +option java_outer_classname = "OsLoginProto"; +option java_package = "com.google.cloud.oslogin.v1"; +option php_namespace = "Google\\Cloud\\OsLogin\\V1"; +option ruby_package = "Google::Cloud::OsLogin::V1"; + +// Cloud OS Login API +// +// The Cloud OS Login API allows you to manage users and their associated SSH +// public keys for logging into virtual machines on Google Cloud Platform. +service OsLoginService { + option (google.api.default_host) = "oslogin.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-platform.read-only," + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/compute.readonly"; + + // Create an SSH public key + rpc CreateSshPublicKey(CreateSshPublicKeyRequest) + returns (google.cloud.oslogin.common.SshPublicKey) { + option (google.api.http) = { + post: "/v1/{parent=users/*}/sshPublicKeys" + body: "ssh_public_key" + }; + option (google.api.method_signature) = "parent,ssh_public_key"; + } + + // Deletes a POSIX account. + rpc DeletePosixAccount(DeletePosixAccountRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=users/*/projects/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Deletes an SSH public key. + rpc DeleteSshPublicKey(DeleteSshPublicKeyRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=users/*/sshPublicKeys/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Retrieves the profile information used for logging in to a virtual machine + // on Google Compute Engine. + rpc GetLoginProfile(GetLoginProfileRequest) returns (LoginProfile) { + option (google.api.http) = { + get: "/v1/{name=users/*}/loginProfile" + }; + option (google.api.method_signature) = "name"; + } + + // Retrieves an SSH public key. + rpc GetSshPublicKey(GetSshPublicKeyRequest) + returns (google.cloud.oslogin.common.SshPublicKey) { + option (google.api.http) = { + get: "/v1/{name=users/*/sshPublicKeys/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Adds an SSH public key and returns the profile information. Default POSIX + // account information is set when no username and UID exist as part of the + // login profile. + rpc ImportSshPublicKey(ImportSshPublicKeyRequest) + returns (ImportSshPublicKeyResponse) { + option (google.api.http) = { + post: "/v1/{parent=users/*}:importSshPublicKey" + body: "ssh_public_key" + }; + option (google.api.method_signature) = "parent,ssh_public_key"; + option (google.api.method_signature) = "parent,ssh_public_key,project_id"; + } + + // Updates an SSH public key and returns the profile information. This method + // supports patch semantics. + rpc UpdateSshPublicKey(UpdateSshPublicKeyRequest) + returns (google.cloud.oslogin.common.SshPublicKey) { + option (google.api.http) = { + patch: "/v1/{name=users/*/sshPublicKeys/*}" + body: "ssh_public_key" + }; + option (google.api.method_signature) = "name,ssh_public_key"; + option (google.api.method_signature) = "name,ssh_public_key,update_mask"; + } +} + +// The user profile information used for logging in to a virtual machine on +// Google Compute Engine. +message LoginProfile { + // Required. A unique user ID. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // The list of POSIX accounts associated with the user. + repeated google.cloud.oslogin.common.PosixAccount posix_accounts = 2; + + // A map from SSH public key fingerprint to the associated key object. + map ssh_public_keys = 3; +} + +// A request message for creating an SSH public key. +message CreateSshPublicKeyRequest { + // Required. The unique ID for the user in format `users/{user}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "oslogin.googleapis.com/SshPublicKey" + } + ]; + + // Required. The SSH public key and expiration time. + google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// A request message for deleting a POSIX account entry. +message DeletePosixAccountRequest { + // Required. A reference to the POSIX account to update. POSIX accounts are + // identified by the project ID they are associated with. A reference to the + // POSIX account is in format `users/{user}/projects/{project}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "oslogin.googleapis.com/PosixAccount" + } + ]; +} + +// A request message for deleting an SSH public key. +message DeleteSshPublicKeyRequest { + // Required. The fingerprint of the public key to update. Public keys are + // identified by their SHA-256 fingerprint. The fingerprint of the public key + // is in format `users/{user}/sshPublicKeys/{fingerprint}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "oslogin.googleapis.com/SshPublicKey" + } + ]; +} + +// A request message for retrieving the login profile information for a user. +message GetLoginProfileRequest { + // Required. The unique ID for the user in format `users/{user}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "oslogin.googleapis.com/PosixAccount" + } + ]; + + // The project ID of the Google Cloud Platform project. + string project_id = 2; + + // A system ID for filtering the results of the request. + string system_id = 3; +} + +// A request message for retrieving an SSH public key. +message GetSshPublicKeyRequest { + // Required. The fingerprint of the public key to retrieve. Public keys are + // identified by their SHA-256 fingerprint. The fingerprint of the public key + // is in format `users/{user}/sshPublicKeys/{fingerprint}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "oslogin.googleapis.com/SshPublicKey" + } + ]; +} + +// A request message for importing an SSH public key. +message ImportSshPublicKeyRequest { + // Required. The unique ID for the user in format `users/{user}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "oslogin.googleapis.com/SshPublicKey" + } + ]; + + // Optional. The SSH public key and expiration time. + google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 + [(google.api.field_behavior) = OPTIONAL]; + + // The project ID of the Google Cloud Platform project. + string project_id = 3; +} + +// A response message for importing an SSH public key. +message ImportSshPublicKeyResponse { + // The login profile information for the user. + LoginProfile login_profile = 1; + + // Detailed information about import results. + string details = 2; +} + +// A request message for updating an SSH public key. +message UpdateSshPublicKeyRequest { + // Required. The fingerprint of the public key to update. Public keys are + // identified by their SHA-256 fingerprint. The fingerprint of the public key + // is in format `users/{user}/sshPublicKeys/{fingerprint}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "oslogin.googleapis.com/SshPublicKey" + } + ]; + + // Required. The SSH public key and expiration time. + google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Mask to control which fields get updated. Updates all if not present. + google.protobuf.FieldMask update_mask = 3; +} diff --git a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.create_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.create_ssh_public_key.js new file mode 100644 index 00000000000..cbf878d6847 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.create_ssh_public_key.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(parent, sshPublicKey) { + // [START oslogin_v1_generated_OsLoginService_CreateSshPublicKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The unique ID for the user in format `users/{user}`. + */ + // const parent = 'abc123' + /** + * Required. The SSH public key and expiration time. + */ + // const sshPublicKey = {} + + // Imports the Oslogin library + const {OsLoginServiceClient} = require('@google-cloud/os-login').v1; + + // Instantiates a client + const osloginClient = new OsLoginServiceClient(); + + async function callCreateSshPublicKey() { + // Construct request + const request = { + parent, + sshPublicKey, + }; + + // Run request + const response = await osloginClient.createSshPublicKey(request); + console.log(response); + } + + callCreateSshPublicKey(); + // [END oslogin_v1_generated_OsLoginService_CreateSshPublicKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.delete_posix_account.js b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.delete_posix_account.js new file mode 100644 index 00000000000..3464e5836ba --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.delete_posix_account.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 oslogin_v1_generated_OsLoginService_DeletePosixAccount_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A reference to the POSIX account to update. POSIX accounts are + * identified by the project ID they are associated with. A reference to the + * POSIX account is in format `users/{user}/projects/{project}`. + */ + // const name = 'abc123' + + // Imports the Oslogin library + const {OsLoginServiceClient} = require('@google-cloud/os-login').v1; + + // Instantiates a client + const osloginClient = new OsLoginServiceClient(); + + async function callDeletePosixAccount() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osloginClient.deletePosixAccount(request); + console.log(response); + } + + callDeletePosixAccount(); + // [END oslogin_v1_generated_OsLoginService_DeletePosixAccount_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.delete_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.delete_ssh_public_key.js new file mode 100644 index 00000000000..82cf1a60119 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.delete_ssh_public_key.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 oslogin_v1_generated_OsLoginService_DeleteSshPublicKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + */ + // const name = 'abc123' + + // Imports the Oslogin library + const {OsLoginServiceClient} = require('@google-cloud/os-login').v1; + + // Instantiates a client + const osloginClient = new OsLoginServiceClient(); + + async function callDeleteSshPublicKey() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osloginClient.deleteSshPublicKey(request); + console.log(response); + } + + callDeleteSshPublicKey(); + // [END oslogin_v1_generated_OsLoginService_DeleteSshPublicKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.get_login_profile.js b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.get_login_profile.js new file mode 100644 index 00000000000..8f2ed7bcf29 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.get_login_profile.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(name) { + // [START oslogin_v1_generated_OsLoginService_GetLoginProfile_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The unique ID for the user in format `users/{user}`. + */ + // const name = 'abc123' + /** + * The project ID of the Google Cloud Platform project. + */ + // const projectId = 'abc123' + /** + * A system ID for filtering the results of the request. + */ + // const systemId = 'abc123' + + // Imports the Oslogin library + const {OsLoginServiceClient} = require('@google-cloud/os-login').v1; + + // Instantiates a client + const osloginClient = new OsLoginServiceClient(); + + async function callGetLoginProfile() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osloginClient.getLoginProfile(request); + console.log(response); + } + + callGetLoginProfile(); + // [END oslogin_v1_generated_OsLoginService_GetLoginProfile_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.get_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.get_ssh_public_key.js new file mode 100644 index 00000000000..6654b51e38d --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.get_ssh_public_key.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 oslogin_v1_generated_OsLoginService_GetSshPublicKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The fingerprint of the public key to retrieve. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + */ + // const name = 'abc123' + + // Imports the Oslogin library + const {OsLoginServiceClient} = require('@google-cloud/os-login').v1; + + // Instantiates a client + const osloginClient = new OsLoginServiceClient(); + + async function callGetSshPublicKey() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osloginClient.getSshPublicKey(request); + console.log(response); + } + + callGetSshPublicKey(); + // [END oslogin_v1_generated_OsLoginService_GetSshPublicKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.import_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.import_ssh_public_key.js new file mode 100644 index 00000000000..877e770826c --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.import_ssh_public_key.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(parent) { + // [START oslogin_v1_generated_OsLoginService_ImportSshPublicKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The unique ID for the user in format `users/{user}`. + */ + // const parent = 'abc123' + /** + * Optional. The SSH public key and expiration time. + */ + // const sshPublicKey = {} + /** + * The project ID of the Google Cloud Platform project. + */ + // const projectId = 'abc123' + + // Imports the Oslogin library + const {OsLoginServiceClient} = require('@google-cloud/os-login').v1; + + // Instantiates a client + const osloginClient = new OsLoginServiceClient(); + + async function callImportSshPublicKey() { + // Construct request + const request = { + parent, + }; + + // Run request + const response = await osloginClient.importSshPublicKey(request); + console.log(response); + } + + callImportSshPublicKey(); + // [END oslogin_v1_generated_OsLoginService_ImportSshPublicKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.update_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.update_ssh_public_key.js new file mode 100644 index 00000000000..30898bb0441 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.update_ssh_public_key.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(name, sshPublicKey) { + // [START oslogin_v1_generated_OsLoginService_UpdateSshPublicKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + */ + // const name = 'abc123' + /** + * Required. The SSH public key and expiration time. + */ + // const sshPublicKey = {} + /** + * Mask to control which fields get updated. Updates all if not present. + */ + // const updateMask = {} + + // Imports the Oslogin library + const {OsLoginServiceClient} = require('@google-cloud/os-login').v1; + + // Instantiates a client + const osloginClient = new OsLoginServiceClient(); + + async function callUpdateSshPublicKey() { + // Construct request + const request = { + name, + sshPublicKey, + }; + + // Run request + const response = await osloginClient.updateSshPublicKey(request); + console.log(response); + } + + callUpdateSshPublicKey(); + // [END oslogin_v1_generated_OsLoginService_UpdateSshPublicKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/snippet_metadata_google.cloud.oslogin.v1.json b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/snippet_metadata_google.cloud.oslogin.v1.json new file mode 100644 index 00000000000..2c35446f956 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/snippet_metadata_google.cloud.oslogin.v1.json @@ -0,0 +1,323 @@ +{ + "clientLibrary": { + "name": "nodejs-oslogin", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.oslogin.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "oslogin_v1_generated_OsLoginService_CreateSshPublicKey_async", + "title": "OsLoginService createSshPublicKey Sample", + "origin": "API_DEFINITION", + "description": " Create an SSH public key", + "canonical": true, + "file": "os_login_service.create_ssh_public_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateSshPublicKey", + "fullName": "google.cloud.oslogin.v1.OsLoginService.CreateSshPublicKey", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "ssh_public_key", + "type": ".google.cloud.oslogin.common.SshPublicKey" + } + ], + "resultType": ".google.cloud.oslogin.common.SshPublicKey", + "client": { + "shortName": "OsLoginServiceClient", + "fullName": "google.cloud.oslogin.v1.OsLoginServiceClient" + }, + "method": { + "shortName": "CreateSshPublicKey", + "fullName": "google.cloud.oslogin.v1.OsLoginService.CreateSshPublicKey", + "service": { + "shortName": "OsLoginService", + "fullName": "google.cloud.oslogin.v1.OsLoginService" + } + } + } + }, + { + "regionTag": "oslogin_v1_generated_OsLoginService_DeletePosixAccount_async", + "title": "OsLoginService deletePosixAccount Sample", + "origin": "API_DEFINITION", + "description": " Deletes a POSIX account.", + "canonical": true, + "file": "os_login_service.delete_posix_account.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeletePosixAccount", + "fullName": "google.cloud.oslogin.v1.OsLoginService.DeletePosixAccount", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "OsLoginServiceClient", + "fullName": "google.cloud.oslogin.v1.OsLoginServiceClient" + }, + "method": { + "shortName": "DeletePosixAccount", + "fullName": "google.cloud.oslogin.v1.OsLoginService.DeletePosixAccount", + "service": { + "shortName": "OsLoginService", + "fullName": "google.cloud.oslogin.v1.OsLoginService" + } + } + } + }, + { + "regionTag": "oslogin_v1_generated_OsLoginService_DeleteSshPublicKey_async", + "title": "OsLoginService deleteSshPublicKey Sample", + "origin": "API_DEFINITION", + "description": " Deletes an SSH public key.", + "canonical": true, + "file": "os_login_service.delete_ssh_public_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteSshPublicKey", + "fullName": "google.cloud.oslogin.v1.OsLoginService.DeleteSshPublicKey", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "OsLoginServiceClient", + "fullName": "google.cloud.oslogin.v1.OsLoginServiceClient" + }, + "method": { + "shortName": "DeleteSshPublicKey", + "fullName": "google.cloud.oslogin.v1.OsLoginService.DeleteSshPublicKey", + "service": { + "shortName": "OsLoginService", + "fullName": "google.cloud.oslogin.v1.OsLoginService" + } + } + } + }, + { + "regionTag": "oslogin_v1_generated_OsLoginService_GetLoginProfile_async", + "title": "OsLoginService getLoginProfile Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the profile information used for logging in to a virtual machine on Google Compute Engine.", + "canonical": true, + "file": "os_login_service.get_login_profile.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetLoginProfile", + "fullName": "google.cloud.oslogin.v1.OsLoginService.GetLoginProfile", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "system_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.oslogin.v1.LoginProfile", + "client": { + "shortName": "OsLoginServiceClient", + "fullName": "google.cloud.oslogin.v1.OsLoginServiceClient" + }, + "method": { + "shortName": "GetLoginProfile", + "fullName": "google.cloud.oslogin.v1.OsLoginService.GetLoginProfile", + "service": { + "shortName": "OsLoginService", + "fullName": "google.cloud.oslogin.v1.OsLoginService" + } + } + } + }, + { + "regionTag": "oslogin_v1_generated_OsLoginService_GetSshPublicKey_async", + "title": "OsLoginService getSshPublicKey Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an SSH public key.", + "canonical": true, + "file": "os_login_service.get_ssh_public_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetSshPublicKey", + "fullName": "google.cloud.oslogin.v1.OsLoginService.GetSshPublicKey", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.oslogin.common.SshPublicKey", + "client": { + "shortName": "OsLoginServiceClient", + "fullName": "google.cloud.oslogin.v1.OsLoginServiceClient" + }, + "method": { + "shortName": "GetSshPublicKey", + "fullName": "google.cloud.oslogin.v1.OsLoginService.GetSshPublicKey", + "service": { + "shortName": "OsLoginService", + "fullName": "google.cloud.oslogin.v1.OsLoginService" + } + } + } + }, + { + "regionTag": "oslogin_v1_generated_OsLoginService_ImportSshPublicKey_async", + "title": "OsLoginService importSshPublicKey Sample", + "origin": "API_DEFINITION", + "description": " Adds an SSH public key and returns the profile information. Default POSIX account information is set when no username and UID exist as part of the login profile.", + "canonical": true, + "file": "os_login_service.import_ssh_public_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportSshPublicKey", + "fullName": "google.cloud.oslogin.v1.OsLoginService.ImportSshPublicKey", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "ssh_public_key", + "type": ".google.cloud.oslogin.common.SshPublicKey" + }, + { + "name": "project_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.oslogin.v1.ImportSshPublicKeyResponse", + "client": { + "shortName": "OsLoginServiceClient", + "fullName": "google.cloud.oslogin.v1.OsLoginServiceClient" + }, + "method": { + "shortName": "ImportSshPublicKey", + "fullName": "google.cloud.oslogin.v1.OsLoginService.ImportSshPublicKey", + "service": { + "shortName": "OsLoginService", + "fullName": "google.cloud.oslogin.v1.OsLoginService" + } + } + } + }, + { + "regionTag": "oslogin_v1_generated_OsLoginService_UpdateSshPublicKey_async", + "title": "OsLoginService updateSshPublicKey Sample", + "origin": "API_DEFINITION", + "description": " Updates an SSH public key and returns the profile information. This method supports patch semantics.", + "canonical": true, + "file": "os_login_service.update_ssh_public_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateSshPublicKey", + "fullName": "google.cloud.oslogin.v1.OsLoginService.UpdateSshPublicKey", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "ssh_public_key", + "type": ".google.cloud.oslogin.common.SshPublicKey" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.oslogin.common.SshPublicKey", + "client": { + "shortName": "OsLoginServiceClient", + "fullName": "google.cloud.oslogin.v1.OsLoginServiceClient" + }, + "method": { + "shortName": "UpdateSshPublicKey", + "fullName": "google.cloud.oslogin.v1.OsLoginService.UpdateSshPublicKey", + "service": { + "shortName": "OsLoginService", + "fullName": "google.cloud.oslogin.v1.OsLoginService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-oslogin/v1/src/index.ts b/owl-bot-staging/google-cloud-oslogin/v1/src/index.ts new file mode 100644 index 00000000000..85e467c85f4 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const OsLoginServiceClient = v1.OsLoginServiceClient; +type OsLoginServiceClient = v1.OsLoginServiceClient; +export {v1, OsLoginServiceClient}; +export default {v1, OsLoginServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-oslogin/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-oslogin/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..fc08cf26063 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/src/v1/gapic_metadata.json @@ -0,0 +1,93 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.oslogin.v1", + "libraryPackage": "@google-cloud/os-login", + "services": { + "OsLoginService": { + "clients": { + "grpc": { + "libraryClient": "OsLoginServiceClient", + "rpcs": { + "CreateSshPublicKey": { + "methods": [ + "createSshPublicKey" + ] + }, + "DeletePosixAccount": { + "methods": [ + "deletePosixAccount" + ] + }, + "DeleteSshPublicKey": { + "methods": [ + "deleteSshPublicKey" + ] + }, + "GetLoginProfile": { + "methods": [ + "getLoginProfile" + ] + }, + "GetSshPublicKey": { + "methods": [ + "getSshPublicKey" + ] + }, + "ImportSshPublicKey": { + "methods": [ + "importSshPublicKey" + ] + }, + "UpdateSshPublicKey": { + "methods": [ + "updateSshPublicKey" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "OsLoginServiceClient", + "rpcs": { + "CreateSshPublicKey": { + "methods": [ + "createSshPublicKey" + ] + }, + "DeletePosixAccount": { + "methods": [ + "deletePosixAccount" + ] + }, + "DeleteSshPublicKey": { + "methods": [ + "deleteSshPublicKey" + ] + }, + "GetLoginProfile": { + "methods": [ + "getLoginProfile" + ] + }, + "GetSshPublicKey": { + "methods": [ + "getSshPublicKey" + ] + }, + "ImportSshPublicKey": { + "methods": [ + "importSshPublicKey" + ] + }, + "UpdateSshPublicKey": { + "methods": [ + "updateSshPublicKey" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-oslogin/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-oslogin/v1/src/v1/index.ts new file mode 100644 index 00000000000..477969ae393 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {OsLoginServiceClient} from './os_login_service_client'; diff --git a/owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_client.ts b/owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_client.ts new file mode 100644 index 00000000000..316a8263a1c --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_client.ts @@ -0,0 +1,942 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/os_login_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './os_login_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Cloud OS Login API + * + * The Cloud OS Login API allows you to manage users and their associated SSH + * public keys for logging into virtual machines on Google Cloud Platform. + * @class + * @memberof v1 + */ +export class OsLoginServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + osLoginServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of OsLoginServiceClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 OsLoginServiceClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof OsLoginServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + posixAccountPathTemplate: new this._gaxModule.PathTemplate( + 'users/{user}/projects/{project}' + ), + sshPublicKeyPathTemplate: new this._gaxModule.PathTemplate( + 'users/{user}/sshPublicKeys/{fingerprint}' + ), + userPathTemplate: new this._gaxModule.PathTemplate( + 'users/{user}' + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.oslogin.v1.OsLoginService', 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.osLoginServiceStub) { + return this.osLoginServiceStub; + } + + // Put together the "service stub" for + // google.cloud.oslogin.v1.OsLoginService. + this.osLoginServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.oslogin.v1.OsLoginService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.oslogin.v1.OsLoginService, + 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 osLoginServiceStubMethods = + ['createSshPublicKey', 'deletePosixAccount', 'deleteSshPublicKey', 'getLoginProfile', 'getSshPublicKey', 'importSshPublicKey', 'updateSshPublicKey']; + for (const methodName of osLoginServiceStubMethods) { + const callPromise = this.osLoginServiceStub.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.osLoginServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'oslogin.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 'oslogin.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/compute.readonly' + ]; + } + + 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 -- + // ------------------- +/** + * Create an SSH public key + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique ID for the user in format `users/{user}`. + * @param {google.cloud.oslogin.common.SshPublicKey} request.sshPublicKey + * Required. The SSH public key and expiration time. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.oslogin.common.SshPublicKey|SshPublicKey}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_login_service.create_ssh_public_key.js + * region_tag:oslogin_v1_generated_OsLoginService_CreateSshPublicKey_async + */ + createSshPublicKey( + request?: protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest|undefined, {}|undefined + ]>; + createSshPublicKey( + request: protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + createSshPublicKey( + request: protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + createSshPublicKey( + request?: protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createSshPublicKey(request, options, callback); + } +/** + * Deletes a POSIX account. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A reference to the POSIX account to update. POSIX accounts are + * identified by the project ID they are associated with. A reference to the + * POSIX account is in format `users/{user}/projects/{project}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_login_service.delete_posix_account.js + * region_tag:oslogin_v1_generated_OsLoginService_DeletePosixAccount_async + */ + deletePosixAccount( + request?: protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest|undefined, {}|undefined + ]>; + deletePosixAccount( + request: protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest|null|undefined, + {}|null|undefined>): void; + deletePosixAccount( + request: protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest|null|undefined, + {}|null|undefined>): void; + deletePosixAccount( + request?: protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deletePosixAccount(request, options, callback); + } +/** + * Deletes an SSH public key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_login_service.delete_ssh_public_key.js + * region_tag:oslogin_v1_generated_OsLoginService_DeleteSshPublicKey_async + */ + deleteSshPublicKey( + request?: protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest|undefined, {}|undefined + ]>; + deleteSshPublicKey( + request: protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + deleteSshPublicKey( + request: protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + deleteSshPublicKey( + request?: protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteSshPublicKey(request, options, callback); + } +/** + * Retrieves the profile information used for logging in to a virtual machine + * on Google Compute Engine. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The unique ID for the user in format `users/{user}`. + * @param {string} request.projectId + * The project ID of the Google Cloud Platform project. + * @param {string} request.systemId + * A system ID for filtering the results of the request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.oslogin.v1.LoginProfile|LoginProfile}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_login_service.get_login_profile.js + * region_tag:oslogin_v1_generated_OsLoginService_GetLoginProfile_async + */ + getLoginProfile( + request?: protos.google.cloud.oslogin.v1.IGetLoginProfileRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.oslogin.v1.ILoginProfile, + protos.google.cloud.oslogin.v1.IGetLoginProfileRequest|undefined, {}|undefined + ]>; + getLoginProfile( + request: protos.google.cloud.oslogin.v1.IGetLoginProfileRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oslogin.v1.ILoginProfile, + protos.google.cloud.oslogin.v1.IGetLoginProfileRequest|null|undefined, + {}|null|undefined>): void; + getLoginProfile( + request: protos.google.cloud.oslogin.v1.IGetLoginProfileRequest, + callback: Callback< + protos.google.cloud.oslogin.v1.ILoginProfile, + protos.google.cloud.oslogin.v1.IGetLoginProfileRequest|null|undefined, + {}|null|undefined>): void; + getLoginProfile( + request?: protos.google.cloud.oslogin.v1.IGetLoginProfileRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.oslogin.v1.ILoginProfile, + protos.google.cloud.oslogin.v1.IGetLoginProfileRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.oslogin.v1.ILoginProfile, + protos.google.cloud.oslogin.v1.IGetLoginProfileRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.oslogin.v1.ILoginProfile, + protos.google.cloud.oslogin.v1.IGetLoginProfileRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getLoginProfile(request, options, callback); + } +/** + * Retrieves an SSH public key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The fingerprint of the public key to retrieve. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.oslogin.common.SshPublicKey|SshPublicKey}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_login_service.get_ssh_public_key.js + * region_tag:oslogin_v1_generated_OsLoginService_GetSshPublicKey_async + */ + getSshPublicKey( + request?: protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest|undefined, {}|undefined + ]>; + getSshPublicKey( + request: protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + getSshPublicKey( + request: protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + getSshPublicKey( + request?: protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getSshPublicKey(request, options, callback); + } +/** + * Adds an SSH public key and returns the profile information. Default POSIX + * account information is set when no username and UID exist as part of the + * login profile. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique ID for the user in format `users/{user}`. + * @param {google.cloud.oslogin.common.SshPublicKey} [request.sshPublicKey] + * Optional. The SSH public key and expiration time. + * @param {string} request.projectId + * The project ID of the Google Cloud Platform project. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.oslogin.v1.ImportSshPublicKeyResponse|ImportSshPublicKeyResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_login_service.import_ssh_public_key.js + * region_tag:oslogin_v1_generated_OsLoginService_ImportSshPublicKey_async + */ + importSshPublicKey( + request?: protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest|undefined, {}|undefined + ]>; + importSshPublicKey( + request: protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + importSshPublicKey( + request: protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest, + callback: Callback< + protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + importSshPublicKey( + request?: protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.importSshPublicKey(request, options, callback); + } +/** + * Updates an SSH public key and returns the profile information. This method + * supports patch semantics. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * @param {google.cloud.oslogin.common.SshPublicKey} request.sshPublicKey + * Required. The SSH public key and expiration time. + * @param {google.protobuf.FieldMask} request.updateMask + * Mask to control which fields get updated. Updates all if not present. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.oslogin.common.SshPublicKey|SshPublicKey}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/os_login_service.update_ssh_public_key.js + * region_tag:oslogin_v1_generated_OsLoginService_UpdateSshPublicKey_async + */ + updateSshPublicKey( + request?: protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest|undefined, {}|undefined + ]>; + updateSshPublicKey( + request: protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + updateSshPublicKey( + request: protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + updateSshPublicKey( + request?: protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateSshPublicKey(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified posixAccount resource name string. + * + * @param {string} user + * @param {string} project + * @returns {string} Resource name string. + */ + posixAccountPath(user:string,project:string) { + return this.pathTemplates.posixAccountPathTemplate.render({ + user: user, + project: project, + }); + } + + /** + * Parse the user from PosixAccount resource. + * + * @param {string} posixAccountName + * A fully-qualified path representing PosixAccount resource. + * @returns {string} A string representing the user. + */ + matchUserFromPosixAccountName(posixAccountName: string) { + return this.pathTemplates.posixAccountPathTemplate.match(posixAccountName).user; + } + + /** + * Parse the project from PosixAccount resource. + * + * @param {string} posixAccountName + * A fully-qualified path representing PosixAccount resource. + * @returns {string} A string representing the project. + */ + matchProjectFromPosixAccountName(posixAccountName: string) { + return this.pathTemplates.posixAccountPathTemplate.match(posixAccountName).project; + } + + /** + * Return a fully-qualified sshPublicKey resource name string. + * + * @param {string} user + * @param {string} fingerprint + * @returns {string} Resource name string. + */ + sshPublicKeyPath(user:string,fingerprint:string) { + return this.pathTemplates.sshPublicKeyPathTemplate.render({ + user: user, + fingerprint: fingerprint, + }); + } + + /** + * Parse the user from SshPublicKey resource. + * + * @param {string} sshPublicKeyName + * A fully-qualified path representing SshPublicKey resource. + * @returns {string} A string representing the user. + */ + matchUserFromSshPublicKeyName(sshPublicKeyName: string) { + return this.pathTemplates.sshPublicKeyPathTemplate.match(sshPublicKeyName).user; + } + + /** + * Parse the fingerprint from SshPublicKey resource. + * + * @param {string} sshPublicKeyName + * A fully-qualified path representing SshPublicKey resource. + * @returns {string} A string representing the fingerprint. + */ + matchFingerprintFromSshPublicKeyName(sshPublicKeyName: string) { + return this.pathTemplates.sshPublicKeyPathTemplate.match(sshPublicKeyName).fingerprint; + } + + /** + * Return a fully-qualified user resource name string. + * + * @param {string} user + * @returns {string} Resource name string. + */ + userPath(user:string) { + return this.pathTemplates.userPathTemplate.render({ + user: user, + }); + } + + /** + * Parse the user from User resource. + * + * @param {string} userName + * A fully-qualified path representing User resource. + * @returns {string} A string representing the user. + */ + matchUserFromUserName(userName: string) { + return this.pathTemplates.userPathTemplate.match(userName).user; + } + + /** + * 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.osLoginServiceStub && !this._terminated) { + return this.osLoginServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_client_config.json b/owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_client_config.json new file mode 100644 index 00000000000..afdd4ec0a35 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_client_config.json @@ -0,0 +1,60 @@ +{ + "interfaces": { + "google.cloud.oslogin.v1.OsLoginService": { + "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": { + "CreateSshPublicKey": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeletePosixAccount": { + "timeout_millis": 10000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteSshPublicKey": { + "timeout_millis": 10000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetLoginProfile": { + "timeout_millis": 10000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetSshPublicKey": { + "timeout_millis": 10000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ImportSshPublicKey": { + "timeout_millis": 10000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateSshPublicKey": { + "timeout_millis": 10000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_proto_list.json b/owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_proto_list.json new file mode 100644 index 00000000000..46f125ed586 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_proto_list.json @@ -0,0 +1,4 @@ +[ + "../../protos/google/cloud/oslogin/common/common.proto", + "../../protos/google/cloud/oslogin/v1/oslogin.proto" +] diff --git a/owl-bot-staging/google-cloud-oslogin/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-oslogin/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..de1b9afaf4f --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const oslogin = require('@google-cloud/os-login'); + +function main() { + const osLoginServiceClient = new oslogin.OsLoginServiceClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-oslogin/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-oslogin/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..ab3709b1bb9 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {OsLoginServiceClient} from '@google-cloud/os-login'; + +// check that the client class type name can be used +function doStuffWithOsLoginServiceClient(client: OsLoginServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const osLoginServiceClient = new OsLoginServiceClient(); + doStuffWithOsLoginServiceClient(osLoginServiceClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-oslogin/v1/system-test/install.ts b/owl-bot-staging/google-cloud-oslogin/v1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/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-oslogin/v1/test/gapic_os_login_service_v1.ts b/owl-bot-staging/google-cloud-oslogin/v1/test/gapic_os_login_service_v1.ts new file mode 100644 index 00000000000..4ddd4c6d480 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/test/gapic_os_login_service_v1.ts @@ -0,0 +1,1015 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 osloginserviceModule from '../src'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +describe('v1.OsLoginServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = osloginserviceModule.v1.OsLoginServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = osloginserviceModule.v1.OsLoginServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = osloginserviceModule.v1.OsLoginServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.osLoginServiceStub, undefined); + await client.initialize(); + assert(client.osLoginServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.osLoginServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.osLoginServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + 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 osloginserviceModule.v1.OsLoginServiceClient({ + 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('createSshPublicKey', () => { + it('invokes createSshPublicKey without error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.CreateSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.CreateSshPublicKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.common.SshPublicKey() + ); + client.innerApiCalls.createSshPublicKey = stubSimpleCall(expectedResponse); + const [response] = await client.createSshPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSshPublicKey without error using callback', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.CreateSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.CreateSshPublicKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.common.SshPublicKey() + ); + client.innerApiCalls.createSshPublicKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createSshPublicKey( + request, + (err?: Error|null, result?: protos.google.cloud.oslogin.common.ISshPublicKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSshPublicKey with error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.CreateSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.CreateSshPublicKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSshPublicKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createSshPublicKey(request), expectedError); + const actualRequest = (client.innerApiCalls.createSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSshPublicKey with closed client', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.CreateSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.CreateSshPublicKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createSshPublicKey(request), expectedError); + }); + }); + + describe('deletePosixAccount', () => { + it('invokes deletePosixAccount without error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.DeletePosixAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.DeletePosixAccountRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deletePosixAccount = stubSimpleCall(expectedResponse); + const [response] = await client.deletePosixAccount(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deletePosixAccount as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePosixAccount as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePosixAccount without error using callback', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.DeletePosixAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.DeletePosixAccountRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deletePosixAccount = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deletePosixAccount( + 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.deletePosixAccount as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePosixAccount as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePosixAccount with error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.DeletePosixAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.DeletePosixAccountRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePosixAccount = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deletePosixAccount(request), expectedError); + const actualRequest = (client.innerApiCalls.deletePosixAccount as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePosixAccount as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePosixAccount with closed client', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.DeletePosixAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.DeletePosixAccountRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deletePosixAccount(request), expectedError); + }); + }); + + describe('deleteSshPublicKey', () => { + it('invokes deleteSshPublicKey without error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteSshPublicKey = stubSimpleCall(expectedResponse); + const [response] = await client.deleteSshPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSshPublicKey without error using callback', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteSshPublicKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteSshPublicKey( + 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.deleteSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSshPublicKey with error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSshPublicKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteSshPublicKey(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSshPublicKey with closed client', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteSshPublicKey(request), expectedError); + }); + }); + + describe('getLoginProfile', () => { + it('invokes getLoginProfile without error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.GetLoginProfileRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.GetLoginProfileRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.v1.LoginProfile() + ); + client.innerApiCalls.getLoginProfile = stubSimpleCall(expectedResponse); + const [response] = await client.getLoginProfile(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getLoginProfile as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getLoginProfile as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getLoginProfile without error using callback', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.GetLoginProfileRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.GetLoginProfileRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.v1.LoginProfile() + ); + client.innerApiCalls.getLoginProfile = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLoginProfile( + request, + (err?: Error|null, result?: protos.google.cloud.oslogin.v1.ILoginProfile|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getLoginProfile as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getLoginProfile as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getLoginProfile with error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.GetLoginProfileRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.GetLoginProfileRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getLoginProfile = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLoginProfile(request), expectedError); + const actualRequest = (client.innerApiCalls.getLoginProfile as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getLoginProfile as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getLoginProfile with closed client', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.GetLoginProfileRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.GetLoginProfileRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getLoginProfile(request), expectedError); + }); + }); + + describe('getSshPublicKey', () => { + it('invokes getSshPublicKey without error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.GetSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.GetSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.common.SshPublicKey() + ); + client.innerApiCalls.getSshPublicKey = stubSimpleCall(expectedResponse); + const [response] = await client.getSshPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSshPublicKey without error using callback', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.GetSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.GetSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.common.SshPublicKey() + ); + client.innerApiCalls.getSshPublicKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSshPublicKey( + request, + (err?: Error|null, result?: protos.google.cloud.oslogin.common.ISshPublicKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSshPublicKey with error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.GetSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.GetSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getSshPublicKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getSshPublicKey(request), expectedError); + const actualRequest = (client.innerApiCalls.getSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSshPublicKey with closed client', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.GetSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.GetSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getSshPublicKey(request), expectedError); + }); + }); + + describe('importSshPublicKey', () => { + it('invokes importSshPublicKey without error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.ImportSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.ImportSshPublicKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.v1.ImportSshPublicKeyResponse() + ); + client.innerApiCalls.importSshPublicKey = stubSimpleCall(expectedResponse); + const [response] = await client.importSshPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.importSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importSshPublicKey without error using callback', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.ImportSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.ImportSshPublicKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.v1.ImportSshPublicKeyResponse() + ); + client.innerApiCalls.importSshPublicKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importSshPublicKey( + request, + (err?: Error|null, result?: protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.importSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importSshPublicKey with error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.ImportSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.ImportSshPublicKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importSshPublicKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.importSshPublicKey(request), expectedError); + const actualRequest = (client.innerApiCalls.importSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importSshPublicKey with closed client', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.ImportSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.ImportSshPublicKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.importSshPublicKey(request), expectedError); + }); + }); + + describe('updateSshPublicKey', () => { + it('invokes updateSshPublicKey without error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.common.SshPublicKey() + ); + client.innerApiCalls.updateSshPublicKey = stubSimpleCall(expectedResponse); + const [response] = await client.updateSshPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateSshPublicKey without error using callback', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.common.SshPublicKey() + ); + client.innerApiCalls.updateSshPublicKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateSshPublicKey( + request, + (err?: Error|null, result?: protos.google.cloud.oslogin.common.ISshPublicKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateSshPublicKey with error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSshPublicKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateSshPublicKey(request), expectedError); + const actualRequest = (client.innerApiCalls.updateSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateSshPublicKey with closed client', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateSshPublicKey(request), expectedError); + }); + }); + + describe('Path templates', () => { + + describe('posixAccount', () => { + const fakePath = "/rendered/path/posixAccount"; + const expectedParameters = { + user: "userValue", + project: "projectValue", + }; + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.posixAccountPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.posixAccountPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('posixAccountPath', () => { + const result = client.posixAccountPath("userValue", "projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.posixAccountPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchUserFromPosixAccountName', () => { + const result = client.matchUserFromPosixAccountName(fakePath); + assert.strictEqual(result, "userValue"); + assert((client.pathTemplates.posixAccountPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProjectFromPosixAccountName', () => { + const result = client.matchProjectFromPosixAccountName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.posixAccountPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('sshPublicKey', () => { + const fakePath = "/rendered/path/sshPublicKey"; + const expectedParameters = { + user: "userValue", + fingerprint: "fingerprintValue", + }; + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.sshPublicKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.sshPublicKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('sshPublicKeyPath', () => { + const result = client.sshPublicKeyPath("userValue", "fingerprintValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.sshPublicKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchUserFromSshPublicKeyName', () => { + const result = client.matchUserFromSshPublicKeyName(fakePath); + assert.strictEqual(result, "userValue"); + assert((client.pathTemplates.sshPublicKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchFingerprintFromSshPublicKeyName', () => { + const result = client.matchFingerprintFromSshPublicKeyName(fakePath); + assert.strictEqual(result, "fingerprintValue"); + assert((client.pathTemplates.sshPublicKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('user', () => { + const fakePath = "/rendered/path/user"; + const expectedParameters = { + user: "userValue", + }; + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.userPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.userPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('userPath', () => { + const result = client.userPath("userValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.userPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchUserFromUserName', () => { + const result = client.matchUserFromUserName(fakePath); + assert.strictEqual(result, "userValue"); + assert((client.pathTemplates.userPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-oslogin/v1/tsconfig.json b/owl-bot-staging/google-cloud-oslogin/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-oslogin/v1/webpack.config.js b/owl-bot-staging/google-cloud-oslogin/v1/webpack.config.js new file mode 100644 index 00000000000..67fc391472d --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'OsLoginService', + filename: './os-login-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-oslogin/v1beta/.eslintignore b/owl-bot-staging/google-cloud-oslogin/v1beta/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/.eslintrc.json b/owl-bot-staging/google-cloud-oslogin/v1beta/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/.gitignore b/owl-bot-staging/google-cloud-oslogin/v1beta/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/.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-oslogin/v1beta/.jsdoc.js b/owl-bot-staging/google-cloud-oslogin/v1beta/.jsdoc.js new file mode 100644 index 00000000000..f945dc1e9e4 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/.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/os-login', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/.mocharc.js b/owl-bot-staging/google-cloud-oslogin/v1beta/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/.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-oslogin/v1beta/.prettierrc.js b/owl-bot-staging/google-cloud-oslogin/v1beta/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/.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-oslogin/v1beta/README.md b/owl-bot-staging/google-cloud-oslogin/v1beta/README.md new file mode 100644 index 00000000000..f7acdc89a3a --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/README.md @@ -0,0 +1 @@ +Oslogin: Nodejs Client diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/package.json b/owl-bot-staging/google-cloud-oslogin/v1beta/package.json new file mode 100644 index 00000000000..7dc97d13da3 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/os-login", + "version": "0.1.0", + "description": "Oslogin client for Node.js", + "repository": "googleapis/nodejs-oslogin", + "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 oslogin", + "oslogin", + "os login service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/protos/google/cloud/oslogin/common/common.proto b/owl-bot-staging/google-cloud-oslogin/v1beta/protos/google/cloud/oslogin/common/common.proto new file mode 100644 index 00000000000..c0a15cc71fd --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/protos/google/cloud/oslogin/common/common.proto @@ -0,0 +1,108 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.oslogin.common; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option csharp_namespace = "Google.Cloud.OsLogin.Common"; +option go_package = "cloud.google.com/go/oslogin/common/commonpb;commonpb"; +option java_outer_classname = "OsLoginProto"; +option java_package = "com.google.cloud.oslogin.common"; +option php_namespace = "Google\\Cloud\\OsLogin\\Common"; +option ruby_package = "Google::Cloud::OsLogin::Common"; +option (google.api.resource_definition) = { + type: "oslogin.googleapis.com/User" + pattern: "users/{user}" +}; + +// The operating system options for account entries. +enum OperatingSystemType { + // The operating system type associated with the user account information is + // unspecified. + OPERATING_SYSTEM_TYPE_UNSPECIFIED = 0; + + // Linux user account information. + LINUX = 1; + + // Windows user account information. + WINDOWS = 2; +} + +// The POSIX account information associated with a Google account. +message PosixAccount { + option (google.api.resource) = { + type: "oslogin.googleapis.com/PosixAccount" + pattern: "users/{user}/projects/{project}" + }; + + // Only one POSIX account can be marked as primary. + bool primary = 1; + + // The username of the POSIX account. + string username = 2; + + // The user ID. + int64 uid = 3; + + // The default group ID. + int64 gid = 4; + + // The path to the home directory for this account. + string home_directory = 5; + + // The path to the logic shell for this account. + string shell = 6; + + // The GECOS (user information) entry for this account. + string gecos = 7; + + // System identifier for which account the username or uid applies to. + // By default, the empty value is used. + string system_id = 8; + + // Output only. A POSIX account identifier. + string account_id = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The operating system type where this account applies. + OperatingSystemType operating_system_type = 10; + + // Output only. The canonical resource name. + string name = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The SSH public key information associated with a Google account. +message SshPublicKey { + option (google.api.resource) = { + type: "oslogin.googleapis.com/SshPublicKey" + pattern: "users/{user}/sshPublicKeys/{fingerprint}" + }; + + // Public key text in SSH format, defined by + // RFC4253 + // section 6.6. + string key = 1; + + // An expiration time in microseconds since epoch. + int64 expiration_time_usec = 2; + + // Output only. The SHA-256 fingerprint of the SSH public key. + string fingerprint = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The canonical resource name. + string name = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/protos/google/cloud/oslogin/v1beta/oslogin.proto b/owl-bot-staging/google-cloud-oslogin/v1beta/protos/google/cloud/oslogin/v1beta/oslogin.proto new file mode 100644 index 00000000000..5209b44316c --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/protos/google/cloud/oslogin/v1beta/oslogin.proto @@ -0,0 +1,321 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.oslogin.v1beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/oslogin/common/common.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.OsLogin.V1Beta"; +option go_package = "cloud.google.com/go/oslogin/apiv1beta/osloginpb;osloginpb"; +option java_multiple_files = true; +option java_outer_classname = "OsLoginProto"; +option java_package = "com.google.cloud.oslogin.v1beta"; +option php_namespace = "Google\\Cloud\\OsLogin\\V1beta"; +option ruby_package = "Google::Cloud::OsLogin::V1beta"; + +// Cloud OS Login API +// +// The Cloud OS Login API allows you to manage users and their associated SSH +// public keys for logging into virtual machines on Google Cloud Platform. +service OsLoginService { + option (google.api.default_host) = "oslogin.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-platform.read-only," + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/compute.readonly"; + + // Create an SSH public key + rpc CreateSshPublicKey(CreateSshPublicKeyRequest) + returns (google.cloud.oslogin.common.SshPublicKey) { + option (google.api.http) = { + post: "/v1beta/{parent=users/*}/sshPublicKeys" + body: "ssh_public_key" + }; + option (google.api.method_signature) = "parent,ssh_public_key"; + } + + // Deletes a POSIX account. + rpc DeletePosixAccount(DeletePosixAccountRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1beta/{name=users/*/projects/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Deletes an SSH public key. + rpc DeleteSshPublicKey(DeleteSshPublicKeyRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1beta/{name=users/*/sshPublicKeys/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Retrieves the profile information used for logging in to a virtual machine + // on Google Compute Engine. + rpc GetLoginProfile(GetLoginProfileRequest) returns (LoginProfile) { + option (google.api.http) = { + get: "/v1beta/{name=users/*}/loginProfile" + }; + option (google.api.method_signature) = "name"; + } + + // Retrieves an SSH public key. + rpc GetSshPublicKey(GetSshPublicKeyRequest) + returns (google.cloud.oslogin.common.SshPublicKey) { + option (google.api.http) = { + get: "/v1beta/{name=users/*/sshPublicKeys/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Adds an SSH public key and returns the profile information. Default POSIX + // account information is set when no username and UID exist as part of the + // login profile. + rpc ImportSshPublicKey(ImportSshPublicKeyRequest) + returns (ImportSshPublicKeyResponse) { + option (google.api.http) = { + post: "/v1beta/{parent=users/*}:importSshPublicKey" + body: "ssh_public_key" + }; + option (google.api.method_signature) = "parent,ssh_public_key"; + option (google.api.method_signature) = "parent,ssh_public_key,project_id"; + } + + // Updates an SSH public key and returns the profile information. This method + // supports patch semantics. + rpc UpdateSshPublicKey(UpdateSshPublicKeyRequest) + returns (google.cloud.oslogin.common.SshPublicKey) { + option (google.api.http) = { + patch: "/v1beta/{name=users/*/sshPublicKeys/*}" + body: "ssh_public_key" + }; + option (google.api.method_signature) = "name,ssh_public_key"; + option (google.api.method_signature) = "name,ssh_public_key,update_mask"; + } + + // Signs an SSH public key for a user to authenticate to an instance. + rpc SignSshPublicKey(SignSshPublicKeyRequest) + returns (SignSshPublicKeyResponse) { + option (google.api.http) = { + post: "/v1beta/{parent=users/*/projects/*/zones/*}:signSshPublicKey" + body: "*" + }; + option (google.api.method_signature) = "parent,ssh_public_key"; + } +} + +// The user profile information used for logging in to a virtual machine on +// Google Compute Engine. +message LoginProfile { + // Required. A unique user ID. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // The list of POSIX accounts associated with the user. + repeated google.cloud.oslogin.common.PosixAccount posix_accounts = 2; + + // A map from SSH public key fingerprint to the associated key object. + map ssh_public_keys = 3; + + // The registered security key credentials for a user. + repeated SecurityKey security_keys = 5; +} + +// A request message for creating an SSH public key. +message CreateSshPublicKeyRequest { + // Required. The unique ID for the user in format `users/{user}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "oslogin.googleapis.com/SshPublicKey" + } + ]; + + // Required. The SSH public key and expiration time. + google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// A request message for deleting a POSIX account entry. +message DeletePosixAccountRequest { + // Required. A reference to the POSIX account to update. POSIX accounts are + // identified by the project ID they are associated with. A reference to the + // POSIX account is in format `users/{user}/projects/{project}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "oslogin.googleapis.com/PosixAccount" + } + ]; +} + +// A request message for deleting an SSH public key. +message DeleteSshPublicKeyRequest { + // Required. The fingerprint of the public key to update. Public keys are + // identified by their SHA-256 fingerprint. The fingerprint of the public key + // is in format `users/{user}/sshPublicKeys/{fingerprint}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "oslogin.googleapis.com/SshPublicKey" + } + ]; +} + +// A request message for retrieving the login profile information for a user. +message GetLoginProfileRequest { + // Required. The unique ID for the user in format `users/{user}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "oslogin.googleapis.com/User" } + ]; + + // The project ID of the Google Cloud Platform project. + string project_id = 2; + + // A system ID for filtering the results of the request. + string system_id = 3; + + // The view configures whether to retrieve security keys information. + LoginProfileView view = 4; +} + +// A request message for retrieving an SSH public key. +message GetSshPublicKeyRequest { + // Required. The fingerprint of the public key to retrieve. Public keys are + // identified by their SHA-256 fingerprint. The fingerprint of the public key + // is in format `users/{user}/sshPublicKeys/{fingerprint}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "oslogin.googleapis.com/SshPublicKey" + } + ]; +} + +// A request message for importing an SSH public key. +message ImportSshPublicKeyRequest { + // The unique ID for the user in format `users/{user}`. + string parent = 1 [(google.api.resource_reference) = { + child_type: "oslogin.googleapis.com/SshPublicKey" + }]; + + // Required. The SSH public key and expiration time. + google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 + [(google.api.field_behavior) = REQUIRED]; + + // The project ID of the Google Cloud Platform project. + string project_id = 3; + + // The view configures whether to retrieve security keys information. + LoginProfileView view = 4; +} + +// A response message for importing an SSH public key. +message ImportSshPublicKeyResponse { + // The login profile information for the user. + LoginProfile login_profile = 1; + + // Detailed information about import results. + string details = 2; +} + +// A request message for updating an SSH public key. +message UpdateSshPublicKeyRequest { + // Required. The fingerprint of the public key to update. Public keys are + // identified by their SHA-256 fingerprint. The fingerprint of the public key + // is in format `users/{user}/sshPublicKeys/{fingerprint}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "oslogin.googleapis.com/SshPublicKey" + } + ]; + + // Required. The SSH public key and expiration time. + google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Mask to control which fields get updated. Updates all if not present. + google.protobuf.FieldMask update_mask = 3; +} + +// The credential information for a Google registered security key. +message SecurityKey { + // Public key text in SSH format, defined by + // [RFC4253]("https://www.ietf.org/rfc/rfc4253.txt") section 6.6. + string public_key = 1; + + // Hardware-backed private key text in SSH format. + string private_key = 2; + + // The FIDO protocol type used to register this credential. + oneof protocol_type { + // The U2F protocol type. + UniversalTwoFactor universal_two_factor = 3; + + // The Web Authentication protocol type. + WebAuthn web_authn = 4; + } +} + +// Security key information specific to the U2F protocol. +message UniversalTwoFactor { + // Application ID for the U2F protocol. + string app_id = 1; +} + +// Security key information specific to the Web Authentication protocol. +message WebAuthn { + // Relying party ID for Web Authentication. + string rp_id = 1; +} + +message SignSshPublicKeyRequest { + // The SSH public key to sign. + string ssh_public_key = 1; + + // The parent project and zone for the signing request. This is needed to + // properly ensure per-organization ISS processing and potentially to provide + // for the possibility of zone-specific certificates used in the signing + // process. + string parent = 2; +} + +message SignSshPublicKeyResponse { + // The signed SSH public key to use in the SSH handshake. + string signed_ssh_public_key = 1; +} + +// The login profile view limits the user content retrieved. +enum LoginProfileView { + // The default login profile view. The API defaults to the BASIC view. + LOGIN_PROFILE_VIEW_UNSPECIFIED = 0; + + // Includes POSIX and SSH key information. + BASIC = 1; + + // Include security key information for the user. + SECURITY_KEY = 2; +} diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.create_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.create_ssh_public_key.js new file mode 100644 index 00000000000..4541a3cc13c --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.create_ssh_public_key.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(parent, sshPublicKey) { + // [START oslogin_v1beta_generated_OsLoginService_CreateSshPublicKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The unique ID for the user in format `users/{user}`. + */ + // const parent = 'abc123' + /** + * Required. The SSH public key and expiration time. + */ + // const sshPublicKey = {} + + // Imports the Oslogin library + const {OsLoginServiceClient} = require('@google-cloud/os-login').v1beta; + + // Instantiates a client + const osloginClient = new OsLoginServiceClient(); + + async function callCreateSshPublicKey() { + // Construct request + const request = { + parent, + sshPublicKey, + }; + + // Run request + const response = await osloginClient.createSshPublicKey(request); + console.log(response); + } + + callCreateSshPublicKey(); + // [END oslogin_v1beta_generated_OsLoginService_CreateSshPublicKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.delete_posix_account.js b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.delete_posix_account.js new file mode 100644 index 00000000000..66fe4e57ce9 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.delete_posix_account.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 oslogin_v1beta_generated_OsLoginService_DeletePosixAccount_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A reference to the POSIX account to update. POSIX accounts are + * identified by the project ID they are associated with. A reference to the + * POSIX account is in format `users/{user}/projects/{project}`. + */ + // const name = 'abc123' + + // Imports the Oslogin library + const {OsLoginServiceClient} = require('@google-cloud/os-login').v1beta; + + // Instantiates a client + const osloginClient = new OsLoginServiceClient(); + + async function callDeletePosixAccount() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osloginClient.deletePosixAccount(request); + console.log(response); + } + + callDeletePosixAccount(); + // [END oslogin_v1beta_generated_OsLoginService_DeletePosixAccount_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.delete_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.delete_ssh_public_key.js new file mode 100644 index 00000000000..edf261fc8bf --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.delete_ssh_public_key.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 oslogin_v1beta_generated_OsLoginService_DeleteSshPublicKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + */ + // const name = 'abc123' + + // Imports the Oslogin library + const {OsLoginServiceClient} = require('@google-cloud/os-login').v1beta; + + // Instantiates a client + const osloginClient = new OsLoginServiceClient(); + + async function callDeleteSshPublicKey() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osloginClient.deleteSshPublicKey(request); + console.log(response); + } + + callDeleteSshPublicKey(); + // [END oslogin_v1beta_generated_OsLoginService_DeleteSshPublicKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.get_login_profile.js b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.get_login_profile.js new file mode 100644 index 00000000000..cb23ebc80dc --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.get_login_profile.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(name) { + // [START oslogin_v1beta_generated_OsLoginService_GetLoginProfile_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The unique ID for the user in format `users/{user}`. + */ + // const name = 'abc123' + /** + * The project ID of the Google Cloud Platform project. + */ + // const projectId = 'abc123' + /** + * A system ID for filtering the results of the request. + */ + // const systemId = 'abc123' + /** + * The view configures whether to retrieve security keys information. + */ + // const view = {} + + // Imports the Oslogin library + const {OsLoginServiceClient} = require('@google-cloud/os-login').v1beta; + + // Instantiates a client + const osloginClient = new OsLoginServiceClient(); + + async function callGetLoginProfile() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osloginClient.getLoginProfile(request); + console.log(response); + } + + callGetLoginProfile(); + // [END oslogin_v1beta_generated_OsLoginService_GetLoginProfile_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.get_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.get_ssh_public_key.js new file mode 100644 index 00000000000..158e5dc7bda --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.get_ssh_public_key.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 oslogin_v1beta_generated_OsLoginService_GetSshPublicKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The fingerprint of the public key to retrieve. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + */ + // const name = 'abc123' + + // Imports the Oslogin library + const {OsLoginServiceClient} = require('@google-cloud/os-login').v1beta; + + // Instantiates a client + const osloginClient = new OsLoginServiceClient(); + + async function callGetSshPublicKey() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await osloginClient.getSshPublicKey(request); + console.log(response); + } + + callGetSshPublicKey(); + // [END oslogin_v1beta_generated_OsLoginService_GetSshPublicKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.import_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.import_ssh_public_key.js new file mode 100644 index 00000000000..e4f5bdcf0a2 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.import_ssh_public_key.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(sshPublicKey) { + // [START oslogin_v1beta_generated_OsLoginService_ImportSshPublicKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 unique ID for the user in format `users/{user}`. + */ + // const parent = 'abc123' + /** + * Required. The SSH public key and expiration time. + */ + // const sshPublicKey = {} + /** + * The project ID of the Google Cloud Platform project. + */ + // const projectId = 'abc123' + /** + * The view configures whether to retrieve security keys information. + */ + // const view = {} + + // Imports the Oslogin library + const {OsLoginServiceClient} = require('@google-cloud/os-login').v1beta; + + // Instantiates a client + const osloginClient = new OsLoginServiceClient(); + + async function callImportSshPublicKey() { + // Construct request + const request = { + sshPublicKey, + }; + + // Run request + const response = await osloginClient.importSshPublicKey(request); + console.log(response); + } + + callImportSshPublicKey(); + // [END oslogin_v1beta_generated_OsLoginService_ImportSshPublicKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.sign_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.sign_ssh_public_key.js new file mode 100644 index 00000000000..9d9f2b2dfb5 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.sign_ssh_public_key.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() { + // [START oslogin_v1beta_generated_OsLoginService_SignSshPublicKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 SSH public key to sign. + */ + // const sshPublicKey = 'abc123' + /** + * The parent project and zone for the signing request. This is needed to + * properly ensure per-organization ISS processing and potentially to provide + * for the possibility of zone-specific certificates used in the signing + * process. + */ + // const parent = 'abc123' + + // Imports the Oslogin library + const {OsLoginServiceClient} = require('@google-cloud/os-login').v1beta; + + // Instantiates a client + const osloginClient = new OsLoginServiceClient(); + + async function callSignSshPublicKey() { + // Construct request + const request = { + }; + + // Run request + const response = await osloginClient.signSshPublicKey(request); + console.log(response); + } + + callSignSshPublicKey(); + // [END oslogin_v1beta_generated_OsLoginService_SignSshPublicKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.update_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.update_ssh_public_key.js new file mode 100644 index 00000000000..f4c10f3fba9 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.update_ssh_public_key.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(name, sshPublicKey) { + // [START oslogin_v1beta_generated_OsLoginService_UpdateSshPublicKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + */ + // const name = 'abc123' + /** + * Required. The SSH public key and expiration time. + */ + // const sshPublicKey = {} + /** + * Mask to control which fields get updated. Updates all if not present. + */ + // const updateMask = {} + + // Imports the Oslogin library + const {OsLoginServiceClient} = require('@google-cloud/os-login').v1beta; + + // Instantiates a client + const osloginClient = new OsLoginServiceClient(); + + async function callUpdateSshPublicKey() { + // Construct request + const request = { + name, + sshPublicKey, + }; + + // Run request + const response = await osloginClient.updateSshPublicKey(request); + console.log(response); + } + + callUpdateSshPublicKey(); + // [END oslogin_v1beta_generated_OsLoginService_UpdateSshPublicKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/snippet_metadata_google.cloud.oslogin.v1beta.json b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/snippet_metadata_google.cloud.oslogin.v1beta.json new file mode 100644 index 00000000000..b1fa3694f12 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/snippet_metadata_google.cloud.oslogin.v1beta.json @@ -0,0 +1,375 @@ +{ + "clientLibrary": { + "name": "nodejs-oslogin", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.oslogin.v1beta", + "version": "v1beta" + } + ] + }, + "snippets": [ + { + "regionTag": "oslogin_v1beta_generated_OsLoginService_CreateSshPublicKey_async", + "title": "OsLoginService createSshPublicKey Sample", + "origin": "API_DEFINITION", + "description": " Create an SSH public key", + "canonical": true, + "file": "os_login_service.create_ssh_public_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateSshPublicKey", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService.CreateSshPublicKey", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "ssh_public_key", + "type": ".google.cloud.oslogin.common.SshPublicKey" + } + ], + "resultType": ".google.cloud.oslogin.common.SshPublicKey", + "client": { + "shortName": "OsLoginServiceClient", + "fullName": "google.cloud.oslogin.v1beta.OsLoginServiceClient" + }, + "method": { + "shortName": "CreateSshPublicKey", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService.CreateSshPublicKey", + "service": { + "shortName": "OsLoginService", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService" + } + } + } + }, + { + "regionTag": "oslogin_v1beta_generated_OsLoginService_DeletePosixAccount_async", + "title": "OsLoginService deletePosixAccount Sample", + "origin": "API_DEFINITION", + "description": " Deletes a POSIX account.", + "canonical": true, + "file": "os_login_service.delete_posix_account.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeletePosixAccount", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService.DeletePosixAccount", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "OsLoginServiceClient", + "fullName": "google.cloud.oslogin.v1beta.OsLoginServiceClient" + }, + "method": { + "shortName": "DeletePosixAccount", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService.DeletePosixAccount", + "service": { + "shortName": "OsLoginService", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService" + } + } + } + }, + { + "regionTag": "oslogin_v1beta_generated_OsLoginService_DeleteSshPublicKey_async", + "title": "OsLoginService deleteSshPublicKey Sample", + "origin": "API_DEFINITION", + "description": " Deletes an SSH public key.", + "canonical": true, + "file": "os_login_service.delete_ssh_public_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteSshPublicKey", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService.DeleteSshPublicKey", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "OsLoginServiceClient", + "fullName": "google.cloud.oslogin.v1beta.OsLoginServiceClient" + }, + "method": { + "shortName": "DeleteSshPublicKey", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService.DeleteSshPublicKey", + "service": { + "shortName": "OsLoginService", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService" + } + } + } + }, + { + "regionTag": "oslogin_v1beta_generated_OsLoginService_GetLoginProfile_async", + "title": "OsLoginService getLoginProfile Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the profile information used for logging in to a virtual machine on Google Compute Engine.", + "canonical": true, + "file": "os_login_service.get_login_profile.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetLoginProfile", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService.GetLoginProfile", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "system_id", + "type": "TYPE_STRING" + }, + { + "name": "view", + "type": ".google.cloud.oslogin.v1beta.LoginProfileView" + } + ], + "resultType": ".google.cloud.oslogin.v1beta.LoginProfile", + "client": { + "shortName": "OsLoginServiceClient", + "fullName": "google.cloud.oslogin.v1beta.OsLoginServiceClient" + }, + "method": { + "shortName": "GetLoginProfile", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService.GetLoginProfile", + "service": { + "shortName": "OsLoginService", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService" + } + } + } + }, + { + "regionTag": "oslogin_v1beta_generated_OsLoginService_GetSshPublicKey_async", + "title": "OsLoginService getSshPublicKey Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an SSH public key.", + "canonical": true, + "file": "os_login_service.get_ssh_public_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetSshPublicKey", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService.GetSshPublicKey", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.oslogin.common.SshPublicKey", + "client": { + "shortName": "OsLoginServiceClient", + "fullName": "google.cloud.oslogin.v1beta.OsLoginServiceClient" + }, + "method": { + "shortName": "GetSshPublicKey", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService.GetSshPublicKey", + "service": { + "shortName": "OsLoginService", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService" + } + } + } + }, + { + "regionTag": "oslogin_v1beta_generated_OsLoginService_ImportSshPublicKey_async", + "title": "OsLoginService importSshPublicKey Sample", + "origin": "API_DEFINITION", + "description": " Adds an SSH public key and returns the profile information. Default POSIX account information is set when no username and UID exist as part of the login profile.", + "canonical": true, + "file": "os_login_service.import_ssh_public_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportSshPublicKey", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService.ImportSshPublicKey", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "ssh_public_key", + "type": ".google.cloud.oslogin.common.SshPublicKey" + }, + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "view", + "type": ".google.cloud.oslogin.v1beta.LoginProfileView" + } + ], + "resultType": ".google.cloud.oslogin.v1beta.ImportSshPublicKeyResponse", + "client": { + "shortName": "OsLoginServiceClient", + "fullName": "google.cloud.oslogin.v1beta.OsLoginServiceClient" + }, + "method": { + "shortName": "ImportSshPublicKey", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService.ImportSshPublicKey", + "service": { + "shortName": "OsLoginService", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService" + } + } + } + }, + { + "regionTag": "oslogin_v1beta_generated_OsLoginService_UpdateSshPublicKey_async", + "title": "OsLoginService updateSshPublicKey Sample", + "origin": "API_DEFINITION", + "description": " Updates an SSH public key and returns the profile information. This method supports patch semantics.", + "canonical": true, + "file": "os_login_service.update_ssh_public_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateSshPublicKey", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService.UpdateSshPublicKey", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "ssh_public_key", + "type": ".google.cloud.oslogin.common.SshPublicKey" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.oslogin.common.SshPublicKey", + "client": { + "shortName": "OsLoginServiceClient", + "fullName": "google.cloud.oslogin.v1beta.OsLoginServiceClient" + }, + "method": { + "shortName": "UpdateSshPublicKey", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService.UpdateSshPublicKey", + "service": { + "shortName": "OsLoginService", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService" + } + } + } + }, + { + "regionTag": "oslogin_v1beta_generated_OsLoginService_SignSshPublicKey_async", + "title": "OsLoginService signSshPublicKey Sample", + "origin": "API_DEFINITION", + "description": " Signs an SSH public key for a user to authenticate to an instance.", + "canonical": true, + "file": "os_login_service.sign_ssh_public_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SignSshPublicKey", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService.SignSshPublicKey", + "async": true, + "parameters": [ + { + "name": "ssh_public_key", + "type": "TYPE_STRING" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.oslogin.v1beta.SignSshPublicKeyResponse", + "client": { + "shortName": "OsLoginServiceClient", + "fullName": "google.cloud.oslogin.v1beta.OsLoginServiceClient" + }, + "method": { + "shortName": "SignSshPublicKey", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService.SignSshPublicKey", + "service": { + "shortName": "OsLoginService", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/src/index.ts b/owl-bot-staging/google-cloud-oslogin/v1beta/src/index.ts new file mode 100644 index 00000000000..5237f188fbf --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1beta from './v1beta'; +const OsLoginServiceClient = v1beta.OsLoginServiceClient; +type OsLoginServiceClient = v1beta.OsLoginServiceClient; +export {v1beta, OsLoginServiceClient}; +export default {v1beta, OsLoginServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/gapic_metadata.json b/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/gapic_metadata.json new file mode 100644 index 00000000000..850a4c8b40a --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/gapic_metadata.json @@ -0,0 +1,103 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.oslogin.v1beta", + "libraryPackage": "@google-cloud/os-login", + "services": { + "OsLoginService": { + "clients": { + "grpc": { + "libraryClient": "OsLoginServiceClient", + "rpcs": { + "CreateSshPublicKey": { + "methods": [ + "createSshPublicKey" + ] + }, + "DeletePosixAccount": { + "methods": [ + "deletePosixAccount" + ] + }, + "DeleteSshPublicKey": { + "methods": [ + "deleteSshPublicKey" + ] + }, + "GetLoginProfile": { + "methods": [ + "getLoginProfile" + ] + }, + "GetSshPublicKey": { + "methods": [ + "getSshPublicKey" + ] + }, + "ImportSshPublicKey": { + "methods": [ + "importSshPublicKey" + ] + }, + "UpdateSshPublicKey": { + "methods": [ + "updateSshPublicKey" + ] + }, + "SignSshPublicKey": { + "methods": [ + "signSshPublicKey" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "OsLoginServiceClient", + "rpcs": { + "CreateSshPublicKey": { + "methods": [ + "createSshPublicKey" + ] + }, + "DeletePosixAccount": { + "methods": [ + "deletePosixAccount" + ] + }, + "DeleteSshPublicKey": { + "methods": [ + "deleteSshPublicKey" + ] + }, + "GetLoginProfile": { + "methods": [ + "getLoginProfile" + ] + }, + "GetSshPublicKey": { + "methods": [ + "getSshPublicKey" + ] + }, + "ImportSshPublicKey": { + "methods": [ + "importSshPublicKey" + ] + }, + "UpdateSshPublicKey": { + "methods": [ + "updateSshPublicKey" + ] + }, + "SignSshPublicKey": { + "methods": [ + "signSshPublicKey" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/index.ts b/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/index.ts new file mode 100644 index 00000000000..477969ae393 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {OsLoginServiceClient} from './os_login_service_client'; diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_client.ts b/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_client.ts new file mode 100644 index 00000000000..ec29e0b9ccf --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_client.ts @@ -0,0 +1,1021 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta/os_login_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './os_login_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Cloud OS Login API + * + * The Cloud OS Login API allows you to manage users and their associated SSH + * public keys for logging into virtual machines on Google Cloud Platform. + * @class + * @memberof v1beta + */ +export class OsLoginServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + osLoginServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of OsLoginServiceClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 OsLoginServiceClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof OsLoginServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + posixAccountPathTemplate: new this._gaxModule.PathTemplate( + 'users/{user}/projects/{project}' + ), + sshPublicKeyPathTemplate: new this._gaxModule.PathTemplate( + 'users/{user}/sshPublicKeys/{fingerprint}' + ), + userPathTemplate: new this._gaxModule.PathTemplate( + 'users/{user}' + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.oslogin.v1beta.OsLoginService', 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.osLoginServiceStub) { + return this.osLoginServiceStub; + } + + // Put together the "service stub" for + // google.cloud.oslogin.v1beta.OsLoginService. + this.osLoginServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.oslogin.v1beta.OsLoginService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.oslogin.v1beta.OsLoginService, + 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 osLoginServiceStubMethods = + ['createSshPublicKey', 'deletePosixAccount', 'deleteSshPublicKey', 'getLoginProfile', 'getSshPublicKey', 'importSshPublicKey', 'updateSshPublicKey', 'signSshPublicKey']; + for (const methodName of osLoginServiceStubMethods) { + const callPromise = this.osLoginServiceStub.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.osLoginServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'oslogin.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 'oslogin.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/compute.readonly' + ]; + } + + 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 -- + // ------------------- +/** + * Create an SSH public key + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique ID for the user in format `users/{user}`. + * @param {google.cloud.oslogin.common.SshPublicKey} request.sshPublicKey + * Required. The SSH public key and expiration time. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.oslogin.common.SshPublicKey|SshPublicKey}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_login_service.create_ssh_public_key.js + * region_tag:oslogin_v1beta_generated_OsLoginService_CreateSshPublicKey_async + */ + createSshPublicKey( + request?: protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest|undefined, {}|undefined + ]>; + createSshPublicKey( + request: protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + createSshPublicKey( + request: protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + createSshPublicKey( + request?: protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createSshPublicKey(request, options, callback); + } +/** + * Deletes a POSIX account. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A reference to the POSIX account to update. POSIX accounts are + * identified by the project ID they are associated with. A reference to the + * POSIX account is in format `users/{user}/projects/{project}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_login_service.delete_posix_account.js + * region_tag:oslogin_v1beta_generated_OsLoginService_DeletePosixAccount_async + */ + deletePosixAccount( + request?: protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest|undefined, {}|undefined + ]>; + deletePosixAccount( + request: protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest|null|undefined, + {}|null|undefined>): void; + deletePosixAccount( + request: protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest|null|undefined, + {}|null|undefined>): void; + deletePosixAccount( + request?: protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deletePosixAccount(request, options, callback); + } +/** + * Deletes an SSH public key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_login_service.delete_ssh_public_key.js + * region_tag:oslogin_v1beta_generated_OsLoginService_DeleteSshPublicKey_async + */ + deleteSshPublicKey( + request?: protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest|undefined, {}|undefined + ]>; + deleteSshPublicKey( + request: protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + deleteSshPublicKey( + request: protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + deleteSshPublicKey( + request?: protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteSshPublicKey(request, options, callback); + } +/** + * Retrieves the profile information used for logging in to a virtual machine + * on Google Compute Engine. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The unique ID for the user in format `users/{user}`. + * @param {string} request.projectId + * The project ID of the Google Cloud Platform project. + * @param {string} request.systemId + * A system ID for filtering the results of the request. + * @param {google.cloud.oslogin.v1beta.LoginProfileView} request.view + * The view configures whether to retrieve security keys information. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.oslogin.v1beta.LoginProfile|LoginProfile}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_login_service.get_login_profile.js + * region_tag:oslogin_v1beta_generated_OsLoginService_GetLoginProfile_async + */ + getLoginProfile( + request?: protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.oslogin.v1beta.ILoginProfile, + protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest|undefined, {}|undefined + ]>; + getLoginProfile( + request: protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oslogin.v1beta.ILoginProfile, + protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest|null|undefined, + {}|null|undefined>): void; + getLoginProfile( + request: protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest, + callback: Callback< + protos.google.cloud.oslogin.v1beta.ILoginProfile, + protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest|null|undefined, + {}|null|undefined>): void; + getLoginProfile( + request?: protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.oslogin.v1beta.ILoginProfile, + protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.oslogin.v1beta.ILoginProfile, + protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.oslogin.v1beta.ILoginProfile, + protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getLoginProfile(request, options, callback); + } +/** + * Retrieves an SSH public key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The fingerprint of the public key to retrieve. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.oslogin.common.SshPublicKey|SshPublicKey}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_login_service.get_ssh_public_key.js + * region_tag:oslogin_v1beta_generated_OsLoginService_GetSshPublicKey_async + */ + getSshPublicKey( + request?: protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest|undefined, {}|undefined + ]>; + getSshPublicKey( + request: protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + getSshPublicKey( + request: protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + getSshPublicKey( + request?: protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getSshPublicKey(request, options, callback); + } +/** + * Adds an SSH public key and returns the profile information. Default POSIX + * account information is set when no username and UID exist as part of the + * login profile. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The unique ID for the user in format `users/{user}`. + * @param {google.cloud.oslogin.common.SshPublicKey} request.sshPublicKey + * Required. The SSH public key and expiration time. + * @param {string} request.projectId + * The project ID of the Google Cloud Platform project. + * @param {google.cloud.oslogin.v1beta.LoginProfileView} request.view + * The view configures whether to retrieve security keys information. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyResponse|ImportSshPublicKeyResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_login_service.import_ssh_public_key.js + * region_tag:oslogin_v1beta_generated_OsLoginService_ImportSshPublicKey_async + */ + importSshPublicKey( + request?: protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest|undefined, {}|undefined + ]>; + importSshPublicKey( + request: protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + importSshPublicKey( + request: protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest, + callback: Callback< + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + importSshPublicKey( + request?: protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.importSshPublicKey(request, options, callback); + } +/** + * Updates an SSH public key and returns the profile information. This method + * supports patch semantics. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * @param {google.cloud.oslogin.common.SshPublicKey} request.sshPublicKey + * Required. The SSH public key and expiration time. + * @param {google.protobuf.FieldMask} request.updateMask + * Mask to control which fields get updated. Updates all if not present. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.oslogin.common.SshPublicKey|SshPublicKey}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_login_service.update_ssh_public_key.js + * region_tag:oslogin_v1beta_generated_OsLoginService_UpdateSshPublicKey_async + */ + updateSshPublicKey( + request?: protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest|undefined, {}|undefined + ]>; + updateSshPublicKey( + request: protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + updateSshPublicKey( + request: protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + updateSshPublicKey( + request?: protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateSshPublicKey(request, options, callback); + } +/** + * Signs an SSH public key for a user to authenticate to an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.sshPublicKey + * The SSH public key to sign. + * @param {string} request.parent + * The parent project and zone for the signing request. This is needed to + * properly ensure per-organization ISS processing and potentially to provide + * for the possibility of zone-specific certificates used in the signing + * process. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.oslogin.v1beta.SignSshPublicKeyResponse|SignSshPublicKeyResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/os_login_service.sign_ssh_public_key.js + * region_tag:oslogin_v1beta_generated_OsLoginService_SignSshPublicKey_async + */ + signSshPublicKey( + request?: protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyResponse, + protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyRequest|undefined, {}|undefined + ]>; + signSshPublicKey( + request: protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyResponse, + protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + signSshPublicKey( + request: protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyRequest, + callback: Callback< + protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyResponse, + protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; + signSshPublicKey( + request?: protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyResponse, + protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyResponse, + protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyResponse, + protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.signSshPublicKey(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified posixAccount resource name string. + * + * @param {string} user + * @param {string} project + * @returns {string} Resource name string. + */ + posixAccountPath(user:string,project:string) { + return this.pathTemplates.posixAccountPathTemplate.render({ + user: user, + project: project, + }); + } + + /** + * Parse the user from PosixAccount resource. + * + * @param {string} posixAccountName + * A fully-qualified path representing PosixAccount resource. + * @returns {string} A string representing the user. + */ + matchUserFromPosixAccountName(posixAccountName: string) { + return this.pathTemplates.posixAccountPathTemplate.match(posixAccountName).user; + } + + /** + * Parse the project from PosixAccount resource. + * + * @param {string} posixAccountName + * A fully-qualified path representing PosixAccount resource. + * @returns {string} A string representing the project. + */ + matchProjectFromPosixAccountName(posixAccountName: string) { + return this.pathTemplates.posixAccountPathTemplate.match(posixAccountName).project; + } + + /** + * Return a fully-qualified sshPublicKey resource name string. + * + * @param {string} user + * @param {string} fingerprint + * @returns {string} Resource name string. + */ + sshPublicKeyPath(user:string,fingerprint:string) { + return this.pathTemplates.sshPublicKeyPathTemplate.render({ + user: user, + fingerprint: fingerprint, + }); + } + + /** + * Parse the user from SshPublicKey resource. + * + * @param {string} sshPublicKeyName + * A fully-qualified path representing SshPublicKey resource. + * @returns {string} A string representing the user. + */ + matchUserFromSshPublicKeyName(sshPublicKeyName: string) { + return this.pathTemplates.sshPublicKeyPathTemplate.match(sshPublicKeyName).user; + } + + /** + * Parse the fingerprint from SshPublicKey resource. + * + * @param {string} sshPublicKeyName + * A fully-qualified path representing SshPublicKey resource. + * @returns {string} A string representing the fingerprint. + */ + matchFingerprintFromSshPublicKeyName(sshPublicKeyName: string) { + return this.pathTemplates.sshPublicKeyPathTemplate.match(sshPublicKeyName).fingerprint; + } + + /** + * Return a fully-qualified user resource name string. + * + * @param {string} user + * @returns {string} Resource name string. + */ + userPath(user:string) { + return this.pathTemplates.userPathTemplate.render({ + user: user, + }); + } + + /** + * Parse the user from User resource. + * + * @param {string} userName + * A fully-qualified path representing User resource. + * @returns {string} A string representing the user. + */ + matchUserFromUserName(userName: string) { + return this.pathTemplates.userPathTemplate.match(userName).user; + } + + /** + * 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.osLoginServiceStub && !this._terminated) { + return this.osLoginServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_client_config.json b/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_client_config.json new file mode 100644 index 00000000000..993e2ef12fe --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_client_config.json @@ -0,0 +1,64 @@ +{ + "interfaces": { + "google.cloud.oslogin.v1beta.OsLoginService": { + "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": { + "CreateSshPublicKey": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeletePosixAccount": { + "timeout_millis": 10000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteSshPublicKey": { + "timeout_millis": 10000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetLoginProfile": { + "timeout_millis": 10000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetSshPublicKey": { + "timeout_millis": 10000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ImportSshPublicKey": { + "timeout_millis": 10000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateSshPublicKey": { + "timeout_millis": 10000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "SignSshPublicKey": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_proto_list.json b/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_proto_list.json new file mode 100644 index 00000000000..078ed1d537d --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_proto_list.json @@ -0,0 +1,4 @@ +[ + "../../protos/google/cloud/oslogin/common/common.proto", + "../../protos/google/cloud/oslogin/v1beta/oslogin.proto" +] diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-oslogin/v1beta/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..de1b9afaf4f --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const oslogin = require('@google-cloud/os-login'); + +function main() { + const osLoginServiceClient = new oslogin.OsLoginServiceClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-oslogin/v1beta/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..ab3709b1bb9 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {OsLoginServiceClient} from '@google-cloud/os-login'; + +// check that the client class type name can be used +function doStuffWithOsLoginServiceClient(client: OsLoginServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const osLoginServiceClient = new OsLoginServiceClient(); + doStuffWithOsLoginServiceClient(osLoginServiceClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/system-test/install.ts b/owl-bot-staging/google-cloud-oslogin/v1beta/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/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-oslogin/v1beta/test/gapic_os_login_service_v1beta.ts b/owl-bot-staging/google-cloud-oslogin/v1beta/test/gapic_os_login_service_v1beta.ts new file mode 100644 index 00000000000..75819591839 --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/test/gapic_os_login_service_v1beta.ts @@ -0,0 +1,1123 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 osloginserviceModule from '../src'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +describe('v1beta.OsLoginServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = osloginserviceModule.v1beta.OsLoginServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = osloginserviceModule.v1beta.OsLoginServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = osloginserviceModule.v1beta.OsLoginServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.osLoginServiceStub, undefined); + await client.initialize(); + assert(client.osLoginServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.osLoginServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.osLoginServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + 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 osloginserviceModule.v1beta.OsLoginServiceClient({ + 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('createSshPublicKey', () => { + it('invokes createSshPublicKey without error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.common.SshPublicKey() + ); + client.innerApiCalls.createSshPublicKey = stubSimpleCall(expectedResponse); + const [response] = await client.createSshPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSshPublicKey without error using callback', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.common.SshPublicKey() + ); + client.innerApiCalls.createSshPublicKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createSshPublicKey( + request, + (err?: Error|null, result?: protos.google.cloud.oslogin.common.ISshPublicKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSshPublicKey with error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSshPublicKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createSshPublicKey(request), expectedError); + const actualRequest = (client.innerApiCalls.createSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSshPublicKey with closed client', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createSshPublicKey(request), expectedError); + }); + }); + + describe('deletePosixAccount', () => { + it('invokes deletePosixAccount without error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.DeletePosixAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.DeletePosixAccountRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deletePosixAccount = stubSimpleCall(expectedResponse); + const [response] = await client.deletePosixAccount(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deletePosixAccount as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePosixAccount as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePosixAccount without error using callback', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.DeletePosixAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.DeletePosixAccountRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deletePosixAccount = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deletePosixAccount( + 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.deletePosixAccount as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePosixAccount as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePosixAccount with error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.DeletePosixAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.DeletePosixAccountRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePosixAccount = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deletePosixAccount(request), expectedError); + const actualRequest = (client.innerApiCalls.deletePosixAccount as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePosixAccount as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePosixAccount with closed client', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.DeletePosixAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.DeletePosixAccountRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deletePosixAccount(request), expectedError); + }); + }); + + describe('deleteSshPublicKey', () => { + it('invokes deleteSshPublicKey without error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteSshPublicKey = stubSimpleCall(expectedResponse); + const [response] = await client.deleteSshPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSshPublicKey without error using callback', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteSshPublicKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteSshPublicKey( + 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.deleteSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSshPublicKey with error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSshPublicKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteSshPublicKey(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSshPublicKey with closed client', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteSshPublicKey(request), expectedError); + }); + }); + + describe('getLoginProfile', () => { + it('invokes getLoginProfile without error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.GetLoginProfileRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.GetLoginProfileRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.LoginProfile() + ); + client.innerApiCalls.getLoginProfile = stubSimpleCall(expectedResponse); + const [response] = await client.getLoginProfile(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getLoginProfile as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getLoginProfile as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getLoginProfile without error using callback', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.GetLoginProfileRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.GetLoginProfileRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.LoginProfile() + ); + client.innerApiCalls.getLoginProfile = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLoginProfile( + request, + (err?: Error|null, result?: protos.google.cloud.oslogin.v1beta.ILoginProfile|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getLoginProfile as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getLoginProfile as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getLoginProfile with error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.GetLoginProfileRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.GetLoginProfileRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getLoginProfile = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLoginProfile(request), expectedError); + const actualRequest = (client.innerApiCalls.getLoginProfile as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getLoginProfile as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getLoginProfile with closed client', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.GetLoginProfileRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.GetLoginProfileRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getLoginProfile(request), expectedError); + }); + }); + + describe('getSshPublicKey', () => { + it('invokes getSshPublicKey without error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.common.SshPublicKey() + ); + client.innerApiCalls.getSshPublicKey = stubSimpleCall(expectedResponse); + const [response] = await client.getSshPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSshPublicKey without error using callback', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.common.SshPublicKey() + ); + client.innerApiCalls.getSshPublicKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSshPublicKey( + request, + (err?: Error|null, result?: protos.google.cloud.oslogin.common.ISshPublicKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSshPublicKey with error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getSshPublicKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getSshPublicKey(request), expectedError); + const actualRequest = (client.innerApiCalls.getSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSshPublicKey with closed client', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getSshPublicKey(request), expectedError); + }); + }); + + describe('importSshPublicKey', () => { + it('invokes importSshPublicKey without error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyResponse() + ); + client.innerApiCalls.importSshPublicKey = stubSimpleCall(expectedResponse); + const [response] = await client.importSshPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.importSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importSshPublicKey without error using callback', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyResponse() + ); + client.innerApiCalls.importSshPublicKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importSshPublicKey( + request, + (err?: Error|null, result?: protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.importSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importSshPublicKey with error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importSshPublicKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.importSshPublicKey(request), expectedError); + const actualRequest = (client.innerApiCalls.importSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importSshPublicKey with closed client', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.importSshPublicKey(request), expectedError); + }); + }); + + describe('updateSshPublicKey', () => { + it('invokes updateSshPublicKey without error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.common.SshPublicKey() + ); + client.innerApiCalls.updateSshPublicKey = stubSimpleCall(expectedResponse); + const [response] = await client.updateSshPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateSshPublicKey without error using callback', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.common.SshPublicKey() + ); + client.innerApiCalls.updateSshPublicKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateSshPublicKey( + request, + (err?: Error|null, result?: protos.google.cloud.oslogin.common.ISshPublicKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateSshPublicKey with error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSshPublicKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateSshPublicKey(request), expectedError); + const actualRequest = (client.innerApiCalls.updateSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateSshPublicKey with closed client', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateSshPublicKey(request), expectedError); + }); + }); + + describe('signSshPublicKey', () => { + it('invokes signSshPublicKey without error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.SignSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.SignSshPublicKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.SignSshPublicKeyResponse() + ); + client.innerApiCalls.signSshPublicKey = stubSimpleCall(expectedResponse); + const [response] = await client.signSshPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.signSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.signSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes signSshPublicKey without error using callback', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.SignSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.SignSshPublicKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.SignSshPublicKeyResponse() + ); + client.innerApiCalls.signSshPublicKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.signSshPublicKey( + request, + (err?: Error|null, result?: protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.signSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.signSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes signSshPublicKey with error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.SignSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.SignSshPublicKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.signSshPublicKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.signSshPublicKey(request), expectedError); + const actualRequest = (client.innerApiCalls.signSshPublicKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.signSshPublicKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes signSshPublicKey with closed client', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.SignSshPublicKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.oslogin.v1beta.SignSshPublicKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.signSshPublicKey(request), expectedError); + }); + }); + + describe('Path templates', () => { + + describe('posixAccount', () => { + const fakePath = "/rendered/path/posixAccount"; + const expectedParameters = { + user: "userValue", + project: "projectValue", + }; + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.posixAccountPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.posixAccountPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('posixAccountPath', () => { + const result = client.posixAccountPath("userValue", "projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.posixAccountPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchUserFromPosixAccountName', () => { + const result = client.matchUserFromPosixAccountName(fakePath); + assert.strictEqual(result, "userValue"); + assert((client.pathTemplates.posixAccountPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProjectFromPosixAccountName', () => { + const result = client.matchProjectFromPosixAccountName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.posixAccountPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('sshPublicKey', () => { + const fakePath = "/rendered/path/sshPublicKey"; + const expectedParameters = { + user: "userValue", + fingerprint: "fingerprintValue", + }; + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.sshPublicKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.sshPublicKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('sshPublicKeyPath', () => { + const result = client.sshPublicKeyPath("userValue", "fingerprintValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.sshPublicKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchUserFromSshPublicKeyName', () => { + const result = client.matchUserFromSshPublicKeyName(fakePath); + assert.strictEqual(result, "userValue"); + assert((client.pathTemplates.sshPublicKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchFingerprintFromSshPublicKeyName', () => { + const result = client.matchFingerprintFromSshPublicKeyName(fakePath); + assert.strictEqual(result, "fingerprintValue"); + assert((client.pathTemplates.sshPublicKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('user', () => { + const fakePath = "/rendered/path/user"; + const expectedParameters = { + user: "userValue", + }; + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.userPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.userPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('userPath', () => { + const result = client.userPath("userValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.userPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchUserFromUserName', () => { + const result = client.matchUserFromUserName(fakePath); + assert.strictEqual(result, "userValue"); + assert((client.pathTemplates.userPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/tsconfig.json b/owl-bot-staging/google-cloud-oslogin/v1beta/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/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-oslogin/v1beta/webpack.config.js b/owl-bot-staging/google-cloud-oslogin/v1beta/webpack.config.js new file mode 100644 index 00000000000..67fc391472d --- /dev/null +++ b/owl-bot-staging/google-cloud-oslogin/v1beta/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: 'OsLoginService', + filename: './os-login-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-phishingprotection/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.gitignore b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.jsdoc.js new file mode 100644 index 00000000000..42bc19bd758 --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.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/phishing-protection', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.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-phishingprotection/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.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-phishingprotection/v1beta1/README.md b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/README.md new file mode 100644 index 00000000000..30dcb3ca0dc --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/README.md @@ -0,0 +1 @@ +Phishingprotection: Nodejs Client diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/package.json b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/package.json new file mode 100644 index 00000000000..835ea83496c --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/phishing-protection", + "version": "0.1.0", + "description": "Phishingprotection client for Node.js", + "repository": "googleapis/nodejs-phishingprotection", + "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 phishingprotection", + "phishingprotection", + "phishing protection service v1 beta1" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/protos/google/cloud/phishingprotection/v1beta1/phishingprotection.proto b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/protos/google/cloud/phishingprotection/v1beta1/phishingprotection.proto new file mode 100644 index 00000000000..82eb6af4424 --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/protos/google/cloud/phishingprotection/v1beta1/phishingprotection.proto @@ -0,0 +1,73 @@ +// Copyright 2019 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +syntax = "proto3"; + +package google.cloud.phishingprotection.v1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option csharp_namespace = "Google.Cloud.PhishingProtection.V1Beta1"; +option go_package = "cloud.google.com/go/phishingprotection/apiv1beta1/phishingprotectionpb;phishingprotectionpb"; +option java_multiple_files = true; +option java_outer_classname = "PhishingProtectionProto"; +option java_package = "com.google.phishingprotection.v1beta1"; +option objc_class_prefix = "GCPP"; +option php_namespace = "Google\\Cloud\\PhishingProtection\\V1beta1"; +option ruby_package = "Google::Cloud::PhishingProtection::V1beta1"; + +// Service to report phishing URIs. +service PhishingProtectionServiceV1Beta1 { + option (google.api.default_host) = "phishingprotection.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Reports a URI suspected of containing phishing content to be reviewed. Once + // the report review is complete, its result can be found in the Cloud + // Security Command Center findings dashboard for Phishing Protection. If the + // result verifies the existence of malicious phishing content, the site will + // be added the to [Google's Social Engineering + // lists](https://support.google.com/webmasters/answer/6350487/) in order to + // protect users that could get exposed to this threat in the future. + rpc ReportPhishing(ReportPhishingRequest) returns (ReportPhishingResponse) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*}/phishing:report" + body: "*" + }; + option (google.api.method_signature) = "parent,uri"; + } +} + +// The ReportPhishing request message. +message ReportPhishingRequest { + // Required. The name of the project for which the report will be created, + // in the format "projects/{project_number}". + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Required. The URI that is being reported for phishing content to be analyzed. + string uri = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The ReportPhishing (empty) response message. +message ReportPhishingResponse { + +} diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/samples/generated/v1beta1/phishing_protection_service_v1_beta1.report_phishing.js b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/samples/generated/v1beta1/phishing_protection_service_v1_beta1.report_phishing.js new file mode 100644 index 00000000000..0d1b2c7c635 --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/samples/generated/v1beta1/phishing_protection_service_v1_beta1.report_phishing.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(parent, uri) { + // [START phishingprotection_v1beta1_generated_PhishingProtectionServiceV1Beta1_ReportPhishing_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 project for which the report will be created, + * in the format "projects/{project_number}". + */ + // const parent = 'abc123' + /** + * Required. The URI that is being reported for phishing content to be analyzed. + */ + // const uri = 'abc123' + + // Imports the Phishingprotection library + const {PhishingProtectionServiceV1Beta1Client} = require('@google-cloud/phishing-protection').v1beta1; + + // Instantiates a client + const phishingprotectionClient = new PhishingProtectionServiceV1Beta1Client(); + + async function callReportPhishing() { + // Construct request + const request = { + parent, + uri, + }; + + // Run request + const response = await phishingprotectionClient.reportPhishing(request); + console.log(response); + } + + callReportPhishing(); + // [END phishingprotection_v1beta1_generated_PhishingProtectionServiceV1Beta1_ReportPhishing_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.phishingprotection.v1beta1.json b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.phishingprotection.v1beta1.json new file mode 100644 index 00000000000..3b80591f191 --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.phishingprotection.v1beta1.json @@ -0,0 +1,59 @@ +{ + "clientLibrary": { + "name": "nodejs-phishingprotection", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.phishingprotection.v1beta1", + "version": "v1beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "phishingprotection_v1beta1_generated_PhishingProtectionServiceV1Beta1_ReportPhishing_async", + "title": "PhishingProtectionServiceV1Beta1 reportPhishing Sample", + "origin": "API_DEFINITION", + "description": " Reports a URI suspected of containing phishing content to be reviewed. Once the report review is complete, its result can be found in the Cloud Security Command Center findings dashboard for Phishing Protection. If the result verifies the existence of malicious phishing content, the site will be added the to [Google's Social Engineering lists](https://support.google.com/webmasters/answer/6350487/) in order to protect users that could get exposed to this threat in the future.", + "canonical": true, + "file": "phishing_protection_service_v1_beta1.report_phishing.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ReportPhishing", + "fullName": "google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1.ReportPhishing", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "uri", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.phishingprotection.v1beta1.ReportPhishingResponse", + "client": { + "shortName": "PhishingProtectionServiceV1Beta1Client", + "fullName": "google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1Client" + }, + "method": { + "shortName": "ReportPhishing", + "fullName": "google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1.ReportPhishing", + "service": { + "shortName": "PhishingProtectionServiceV1Beta1", + "fullName": "google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/index.ts new file mode 100644 index 00000000000..32cceabcb87 --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1beta1 from './v1beta1'; +const PhishingProtectionServiceV1Beta1Client = v1beta1.PhishingProtectionServiceV1Beta1Client; +type PhishingProtectionServiceV1Beta1Client = v1beta1.PhishingProtectionServiceV1Beta1Client; +export {v1beta1, PhishingProtectionServiceV1Beta1Client}; +export default {v1beta1, PhishingProtectionServiceV1Beta1Client}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/gapic_metadata.json new file mode 100644 index 00000000000..1840cf8dbd5 --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/gapic_metadata.json @@ -0,0 +1,33 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.phishingprotection.v1beta1", + "libraryPackage": "@google-cloud/phishing-protection", + "services": { + "PhishingProtectionServiceV1Beta1": { + "clients": { + "grpc": { + "libraryClient": "PhishingProtectionServiceV1Beta1Client", + "rpcs": { + "ReportPhishing": { + "methods": [ + "reportPhishing" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "PhishingProtectionServiceV1Beta1Client", + "rpcs": { + "ReportPhishing": { + "methods": [ + "reportPhishing" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/index.ts new file mode 100644 index 00000000000..f2c65442af2 --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {PhishingProtectionServiceV1Beta1Client} from './phishing_protection_service_v1_beta1_client'; diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_client.ts b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_client.ts new file mode 100644 index 00000000000..38487d835dd --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_client.ts @@ -0,0 +1,421 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta1/phishing_protection_service_v1_beta1_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './phishing_protection_service_v1_beta1_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service to report phishing URIs. + * @class + * @memberof v1beta1 + */ +export class PhishingProtectionServiceV1Beta1Client { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + phishingProtectionServiceV1Beta1Stub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of PhishingProtectionServiceV1Beta1Client. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 PhishingProtectionServiceV1Beta1Client({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof PhishingProtectionServiceV1Beta1Client; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1', 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.phishingProtectionServiceV1Beta1Stub) { + return this.phishingProtectionServiceV1Beta1Stub; + } + + // Put together the "service stub" for + // google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1. + this.phishingProtectionServiceV1Beta1Stub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1, + 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 phishingProtectionServiceV1Beta1StubMethods = + ['reportPhishing']; + for (const methodName of phishingProtectionServiceV1Beta1StubMethods) { + const callPromise = this.phishingProtectionServiceV1Beta1Stub.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.phishingProtectionServiceV1Beta1Stub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'phishingprotection.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 'phishingprotection.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 -- + // ------------------- +/** + * Reports a URI suspected of containing phishing content to be reviewed. Once + * the report review is complete, its result can be found in the Cloud + * Security Command Center findings dashboard for Phishing Protection. If the + * result verifies the existence of malicious phishing content, the site will + * be added the to [Google's Social Engineering + * lists](https://support.google.com/webmasters/answer/6350487/) in order to + * protect users that could get exposed to this threat in the future. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project for which the report will be created, + * in the format "projects/{project_number}". + * @param {string} request.uri + * Required. The URI that is being reported for phishing content to be analyzed. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.phishingprotection.v1beta1.ReportPhishingResponse|ReportPhishingResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/phishing_protection_service_v1_beta1.report_phishing.js + * region_tag:phishingprotection_v1beta1_generated_PhishingProtectionServiceV1Beta1_ReportPhishing_async + */ + reportPhishing( + request?: protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse, + protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest|undefined, {}|undefined + ]>; + reportPhishing( + request: protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse, + protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest|null|undefined, + {}|null|undefined>): void; + reportPhishing( + request: protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest, + callback: Callback< + protos.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse, + protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest|null|undefined, + {}|null|undefined>): void; + reportPhishing( + request?: protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse, + protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse, + protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse, + protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.reportPhishing(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.phishingProtectionServiceV1Beta1Stub && !this._terminated) { + return this.phishingProtectionServiceV1Beta1Stub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_client_config.json b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_client_config.json new file mode 100644 index 00000000000..44b8db8ab62 --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_client_config.json @@ -0,0 +1,31 @@ +{ + "interfaces": { + "google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1": { + "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": { + "ReportPhishing": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_proto_list.json b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_proto_list.json new file mode 100644 index 00000000000..55a8764d3ea --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/phishingprotection/v1beta1/phishingprotection.proto" +] diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..969b6c48196 --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const phishingprotection = require('@google-cloud/phishing-protection'); + +function main() { + const phishingProtectionServiceV1Beta1Client = new phishingprotection.PhishingProtectionServiceV1Beta1Client(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..a60c7a4ddae --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {PhishingProtectionServiceV1Beta1Client} from '@google-cloud/phishing-protection'; + +// check that the client class type name can be used +function doStuffWithPhishingProtectionServiceV1Beta1Client(client: PhishingProtectionServiceV1Beta1Client) { + client.close(); +} + +function main() { + // check that the client instance can be created + const phishingProtectionServiceV1Beta1Client = new PhishingProtectionServiceV1Beta1Client(); + doStuffWithPhishingProtectionServiceV1Beta1Client(phishingProtectionServiceV1Beta1Client); +} + +main(); diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/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-phishingprotection/v1beta1/test/gapic_phishing_protection_service_v1_beta1_v1beta1.ts b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/test/gapic_phishing_protection_service_v1_beta1_v1beta1.ts new file mode 100644 index 00000000000..e1000c503bf --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/test/gapic_phishing_protection_service_v1_beta1_v1beta1.ts @@ -0,0 +1,291 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 phishingprotectionservicev1beta1Module from '../src'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +describe('v1beta1.PhishingProtectionServiceV1Beta1Client', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.phishingProtectionServiceV1Beta1Stub, undefined); + await client.initialize(); + assert(client.phishingProtectionServiceV1Beta1Stub); + }); + + it('has close method for the initialized client', done => { + const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.phishingProtectionServiceV1Beta1Stub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.phishingProtectionServiceV1Beta1Stub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ + 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 phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ + 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('reportPhishing', () => { + it('invokes reportPhishing without error', async () => { + const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.phishingprotection.v1beta1.ReportPhishingRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.phishingprotection.v1beta1.ReportPhishingRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.phishingprotection.v1beta1.ReportPhishingResponse() + ); + client.innerApiCalls.reportPhishing = stubSimpleCall(expectedResponse); + const [response] = await client.reportPhishing(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.reportPhishing as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reportPhishing as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reportPhishing without error using callback', async () => { + const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.phishingprotection.v1beta1.ReportPhishingRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.phishingprotection.v1beta1.ReportPhishingRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.phishingprotection.v1beta1.ReportPhishingResponse() + ); + client.innerApiCalls.reportPhishing = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.reportPhishing( + request, + (err?: Error|null, result?: protos.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.reportPhishing as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reportPhishing as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reportPhishing with error', async () => { + const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.phishingprotection.v1beta1.ReportPhishingRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.phishingprotection.v1beta1.ReportPhishingRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reportPhishing = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.reportPhishing(request), expectedError); + const actualRequest = (client.innerApiCalls.reportPhishing as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reportPhishing as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reportPhishing with closed client', async () => { + const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.phishingprotection.v1beta1.ReportPhishingRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.phishingprotection.v1beta1.ReportPhishingRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.reportPhishing(request), expectedError); + }); + }); + + describe('Path templates', () => { + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/webpack.config.js new file mode 100644 index 00000000000..e3f8ac35c5f --- /dev/null +++ b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'PhishingProtectionServiceV1Beta1', + filename: './phishing-protection-service-v1-beta1.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-policytroubleshooter-iam/v3/.eslintignore b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.eslintrc.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.gitignore b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.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-policytroubleshooter-iam/v3/.jsdoc.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.jsdoc.js new file mode 100644 index 00000000000..cdc66248f75 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.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/iam', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.mocharc.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.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-policytroubleshooter-iam/v3/.prettierrc.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.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-policytroubleshooter-iam/v3/README.md b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/README.md new file mode 100644 index 00000000000..905fae6bcad --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/README.md @@ -0,0 +1 @@ +Iam: Nodejs Client diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/package.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/package.json new file mode 100644 index 00000000000..050b00ab47e --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/package.json @@ -0,0 +1,59 @@ +{ + "name": "@google-cloud/iam", + "version": "0.1.0", + "description": "Iam client for Node.js", + "repository": "googleapis/nodejs-iam", + "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 iam", + "iam", + "policies", + "policy troubleshooter" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/protos/google/cloud/policytroubleshooter/iam/v3/troubleshooter.proto b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/protos/google/cloud/policytroubleshooter/iam/v3/troubleshooter.proto new file mode 100644 index 00000000000..6a2928b1d55 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/protos/google/cloud/policytroubleshooter/iam/v3/troubleshooter.proto @@ -0,0 +1,757 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.policytroubleshooter.iam.v3; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/iam/v1/policy.proto"; +import "google/iam/v2/policy.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/expr.proto"; + +option cc_enable_arenas = true; +option csharp_namespace = "Google.Cloud.PolicyTroubleshooter.Iam.V3"; +option go_package = "cloud.google.com/go/policytroubleshooter/iam/apiv3/iampb;iampb"; +option java_multiple_files = true; +option java_outer_classname = "TroubleshooterProto"; +option java_package = "com.google.cloud.policytroubleshooter.iam.v3"; +option php_namespace = "Google\\Cloud\\PolicyTroubleshooter\\Iam\\V3"; +option ruby_package = "Google::Cloud::PolicyTroubleshooter::Iam::V3"; + +// IAM Policy Troubleshooter service. +// +// This service helps you troubleshoot access issues for Google Cloud resources. +service PolicyTroubleshooter { + option (google.api.default_host) = "policytroubleshooter.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Checks whether a principal has a specific permission for a specific + // resource, and explains why the principal does or doesn't have that + // permission. + rpc TroubleshootIamPolicy(TroubleshootIamPolicyRequest) + returns (TroubleshootIamPolicyResponse) { + option (google.api.http) = { + post: "/v3/iam:troubleshoot" + body: "*" + }; + } +} + +// Whether IAM allow policies gives the principal the permission. +enum AllowAccessState { + // Not specified. + ALLOW_ACCESS_STATE_UNSPECIFIED = 0; + + // The allow policy gives the principal the permission. + ALLOW_ACCESS_STATE_GRANTED = 1; + + // The allow policy doesn't give the principal the permission. + ALLOW_ACCESS_STATE_NOT_GRANTED = 2; + + // The allow policy gives the principal the permission if a condition + // expression evaluate to `true`. However, the sender of the request didn't + // provide enough context for Policy Troubleshooter to evaluate the condition + // expression. + ALLOW_ACCESS_STATE_UNKNOWN_CONDITIONAL = 3; + + // The sender of the request doesn't have access to all of the allow policies + // that Policy Troubleshooter needs to evaluate the principal's access. + ALLOW_ACCESS_STATE_UNKNOWN_INFO = 4; +} + +// Whether IAM deny policies deny the principal the permission. +enum DenyAccessState { + // Not specified. + DENY_ACCESS_STATE_UNSPECIFIED = 0; + + // The deny policy denies the principal the permission. + DENY_ACCESS_STATE_DENIED = 1; + + // The deny policy doesn't deny the principal the permission. + DENY_ACCESS_STATE_NOT_DENIED = 2; + + // The deny policy denies the principal the permission if a condition + // expression evaluates to `true`. However, the sender of the request didn't + // provide enough context for Policy Troubleshooter to evaluate the condition + // expression. + DENY_ACCESS_STATE_UNKNOWN_CONDITIONAL = 3; + + // The sender of the request does not have access to all of the deny policies + // that Policy Troubleshooter needs to evaluate the principal's access. + DENY_ACCESS_STATE_UNKNOWN_INFO = 4; +} + +// Whether a role includes a specific permission. +enum RolePermissionInclusionState { + // Not specified. + ROLE_PERMISSION_INCLUSION_STATE_UNSPECIFIED = 0; + + // The permission is included in the role. + ROLE_PERMISSION_INCLUDED = 1; + + // The permission is not included in the role. + ROLE_PERMISSION_NOT_INCLUDED = 2; + + // The sender of the request is not allowed to access the role definition. + ROLE_PERMISSION_UNKNOWN_INFO = 3; +} + +// Whether the permission in the request matches the permission in the policy. +enum PermissionPatternMatchingState { + // Not specified. + PERMISSION_PATTERN_MATCHING_STATE_UNSPECIFIED = 0; + + // The permission in the request matches the permission in the policy. + PERMISSION_PATTERN_MATCHED = 1; + + // The permission in the request matches the permission in the policy. + PERMISSION_PATTERN_NOT_MATCHED = 2; +} + +// Whether the principal in the request matches the principal in the policy. +enum MembershipMatchingState { + // Not specified. + MEMBERSHIP_MATCHING_STATE_UNSPECIFIED = 0; + + // The principal in the request matches the principal in the policy. The + // principal can be included directly or indirectly: + // + // * A principal is included directly if that principal is listed in the + // role binding. + // * A principal is included indirectly if that principal is in a Google + // group, Google Workspace account, or Cloud Identity domain that is listed + // in the policy. + MEMBERSHIP_MATCHED = 1; + + // The principal in the request doesn't match the principal in the policy. + MEMBERSHIP_NOT_MATCHED = 2; + + // The principal in the policy is a group or domain, and the sender of the + // request doesn't have permission to view whether the principal in the + // request is a member of the group or domain. + MEMBERSHIP_UNKNOWN_INFO = 3; + + // The principal is an unsupported type. + MEMBERSHIP_UNKNOWN_UNSUPPORTED = 4; +} + +// The extent to which a single data point contributes to an overall +// determination. +enum HeuristicRelevance { + // Not specified. + HEURISTIC_RELEVANCE_UNSPECIFIED = 0; + + // The data point has a limited effect on the result. Changing the data point + // is unlikely to affect the overall determination. + HEURISTIC_RELEVANCE_NORMAL = 1; + + // The data point has a strong effect on the result. Changing the data point + // is likely to affect the overall determination. + HEURISTIC_RELEVANCE_HIGH = 2; +} + +// Request for +// [TroubleshootIamPolicy][google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter.TroubleshootIamPolicy]. +message TroubleshootIamPolicyRequest { + // The information to use for checking whether a principal has a permission + // for a resource. + AccessTuple access_tuple = 1; +} + +// Response for +// [TroubleshootIamPolicy][google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter.TroubleshootIamPolicy]. +message TroubleshootIamPolicyResponse { + // Whether the principal has the permission on the resource. + enum OverallAccessState { + // Not specified. + OVERALL_ACCESS_STATE_UNSPECIFIED = 0; + + // The principal has the permission. + CAN_ACCESS = 1; + + // The principal doesn't have the permission. + CANNOT_ACCESS = 2; + + // The principal might have the permission, but the sender can't access all + // of the information needed to fully evaluate the principal's access. + UNKNOWN_INFO = 3; + + // The principal might have the permission, but Policy Troubleshooter can't + // fully evaluate the principal's access because the sender didn't provide + // the required context to evaluate the condition. + UNKNOWN_CONDITIONAL = 4; + } + + // Indicates whether the principal has the specified permission for the + // specified resource, based on evaluating all types of the applicable IAM + // policies. + OverallAccessState overall_access_state = 1; + + // The access tuple from the request, including any provided context used to + // evaluate the condition. + AccessTuple access_tuple = 2; + + // An explanation of how the applicable IAM allow policies affect the final + // access state. + AllowPolicyExplanation allow_policy_explanation = 3; + + // An explanation of how the applicable IAM deny policies affect the final + // access state. + DenyPolicyExplanation deny_policy_explanation = 4; +} + +// Information about the principal, resource, and permission to check. +message AccessTuple { + // Required. The email address of the principal whose access you want to + // check. For example, `alice@example.com` or + // `my-service-account@my-project.iam.gserviceaccount.com`. + // + // The principal must be a Google Account or a service account. Other types of + // principals are not supported. + string principal = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The full resource name that identifies the resource. For example, + // `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`. + // + // For examples of full resource names for Google Cloud services, see + // https://cloud.google.com/iam/help/troubleshooter/full-resource-names. + string full_resource_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The IAM permission to check for, either in the `v1` permission + // format or the `v2` permission format. + // + // For a complete list of IAM permissions in the `v1` format, see + // https://cloud.google.com/iam/help/permissions/reference. + // + // For a list of IAM permissions in the `v2` format, see + // https://cloud.google.com/iam/help/deny/supported-permissions. + // + // For a complete list of predefined IAM roles and the permissions in each + // role, see https://cloud.google.com/iam/help/roles/reference. + string permission = 3 [(google.api.field_behavior) = REQUIRED]; + + // Output only. The permission that Policy Troubleshooter checked for, in + // the `v2` format. + string permission_fqdn = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Additional context for the request, such as the request time or + // IP address. This context allows Policy Troubleshooter to troubleshoot + // conditional role bindings and deny rules. + ConditionContext condition_context = 5 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Additional context for troubleshooting conditional role bindings and deny +// rules. +message ConditionContext { + // Core attributes for a resource. A resource is an + // addressable (named) entity provided by the destination service. For + // example, a Compute Engine instance. + message Resource { + // The name of the service that this resource belongs to, such as + // `compute.googleapis.com`. The service name might not match the DNS + // hostname that actually serves the request. + // + // For a full list of resource service values, see + // https://cloud.google.com/iam/help/conditions/resource-services + string service = 1; + + // The stable identifier (name) of a resource on the `service`. A resource + // can be logically identified as `//{resource.service}/{resource.name}`. + // Unlike the resource URI, the resource name doesn't contain any protocol + // and version information. + // + // For a list of full resource name formats, see + // https://cloud.google.com/iam/help/troubleshooter/full-resource-names + string name = 2; + + // The type of the resource, in the format `{service}/{kind}`. + // + // For a full list of resource type values, see + // https://cloud.google.com/iam/help/conditions/resource-types + string type = 3; + } + + // This message defines attributes for a node that handles a network request. + // The node can be either a service or an application that sends, forwards, + // or receives the request. Service peers should fill in + // `principal` and `labels` as appropriate. + message Peer { + // The IPv4 or IPv6 address of the peer. + string ip = 1; + + // The network port of the peer. + int64 port = 2; + } + + // This message defines attributes for an HTTP request. If the actual + // request is not an HTTP request, the runtime system should try to map + // the actual request to an equivalent HTTP request. + message Request { + // Optional. The timestamp when the destination service receives the first + // byte of the request. + google.protobuf.Timestamp receive_time = 1 + [(google.api.field_behavior) = OPTIONAL]; + } + + // A tag that applies to a resource during policy evaluation. Tags can be + // either directly bound to a resource or inherited from its ancestor. + // `EffectiveTag` contains the `name` and `namespaced_name` of the tag value + // and tag key, with additional fields of `inherited` to indicate the + // inheritance status of the effective tag. + message EffectiveTag { + // Output only. Resource name for TagValue in the format `tagValues/456`. + string tag_value = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The namespaced name of the TagValue. Can be in the form + // `{organization_id}/{tag_key_short_name}/{tag_value_short_name}` or + // `{project_id}/{tag_key_short_name}/{tag_value_short_name}` or + // `{project_number}/{tag_key_short_name}/{tag_value_short_name}`. + string namespaced_tag_value = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The name of the TagKey, in the format `tagKeys/{id}`, such + // as `tagKeys/123`. + string tag_key = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The namespaced name of the TagKey. Can be in the form + // `{organization_id}/{tag_key_short_name}` or + // `{project_id}/{tag_key_short_name}` or + // `{project_number}/{tag_key_short_name}`. + string namespaced_tag_key = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The parent name of the tag key. + // Must be in the format `organizations/{organization_id}` or + // `projects/{project_number}` + string tag_key_parent_name = 6; + + // Output only. Indicates the inheritance status of a tag value + // attached to the given resource. If the tag value is inherited from one of + // the resource's ancestors, inherited will be true. If false, then the tag + // value is directly attached to the resource, inherited will be false. + bool inherited = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + } + + // Represents a target resource that is involved with a network activity. + // If multiple resources are involved with an activity, this must be the + // primary one. + Resource resource = 1; + + // The destination of a network activity, such as accepting a TCP connection. + // In a multi-hop network activity, the destination represents the receiver of + // the last hop. + Peer destination = 2; + + // Represents a network request, such as an HTTP request. + Request request = 3; + + // Output only. The effective tags on the resource. The effective tags are + // fetched during troubleshooting. + repeated EffectiveTag effective_tags = 4 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Details about how the relevant IAM allow policies affect the final access +// state. +message AllowPolicyExplanation { + // Indicates whether the principal has the specified permission for the + // specified resource, based on evaluating all applicable IAM allow policies. + AllowAccessState allow_access_state = 1; + + // List of IAM allow policies that were evaluated to check the principal's + // permissions, with annotations to indicate how each policy contributed to + // the final result. + // + // The list of policies includes the policy for the resource itself, as well + // as allow policies that are inherited from higher levels of the resource + // hierarchy, including the organization, the folder, and the project. + // + // To learn more about the resource hierarchy, see + // https://cloud.google.com/iam/help/resource-hierarchy. + repeated ExplainedAllowPolicy explained_policies = 2; + + // The relevance of the allow policy type to the overall access state. + HeuristicRelevance relevance = 3; +} + +// Details about how a specific IAM allow policy contributed to the final access +// state. +message ExplainedAllowPolicy { + // Required. Indicates whether _this policy_ provides the specified permission + // to the specified principal for the specified resource. + // + // This field does _not_ indicate whether the principal actually has the + // permission for the resource. There might be another policy that overrides + // this policy. To determine whether the principal actually has the + // permission, use the `overall_access_state` field in the + // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse]. + AllowAccessState allow_access_state = 1 + [(google.api.field_behavior) = REQUIRED]; + + // The full resource name that identifies the resource. For example, + // `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`. + // + // If the sender of the request does not have access to the policy, this field + // is omitted. + // + // For examples of full resource names for Google Cloud services, see + // https://cloud.google.com/iam/help/troubleshooter/full-resource-names. + string full_resource_name = 2; + + // Details about how each role binding in the policy affects the principal's + // ability, or inability, to use the permission for the resource. The order of + // the role bindings matches the role binding order in the policy. + // + // If the sender of the request does not have access to the policy, this field + // is omitted. + repeated AllowBindingExplanation binding_explanations = 3; + + // The relevance of this policy to the overall access state in the + // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse]. + // + // If the sender of the request does not have access to the policy, this field + // is omitted. + HeuristicRelevance relevance = 4; + + // The IAM allow policy attached to the resource. + // + // If the sender of the request does not have access to the policy, this field + // is empty. + google.iam.v1.Policy policy = 5; +} + +// Details about how a role binding in an allow policy affects a principal's +// ability to use a permission. +message AllowBindingExplanation { + // Details about whether the role binding includes the principal. + message AnnotatedAllowMembership { + // Indicates whether the role binding includes the principal. + MembershipMatchingState membership = 1; + + // The relevance of the principal's status to the overall determination for + // the role binding. + HeuristicRelevance relevance = 2; + } + + // Required. Indicates whether _this role binding_ gives the specified + // permission to the specified principal on the specified resource. + // + // This field does _not_ indicate whether the principal actually has the + // permission on the resource. There might be another role binding that + // overrides this role binding. To determine whether the principal actually + // has the permission, use the `overall_access_state` field in the + // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse]. + AllowAccessState allow_access_state = 1 + [(google.api.field_behavior) = REQUIRED]; + + // The role that this role binding grants. For example, + // `roles/compute.admin`. + // + // For a complete list of predefined IAM roles, as well as the permissions in + // each role, see https://cloud.google.com/iam/help/roles/reference. + string role = 2; + + // Indicates whether the role granted by this role binding contains the + // specified permission. + RolePermissionInclusionState role_permission = 3; + + // The relevance of the permission's existence, or nonexistence, in the role + // to the overall determination for the entire policy. + HeuristicRelevance role_permission_relevance = 4; + + // The combined result of all memberships. Indicates if the principal is + // included in any role binding, either directly or indirectly. + AnnotatedAllowMembership combined_membership = 5; + + // Indicates whether each role binding includes the principal specified in the + // request, either directly or indirectly. Each key identifies a principal in + // the role binding, and each value indicates whether the principal in the + // role binding includes the principal in the request. + // + // For example, suppose that a role binding includes the following principals: + // + // * `user:alice@example.com` + // * `group:product-eng@example.com` + // + // You want to troubleshoot access for `user:bob@example.com`. This user is a + // member of the group `group:product-eng@example.com`. + // + // For the first principal in the role binding, the key is + // `user:alice@example.com`, and the `membership` field in the value is set to + // `NOT_INCLUDED`. + // + // For the second principal in the role binding, the key is + // `group:product-eng@example.com`, and the `membership` field in the value is + // set to `INCLUDED`. + map memberships = 6; + + // The relevance of this role binding to the overall determination for the + // entire policy. + HeuristicRelevance relevance = 7; + + // A condition expression that specifies when the role binding grants access. + // + // To learn about IAM Conditions, see + // https://cloud.google.com/iam/help/conditions/overview. + google.type.Expr condition = 8; + + // Condition evaluation state for this role binding. + ConditionExplanation condition_explanation = 9; +} + +// Details about how the relevant IAM deny policies affect the final access +// state. +message DenyPolicyExplanation { + // Indicates whether the principal is denied the specified permission for + // the specified resource, based on evaluating all applicable IAM deny + // policies. + DenyAccessState deny_access_state = 1; + + // List of resources with IAM deny policies that were evaluated to check the + // principal's denied permissions, with annotations to indicate how each + // policy contributed to the final result. + // + // The list of resources includes the policy for the resource itself, as well + // as policies that are inherited from higher levels of the resource + // hierarchy, including the organization, the folder, and the project. The + // order of the resources starts from the resource and climbs up the resource + // hierarchy. + // + // To learn more about the resource hierarchy, see + // https://cloud.google.com/iam/help/resource-hierarchy. + repeated ExplainedDenyResource explained_resources = 2; + + // The relevance of the deny policy result to the overall access state. + HeuristicRelevance relevance = 3; + + // Indicates whether the permission to troubleshoot is supported in deny + // policies. + bool permission_deniable = 4; +} + +// Details about how a specific resource contributed to the deny policy +// evaluation. +message ExplainedDenyResource { + // Required. Indicates whether any policies attached to _this resource_ deny + // the specific permission to the specified principal for the specified + // resource. + // + // This field does _not_ indicate whether the principal actually has the + // permission for the resource. There might be another policy that overrides + // this policy. To determine whether the principal actually has the + // permission, use the `overall_access_state` field in the + // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse]. + DenyAccessState deny_access_state = 1 + [(google.api.field_behavior) = REQUIRED]; + + // The full resource name that identifies the resource. For example, + // `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`. + // + // If the sender of the request does not have access to the policy, this field + // is omitted. + // + // For examples of full resource names for Google Cloud services, see + // https://cloud.google.com/iam/help/troubleshooter/full-resource-names. + string full_resource_name = 2; + + // List of IAM deny policies that were evaluated to check the principal's + // denied permissions, with annotations to indicate how each policy + // contributed to the final result. + repeated ExplainedDenyPolicy explained_policies = 3; + + // The relevance of this policy to the overall access state in the + // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse]. + // + // If the sender of the request does not have access to the policy, this field + // is omitted. + HeuristicRelevance relevance = 4; +} + +// Details about how a specific IAM deny policy [Policy][google.iam.v2.Policy] +// contributed to the access check. +message ExplainedDenyPolicy { + // Required. Indicates whether _this policy_ denies the specified permission + // to the specified principal for the specified resource. + // + // This field does _not_ indicate whether the principal actually has the + // permission for the resource. There might be another policy that overrides + // this policy. To determine whether the principal actually has the + // permission, use the `overall_access_state` field in the + // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse]. + DenyAccessState deny_access_state = 1 + [(google.api.field_behavior) = REQUIRED]; + + // The IAM deny policy attached to the resource. + // + // If the sender of the request does not have access to the policy, this field + // is omitted. + google.iam.v2.Policy policy = 2; + + // Details about how each rule in the policy affects the principal's inability + // to use the permission for the resource. The order of the deny rule matches + // the order of the rules in the deny policy. + // + // If the sender of the request does not have access to the policy, this field + // is omitted. + repeated DenyRuleExplanation rule_explanations = 3; + + // The relevance of this policy to the overall access state in the + // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse]. + // + // If the sender of the request does not have access to the policy, this field + // is omitted. + HeuristicRelevance relevance = 4; +} + +// Details about how a deny rule in a deny policy affects a principal's ability +// to use a permission. +message DenyRuleExplanation { + // Details about whether the permission in the request is denied by the + // deny rule. + message AnnotatedPermissionMatching { + // Indicates whether the permission in the request is denied by the deny + // rule. + PermissionPatternMatchingState permission_matching_state = 1; + + // The relevance of the permission status to the overall determination for + // the rule. + HeuristicRelevance relevance = 2; + } + + // Details about whether the principal in the request is listed as a denied + // principal in the deny rule, either directly or through membership in a + // principal set. + message AnnotatedDenyPrincipalMatching { + // Indicates whether the principal is listed as a denied principal in the + // deny rule, either directly or through membership in a principal set. + MembershipMatchingState membership = 1; + + // The relevance of the principal's status to the overall determination for + // the role binding. + HeuristicRelevance relevance = 2; + } + + // Required. Indicates whether _this rule_ denies the specified permission to + // the specified principal for the specified resource. + // + // This field does _not_ indicate whether the principal is actually denied on + // the permission for the resource. There might be another rule that overrides + // this rule. To determine whether the principal actually has the permission, + // use the `overall_access_state` field in the + // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse]. + DenyAccessState deny_access_state = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates whether the permission in the request is listed as a denied + // permission in the deny rule. + AnnotatedPermissionMatching combined_denied_permission = 2; + + // Lists all denied permissions in the deny rule and indicates whether each + // permission matches the permission in the request. + // + // Each key identifies a denied permission in the rule, and each value + // indicates whether the denied permission matches the permission in the + // request. + map denied_permissions = 3; + + // Indicates whether the permission in the request is listed as an exception + // permission in the deny rule. + AnnotatedPermissionMatching combined_exception_permission = 4; + + // Lists all exception permissions in the deny rule and indicates whether each + // permission matches the permission in the request. + // + // Each key identifies a exception permission in the rule, and each value + // indicates whether the exception permission matches the permission in the + // request. + map exception_permissions = 5; + + // Indicates whether the principal is listed as a denied principal in the + // deny rule, either directly or through membership in a principal set. + AnnotatedDenyPrincipalMatching combined_denied_principal = 6; + + // Lists all denied principals in the deny rule and indicates whether each + // principal matches the principal in the request, either directly or through + // membership in a principal set. + // + // Each key identifies a denied principal in the rule, and each value + // indicates whether the denied principal matches the principal in the + // request. + map denied_principals = 7; + + // Indicates whether the principal is listed as an exception principal in the + // deny rule, either directly or through membership in a principal set. + AnnotatedDenyPrincipalMatching combined_exception_principal = 8; + + // Lists all exception principals in the deny rule and indicates whether each + // principal matches the principal in the request, either directly or through + // membership in a principal set. + // + // Each key identifies a exception principal in the rule, and each value + // indicates whether the exception principal matches the principal in the + // request. + map exception_principals = 9; + + // The relevance of this role binding to the overall determination for the + // entire policy. + HeuristicRelevance relevance = 10; + + // A condition expression that specifies when the deny rule denies the + // principal access. + // + // To learn about IAM Conditions, see + // https://cloud.google.com/iam/help/conditions/overview. + google.type.Expr condition = 11; + + // Condition evaluation state for this role binding. + ConditionExplanation condition_explanation = 12; +} + +// Explanation for how a condition affects a principal's access +message ConditionExplanation { + // Evaluated state of a condition expression. + message EvaluationState { + // Start position of an expression in the condition, by character. + int32 start = 1; + + // End position of an expression in the condition, by character, + // end included, for example: the end position of the first part of + // `a==b || c==d` would be 4. + int32 end = 2; + + // Value of this expression. + google.protobuf.Value value = 3; + + // Any errors that prevented complete evaluation of the condition + // expression. + repeated google.rpc.Status errors = 4; + } + + // Value of the condition. + google.protobuf.Value value = 1; + + // Any errors that prevented complete evaluation of the condition expression. + repeated google.rpc.Status errors = 3; + + // The value of each statement of the condition expression. The value can be + // `true`, `false`, or `null`. The value is `null` if the statement can't be + // evaluated. + repeated EvaluationState evaluation_states = 2; +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/samples/generated/v3/policy_troubleshooter.troubleshoot_iam_policy.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/samples/generated/v3/policy_troubleshooter.troubleshoot_iam_policy.js new file mode 100644 index 00000000000..d8808bed570 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/samples/generated/v3/policy_troubleshooter.troubleshoot_iam_policy.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 policytroubleshooter_v3_generated_PolicyTroubleshooter_TroubleshootIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 information to use for checking whether a principal has a permission + * for a resource. + */ + // const accessTuple = {} + + // Imports the Iam library + const {PolicyTroubleshooterClient} = require('@google-cloud/iam').v3; + + // Instantiates a client + const iamClient = new PolicyTroubleshooterClient(); + + async function callTroubleshootIamPolicy() { + // Construct request + const request = { + }; + + // Run request + const response = await iamClient.troubleshootIamPolicy(request); + console.log(response); + } + + callTroubleshootIamPolicy(); + // [END policytroubleshooter_v3_generated_PolicyTroubleshooter_TroubleshootIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/samples/generated/v3/snippet_metadata_google.cloud.policytroubleshooter.iam.v3.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/samples/generated/v3/snippet_metadata_google.cloud.policytroubleshooter.iam.v3.json new file mode 100644 index 00000000000..a15c84dda60 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/samples/generated/v3/snippet_metadata_google.cloud.policytroubleshooter.iam.v3.json @@ -0,0 +1,55 @@ +{ + "clientLibrary": { + "name": "nodejs-iam", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.policytroubleshooter.iam.v3", + "version": "v3" + } + ] + }, + "snippets": [ + { + "regionTag": "policytroubleshooter_v3_generated_PolicyTroubleshooter_TroubleshootIamPolicy_async", + "title": "Policies troubleshootIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Checks whether a principal has a specific permission for a specific resource, and explains why the principal does or doesn't have that permission.", + "canonical": true, + "file": "policy_troubleshooter.troubleshoot_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TroubleshootIamPolicy", + "fullName": "google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter.TroubleshootIamPolicy", + "async": true, + "parameters": [ + { + "name": "access_tuple", + "type": ".google.cloud.policytroubleshooter.iam.v3.AccessTuple" + } + ], + "resultType": ".google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse", + "client": { + "shortName": "PolicyTroubleshooterClient", + "fullName": "google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooterClient" + }, + "method": { + "shortName": "TroubleshootIamPolicy", + "fullName": "google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter.TroubleshootIamPolicy", + "service": { + "shortName": "PolicyTroubleshooter", + "fullName": "google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/index.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/index.ts new file mode 100644 index 00000000000..a50d76fcacd --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v3 from './v3'; +const PolicyTroubleshooterClient = v3.PolicyTroubleshooterClient; +type PolicyTroubleshooterClient = v3.PolicyTroubleshooterClient; +export {v3, PolicyTroubleshooterClient}; +export default {v3, PolicyTroubleshooterClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/gapic_metadata.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/gapic_metadata.json new file mode 100644 index 00000000000..2b25fe850a6 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/gapic_metadata.json @@ -0,0 +1,33 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.policytroubleshooter.iam.v3", + "libraryPackage": "@google-cloud/iam", + "services": { + "PolicyTroubleshooter": { + "clients": { + "grpc": { + "libraryClient": "PolicyTroubleshooterClient", + "rpcs": { + "TroubleshootIamPolicy": { + "methods": [ + "troubleshootIamPolicy" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "PolicyTroubleshooterClient", + "rpcs": { + "TroubleshootIamPolicy": { + "methods": [ + "troubleshootIamPolicy" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/index.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/index.ts new file mode 100644 index 00000000000..cb1bab0ce55 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {PolicyTroubleshooterClient} from './policy_troubleshooter_client'; diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_client.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_client.ts new file mode 100644 index 00000000000..4df8f58dce0 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_client.ts @@ -0,0 +1,376 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v3/policy_troubleshooter_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './policy_troubleshooter_client_config.json'; +const version = require('../../../package.json').version; + +/** + * IAM Policy Troubleshooter service. + * + * This service helps you troubleshoot access issues for Google Cloud resources. + * @class + * @memberof v3 + */ +export class PolicyTroubleshooterClient { + 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}; + policyTroubleshooterStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of PolicyTroubleshooterClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 PolicyTroubleshooterClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof PolicyTroubleshooterClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter', 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.policyTroubleshooterStub) { + return this.policyTroubleshooterStub; + } + + // Put together the "service stub" for + // google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter. + this.policyTroubleshooterStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter, + 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 policyTroubleshooterStubMethods = + ['troubleshootIamPolicy']; + for (const methodName of policyTroubleshooterStubMethods) { + const callPromise = this.policyTroubleshooterStub.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.policyTroubleshooterStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'policytroubleshooter.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 'policytroubleshooter.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 -- + // ------------------- +/** + * Checks whether a principal has a specific permission for a specific + * resource, and explains why the principal does or doesn't have that + * permission. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.policytroubleshooter.iam.v3.AccessTuple} request.accessTuple + * The information to use for checking whether a principal has a permission + * for a resource. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse|TroubleshootIamPolicyResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/policy_troubleshooter.troubleshoot_iam_policy.js + * region_tag:policytroubleshooter_v3_generated_PolicyTroubleshooter_TroubleshootIamPolicy_async + */ + troubleshootIamPolicy( + request?: protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyResponse, + protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyRequest|undefined, {}|undefined + ]>; + troubleshootIamPolicy( + request: protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyResponse, + protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + troubleshootIamPolicy( + request: protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyRequest, + callback: Callback< + protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyResponse, + protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + troubleshootIamPolicy( + request?: protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyResponse, + protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyResponse, + protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyResponse, + protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.troubleshootIamPolicy(request, options, callback); + } + + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.policyTroubleshooterStub && !this._terminated) { + return this.policyTroubleshooterStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_client_config.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_client_config.json new file mode 100644 index 00000000000..d181f4c282f --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_client_config.json @@ -0,0 +1,43 @@ +{ + "interfaces": { + "google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "TroubleshootIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_proto_list.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_proto_list.json new file mode 100644 index 00000000000..175cedf9925 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_proto_list.json @@ -0,0 +1,4 @@ +[ + "../../protos/google/cloud/policytroubleshooter/iam/v3/troubleshooter.proto", + "../../protos/google/iam/v2/deny.proto" +] diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..74397918dca --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const iam = require('@google-cloud/iam'); + +function main() { + const policyTroubleshooterClient = new iam.PolicyTroubleshooterClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..14de8f1de24 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {PolicyTroubleshooterClient} from '@google-cloud/iam'; + +// check that the client class type name can be used +function doStuffWithPolicyTroubleshooterClient(client: PolicyTroubleshooterClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const policyTroubleshooterClient = new PolicyTroubleshooterClient(); + doStuffWithPolicyTroubleshooterClient(policyTroubleshooterClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/install.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/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-policytroubleshooter-iam/v3/test/gapic_policy_troubleshooter_v3.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/test/gapic_policy_troubleshooter_v3.ts new file mode 100644 index 00000000000..ef1b568e11b --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/test/gapic_policy_troubleshooter_v3.ts @@ -0,0 +1,225 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 policytroubleshooterModule from '../src'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +describe('v3.PolicyTroubleshooterClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = policytroubleshooterModule.v3.PolicyTroubleshooterClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = policytroubleshooterModule.v3.PolicyTroubleshooterClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = policytroubleshooterModule.v3.PolicyTroubleshooterClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new policytroubleshooterModule.v3.PolicyTroubleshooterClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new policytroubleshooterModule.v3.PolicyTroubleshooterClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new policytroubleshooterModule.v3.PolicyTroubleshooterClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.policyTroubleshooterStub, undefined); + await client.initialize(); + assert(client.policyTroubleshooterStub); + }); + + it('has close method for the initialized client', done => { + const client = new policytroubleshooterModule.v3.PolicyTroubleshooterClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.policyTroubleshooterStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new policytroubleshooterModule.v3.PolicyTroubleshooterClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.policyTroubleshooterStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new policytroubleshooterModule.v3.PolicyTroubleshooterClient({ + 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 policytroubleshooterModule.v3.PolicyTroubleshooterClient({ + 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('troubleshootIamPolicy', () => { + it('invokes troubleshootIamPolicy without error', async () => { + const client = new policytroubleshooterModule.v3.PolicyTroubleshooterClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse() + ); + client.innerApiCalls.troubleshootIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.troubleshootIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes troubleshootIamPolicy without error using callback', async () => { + const client = new policytroubleshooterModule.v3.PolicyTroubleshooterClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse() + ); + client.innerApiCalls.troubleshootIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.troubleshootIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes troubleshootIamPolicy with error', async () => { + const client = new policytroubleshooterModule.v3.PolicyTroubleshooterClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.troubleshootIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.troubleshootIamPolicy(request), expectedError); + }); + + it('invokes troubleshootIamPolicy with closed client', async () => { + const client = new policytroubleshooterModule.v3.PolicyTroubleshooterClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.troubleshootIamPolicy(request), expectedError); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/tsconfig.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/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-policytroubleshooter-iam/v3/webpack.config.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/webpack.config.js new file mode 100644 index 00000000000..f423e0d5294 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/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: 'Policies', + filename: './policies.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-policytroubleshooter-iam/v3beta/.eslintignore b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.eslintrc.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.gitignore b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.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-policytroubleshooter-iam/v3beta/.jsdoc.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.jsdoc.js new file mode 100644 index 00000000000..ead6a1300bd --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.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/policy-troubleshooter-iam', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.mocharc.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.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-policytroubleshooter-iam/v3beta/.prettierrc.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.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-policytroubleshooter-iam/v3beta/README.md b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/README.md new file mode 100644 index 00000000000..905fae6bcad --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/README.md @@ -0,0 +1 @@ +Iam: Nodejs Client diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/package.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/package.json new file mode 100644 index 00000000000..d4dacb27b30 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/package.json @@ -0,0 +1,59 @@ +{ + "name": "@google-cloud/policy-troubleshooter-iam", + "version": "0.1.0", + "description": "Iam client for Node.js", + "repository": "googleapis/nodejs-iam", + "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 iam", + "iam", + "policies", + "policy troubleshooter" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/cloud/policytroubleshooter/iam/v3beta/troubleshooter.proto b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/cloud/policytroubleshooter/iam/v3beta/troubleshooter.proto new file mode 100644 index 00000000000..2d4c9429a14 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/cloud/policytroubleshooter/iam/v3beta/troubleshooter.proto @@ -0,0 +1,754 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.policytroubleshooter.iam.v3beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/iam/v1/policy.proto"; +import "google/iam/v2/policy.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/expr.proto"; + +option cc_enable_arenas = true; +option go_package = "cloud.google.com/go/policytroubleshooter/iam/apiv3beta/iampb;iampb"; +option java_multiple_files = true; +option java_outer_classname = "TroubleshooterProto"; +option java_package = "com.google.cloud.policytroubleshooter.iam.v3beta"; + +// IAM Policy Troubleshooter service. +// +// This service helps you troubleshoot access issues for Google Cloud resources. +service PolicyTroubleshooter { + option (google.api.default_host) = "policytroubleshooter.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Checks whether a principal has a specific permission for a specific + // resource, and explains why the principal does or doesn't have that + // permission. + rpc TroubleshootIamPolicy(TroubleshootIamPolicyRequest) + returns (TroubleshootIamPolicyResponse) { + option (google.api.http) = { + post: "/v3beta/iam:troubleshoot" + body: "*" + }; + } +} + +// Whether IAM allow policies gives the principal the permission. +enum AllowAccessState { + // Not specified. + ALLOW_ACCESS_STATE_UNSPECIFIED = 0; + + // The allow policy gives the principal the permission. + ALLOW_ACCESS_STATE_GRANTED = 1; + + // The allow policy doesn't give the principal the permission. + ALLOW_ACCESS_STATE_NOT_GRANTED = 2; + + // The allow policy gives the principal the permission if a condition + // expression evaluate to `true`. However, the sender of the request didn't + // provide enough context for Policy Troubleshooter to evaluate the condition + // expression. + ALLOW_ACCESS_STATE_UNKNOWN_CONDITIONAL = 3; + + // The sender of the request doesn't have access to all of the allow policies + // that Policy Troubleshooter needs to evaluate the principal's access. + ALLOW_ACCESS_STATE_UNKNOWN_INFO = 4; +} + +// Whether IAM deny policies deny the principal the permission. +enum DenyAccessState { + // Not specified. + DENY_ACCESS_STATE_UNSPECIFIED = 0; + + // The deny policy denies the principal the permission. + DENY_ACCESS_STATE_DENIED = 1; + + // The deny policy doesn't deny the principal the permission. + DENY_ACCESS_STATE_NOT_DENIED = 2; + + // The deny policy denies the principal the permission if a condition + // expression evaluates to `true`. However, the sender of the request didn't + // provide enough context for Policy Troubleshooter to evaluate the condition + // expression. + DENY_ACCESS_STATE_UNKNOWN_CONDITIONAL = 3; + + // The sender of the request does not have access to all of the deny policies + // that Policy Troubleshooter needs to evaluate the principal's access. + DENY_ACCESS_STATE_UNKNOWN_INFO = 4; +} + +// Whether a role includes a specific permission. +enum RolePermissionInclusionState { + // Not specified. + ROLE_PERMISSION_INCLUSION_STATE_UNSPECIFIED = 0; + + // The permission is included in the role. + ROLE_PERMISSION_INCLUDED = 1; + + // The permission is not included in the role. + ROLE_PERMISSION_NOT_INCLUDED = 2; + + // The sender of the request is not allowed to access the role definition. + ROLE_PERMISSION_UNKNOWN_INFO = 3; +} + +// Whether the permission in the request matches the permission in the policy. +enum PermissionPatternMatchingState { + // Not specified. + PERMISSION_PATTERN_MATCHING_STATE_UNSPECIFIED = 0; + + // The permission in the request matches the permission in the policy. + PERMISSION_PATTERN_MATCHED = 1; + + // The permission in the request matches the permission in the policy. + PERMISSION_PATTERN_NOT_MATCHED = 2; +} + +// Whether the principal in the request matches the principal in the policy. +enum MembershipMatchingState { + // Not specified. + MEMBERSHIP_MATCHING_STATE_UNSPECIFIED = 0; + + // The principal in the request matches the principal in the policy. The + // principal can be included directly or indirectly: + // + // * A principal is included directly if that principal is listed in the + // role binding. + // * A principal is included indirectly if that principal is in a Google + // group, Google Workspace account, or Cloud Identity domain that is listed + // in the policy. + MEMBERSHIP_MATCHED = 1; + + // The principal in the request doesn't match the principal in the policy. + MEMBERSHIP_NOT_MATCHED = 2; + + // The principal in the policy is a group or domain, and the sender of the + // request doesn't have permission to view whether the principal in the + // request is a member of the group or domain. + MEMBERSHIP_UNKNOWN_INFO = 3; + + // The principal is an unsupported type. + MEMBERSHIP_UNKNOWN_UNSUPPORTED = 4; +} + +// The extent to which a single data point contributes to an overall +// determination. +enum HeuristicRelevance { + // Not specified. + HEURISTIC_RELEVANCE_UNSPECIFIED = 0; + + // The data point has a limited effect on the result. Changing the data point + // is unlikely to affect the overall determination. + HEURISTIC_RELEVANCE_NORMAL = 1; + + // The data point has a strong effect on the result. Changing the data point + // is likely to affect the overall determination. + HEURISTIC_RELEVANCE_HIGH = 2; +} + +// Request for +// [TroubleshootIamPolicy][google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooter.TroubleshootIamPolicy]. +message TroubleshootIamPolicyRequest { + // The information to use for checking whether a principal has a permission + // for a resource. + AccessTuple access_tuple = 1; +} + +// Response for +// [TroubleshootIamPolicy][google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooter.TroubleshootIamPolicy]. +message TroubleshootIamPolicyResponse { + // Whether the principal has the permission on the resource. + enum OverallAccessState { + // Not specified. + OVERALL_ACCESS_STATE_UNSPECIFIED = 0; + + // The principal has the permission. + CAN_ACCESS = 1; + + // The principal doesn't have the permission. + CANNOT_ACCESS = 2; + + // The principal might have the permission, but the sender can't access all + // of the information needed to fully evaluate the principal's access. + UNKNOWN_INFO = 3; + + // The principal might have the permission, but Policy Troubleshooter can't + // fully evaluate the principal's access because the sender didn't provide + // the required context to evaluate the condition. + UNKNOWN_CONDITIONAL = 4; + } + + // Indicates whether the principal has the specified permission for the + // specified resource, based on evaluating all types of the applicable IAM + // policies. + OverallAccessState overall_access_state = 1; + + // The access tuple from the request, including any provided context used to + // evaluate the condition. + AccessTuple access_tuple = 2; + + // An explanation of how the applicable IAM allow policies affect the final + // access state. + AllowPolicyExplanation allow_policy_explanation = 3; + + // An explanation of how the applicable IAM deny policies affect the final + // access state. + DenyPolicyExplanation deny_policy_explanation = 4; +} + +// Information about the principal, resource, and permission to check. +message AccessTuple { + // Required. The email address of the principal whose access you want to + // check. For example, `alice@example.com` or + // `my-service-account@my-project.iam.gserviceaccount.com`. + // + // The principal must be a Google Account or a service account. Other types of + // principals are not supported. + string principal = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The full resource name that identifies the resource. For example, + // `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`. + // + // For examples of full resource names for Google Cloud services, see + // https://cloud.google.com/iam/help/troubleshooter/full-resource-names. + string full_resource_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The IAM permission to check for, either in the `v1` permission + // format or the `v2` permission format. + // + // For a complete list of IAM permissions in the `v1` format, see + // https://cloud.google.com/iam/help/permissions/reference. + // + // For a list of IAM permissions in the `v2` format, see + // https://cloud.google.com/iam/help/deny/supported-permissions. + // + // For a complete list of predefined IAM roles and the permissions in each + // role, see https://cloud.google.com/iam/help/roles/reference. + string permission = 3 [(google.api.field_behavior) = REQUIRED]; + + // Output only. The permission that Policy Troubleshooter checked for, in + // the `v2` format. + string permission_fqdn = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Additional context for the request, such as the request time or + // IP address. This context allows Policy Troubleshooter to troubleshoot + // conditional role bindings and deny rules. + ConditionContext condition_context = 5 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Additional context for troubleshooting conditional role bindings and deny +// rules. +message ConditionContext { + // Core attributes for a resource. A resource is an + // addressable (named) entity provided by the destination service. For + // example, a Compute Engine instance. + message Resource { + // The name of the service that this resource belongs to, such as + // `compute.googleapis.com`. The service name might not match the DNS + // hostname that actually serves the request. + // + // For a full list of resource service values, see + // https://cloud.google.com/iam/help/conditions/resource-services + string service = 1; + + // The stable identifier (name) of a resource on the `service`. A resource + // can be logically identified as `//{resource.service}/{resource.name}`. + // Unlike the resource URI, the resource name doesn't contain any protocol + // and version information. + // + // For a list of full resource name formats, see + // https://cloud.google.com/iam/help/troubleshooter/full-resource-names + string name = 2; + + // The type of the resource, in the format `{service}/{kind}`. + // + // For a full list of resource type values, see + // https://cloud.google.com/iam/help/conditions/resource-types + string type = 3; + } + + // This message defines attributes for a node that handles a network request. + // The node can be either a service or an application that sends, forwards, + // or receives the request. Service peers should fill in + // `principal` and `labels` as appropriate. + message Peer { + // The IPv4 or IPv6 address of the peer. + string ip = 1; + + // The network port of the peer. + int64 port = 2; + } + + // This message defines attributes for an HTTP request. If the actual + // request is not an HTTP request, the runtime system should try to map + // the actual request to an equivalent HTTP request. + message Request { + // Optional. The timestamp when the destination service receives the first + // byte of the request. + google.protobuf.Timestamp receive_time = 1 + [(google.api.field_behavior) = OPTIONAL]; + } + + // A tag that applies to a resource during policy evaluation. Tags can be + // either directly bound to a resource or inherited from its ancestor. + // `EffectiveTag` contains the `name` and `namespaced_name` of the tag value + // and tag key, with additional fields of `inherited` to indicate the + // inheritance status of the effective tag. + message EffectiveTag { + // Output only. Resource name for TagValue in the format `tagValues/456`. + string tag_value = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The namespaced name of the TagValue. Can be in the form + // `{organization_id}/{tag_key_short_name}/{tag_value_short_name}` or + // `{project_id}/{tag_key_short_name}/{tag_value_short_name}` or + // `{project_number}/{tag_key_short_name}/{tag_value_short_name}`. + string namespaced_tag_value = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The name of the TagKey, in the format `tagKeys/{id}`, such + // as `tagKeys/123`. + string tag_key = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The namespaced name of the TagKey. Can be in the form + // `{organization_id}/{tag_key_short_name}` or + // `{project_id}/{tag_key_short_name}` or + // `{project_number}/{tag_key_short_name}`. + string namespaced_tag_key = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The parent name of the tag key. + // Must be in the format `organizations/{organization_id}` or + // `projects/{project_number}` + string tag_key_parent_name = 6; + + // Output only. Indicates the inheritance status of a tag value + // attached to the given resource. If the tag value is inherited from one of + // the resource's ancestors, inherited will be true. If false, then the tag + // value is directly attached to the resource, inherited will be false. + bool inherited = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + } + + // Represents a target resource that is involved with a network activity. + // If multiple resources are involved with an activity, this must be the + // primary one. + Resource resource = 1; + + // The destination of a network activity, such as accepting a TCP connection. + // In a multi-hop network activity, the destination represents the receiver of + // the last hop. + Peer destination = 2; + + // Represents a network request, such as an HTTP request. + Request request = 3; + + // Output only. The effective tags on the resource. The effective tags are + // fetched during troubleshooting. + repeated EffectiveTag effective_tags = 4 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Details about how the relevant IAM allow policies affect the final access +// state. +message AllowPolicyExplanation { + // Indicates whether the principal has the specified permission for the + // specified resource, based on evaluating all applicable IAM allow policies. + AllowAccessState allow_access_state = 1; + + // List of IAM allow policies that were evaluated to check the principal's + // permissions, with annotations to indicate how each policy contributed to + // the final result. + // + // The list of policies includes the policy for the resource itself, as well + // as allow policies that are inherited from higher levels of the resource + // hierarchy, including the organization, the folder, and the project. + // + // To learn more about the resource hierarchy, see + // https://cloud.google.com/iam/help/resource-hierarchy. + repeated ExplainedAllowPolicy explained_policies = 2; + + // The relevance of the allow policy type to the overall access state. + HeuristicRelevance relevance = 3; +} + +// Details about how a specific IAM allow policy contributed to the final access +// state. +message ExplainedAllowPolicy { + // Required. Indicates whether _this policy_ provides the specified permission + // to the specified principal for the specified resource. + // + // This field does _not_ indicate whether the principal actually has the + // permission for the resource. There might be another policy that overrides + // this policy. To determine whether the principal actually has the + // permission, use the `overall_access_state` field in the + // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse]. + AllowAccessState allow_access_state = 1 + [(google.api.field_behavior) = REQUIRED]; + + // The full resource name that identifies the resource. For example, + // `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`. + // + // If the sender of the request does not have access to the policy, this field + // is omitted. + // + // For examples of full resource names for Google Cloud services, see + // https://cloud.google.com/iam/help/troubleshooter/full-resource-names. + string full_resource_name = 2; + + // Details about how each role binding in the policy affects the principal's + // ability, or inability, to use the permission for the resource. The order of + // the role bindings matches the role binding order in the policy. + // + // If the sender of the request does not have access to the policy, this field + // is omitted. + repeated AllowBindingExplanation binding_explanations = 3; + + // The relevance of this policy to the overall access state in the + // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse]. + // + // If the sender of the request does not have access to the policy, this field + // is omitted. + HeuristicRelevance relevance = 4; + + // The IAM allow policy attached to the resource. + // + // If the sender of the request does not have access to the policy, this field + // is empty. + google.iam.v1.Policy policy = 5; +} + +// Details about how a role binding in an allow policy affects a principal's +// ability to use a permission. +message AllowBindingExplanation { + // Details about whether the role binding includes the principal. + message AnnotatedAllowMembership { + // Indicates whether the role binding includes the principal. + MembershipMatchingState membership = 1; + + // The relevance of the principal's status to the overall determination for + // the role binding. + HeuristicRelevance relevance = 2; + } + + // Required. Indicates whether _this role binding_ gives the specified + // permission to the specified principal on the specified resource. + // + // This field does _not_ indicate whether the principal actually has the + // permission on the resource. There might be another role binding that + // overrides this role binding. To determine whether the principal actually + // has the permission, use the `overall_access_state` field in the + // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse]. + AllowAccessState allow_access_state = 1 + [(google.api.field_behavior) = REQUIRED]; + + // The role that this role binding grants. For example, + // `roles/compute.admin`. + // + // For a complete list of predefined IAM roles, as well as the permissions in + // each role, see https://cloud.google.com/iam/help/roles/reference. + string role = 2; + + // Indicates whether the role granted by this role binding contains the + // specified permission. + RolePermissionInclusionState role_permission = 3; + + // The relevance of the permission's existence, or nonexistence, in the role + // to the overall determination for the entire policy. + HeuristicRelevance role_permission_relevance = 4; + + // The combined result of all memberships. Indicates if the principal is + // included in any role binding, either directly or indirectly. + AnnotatedAllowMembership combined_membership = 5; + + // Indicates whether each role binding includes the principal specified in the + // request, either directly or indirectly. Each key identifies a principal in + // the role binding, and each value indicates whether the principal in the + // role binding includes the principal in the request. + // + // For example, suppose that a role binding includes the following principals: + // + // * `user:alice@example.com` + // * `group:product-eng@example.com` + // + // You want to troubleshoot access for `user:bob@example.com`. This user is a + // member of the group `group:product-eng@example.com`. + // + // For the first principal in the role binding, the key is + // `user:alice@example.com`, and the `membership` field in the value is set to + // `NOT_INCLUDED`. + // + // For the second principal in the role binding, the key is + // `group:product-eng@example.com`, and the `membership` field in the value is + // set to `INCLUDED`. + map memberships = 6; + + // The relevance of this role binding to the overall determination for the + // entire policy. + HeuristicRelevance relevance = 7; + + // A condition expression that specifies when the role binding grants access. + // + // To learn about IAM Conditions, see + // https://cloud.google.com/iam/help/conditions/overview. + google.type.Expr condition = 8; + + // Condition evaluation state for this role binding. + ConditionExplanation condition_explanation = 9; +} + +// Details about how the relevant IAM deny policies affect the final access +// state. +message DenyPolicyExplanation { + // Indicates whether the principal is denied the specified permission for + // the specified resource, based on evaluating all applicable IAM deny + // policies. + DenyAccessState deny_access_state = 1; + + // List of resources with IAM deny policies that were evaluated to check the + // principal's denied permissions, with annotations to indicate how each + // policy contributed to the final result. + // + // The list of resources includes the policy for the resource itself, as well + // as policies that are inherited from higher levels of the resource + // hierarchy, including the organization, the folder, and the project. The + // order of the resources starts from the resource and climbs up the resource + // hierarchy. + // + // To learn more about the resource hierarchy, see + // https://cloud.google.com/iam/help/resource-hierarchy. + repeated ExplainedDenyResource explained_resources = 2; + + // The relevance of the deny policy result to the overall access state. + HeuristicRelevance relevance = 3; + + // Indicates whether the permission to troubleshoot is supported in deny + // policies. + bool permission_deniable = 4; +} + +// Details about how a specific resource contributed to the deny policy +// evaluation. +message ExplainedDenyResource { + // Required. Indicates whether any policies attached to _this resource_ deny + // the specific permission to the specified principal for the specified + // resource. + // + // This field does _not_ indicate whether the principal actually has the + // permission for the resource. There might be another policy that overrides + // this policy. To determine whether the principal actually has the + // permission, use the `overall_access_state` field in the + // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse]. + DenyAccessState deny_access_state = 1 + [(google.api.field_behavior) = REQUIRED]; + + // The full resource name that identifies the resource. For example, + // `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`. + // + // If the sender of the request does not have access to the policy, this field + // is omitted. + // + // For examples of full resource names for Google Cloud services, see + // https://cloud.google.com/iam/help/troubleshooter/full-resource-names. + string full_resource_name = 2; + + // List of IAM deny policies that were evaluated to check the principal's + // denied permissions, with annotations to indicate how each policy + // contributed to the final result. + repeated ExplainedDenyPolicy explained_policies = 3; + + // The relevance of this policy to the overall access state in the + // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse]. + // + // If the sender of the request does not have access to the policy, this field + // is omitted. + HeuristicRelevance relevance = 4; +} + +// Details about how a specific IAM deny policy [Policy][google.iam.v2.Policy] +// contributed to the access check. +message ExplainedDenyPolicy { + // Required. Indicates whether _this policy_ denies the specified permission + // to the specified principal for the specified resource. + // + // This field does _not_ indicate whether the principal actually has the + // permission for the resource. There might be another policy that overrides + // this policy. To determine whether the principal actually has the + // permission, use the `overall_access_state` field in the + // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse]. + DenyAccessState deny_access_state = 1 + [(google.api.field_behavior) = REQUIRED]; + + // The IAM deny policy attached to the resource. + // + // If the sender of the request does not have access to the policy, this field + // is omitted. + google.iam.v2.Policy policy = 2; + + // Details about how each rule in the policy affects the principal's inability + // to use the permission for the resource. The order of the deny rule matches + // the order of the rules in the deny policy. + // + // If the sender of the request does not have access to the policy, this field + // is omitted. + repeated DenyRuleExplanation rule_explanations = 3; + + // The relevance of this policy to the overall access state in the + // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse]. + // + // If the sender of the request does not have access to the policy, this field + // is omitted. + HeuristicRelevance relevance = 4; +} + +// Details about how a deny rule in a deny policy affects a principal's ability +// to use a permission. +message DenyRuleExplanation { + // Details about whether the permission in the request is denied by the + // deny rule. + message AnnotatedPermissionMatching { + // Indicates whether the permission in the request is denied by the deny + // rule. + PermissionPatternMatchingState permission_matching_state = 1; + + // The relevance of the permission status to the overall determination for + // the rule. + HeuristicRelevance relevance = 2; + } + + // Details about whether the principal in the request is listed as a denied + // principal in the deny rule, either directly or through membership in a + // principal set. + message AnnotatedDenyPrincipalMatching { + // Indicates whether the principal is listed as a denied principal in the + // deny rule, either directly or through membership in a principal set. + MembershipMatchingState membership = 1; + + // The relevance of the principal's status to the overall determination for + // the role binding. + HeuristicRelevance relevance = 2; + } + + // Required. Indicates whether _this rule_ denies the specified permission to + // the specified principal for the specified resource. + // + // This field does _not_ indicate whether the principal is actually denied on + // the permission for the resource. There might be another rule that overrides + // this rule. To determine whether the principal actually has the permission, + // use the `overall_access_state` field in the + // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse]. + DenyAccessState deny_access_state = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates whether the permission in the request is listed as a denied + // permission in the deny rule. + AnnotatedPermissionMatching combined_denied_permission = 2; + + // Lists all denied permissions in the deny rule and indicates whether each + // permission matches the permission in the request. + // + // Each key identifies a denied permission in the rule, and each value + // indicates whether the denied permission matches the permission in the + // request. + map denied_permissions = 3; + + // Indicates whether the permission in the request is listed as an exception + // permission in the deny rule. + AnnotatedPermissionMatching combined_exception_permission = 4; + + // Lists all exception permissions in the deny rule and indicates whether each + // permission matches the permission in the request. + // + // Each key identifies a exception permission in the rule, and each value + // indicates whether the exception permission matches the permission in the + // request. + map exception_permissions = 5; + + // Indicates whether the principal is listed as a denied principal in the + // deny rule, either directly or through membership in a principal set. + AnnotatedDenyPrincipalMatching combined_denied_principal = 6; + + // Lists all denied principals in the deny rule and indicates whether each + // principal matches the principal in the request, either directly or through + // membership in a principal set. + // + // Each key identifies a denied principal in the rule, and each value + // indicates whether the denied principal matches the principal in the + // request. + map denied_principals = 7; + + // Indicates whether the principal is listed as an exception principal in the + // deny rule, either directly or through membership in a principal set. + AnnotatedDenyPrincipalMatching combined_exception_principal = 8; + + // Lists all exception principals in the deny rule and indicates whether each + // principal matches the principal in the request, either directly or through + // membership in a principal set. + // + // Each key identifies a exception principal in the rule, and each value + // indicates whether the exception principal matches the principal in the + // request. + map exception_principals = 9; + + // The relevance of this role binding to the overall determination for the + // entire policy. + HeuristicRelevance relevance = 10; + + // A condition expression that specifies when the deny rule denies the + // principal access. + // + // To learn about IAM Conditions, see + // https://cloud.google.com/iam/help/conditions/overview. + google.type.Expr condition = 11; + + // Condition evaluation state for this role binding. + ConditionExplanation condition_explanation = 12; +} + +// Explanation for how a condition affects a principal's access +message ConditionExplanation { + // Evaluated state of a condition expression. + message EvaluationState { + // Start position of an expression in the condition, by character. + int32 start = 1; + + // End position of an expression in the condition, by character, + // end included, for example: the end position of the first part of + // `a==b || c==d` would be 4. + int32 end = 2; + + // Value of this expression. + google.protobuf.Value value = 3; + + // Any errors that prevented complete evaluation of the condition + // expression. + repeated google.rpc.Status errors = 4; + } + + // Value of the condition. + google.protobuf.Value value = 1; + + // Any errors that prevented complete evaluation of the condition expression. + repeated google.rpc.Status errors = 3; + + // The value of each statement of the condition expression. The value can be + // `true`, `false`, or `null`. The value is `null` if the statement can't be + // evaluated. + repeated EvaluationState evaluation_states = 2; +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v1/policy.proto b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v1/policy.proto new file mode 100644 index 00000000000..2386563b36e --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v1/policy.proto @@ -0,0 +1,410 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.iam.v1; + +import "google/type/expr.proto"; + +option cc_enable_arenas = true; +option csharp_namespace = "Google.Cloud.Iam.V1"; +option go_package = "cloud.google.com/go/iam/apiv1/iampb;iampb"; +option java_multiple_files = true; +option java_outer_classname = "PolicyProto"; +option java_package = "com.google.iam.v1"; +option php_namespace = "Google\\Cloud\\Iam\\V1"; + +// An Identity and Access Management (IAM) policy, which specifies access +// controls for Google Cloud resources. +// +// +// A `Policy` is a collection of `bindings`. A `binding` binds one or more +// `members`, or principals, to a single `role`. Principals can be user +// accounts, service accounts, Google groups, and domains (such as G Suite). A +// `role` is a named list of permissions; each `role` can be an IAM predefined +// role or a user-created custom role. +// +// For some types of Google Cloud resources, a `binding` can also specify a +// `condition`, which is a logical expression that allows access to a resource +// only if the expression evaluates to `true`. A condition can add constraints +// based on attributes of the request, the resource, or both. To learn which +// resources support conditions in their IAM policies, see the +// [IAM +// documentation](https://cloud.google.com/iam/help/conditions/resource-policies). +// +// **JSON example:** +// +// ``` +// { +// "bindings": [ +// { +// "role": "roles/resourcemanager.organizationAdmin", +// "members": [ +// "user:mike@example.com", +// "group:admins@example.com", +// "domain:google.com", +// "serviceAccount:my-project-id@appspot.gserviceaccount.com" +// ] +// }, +// { +// "role": "roles/resourcemanager.organizationViewer", +// "members": [ +// "user:eve@example.com" +// ], +// "condition": { +// "title": "expirable access", +// "description": "Does not grant access after Sep 2020", +// "expression": "request.time < +// timestamp('2020-10-01T00:00:00.000Z')", +// } +// } +// ], +// "etag": "BwWWja0YfJA=", +// "version": 3 +// } +// ``` +// +// **YAML example:** +// +// ``` +// bindings: +// - members: +// - user:mike@example.com +// - group:admins@example.com +// - domain:google.com +// - serviceAccount:my-project-id@appspot.gserviceaccount.com +// role: roles/resourcemanager.organizationAdmin +// - members: +// - user:eve@example.com +// role: roles/resourcemanager.organizationViewer +// condition: +// title: expirable access +// description: Does not grant access after Sep 2020 +// expression: request.time < timestamp('2020-10-01T00:00:00.000Z') +// etag: BwWWja0YfJA= +// version: 3 +// ``` +// +// For a description of IAM and its features, see the +// [IAM documentation](https://cloud.google.com/iam/docs/). +message Policy { + // Specifies the format of the policy. + // + // Valid values are `0`, `1`, and `3`. Requests that specify an invalid value + // are rejected. + // + // Any operation that affects conditional role bindings must specify version + // `3`. This requirement applies to the following operations: + // + // * Getting a policy that includes a conditional role binding + // * Adding a conditional role binding to a policy + // * Changing a conditional role binding in a policy + // * Removing any role binding, with or without a condition, from a policy + // that includes conditions + // + // **Important:** If you use IAM Conditions, you must include the `etag` field + // whenever you call `setIamPolicy`. If you omit this field, then IAM allows + // you to overwrite a version `3` policy with a version `1` policy, and all of + // the conditions in the version `3` policy are lost. + // + // If a policy does not include any conditions, operations on that policy may + // specify any valid version or leave the field unset. + // + // To learn which resources support conditions in their IAM policies, see the + // [IAM + // documentation](https://cloud.google.com/iam/help/conditions/resource-policies). + int32 version = 1; + + // Associates a list of `members`, or principals, with a `role`. Optionally, + // may specify a `condition` that determines how and when the `bindings` are + // applied. Each of the `bindings` must contain at least one principal. + // + // The `bindings` in a `Policy` can refer to up to 1,500 principals; up to 250 + // of these principals can be Google groups. Each occurrence of a principal + // counts towards these limits. For example, if the `bindings` grant 50 + // different roles to `user:alice@example.com`, and not to any other + // principal, then you can add another 1,450 principals to the `bindings` in + // the `Policy`. + repeated Binding bindings = 4; + + // Specifies cloud audit logging configuration for this policy. + repeated AuditConfig audit_configs = 6; + + // `etag` is used for optimistic concurrency control as a way to help + // prevent simultaneous updates of a policy from overwriting each other. + // It is strongly suggested that systems make use of the `etag` in the + // read-modify-write cycle to perform policy updates in order to avoid race + // conditions: An `etag` is returned in the response to `getIamPolicy`, and + // systems are expected to put that etag in the request to `setIamPolicy` to + // ensure that their change will be applied to the same version of the policy. + // + // **Important:** If you use IAM Conditions, you must include the `etag` field + // whenever you call `setIamPolicy`. If you omit this field, then IAM allows + // you to overwrite a version `3` policy with a version `1` policy, and all of + // the conditions in the version `3` policy are lost. + bytes etag = 3; +} + +// Associates `members`, or principals, with a `role`. +message Binding { + // Role that is assigned to the list of `members`, or principals. + // For example, `roles/viewer`, `roles/editor`, or `roles/owner`. + string role = 1; + + // Specifies the principals requesting access for a Google Cloud resource. + // `members` can have the following values: + // + // * `allUsers`: A special identifier that represents anyone who is + // on the internet; with or without a Google account. + // + // * `allAuthenticatedUsers`: A special identifier that represents anyone + // who is authenticated with a Google account or a service account. + // + // * `user:{emailid}`: An email address that represents a specific Google + // account. For example, `alice@example.com` . + // + // + // * `serviceAccount:{emailid}`: An email address that represents a service + // account. For example, `my-other-app@appspot.gserviceaccount.com`. + // + // * `group:{emailid}`: An email address that represents a Google group. + // For example, `admins@example.com`. + // + // * `deleted:user:{emailid}?uid={uniqueid}`: An email address (plus unique + // identifier) representing a user that has been recently deleted. For + // example, `alice@example.com?uid=123456789012345678901`. If the user is + // recovered, this value reverts to `user:{emailid}` and the recovered user + // retains the role in the binding. + // + // * `deleted:serviceAccount:{emailid}?uid={uniqueid}`: An email address (plus + // unique identifier) representing a service account that has been recently + // deleted. For example, + // `my-other-app@appspot.gserviceaccount.com?uid=123456789012345678901`. + // If the service account is undeleted, this value reverts to + // `serviceAccount:{emailid}` and the undeleted service account retains the + // role in the binding. + // + // * `deleted:group:{emailid}?uid={uniqueid}`: An email address (plus unique + // identifier) representing a Google group that has been recently + // deleted. For example, `admins@example.com?uid=123456789012345678901`. If + // the group is recovered, this value reverts to `group:{emailid}` and the + // recovered group retains the role in the binding. + // + // + // * `domain:{domain}`: The G Suite domain (primary) that represents all the + // users of that domain. For example, `google.com` or `example.com`. + // + // + repeated string members = 2; + + // The condition that is associated with this binding. + // + // If the condition evaluates to `true`, then this binding applies to the + // current request. + // + // If the condition evaluates to `false`, then this binding does not apply to + // the current request. However, a different role binding might grant the same + // role to one or more of the principals in this binding. + // + // To learn which resources support conditions in their IAM policies, see the + // [IAM + // documentation](https://cloud.google.com/iam/help/conditions/resource-policies). + google.type.Expr condition = 3; +} + +// Specifies the audit configuration for a service. +// The configuration determines which permission types are logged, and what +// identities, if any, are exempted from logging. +// An AuditConfig must have one or more AuditLogConfigs. +// +// If there are AuditConfigs for both `allServices` and a specific service, +// the union of the two AuditConfigs is used for that service: the log_types +// specified in each AuditConfig are enabled, and the exempted_members in each +// AuditLogConfig are exempted. +// +// Example Policy with multiple AuditConfigs: +// +// { +// "audit_configs": [ +// { +// "service": "allServices", +// "audit_log_configs": [ +// { +// "log_type": "DATA_READ", +// "exempted_members": [ +// "user:jose@example.com" +// ] +// }, +// { +// "log_type": "DATA_WRITE" +// }, +// { +// "log_type": "ADMIN_READ" +// } +// ] +// }, +// { +// "service": "sampleservice.googleapis.com", +// "audit_log_configs": [ +// { +// "log_type": "DATA_READ" +// }, +// { +// "log_type": "DATA_WRITE", +// "exempted_members": [ +// "user:aliya@example.com" +// ] +// } +// ] +// } +// ] +// } +// +// For sampleservice, this policy enables DATA_READ, DATA_WRITE and ADMIN_READ +// logging. It also exempts `jose@example.com` from DATA_READ logging, and +// `aliya@example.com` from DATA_WRITE logging. +message AuditConfig { + // Specifies a service that will be enabled for audit logging. + // For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. + // `allServices` is a special value that covers all services. + string service = 1; + + // The configuration for logging of each type of permission. + repeated AuditLogConfig audit_log_configs = 3; +} + +// Provides the configuration for logging a type of permissions. +// Example: +// +// { +// "audit_log_configs": [ +// { +// "log_type": "DATA_READ", +// "exempted_members": [ +// "user:jose@example.com" +// ] +// }, +// { +// "log_type": "DATA_WRITE" +// } +// ] +// } +// +// This enables 'DATA_READ' and 'DATA_WRITE' logging, while exempting +// jose@example.com from DATA_READ logging. +message AuditLogConfig { + // The list of valid permission types for which logging can be configured. + // Admin writes are always logged, and are not configurable. + enum LogType { + // Default case. Should never be this. + LOG_TYPE_UNSPECIFIED = 0; + + // Admin reads. Example: CloudIAM getIamPolicy + ADMIN_READ = 1; + + // Data writes. Example: CloudSQL Users create + DATA_WRITE = 2; + + // Data reads. Example: CloudSQL Users list + DATA_READ = 3; + } + + // The log type that this config enables. + LogType log_type = 1; + + // Specifies the identities that do not cause logging for this type of + // permission. + // Follows the same format of + // [Binding.members][google.iam.v1.Binding.members]. + repeated string exempted_members = 2; +} + +// The difference delta between two policies. +message PolicyDelta { + // The delta for Bindings between two policies. + repeated BindingDelta binding_deltas = 1; + + // The delta for AuditConfigs between two policies. + repeated AuditConfigDelta audit_config_deltas = 2; +} + +// One delta entry for Binding. Each individual change (only one member in each +// entry) to a binding will be a separate entry. +message BindingDelta { + // The type of action performed on a Binding in a policy. + enum Action { + // Unspecified. + ACTION_UNSPECIFIED = 0; + + // Addition of a Binding. + ADD = 1; + + // Removal of a Binding. + REMOVE = 2; + } + + // The action that was performed on a Binding. + // Required + Action action = 1; + + // Role that is assigned to `members`. + // For example, `roles/viewer`, `roles/editor`, or `roles/owner`. + // Required + string role = 2; + + // A single identity requesting access for a Google Cloud resource. + // Follows the same format of Binding.members. + // Required + string member = 3; + + // The condition that is associated with this binding. + google.type.Expr condition = 4; +} + +// One delta entry for AuditConfig. Each individual change (only one +// exempted_member in each entry) to a AuditConfig will be a separate entry. +message AuditConfigDelta { + // The type of action performed on an audit configuration in a policy. + enum Action { + // Unspecified. + ACTION_UNSPECIFIED = 0; + + // Addition of an audit configuration. + ADD = 1; + + // Removal of an audit configuration. + REMOVE = 2; + } + + // The action that was performed on an audit configuration in a policy. + // Required + Action action = 1; + + // Specifies a service that was configured for Cloud Audit Logging. + // For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. + // `allServices` is a special value that covers all services. + // Required + string service = 2; + + // A single identity that is exempted from "data access" audit + // logging for the `service` specified above. + // Follows the same format of Binding.members. + string exempted_member = 3; + + // Specifies the log_type that was be enabled. ADMIN_ACTIVITY is always + // enabled, and cannot be configured. + // Required + string log_type = 4; +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v2/deny.proto b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v2/deny.proto new file mode 100644 index 00000000000..a3c8ff14e9a --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v2/deny.proto @@ -0,0 +1,109 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.iam.v2; + +import "google/type/expr.proto"; + +option csharp_namespace = "Google.Cloud.Iam.V2"; +option go_package = "cloud.google.com/go/iam/apiv2/iampb;iampb"; +option java_multiple_files = true; +option java_outer_classname = "DenyRuleProto"; +option java_package = "com.google.iam.v2"; +option php_namespace = "Google\\Cloud\\Iam\\V2"; + +// A deny rule in an IAM deny policy. +message DenyRule { + // The identities that are prevented from using one or more permissions on + // Google Cloud resources. This field can contain the following values: + // + // * `principalSet://goog/public:all`: A special identifier that represents + // any principal that is on the internet, even if they do not have a Google + // Account or are not logged in. + // + // * `principal://goog/subject/{email_id}`: A specific Google Account. + // Includes Gmail, Cloud Identity, and Google Workspace user accounts. For + // example, `principal://goog/subject/alice@example.com`. + // + // * `deleted:principal://goog/subject/{email_id}?uid={uid}`: A specific + // Google Account that was deleted recently. For example, + // `deleted:principal://goog/subject/alice@example.com?uid=1234567890`. If + // the Google Account is recovered, this identifier reverts to the standard + // identifier for a Google Account. + // + // * `principalSet://goog/group/{group_id}`: A Google group. For example, + // `principalSet://goog/group/admins@example.com`. + // + // * `deleted:principalSet://goog/group/{group_id}?uid={uid}`: A Google group + // that was deleted recently. For example, + // `deleted:principalSet://goog/group/admins@example.com?uid=1234567890`. If + // the Google group is restored, this identifier reverts to the standard + // identifier for a Google group. + // + // * `principal://iam.googleapis.com/projects/-/serviceAccounts/{service_account_id}`: + // A Google Cloud service account. For example, + // `principal://iam.googleapis.com/projects/-/serviceAccounts/my-service-account@iam.gserviceaccount.com`. + // + // * `deleted:principal://iam.googleapis.com/projects/-/serviceAccounts/{service_account_id}?uid={uid}`: + // A Google Cloud service account that was deleted recently. For example, + // `deleted:principal://iam.googleapis.com/projects/-/serviceAccounts/my-service-account@iam.gserviceaccount.com?uid=1234567890`. + // If the service account is undeleted, this identifier reverts to the + // standard identifier for a service account. + // + // * `principalSet://goog/cloudIdentityCustomerId/{customer_id}`: All of the + // principals associated with the specified Google Workspace or Cloud + // Identity customer ID. For example, + // `principalSet://goog/cloudIdentityCustomerId/C01Abc35`. + repeated string denied_principals = 1; + + // The identities that are excluded from the deny rule, even if they are + // listed in the `denied_principals`. For example, you could add a Google + // group to the `denied_principals`, then exclude specific users who belong to + // that group. + // + // This field can contain the same values as the `denied_principals` field, + // excluding `principalSet://goog/public:all`, which represents all users on + // the internet. + repeated string exception_principals = 2; + + // The permissions that are explicitly denied by this rule. Each permission + // uses the format `{service_fqdn}/{resource}.{verb}`, where `{service_fqdn}` + // is the fully qualified domain name for the service. For example, + // `iam.googleapis.com/roles.list`. + repeated string denied_permissions = 3; + + // Specifies the permissions that this rule excludes from the set of denied + // permissions given by `denied_permissions`. If a permission appears in + // `denied_permissions` _and_ in `exception_permissions` then it will _not_ be + // denied. + // + // The excluded permissions can be specified using the same syntax as + // `denied_permissions`. + repeated string exception_permissions = 4; + + // The condition that determines whether this deny rule applies to a request. + // If the condition expression evaluates to `true`, then the deny rule is + // applied; otherwise, the deny rule is not applied. + // + // Each deny rule is evaluated independently. If this deny rule does not apply + // to a request, other deny rules might still apply. + // + // The condition can use CEL functions that evaluate + // [resource + // tags](https://cloud.google.com/iam/help/conditions/resource-tags). Other + // functions and operators are not supported. + google.type.Expr denial_condition = 5; +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v2/policy.proto b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v2/policy.proto new file mode 100644 index 00000000000..56f73da089b --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v2/policy.proto @@ -0,0 +1,287 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.iam.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/iam/v2/deny.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Iam.V2"; +option go_package = "cloud.google.com/go/iam/apiv2/iampb;iampb"; +option java_multiple_files = true; +option java_outer_classname = "PolicyProto"; +option java_package = "com.google.iam.v2"; +option php_namespace = "Google\\Cloud\\Iam\\V2"; + +// An interface for managing Identity and Access Management (IAM) policies. +service Policies { + option (google.api.default_host) = "iam.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves the policies of the specified kind that are attached to a + // resource. + // + // The response lists only policy metadata. In particular, policy rules are + // omitted. + rpc ListPolicies(ListPoliciesRequest) returns (ListPoliciesResponse) { + option (google.api.http) = { + get: "/v2/{parent=policies/*/*}" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a policy. + rpc GetPolicy(GetPolicyRequest) returns (Policy) { + option (google.api.http) = { + get: "/v2/{name=policies/*/*/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a policy. + rpc CreatePolicy(CreatePolicyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=policies/*/*}" + body: "policy" + }; + option (google.api.method_signature) = "parent,policy,policy_id"; + option (google.longrunning.operation_info) = { + response_type: "Policy" + metadata_type: "PolicyOperationMetadata" + }; + } + + // Updates the specified policy. + // + // You can update only the rules and the display name for the policy. + // + // To update a policy, you should use a read-modify-write loop: + // + // 1. Use [GetPolicy][google.iam.v2.Policies.GetPolicy] to read the current version of the policy. + // 2. Modify the policy as needed. + // 3. Use `UpdatePolicy` to write the updated policy. + // + // This pattern helps prevent conflicts between concurrent updates. + rpc UpdatePolicy(UpdatePolicyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + put: "/v2/{policy.name=policies/*/*/*}" + body: "policy" + }; + option (google.longrunning.operation_info) = { + response_type: "Policy" + metadata_type: "PolicyOperationMetadata" + }; + } + + // Deletes a policy. This action is permanent. + rpc DeletePolicy(DeletePolicyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v2/{name=policies/*/*/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Policy" + metadata_type: "PolicyOperationMetadata" + }; + } +} + +// Data for an IAM policy. +message Policy { + // Immutable. The resource name of the `Policy`, which must be unique. Format: + // `policies/{attachment_point}/denypolicies/{policy_id}` + // + // + // The attachment point is identified by its URL-encoded full resource name, + // which means that the forward-slash character, `/`, must be written as + // `%2F`. For example, + // `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-deny-policy`. + // + // For organizations and folders, use the numeric ID in the full resource + // name. For projects, requests can use the alphanumeric or the numeric ID. + // Responses always contain the numeric ID. + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. The globally unique ID of the `Policy`. Assigned automatically when the + // `Policy` is created. + string uid = 2 [(google.api.field_behavior) = IMMUTABLE]; + + // Output only. The kind of the `Policy`. Always contains the value `DenyPolicy`. + string kind = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // A user-specified description of the `Policy`. This value can be up to 63 + // characters. + string display_name = 4; + + // A key-value map to store arbitrary metadata for the `Policy`. Keys + // can be up to 63 characters. Values can be up to 255 characters. + map annotations = 5; + + // An opaque tag that identifies the current version of the `Policy`. IAM uses + // this value to help manage concurrent updates, so they do not cause one + // update to be overwritten by another. + // + // If this field is present in a [CreatePolicy][] request, the value is + // ignored. + string etag = 6; + + // Output only. The time when the `Policy` was created. + google.protobuf.Timestamp create_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time when the `Policy` was last updated. + google.protobuf.Timestamp update_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time when the `Policy` was deleted. Empty if the policy is not deleted. + google.protobuf.Timestamp delete_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // A list of rules that specify the behavior of the `Policy`. All of the rules + // should be of the `kind` specified in the `Policy`. + repeated PolicyRule rules = 10; + + // Immutable. Specifies that this policy is managed by an authority and can only be + // modified by that authority. Usage is restricted. + string managing_authority = 11 [(google.api.field_behavior) = IMMUTABLE]; +} + +// A single rule in a `Policy`. +message PolicyRule { + oneof kind { + // A rule for a deny policy. + DenyRule deny_rule = 2; + } + + // A user-specified description of the rule. This value can be up to 256 + // characters. + string description = 1; +} + +// Request message for `ListPolicies`. +message ListPoliciesRequest { + // Required. The resource that the policy is attached to, along with the kind of policy + // to list. Format: + // `policies/{attachment_point}/denypolicies` + // + // + // The attachment point is identified by its URL-encoded full resource name, + // which means that the forward-slash character, `/`, must be written as + // `%2F`. For example, + // `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies`. + // + // For organizations and folders, use the numeric ID in the full resource + // name. For projects, you can use the alphanumeric or the numeric ID. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The maximum number of policies to return. IAM ignores this value and uses + // the value 1000. + int32 page_size = 2; + + // A page token received in a [ListPoliciesResponse][google.iam.v2.ListPoliciesResponse]. Provide this token to + // retrieve the next page. + string page_token = 3; +} + +// Response message for `ListPolicies`. +message ListPoliciesResponse { + // Metadata for the policies that are attached to the resource. + repeated Policy policies = 1; + + // A page token that you can use in a [ListPoliciesRequest][google.iam.v2.ListPoliciesRequest] to retrieve the + // next page. If this field is omitted, there are no additional pages. + string next_page_token = 2; +} + +// Request message for `GetPolicy`. +message GetPolicyRequest { + // Required. The resource name of the policy to retrieve. Format: + // `policies/{attachment_point}/denypolicies/{policy_id}` + // + // + // Use the URL-encoded full resource name, which means that the forward-slash + // character, `/`, must be written as `%2F`. For example, + // `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy`. + // + // For organizations and folders, use the numeric ID in the full resource + // name. For projects, you can use the alphanumeric or the numeric ID. + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for `CreatePolicy`. +message CreatePolicyRequest { + // Required. The resource that the policy is attached to, along with the kind of policy + // to create. Format: `policies/{attachment_point}/denypolicies` + // + // + // The attachment point is identified by its URL-encoded full resource name, + // which means that the forward-slash character, `/`, must be written as + // `%2F`. For example, + // `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies`. + // + // For organizations and folders, use the numeric ID in the full resource + // name. For projects, you can use the alphanumeric or the numeric ID. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The policy to create. + Policy policy = 2 [(google.api.field_behavior) = REQUIRED]; + + // The ID to use for this policy, which will become the final component of + // the policy's resource name. The ID must contain 3 to 63 characters. It can + // contain lowercase letters and numbers, as well as dashes (`-`) and periods + // (`.`). The first character must be a lowercase letter. + string policy_id = 3; +} + +// Request message for `UpdatePolicy`. +message UpdatePolicyRequest { + // Required. The policy to update. + // + // To prevent conflicting updates, the `etag` value must match the value that + // is stored in IAM. If the `etag` values do not match, the request fails with + // a `409` error code and `ABORTED` status. + Policy policy = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for `DeletePolicy`. +message DeletePolicyRequest { + // Required. The resource name of the policy to delete. Format: + // `policies/{attachment_point}/denypolicies/{policy_id}` + // + // + // Use the URL-encoded full resource name, which means that the forward-slash + // character, `/`, must be written as `%2F`. For example, + // `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy`. + // + // For organizations and folders, use the numeric ID in the full resource + // name. For projects, you can use the alphanumeric or the numeric ID. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The expected `etag` of the policy to delete. If the value does not match + // the value that is stored in IAM, the request fails with a `409` error code + // and `ABORTED` status. + // + // If you omit this field, the policy is deleted regardless of its current + // `etag`. + string etag = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Metadata for long-running `Policy` operations. +message PolicyOperationMetadata { + // Timestamp when the `google.longrunning.Operation` was created. + google.protobuf.Timestamp create_time = 1; +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/rpc/status.proto b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/rpc/status.proto new file mode 100644 index 00000000000..923e169381a --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/rpc/status.proto @@ -0,0 +1,49 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.rpc; + +import "google/protobuf/any.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/rpc/status;status"; +option java_multiple_files = true; +option java_outer_classname = "StatusProto"; +option java_package = "com.google.rpc"; +option objc_class_prefix = "RPC"; + +// The `Status` type defines a logical error model that is suitable for +// different programming environments, including REST APIs and RPC APIs. It is +// used by [gRPC](https://github.com/grpc). Each `Status` message contains +// three pieces of data: error code, error message, and error details. +// +// You can find out more about this error model and how to work with it in the +// [API Design Guide](https://cloud.google.com/apis/design/errors). +message Status { + // The status code, which should be an enum value of + // [google.rpc.Code][google.rpc.Code]. + int32 code = 1; + + // A developer-facing error message, which should be in English. Any + // user-facing error message should be localized and sent in the + // [google.rpc.Status.details][google.rpc.Status.details] field, or localized + // by the client. + string message = 2; + + // A list of messages that carry the error details. There is a common set of + // message types for APIs to use. + repeated google.protobuf.Any details = 3; +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/type/expr.proto b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/type/expr.proto new file mode 100644 index 00000000000..af0778cf958 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/type/expr.proto @@ -0,0 +1,73 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.type; + +option go_package = "google.golang.org/genproto/googleapis/type/expr;expr"; +option java_multiple_files = true; +option java_outer_classname = "ExprProto"; +option java_package = "com.google.type"; +option objc_class_prefix = "GTP"; + +// Represents a textual expression in the Common Expression Language (CEL) +// syntax. CEL is a C-like expression language. The syntax and semantics of CEL +// are documented at https://github.com/google/cel-spec. +// +// Example (Comparison): +// +// title: "Summary size limit" +// description: "Determines if a summary is less than 100 chars" +// expression: "document.summary.size() < 100" +// +// Example (Equality): +// +// title: "Requestor is owner" +// description: "Determines if requestor is the document owner" +// expression: "document.owner == request.auth.claims.email" +// +// Example (Logic): +// +// title: "Public documents" +// description: "Determine whether the document should be publicly visible" +// expression: "document.type != 'private' && document.type != 'internal'" +// +// Example (Data Manipulation): +// +// title: "Notification string" +// description: "Create a notification string with a timestamp." +// expression: "'New message received at ' + string(document.create_time)" +// +// The exact variables and functions that may be referenced within an expression +// are determined by the service that evaluates it. See the service +// documentation for additional information. +message Expr { + // Textual representation of an expression in Common Expression Language + // syntax. + string expression = 1; + + // Optional. Title for the expression, i.e. a short string describing + // its purpose. This can be used e.g. in UIs which allow to enter the + // expression. + string title = 2; + + // Optional. Description of the expression. This is a longer text which + // describes the expression, e.g. when hovered over it in a UI. + string description = 3; + + // Optional. String indicating the location of the expression for error + // reporting, e.g. a file name and a position in the file. + string location = 4; +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/samples/generated/v3beta/policy_troubleshooter.troubleshoot_iam_policy.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/samples/generated/v3beta/policy_troubleshooter.troubleshoot_iam_policy.js new file mode 100644 index 00000000000..53ecfb8b890 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/samples/generated/v3beta/policy_troubleshooter.troubleshoot_iam_policy.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 policytroubleshooter_v3beta_generated_PolicyTroubleshooter_TroubleshootIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 information to use for checking whether a principal has a permission + * for a resource. + */ + // const accessTuple = {} + + // Imports the Iam library + const {PolicyTroubleshooterClient} = require('@google-cloud/policy-troubleshooter-iam').v3beta; + + // Instantiates a client + const iamClient = new PolicyTroubleshooterClient(); + + async function callTroubleshootIamPolicy() { + // Construct request + const request = { + }; + + // Run request + const response = await iamClient.troubleshootIamPolicy(request); + console.log(response); + } + + callTroubleshootIamPolicy(); + // [END policytroubleshooter_v3beta_generated_PolicyTroubleshooter_TroubleshootIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/samples/generated/v3beta/snippet_metadata_google.cloud.policytroubleshooter.iam.v3beta.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/samples/generated/v3beta/snippet_metadata_google.cloud.policytroubleshooter.iam.v3beta.json new file mode 100644 index 00000000000..42f975e02de --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/samples/generated/v3beta/snippet_metadata_google.cloud.policytroubleshooter.iam.v3beta.json @@ -0,0 +1,55 @@ +{ + "clientLibrary": { + "name": "nodejs-iam", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.policytroubleshooter.iam.v3beta", + "version": "v3beta" + } + ] + }, + "snippets": [ + { + "regionTag": "policytroubleshooter_v3beta_generated_PolicyTroubleshooter_TroubleshootIamPolicy_async", + "title": "Policies troubleshootIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Checks whether a principal has a specific permission for a specific resource, and explains why the principal does or doesn't have that permission.", + "canonical": true, + "file": "policy_troubleshooter.troubleshoot_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TroubleshootIamPolicy", + "fullName": "google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooter.TroubleshootIamPolicy", + "async": true, + "parameters": [ + { + "name": "access_tuple", + "type": ".google.cloud.policytroubleshooter.iam.v3beta.AccessTuple" + } + ], + "resultType": ".google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse", + "client": { + "shortName": "PolicyTroubleshooterClient", + "fullName": "google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooterClient" + }, + "method": { + "shortName": "TroubleshootIamPolicy", + "fullName": "google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooter.TroubleshootIamPolicy", + "service": { + "shortName": "PolicyTroubleshooter", + "fullName": "google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooter" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/index.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/index.ts new file mode 100644 index 00000000000..29c5ee15a98 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v3beta from './v3beta'; +const PolicyTroubleshooterClient = v3beta.PolicyTroubleshooterClient; +type PolicyTroubleshooterClient = v3beta.PolicyTroubleshooterClient; +export {v3beta, PolicyTroubleshooterClient}; +export default {v3beta, PolicyTroubleshooterClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/gapic_metadata.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/gapic_metadata.json new file mode 100644 index 00000000000..96581c62bb5 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/gapic_metadata.json @@ -0,0 +1,33 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.policytroubleshooter.iam.v3beta", + "libraryPackage": "@google-cloud/policy-troubleshooter-iam", + "services": { + "PolicyTroubleshooter": { + "clients": { + "grpc": { + "libraryClient": "PolicyTroubleshooterClient", + "rpcs": { + "TroubleshootIamPolicy": { + "methods": [ + "troubleshootIamPolicy" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "PolicyTroubleshooterClient", + "rpcs": { + "TroubleshootIamPolicy": { + "methods": [ + "troubleshootIamPolicy" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/index.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/index.ts new file mode 100644 index 00000000000..cb1bab0ce55 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {PolicyTroubleshooterClient} from './policy_troubleshooter_client'; diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_client.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_client.ts new file mode 100644 index 00000000000..e1ba0b9189c --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_client.ts @@ -0,0 +1,376 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v3beta/policy_troubleshooter_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './policy_troubleshooter_client_config.json'; +const version = require('../../../package.json').version; + +/** + * IAM Policy Troubleshooter service. + * + * This service helps you troubleshoot access issues for Google Cloud resources. + * @class + * @memberof v3beta + */ +export class PolicyTroubleshooterClient { + 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}; + policyTroubleshooterStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of PolicyTroubleshooterClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 PolicyTroubleshooterClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof PolicyTroubleshooterClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooter', 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.policyTroubleshooterStub) { + return this.policyTroubleshooterStub; + } + + // Put together the "service stub" for + // google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooter. + this.policyTroubleshooterStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooter') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooter, + 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 policyTroubleshooterStubMethods = + ['troubleshootIamPolicy']; + for (const methodName of policyTroubleshooterStubMethods) { + const callPromise = this.policyTroubleshooterStub.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.policyTroubleshooterStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'policytroubleshooter.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 'policytroubleshooter.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 -- + // ------------------- +/** + * Checks whether a principal has a specific permission for a specific + * resource, and explains why the principal does or doesn't have that + * permission. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.policytroubleshooter.iam.v3beta.AccessTuple} request.accessTuple + * The information to use for checking whether a principal has a permission + * for a resource. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse|TroubleshootIamPolicyResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3beta/policy_troubleshooter.troubleshoot_iam_policy.js + * region_tag:policytroubleshooter_v3beta_generated_PolicyTroubleshooter_TroubleshootIamPolicy_async + */ + troubleshootIamPolicy( + request?: protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyResponse, + protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyRequest|undefined, {}|undefined + ]>; + troubleshootIamPolicy( + request: protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyResponse, + protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + troubleshootIamPolicy( + request: protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyRequest, + callback: Callback< + protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyResponse, + protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + troubleshootIamPolicy( + request?: protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyResponse, + protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyResponse, + protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyResponse, + protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.troubleshootIamPolicy(request, options, callback); + } + + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.policyTroubleshooterStub && !this._terminated) { + return this.policyTroubleshooterStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_client_config.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_client_config.json new file mode 100644 index 00000000000..eb4ce1f3959 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_client_config.json @@ -0,0 +1,43 @@ +{ + "interfaces": { + "google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooter": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "TroubleshootIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_proto_list.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_proto_list.json new file mode 100644 index 00000000000..45e4242c422 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_proto_list.json @@ -0,0 +1,4 @@ +[ + "../../protos/google/cloud/policytroubleshooter/iam/v3beta/troubleshooter.proto", + "../../protos/google/iam/v2/deny.proto" +] diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..0a33a6a9558 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const iam = require('@google-cloud/policy-troubleshooter-iam'); + +function main() { + const policyTroubleshooterClient = new iam.PolicyTroubleshooterClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..640427e0ee7 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {PolicyTroubleshooterClient} from '@google-cloud/policy-troubleshooter-iam'; + +// check that the client class type name can be used +function doStuffWithPolicyTroubleshooterClient(client: PolicyTroubleshooterClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const policyTroubleshooterClient = new PolicyTroubleshooterClient(); + doStuffWithPolicyTroubleshooterClient(policyTroubleshooterClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/install.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/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-policytroubleshooter-iam/v3beta/test/gapic_policy_troubleshooter_v3beta.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/test/gapic_policy_troubleshooter_v3beta.ts new file mode 100644 index 00000000000..c5336388dfa --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/test/gapic_policy_troubleshooter_v3beta.ts @@ -0,0 +1,225 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 policytroubleshooterModule from '../src'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +describe('v3beta.PolicyTroubleshooterClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = policytroubleshooterModule.v3beta.PolicyTroubleshooterClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = policytroubleshooterModule.v3beta.PolicyTroubleshooterClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = policytroubleshooterModule.v3beta.PolicyTroubleshooterClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new policytroubleshooterModule.v3beta.PolicyTroubleshooterClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new policytroubleshooterModule.v3beta.PolicyTroubleshooterClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new policytroubleshooterModule.v3beta.PolicyTroubleshooterClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.policyTroubleshooterStub, undefined); + await client.initialize(); + assert(client.policyTroubleshooterStub); + }); + + it('has close method for the initialized client', done => { + const client = new policytroubleshooterModule.v3beta.PolicyTroubleshooterClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.policyTroubleshooterStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new policytroubleshooterModule.v3beta.PolicyTroubleshooterClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.policyTroubleshooterStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new policytroubleshooterModule.v3beta.PolicyTroubleshooterClient({ + 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 policytroubleshooterModule.v3beta.PolicyTroubleshooterClient({ + 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('troubleshootIamPolicy', () => { + it('invokes troubleshootIamPolicy without error', async () => { + const client = new policytroubleshooterModule.v3beta.PolicyTroubleshooterClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse() + ); + client.innerApiCalls.troubleshootIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.troubleshootIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes troubleshootIamPolicy without error using callback', async () => { + const client = new policytroubleshooterModule.v3beta.PolicyTroubleshooterClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse() + ); + client.innerApiCalls.troubleshootIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.troubleshootIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes troubleshootIamPolicy with error', async () => { + const client = new policytroubleshooterModule.v3beta.PolicyTroubleshooterClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.troubleshootIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.troubleshootIamPolicy(request), expectedError); + }); + + it('invokes troubleshootIamPolicy with closed client', async () => { + const client = new policytroubleshooterModule.v3beta.PolicyTroubleshooterClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.troubleshootIamPolicy(request), expectedError); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/tsconfig.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/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-policytroubleshooter-iam/v3beta/webpack.config.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/webpack.config.js new file mode 100644 index 00000000000..f423e0d5294 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/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: 'Policies', + filename: './policies.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-policytroubleshooter/v1/.eslintignore b/owl-bot-staging/google-cloud-policytroubleshooter/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/.eslintrc.json b/owl-bot-staging/google-cloud-policytroubleshooter/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/.gitignore b/owl-bot-staging/google-cloud-policytroubleshooter/v1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/.jsdoc.js b/owl-bot-staging/google-cloud-policytroubleshooter/v1/.jsdoc.js new file mode 100644 index 00000000000..4e108ab141e --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/.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/policy-troubleshooter', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/.mocharc.js b/owl-bot-staging/google-cloud-policytroubleshooter/v1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/.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-policytroubleshooter/v1/.prettierrc.js b/owl-bot-staging/google-cloud-policytroubleshooter/v1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/.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-policytroubleshooter/v1/README.md b/owl-bot-staging/google-cloud-policytroubleshooter/v1/README.md new file mode 100644 index 00000000000..d7265c118dc --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/README.md @@ -0,0 +1 @@ +Policytroubleshooter: Nodejs Client diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/package.json b/owl-bot-staging/google-cloud-policytroubleshooter/v1/package.json new file mode 100644 index 00000000000..d55249ffd9d --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/policy-troubleshooter", + "version": "0.1.0", + "description": "Policytroubleshooter client for Node.js", + "repository": "googleapis/nodejs-policytroubleshooter", + "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 policytroubleshooter", + "policytroubleshooter", + "iam checker" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/protos/google/cloud/policytroubleshooter/v1/checker.proto b/owl-bot-staging/google-cloud-policytroubleshooter/v1/protos/google/cloud/policytroubleshooter/v1/checker.proto new file mode 100644 index 00000000000..ebefb7b6af3 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/protos/google/cloud/policytroubleshooter/v1/checker.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.policytroubleshooter.v1; + +import public "google/cloud/policytroubleshooter/v1/explanations.proto"; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/rpc/status.proto"; + +option cc_enable_arenas = true; +option csharp_namespace = "Google.Cloud.PolicyTroubleshooter.V1"; +option go_package = "cloud.google.com/go/policytroubleshooter/apiv1/policytroubleshooterpb;policytroubleshooterpb"; +option java_multiple_files = true; +option java_outer_classname = "IAMCheckerProto"; +option java_package = "com.google.cloud.policytroubleshooter.v1"; +option php_namespace = "Google\\Cloud\\PolicyTroubleshooter\\V1"; +option ruby_package = "Google::Cloud::PolicyTroubleshooter::V1"; + +// IAM Policy Troubleshooter service. +// +// This service helps you troubleshoot access issues for Google Cloud resources. +service IamChecker { + option (google.api.default_host) = "policytroubleshooter.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Checks whether a principal has a specific permission for a specific + // resource, and explains why the principal does or does not have that + // permission. + rpc TroubleshootIamPolicy(TroubleshootIamPolicyRequest) + returns (TroubleshootIamPolicyResponse) { + option (google.api.http) = { + post: "/v1/iam:troubleshoot" + body: "*" + }; + } +} + +// Request for +// [TroubleshootIamPolicy][google.cloud.policytroubleshooter.v1.IamChecker.TroubleshootIamPolicy]. +message TroubleshootIamPolicyRequest { + // The information to use for checking whether a principal has a permission + // for a resource. + AccessTuple access_tuple = 1; +} + +// Response for +// [TroubleshootIamPolicy][google.cloud.policytroubleshooter.v1.IamChecker.TroubleshootIamPolicy]. +message TroubleshootIamPolicyResponse { + // Indicates whether the principal has the specified permission for the + // specified resource, based on evaluating all of the applicable IAM policies. + AccessState access = 1; + + // List of IAM policies that were evaluated to check the principal's + // permissions, with annotations to indicate how each policy contributed to + // the final result. + // + // The list of policies can include the policy for the resource itself. It can + // also include policies that are inherited from higher levels of the resource + // hierarchy, including the organization, the folder, and the project. + // + // To learn more about the resource hierarchy, see + // https://cloud.google.com/iam/help/resource-hierarchy. + repeated ExplainedPolicy explained_policies = 2; + + // The general errors contained in the troubleshooting response. + repeated google.rpc.Status errors = 3; +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/protos/google/cloud/policytroubleshooter/v1/explanations.proto b/owl-bot-staging/google-cloud-policytroubleshooter/v1/protos/google/cloud/policytroubleshooter/v1/explanations.proto new file mode 100644 index 00000000000..18d4611eb1c --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/protos/google/cloud/policytroubleshooter/v1/explanations.proto @@ -0,0 +1,247 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.policytroubleshooter.v1; + +import "google/api/field_behavior.proto"; +import "google/iam/v1/policy.proto"; +import "google/type/expr.proto"; + +option csharp_namespace = "Google.Cloud.PolicyTroubleshooter.V1"; +option go_package = "cloud.google.com/go/policytroubleshooter/apiv1/policytroubleshooterpb;policytroubleshooterpb"; +option php_namespace = "Google\\Cloud\\PolicyTroubleshooter\\V1"; +option ruby_package = "Google::Cloud::PolicyTroubleshooter::V1"; + +// Information about the principal, resource, and permission to check. +message AccessTuple { + // Required. The principal whose access you want to check, in the form of + // the email address that represents that principal. For example, + // `alice@example.com` or + // `my-service-account@my-project.iam.gserviceaccount.com`. + // + // The principal must be a Google Account or a service account. Other types of + // principals are not supported. + string principal = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The full resource name that identifies the resource. For example, + // `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`. + // + // For examples of full resource names for Google Cloud services, see + // https://cloud.google.com/iam/help/troubleshooter/full-resource-names. + string full_resource_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The IAM permission to check for the specified principal and + // resource. + // + // For a complete list of IAM permissions, see + // https://cloud.google.com/iam/help/permissions/reference. + // + // For a complete list of predefined IAM roles and the permissions in each + // role, see https://cloud.google.com/iam/help/roles/reference. + string permission = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Details about how a specific IAM [Policy][google.iam.v1.Policy] contributed +// to the access check. +message ExplainedPolicy { + // Indicates whether _this policy_ provides the specified permission to the + // specified principal for the specified resource. + // + // This field does _not_ indicate whether the principal actually has the + // permission for the resource. There might be another policy that overrides + // this policy. To determine whether the principal actually has the + // permission, use the `access` field in the + // [TroubleshootIamPolicyResponse][IamChecker.TroubleshootIamPolicyResponse]. + AccessState access = 1; + + // The full resource name that identifies the resource. For example, + // `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`. + // + // If the sender of the request does not have access to the policy, this field + // is omitted. + // + // For examples of full resource names for Google Cloud services, see + // https://cloud.google.com/iam/help/troubleshooter/full-resource-names. + string full_resource_name = 2; + + // The IAM policy attached to the resource. + // + // If the sender of the request does not have access to the policy, this field + // is empty. + google.iam.v1.Policy policy = 3; + + // Details about how each binding in the policy affects the principal's + // ability, or inability, to use the permission for the resource. + // + // If the sender of the request does not have access to the policy, this field + // is omitted. + repeated BindingExplanation binding_explanations = 4; + + // The relevance of this policy to the overall determination in the + // [TroubleshootIamPolicyResponse][IamChecker.TroubleshootIamPolicyResponse]. + // + // If the sender of the request does not have access to the policy, this field + // is omitted. + HeuristicRelevance relevance = 5; +} + +// Details about how a binding in a policy affects a principal's ability to use +// a permission. +message BindingExplanation { + // Whether a role includes a specific permission. + enum RolePermission { + // Default value. This value is unused. + ROLE_PERMISSION_UNSPECIFIED = 0; + + // The permission is included in the role. + ROLE_PERMISSION_INCLUDED = 1; + + // The permission is not included in the role. + ROLE_PERMISSION_NOT_INCLUDED = 2; + + // The sender of the request is not allowed to access the binding. + ROLE_PERMISSION_UNKNOWN_INFO_DENIED = 3; + } + + // Whether the binding includes the principal. + enum Membership { + // Default value. This value is unused. + MEMBERSHIP_UNSPECIFIED = 0; + + // The binding includes the principal. The principal can be included + // directly or indirectly. For example: + // + // * A principal is included directly if that principal is listed in the + // binding. + // * A principal is included indirectly if that principal is in a Google + // group or Google Workspace domain that is listed in the binding. + MEMBERSHIP_INCLUDED = 1; + + // The binding does not include the principal. + MEMBERSHIP_NOT_INCLUDED = 2; + + // The sender of the request is not allowed to access the binding. + MEMBERSHIP_UNKNOWN_INFO_DENIED = 3; + + // The principal is an unsupported type. Only Google Accounts and service + // accounts are supported. + MEMBERSHIP_UNKNOWN_UNSUPPORTED = 4; + } + + // Details about whether the binding includes the principal. + message AnnotatedMembership { + // Indicates whether the binding includes the principal. + Membership membership = 1; + + // The relevance of the principal's status to the overall determination for + // the binding. + HeuristicRelevance relevance = 2; + } + + // Required. Indicates whether _this binding_ provides the specified + // permission to the specified principal for the specified resource. + // + // This field does _not_ indicate whether the principal actually has the + // permission for the resource. There might be another binding that overrides + // this binding. To determine whether the principal actually has the + // permission, use the `access` field in the + // [TroubleshootIamPolicyResponse][IamChecker.TroubleshootIamPolicyResponse]. + AccessState access = 1 [(google.api.field_behavior) = REQUIRED]; + + // The role that this binding grants. For example, + // `roles/compute.serviceAgent`. + // + // For a complete list of predefined IAM roles, as well as the permissions in + // each role, see https://cloud.google.com/iam/help/roles/reference. + string role = 2; + + // Indicates whether the role granted by this binding contains the specified + // permission. + RolePermission role_permission = 3; + + // The relevance of the permission's existence, or nonexistence, in the role + // to the overall determination for the entire policy. + HeuristicRelevance role_permission_relevance = 4; + + // Indicates whether each principal in the binding includes the principal + // specified in the request, either directly or indirectly. Each key + // identifies a principal in the binding, and each value indicates whether the + // principal in the binding includes the principal in the request. + // + // For example, suppose that a binding includes the following principals: + // + // * `user:alice@example.com` + // * `group:product-eng@example.com` + // + // You want to troubleshoot access for `user:bob@example.com`. This user is a + // principal of the group `group:product-eng@example.com`. + // + // For the first principal in the binding, the key is + // `user:alice@example.com`, and the `membership` field in the value is set to + // `MEMBERSHIP_NOT_INCLUDED`. + // + // For the second principal in the binding, the key is + // `group:product-eng@example.com`, and the `membership` field in the value is + // set to `MEMBERSHIP_INCLUDED`. + map memberships = 5; + + // The relevance of this binding to the overall determination for the entire + // policy. + HeuristicRelevance relevance = 6; + + // A condition expression that prevents this binding from granting access + // unless the expression evaluates to `true`. + // + // To learn about IAM Conditions, see + // https://cloud.google.com/iam/help/conditions/overview. + google.type.Expr condition = 7; +} + +// Whether a principal has a permission for a resource. +enum AccessState { + // Default value. This value is unused. + ACCESS_STATE_UNSPECIFIED = 0; + + // The principal has the permission. + GRANTED = 1; + + // The principal does not have the permission. + NOT_GRANTED = 2; + + // The principal has the permission only if a condition expression evaluates + // to `true`. + UNKNOWN_CONDITIONAL = 3; + + // The sender of the request does not have access to all of the policies that + // Policy Troubleshooter needs to evaluate. + UNKNOWN_INFO_DENIED = 4; +} + +// The extent to which a single data point, such as the existence of a binding +// or whether a binding includes a specific principal, contributes to an overall +// determination. +enum HeuristicRelevance { + // Default value. This value is unused. + HEURISTIC_RELEVANCE_UNSPECIFIED = 0; + + // The data point has a limited effect on the result. Changing the data point + // is unlikely to affect the overall determination. + NORMAL = 1; + + // The data point has a strong effect on the result. Changing the data point + // is likely to affect the overall determination. + HIGH = 2; +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/samples/generated/v1/iam_checker.troubleshoot_iam_policy.js b/owl-bot-staging/google-cloud-policytroubleshooter/v1/samples/generated/v1/iam_checker.troubleshoot_iam_policy.js new file mode 100644 index 00000000000..81f3d5f5e0e --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/samples/generated/v1/iam_checker.troubleshoot_iam_policy.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 policytroubleshooter_v1_generated_IamChecker_TroubleshootIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 information to use for checking whether a principal has a permission + * for a resource. + */ + // const accessTuple = {} + + // Imports the Policytroubleshooter library + const {IamCheckerClient} = require('@google-cloud/policy-troubleshooter').v1; + + // Instantiates a client + const policytroubleshooterClient = new IamCheckerClient(); + + async function callTroubleshootIamPolicy() { + // Construct request + const request = { + }; + + // Run request + const response = await policytroubleshooterClient.troubleshootIamPolicy(request); + console.log(response); + } + + callTroubleshootIamPolicy(); + // [END policytroubleshooter_v1_generated_IamChecker_TroubleshootIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/samples/generated/v1/snippet_metadata_google.cloud.policytroubleshooter.v1.json b/owl-bot-staging/google-cloud-policytroubleshooter/v1/samples/generated/v1/snippet_metadata_google.cloud.policytroubleshooter.v1.json new file mode 100644 index 00000000000..9c38afc4ec0 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/samples/generated/v1/snippet_metadata_google.cloud.policytroubleshooter.v1.json @@ -0,0 +1,55 @@ +{ + "clientLibrary": { + "name": "nodejs-policytroubleshooter", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.policytroubleshooter.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "policytroubleshooter_v1_generated_IamChecker_TroubleshootIamPolicy_async", + "title": "IamChecker troubleshootIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Checks whether a principal has a specific permission for a specific resource, and explains why the principal does or does not have that permission.", + "canonical": true, + "file": "iam_checker.troubleshoot_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TroubleshootIamPolicy", + "fullName": "google.cloud.policytroubleshooter.v1.IamChecker.TroubleshootIamPolicy", + "async": true, + "parameters": [ + { + "name": "access_tuple", + "type": ".google.cloud.policytroubleshooter.v1.AccessTuple" + } + ], + "resultType": ".google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyResponse", + "client": { + "shortName": "IamCheckerClient", + "fullName": "google.cloud.policytroubleshooter.v1.IamCheckerClient" + }, + "method": { + "shortName": "TroubleshootIamPolicy", + "fullName": "google.cloud.policytroubleshooter.v1.IamChecker.TroubleshootIamPolicy", + "service": { + "shortName": "IamChecker", + "fullName": "google.cloud.policytroubleshooter.v1.IamChecker" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/index.ts b/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/index.ts new file mode 100644 index 00000000000..d8ee5214153 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const IamCheckerClient = v1.IamCheckerClient; +type IamCheckerClient = v1.IamCheckerClient; +export {v1, IamCheckerClient}; +export default {v1, IamCheckerClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..daff31dc6c1 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/gapic_metadata.json @@ -0,0 +1,33 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.policytroubleshooter.v1", + "libraryPackage": "@google-cloud/policy-troubleshooter", + "services": { + "IamChecker": { + "clients": { + "grpc": { + "libraryClient": "IamCheckerClient", + "rpcs": { + "TroubleshootIamPolicy": { + "methods": [ + "troubleshootIamPolicy" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "IamCheckerClient", + "rpcs": { + "TroubleshootIamPolicy": { + "methods": [ + "troubleshootIamPolicy" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_client.ts b/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_client.ts new file mode 100644 index 00000000000..9a9e2908281 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_client.ts @@ -0,0 +1,376 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/iam_checker_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './iam_checker_client_config.json'; +const version = require('../../../package.json').version; + +/** + * IAM Policy Troubleshooter service. + * + * This service helps you troubleshoot access issues for Google Cloud resources. + * @class + * @memberof v1 + */ +export class IamCheckerClient { + 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}; + iamCheckerStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of IamCheckerClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 IamCheckerClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof IamCheckerClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.policytroubleshooter.v1.IamChecker', 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.iamCheckerStub) { + return this.iamCheckerStub; + } + + // Put together the "service stub" for + // google.cloud.policytroubleshooter.v1.IamChecker. + this.iamCheckerStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.policytroubleshooter.v1.IamChecker') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.policytroubleshooter.v1.IamChecker, + 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 iamCheckerStubMethods = + ['troubleshootIamPolicy']; + for (const methodName of iamCheckerStubMethods) { + const callPromise = this.iamCheckerStub.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.iamCheckerStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'policytroubleshooter.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 'policytroubleshooter.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 -- + // ------------------- +/** + * Checks whether a principal has a specific permission for a specific + * resource, and explains why the principal does or does not have that + * permission. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.policytroubleshooter.v1.AccessTuple} request.accessTuple + * The information to use for checking whether a principal has a permission + * for a resource. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyResponse|TroubleshootIamPolicyResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/iam_checker.troubleshoot_iam_policy.js + * region_tag:policytroubleshooter_v1_generated_IamChecker_TroubleshootIamPolicy_async + */ + troubleshootIamPolicy( + request?: protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyResponse, + protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest|undefined, {}|undefined + ]>; + troubleshootIamPolicy( + request: protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyResponse, + protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + troubleshootIamPolicy( + request: protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest, + callback: Callback< + protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyResponse, + protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + troubleshootIamPolicy( + request?: protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyResponse, + protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyResponse, + protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyResponse, + protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.troubleshootIamPolicy(request, options, callback); + } + + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.iamCheckerStub && !this._terminated) { + return this.iamCheckerStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_client_config.json b/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_client_config.json new file mode 100644 index 00000000000..6d70cf67ac3 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_client_config.json @@ -0,0 +1,31 @@ +{ + "interfaces": { + "google.cloud.policytroubleshooter.v1.IamChecker": { + "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": { + "TroubleshootIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_proto_list.json b/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_proto_list.json new file mode 100644 index 00000000000..3da19f410cc --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_proto_list.json @@ -0,0 +1,4 @@ +[ + "../../protos/google/cloud/policytroubleshooter/v1/checker.proto", + "../../protos/google/cloud/policytroubleshooter/v1/explanations.proto" +] diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/index.ts new file mode 100644 index 00000000000..0986c6e6fce --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {IamCheckerClient} from './iam_checker_client'; diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..63c539e92de --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const policytroubleshooter = require('@google-cloud/policy-troubleshooter'); + +function main() { + const iamCheckerClient = new policytroubleshooter.IamCheckerClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..26430b75adf --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {IamCheckerClient} from '@google-cloud/policy-troubleshooter'; + +// check that the client class type name can be used +function doStuffWithIamCheckerClient(client: IamCheckerClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const iamCheckerClient = new IamCheckerClient(); + doStuffWithIamCheckerClient(iamCheckerClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/install.ts b/owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/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-policytroubleshooter/v1/test/gapic_iam_checker_v1.ts b/owl-bot-staging/google-cloud-policytroubleshooter/v1/test/gapic_iam_checker_v1.ts new file mode 100644 index 00000000000..aa508cbb6ed --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/test/gapic_iam_checker_v1.ts @@ -0,0 +1,225 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 iamcheckerModule from '../src'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +describe('v1.IamCheckerClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = iamcheckerModule.v1.IamCheckerClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = iamcheckerModule.v1.IamCheckerClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = iamcheckerModule.v1.IamCheckerClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new iamcheckerModule.v1.IamCheckerClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new iamcheckerModule.v1.IamCheckerClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new iamcheckerModule.v1.IamCheckerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.iamCheckerStub, undefined); + await client.initialize(); + assert(client.iamCheckerStub); + }); + + it('has close method for the initialized client', done => { + const client = new iamcheckerModule.v1.IamCheckerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.iamCheckerStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new iamcheckerModule.v1.IamCheckerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.iamCheckerStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new iamcheckerModule.v1.IamCheckerClient({ + 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 iamcheckerModule.v1.IamCheckerClient({ + 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('troubleshootIamPolicy', () => { + it('invokes troubleshootIamPolicy without error', async () => { + const client = new iamcheckerModule.v1.IamCheckerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyResponse() + ); + client.innerApiCalls.troubleshootIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.troubleshootIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes troubleshootIamPolicy without error using callback', async () => { + const client = new iamcheckerModule.v1.IamCheckerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyResponse() + ); + client.innerApiCalls.troubleshootIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.troubleshootIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes troubleshootIamPolicy with error', async () => { + const client = new iamcheckerModule.v1.IamCheckerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.troubleshootIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.troubleshootIamPolicy(request), expectedError); + }); + + it('invokes troubleshootIamPolicy with closed client', async () => { + const client = new iamcheckerModule.v1.IamCheckerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.troubleshootIamPolicy(request), expectedError); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/tsconfig.json b/owl-bot-staging/google-cloud-policytroubleshooter/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/webpack.config.js b/owl-bot-staging/google-cloud-policytroubleshooter/v1/webpack.config.js new file mode 100644 index 00000000000..3fbe558bc97 --- /dev/null +++ b/owl-bot-staging/google-cloud-policytroubleshooter/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'IamChecker', + filename: './iam-checker.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-privatecatalog/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.gitignore b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.jsdoc.js new file mode 100644 index 00000000000..aefbb43f80f --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.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/private-catalog', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.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-privatecatalog/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.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-privatecatalog/v1beta1/README.md b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/README.md new file mode 100644 index 00000000000..0b9f815350d --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/README.md @@ -0,0 +1 @@ +Privatecatalog: Nodejs Client diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/package.json b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/package.json new file mode 100644 index 00000000000..61599b4ec3e --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/private-catalog", + "version": "0.1.0", + "description": "Privatecatalog client for Node.js", + "repository": "googleapis/nodejs-privatecatalog", + "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 privatecatalog", + "privatecatalog", + "private catalog" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/protos/google/cloud/privatecatalog/v1beta1/private_catalog.proto b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/protos/google/cloud/privatecatalog/v1beta1/private_catalog.proto new file mode 100644 index 00000000000..1ee77714357 --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/protos/google/cloud/privatecatalog/v1beta1/private_catalog.proto @@ -0,0 +1,556 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.privatecatalog.v1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.PrivateCatalog.V1Beta1"; +option go_package = "cloud.google.com/go/privatecatalog/apiv1beta1/privatecatalogpb;privatecatalogpb"; +option java_multiple_files = true; +option java_outer_classname = "PrivateCatalogProto"; +option java_package = "com.google.cloud.privatecatalog.v1beta1"; +option php_namespace = "Google\\Cloud\\PrivateCatalog\\V1beta1"; +option ruby_package = "Google::Cloud::PrivateCatalog::V1beta1"; + +// `PrivateCatalog` allows catalog consumers to retrieve `Catalog`, `Product` +// and `Version` resources under a target resource context. +// +// `Catalog` is computed based on the [Association][]s linked to the target +// resource and its ancestors. Each association's +// [google.cloud.privatecatalogproducer.v1beta.Catalog][] is transformed into a +// `Catalog`. If multiple associations have the same parent +// [google.cloud.privatecatalogproducer.v1beta.Catalog][], they are +// de-duplicated into one `Catalog`. Users must have +// `cloudprivatecatalog.catalogTargets.get` IAM permission on the resource +// context in order to access catalogs. `Catalog` contains the resource name and +// a subset of data of the original +// [google.cloud.privatecatalogproducer.v1beta.Catalog][]. +// +// `Product` is child resource of the catalog. A `Product` contains the resource +// name and a subset of the data of the original +// [google.cloud.privatecatalogproducer.v1beta.Product][]. +// +// `Version` is child resource of the product. A `Version` contains the resource +// name and a subset of the data of the original +// [google.cloud.privatecatalogproducer.v1beta.Version][]. +service PrivateCatalog { + option (google.api.default_host) = "cloudprivatecatalog.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Search [Catalog][google.cloud.privatecatalog.v1beta1.Catalog] resources that consumers have access to, within the + // scope of the consumer cloud resource hierarchy context. + rpc SearchCatalogs(SearchCatalogsRequest) returns (SearchCatalogsResponse) { + option (google.api.http) = { + get: "/v1beta1/{resource=projects/*}/catalogs:search" + additional_bindings { + get: "/v1beta1/{resource=organizations/*}/catalogs:search" + } + additional_bindings { + get: "/v1beta1/{resource=folders/*}/catalogs:search" + } + }; + } + + // Search [Product][google.cloud.privatecatalog.v1beta1.Product] resources that consumers have access to, within the + // scope of the consumer cloud resource hierarchy context. + rpc SearchProducts(SearchProductsRequest) returns (SearchProductsResponse) { + option (google.api.http) = { + get: "/v1beta1/{resource=projects/*}/products:search" + additional_bindings { + get: "/v1beta1/{resource=organizations/*}/products:search" + } + additional_bindings { + get: "/v1beta1/{resource=folders/*}/products:search" + } + }; + } + + // Search [Version][google.cloud.privatecatalog.v1beta1.Version] resources that consumers have access to, within the + // scope of the consumer cloud resource hierarchy context. + rpc SearchVersions(SearchVersionsRequest) returns (SearchVersionsResponse) { + option (google.api.http) = { + get: "/v1beta1/{resource=projects/*}/versions:search" + additional_bindings { + get: "/v1beta1/{resource=organizations/*}/versions:search" + } + additional_bindings { + get: "/v1beta1/{resource=folders/*}/versions:search" + } + }; + } +} + +// Request message for [PrivateCatalog.SearchCatalogs][google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchCatalogs]. +message SearchCatalogsRequest { + // Required. The name of the resource context. It can be in following formats: + // + // * `projects/{project}` + // * `folders/{folder}` + // * `organizations/{organization}` + string resource = 1 [(google.api.field_behavior) = REQUIRED]; + + // The query to filter the catalogs. The supported queries are: + // + // * Get a single catalog: `name=catalogs/{catalog}` + string query = 2; + + // The maximum number of entries that are requested. + int32 page_size = 3; + + // A pagination token returned from a previous call to SearchCatalogs that + // indicates where this listing should continue from. + string page_token = 4; +} + +// Response message for [PrivateCatalog.SearchCatalogs][google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchCatalogs]. +message SearchCatalogsResponse { + // The `Catalog`s computed from the resource context. + repeated Catalog catalogs = 1; + + // A pagination token returned from a previous call to SearchCatalogs that + // indicates from where listing should continue. + string next_page_token = 2; +} + +// Request message for [PrivateCatalog.SearchProducts][google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchProducts]. +message SearchProductsRequest { + // Required. The name of the resource context. See [SearchCatalogsRequest.resource][google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource] + // for details. + string resource = 1 [(google.api.field_behavior) = REQUIRED]; + + // The query to filter the products. + // + // The supported queries are: + // * List products of all catalogs: empty + // * List products under a catalog: `parent=catalogs/{catalog}` + // * Get a product by name: + // `name=catalogs/{catalog}/products/{product}` + string query = 2; + + // The maximum number of entries that are requested. + int32 page_size = 3; + + // A pagination token returned from a previous call to SearchProducts that + // indicates where this listing should continue from. + string page_token = 4; +} + +// Response message for [PrivateCatalog.SearchProducts][google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchProducts]. +message SearchProductsResponse { + // The `Product` resources computed from the resource context. + repeated Product products = 1; + + // A pagination token returned from a previous call to SearchProducts that + // indicates from where listing should continue. + string next_page_token = 2; +} + +// Request message for [PrivateCatalog.SearchVersions][google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchVersions]. +message SearchVersionsRequest { + // Required. The name of the resource context. See [SearchCatalogsRequest.resource][google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource] + // for details. + string resource = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The query to filter the versions. + // + // The supported queries are: + // * List versions under a product: + // `parent=catalogs/{catalog}/products/{product}` + // * Get a version by name: + // `name=catalogs/{catalog}/products/{product}/versions/{version}` + string query = 2 [(google.api.field_behavior) = REQUIRED]; + + // The maximum number of entries that are requested. + int32 page_size = 3; + + // A pagination token returned from a previous call to SearchVersions + // that indicates where this listing should continue from. + string page_token = 4; +} + +// Response message for [PrivateCatalog.SearchVersions][google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchVersions]. +message SearchVersionsResponse { + // The `Version` resources computed from the resource context. + repeated Version versions = 1; + + // A pagination token returned from a previous call to SearchVersions that + // indicates from where the listing should continue. + string next_page_token = 2; +} + +// The readonly representation of a catalog computed with a given resource +// context. +message Catalog { + option (google.api.resource) = { + type: "cloudprivatecatalog.googleapis.com/Catalog" + pattern: "catalogs/{catalog}" + }; + + // Output only. The resource name of the target catalog, in the format of + // `catalogs/{catalog}'. + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The descriptive name of the catalog as it appears in UIs. + string display_name = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The description of the catalog. + string description = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time when the catalog was created. + google.protobuf.Timestamp create_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time when the catalog was last updated. + google.protobuf.Timestamp update_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The readonly representation of a product computed with a given resource +// context. +message Product { + option (google.api.resource) = { + type: "cloudprivatecatalog.googleapis.com/Product" + pattern: "products/{product}" + }; + + // Output only. The resource name of the target product, in the format of + // `products/[a-z][-a-z0-9]*[a-z0-9]'. + // + // A unique identifier for the product under a catalog. + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The type of the product asset. It can be one of the following values: + // + // * `google.deploymentmanager.Template` + // * `google.cloudprivatecatalog.ListingOnly` + // * `google.cloudprivatecatalog.Terraform` + string asset_type = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. Output only. The display metadata to describe the product. The JSON schema of the + // metadata differs by [Product.asset_type][google.cloud.privatecatalog.v1beta1.Product.asset_type]. + // When the type is `google.deploymentmanager.Template`, the schema is as + // follows: + // + // ``` + // "$schema": http://json-schema.org/draft-04/schema# + // type: object + // properties: + // name: + // type: string + // minLength: 1 + // maxLength: 64 + // description: + // type: string + // minLength: 1 + // maxLength: 2048 + // tagline: + // type: string + // minLength: 1 + // maxLength: 100 + // support_info: + // type: string + // minLength: 1 + // maxLength: 2048 + // creator: + // type: string + // minLength: 1 + // maxLength: 100 + // documentations: + // type: array + // items: + // type: object + // properties: + // url: + // type: string + // pattern: + // "^(https?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]" + // title: + // type: string + // minLength: 1 + // maxLength: 64 + // description: + // type: string + // minLength: 1 + // maxLength: 2048 + // required: + // - name + // - description + // additionalProperties: false + // + // ``` + // + // When the asset type is `google.cloudprivatecatalog.ListingOnly`, the schema + // is as follows: + // + // ``` + // "$schema": http://json-schema.org/draft-04/schema# + // type: object + // properties: + // name: + // type: string + // minLength: 1 + // maxLength: 64 + // description: + // type: string + // minLength: 1 + // maxLength: 2048 + // tagline: + // type: string + // minLength: 1 + // maxLength: 100 + // support_info: + // type: string + // minLength: 1 + // maxLength: 2048 + // creator: + // type: string + // minLength: 1 + // maxLength: 100 + // documentations: + // type: array + // items: + // type: object + // properties: + // url: + // type: string + // pattern: + // "^(https?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]" + // title: + // type: string + // minLength: 1 + // maxLength: 64 + // description: + // type: string + // minLength: 1 + // maxLength: 2048 + // signup_url: + // type: string + // pattern: + // "^(https?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]" + // required: + // - name + // - description + // - signup_url + // additionalProperties: false + // + // ``` + // + // When the asset type is `google.cloudprivatecatalog.Terraform`, the schema + // is as follows: + // + // ``` + // "$schema": http://json-schema.org/draft-04/schema# + // type: object + // properties: + // name: + // type: string + // minLength: 1 + // maxLength: 64 + // description: + // type: string + // minLength: 1 + // maxLength: 2048 + // tagline: + // type: string + // minLength: 1 + // maxLength: 100 + // support_info: + // type: string + // minLength: 1 + // maxLength: 2048 + // creator: + // type: string + // minLength: 1 + // maxLength: 100 + // documentations: + // type: array + // items: + // type: object + // properties: + // url: + // type: string + // pattern: + // "^(https?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]" + // title: + // type: string + // minLength: 1 + // maxLength: 64 + // description: + // type: string + // minLength: 1 + // maxLength: 2048 + // required: + // - name + // - description + // additionalProperties: true + google.protobuf.Struct display_metadata = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = OUTPUT_ONLY + ]; + + // Output only. The icon URI of the product. + string icon_uri = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A collection of assets referred by a product. + // This field is set for Terraform Products only. + repeated AssetReference asset_references = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time when the product was created. + google.protobuf.Timestamp create_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time when the product was last updated. + google.protobuf.Timestamp update_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Defines the reference of an asset belonging to a product. +message AssetReference { + // Possible validation steates of an asset reference. + enum AssetValidationState { + // Unknown state. + ASSET_VALIDATION_STATE_UNSPECIFIED = 0; + + // The validation is still in process. + PENDING = 1; + + // The validation is done and the asset reference is valid. + VALID = 2; + + // The validation is done and the asset reference is invalid. + INVALID = 3; + } + + // Output only. A unique identifier among asset references in a product. + string id = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The human-readable description of the referenced asset. Maximum 256 + // characters in length. + string description = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The definition of input parameters to hydrate the asset template. + Inputs inputs = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The current state of the asset reference. + AssetValidationState validation_status = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The validation process metadata. + google.longrunning.Operation validation_operation = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The destination of the asset. + oneof source { + // Output only. The asset resource name if an asset is hosted by Private Catalog. + string asset = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The cloud storage object path. + string gcs_path = 11 [ + deprecated = true, + (google.api.field_behavior) = OUTPUT_ONLY + ]; + + // Output only. The git source. + GitSource git_source = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; + } + + // Output only. The cloud storage source. + GcsSource gcs_source = 16 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The creation timestamp of the asset reference. + google.protobuf.Timestamp create_time = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last update timestamp of the asset reference. + google.protobuf.Timestamp update_time = 13 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The version of the source used for this asset reference. + string version = 14 [deprecated = true]; +} + +// Defines definition of input parameters of asset templates. +message Inputs { + // Output only. The JSON schema defining the inputs and their formats. + google.protobuf.Struct parameters = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Defines how to access Cloud Storage source. +message GcsSource { + // Output only. the cloud storage object path. + string gcs_path = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Generation of the object, which is set when the content of an object starts + // being written. + int64 generation = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time when the object metadata was last changed. + google.protobuf.Timestamp update_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Defines how to access a Git Source. +message GitSource { + // Location of the Git repo to build. + string repo = 1; + + // Directory, relative to the source root, in which to run the build. + // + // This must be a relative path. If a step's `dir` is specified and is an + // absolute path, this value is ignored for that step's execution. + string dir = 2; + + // The revision to fetch from the Git repository such as a branch, a tag, a + // commit SHA, or any Git ref. + oneof ref { + // The revision commit to use. + string commit = 3; + + // The revision branch to use. + string branch = 4; + + // The revision tag to use. + string tag = 5; + } +} + +// The consumer representation of a version which is a child resource under a +// `Product` with asset data. +message Version { + option (google.api.resource) = { + type: "cloudprivatecatalog.googleapis.com/Version" + pattern: "catalogs/{catalog}/products/{product}/versions/{version}" + }; + + // Output only. The resource name of the version, in the format + // `catalogs/{catalog}/products/{product}/versions/[a-z][-a-z0-9]*[a-z0-9]'. + // + // A unique identifier for the version under a product. + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The user-supplied description of the version. Maximum of 256 + // characters. + string description = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The asset which has been validated and is ready to be + // provisioned. See + // [google.cloud.privatecatalogproducer.v1beta.Version.asset][] for details. + google.protobuf.Struct asset = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time when the version was created. + google.protobuf.Timestamp create_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time when the version was last updated. + google.protobuf.Timestamp update_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_catalogs.js b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_catalogs.js new file mode 100644 index 00000000000..7b53967a42d --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_catalogs.js @@ -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. ** + + + +'use strict'; + +function main(resource) { + // [START cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchCatalogs_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 resource context. It can be in following formats: + * * `projects/{project}` + * * `folders/{folder}` + * * `organizations/{organization}` + */ + // const resource = 'abc123' + /** + * The query to filter the catalogs. The supported queries are: + * * Get a single catalog: `name=catalogs/{catalog}` + */ + // const query = 'abc123' + /** + * The maximum number of entries that are requested. + */ + // const pageSize = 1234 + /** + * A pagination token returned from a previous call to SearchCatalogs that + * indicates where this listing should continue from. + */ + // const pageToken = 'abc123' + + // Imports the Privatecatalog library + const {PrivateCatalogClient} = require('@google-cloud/private-catalog').v1beta1; + + // Instantiates a client + const privatecatalogClient = new PrivateCatalogClient(); + + async function callSearchCatalogs() { + // Construct request + const request = { + resource, + }; + + // Run request + const iterable = await privatecatalogClient.searchCatalogsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearchCatalogs(); + // [END cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchCatalogs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_products.js b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_products.js new file mode 100644 index 00000000000..7dd109ea62a --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_products.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(resource) { + // [START cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 resource context. See SearchCatalogsRequest.resource google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource + * for details. + */ + // const resource = 'abc123' + /** + * The query to filter the products. + * The supported queries are: + * * List products of all catalogs: empty + * * List products under a catalog: `parent=catalogs/{catalog}` + * * Get a product by name: + * `name=catalogs/{catalog}/products/{product}` + */ + // const query = 'abc123' + /** + * The maximum number of entries that are requested. + */ + // const pageSize = 1234 + /** + * A pagination token returned from a previous call to SearchProducts that + * indicates where this listing should continue from. + */ + // const pageToken = 'abc123' + + // Imports the Privatecatalog library + const {PrivateCatalogClient} = require('@google-cloud/private-catalog').v1beta1; + + // Instantiates a client + const privatecatalogClient = new PrivateCatalogClient(); + + async function callSearchProducts() { + // Construct request + const request = { + resource, + }; + + // Run request + const iterable = await privatecatalogClient.searchProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearchProducts(); + // [END cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_versions.js b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_versions.js new file mode 100644 index 00000000000..4ebfd5bf29b --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_versions.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(resource, query) { + // [START cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchVersions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 resource context. See SearchCatalogsRequest.resource google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource + * for details. + */ + // const resource = 'abc123' + /** + * Required. The query to filter the versions. + * The supported queries are: + * * List versions under a product: + * `parent=catalogs/{catalog}/products/{product}` + * * Get a version by name: + * `name=catalogs/{catalog}/products/{product}/versions/{version}` + */ + // const query = 'abc123' + /** + * The maximum number of entries that are requested. + */ + // const pageSize = 1234 + /** + * A pagination token returned from a previous call to SearchVersions + * that indicates where this listing should continue from. + */ + // const pageToken = 'abc123' + + // Imports the Privatecatalog library + const {PrivateCatalogClient} = require('@google-cloud/private-catalog').v1beta1; + + // Instantiates a client + const privatecatalogClient = new PrivateCatalogClient(); + + async function callSearchVersions() { + // Construct request + const request = { + resource, + query, + }; + + // Run request + const iterable = await privatecatalogClient.searchVersionsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearchVersions(); + // [END cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchVersions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.privatecatalog.v1beta1.json b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.privatecatalog.v1beta1.json new file mode 100644 index 00000000000..fabcb9253d9 --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.privatecatalog.v1beta1.json @@ -0,0 +1,171 @@ +{ + "clientLibrary": { + "name": "nodejs-privatecatalog", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.privatecatalog.v1beta1", + "version": "v1beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchCatalogs_async", + "title": "PrivateCatalog searchCatalogs Sample", + "origin": "API_DEFINITION", + "description": " Search [Catalog][google.cloud.privatecatalog.v1beta1.Catalog] resources that consumers have access to, within the scope of the consumer cloud resource hierarchy context.", + "canonical": true, + "file": "private_catalog.search_catalogs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SearchCatalogs", + "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchCatalogs", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.privatecatalog.v1beta1.SearchCatalogsResponse", + "client": { + "shortName": "PrivateCatalogClient", + "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalogClient" + }, + "method": { + "shortName": "SearchCatalogs", + "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchCatalogs", + "service": { + "shortName": "PrivateCatalog", + "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog" + } + } + } + }, + { + "regionTag": "cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchProducts_async", + "title": "PrivateCatalog searchProducts Sample", + "origin": "API_DEFINITION", + "description": " Search [Product][google.cloud.privatecatalog.v1beta1.Product] resources that consumers have access to, within the scope of the consumer cloud resource hierarchy context.", + "canonical": true, + "file": "private_catalog.search_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 74, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SearchProducts", + "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchProducts", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.privatecatalog.v1beta1.SearchProductsResponse", + "client": { + "shortName": "PrivateCatalogClient", + "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalogClient" + }, + "method": { + "shortName": "SearchProducts", + "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchProducts", + "service": { + "shortName": "PrivateCatalog", + "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog" + } + } + } + }, + { + "regionTag": "cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchVersions_async", + "title": "PrivateCatalog searchVersions Sample", + "origin": "API_DEFINITION", + "description": " Search [Version][google.cloud.privatecatalog.v1beta1.Version] resources that consumers have access to, within the scope of the consumer cloud resource hierarchy context.", + "canonical": true, + "file": "private_catalog.search_versions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SearchVersions", + "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchVersions", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.privatecatalog.v1beta1.SearchVersionsResponse", + "client": { + "shortName": "PrivateCatalogClient", + "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalogClient" + }, + "method": { + "shortName": "SearchVersions", + "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchVersions", + "service": { + "shortName": "PrivateCatalog", + "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/index.ts new file mode 100644 index 00000000000..b270b97e185 --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1beta1 from './v1beta1'; +const PrivateCatalogClient = v1beta1.PrivateCatalogClient; +type PrivateCatalogClient = v1beta1.PrivateCatalogClient; +export {v1beta1, PrivateCatalogClient}; +export default {v1beta1, PrivateCatalogClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/gapic_metadata.json new file mode 100644 index 00000000000..191f515a726 --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/gapic_metadata.json @@ -0,0 +1,65 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.privatecatalog.v1beta1", + "libraryPackage": "@google-cloud/private-catalog", + "services": { + "PrivateCatalog": { + "clients": { + "grpc": { + "libraryClient": "PrivateCatalogClient", + "rpcs": { + "SearchCatalogs": { + "methods": [ + "searchCatalogs", + "searchCatalogsStream", + "searchCatalogsAsync" + ] + }, + "SearchProducts": { + "methods": [ + "searchProducts", + "searchProductsStream", + "searchProductsAsync" + ] + }, + "SearchVersions": { + "methods": [ + "searchVersions", + "searchVersionsStream", + "searchVersionsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "PrivateCatalogClient", + "rpcs": { + "SearchCatalogs": { + "methods": [ + "searchCatalogs", + "searchCatalogsStream", + "searchCatalogsAsync" + ] + }, + "SearchProducts": { + "methods": [ + "searchProducts", + "searchProductsStream", + "searchProductsAsync" + ] + }, + "SearchVersions": { + "methods": [ + "searchVersions", + "searchVersionsStream", + "searchVersionsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/index.ts new file mode 100644 index 00000000000..b81fb955db1 --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {PrivateCatalogClient} from './private_catalog_client'; diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_client.ts b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_client.ts new file mode 100644 index 00000000000..67334899b08 --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_client.ts @@ -0,0 +1,1053 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta1/private_catalog_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './private_catalog_client_config.json'; +const version = require('../../../package.json').version; + +/** + * `PrivateCatalog` allows catalog consumers to retrieve `Catalog`, `Product` + * and `Version` resources under a target resource context. + * + * `Catalog` is computed based on the {@link protos.|Association}s linked to the target + * resource and its ancestors. Each association's + * {@link protos.|google.cloud.privatecatalogproducer.v1beta.Catalog} is transformed into a + * `Catalog`. If multiple associations have the same parent + * {@link protos.|google.cloud.privatecatalogproducer.v1beta.Catalog}, they are + * de-duplicated into one `Catalog`. Users must have + * `cloudprivatecatalog.catalogTargets.get` IAM permission on the resource + * context in order to access catalogs. `Catalog` contains the resource name and + * a subset of data of the original + * {@link protos.|google.cloud.privatecatalogproducer.v1beta.Catalog}. + * + * `Product` is child resource of the catalog. A `Product` contains the resource + * name and a subset of the data of the original + * {@link protos.|google.cloud.privatecatalogproducer.v1beta.Product}. + * + * `Version` is child resource of the product. A `Version` contains the resource + * name and a subset of the data of the original + * {@link protos.|google.cloud.privatecatalogproducer.v1beta.Version}. + * @class + * @memberof v1beta1 + */ +export class PrivateCatalogClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + privateCatalogStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of PrivateCatalogClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 PrivateCatalogClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof PrivateCatalogClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'catalogs/{catalog}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'products/{product}' + ), + versionPathTemplate: new this._gaxModule.PathTemplate( + 'catalogs/{catalog}/products/{product}/versions/{version}' + ), + }; + + // 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 = { + searchCatalogs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'catalogs'), + searchProducts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), + searchVersions: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'versions') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.privatecatalog.v1beta1.PrivateCatalog', 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.privateCatalogStub) { + return this.privateCatalogStub; + } + + // Put together the "service stub" for + // google.cloud.privatecatalog.v1beta1.PrivateCatalog. + this.privateCatalogStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.privatecatalog.v1beta1.PrivateCatalog') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.privatecatalog.v1beta1.PrivateCatalog, + 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 privateCatalogStubMethods = + ['searchCatalogs', 'searchProducts', 'searchVersions']; + for (const methodName of privateCatalogStubMethods) { + const callPromise = this.privateCatalogStub.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.privateCatalogStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudprivatecatalog.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 'cloudprivatecatalog.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 -- + // ------------------- + + /** + * Search {@link protos.google.cloud.privatecatalog.v1beta1.Catalog|Catalog} resources that consumers have access to, within the + * scope of the consumer cloud resource hierarchy context. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * Required. The name of the resource context. It can be in following formats: + * + * * `projects/{project}` + * * `folders/{folder}` + * * `organizations/{organization}` + * @param {string} request.query + * The query to filter the catalogs. The supported queries are: + * + * * Get a single catalog: `name=catalogs/{catalog}` + * @param {number} request.pageSize + * The maximum number of entries that are requested. + * @param {string} request.pageToken + * A pagination token returned from a previous call to SearchCatalogs that + * indicates where this listing should continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.privatecatalog.v1beta1.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 `searchCatalogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + searchCatalogs( + request?: protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.privatecatalog.v1beta1.ICatalog[], + protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest|null, + protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsResponse + ]>; + searchCatalogs( + request: protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest, + protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsResponse|null|undefined, + protos.google.cloud.privatecatalog.v1beta1.ICatalog>): void; + searchCatalogs( + request: protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest, + callback: PaginationCallback< + protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest, + protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsResponse|null|undefined, + protos.google.cloud.privatecatalog.v1beta1.ICatalog>): void; + searchCatalogs( + request?: protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest, + protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsResponse|null|undefined, + protos.google.cloud.privatecatalog.v1beta1.ICatalog>, + callback?: PaginationCallback< + protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest, + protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsResponse|null|undefined, + protos.google.cloud.privatecatalog.v1beta1.ICatalog>): + Promise<[ + protos.google.cloud.privatecatalog.v1beta1.ICatalog[], + protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest|null, + protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.searchCatalogs(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.resource + * Required. The name of the resource context. It can be in following formats: + * + * * `projects/{project}` + * * `folders/{folder}` + * * `organizations/{organization}` + * @param {string} request.query + * The query to filter the catalogs. The supported queries are: + * + * * Get a single catalog: `name=catalogs/{catalog}` + * @param {number} request.pageSize + * The maximum number of entries that are requested. + * @param {string} request.pageToken + * A pagination token returned from a previous call to SearchCatalogs that + * indicates where this listing should continue from. + * @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 protos.google.cloud.privatecatalog.v1beta1.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 `searchCatalogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + searchCatalogsStream( + request?: protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest, + 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({ + 'resource': request.resource ?? '', + }); + const defaultCallSettings = this._defaults['searchCatalogs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchCatalogs.createStream( + this.innerApiCalls.searchCatalogs as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `searchCatalogs`, 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.resource + * Required. The name of the resource context. It can be in following formats: + * + * * `projects/{project}` + * * `folders/{folder}` + * * `organizations/{organization}` + * @param {string} request.query + * The query to filter the catalogs. The supported queries are: + * + * * Get a single catalog: `name=catalogs/{catalog}` + * @param {number} request.pageSize + * The maximum number of entries that are requested. + * @param {string} request.pageToken + * A pagination token returned from a previous call to SearchCatalogs that + * indicates where this listing should continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.privatecatalog.v1beta1.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/private_catalog.search_catalogs.js + * region_tag:cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchCatalogs_async + */ + searchCatalogsAsync( + request?: protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest, + 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({ + 'resource': request.resource ?? '', + }); + const defaultCallSettings = this._defaults['searchCatalogs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchCatalogs.asyncIterate( + this.innerApiCalls['searchCatalogs'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Search {@link protos.google.cloud.privatecatalog.v1beta1.Product|Product} resources that consumers have access to, within the + * scope of the consumer cloud resource hierarchy context. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * Required. The name of the resource context. See {@link protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource|SearchCatalogsRequest.resource} + * for details. + * @param {string} request.query + * The query to filter the products. + * + * The supported queries are: + * * List products of all catalogs: empty + * * List products under a catalog: `parent=catalogs/{catalog}` + * * Get a product by name: + * `name=catalogs/{catalog}/products/{product}` + * @param {number} request.pageSize + * The maximum number of entries that are requested. + * @param {string} request.pageToken + * A pagination token returned from a previous call to SearchProducts that + * indicates where this listing should continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.privatecatalog.v1beta1.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 `searchProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + searchProducts( + request?: protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.privatecatalog.v1beta1.IProduct[], + protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest|null, + protos.google.cloud.privatecatalog.v1beta1.ISearchProductsResponse + ]>; + searchProducts( + request: protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest, + protos.google.cloud.privatecatalog.v1beta1.ISearchProductsResponse|null|undefined, + protos.google.cloud.privatecatalog.v1beta1.IProduct>): void; + searchProducts( + request: protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest, + callback: PaginationCallback< + protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest, + protos.google.cloud.privatecatalog.v1beta1.ISearchProductsResponse|null|undefined, + protos.google.cloud.privatecatalog.v1beta1.IProduct>): void; + searchProducts( + request?: protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest, + protos.google.cloud.privatecatalog.v1beta1.ISearchProductsResponse|null|undefined, + protos.google.cloud.privatecatalog.v1beta1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest, + protos.google.cloud.privatecatalog.v1beta1.ISearchProductsResponse|null|undefined, + protos.google.cloud.privatecatalog.v1beta1.IProduct>): + Promise<[ + protos.google.cloud.privatecatalog.v1beta1.IProduct[], + protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest|null, + protos.google.cloud.privatecatalog.v1beta1.ISearchProductsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.searchProducts(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.resource + * Required. The name of the resource context. See {@link protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource|SearchCatalogsRequest.resource} + * for details. + * @param {string} request.query + * The query to filter the products. + * + * The supported queries are: + * * List products of all catalogs: empty + * * List products under a catalog: `parent=catalogs/{catalog}` + * * Get a product by name: + * `name=catalogs/{catalog}/products/{product}` + * @param {number} request.pageSize + * The maximum number of entries that are requested. + * @param {string} request.pageToken + * A pagination token returned from a previous call to SearchProducts that + * indicates where this listing should continue from. + * @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 protos.google.cloud.privatecatalog.v1beta1.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 `searchProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + searchProductsStream( + request?: protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest, + 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({ + 'resource': request.resource ?? '', + }); + const defaultCallSettings = this._defaults['searchProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchProducts.createStream( + this.innerApiCalls.searchProducts as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `searchProducts`, 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.resource + * Required. The name of the resource context. See {@link protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource|SearchCatalogsRequest.resource} + * for details. + * @param {string} request.query + * The query to filter the products. + * + * The supported queries are: + * * List products of all catalogs: empty + * * List products under a catalog: `parent=catalogs/{catalog}` + * * Get a product by name: + * `name=catalogs/{catalog}/products/{product}` + * @param {number} request.pageSize + * The maximum number of entries that are requested. + * @param {string} request.pageToken + * A pagination token returned from a previous call to SearchProducts that + * indicates where this listing should continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.privatecatalog.v1beta1.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/private_catalog.search_products.js + * region_tag:cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchProducts_async + */ + searchProductsAsync( + request?: protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest, + 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({ + 'resource': request.resource ?? '', + }); + const defaultCallSettings = this._defaults['searchProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchProducts.asyncIterate( + this.innerApiCalls['searchProducts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Search {@link protos.google.cloud.privatecatalog.v1beta1.Version|Version} resources that consumers have access to, within the + * scope of the consumer cloud resource hierarchy context. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * Required. The name of the resource context. See {@link protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource|SearchCatalogsRequest.resource} + * for details. + * @param {string} request.query + * Required. The query to filter the versions. + * + * The supported queries are: + * * List versions under a product: + * `parent=catalogs/{catalog}/products/{product}` + * * Get a version by name: + * `name=catalogs/{catalog}/products/{product}/versions/{version}` + * @param {number} request.pageSize + * The maximum number of entries that are requested. + * @param {string} request.pageToken + * A pagination token returned from a previous call to SearchVersions + * that indicates where this listing should continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.privatecatalog.v1beta1.Version|Version}. + * 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 `searchVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + searchVersions( + request?: protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.privatecatalog.v1beta1.IVersion[], + protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest|null, + protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsResponse + ]>; + searchVersions( + request: protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest, + protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsResponse|null|undefined, + protos.google.cloud.privatecatalog.v1beta1.IVersion>): void; + searchVersions( + request: protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest, + callback: PaginationCallback< + protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest, + protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsResponse|null|undefined, + protos.google.cloud.privatecatalog.v1beta1.IVersion>): void; + searchVersions( + request?: protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest, + protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsResponse|null|undefined, + protos.google.cloud.privatecatalog.v1beta1.IVersion>, + callback?: PaginationCallback< + protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest, + protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsResponse|null|undefined, + protos.google.cloud.privatecatalog.v1beta1.IVersion>): + Promise<[ + protos.google.cloud.privatecatalog.v1beta1.IVersion[], + protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest|null, + protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.searchVersions(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.resource + * Required. The name of the resource context. See {@link protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource|SearchCatalogsRequest.resource} + * for details. + * @param {string} request.query + * Required. The query to filter the versions. + * + * The supported queries are: + * * List versions under a product: + * `parent=catalogs/{catalog}/products/{product}` + * * Get a version by name: + * `name=catalogs/{catalog}/products/{product}/versions/{version}` + * @param {number} request.pageSize + * The maximum number of entries that are requested. + * @param {string} request.pageToken + * A pagination token returned from a previous call to SearchVersions + * that indicates where this listing should continue from. + * @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 protos.google.cloud.privatecatalog.v1beta1.Version|Version} 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 `searchVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + searchVersionsStream( + request?: protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest, + 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({ + 'resource': request.resource ?? '', + }); + const defaultCallSettings = this._defaults['searchVersions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchVersions.createStream( + this.innerApiCalls.searchVersions as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `searchVersions`, 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.resource + * Required. The name of the resource context. See {@link protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource|SearchCatalogsRequest.resource} + * for details. + * @param {string} request.query + * Required. The query to filter the versions. + * + * The supported queries are: + * * List versions under a product: + * `parent=catalogs/{catalog}/products/{product}` + * * Get a version by name: + * `name=catalogs/{catalog}/products/{product}/versions/{version}` + * @param {number} request.pageSize + * The maximum number of entries that are requested. + * @param {string} request.pageToken + * A pagination token returned from a previous call to SearchVersions + * that indicates where this listing should continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.privatecatalog.v1beta1.Version|Version}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/private_catalog.search_versions.js + * region_tag:cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchVersions_async + */ + searchVersionsAsync( + request?: protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest, + 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({ + 'resource': request.resource ?? '', + }); + const defaultCallSettings = this._defaults['searchVersions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchVersions.asyncIterate( + this.innerApiCalls['searchVersions'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + catalog: catalog, + }); + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(product:string) { + return this.pathTemplates.productPathTemplate.render({ + product: product, + }); + } + + /** + * 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 version resource name string. + * + * @param {string} catalog + * @param {string} product + * @param {string} version + * @returns {string} Resource name string. + */ + versionPath(catalog:string,product:string,version:string) { + return this.pathTemplates.versionPathTemplate.render({ + catalog: catalog, + product: product, + version: version, + }); + } + + /** + * Parse the catalog from Version resource. + * + * @param {string} versionName + * A fully-qualified path representing Version resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromVersionName(versionName: string) { + return this.pathTemplates.versionPathTemplate.match(versionName).catalog; + } + + /** + * Parse the product from Version resource. + * + * @param {string} versionName + * A fully-qualified path representing Version resource. + * @returns {string} A string representing the product. + */ + matchProductFromVersionName(versionName: string) { + return this.pathTemplates.versionPathTemplate.match(versionName).product; + } + + /** + * Parse the version from Version resource. + * + * @param {string} versionName + * A fully-qualified path representing Version resource. + * @returns {string} A string representing the version. + */ + matchVersionFromVersionName(versionName: string) { + return this.pathTemplates.versionPathTemplate.match(versionName).version; + } + + /** + * 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.privateCatalogStub && !this._terminated) { + return this.privateCatalogStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_client_config.json b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_client_config.json new file mode 100644 index 00000000000..117c2f9dbce --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_client_config.json @@ -0,0 +1,38 @@ +{ + "interfaces": { + "google.cloud.privatecatalog.v1beta1.PrivateCatalog": { + "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": { + "SearchCatalogs": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SearchProducts": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SearchVersions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_proto_list.json b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_proto_list.json new file mode 100644 index 00000000000..1803923fd85 --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/privatecatalog/v1beta1/private_catalog.proto" +] diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..208f320b48b --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const privatecatalog = require('@google-cloud/private-catalog'); + +function main() { + const privateCatalogClient = new privatecatalog.PrivateCatalogClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..db703726a6d --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {PrivateCatalogClient} from '@google-cloud/private-catalog'; + +// check that the client class type name can be used +function doStuffWithPrivateCatalogClient(client: PrivateCatalogClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const privateCatalogClient = new PrivateCatalogClient(); + doStuffWithPrivateCatalogClient(privateCatalogClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/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-privatecatalog/v1beta1/test/gapic_private_catalog_v1beta1.ts b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/test/gapic_private_catalog_v1beta1.ts new file mode 100644 index 00000000000..d6def4f42c3 --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/test/gapic_private_catalog_v1beta1.ts @@ -0,0 +1,1041 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 privatecatalogModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +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('v1beta1.PrivateCatalogClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = privatecatalogModule.v1beta1.PrivateCatalogClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = privatecatalogModule.v1beta1.PrivateCatalogClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = privatecatalogModule.v1beta1.PrivateCatalogClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.privateCatalogStub, undefined); + await client.initialize(); + assert(client.privateCatalogStub); + }); + + it('has close method for the initialized client', done => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.privateCatalogStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.privateCatalogStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + 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 privatecatalogModule.v1beta1.PrivateCatalogClient({ + 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('searchCatalogs', () => { + it('invokes searchCatalogs without error', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), + ]; + client.innerApiCalls.searchCatalogs = stubSimpleCall(expectedResponse); + const [response] = await client.searchCatalogs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.searchCatalogs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.searchCatalogs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes searchCatalogs without error using callback', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), + ]; + client.innerApiCalls.searchCatalogs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchCatalogs( + request, + (err?: Error|null, result?: protos.google.cloud.privatecatalog.v1beta1.ICatalog[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.searchCatalogs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.searchCatalogs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes searchCatalogs with error', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.searchCatalogs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.searchCatalogs(request), expectedError); + const actualRequest = (client.innerApiCalls.searchCatalogs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.searchCatalogs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes searchCatalogsStream without error', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), + ]; + client.descriptors.page.searchCatalogs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.searchCatalogsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.privatecatalog.v1beta1.Catalog[] = []; + stream.on('data', (response: protos.google.cloud.privatecatalog.v1beta1.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.searchCatalogs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchCatalogs, request)); + assert( + (client.descriptors.page.searchCatalogs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes searchCatalogsStream with error', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchCatalogs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.searchCatalogsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.privatecatalog.v1beta1.Catalog[] = []; + stream.on('data', (response: protos.google.cloud.privatecatalog.v1beta1.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.searchCatalogs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchCatalogs, request)); + assert( + (client.descriptors.page.searchCatalogs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with searchCatalogs without error', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), + ]; + client.descriptors.page.searchCatalogs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.privatecatalog.v1beta1.ICatalog[] = []; + const iterable = client.searchCatalogsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.searchCatalogs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.searchCatalogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with searchCatalogs with error', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchCatalogs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchCatalogsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.privatecatalog.v1beta1.ICatalog[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.searchCatalogs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.searchCatalogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('searchProducts', () => { + it('invokes searchProducts without error', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.privatecatalog.v1beta1.SearchProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchProductsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), + ]; + client.innerApiCalls.searchProducts = stubSimpleCall(expectedResponse); + const [response] = await client.searchProducts(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.searchProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.searchProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes searchProducts without error using callback', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.privatecatalog.v1beta1.SearchProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchProductsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), + ]; + client.innerApiCalls.searchProducts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchProducts( + request, + (err?: Error|null, result?: protos.google.cloud.privatecatalog.v1beta1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.searchProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.searchProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes searchProducts with error', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.privatecatalog.v1beta1.SearchProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchProductsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.searchProducts = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.searchProducts(request), expectedError); + const actualRequest = (client.innerApiCalls.searchProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.searchProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes searchProductsStream without error', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.privatecatalog.v1beta1.SearchProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchProductsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), + ]; + client.descriptors.page.searchProducts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.searchProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.privatecatalog.v1beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.privatecatalog.v1beta1.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.searchProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchProducts, request)); + assert( + (client.descriptors.page.searchProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes searchProductsStream with error', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.privatecatalog.v1beta1.SearchProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchProductsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchProducts.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.searchProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.privatecatalog.v1beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.privatecatalog.v1beta1.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.searchProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchProducts, request)); + assert( + (client.descriptors.page.searchProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with searchProducts without error', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.privatecatalog.v1beta1.SearchProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchProductsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), + ]; + client.descriptors.page.searchProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.privatecatalog.v1beta1.IProduct[] = []; + const iterable = client.searchProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.searchProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.searchProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with searchProducts with error', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.privatecatalog.v1beta1.SearchProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchProductsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchProductsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.privatecatalog.v1beta1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.searchProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.searchProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('searchVersions', () => { + it('invokes searchVersions without error', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), + ]; + client.innerApiCalls.searchVersions = stubSimpleCall(expectedResponse); + const [response] = await client.searchVersions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.searchVersions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.searchVersions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes searchVersions without error using callback', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), + ]; + client.innerApiCalls.searchVersions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchVersions( + request, + (err?: Error|null, result?: protos.google.cloud.privatecatalog.v1beta1.IVersion[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.searchVersions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.searchVersions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes searchVersions with error', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.searchVersions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.searchVersions(request), expectedError); + const actualRequest = (client.innerApiCalls.searchVersions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.searchVersions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes searchVersionsStream without error', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), + ]; + client.descriptors.page.searchVersions.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.searchVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.privatecatalog.v1beta1.Version[] = []; + stream.on('data', (response: protos.google.cloud.privatecatalog.v1beta1.Version) => { + 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.searchVersions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchVersions, request)); + assert( + (client.descriptors.page.searchVersions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes searchVersionsStream with error', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchVersions.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.searchVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.privatecatalog.v1beta1.Version[] = []; + stream.on('data', (response: protos.google.cloud.privatecatalog.v1beta1.Version) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.searchVersions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchVersions, request)); + assert( + (client.descriptors.page.searchVersions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with searchVersions without error', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), + generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), + ]; + client.descriptors.page.searchVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.privatecatalog.v1beta1.IVersion[] = []; + const iterable = client.searchVersionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.searchVersions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.searchVersions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with searchVersions with error', async () => { + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchVersionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.privatecatalog.v1beta1.IVersion[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.searchVersions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.searchVersions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + catalog: "catalogValue", + }; + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + 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("catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + product: "productValue", + }; + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + 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("productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('version', () => { + const fakePath = "/rendered/path/version"; + const expectedParameters = { + catalog: "catalogValue", + product: "productValue", + version: "versionValue", + }; + const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.versionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.versionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('versionPath', () => { + const result = client.versionPath("catalogValue", "productValue", "versionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.versionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchCatalogFromVersionName', () => { + const result = client.matchCatalogFromVersionName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.versionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromVersionName', () => { + const result = client.matchProductFromVersionName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.versionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchVersionFromVersionName', () => { + const result = client.matchVersionFromVersionName(fakePath); + assert.strictEqual(result, "versionValue"); + assert((client.pathTemplates.versionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/webpack.config.js new file mode 100644 index 00000000000..23fa00eb490 --- /dev/null +++ b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'PrivateCatalog', + filename: './private-catalog.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-rapidmigrationassessment/v1/.eslintignore b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.eslintrc.json b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.gitignore b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.jsdoc.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.jsdoc.js new file mode 100644 index 00000000000..ca6869617a6 --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.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/rapidmigrationassessment', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.mocharc.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.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-rapidmigrationassessment/v1/.prettierrc.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.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-rapidmigrationassessment/v1/README.md b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/README.md new file mode 100644 index 00000000000..d371ae35ec0 --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/README.md @@ -0,0 +1 @@ +Rapidmigrationassessment: Nodejs Client diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/package.json b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/package.json new file mode 100644 index 00000000000..f4379e51abe --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/rapidmigrationassessment", + "version": "0.1.0", + "description": "Rapidmigrationassessment client for Node.js", + "repository": "googleapis/nodejs-rapidmigrationassessment", + "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 rapidmigrationassessment", + "rapidmigrationassessment", + "rapid migration assessment" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/protos/google/cloud/rapidmigrationassessment/v1/api_entities.proto b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/protos/google/cloud/rapidmigrationassessment/v1/api_entities.proto new file mode 100644 index 00000000000..54a3247c536 --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/protos/google/cloud/rapidmigrationassessment/v1/api_entities.proto @@ -0,0 +1,171 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.rapidmigrationassessment.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.RapidMigrationAssessment.V1"; +option go_package = "cloud.google.com/go/rapidmigrationassessment/apiv1/rapidmigrationassessmentpb;rapidmigrationassessmentpb"; +option java_multiple_files = true; +option java_outer_classname = "ApiEntitiesProto"; +option java_package = "com.google.cloud.rapidmigrationassessment.v1"; +option php_namespace = "Google\\Cloud\\RapidMigrationAssessment\\V1"; +option ruby_package = "Google::Cloud::RapidMigrationAssessment::V1"; + +// Message describing a MC Source of type Guest OS Scan. +message GuestOsScan { + // reference to the corresponding Guest OS Scan in MC Source. + string core_source = 1; +} + +// Message describing a MC Source of type VSphere Scan. +message VSphereScan { + // reference to the corresponding VSphere Scan in MC Source. + string core_source = 1; +} + +// Message describing Collector object. +message Collector { + option (google.api.resource) = { + type: "rapidmigrationassessment.googleapis.com/Collector" + pattern: "projects/{project}/locations/{location}/collectors/{collector}" + }; + + // -- Using suggestion from API Linter Analyzer for nesting enum -- + // -- https://linter.aip.dev/216/nesting -- + // State of a Collector (server_side). + // States are used for internal purposes and named to keep + // convention of legacy product: + // https://cloud.google.com/migrate/stratozone/docs/about-stratoprobe. + enum State { + // Collector state is not recognized. + STATE_UNSPECIFIED = 0; + + // Collector started to create, but hasn't been completed MC source creation + // and db object creation. + STATE_INITIALIZING = 1; + + // Collector has been created, MC source creation and db object creation + // completed. + STATE_READY_TO_USE = 2; + + // Collector client has been registered with client. + STATE_REGISTERED = 3; + + // Collector client is actively scanning. + STATE_ACTIVE = 4; + + // Collector is not actively scanning. + STATE_PAUSED = 5; + + // Collector is starting background job for deletion. + STATE_DELETING = 6; + + // Collector completed all tasks for deletion. + STATE_DECOMMISSIONED = 7; + + // Collector is in error state. + STATE_ERROR = 8; + } + + // name of resource. + string name = 1; + + // Output only. Create time stamp. + google.protobuf.Timestamp create_time = 2 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Update time stamp. + google.protobuf.Timestamp update_time = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Labels as key value pairs. + map labels = 4; + + // User specified name of the Collector. + string display_name = 5; + + // User specified description of the Collector. + string description = 6; + + // Service Account email used to ingest data to this Collector. + string service_account = 7; + + // Output only. Store cloud storage bucket name (which is a guid) created with + // this Collector. + string bucket = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // User specified expected asset count. + int64 expected_asset_count = 9; + + // Output only. State of the Collector. + State state = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Client version. + string client_version = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Reference to MC Source Guest Os Scan. + GuestOsScan guest_os_scan = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Reference to MC Source vsphere_scan. + VSphereScan vsphere_scan = 13 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // How many days to collect data. + int32 collection_days = 14; + + // Uri for EULA (End User License Agreement) from customer. + string eula_uri = 15; +} + +// Message describing an Annotation +message Annotation { + option (google.api.resource) = { + type: "rapidmigrationassessment.googleapis.com/Annotation" + pattern: "projects/{project}/locations/{location}/annotations/{annotation}" + }; + + // Types for project level setting. + enum Type { + // Unknown type + TYPE_UNSPECIFIED = 0; + + // Indicates that this project has opted into StratoZone export. + TYPE_LEGACY_EXPORT_CONSENT = 1; + + // Indicates that this project is created by Qwiklab. + TYPE_QWIKLAB = 2; + } + + // name of resource. + string name = 1; + + // Output only. Create time stamp. + google.protobuf.Timestamp create_time = 2 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Update time stamp. + google.protobuf.Timestamp update_time = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Labels as key value pairs. + map labels = 4; + + // Type of an annotation. + Type type = 5; +} diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/protos/google/cloud/rapidmigrationassessment/v1/rapidmigrationassessment.proto b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/protos/google/cloud/rapidmigrationassessment/v1/rapidmigrationassessment.proto new file mode 100644 index 00000000000..4e4026efe04 --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/protos/google/cloud/rapidmigrationassessment/v1/rapidmigrationassessment.proto @@ -0,0 +1,421 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.rapidmigrationassessment.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/rapidmigrationassessment/v1/api_entities.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.RapidMigrationAssessment.V1"; +option go_package = "cloud.google.com/go/rapidmigrationassessment/apiv1/rapidmigrationassessmentpb;rapidmigrationassessmentpb"; +option java_multiple_files = true; +option java_outer_classname = "RapidMigrationAssessmentProto"; +option java_package = "com.google.cloud.rapidmigrationassessment.v1"; +option php_namespace = "Google\\Cloud\\RapidMigrationAssessment\\V1"; +option ruby_package = "Google::Cloud::RapidMigrationAssessment::V1"; + +// Rapid Migration Assessment service +service RapidMigrationAssessment { + option (google.api.default_host) = "rapidmigrationassessment.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Create a Collector to manage the on-prem appliance which collects + // information about Customer assets. + rpc CreateCollector(CreateCollectorRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/collectors" + body: "collector" + }; + option (google.api.method_signature) = "parent,collector,collector_id"; + option (google.longrunning.operation_info) = { + response_type: "Collector" + metadata_type: "OperationMetadata" + }; + } + + // Creates an Annotation + rpc CreateAnnotation(CreateAnnotationRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/annotations" + body: "annotation" + }; + option (google.api.method_signature) = "parent,annotation"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.rapidmigrationassessment.v1.Annotation" + metadata_type: "OperationMetadata" + }; + } + + // Gets details of a single Annotation. + rpc GetAnnotation(GetAnnotationRequest) returns (Annotation) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/annotations/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists Collectors in a given project and location. + rpc ListCollectors(ListCollectorsRequest) returns (ListCollectorsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/collectors" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets details of a single Collector. + rpc GetCollector(GetCollectorRequest) returns (Collector) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/collectors/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the parameters of a single Collector. + rpc UpdateCollector(UpdateCollectorRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{collector.name=projects/*/locations/*/collectors/*}" + body: "collector" + }; + option (google.api.method_signature) = "collector,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "Collector" + metadata_type: "OperationMetadata" + }; + } + + // Deletes a single Collector - changes state of collector to "Deleting". + rpc DeleteCollector(DeleteCollectorRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/collectors/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Collector" + metadata_type: "OperationMetadata" + }; + } + + // Resumes the given collector. + rpc ResumeCollector(ResumeCollectorRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/collectors/*}:resume" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Collector" + metadata_type: "OperationMetadata" + }; + } + + // Registers the given collector. + rpc RegisterCollector(RegisterCollectorRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/collectors/*}:register" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Collector" + metadata_type: "OperationMetadata" + }; + } + + // Pauses the given collector. + rpc PauseCollector(PauseCollectorRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/collectors/*}:pause" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Collector" + metadata_type: "OperationMetadata" + }; + } +} + +// Message for creating an AnnotationS. +message CreateAnnotationRequest { + // Required. Name of the parent (project+location). + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The resource being created. + Annotation annotation = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. An optional request ID to identify requests. + string request_id = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Message for getting a specific Annotation +message GetAnnotationRequest { + // Required. Name of the resource. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "rapidmigrationassessment.googleapis.com/Annotation" + } + ]; +} + +// Message for creating a Collector. +message CreateCollectorRequest { + // Required. Name of the parent (project+location). + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. Id of the requesting object. + string collector_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The resource being created. + Collector collector = 3 [(google.api.field_behavior) = REQUIRED]; + + // Optional. An optional request ID to identify requests. + string request_id = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Message for requesting list of Collectors. +message ListCollectorsRequest { + // Required. Parent value for ListCollectorsRequest. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Requested page size. Server may return fewer items than requested. + // If unspecified, server will pick an appropriate default. + int32 page_size = 2; + + // A token identifying a page of results the server should return. + string page_token = 3; + + // Filtering results. + string filter = 4; + + // Hint for how to order the results. + string order_by = 5; +} + +// Message for response to listing Collectors. +message ListCollectorsResponse { + // The list of Collectors. + repeated Collector collectors = 1; + + // A token identifying a page of results the server should return. + string next_page_token = 2; + + // Locations that could not be reached. + repeated string unreachable = 3; +} + +// Message for getting a specific Collector. +message GetCollectorRequest { + // Required. Name of the resource. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "rapidmigrationassessment.googleapis.com/Collector" + } + ]; +} + +// Message for deleting a Collector. +message DeleteCollectorRequest { + // Required. Name of the resource. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "rapidmigrationassessment.googleapis.com/Collector" + } + ]; + + // Optional. An optional request ID to identify requests. Specify a unique + // request ID so that if you must retry your request, the server will know to + // ignore the request if it has already been completed. The server will + // guarantee that for at least 60 minutes after the first request. + // + // For example, consider a situation where you make an initial request and + // the request times out. If you make the request again with the same request + // ID, the server can check if original operation with the same request ID + // was received, and if so, will ignore the second request. This prevents + // clients from accidentally creating duplicate commitments. + // + // The request ID must be a valid UUID with the exception that zero UUID is + // not supported (00000000-0000-0000-0000-000000000000). + string request_id = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Message for updating a Collector. +message UpdateCollectorRequest { + // Required. Field mask is used to specify the fields to be overwritten in the + // Collector resource by the update. + // The fields specified in the update_mask are relative to the resource, not + // the full request. A field will be overwritten if it is in the mask. If the + // user does not provide a mask then all fields will be overwritten. + google.protobuf.FieldMask update_mask = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. The resource being updated. + Collector collector = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. An optional request ID to identify requests. Specify a unique + // request ID so that if you must retry your request, the server will know to + // ignore the request if it has already been completed. The server will + // guarantee that for at least 60 minutes since the first request. + // + // For example, consider a situation where you make an initial request and + // the request times out. If you make the request again with the same request + // ID, the server can check if original operation with the same request ID + // was received, and if so, will ignore the second request. This prevents + // clients from accidentally creating duplicate commitments. + // + // The request ID must be a valid UUID with the exception that zero UUID is + // not supported (00000000-0000-0000-0000-000000000000). + string request_id = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Message for resuming a Collector. +message ResumeCollectorRequest { + // Required. Name of the resource. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "rapidmigrationassessment.googleapis.com/Collector" + } + ]; + + // Optional. An optional request ID to identify requests. Specify a unique + // request ID so that if you must retry your request, the server will know to + // ignore the request if it has already been completed. The server will + // guarantee that for at least 60 minutes after the first request. + // + // For example, consider a situation where you make an initial request and + // the request times out. If you make the request again with the same request + // ID, the server can check if original operation with the same request ID + // was received, and if so, will ignore the second request. This prevents + // clients from accidentally creating duplicate commitments. + // + // The request ID must be a valid UUID with the exception that zero UUID is + // not supported (00000000-0000-0000-0000-000000000000). + string request_id = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Message for registering a Collector. +message RegisterCollectorRequest { + // Required. Name of the resource. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "rapidmigrationassessment.googleapis.com/Collector" + } + ]; + + // Optional. An optional request ID to identify requests. Specify a unique + // request ID so that if you must retry your request, the server will know to + // ignore the request if it has already been completed. The server will + // guarantee that for at least 60 minutes after the first request. + // + // For example, consider a situation where you make an initial request and + // the request times out. If you make the request again with the same request + // ID, the server can check if original operation with the same request ID + // was received, and if so, will ignore the second request. This prevents + // clients from accidentally creating duplicate commitments. + // + // The request ID must be a valid UUID with the exception that zero UUID is + // not supported (00000000-0000-0000-0000-000000000000). + string request_id = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Message for pausing a Collector. +message PauseCollectorRequest { + // Required. Name of the resource. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "rapidmigrationassessment.googleapis.com/Collector" + } + ]; + + // Optional. An optional request ID to identify requests. Specify a unique + // request ID so that if you must retry your request, the server will know to + // ignore the request if it has already been completed. The server will + // guarantee that for at least 60 minutes after the first request. + // + // For example, consider a situation where you make an initial request and + // the request times out. If you make the request again with the same request + // ID, the server can check if original operation with the same request ID + // was received, and if so, will ignore the second request. This prevents + // clients from accidentally creating duplicate commitments. + // + // The request ID must be a valid UUID with the exception that zero UUID is + // not supported (00000000-0000-0000-0000-000000000000). + string request_id = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Represents the metadata of the long-running operation. +message OperationMetadata { + // Output only. The time the operation was created. + google.protobuf.Timestamp create_time = 1 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time the operation finished running. + google.protobuf.Timestamp end_time = 2 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Server-defined resource path for the target of the operation. + string target = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the verb executed by the operation. + string verb = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Human-readable status of the operation, if any. + string status_message = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Identifies whether the user has requested cancellation + // of the operation. Operations that have successfully been cancelled + // have [Operation.error][] value with a + // [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + // `Code.CANCELLED`. + bool requested_cancellation = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. API version used to start the operation. + string api_version = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.create_annotation.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.create_annotation.js new file mode 100644 index 00000000000..8c36b454cac --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.create_annotation.js @@ -0,0 +1,71 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, annotation) { + // [START rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateAnnotation_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the parent (project+location). + */ + // const parent = 'abc123' + /** + * Required. The resource being created. + */ + // const annotation = {} + /** + * Optional. An optional request ID to identify requests. + */ + // const requestId = 'abc123' + + // Imports the Rapidmigrationassessment library + const {RapidMigrationAssessmentClient} = require('@google-cloud/rapidmigrationassessment').v1; + + // Instantiates a client + const rapidmigrationassessmentClient = new RapidMigrationAssessmentClient(); + + async function callCreateAnnotation() { + // Construct request + const request = { + parent, + annotation, + }; + + // Run request + const [operation] = await rapidmigrationassessmentClient.createAnnotation(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateAnnotation(); + // [END rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateAnnotation_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.create_collector.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.create_collector.js new file mode 100644 index 00000000000..17da48ec980 --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.create_collector.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, collectorId, collector) { + // [START rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateCollector_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the parent (project+location). + */ + // const parent = 'abc123' + /** + * Required. Id of the requesting object. + */ + // const collectorId = 'abc123' + /** + * Required. The resource being created. + */ + // const collector = {} + /** + * Optional. An optional request ID to identify requests. + */ + // const requestId = 'abc123' + + // Imports the Rapidmigrationassessment library + const {RapidMigrationAssessmentClient} = require('@google-cloud/rapidmigrationassessment').v1; + + // Instantiates a client + const rapidmigrationassessmentClient = new RapidMigrationAssessmentClient(); + + async function callCreateCollector() { + // Construct request + const request = { + parent, + collectorId, + collector, + }; + + // Run request + const [operation] = await rapidmigrationassessmentClient.createCollector(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateCollector(); + // [END rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateCollector_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.delete_collector.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.delete_collector.js new file mode 100644 index 00000000000..c7504e2980b --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.delete_collector.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(name) { + // [START rapidmigrationassessment_v1_generated_RapidMigrationAssessment_DeleteCollector_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the resource. + */ + // const name = 'abc123' + /** + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Rapidmigrationassessment library + const {RapidMigrationAssessmentClient} = require('@google-cloud/rapidmigrationassessment').v1; + + // Instantiates a client + const rapidmigrationassessmentClient = new RapidMigrationAssessmentClient(); + + async function callDeleteCollector() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await rapidmigrationassessmentClient.deleteCollector(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteCollector(); + // [END rapidmigrationassessment_v1_generated_RapidMigrationAssessment_DeleteCollector_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.get_annotation.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.get_annotation.js new file mode 100644 index 00000000000..44abe364031 --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.get_annotation.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(name) { + // [START rapidmigrationassessment_v1_generated_RapidMigrationAssessment_GetAnnotation_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the resource. + */ + // const name = 'abc123' + + // Imports the Rapidmigrationassessment library + const {RapidMigrationAssessmentClient} = require('@google-cloud/rapidmigrationassessment').v1; + + // Instantiates a client + const rapidmigrationassessmentClient = new RapidMigrationAssessmentClient(); + + async function callGetAnnotation() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await rapidmigrationassessmentClient.getAnnotation(request); + console.log(response); + } + + callGetAnnotation(); + // [END rapidmigrationassessment_v1_generated_RapidMigrationAssessment_GetAnnotation_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.get_collector.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.get_collector.js new file mode 100644 index 00000000000..a4948a4a784 --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.get_collector.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(name) { + // [START rapidmigrationassessment_v1_generated_RapidMigrationAssessment_GetCollector_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the resource. + */ + // const name = 'abc123' + + // Imports the Rapidmigrationassessment library + const {RapidMigrationAssessmentClient} = require('@google-cloud/rapidmigrationassessment').v1; + + // Instantiates a client + const rapidmigrationassessmentClient = new RapidMigrationAssessmentClient(); + + async function callGetCollector() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await rapidmigrationassessmentClient.getCollector(request); + console.log(response); + } + + callGetCollector(); + // [END rapidmigrationassessment_v1_generated_RapidMigrationAssessment_GetCollector_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.list_collectors.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.list_collectors.js new file mode 100644 index 00000000000..106c18dadfa --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.list_collectors.js @@ -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. ** + + + +'use strict'; + +function main(parent) { + // [START rapidmigrationassessment_v1_generated_RapidMigrationAssessment_ListCollectors_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Parent value for ListCollectorsRequest. + */ + // const parent = 'abc123' + /** + * Requested page size. Server may return fewer items than requested. + * If unspecified, server will pick an appropriate default. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results the server should return. + */ + // const pageToken = 'abc123' + /** + * Filtering results. + */ + // const filter = 'abc123' + /** + * Hint for how to order the results. + */ + // const orderBy = 'abc123' + + // Imports the Rapidmigrationassessment library + const {RapidMigrationAssessmentClient} = require('@google-cloud/rapidmigrationassessment').v1; + + // Instantiates a client + const rapidmigrationassessmentClient = new RapidMigrationAssessmentClient(); + + async function callListCollectors() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await rapidmigrationassessmentClient.listCollectorsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListCollectors(); + // [END rapidmigrationassessment_v1_generated_RapidMigrationAssessment_ListCollectors_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.pause_collector.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.pause_collector.js new file mode 100644 index 00000000000..3035bbf3654 --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.pause_collector.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(name) { + // [START rapidmigrationassessment_v1_generated_RapidMigrationAssessment_PauseCollector_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the resource. + */ + // const name = 'abc123' + /** + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Rapidmigrationassessment library + const {RapidMigrationAssessmentClient} = require('@google-cloud/rapidmigrationassessment').v1; + + // Instantiates a client + const rapidmigrationassessmentClient = new RapidMigrationAssessmentClient(); + + async function callPauseCollector() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await rapidmigrationassessmentClient.pauseCollector(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPauseCollector(); + // [END rapidmigrationassessment_v1_generated_RapidMigrationAssessment_PauseCollector_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.register_collector.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.register_collector.js new file mode 100644 index 00000000000..87b3025700b --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.register_collector.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(name) { + // [START rapidmigrationassessment_v1_generated_RapidMigrationAssessment_RegisterCollector_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the resource. + */ + // const name = 'abc123' + /** + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Rapidmigrationassessment library + const {RapidMigrationAssessmentClient} = require('@google-cloud/rapidmigrationassessment').v1; + + // Instantiates a client + const rapidmigrationassessmentClient = new RapidMigrationAssessmentClient(); + + async function callRegisterCollector() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await rapidmigrationassessmentClient.registerCollector(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRegisterCollector(); + // [END rapidmigrationassessment_v1_generated_RapidMigrationAssessment_RegisterCollector_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.resume_collector.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.resume_collector.js new file mode 100644 index 00000000000..d8610ae25a9 --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.resume_collector.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(name) { + // [START rapidmigrationassessment_v1_generated_RapidMigrationAssessment_ResumeCollector_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the resource. + */ + // const name = 'abc123' + /** + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Rapidmigrationassessment library + const {RapidMigrationAssessmentClient} = require('@google-cloud/rapidmigrationassessment').v1; + + // Instantiates a client + const rapidmigrationassessmentClient = new RapidMigrationAssessmentClient(); + + async function callResumeCollector() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await rapidmigrationassessmentClient.resumeCollector(request); + const [response] = await operation.promise(); + console.log(response); + } + + callResumeCollector(); + // [END rapidmigrationassessment_v1_generated_RapidMigrationAssessment_ResumeCollector_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.update_collector.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.update_collector.js new file mode 100644 index 00000000000..0f957714578 --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.update_collector.js @@ -0,0 +1,85 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(updateMask, collector) { + // [START rapidmigrationassessment_v1_generated_RapidMigrationAssessment_UpdateCollector_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Field mask is used to specify the fields to be overwritten in the + * Collector resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + */ + // const updateMask = {} + /** + * Required. The resource being updated. + */ + // const collector = {} + /** + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Rapidmigrationassessment library + const {RapidMigrationAssessmentClient} = require('@google-cloud/rapidmigrationassessment').v1; + + // Instantiates a client + const rapidmigrationassessmentClient = new RapidMigrationAssessmentClient(); + + async function callUpdateCollector() { + // Construct request + const request = { + updateMask, + collector, + }; + + // Run request + const [operation] = await rapidmigrationassessmentClient.updateCollector(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateCollector(); + // [END rapidmigrationassessment_v1_generated_RapidMigrationAssessment_UpdateCollector_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/snippet_metadata_google.cloud.rapidmigrationassessment.v1.json b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/snippet_metadata_google.cloud.rapidmigrationassessment.v1.json new file mode 100644 index 00000000000..529df2f36b2 --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/snippet_metadata_google.cloud.rapidmigrationassessment.v1.json @@ -0,0 +1,475 @@ +{ + "clientLibrary": { + "name": "nodejs-rapidmigrationassessment", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.rapidmigrationassessment.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateCollector_async", + "title": "RapidMigrationAssessment createCollector Sample", + "origin": "API_DEFINITION", + "description": " Create a Collector to manage the on-prem appliance which collects information about Customer assets.", + "canonical": true, + "file": "rapid_migration_assessment.create_collector.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateCollector", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.CreateCollector", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "collector_id", + "type": "TYPE_STRING" + }, + { + "name": "collector", + "type": ".google.cloud.rapidmigrationassessment.v1.Collector" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "RapidMigrationAssessmentClient", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient" + }, + "method": { + "shortName": "CreateCollector", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.CreateCollector", + "service": { + "shortName": "RapidMigrationAssessment", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment" + } + } + } + }, + { + "regionTag": "rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateAnnotation_async", + "title": "RapidMigrationAssessment createAnnotation Sample", + "origin": "API_DEFINITION", + "description": " Creates an Annotation", + "canonical": true, + "file": "rapid_migration_assessment.create_annotation.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateAnnotation", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.CreateAnnotation", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "annotation", + "type": ".google.cloud.rapidmigrationassessment.v1.Annotation" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "RapidMigrationAssessmentClient", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient" + }, + "method": { + "shortName": "CreateAnnotation", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.CreateAnnotation", + "service": { + "shortName": "RapidMigrationAssessment", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment" + } + } + } + }, + { + "regionTag": "rapidmigrationassessment_v1_generated_RapidMigrationAssessment_GetAnnotation_async", + "title": "RapidMigrationAssessment getAnnotation Sample", + "origin": "API_DEFINITION", + "description": " Gets details of a single Annotation.", + "canonical": true, + "file": "rapid_migration_assessment.get_annotation.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetAnnotation", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.GetAnnotation", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.rapidmigrationassessment.v1.Annotation", + "client": { + "shortName": "RapidMigrationAssessmentClient", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient" + }, + "method": { + "shortName": "GetAnnotation", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.GetAnnotation", + "service": { + "shortName": "RapidMigrationAssessment", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment" + } + } + } + }, + { + "regionTag": "rapidmigrationassessment_v1_generated_RapidMigrationAssessment_ListCollectors_async", + "title": "RapidMigrationAssessment listCollectors Sample", + "origin": "API_DEFINITION", + "description": " Lists Collectors in a given project and location.", + "canonical": true, + "file": "rapid_migration_assessment.list_collectors.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListCollectors", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.ListCollectors", + "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": "order_by", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.rapidmigrationassessment.v1.ListCollectorsResponse", + "client": { + "shortName": "RapidMigrationAssessmentClient", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient" + }, + "method": { + "shortName": "ListCollectors", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.ListCollectors", + "service": { + "shortName": "RapidMigrationAssessment", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment" + } + } + } + }, + { + "regionTag": "rapidmigrationassessment_v1_generated_RapidMigrationAssessment_GetCollector_async", + "title": "RapidMigrationAssessment getCollector Sample", + "origin": "API_DEFINITION", + "description": " Gets details of a single Collector.", + "canonical": true, + "file": "rapid_migration_assessment.get_collector.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetCollector", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.GetCollector", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.rapidmigrationassessment.v1.Collector", + "client": { + "shortName": "RapidMigrationAssessmentClient", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient" + }, + "method": { + "shortName": "GetCollector", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.GetCollector", + "service": { + "shortName": "RapidMigrationAssessment", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment" + } + } + } + }, + { + "regionTag": "rapidmigrationassessment_v1_generated_RapidMigrationAssessment_UpdateCollector_async", + "title": "RapidMigrationAssessment updateCollector Sample", + "origin": "API_DEFINITION", + "description": " Updates the parameters of a single Collector.", + "canonical": true, + "file": "rapid_migration_assessment.update_collector.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 77, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCollector", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.UpdateCollector", + "async": true, + "parameters": [ + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "collector", + "type": ".google.cloud.rapidmigrationassessment.v1.Collector" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "RapidMigrationAssessmentClient", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient" + }, + "method": { + "shortName": "UpdateCollector", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.UpdateCollector", + "service": { + "shortName": "RapidMigrationAssessment", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment" + } + } + } + }, + { + "regionTag": "rapidmigrationassessment_v1_generated_RapidMigrationAssessment_DeleteCollector_async", + "title": "RapidMigrationAssessment deleteCollector Sample", + "origin": "API_DEFINITION", + "description": " Deletes a single Collector - changes state of collector to \"Deleting\".", + "canonical": true, + "file": "rapid_migration_assessment.delete_collector.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteCollector", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.DeleteCollector", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "RapidMigrationAssessmentClient", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient" + }, + "method": { + "shortName": "DeleteCollector", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.DeleteCollector", + "service": { + "shortName": "RapidMigrationAssessment", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment" + } + } + } + }, + { + "regionTag": "rapidmigrationassessment_v1_generated_RapidMigrationAssessment_ResumeCollector_async", + "title": "RapidMigrationAssessment resumeCollector Sample", + "origin": "API_DEFINITION", + "description": " Resumes the given collector.", + "canonical": true, + "file": "rapid_migration_assessment.resume_collector.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ResumeCollector", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.ResumeCollector", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "RapidMigrationAssessmentClient", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient" + }, + "method": { + "shortName": "ResumeCollector", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.ResumeCollector", + "service": { + "shortName": "RapidMigrationAssessment", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment" + } + } + } + }, + { + "regionTag": "rapidmigrationassessment_v1_generated_RapidMigrationAssessment_RegisterCollector_async", + "title": "RapidMigrationAssessment registerCollector Sample", + "origin": "API_DEFINITION", + "description": " Registers the given collector.", + "canonical": true, + "file": "rapid_migration_assessment.register_collector.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RegisterCollector", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.RegisterCollector", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "RapidMigrationAssessmentClient", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient" + }, + "method": { + "shortName": "RegisterCollector", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.RegisterCollector", + "service": { + "shortName": "RapidMigrationAssessment", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment" + } + } + } + }, + { + "regionTag": "rapidmigrationassessment_v1_generated_RapidMigrationAssessment_PauseCollector_async", + "title": "RapidMigrationAssessment pauseCollector Sample", + "origin": "API_DEFINITION", + "description": " Pauses the given collector.", + "canonical": true, + "file": "rapid_migration_assessment.pause_collector.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PauseCollector", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.PauseCollector", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "RapidMigrationAssessmentClient", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient" + }, + "method": { + "shortName": "PauseCollector", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.PauseCollector", + "service": { + "shortName": "RapidMigrationAssessment", + "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/index.ts b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/index.ts new file mode 100644 index 00000000000..382b2cd1d2c --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const RapidMigrationAssessmentClient = v1.RapidMigrationAssessmentClient; +type RapidMigrationAssessmentClient = v1.RapidMigrationAssessmentClient; +export {v1, RapidMigrationAssessmentClient}; +export default {v1, RapidMigrationAssessmentClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..556ad365abb --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/gapic_metadata.json @@ -0,0 +1,127 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.rapidmigrationassessment.v1", + "libraryPackage": "@google-cloud/rapidmigrationassessment", + "services": { + "RapidMigrationAssessment": { + "clients": { + "grpc": { + "libraryClient": "RapidMigrationAssessmentClient", + "rpcs": { + "GetAnnotation": { + "methods": [ + "getAnnotation" + ] + }, + "GetCollector": { + "methods": [ + "getCollector" + ] + }, + "CreateCollector": { + "methods": [ + "createCollector" + ] + }, + "CreateAnnotation": { + "methods": [ + "createAnnotation" + ] + }, + "UpdateCollector": { + "methods": [ + "updateCollector" + ] + }, + "DeleteCollector": { + "methods": [ + "deleteCollector" + ] + }, + "ResumeCollector": { + "methods": [ + "resumeCollector" + ] + }, + "RegisterCollector": { + "methods": [ + "registerCollector" + ] + }, + "PauseCollector": { + "methods": [ + "pauseCollector" + ] + }, + "ListCollectors": { + "methods": [ + "listCollectors", + "listCollectorsStream", + "listCollectorsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RapidMigrationAssessmentClient", + "rpcs": { + "GetAnnotation": { + "methods": [ + "getAnnotation" + ] + }, + "GetCollector": { + "methods": [ + "getCollector" + ] + }, + "CreateCollector": { + "methods": [ + "createCollector" + ] + }, + "CreateAnnotation": { + "methods": [ + "createAnnotation" + ] + }, + "UpdateCollector": { + "methods": [ + "updateCollector" + ] + }, + "DeleteCollector": { + "methods": [ + "deleteCollector" + ] + }, + "ResumeCollector": { + "methods": [ + "resumeCollector" + ] + }, + "RegisterCollector": { + "methods": [ + "registerCollector" + ] + }, + "PauseCollector": { + "methods": [ + "pauseCollector" + ] + }, + "ListCollectors": { + "methods": [ + "listCollectors", + "listCollectorsStream", + "listCollectorsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/index.ts new file mode 100644 index 00000000000..25827d9bbd9 --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {RapidMigrationAssessmentClient} from './rapid_migration_assessment_client'; diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_client.ts b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_client.ts new file mode 100644 index 00000000000..08aaf0e546a --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_client.ts @@ -0,0 +1,1839 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/rapid_migration_assessment_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './rapid_migration_assessment_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Rapid Migration Assessment service + * @class + * @memberof v1 + */ +export class RapidMigrationAssessmentClient { + 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; + rapidMigrationAssessmentStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RapidMigrationAssessmentClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 RapidMigrationAssessmentClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RapidMigrationAssessmentClient; + 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 { + 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 = { + annotationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/annotations/{annotation}' + ), + collectorPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collectors/{collector}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + }; + + // 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 = { + listCollectors: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'collectors') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createCollectorResponse = protoFilesRoot.lookup( + '.google.cloud.rapidmigrationassessment.v1.Collector') as gax.protobuf.Type; + const createCollectorMetadata = protoFilesRoot.lookup( + '.google.cloud.rapidmigrationassessment.v1.OperationMetadata') as gax.protobuf.Type; + const createAnnotationResponse = protoFilesRoot.lookup( + '.google.cloud.rapidmigrationassessment.v1.Annotation') as gax.protobuf.Type; + const createAnnotationMetadata = protoFilesRoot.lookup( + '.google.cloud.rapidmigrationassessment.v1.OperationMetadata') as gax.protobuf.Type; + const updateCollectorResponse = protoFilesRoot.lookup( + '.google.cloud.rapidmigrationassessment.v1.Collector') as gax.protobuf.Type; + const updateCollectorMetadata = protoFilesRoot.lookup( + '.google.cloud.rapidmigrationassessment.v1.OperationMetadata') as gax.protobuf.Type; + const deleteCollectorResponse = protoFilesRoot.lookup( + '.google.cloud.rapidmigrationassessment.v1.Collector') as gax.protobuf.Type; + const deleteCollectorMetadata = protoFilesRoot.lookup( + '.google.cloud.rapidmigrationassessment.v1.OperationMetadata') as gax.protobuf.Type; + const resumeCollectorResponse = protoFilesRoot.lookup( + '.google.cloud.rapidmigrationassessment.v1.Collector') as gax.protobuf.Type; + const resumeCollectorMetadata = protoFilesRoot.lookup( + '.google.cloud.rapidmigrationassessment.v1.OperationMetadata') as gax.protobuf.Type; + const registerCollectorResponse = protoFilesRoot.lookup( + '.google.cloud.rapidmigrationassessment.v1.Collector') as gax.protobuf.Type; + const registerCollectorMetadata = protoFilesRoot.lookup( + '.google.cloud.rapidmigrationassessment.v1.OperationMetadata') as gax.protobuf.Type; + const pauseCollectorResponse = protoFilesRoot.lookup( + '.google.cloud.rapidmigrationassessment.v1.Collector') as gax.protobuf.Type; + const pauseCollectorMetadata = protoFilesRoot.lookup( + '.google.cloud.rapidmigrationassessment.v1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createCollector: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createCollectorResponse.decode.bind(createCollectorResponse), + createCollectorMetadata.decode.bind(createCollectorMetadata)), + createAnnotation: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createAnnotationResponse.decode.bind(createAnnotationResponse), + createAnnotationMetadata.decode.bind(createAnnotationMetadata)), + updateCollector: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateCollectorResponse.decode.bind(updateCollectorResponse), + updateCollectorMetadata.decode.bind(updateCollectorMetadata)), + deleteCollector: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteCollectorResponse.decode.bind(deleteCollectorResponse), + deleteCollectorMetadata.decode.bind(deleteCollectorMetadata)), + resumeCollector: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + resumeCollectorResponse.decode.bind(resumeCollectorResponse), + resumeCollectorMetadata.decode.bind(resumeCollectorMetadata)), + registerCollector: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + registerCollectorResponse.decode.bind(registerCollectorResponse), + registerCollectorMetadata.decode.bind(registerCollectorMetadata)), + pauseCollector: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + pauseCollectorResponse.decode.bind(pauseCollectorResponse), + pauseCollectorMetadata.decode.bind(pauseCollectorMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment', 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.rapidMigrationAssessmentStub) { + return this.rapidMigrationAssessmentStub; + } + + // Put together the "service stub" for + // google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment. + this.rapidMigrationAssessmentStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment, + 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 rapidMigrationAssessmentStubMethods = + ['createCollector', 'createAnnotation', 'getAnnotation', 'listCollectors', 'getCollector', 'updateCollector', 'deleteCollector', 'resumeCollector', 'registerCollector', 'pauseCollector']; + for (const methodName of rapidMigrationAssessmentStubMethods) { + const callPromise = this.rapidMigrationAssessmentStub.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.rapidMigrationAssessmentStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'rapidmigrationassessment.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 'rapidmigrationassessment.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 details of a single Annotation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.rapidmigrationassessment.v1.Annotation|Annotation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/rapid_migration_assessment.get_annotation.js + * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_GetAnnotation_async + */ + getAnnotation( + request?: protos.google.cloud.rapidmigrationassessment.v1.IGetAnnotationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.rapidmigrationassessment.v1.IAnnotation, + protos.google.cloud.rapidmigrationassessment.v1.IGetAnnotationRequest|undefined, {}|undefined + ]>; + getAnnotation( + request: protos.google.cloud.rapidmigrationassessment.v1.IGetAnnotationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.rapidmigrationassessment.v1.IAnnotation, + protos.google.cloud.rapidmigrationassessment.v1.IGetAnnotationRequest|null|undefined, + {}|null|undefined>): void; + getAnnotation( + request: protos.google.cloud.rapidmigrationassessment.v1.IGetAnnotationRequest, + callback: Callback< + protos.google.cloud.rapidmigrationassessment.v1.IAnnotation, + protos.google.cloud.rapidmigrationassessment.v1.IGetAnnotationRequest|null|undefined, + {}|null|undefined>): void; + getAnnotation( + request?: protos.google.cloud.rapidmigrationassessment.v1.IGetAnnotationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.rapidmigrationassessment.v1.IAnnotation, + protos.google.cloud.rapidmigrationassessment.v1.IGetAnnotationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.rapidmigrationassessment.v1.IAnnotation, + protos.google.cloud.rapidmigrationassessment.v1.IGetAnnotationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.rapidmigrationassessment.v1.IAnnotation, + protos.google.cloud.rapidmigrationassessment.v1.IGetAnnotationRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getAnnotation(request, options, callback); + } +/** + * Gets details of a single Collector. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.rapidmigrationassessment.v1.Collector|Collector}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/rapid_migration_assessment.get_collector.js + * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_GetCollector_async + */ + getCollector( + request?: protos.google.cloud.rapidmigrationassessment.v1.IGetCollectorRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.rapidmigrationassessment.v1.ICollector, + protos.google.cloud.rapidmigrationassessment.v1.IGetCollectorRequest|undefined, {}|undefined + ]>; + getCollector( + request: protos.google.cloud.rapidmigrationassessment.v1.IGetCollectorRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.rapidmigrationassessment.v1.ICollector, + protos.google.cloud.rapidmigrationassessment.v1.IGetCollectorRequest|null|undefined, + {}|null|undefined>): void; + getCollector( + request: protos.google.cloud.rapidmigrationassessment.v1.IGetCollectorRequest, + callback: Callback< + protos.google.cloud.rapidmigrationassessment.v1.ICollector, + protos.google.cloud.rapidmigrationassessment.v1.IGetCollectorRequest|null|undefined, + {}|null|undefined>): void; + getCollector( + request?: protos.google.cloud.rapidmigrationassessment.v1.IGetCollectorRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.rapidmigrationassessment.v1.ICollector, + protos.google.cloud.rapidmigrationassessment.v1.IGetCollectorRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.rapidmigrationassessment.v1.ICollector, + protos.google.cloud.rapidmigrationassessment.v1.IGetCollectorRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.rapidmigrationassessment.v1.ICollector, + protos.google.cloud.rapidmigrationassessment.v1.IGetCollectorRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getCollector(request, options, callback); + } + +/** + * Create a Collector to manage the on-prem appliance which collects + * information about Customer assets. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the parent (project+location). + * @param {string} request.collectorId + * Required. Id of the requesting object. + * @param {google.cloud.rapidmigrationassessment.v1.Collector} request.collector + * Required. The resource being created. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/rapid_migration_assessment.create_collector.js + * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateCollector_async + */ + createCollector( + request?: protos.google.cloud.rapidmigrationassessment.v1.ICreateCollectorRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createCollector( + request: protos.google.cloud.rapidmigrationassessment.v1.ICreateCollectorRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createCollector( + request: protos.google.cloud.rapidmigrationassessment.v1.ICreateCollectorRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createCollector( + request?: protos.google.cloud.rapidmigrationassessment.v1.ICreateCollectorRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createCollector(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createCollector()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/rapid_migration_assessment.create_collector.js + * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateCollector_async + */ + async checkCreateCollectorProgress(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.createCollector, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Creates an Annotation + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the parent (project+location). + * @param {google.cloud.rapidmigrationassessment.v1.Annotation} request.annotation + * Required. The resource being created. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/rapid_migration_assessment.create_annotation.js + * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateAnnotation_async + */ + createAnnotation( + request?: protos.google.cloud.rapidmigrationassessment.v1.ICreateAnnotationRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createAnnotation( + request: protos.google.cloud.rapidmigrationassessment.v1.ICreateAnnotationRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createAnnotation( + request: protos.google.cloud.rapidmigrationassessment.v1.ICreateAnnotationRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createAnnotation( + request?: protos.google.cloud.rapidmigrationassessment.v1.ICreateAnnotationRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createAnnotation(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createAnnotation()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/rapid_migration_assessment.create_annotation.js + * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateAnnotation_async + */ + async checkCreateAnnotationProgress(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.createAnnotation, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the parameters of a single Collector. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Field mask is used to specify the fields to be overwritten in the + * Collector resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.rapidmigrationassessment.v1.Collector} request.collector + * Required. The resource being updated. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/rapid_migration_assessment.update_collector.js + * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_UpdateCollector_async + */ + updateCollector( + request?: protos.google.cloud.rapidmigrationassessment.v1.IUpdateCollectorRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateCollector( + request: protos.google.cloud.rapidmigrationassessment.v1.IUpdateCollectorRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateCollector( + request: protos.google.cloud.rapidmigrationassessment.v1.IUpdateCollectorRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateCollector( + request?: protos.google.cloud.rapidmigrationassessment.v1.IUpdateCollectorRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'collector.name': request.collector!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateCollector(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateCollector()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/rapid_migration_assessment.update_collector.js + * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_UpdateCollector_async + */ + async checkUpdateCollectorProgress(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.updateCollector, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a single Collector - changes state of collector to "Deleting". + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/rapid_migration_assessment.delete_collector.js + * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_DeleteCollector_async + */ + deleteCollector( + request?: protos.google.cloud.rapidmigrationassessment.v1.IDeleteCollectorRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteCollector( + request: protos.google.cloud.rapidmigrationassessment.v1.IDeleteCollectorRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteCollector( + request: protos.google.cloud.rapidmigrationassessment.v1.IDeleteCollectorRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteCollector( + request?: protos.google.cloud.rapidmigrationassessment.v1.IDeleteCollectorRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteCollector(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteCollector()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/rapid_migration_assessment.delete_collector.js + * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_DeleteCollector_async + */ + async checkDeleteCollectorProgress(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.deleteCollector, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Resumes the given collector. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/rapid_migration_assessment.resume_collector.js + * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_ResumeCollector_async + */ + resumeCollector( + request?: protos.google.cloud.rapidmigrationassessment.v1.IResumeCollectorRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + resumeCollector( + request: protos.google.cloud.rapidmigrationassessment.v1.IResumeCollectorRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + resumeCollector( + request: protos.google.cloud.rapidmigrationassessment.v1.IResumeCollectorRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + resumeCollector( + request?: protos.google.cloud.rapidmigrationassessment.v1.IResumeCollectorRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.resumeCollector(request, options, callback); + } +/** + * Check the status of the long running operation returned by `resumeCollector()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/rapid_migration_assessment.resume_collector.js + * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_ResumeCollector_async + */ + async checkResumeCollectorProgress(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.resumeCollector, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Registers the given collector. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/rapid_migration_assessment.register_collector.js + * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_RegisterCollector_async + */ + registerCollector( + request?: protos.google.cloud.rapidmigrationassessment.v1.IRegisterCollectorRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + registerCollector( + request: protos.google.cloud.rapidmigrationassessment.v1.IRegisterCollectorRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + registerCollector( + request: protos.google.cloud.rapidmigrationassessment.v1.IRegisterCollectorRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + registerCollector( + request?: protos.google.cloud.rapidmigrationassessment.v1.IRegisterCollectorRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.registerCollector(request, options, callback); + } +/** + * Check the status of the long running operation returned by `registerCollector()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/rapid_migration_assessment.register_collector.js + * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_RegisterCollector_async + */ + async checkRegisterCollectorProgress(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.registerCollector, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Pauses the given collector. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/rapid_migration_assessment.pause_collector.js + * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_PauseCollector_async + */ + pauseCollector( + request?: protos.google.cloud.rapidmigrationassessment.v1.IPauseCollectorRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + pauseCollector( + request: protos.google.cloud.rapidmigrationassessment.v1.IPauseCollectorRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + pauseCollector( + request: protos.google.cloud.rapidmigrationassessment.v1.IPauseCollectorRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + pauseCollector( + request?: protos.google.cloud.rapidmigrationassessment.v1.IPauseCollectorRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.pauseCollector(request, options, callback); + } +/** + * Check the status of the long running operation returned by `pauseCollector()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/rapid_migration_assessment.pause_collector.js + * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_PauseCollector_async + */ + async checkPauseCollectorProgress(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.pauseCollector, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists Collectors in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListCollectorsRequest. + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Hint for how to order the 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 Array of {@link protos.google.cloud.rapidmigrationassessment.v1.Collector|Collector}. + * 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 `listCollectorsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listCollectors( + request?: protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.rapidmigrationassessment.v1.ICollector[], + protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest|null, + protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsResponse + ]>; + listCollectors( + request: protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest, + protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsResponse|null|undefined, + protos.google.cloud.rapidmigrationassessment.v1.ICollector>): void; + listCollectors( + request: protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest, + callback: PaginationCallback< + protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest, + protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsResponse|null|undefined, + protos.google.cloud.rapidmigrationassessment.v1.ICollector>): void; + listCollectors( + request?: protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest, + protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsResponse|null|undefined, + protos.google.cloud.rapidmigrationassessment.v1.ICollector>, + callback?: PaginationCallback< + protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest, + protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsResponse|null|undefined, + protos.google.cloud.rapidmigrationassessment.v1.ICollector>): + Promise<[ + protos.google.cloud.rapidmigrationassessment.v1.ICollector[], + protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest|null, + protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listCollectors(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. Parent value for ListCollectorsRequest. + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Hint for how to order the results. + * @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 protos.google.cloud.rapidmigrationassessment.v1.Collector|Collector} 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 `listCollectorsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listCollectorsStream( + request?: protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest, + 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['listCollectors']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCollectors.createStream( + this.innerApiCalls.listCollectors as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listCollectors`, 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. Parent value for ListCollectorsRequest. + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Hint for how to order the results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.rapidmigrationassessment.v1.Collector|Collector}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/rapid_migration_assessment.list_collectors.js + * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_ListCollectors_async + */ + listCollectorsAsync( + request?: protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest, + 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['listCollectors']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCollectors.asyncIterate( + this.innerApiCalls['listCollectors'] 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 annotation resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} annotation + * @returns {string} Resource name string. + */ + annotationPath(project:string,location:string,annotation:string) { + return this.pathTemplates.annotationPathTemplate.render({ + project: project, + location: location, + annotation: annotation, + }); + } + + /** + * Parse the project from Annotation resource. + * + * @param {string} annotationName + * A fully-qualified path representing Annotation resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAnnotationName(annotationName: string) { + return this.pathTemplates.annotationPathTemplate.match(annotationName).project; + } + + /** + * Parse the location from Annotation resource. + * + * @param {string} annotationName + * A fully-qualified path representing Annotation resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAnnotationName(annotationName: string) { + return this.pathTemplates.annotationPathTemplate.match(annotationName).location; + } + + /** + * Parse the annotation from Annotation resource. + * + * @param {string} annotationName + * A fully-qualified path representing Annotation resource. + * @returns {string} A string representing the annotation. + */ + matchAnnotationFromAnnotationName(annotationName: string) { + return this.pathTemplates.annotationPathTemplate.match(annotationName).annotation; + } + + /** + * Return a fully-qualified collector resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collector + * @returns {string} Resource name string. + */ + collectorPath(project:string,location:string,collector:string) { + return this.pathTemplates.collectorPathTemplate.render({ + project: project, + location: location, + collector: collector, + }); + } + + /** + * Parse the project from Collector resource. + * + * @param {string} collectorName + * A fully-qualified path representing Collector resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCollectorName(collectorName: string) { + return this.pathTemplates.collectorPathTemplate.match(collectorName).project; + } + + /** + * Parse the location from Collector resource. + * + * @param {string} collectorName + * A fully-qualified path representing Collector resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCollectorName(collectorName: string) { + return this.pathTemplates.collectorPathTemplate.match(collectorName).location; + } + + /** + * Parse the collector from Collector resource. + * + * @param {string} collectorName + * A fully-qualified path representing Collector resource. + * @returns {string} A string representing the collector. + */ + matchCollectorFromCollectorName(collectorName: string) { + return this.pathTemplates.collectorPathTemplate.match(collectorName).collector; + } + + /** + * 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; + } + + /** + * 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.rapidMigrationAssessmentStub && !this._terminated) { + return this.rapidMigrationAssessmentStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_client_config.json b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_client_config.json new file mode 100644 index 00000000000..83e4b3b1c8b --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_client_config.json @@ -0,0 +1,85 @@ +{ + "interfaces": { + "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment": { + "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 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateCollector": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateAnnotation": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetAnnotation": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "ListCollectors": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "GetCollector": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "UpdateCollector": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteCollector": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ResumeCollector": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RegisterCollector": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "PauseCollector": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_proto_list.json b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_proto_list.json new file mode 100644 index 00000000000..6c93aa0c5bd --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_proto_list.json @@ -0,0 +1,4 @@ +[ + "../../protos/google/cloud/rapidmigrationassessment/v1/api_entities.proto", + "../../protos/google/cloud/rapidmigrationassessment/v1/rapidmigrationassessment.proto" +] diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..043caedcfc7 --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const rapidmigrationassessment = require('@google-cloud/rapidmigrationassessment'); + +function main() { + const rapidMigrationAssessmentClient = new rapidmigrationassessment.RapidMigrationAssessmentClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..5f1819598d7 --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {RapidMigrationAssessmentClient} from '@google-cloud/rapidmigrationassessment'; + +// check that the client class type name can be used +function doStuffWithRapidMigrationAssessmentClient(client: RapidMigrationAssessmentClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const rapidMigrationAssessmentClient = new RapidMigrationAssessmentClient(); + doStuffWithRapidMigrationAssessmentClient(rapidMigrationAssessmentClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/install.ts b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/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-rapidmigrationassessment/v1/test/gapic_rapid_migration_assessment_v1.ts b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/test/gapic_rapid_migration_assessment_v1.ts new file mode 100644 index 00000000000..5cf9b669399 --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/test/gapic_rapid_migration_assessment_v1.ts @@ -0,0 +1,2310 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 rapidmigrationassessmentModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.RapidMigrationAssessmentClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.rapidMigrationAssessmentStub, undefined); + await client.initialize(); + assert(client.rapidMigrationAssessmentStub); + }); + + it('has close method for the initialized client', done => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.rapidMigrationAssessmentStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.rapidMigrationAssessmentStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + 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('getAnnotation', () => { + it('invokes getAnnotation without error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.GetAnnotationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.GetAnnotationRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.Annotation() + ); + client.innerApiCalls.getAnnotation = stubSimpleCall(expectedResponse); + const [response] = await client.getAnnotation(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getAnnotation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAnnotation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAnnotation without error using callback', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.GetAnnotationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.GetAnnotationRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.Annotation() + ); + client.innerApiCalls.getAnnotation = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAnnotation( + request, + (err?: Error|null, result?: protos.google.cloud.rapidmigrationassessment.v1.IAnnotation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getAnnotation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAnnotation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAnnotation with error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.GetAnnotationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.GetAnnotationRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAnnotation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getAnnotation(request), expectedError); + const actualRequest = (client.innerApiCalls.getAnnotation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAnnotation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAnnotation with closed client', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.GetAnnotationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.GetAnnotationRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getAnnotation(request), expectedError); + }); + }); + + describe('getCollector', () => { + it('invokes getCollector without error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.GetCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.GetCollectorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.Collector() + ); + client.innerApiCalls.getCollector = stubSimpleCall(expectedResponse); + const [response] = await client.getCollector(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCollector without error using callback', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.GetCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.GetCollectorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.Collector() + ); + client.innerApiCalls.getCollector = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCollector( + request, + (err?: Error|null, result?: protos.google.cloud.rapidmigrationassessment.v1.ICollector|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCollector with error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.GetCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.GetCollectorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCollector = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getCollector(request), expectedError); + const actualRequest = (client.innerApiCalls.getCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCollector with closed client', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.GetCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.GetCollectorRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getCollector(request), expectedError); + }); + }); + + describe('createCollector', () => { + it('invokes createCollector without error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.CreateCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.CreateCollectorRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createCollector = stubLongRunningCall(expectedResponse); + const [operation] = await client.createCollector(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createCollector without error using callback', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.CreateCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.CreateCollectorRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createCollector = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCollector( + request, + (err?: Error|null, + result?: 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.createCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createCollector with call error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.CreateCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.CreateCollectorRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCollector = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createCollector(request), expectedError); + const actualRequest = (client.innerApiCalls.createCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createCollector with LRO error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.CreateCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.CreateCollectorRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCollector = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createCollector(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateCollectorProgress without error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateCollectorProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateCollectorProgress with error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateCollectorProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('createAnnotation', () => { + it('invokes createAnnotation without error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.CreateAnnotationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.CreateAnnotationRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createAnnotation = stubLongRunningCall(expectedResponse); + const [operation] = await client.createAnnotation(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createAnnotation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createAnnotation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createAnnotation without error using callback', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.CreateAnnotationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.CreateAnnotationRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createAnnotation = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createAnnotation( + request, + (err?: Error|null, + result?: 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.createAnnotation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createAnnotation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createAnnotation with call error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.CreateAnnotationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.CreateAnnotationRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createAnnotation = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createAnnotation(request), expectedError); + const actualRequest = (client.innerApiCalls.createAnnotation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createAnnotation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createAnnotation with LRO error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.CreateAnnotationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.CreateAnnotationRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createAnnotation = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createAnnotation(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createAnnotation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createAnnotation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateAnnotationProgress without error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateAnnotationProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateAnnotationProgress with error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateAnnotationProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateCollector', () => { + it('invokes updateCollector without error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.UpdateCollectorRequest() + ); + request.collector ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.UpdateCollectorRequest', ['collector', 'name']); + request.collector.name = defaultValue1; + const expectedHeaderRequestParams = `collector.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateCollector = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateCollector(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCollector without error using callback', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.UpdateCollectorRequest() + ); + request.collector ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.UpdateCollectorRequest', ['collector', 'name']); + request.collector.name = defaultValue1; + const expectedHeaderRequestParams = `collector.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateCollector = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCollector( + request, + (err?: Error|null, + result?: 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.updateCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCollector with call error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.UpdateCollectorRequest() + ); + request.collector ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.UpdateCollectorRequest', ['collector', 'name']); + request.collector.name = defaultValue1; + const expectedHeaderRequestParams = `collector.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCollector = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateCollector(request), expectedError); + const actualRequest = (client.innerApiCalls.updateCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCollector with LRO error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.UpdateCollectorRequest() + ); + request.collector ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.UpdateCollectorRequest', ['collector', 'name']); + request.collector.name = defaultValue1; + const expectedHeaderRequestParams = `collector.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCollector = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateCollector(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateCollectorProgress without error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateCollectorProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateCollectorProgress with error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateCollectorProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteCollector', () => { + it('invokes deleteCollector without error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.DeleteCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.DeleteCollectorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteCollector = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteCollector(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteCollector without error using callback', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.DeleteCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.DeleteCollectorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteCollector = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteCollector( + request, + (err?: Error|null, + result?: 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.deleteCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteCollector with call error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.DeleteCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.DeleteCollectorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCollector = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteCollector(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteCollector with LRO error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.DeleteCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.DeleteCollectorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCollector = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteCollector(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteCollectorProgress without error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteCollectorProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteCollectorProgress with error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteCollectorProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('resumeCollector', () => { + it('invokes resumeCollector without error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.ResumeCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ResumeCollectorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.resumeCollector = stubLongRunningCall(expectedResponse); + const [operation] = await client.resumeCollector(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resumeCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeCollector without error using callback', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.ResumeCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ResumeCollectorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.resumeCollector = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resumeCollector( + request, + (err?: Error|null, + result?: 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.resumeCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeCollector with call error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.ResumeCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ResumeCollectorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resumeCollector = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.resumeCollector(request), expectedError); + const actualRequest = (client.innerApiCalls.resumeCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeCollector with LRO error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.ResumeCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ResumeCollectorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resumeCollector = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.resumeCollector(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.resumeCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkResumeCollectorProgress without error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkResumeCollectorProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkResumeCollectorProgress with error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkResumeCollectorProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('registerCollector', () => { + it('invokes registerCollector without error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.RegisterCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.RegisterCollectorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.registerCollector = stubLongRunningCall(expectedResponse); + const [operation] = await client.registerCollector(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.registerCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.registerCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes registerCollector without error using callback', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.RegisterCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.RegisterCollectorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.registerCollector = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.registerCollector( + request, + (err?: Error|null, + result?: 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.registerCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.registerCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes registerCollector with call error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.RegisterCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.RegisterCollectorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.registerCollector = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.registerCollector(request), expectedError); + const actualRequest = (client.innerApiCalls.registerCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.registerCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes registerCollector with LRO error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.RegisterCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.RegisterCollectorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.registerCollector = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.registerCollector(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.registerCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.registerCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkRegisterCollectorProgress without error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRegisterCollectorProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRegisterCollectorProgress with error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRegisterCollectorProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('pauseCollector', () => { + it('invokes pauseCollector without error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.PauseCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.PauseCollectorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.pauseCollector = stubLongRunningCall(expectedResponse); + const [operation] = await client.pauseCollector(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pauseCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseCollector without error using callback', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.PauseCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.PauseCollectorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.pauseCollector = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.pauseCollector( + request, + (err?: Error|null, + result?: 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.pauseCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseCollector with call error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.PauseCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.PauseCollectorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.pauseCollector = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.pauseCollector(request), expectedError); + const actualRequest = (client.innerApiCalls.pauseCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseCollector with LRO error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.PauseCollectorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.PauseCollectorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.pauseCollector = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.pauseCollector(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.pauseCollector as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseCollector as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkPauseCollectorProgress without error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPauseCollectorProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPauseCollectorProgress with error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkPauseCollectorProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listCollectors', () => { + it('invokes listCollectors without error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), + generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), + generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), + ]; + client.innerApiCalls.listCollectors = stubSimpleCall(expectedResponse); + const [response] = await client.listCollectors(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listCollectors as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCollectors as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listCollectors without error using callback', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), + generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), + generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), + ]; + client.innerApiCalls.listCollectors = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCollectors( + request, + (err?: Error|null, result?: protos.google.cloud.rapidmigrationassessment.v1.ICollector[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listCollectors as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCollectors as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listCollectors with error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCollectors = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCollectors(request), expectedError); + const actualRequest = (client.innerApiCalls.listCollectors as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCollectors as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listCollectorsStream without error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), + generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), + generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), + ]; + client.descriptors.page.listCollectors.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listCollectorsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.rapidmigrationassessment.v1.Collector[] = []; + stream.on('data', (response: protos.google.cloud.rapidmigrationassessment.v1.Collector) => { + 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.listCollectors.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCollectors, request)); + assert( + (client.descriptors.page.listCollectors.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listCollectorsStream with error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCollectors.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listCollectorsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.rapidmigrationassessment.v1.Collector[] = []; + stream.on('data', (response: protos.google.cloud.rapidmigrationassessment.v1.Collector) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listCollectors.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCollectors, request)); + assert( + (client.descriptors.page.listCollectors.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listCollectors without error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), + generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), + generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), + ]; + client.descriptors.page.listCollectors.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.rapidmigrationassessment.v1.ICollector[] = []; + const iterable = client.listCollectorsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCollectors.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listCollectors.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listCollectors with error', async () => { + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCollectors.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCollectorsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.rapidmigrationassessment.v1.ICollector[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCollectors.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listCollectors.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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + 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('annotation', () => { + const fakePath = "/rendered/path/annotation"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + annotation: "annotationValue", + }; + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.annotationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.annotationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('annotationPath', () => { + const result = client.annotationPath("projectValue", "locationValue", "annotationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.annotationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAnnotationName', () => { + const result = client.matchProjectFromAnnotationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.annotationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAnnotationName', () => { + const result = client.matchLocationFromAnnotationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.annotationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchAnnotationFromAnnotationName', () => { + const result = client.matchAnnotationFromAnnotationName(fakePath); + assert.strictEqual(result, "annotationValue"); + assert((client.pathTemplates.annotationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('collector', () => { + const fakePath = "/rendered/path/collector"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collector: "collectorValue", + }; + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.collectorPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.collectorPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('collectorPath', () => { + const result = client.collectorPath("projectValue", "locationValue", "collectorValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.collectorPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCollectorName', () => { + const result = client.matchProjectFromCollectorName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.collectorPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCollectorName', () => { + const result = client.matchLocationFromCollectorName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.collectorPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectorFromCollectorName', () => { + const result = client.matchCollectorFromCollectorName(fakePath); + assert.strictEqual(result, "collectorValue"); + assert((client.pathTemplates.collectorPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ + 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)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/tsconfig.json b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/webpack.config.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/webpack.config.js new file mode 100644 index 00000000000..5dfe6903548 --- /dev/null +++ b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'RapidMigrationAssessment', + filename: './rapid-migration-assessment.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-recaptchaenterprise/v1/.eslintignore b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.eslintrc.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.gitignore b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.jsdoc.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.jsdoc.js new file mode 100644 index 00000000000..495384476fc --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.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/recaptcha-enterprise', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.mocharc.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.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-recaptchaenterprise/v1/.prettierrc.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.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-recaptchaenterprise/v1/README.md b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/README.md new file mode 100644 index 00000000000..57a5e168123 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/README.md @@ -0,0 +1 @@ +Recaptchaenterprise: Nodejs Client diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/package.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/package.json new file mode 100644 index 00000000000..8fa34225ff3 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/recaptcha-enterprise", + "version": "0.1.0", + "description": "Recaptchaenterprise client for Node.js", + "repository": "googleapis/nodejs-recaptchaenterprise", + "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 recaptchaenterprise", + "recaptchaenterprise", + "recaptcha enterprise service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto new file mode 100644 index 00000000000..e73de0c97e0 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto @@ -0,0 +1,1427 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.recaptchaenterprise.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.RecaptchaEnterprise.V1"; +option go_package = "cloud.google.com/go/recaptchaenterprise/v2/apiv1/recaptchaenterprisepb;recaptchaenterprisepb"; +option java_multiple_files = true; +option java_outer_classname = "RecaptchaEnterpriseProto"; +option java_package = "com.google.recaptchaenterprise.v1"; +option objc_class_prefix = "GCRE"; +option php_namespace = "Google\\Cloud\\RecaptchaEnterprise\\V1"; +option ruby_package = "Google::Cloud::RecaptchaEnterprise::V1"; + +// Service to determine the likelihood an event is legitimate. +service RecaptchaEnterpriseService { + option (google.api.default_host) = "recaptchaenterprise.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates an Assessment of the likelihood an event is legitimate. + rpc CreateAssessment(CreateAssessmentRequest) returns (Assessment) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/assessments" + body: "assessment" + }; + option (google.api.method_signature) = "parent,assessment"; + } + + // Annotates a previously created Assessment to provide additional information + // on whether the event turned out to be authentic or fraudulent. + rpc AnnotateAssessment(AnnotateAssessmentRequest) + returns (AnnotateAssessmentResponse) { + option (google.api.http) = { + post: "/v1/{name=projects/*/assessments/*}:annotate" + body: "*" + }; + option (google.api.method_signature) = "name,annotation"; + } + + // Creates a new reCAPTCHA Enterprise key. + rpc CreateKey(CreateKeyRequest) returns (Key) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/keys" + body: "key" + }; + option (google.api.method_signature) = "parent,key"; + } + + // Returns the list of all keys that belong to a project. + rpc ListKeys(ListKeysRequest) returns (ListKeysResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*}/keys" + }; + option (google.api.method_signature) = "parent"; + } + + // Returns the secret key related to the specified public key. + // You must use the legacy secret key only in a 3rd party integration with + // legacy reCAPTCHA. + rpc RetrieveLegacySecretKey(RetrieveLegacySecretKeyRequest) + returns (RetrieveLegacySecretKeyResponse) { + option (google.api.http) = { + get: "/v1/{key=projects/*/keys/*}:retrieveLegacySecretKey" + }; + option (google.api.method_signature) = "key"; + } + + // Returns the specified key. + rpc GetKey(GetKeyRequest) returns (Key) { + option (google.api.http) = { + get: "/v1/{name=projects/*/keys/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the specified key. + rpc UpdateKey(UpdateKeyRequest) returns (Key) { + option (google.api.http) = { + patch: "/v1/{key.name=projects/*/keys/*}" + body: "key" + }; + option (google.api.method_signature) = "key,update_mask"; + } + + // Deletes the specified key. + rpc DeleteKey(DeleteKeyRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/keys/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise. + // Once a key is migrated, it can be used from either product. SiteVerify + // requests are billed as CreateAssessment calls. You must be + // authenticated as one of the current owners of the reCAPTCHA Site Key, and + // your user must have the reCAPTCHA Enterprise Admin IAM role in the + // destination project. + rpc MigrateKey(MigrateKeyRequest) returns (Key) { + option (google.api.http) = { + post: "/v1/{name=projects/*/keys/*}:migrate" + body: "*" + }; + } + + // Get some aggregated metrics for a Key. This data can be used to build + // dashboards. + rpc GetMetrics(GetMetricsRequest) returns (Metrics) { + option (google.api.http) = { + get: "/v1/{name=projects/*/keys/*/metrics}" + }; + option (google.api.method_signature) = "name"; + } + + // List groups of related accounts. + rpc ListRelatedAccountGroups(ListRelatedAccountGroupsRequest) + returns (ListRelatedAccountGroupsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*}/relatedaccountgroups" + }; + option (google.api.method_signature) = "parent"; + } + + // Get memberships in a group of related accounts. + rpc ListRelatedAccountGroupMemberships( + ListRelatedAccountGroupMembershipsRequest) + returns (ListRelatedAccountGroupMembershipsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/relatedaccountgroups/*}/memberships" + }; + option (google.api.method_signature) = "parent"; + } + + // Search group memberships related to a given account. + rpc SearchRelatedAccountGroupMemberships( + SearchRelatedAccountGroupMembershipsRequest) + returns (SearchRelatedAccountGroupMembershipsResponse) { + option (google.api.http) = { + post: "/v1/{project=projects/*}/relatedaccountgroupmemberships:search" + body: "*" + }; + option (google.api.method_signature) = "project,hashed_account_id"; + } +} + +// The create assessment request message. +message CreateAssessmentRequest { + // Required. The name of the project in which the assessment will be created, + // in the format "projects/{project}". + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Required. The assessment details. + Assessment assessment = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Describes an event in the lifecycle of a payment transaction. +message TransactionEvent { + // Enum that represents an event in the payment transaction lifecycle. + enum TransactionEventType { + // Default, unspecified event type. + TRANSACTION_EVENT_TYPE_UNSPECIFIED = 0; + + // Indicates that the transaction is approved by the merchant. The + // accompanying reasons can include terms such as 'INHOUSE', 'ACCERTIFY', + // 'CYBERSOURCE', or 'MANUAL_REVIEW'. + MERCHANT_APPROVE = 1; + + // Indicates that the transaction is denied and concluded due to risks + // detected by the merchant. The accompanying reasons can include terms such + // as 'INHOUSE', 'ACCERTIFY', 'CYBERSOURCE', or 'MANUAL_REVIEW'. + MERCHANT_DENY = 2; + + // Indicates that the transaction is being evaluated by a human, due to + // suspicion or risk. + MANUAL_REVIEW = 3; + + // Indicates that the authorization attempt with the card issuer succeeded. + AUTHORIZATION = 4; + + // Indicates that the authorization attempt with the card issuer failed. + // The accompanying reasons can include Visa's '54' indicating that the card + // is expired, or '82' indicating that the CVV is incorrect. + AUTHORIZATION_DECLINE = 5; + + // Indicates that the transaction is completed because the funds were + // settled. + PAYMENT_CAPTURE = 6; + + // Indicates that the transaction could not be completed because the funds + // were not settled. + PAYMENT_CAPTURE_DECLINE = 7; + + // Indicates that the transaction has been canceled. Specify the reason + // for the cancellation. For example, 'INSUFFICIENT_INVENTORY'. + CANCEL = 8; + + // Indicates that the merchant has received a chargeback inquiry due to + // fraud for the transaction, requesting additional information before a + // fraud chargeback is officially issued and a formal chargeback + // notification is sent. + CHARGEBACK_INQUIRY = 9; + + // Indicates that the merchant has received a chargeback alert due to fraud + // for the transaction. The process of resolving the dispute without + // involving the payment network is started. + CHARGEBACK_ALERT = 10; + + // Indicates that a fraud notification is issued for the transaction, sent + // by the payment instrument's issuing bank because the transaction appears + // to be fraudulent. We recommend including TC40 or SAFE data in the + // `reason` field for this event type. For partial chargebacks, we recommend + // that you include an amount in the `value` field. + FRAUD_NOTIFICATION = 11; + + // Indicates that the merchant is informed by the payment network that the + // transaction has entered the chargeback process due to fraud. Reason code + // examples include Discover's '6005' and '6041'. For partial chargebacks, + // we recommend that you include an amount in the `value` field. + CHARGEBACK = 12; + + // Indicates that the transaction has entered the chargeback process due to + // fraud, and that the merchant has chosen to enter representment. Reason + // examples include Discover's '6005' and '6041'. For partial chargebacks, + // we recommend that you include an amount in the `value` field. + CHARGEBACK_REPRESENTMENT = 13; + + // Indicates that the transaction has had a fraud chargeback which was + // illegitimate and was reversed as a result. For partial chargebacks, we + // recommend that you include an amount in the `value` field. + CHARGEBACK_REVERSE = 14; + + // Indicates that the merchant has received a refund for a completed + // transaction. For partial refunds, we recommend that you include an amount + // in the `value` field. Reason example: 'TAX_EXEMPT' (partial refund of + // exempt tax) + REFUND_REQUEST = 15; + + // Indicates that the merchant has received a refund request for this + // transaction, but that they have declined it. For partial refunds, we + // recommend that you include an amount in the `value` field. Reason + // example: 'TAX_EXEMPT' (partial refund of exempt tax) + REFUND_DECLINE = 16; + + // Indicates that the completed transaction was refunded by the merchant. + // For partial refunds, we recommend that you include an amount in the + // `value` field. Reason example: 'TAX_EXEMPT' (partial refund of exempt + // tax) + REFUND = 17; + + // Indicates that the completed transaction was refunded by the merchant, + // and that this refund was reversed. For partial refunds, we recommend that + // you include an amount in the `value` field. + REFUND_REVERSE = 18; + } + + // Optional. The type of this transaction event. + TransactionEventType event_type = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The reason or standardized code that corresponds with this + // transaction event, if one exists. For example, a CHARGEBACK event with code + // 6005. + string reason = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The value that corresponds with this transaction event, if one + // exists. For example, a refund event where $5.00 was refunded. Currency is + // obtained from the original transaction data. + double value = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Timestamp when this transaction event occurred; otherwise assumed + // to be the time of the API call. + google.protobuf.Timestamp event_time = 4 + [(google.api.field_behavior) = OPTIONAL]; +} + +// The request message to annotate an Assessment. +message AnnotateAssessmentRequest { + // Enum that represents the types of annotations. + enum Annotation { + // Default unspecified type. + ANNOTATION_UNSPECIFIED = 0; + + // Provides information that the event turned out to be legitimate. + LEGITIMATE = 1; + + // Provides information that the event turned out to be fraudulent. + FRAUDULENT = 2; + + // Provides information that the event was related to a login event in which + // the user typed the correct password. Deprecated, prefer indicating + // CORRECT_PASSWORD through the reasons field instead. + PASSWORD_CORRECT = 3 [deprecated = true]; + + // Provides information that the event was related to a login event in which + // the user typed the incorrect password. Deprecated, prefer indicating + // INCORRECT_PASSWORD through the reasons field instead. + PASSWORD_INCORRECT = 4 [deprecated = true]; + } + + // Enum that represents potential reasons for annotating an assessment. + enum Reason { + // Default unspecified reason. + REASON_UNSPECIFIED = 0; + + // Indicates that the transaction had a chargeback issued with no other + // details. When possible, specify the type by using CHARGEBACK_FRAUD or + // CHARGEBACK_DISPUTE instead. + CHARGEBACK = 1; + + // Indicates that the transaction had a chargeback issued related to an + // alleged unauthorized transaction from the cardholder's perspective (for + // example, the card number was stolen). + CHARGEBACK_FRAUD = 8; + + // Indicates that the transaction had a chargeback issued related to the + // cardholder having provided their card details but allegedly not being + // satisfied with the purchase (for example, misrepresentation, attempted + // cancellation). + CHARGEBACK_DISPUTE = 9; + + // Indicates that the completed payment transaction was refunded by the + // seller. + REFUND = 10; + + // Indicates that the completed payment transaction was determined to be + // fraudulent by the seller, and was cancelled and refunded as a result. + REFUND_FRAUD = 11; + + // Indicates that the payment transaction was accepted, and the user was + // charged. + TRANSACTION_ACCEPTED = 12; + + // Indicates that the payment transaction was declined, for example due to + // invalid card details. + TRANSACTION_DECLINED = 13; + + // Indicates the transaction associated with the assessment is suspected of + // being fraudulent based on the payment method, billing details, shipping + // address or other transaction information. + PAYMENT_HEURISTICS = 2; + + // Indicates that the user was served a 2FA challenge. An old assessment + // with `ENUM_VALUES.INITIATED_TWO_FACTOR` reason that has not been + // overwritten with `PASSED_TWO_FACTOR` is treated as an abandoned 2FA flow. + // This is equivalent to `FAILED_TWO_FACTOR`. + INITIATED_TWO_FACTOR = 7; + + // Indicates that the user passed a 2FA challenge. + PASSED_TWO_FACTOR = 3; + + // Indicates that the user failed a 2FA challenge. + FAILED_TWO_FACTOR = 4; + + // Indicates the user provided the correct password. + CORRECT_PASSWORD = 5; + + // Indicates the user provided an incorrect password. + INCORRECT_PASSWORD = 6; + + // Indicates that the user sent unwanted and abusive messages to other users + // of the platform, such as spam, scams, phishing, or social engineering. + SOCIAL_SPAM = 14; + } + + // Required. The resource name of the Assessment, in the format + // "projects/{project}/assessments/{assessment}". + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recaptchaenterprise.googleapis.com/Assessment" + } + ]; + + // Optional. The annotation that will be assigned to the Event. This field can + // be left empty to provide reasons that apply to an event without concluding + // whether the event is legitimate or fraudulent. + Annotation annotation = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Optional reasons for the annotation that will be assigned to the + // Event. + repeated Reason reasons = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Unique stable hashed user identifier to apply to the assessment. + // This is an alternative to setting the hashed_account_id in + // CreateAssessment, for example when the account identifier is not yet known + // in the initial request. It is recommended that the identifier is hashed + // using hmac-sha256 with stable secret. + bytes hashed_account_id = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If the assessment is part of a payment transaction, provide + // details on payment lifecycle events that occur in the transaction. + TransactionEvent transaction_event = 5 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Empty response for AnnotateAssessment. +message AnnotateAssessmentResponse {} + +// Information about a verification endpoint that can be used for 2FA. +message EndpointVerificationInfo { + oneof endpoint { + // Email address for which to trigger a verification request. + string email_address = 1; + + // Phone number for which to trigger a verification request. Should be given + // in E.164 format. + string phone_number = 2; + } + + // Output only. Token to provide to the client to trigger endpoint + // verification. It must be used within 15 minutes. + string request_token = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp of the last successful verification for the + // endpoint, if any. + google.protobuf.Timestamp last_verification_time = 4 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Information about account verification, used for identity verification. +message AccountVerificationInfo { + // Result of the account verification as contained in the verdict token issued + // at the end of the verification flow. + enum Result { + // No information about the latest account verification. + RESULT_UNSPECIFIED = 0; + + // The user was successfully verified. This means the account verification + // challenge was successfully completed. + SUCCESS_USER_VERIFIED = 1; + + // The user failed the verification challenge. + ERROR_USER_NOT_VERIFIED = 2; + + // The site is not properly onboarded to use the account verification + // feature. + ERROR_SITE_ONBOARDING_INCOMPLETE = 3; + + // The recipient is not allowed for account verification. This can occur + // during integration but should not occur in production. + ERROR_RECIPIENT_NOT_ALLOWED = 4; + + // The recipient has already been sent too many verification codes in a + // short amount of time. + ERROR_RECIPIENT_ABUSE_LIMIT_EXHAUSTED = 5; + + // The verification flow could not be completed due to a critical internal + // error. + ERROR_CRITICAL_INTERNAL = 6; + + // The client has exceeded their two factor request quota for this period of + // time. + ERROR_CUSTOMER_QUOTA_EXHAUSTED = 7; + + // The request cannot be processed at the time because of an incident. This + // bypass can be restricted to a problematic destination email domain, a + // customer, or could affect the entire service. + ERROR_VERIFICATION_BYPASSED = 8; + + // The request parameters do not match with the token provided and cannot be + // processed. + ERROR_VERDICT_MISMATCH = 9; + } + + // Endpoints that can be used for identity verification. + repeated EndpointVerificationInfo endpoints = 1; + + // Language code preference for the verification message, set as a IETF BCP 47 + // language code. + string language_code = 3; + + // Output only. Result of the latest account verification challenge. + Result latest_verification_result = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Username of the account that is being verified. Deprecated. Customers + // should now provide the hashed account ID field in Event. + string username = 2 [deprecated = true]; +} + +// Private password leak verification info. +message PrivatePasswordLeakVerification { + // Optional. Exactly 26-bit prefix of the SHA-256 hash of the canonicalized + // username. It is used to look up password leaks associated with that hash + // prefix. + bytes lookup_hash_prefix = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Encrypted Scrypt hash of the canonicalized username+password. It + // is re-encrypted by the server and returned through + // `reencrypted_user_credentials_hash`. + bytes encrypted_user_credentials_hash = 2 + [(google.api.field_behavior) = OPTIONAL]; + + // Output only. List of prefixes of the encrypted potential password leaks + // that matched the given parameters. They must be compared with the + // client-side decryption prefix of `reencrypted_user_credentials_hash` + repeated bytes encrypted_leak_match_prefixes = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Corresponds to the re-encryption of the + // `encrypted_user_credentials_hash` field. It is used to match potential + // password leaks within `encrypted_leak_match_prefixes`. + bytes reencrypted_user_credentials_hash = 4 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A reCAPTCHA Enterprise assessment resource. +message Assessment { + option (google.api.resource) = { + type: "recaptchaenterprise.googleapis.com/Assessment" + pattern: "projects/{project}/assessments/{assessment}" + }; + + // Output only. The resource name for the Assessment in the format + // "projects/{project}/assessments/{assessment}". + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The event being assessed. + Event event = 2; + + // Output only. The risk analysis result for the event being assessed. + RiskAnalysis risk_analysis = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Properties of the provided event token. + TokenProperties token_properties = 4 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Account verification information for identity verification. The assessment + // event must include a token and site key to use this feature. + AccountVerificationInfo account_verification = 5; + + // Assessment returned by account defender when a hashed_account_id is + // provided. + AccountDefenderAssessment account_defender_assessment = 6; + + // The private password leak verification field contains the parameters that + // are used to to check for leaks privately without sharing user credentials. + PrivatePasswordLeakVerification private_password_leak_verification = 8; + + // Assessment returned by Fraud Prevention when TransactionData is provided. + FraudPreventionAssessment fraud_prevention_assessment = 11; +} + +// The event being assessed. +message Event { + // Optional. The user response token provided by the reCAPTCHA Enterprise + // client-side integration on your site. + string token = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The site key that was used to invoke reCAPTCHA Enterprise on your + // site and generate the token. + string site_key = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The user agent present in the request from the user's device + // related to this event. + string user_agent = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The IP address in the request from the user's device related to + // this event. + string user_ip_address = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The expected action for this type of event. This should be the + // same action provided at token generation time on client-side platforms + // already integrated with recaptcha enterprise. + string expected_action = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Unique stable hashed user identifier for the request. The + // identifier must be hashed using hmac-sha256 with stable secret. + bytes hashed_account_id = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Data describing a payment transaction to be assessed. Sending + // this data enables reCAPTCHA Enterprise Fraud Prevention and the + // FraudPreventionAssessment component in the response. + TransactionData transaction_data = 13 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Transaction data associated with a payment protected by reCAPTCHA Enterprise. +// All fields are optional. +message TransactionData { + // Structured address format for billing and shipping addresses. + message Address { + // The recipient name, potentially including information such as "care of". + string recipient = 1; + + // The first lines of the address. The first line generally contains the + // street name and number, and further lines may include information such as + // an apartment number. + repeated string address = 2; + + // The town/city of the address. + string locality = 3; + + // The state, province, or otherwise administrative area of the address. + string administrative_area = 4; + + // The CLDR country/region of the address. + string region_code = 5; + + // The postal or ZIP code of the address. + string postal_code = 6; + } + + // Details about a user's account involved in the transaction. + message User { + // Unique account identifier for this user. If using account defender, + // this should match the hashed_account_id field. Otherwise, a unique and + // persistent identifier for this account. + string account_id = 6; + + // The epoch milliseconds of the user's account creation. + int64 creation_ms = 1; + + // The email address of the user. + string email = 2; + + // Whether the email has been verified to be accessible by the user (OTP or + // similar). + bool email_verified = 3; + + // The phone number of the user, with country code. + string phone_number = 4; + + // Whether the phone number has been verified to be accessible by the user + // (OTP or similar). + bool phone_verified = 5; + } + + // Line items being purchased in this transaction. + message Item { + // The full name of the item. + string name = 1; + + // The value per item that the user is paying, in the transaction currency, + // after discounts. + double value = 2; + + // The quantity of this item that is being purchased. + int64 quantity = 3; + + // When a merchant is specified, its corresponding account_id. Necessary to + // populate marketplace-style transactions. + string merchant_account_id = 4; + } + + // Details about the transaction from the gateway. + message GatewayInfo { + // Name of the gateway service (for example, stripe, square, paypal). + string name = 1; + + // Gateway response code describing the state of the transaction. + string gateway_response_code = 2; + + // AVS response code from the gateway + // (available only when reCAPTCHA Enterprise is called after authorization). + string avs_response_code = 3; + + // CVV response code from the gateway + // (available only when reCAPTCHA Enterprise is called after authorization). + string cvv_response_code = 4; + } + + // Unique identifier for the transaction. This custom identifier can be used + // to reference this transaction in the future, for example, labeling a refund + // or chargeback event. Two attempts at the same transaction should use the + // same transaction id. + optional string transaction_id = 11; + + // The payment method for the transaction. The allowed values are: + // + // * credit-card + // * debit-card + // * gift-card + // * processor-{name} (If a third-party is used, for example, + // processor-paypal) + // * custom-{name} (If an alternative method is used, for example, + // custom-crypto) + string payment_method = 1; + + // The Bank Identification Number - generally the first 6 or 8 digits of the + // card. + string card_bin = 2; + + // The last four digits of the card. + string card_last_four = 3; + + // The currency code in ISO-4217 format. + string currency_code = 4; + + // The decimal value of the transaction in the specified currency. + double value = 5; + + // The value of shipping in the specified currency. 0 for free or no shipping. + double shipping_value = 12; + + // Destination address if this transaction involves shipping a physical item. + Address shipping_address = 6; + + // Address associated with the payment method when applicable. + Address billing_address = 7; + + // Information about the user paying/initiating the transaction. + User user = 8; + + // Information about the user or users fulfilling the transaction. + repeated User merchants = 13; + + // Items purchased in this transaction. + repeated Item items = 14; + + // Information about the payment gateway's response to the transaction. + GatewayInfo gateway_info = 10; +} + +// Risk analysis result for an event. +message RiskAnalysis { + // Reasons contributing to the risk analysis verdict. + enum ClassificationReason { + // Default unspecified type. + CLASSIFICATION_REASON_UNSPECIFIED = 0; + + // Interactions matched the behavior of an automated agent. + AUTOMATION = 1; + + // The event originated from an illegitimate environment. + UNEXPECTED_ENVIRONMENT = 2; + + // Traffic volume from the event source is higher than normal. + TOO_MUCH_TRAFFIC = 3; + + // Interactions with the site were significantly different than expected + // patterns. + UNEXPECTED_USAGE_PATTERNS = 4; + + // Too little traffic has been received from this site thus far to generate + // quality risk analysis. + LOW_CONFIDENCE_SCORE = 5; + + // The request matches behavioral characteristics of a carding attack. + SUSPECTED_CARDING = 6; + + // The request matches behavioral characteristics of chargebacks for fraud. + SUSPECTED_CHARGEBACK = 7; + } + + // Legitimate event score from 0.0 to 1.0. + // (1.0 means very likely legitimate traffic while 0.0 means very likely + // non-legitimate traffic). + float score = 1; + + // Reasons contributing to the risk analysis verdict. + repeated ClassificationReason reasons = 2; +} + +// Properties of the provided event token. +message TokenProperties { + // Enum that represents the types of invalid token reasons. + enum InvalidReason { + // Default unspecified type. + INVALID_REASON_UNSPECIFIED = 0; + + // If the failure reason was not accounted for. + UNKNOWN_INVALID_REASON = 1; + + // The provided user verification token was malformed. + MALFORMED = 2; + + // The user verification token had expired. + EXPIRED = 3; + + // The user verification had already been seen. + DUPE = 4; + + // The user verification token was not present. + MISSING = 5; + + // A retriable error (such as network failure) occurred on the browser. + // Could easily be simulated by an attacker. + BROWSER_ERROR = 6; + } + + // Whether the provided user response token is valid. When valid = false, the + // reason could be specified in invalid_reason or it could also be due to + // a user failing to solve a challenge or a sitekey mismatch (i.e the sitekey + // used to generate the token was different than the one specified in the + // assessment). + bool valid = 1; + + // Reason associated with the response when valid = false. + InvalidReason invalid_reason = 2; + + // The timestamp corresponding to the generation of the token. + google.protobuf.Timestamp create_time = 3; + + // The hostname of the page on which the token was generated (Web keys only). + string hostname = 4; + + // The name of the Android package with which the token was generated (Android + // keys only). + string android_package_name = 8; + + // The ID of the iOS bundle with which the token was generated (iOS keys + // only). + string ios_bundle_id = 9; + + // Action name provided at token generation. + string action = 5; +} + +// Assessment for Fraud Prevention. +message FraudPreventionAssessment { + // Information about stolen instrument fraud, where the user is not the + // legitimate owner of the instrument being used for the purchase. + message StolenInstrumentVerdict { + // Probability (0-1) of this transaction being executed with a stolen + // instrument. + float risk = 1; + } + + // Information about card testing fraud, where an adversary is testing + // fraudulently obtained cards or brute forcing their details. + message CardTestingVerdict { + // Probability (0-1) of this transaction attempt being part of a card + // testing attack. + float risk = 1; + } + + // Probability (0-1) of this transaction being fraudulent. Summarizes the + // combined risk of attack vectors below. + float transaction_risk = 1; + + // Assessment of this transaction for risk of a stolen instrument. + StolenInstrumentVerdict stolen_instrument_verdict = 2; + + // Assessment of this transaction for risk of being part of a card testing + // attack. + CardTestingVerdict card_testing_verdict = 3; +} + +// Account defender risk assessment. +message AccountDefenderAssessment { + // Labels returned by account defender for this request. + enum AccountDefenderLabel { + // Default unspecified type. + ACCOUNT_DEFENDER_LABEL_UNSPECIFIED = 0; + + // The request matches a known good profile for the user. + PROFILE_MATCH = 1; + + // The request is potentially a suspicious login event and must be further + // verified either through multi-factor authentication or another system. + SUSPICIOUS_LOGIN_ACTIVITY = 2; + + // The request matched a profile that previously had suspicious account + // creation behavior. This can mean that this is a fake account. + SUSPICIOUS_ACCOUNT_CREATION = 3; + + // The account in the request has a high number of related accounts. It does + // not necessarily imply that the account is bad but can require further + // investigation. + RELATED_ACCOUNTS_NUMBER_HIGH = 4; + } + + // Labels for this request. + repeated AccountDefenderLabel labels = 1; +} + +// The create key request message. +message CreateKeyRequest { + // Required. The name of the project in which the key will be created, in the + // format "projects/{project}". + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Required. Information to create a reCAPTCHA Enterprise key. + Key key = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The list keys request message. +message ListKeysRequest { + // Required. The name of the project that contains the keys that will be + // listed, in the format "projects/{project}". + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Optional. The maximum number of keys to return. Default is 10. Max limit is + // 1000. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The next_page_token value returned from a previous. + // ListKeysRequest, if any. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response to request to list keys in a project. +message ListKeysResponse { + // Key details. + repeated Key keys = 1; + + // Token to retrieve the next page of results. It is set to empty if no keys + // remain in results. + string next_page_token = 2; +} + +// The retrieve legacy secret key request message. +message RetrieveLegacySecretKeyRequest { + // Required. The public key name linked to the requested secret key in the + // format "projects/{project}/keys/{key}". + string key = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recaptchaenterprise.googleapis.com/Key" + } + ]; +} + +// The get key request message. +message GetKeyRequest { + // Required. The name of the requested key, in the format + // "projects/{project}/keys/{key}". + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recaptchaenterprise.googleapis.com/Key" + } + ]; +} + +// The update key request message. +message UpdateKeyRequest { + // Required. The key to update. + Key key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The mask to control which fields of the key get updated. If the + // mask is not present, all fields will be updated. + google.protobuf.FieldMask update_mask = 2 + [(google.api.field_behavior) = OPTIONAL]; +} + +// The delete key request message. +message DeleteKeyRequest { + // Required. The name of the key to be deleted, in the format + // "projects/{project}/keys/{key}". + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recaptchaenterprise.googleapis.com/Key" + } + ]; +} + +// The migrate key request message. +message MigrateKeyRequest { + // Required. The name of the key to be migrated, in the format + // "projects/{project}/keys/{key}". + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recaptchaenterprise.googleapis.com/Key" + } + ]; + + // Optional. If true, skips the billing check. + // A reCAPTCHA Enterprise key or migrated key behaves differently than a + // reCAPTCHA (non-Enterprise version) key when you reach a quota limit (see + // https://cloud.google.com/recaptcha-enterprise/quotas#quota_limit). To avoid + // any disruption of your usage, we check that a billing account is present. + // If your usage of reCAPTCHA is under the free quota, you can safely skip the + // billing check and proceed with the migration. See + // https://cloud.google.com/recaptcha-enterprise/docs/billing-information. + bool skip_billing_check = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// The get metrics request message. +message GetMetricsRequest { + // Required. The name of the requested metrics, in the format + // "projects/{project}/keys/{key}/metrics". + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recaptchaenterprise.googleapis.com/Metrics" + } + ]; +} + +// Metrics for a single Key. +message Metrics { + option (google.api.resource) = { + type: "recaptchaenterprise.googleapis.com/Metrics" + pattern: "projects/{project}/keys/{key}/metrics" + }; + + // Output only. The name of the metrics, in the format + // "projects/{project}/keys/{key}/metrics". + string name = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Inclusive start time aligned to a day (UTC). + google.protobuf.Timestamp start_time = 1; + + // Metrics will be continuous and in order by dates, and in the granularity + // of day. All Key types should have score-based data. + repeated ScoreMetrics score_metrics = 2; + + // Metrics will be continuous and in order by dates, and in the granularity + // of day. Only challenge-based keys (CHECKBOX, INVISIBLE), will have + // challenge-based data. + repeated ChallengeMetrics challenge_metrics = 3; +} + +// Secret key is used only in legacy reCAPTCHA. It must be used in a 3rd party +// integration with legacy reCAPTCHA. +message RetrieveLegacySecretKeyResponse { + // The secret key (also known as shared secret) authorizes communication + // between your application backend and the reCAPTCHA Enterprise server to + // create an assessment. + // The secret key needs to be kept safe for security purposes. + string legacy_secret_key = 1; +} + +// A key used to identify and configure applications (web and/or mobile) that +// use reCAPTCHA Enterprise. +message Key { + option (google.api.resource) = { + type: "recaptchaenterprise.googleapis.com/Key" + pattern: "projects/{project}/keys/{key}" + }; + + // The resource name for the Key in the format + // "projects/{project}/keys/{key}". + string name = 1; + + // Human-readable display name of this key. Modifiable by user. + string display_name = 2; + + // Platform specific settings for this key. The key can only be used on a + // platform for which the settings are enabled. + oneof platform_settings { + // Settings for keys that can be used by websites. + WebKeySettings web_settings = 3; + + // Settings for keys that can be used by Android apps. + AndroidKeySettings android_settings = 4; + + // Settings for keys that can be used by iOS apps. + IOSKeySettings ios_settings = 5; + } + + // See + // Creating and managing labels. + map labels = 6; + + // Output only. The timestamp corresponding to the creation of this Key. + google.protobuf.Timestamp create_time = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Options for user acceptance testing. + TestingOptions testing_options = 9; + + // Settings for WAF + WafSettings waf_settings = 10; +} + +// Options for user acceptance testing. +message TestingOptions { + // Enum that represents the challenge option for challenge-based (CHECKBOX, + // INVISIBLE) testing keys. + enum TestingChallenge { + // Perform the normal risk analysis and return either nocaptcha or a + // challenge depending on risk and trust factors. + TESTING_CHALLENGE_UNSPECIFIED = 0; + + // Challenge requests for this key always return a nocaptcha, which + // does not require a solution. + NOCAPTCHA = 1; + + // Challenge requests for this key always return an unsolvable + // challenge. + UNSOLVABLE_CHALLENGE = 2; + } + + // All assessments for this Key will return this score. Must be between 0 + // (likely not legitimate) and 1 (likely legitimate) inclusive. + float testing_score = 1; + + // For challenge-based keys only (CHECKBOX, INVISIBLE), all challenge requests + // for this site will return nocaptcha if NOCAPTCHA, or an unsolvable + // challenge if CHALLENGE. + TestingChallenge testing_challenge = 2; +} + +// Settings specific to keys that can be used by websites. +message WebKeySettings { + // Enum that represents the integration types for web keys. + enum IntegrationType { + // Default type that indicates this enum hasn't been specified. This is not + // a valid IntegrationType, one of the other types must be specified + // instead. + INTEGRATION_TYPE_UNSPECIFIED = 0; + + // Only used to produce scores. It doesn't display the "I'm not a robot" + // checkbox and never shows captcha challenges. + SCORE = 1; + + // Displays the "I'm not a robot" checkbox and may show captcha challenges + // after it is checked. + CHECKBOX = 2; + + // Doesn't display the "I'm not a robot" checkbox, but may show captcha + // challenges after risk analysis. + INVISIBLE = 3; + } + + // Enum that represents the possible challenge frequency and difficulty + // configurations for a web key. + enum ChallengeSecurityPreference { + // Default type that indicates this enum hasn't been specified. + CHALLENGE_SECURITY_PREFERENCE_UNSPECIFIED = 0; + + // Key tends to show fewer and easier challenges. + USABILITY = 1; + + // Key tends to show balanced (in amount and difficulty) challenges. + BALANCE = 2; + + // Key tends to show more and harder challenges. + SECURITY = 3; + } + + // If set to true, it means allowed_domains will not be enforced. + bool allow_all_domains = 3; + + // Domains or subdomains of websites allowed to use the key. All subdomains + // of an allowed domain are automatically allowed. A valid domain requires a + // host and must not include any path, port, query or fragment. + // Examples: 'example.com' or 'subdomain.example.com' + repeated string allowed_domains = 1; + + // If set to true, the key can be used on AMP (Accelerated Mobile Pages) + // websites. This is supported only for the SCORE integration type. + bool allow_amp_traffic = 2; + + // Required. Describes how this key is integrated with the website. + IntegrationType integration_type = 4 [(google.api.field_behavior) = REQUIRED]; + + // Settings for the frequency and difficulty at which this key triggers + // captcha challenges. This should only be specified for IntegrationTypes + // CHECKBOX and INVISIBLE. + ChallengeSecurityPreference challenge_security_preference = 5; +} + +// Settings specific to keys that can be used by Android apps. +message AndroidKeySettings { + // If set to true, allowed_package_names are not enforced. + bool allow_all_package_names = 2; + + // Android package names of apps allowed to use the key. + // Example: 'com.companyname.appname' + repeated string allowed_package_names = 1; +} + +// Settings specific to keys that can be used by iOS apps. +message IOSKeySettings { + // If set to true, allowed_bundle_ids are not enforced. + bool allow_all_bundle_ids = 2; + + // iOS bundle ids of apps allowed to use the key. + // Example: 'com.companyname.productname.appname' + repeated string allowed_bundle_ids = 1; +} + +// Score distribution. +message ScoreDistribution { + // Map key is score value multiplied by 100. The scores are discrete values + // between [0, 1]. The maximum number of buckets is on order of a few dozen, + // but typically much lower (ie. 10). + map score_buckets = 1; +} + +// Metrics related to scoring. +message ScoreMetrics { + // Aggregated score metrics for all traffic. + ScoreDistribution overall_metrics = 1; + + // Action-based metrics. The map key is the action name which specified by the + // site owners at time of the "execute" client-side call. + map action_metrics = 2; +} + +// Metrics related to challenges. +message ChallengeMetrics { + // Count of reCAPTCHA checkboxes or badges rendered. This is mostly equivalent + // to a count of pageloads for pages that include reCAPTCHA. + int64 pageload_count = 1; + + // Count of nocaptchas (successful verification without a challenge) issued. + int64 nocaptcha_count = 2; + + // Count of submitted challenge solutions that were incorrect or otherwise + // deemed suspicious such that a subsequent challenge was triggered. + int64 failed_count = 3; + + // Count of nocaptchas (successful verification without a challenge) plus + // submitted challenge solutions that were correct and resulted in + // verification. + int64 passed_count = 4; +} + +// The request message to list memberships in a related account group. +message ListRelatedAccountGroupMembershipsRequest { + // Required. The resource name for the related account group in the format + // `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "recaptchaenterprise.googleapis.com/RelatedAccountGroupMembership" + } + ]; + + // Optional. The maximum number of accounts to return. The service might + // return fewer than this value. If unspecified, at most 50 accounts are + // returned. The maximum value is 1000; values above 1000 are coerced to 1000. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous + // `ListRelatedAccountGroupMemberships` call. + // + // When paginating, all other parameters provided to + // `ListRelatedAccountGroupMemberships` must match the call that provided the + // page token. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response to a `ListRelatedAccountGroupMemberships` call. +message ListRelatedAccountGroupMembershipsResponse { + // The memberships listed by the query. + repeated RelatedAccountGroupMembership related_account_group_memberships = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} + +// The request message to list related account groups. +message ListRelatedAccountGroupsRequest { + // Required. The name of the project to list related account groups from, in + // the format "projects/{project}". + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "recaptchaenterprise.googleapis.com/RelatedAccountGroup" + } + ]; + + // Optional. The maximum number of groups to return. The service might return + // fewer than this value. If unspecified, at most 50 groups are returned. The + // maximum value is 1000; values above 1000 are coerced to 1000. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListRelatedAccountGroups` + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // `ListRelatedAccountGroups` must match the call that provided the page + // token. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response to a `ListRelatedAccountGroups` call. +message ListRelatedAccountGroupsResponse { + // The groups of related accounts listed by the query. + repeated RelatedAccountGroup related_account_groups = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} + +// The request message to search related account group memberships. +message SearchRelatedAccountGroupMembershipsRequest { + // Required. The name of the project to search related account group + // memberships from. Specify the project name in the following format: + // "projects/{project}". + string project = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "recaptchaenterprise.googleapis.com/RelatedAccountGroupMembership" + } + ]; + + // Optional. The unique stable hashed user identifier we should search + // connections to. The identifier should correspond to a `hashed_account_id` + // provided in a previous `CreateAssessment` or `AnnotateAssessment` call. + bytes hashed_account_id = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maximum number of groups to return. The service might return + // fewer than this value. If unspecified, at most 50 groups are returned. The + // maximum value is 1000; values above 1000 are coerced to 1000. + int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous + // `SearchRelatedAccountGroupMemberships` call. Provide this to retrieve the + // subsequent page. + // + // When paginating, all other parameters provided to + // `SearchRelatedAccountGroupMemberships` must match the call that provided + // the page token. + string page_token = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response to a `SearchRelatedAccountGroupMemberships` call. +message SearchRelatedAccountGroupMembershipsResponse { + // The queried memberships. + repeated RelatedAccountGroupMembership related_account_group_memberships = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} + +// A membership in a group of related accounts. +message RelatedAccountGroupMembership { + option (google.api.resource) = { + type: "recaptchaenterprise.googleapis.com/RelatedAccountGroupMembership" + pattern: "projects/{project}/relatedaccountgroups/{relatedaccountgroup}/memberships/{membership}" + }; + + // Required. The resource name for this membership in the format + // `projects/{project}/relatedaccountgroups/{relatedaccountgroup}/memberships/{membership}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recaptchaenterprise.googleapis.com/RelatedAccountGroupMembership" + } + ]; + + // The unique stable hashed user identifier of the member. The identifier + // corresponds to a `hashed_account_id` provided in a previous + // `CreateAssessment` or `AnnotateAssessment` call. + bytes hashed_account_id = 2; +} + +// A group of related accounts. +message RelatedAccountGroup { + option (google.api.resource) = { + type: "recaptchaenterprise.googleapis.com/RelatedAccountGroup" + pattern: "projects/{project}/relatedaccountgroups/{relatedaccountgroup}" + }; + + // Required. The resource name for the related account group in the format + // `projects/{project}/relatedaccountgroups/{related_account_group}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recaptchaenterprise.googleapis.com/RelatedAccountGroup" + } + ]; +} + +// Settings specific to keys that can be used for WAF (Web Application +// Firewall). +message WafSettings { + // Supported WAF features. For more information, see + // https://cloud.google.com/recaptcha-enterprise/docs/usecase#comparison_of_features. + enum WafFeature { + // Undefined feature. + WAF_FEATURE_UNSPECIFIED = 0; + + // Redirects suspicious traffic to reCAPTCHA. + CHALLENGE_PAGE = 1; + + // Use reCAPTCHA session-tokens to protect the whole user session on the + // site's domain. + SESSION_TOKEN = 2; + + // Use reCAPTCHA action-tokens to protect user actions. + ACTION_TOKEN = 3; + } + + // Web Application Firewalls supported by reCAPTCHA Enterprise. + enum WafService { + // Undefined WAF + WAF_SERVICE_UNSPECIFIED = 0; + + // Cloud Armor + CA = 1; + } + + // Required. The WAF service that uses this key. + WafService waf_service = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The WAF feature for which this key is enabled. + WafFeature waf_feature = 2 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.annotate_assessment.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.annotate_assessment.js new file mode 100644 index 00000000000..cee2e28bab5 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.annotate_assessment.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(name) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_AnnotateAssessment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 Assessment, in the format + * "projects/{project}/assessments/{assessment}". + */ + // const name = 'abc123' + /** + * Optional. The annotation that will be assigned to the Event. This field can + * be left empty to provide reasons that apply to an event without concluding + * whether the event is legitimate or fraudulent. + */ + // const annotation = {} + /** + * Optional. Optional reasons for the annotation that will be assigned to the + * Event. + */ + // const reasons = [1,2,3,4] + /** + * Optional. Unique stable hashed user identifier to apply to the assessment. + * This is an alternative to setting the hashed_account_id in + * CreateAssessment, for example when the account identifier is not yet known + * in the initial request. It is recommended that the identifier is hashed + * using hmac-sha256 with stable secret. + */ + // const hashedAccountId = Buffer.from('string') + /** + * Optional. If the assessment is part of a payment transaction, provide + * details on payment lifecycle events that occur in the transaction. + */ + // const transactionEvent = {} + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callAnnotateAssessment() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await recaptchaenterpriseClient.annotateAssessment(request); + console.log(response); + } + + callAnnotateAssessment(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_AnnotateAssessment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.create_assessment.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.create_assessment.js new file mode 100644 index 00000000000..29aa4bca8ba --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.create_assessment.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(parent, assessment) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateAssessment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 project in which the assessment will be created, + * in the format "projects/{project}". + */ + // const parent = 'abc123' + /** + * Required. The assessment details. + */ + // const assessment = {} + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callCreateAssessment() { + // Construct request + const request = { + parent, + assessment, + }; + + // Run request + const response = await recaptchaenterpriseClient.createAssessment(request); + console.log(response); + } + + callCreateAssessment(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateAssessment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.create_key.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.create_key.js new file mode 100644 index 00000000000..7fe47aeda81 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.create_key.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(parent, key) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 project in which the key will be created, in the + * format "projects/{project}". + */ + // const parent = 'abc123' + /** + * Required. Information to create a reCAPTCHA Enterprise key. + */ + // const key = {} + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callCreateKey() { + // Construct request + const request = { + parent, + key, + }; + + // Run request + const response = await recaptchaenterpriseClient.createKey(request); + console.log(response); + } + + callCreateKey(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.delete_key.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.delete_key.js new file mode 100644 index 00000000000..83e23ec68f4 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.delete_key.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 recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 key to be deleted, in the format + * "projects/{project}/keys/{key}". + */ + // const name = 'abc123' + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callDeleteKey() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await recaptchaenterpriseClient.deleteKey(request); + console.log(response); + } + + callDeleteKey(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.get_key.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.get_key.js new file mode 100644 index 00000000000..6c56f81e9b6 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.get_key.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 recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 requested key, in the format + * "projects/{project}/keys/{key}". + */ + // const name = 'abc123' + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callGetKey() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await recaptchaenterpriseClient.getKey(request); + console.log(response); + } + + callGetKey(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.get_metrics.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.get_metrics.js new file mode 100644 index 00000000000..4f39fdf1b68 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.get_metrics.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 recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetMetrics_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 requested metrics, in the format + * "projects/{project}/keys/{key}/metrics". + */ + // const name = 'abc123' + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callGetMetrics() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await recaptchaenterpriseClient.getMetrics(request); + console.log(response); + } + + callGetMetrics(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetMetrics_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_keys.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_keys.js new file mode 100644 index 00000000000..0e1be786060 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_keys.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) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListKeys_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 project that contains the keys that will be + * listed, in the format "projects/{project}". + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of keys to return. Default is 10. Max limit is + * 1000. + */ + // const pageSize = 1234 + /** + * Optional. The next_page_token value returned from a previous. + * ListKeysRequest, if any. + */ + // const pageToken = 'abc123' + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callListKeys() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await recaptchaenterpriseClient.listKeysAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListKeys(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListKeys_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_group_memberships.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_group_memberships.js new file mode 100644 index 00000000000..a5465546337 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_group_memberships.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(parent) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroupMemberships_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name for the related account group in the format + * `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`. + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of accounts to return. The service might + * return fewer than this value. If unspecified, at most 50 accounts are + * returned. The maximum value is 1000; values above 1000 are coerced to 1000. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous + * `ListRelatedAccountGroupMemberships` call. + * When paginating, all other parameters provided to + * `ListRelatedAccountGroupMemberships` must match the call that provided the + * page token. + */ + // const pageToken = 'abc123' + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callListRelatedAccountGroupMemberships() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await recaptchaenterpriseClient.listRelatedAccountGroupMembershipsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListRelatedAccountGroupMemberships(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroupMemberships_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_groups.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_groups.js new file mode 100644 index 00000000000..933d0de8409 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_groups.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(parent) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroups_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 project to list related account groups from, in + * the format "projects/{project}". + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of groups to return. The service might return + * fewer than this value. If unspecified, at most 50 groups are returned. The + * maximum value is 1000; values above 1000 are coerced to 1000. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListRelatedAccountGroups` + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * `ListRelatedAccountGroups` must match the call that provided the page + * token. + */ + // const pageToken = 'abc123' + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callListRelatedAccountGroups() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await recaptchaenterpriseClient.listRelatedAccountGroupsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListRelatedAccountGroups(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroups_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.migrate_key.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.migrate_key.js new file mode 100644 index 00000000000..1939aa98f80 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.migrate_key.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(name) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_MigrateKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 key to be migrated, in the format + * "projects/{project}/keys/{key}". + */ + // const name = 'abc123' + /** + * Optional. If true, skips the billing check. + * A reCAPTCHA Enterprise key or migrated key behaves differently than a + * reCAPTCHA (non-Enterprise version) key when you reach a quota limit (see + * https://cloud.google.com/recaptcha-enterprise/quotas#quota_limit). To avoid + * any disruption of your usage, we check that a billing account is present. + * If your usage of reCAPTCHA is under the free quota, you can safely skip the + * billing check and proceed with the migration. See + * https://cloud.google.com/recaptcha-enterprise/docs/billing-information. + */ + // const skipBillingCheck = true + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callMigrateKey() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await recaptchaenterpriseClient.migrateKey(request); + console.log(response); + } + + callMigrateKey(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_MigrateKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.retrieve_legacy_secret_key.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.retrieve_legacy_secret_key.js new file mode 100644 index 00000000000..38b39612b9c --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.retrieve_legacy_secret_key.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(key) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_RetrieveLegacySecretKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The public key name linked to the requested secret key in the + * format "projects/{project}/keys/{key}". + */ + // const key = 'abc123' + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callRetrieveLegacySecretKey() { + // Construct request + const request = { + key, + }; + + // Run request + const response = await recaptchaenterpriseClient.retrieveLegacySecretKey(request); + console.log(response); + } + + callRetrieveLegacySecretKey(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_RetrieveLegacySecretKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.search_related_account_group_memberships.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.search_related_account_group_memberships.js new file mode 100644 index 00000000000..bf66fa88c2f --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.search_related_account_group_memberships.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(project) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_SearchRelatedAccountGroupMemberships_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 project to search related account group + * memberships from. Specify the project name in the following format: + * "projects/{project}". + */ + // const project = 'my-project' + /** + * Optional. The unique stable hashed user identifier we should search + * connections to. The identifier should correspond to a `hashed_account_id` + * provided in a previous `CreateAssessment` or `AnnotateAssessment` call. + */ + // const hashedAccountId = Buffer.from('string') + /** + * Optional. The maximum number of groups to return. The service might return + * fewer than this value. If unspecified, at most 50 groups are returned. The + * maximum value is 1000; values above 1000 are coerced to 1000. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous + * `SearchRelatedAccountGroupMemberships` call. Provide this to retrieve the + * subsequent page. + * When paginating, all other parameters provided to + * `SearchRelatedAccountGroupMemberships` must match the call that provided + * the page token. + */ + // const pageToken = 'abc123' + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callSearchRelatedAccountGroupMemberships() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await recaptchaenterpriseClient.searchRelatedAccountGroupMembershipsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearchRelatedAccountGroupMemberships(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_SearchRelatedAccountGroupMemberships_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.update_key.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.update_key.js new file mode 100644 index 00000000000..7bc0ae4bc29 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.update_key.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(key) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_UpdateKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The key to update. + */ + // const key = {} + /** + * Optional. The mask to control which fields of the key get updated. If the + * mask is not present, all fields will be updated. + */ + // const updateMask = {} + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callUpdateKey() { + // Construct request + const request = { + key, + }; + + // Run request + const response = await recaptchaenterpriseClient.updateKey(request); + console.log(response); + } + + callUpdateKey(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_UpdateKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/snippet_metadata_google.cloud.recaptchaenterprise.v1.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/snippet_metadata_google.cloud.recaptchaenterprise.v1.json new file mode 100644 index 00000000000..7ec1519e054 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/snippet_metadata_google.cloud.recaptchaenterprise.v1.json @@ -0,0 +1,603 @@ +{ + "clientLibrary": { + "name": "nodejs-recaptchaenterprise", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.recaptchaenterprise.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateAssessment_async", + "title": "RecaptchaEnterpriseService createAssessment Sample", + "origin": "API_DEFINITION", + "description": " Creates an Assessment of the likelihood an event is legitimate.", + "canonical": true, + "file": "recaptcha_enterprise_service.create_assessment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateAssessment", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.CreateAssessment", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "assessment", + "type": ".google.cloud.recaptchaenterprise.v1.Assessment" + } + ], + "resultType": ".google.cloud.recaptchaenterprise.v1.Assessment", + "client": { + "shortName": "RecaptchaEnterpriseServiceClient", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" + }, + "method": { + "shortName": "CreateAssessment", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.CreateAssessment", + "service": { + "shortName": "RecaptchaEnterpriseService", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" + } + } + } + }, + { + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_AnnotateAssessment_async", + "title": "RecaptchaEnterpriseService annotateAssessment Sample", + "origin": "API_DEFINITION", + "description": " Annotates a previously created Assessment to provide additional information on whether the event turned out to be authentic or fraudulent.", + "canonical": true, + "file": "recaptcha_enterprise_service.annotate_assessment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 78, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AnnotateAssessment", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.AnnotateAssessment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "annotation", + "type": ".google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest.Annotation" + }, + { + "name": "reasons", + "type": "TYPE_ENUM[]" + }, + { + "name": "hashed_account_id", + "type": "TYPE_BYTES" + }, + { + "name": "transaction_event", + "type": ".google.cloud.recaptchaenterprise.v1.TransactionEvent" + } + ], + "resultType": ".google.cloud.recaptchaenterprise.v1.AnnotateAssessmentResponse", + "client": { + "shortName": "RecaptchaEnterpriseServiceClient", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" + }, + "method": { + "shortName": "AnnotateAssessment", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.AnnotateAssessment", + "service": { + "shortName": "RecaptchaEnterpriseService", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" + } + } + } + }, + { + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateKey_async", + "title": "RecaptchaEnterpriseService createKey Sample", + "origin": "API_DEFINITION", + "description": " Creates a new reCAPTCHA Enterprise key.", + "canonical": true, + "file": "recaptcha_enterprise_service.create_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateKey", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.CreateKey", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "key", + "type": ".google.cloud.recaptchaenterprise.v1.Key" + } + ], + "resultType": ".google.cloud.recaptchaenterprise.v1.Key", + "client": { + "shortName": "RecaptchaEnterpriseServiceClient", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" + }, + "method": { + "shortName": "CreateKey", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.CreateKey", + "service": { + "shortName": "RecaptchaEnterpriseService", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" + } + } + } + }, + { + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListKeys_async", + "title": "RecaptchaEnterpriseService listKeys Sample", + "origin": "API_DEFINITION", + "description": " Returns the list of all keys that belong to a project.", + "canonical": true, + "file": "recaptcha_enterprise_service.list_keys.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListKeys", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.ListKeys", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recaptchaenterprise.v1.ListKeysResponse", + "client": { + "shortName": "RecaptchaEnterpriseServiceClient", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" + }, + "method": { + "shortName": "ListKeys", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.ListKeys", + "service": { + "shortName": "RecaptchaEnterpriseService", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" + } + } + } + }, + { + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_RetrieveLegacySecretKey_async", + "title": "RecaptchaEnterpriseService retrieveLegacySecretKey Sample", + "origin": "API_DEFINITION", + "description": " Returns the secret key related to the specified public key. You must use the legacy secret key only in a 3rd party integration with legacy reCAPTCHA.", + "canonical": true, + "file": "recaptcha_enterprise_service.retrieve_legacy_secret_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RetrieveLegacySecretKey", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.RetrieveLegacySecretKey", + "async": true, + "parameters": [ + { + "name": "key", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyResponse", + "client": { + "shortName": "RecaptchaEnterpriseServiceClient", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" + }, + "method": { + "shortName": "RetrieveLegacySecretKey", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.RetrieveLegacySecretKey", + "service": { + "shortName": "RecaptchaEnterpriseService", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" + } + } + } + }, + { + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetKey_async", + "title": "RecaptchaEnterpriseService getKey Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified key.", + "canonical": true, + "file": "recaptcha_enterprise_service.get_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetKey", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.GetKey", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recaptchaenterprise.v1.Key", + "client": { + "shortName": "RecaptchaEnterpriseServiceClient", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" + }, + "method": { + "shortName": "GetKey", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.GetKey", + "service": { + "shortName": "RecaptchaEnterpriseService", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" + } + } + } + }, + { + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_UpdateKey_async", + "title": "RecaptchaEnterpriseService updateKey Sample", + "origin": "API_DEFINITION", + "description": " Updates the specified key.", + "canonical": true, + "file": "recaptcha_enterprise_service.update_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateKey", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.UpdateKey", + "async": true, + "parameters": [ + { + "name": "key", + "type": ".google.cloud.recaptchaenterprise.v1.Key" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.recaptchaenterprise.v1.Key", + "client": { + "shortName": "RecaptchaEnterpriseServiceClient", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" + }, + "method": { + "shortName": "UpdateKey", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.UpdateKey", + "service": { + "shortName": "RecaptchaEnterpriseService", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" + } + } + } + }, + { + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteKey_async", + "title": "RecaptchaEnterpriseService deleteKey Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified key.", + "canonical": true, + "file": "recaptcha_enterprise_service.delete_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteKey", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.DeleteKey", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "RecaptchaEnterpriseServiceClient", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" + }, + "method": { + "shortName": "DeleteKey", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.DeleteKey", + "service": { + "shortName": "RecaptchaEnterpriseService", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" + } + } + } + }, + { + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_MigrateKey_async", + "title": "RecaptchaEnterpriseService migrateKey Sample", + "origin": "API_DEFINITION", + "description": " Migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise. Once a key is migrated, it can be used from either product. SiteVerify requests are billed as CreateAssessment calls. You must be authenticated as one of the current owners of the reCAPTCHA Site Key, and your user must have the reCAPTCHA Enterprise Admin IAM role in the destination project.", + "canonical": true, + "file": "recaptcha_enterprise_service.migrate_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "MigrateKey", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.MigrateKey", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "skip_billing_check", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.recaptchaenterprise.v1.Key", + "client": { + "shortName": "RecaptchaEnterpriseServiceClient", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" + }, + "method": { + "shortName": "MigrateKey", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.MigrateKey", + "service": { + "shortName": "RecaptchaEnterpriseService", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" + } + } + } + }, + { + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetMetrics_async", + "title": "RecaptchaEnterpriseService getMetrics Sample", + "origin": "API_DEFINITION", + "description": " Get some aggregated metrics for a Key. This data can be used to build dashboards.", + "canonical": true, + "file": "recaptcha_enterprise_service.get_metrics.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetMetrics", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.GetMetrics", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recaptchaenterprise.v1.Metrics", + "client": { + "shortName": "RecaptchaEnterpriseServiceClient", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" + }, + "method": { + "shortName": "GetMetrics", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.GetMetrics", + "service": { + "shortName": "RecaptchaEnterpriseService", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" + } + } + } + }, + { + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroups_async", + "title": "RecaptchaEnterpriseService listRelatedAccountGroups Sample", + "origin": "API_DEFINITION", + "description": " List groups of related accounts.", + "canonical": true, + "file": "recaptcha_enterprise_service.list_related_account_groups.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListRelatedAccountGroups", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.ListRelatedAccountGroups", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsResponse", + "client": { + "shortName": "RecaptchaEnterpriseServiceClient", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" + }, + "method": { + "shortName": "ListRelatedAccountGroups", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.ListRelatedAccountGroups", + "service": { + "shortName": "RecaptchaEnterpriseService", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" + } + } + } + }, + { + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroupMemberships_async", + "title": "RecaptchaEnterpriseService listRelatedAccountGroupMemberships Sample", + "origin": "API_DEFINITION", + "description": " Get memberships in a group of related accounts.", + "canonical": true, + "file": "recaptcha_enterprise_service.list_related_account_group_memberships.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListRelatedAccountGroupMemberships", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.ListRelatedAccountGroupMemberships", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsResponse", + "client": { + "shortName": "RecaptchaEnterpriseServiceClient", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" + }, + "method": { + "shortName": "ListRelatedAccountGroupMemberships", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.ListRelatedAccountGroupMemberships", + "service": { + "shortName": "RecaptchaEnterpriseService", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" + } + } + } + }, + { + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_SearchRelatedAccountGroupMemberships_async", + "title": "RecaptchaEnterpriseService searchRelatedAccountGroupMemberships Sample", + "origin": "API_DEFINITION", + "description": " Search group memberships related to a given account.", + "canonical": true, + "file": "recaptcha_enterprise_service.search_related_account_group_memberships.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 78, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SearchRelatedAccountGroupMemberships", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.SearchRelatedAccountGroupMemberships", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "hashed_account_id", + "type": "TYPE_BYTES" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsResponse", + "client": { + "shortName": "RecaptchaEnterpriseServiceClient", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" + }, + "method": { + "shortName": "SearchRelatedAccountGroupMemberships", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.SearchRelatedAccountGroupMemberships", + "service": { + "shortName": "RecaptchaEnterpriseService", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/index.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/index.ts new file mode 100644 index 00000000000..d639c71ddee --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const RecaptchaEnterpriseServiceClient = v1.RecaptchaEnterpriseServiceClient; +type RecaptchaEnterpriseServiceClient = v1.RecaptchaEnterpriseServiceClient; +export {v1, RecaptchaEnterpriseServiceClient}; +export default {v1, RecaptchaEnterpriseServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..023c63fe31e --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/gapic_metadata.json @@ -0,0 +1,169 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.recaptchaenterprise.v1", + "libraryPackage": "@google-cloud/recaptcha-enterprise", + "services": { + "RecaptchaEnterpriseService": { + "clients": { + "grpc": { + "libraryClient": "RecaptchaEnterpriseServiceClient", + "rpcs": { + "CreateAssessment": { + "methods": [ + "createAssessment" + ] + }, + "AnnotateAssessment": { + "methods": [ + "annotateAssessment" + ] + }, + "CreateKey": { + "methods": [ + "createKey" + ] + }, + "RetrieveLegacySecretKey": { + "methods": [ + "retrieveLegacySecretKey" + ] + }, + "GetKey": { + "methods": [ + "getKey" + ] + }, + "UpdateKey": { + "methods": [ + "updateKey" + ] + }, + "DeleteKey": { + "methods": [ + "deleteKey" + ] + }, + "MigrateKey": { + "methods": [ + "migrateKey" + ] + }, + "GetMetrics": { + "methods": [ + "getMetrics" + ] + }, + "ListKeys": { + "methods": [ + "listKeys", + "listKeysStream", + "listKeysAsync" + ] + }, + "ListRelatedAccountGroups": { + "methods": [ + "listRelatedAccountGroups", + "listRelatedAccountGroupsStream", + "listRelatedAccountGroupsAsync" + ] + }, + "ListRelatedAccountGroupMemberships": { + "methods": [ + "listRelatedAccountGroupMemberships", + "listRelatedAccountGroupMembershipsStream", + "listRelatedAccountGroupMembershipsAsync" + ] + }, + "SearchRelatedAccountGroupMemberships": { + "methods": [ + "searchRelatedAccountGroupMemberships", + "searchRelatedAccountGroupMembershipsStream", + "searchRelatedAccountGroupMembershipsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RecaptchaEnterpriseServiceClient", + "rpcs": { + "CreateAssessment": { + "methods": [ + "createAssessment" + ] + }, + "AnnotateAssessment": { + "methods": [ + "annotateAssessment" + ] + }, + "CreateKey": { + "methods": [ + "createKey" + ] + }, + "RetrieveLegacySecretKey": { + "methods": [ + "retrieveLegacySecretKey" + ] + }, + "GetKey": { + "methods": [ + "getKey" + ] + }, + "UpdateKey": { + "methods": [ + "updateKey" + ] + }, + "DeleteKey": { + "methods": [ + "deleteKey" + ] + }, + "MigrateKey": { + "methods": [ + "migrateKey" + ] + }, + "GetMetrics": { + "methods": [ + "getMetrics" + ] + }, + "ListKeys": { + "methods": [ + "listKeys", + "listKeysStream", + "listKeysAsync" + ] + }, + "ListRelatedAccountGroups": { + "methods": [ + "listRelatedAccountGroups", + "listRelatedAccountGroupsStream", + "listRelatedAccountGroupsAsync" + ] + }, + "ListRelatedAccountGroupMemberships": { + "methods": [ + "listRelatedAccountGroupMemberships", + "listRelatedAccountGroupMembershipsStream", + "listRelatedAccountGroupMembershipsAsync" + ] + }, + "SearchRelatedAccountGroupMemberships": { + "methods": [ + "searchRelatedAccountGroupMemberships", + "searchRelatedAccountGroupMembershipsStream", + "searchRelatedAccountGroupMembershipsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/index.ts new file mode 100644 index 00000000000..c976fda6970 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {RecaptchaEnterpriseServiceClient} from './recaptcha_enterprise_service_client'; diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_client.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_client.ts new file mode 100644 index 00000000000..79b512852dd --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_client.ts @@ -0,0 +1,2023 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/recaptcha_enterprise_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './recaptcha_enterprise_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service to determine the likelihood an event is legitimate. + * @class + * @memberof v1 + */ +export class RecaptchaEnterpriseServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + recaptchaEnterpriseServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RecaptchaEnterpriseServiceClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 RecaptchaEnterpriseServiceClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RecaptchaEnterpriseServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + assessmentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/assessments/{assessment}' + ), + keyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/keys/{key}' + ), + metricsPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/keys/{key}/metrics' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + relatedAccountGroupPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/relatedaccountgroups/{relatedaccountgroup}' + ), + relatedAccountGroupMembershipPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/relatedaccountgroups/{relatedaccountgroup}/memberships/{membership}' + ), + }; + + // 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 = { + listKeys: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'keys'), + listRelatedAccountGroups: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'relatedAccountGroups'), + listRelatedAccountGroupMemberships: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'relatedAccountGroupMemberships'), + searchRelatedAccountGroupMemberships: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'relatedAccountGroupMemberships') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService', 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.recaptchaEnterpriseServiceStub) { + return this.recaptchaEnterpriseServiceStub; + } + + // Put together the "service stub" for + // google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService. + this.recaptchaEnterpriseServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService, + 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 recaptchaEnterpriseServiceStubMethods = + ['createAssessment', 'annotateAssessment', 'createKey', 'listKeys', 'retrieveLegacySecretKey', 'getKey', 'updateKey', 'deleteKey', 'migrateKey', 'getMetrics', 'listRelatedAccountGroups', 'listRelatedAccountGroupMemberships', 'searchRelatedAccountGroupMemberships']; + for (const methodName of recaptchaEnterpriseServiceStubMethods) { + const callPromise = this.recaptchaEnterpriseServiceStub.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.recaptchaEnterpriseServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'recaptchaenterprise.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 'recaptchaenterprise.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 an Assessment of the likelihood an event is legitimate. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project in which the assessment will be created, + * in the format "projects/{project}". + * @param {google.cloud.recaptchaenterprise.v1.Assessment} request.assessment + * Required. The assessment 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 protos.google.cloud.recaptchaenterprise.v1.Assessment|Assessment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recaptcha_enterprise_service.create_assessment.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateAssessment_async + */ + createAssessment( + request?: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|undefined, {}|undefined + ]>; + createAssessment( + request: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|null|undefined, + {}|null|undefined>): void; + createAssessment( + request: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|null|undefined, + {}|null|undefined>): void; + createAssessment( + request?: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createAssessment(request, options, callback); + } +/** + * Annotates a previously created Assessment to provide additional information + * on whether the event turned out to be authentic or fraudulent. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Assessment, in the format + * "projects/{project}/assessments/{assessment}". + * @param {google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest.Annotation} [request.annotation] + * Optional. The annotation that will be assigned to the Event. This field can + * be left empty to provide reasons that apply to an event without concluding + * whether the event is legitimate or fraudulent. + * @param {number[]} [request.reasons] + * Optional. Optional reasons for the annotation that will be assigned to the + * Event. + * @param {Buffer} [request.hashedAccountId] + * Optional. Unique stable hashed user identifier to apply to the assessment. + * This is an alternative to setting the hashed_account_id in + * CreateAssessment, for example when the account identifier is not yet known + * in the initial request. It is recommended that the identifier is hashed + * using hmac-sha256 with stable secret. + * @param {google.cloud.recaptchaenterprise.v1.TransactionEvent} [request.transactionEvent] + * Optional. If the assessment is part of a payment transaction, provide + * details on payment lifecycle events that occur in the transaction. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentResponse|AnnotateAssessmentResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recaptcha_enterprise_service.annotate_assessment.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_AnnotateAssessment_async + */ + annotateAssessment( + request?: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|undefined, {}|undefined + ]>; + annotateAssessment( + request: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|null|undefined, + {}|null|undefined>): void; + annotateAssessment( + request: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|null|undefined, + {}|null|undefined>): void; + annotateAssessment( + request?: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.annotateAssessment(request, options, callback); + } +/** + * Creates a new reCAPTCHA Enterprise key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project in which the key will be created, in the + * format "projects/{project}". + * @param {google.cloud.recaptchaenterprise.v1.Key} request.key + * Required. Information to create a reCAPTCHA Enterprise key. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recaptchaenterprise.v1.Key|Key}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recaptcha_enterprise_service.create_key.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateKey_async + */ + createKey( + request?: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|undefined, {}|undefined + ]>; + createKey( + request: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|null|undefined, + {}|null|undefined>): void; + createKey( + request: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|null|undefined, + {}|null|undefined>): void; + createKey( + request?: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createKey(request, options, callback); + } +/** + * Returns the secret key related to the specified public key. + * You must use the legacy secret key only in a 3rd party integration with + * legacy reCAPTCHA. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.key + * Required. The public key name linked to the requested secret key in the + * format "projects/{project}/keys/{key}". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyResponse|RetrieveLegacySecretKeyResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recaptcha_enterprise_service.retrieve_legacy_secret_key.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_RetrieveLegacySecretKey_async + */ + retrieveLegacySecretKey( + request?: protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyResponse, + protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyRequest|undefined, {}|undefined + ]>; + retrieveLegacySecretKey( + request: protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyResponse, + protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyRequest|null|undefined, + {}|null|undefined>): void; + retrieveLegacySecretKey( + request: protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyResponse, + protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyRequest|null|undefined, + {}|null|undefined>): void; + retrieveLegacySecretKey( + request?: protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyResponse, + protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyResponse, + protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyResponse, + protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'key': request.key ?? '', + }); + this.initialize(); + return this.innerApiCalls.retrieveLegacySecretKey(request, options, callback); + } +/** + * Returns the specified key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the requested key, in the format + * "projects/{project}/keys/{key}". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recaptchaenterprise.v1.Key|Key}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recaptcha_enterprise_service.get_key.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetKey_async + */ + getKey( + request?: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|undefined, {}|undefined + ]>; + getKey( + request: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|null|undefined, + {}|null|undefined>): void; + getKey( + request: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|null|undefined, + {}|null|undefined>): void; + getKey( + request?: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getKey(request, options, callback); + } +/** + * Updates the specified key. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.recaptchaenterprise.v1.Key} request.key + * Required. The key to update. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. The mask to control which fields of the key get updated. If the + * mask is not present, all fields will be 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 protos.google.cloud.recaptchaenterprise.v1.Key|Key}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recaptcha_enterprise_service.update_key.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_UpdateKey_async + */ + updateKey( + request?: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|undefined, {}|undefined + ]>; + updateKey( + request: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|null|undefined, + {}|null|undefined>): void; + updateKey( + request: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|null|undefined, + {}|null|undefined>): void; + updateKey( + request?: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'key.name': request.key!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateKey(request, options, callback); + } +/** + * Deletes the specified key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the key to be deleted, in the format + * "projects/{project}/keys/{key}". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recaptcha_enterprise_service.delete_key.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteKey_async + */ + deleteKey( + request?: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|undefined, {}|undefined + ]>; + deleteKey( + request: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|null|undefined, + {}|null|undefined>): void; + deleteKey( + request: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|null|undefined, + {}|null|undefined>): void; + deleteKey( + request?: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteKey(request, options, callback); + } +/** + * Migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise. + * Once a key is migrated, it can be used from either product. SiteVerify + * requests are billed as CreateAssessment calls. You must be + * authenticated as one of the current owners of the reCAPTCHA Site Key, and + * your user must have the reCAPTCHA Enterprise Admin IAM role in the + * destination project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the key to be migrated, in the format + * "projects/{project}/keys/{key}". + * @param {boolean} [request.skipBillingCheck] + * Optional. If true, skips the billing check. + * A reCAPTCHA Enterprise key or migrated key behaves differently than a + * reCAPTCHA (non-Enterprise version) key when you reach a quota limit (see + * https://cloud.google.com/recaptcha-enterprise/quotas#quota_limit). To avoid + * any disruption of your usage, we check that a billing account is present. + * If your usage of reCAPTCHA is under the free quota, you can safely skip the + * billing check and proceed with the migration. See + * https://cloud.google.com/recaptcha-enterprise/docs/billing-information. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recaptchaenterprise.v1.Key|Key}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recaptcha_enterprise_service.migrate_key.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_MigrateKey_async + */ + migrateKey( + request?: protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|undefined, {}|undefined + ]>; + migrateKey( + request: protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|null|undefined, + {}|null|undefined>): void; + migrateKey( + request: protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|null|undefined, + {}|null|undefined>): void; + migrateKey( + request?: protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.migrateKey(request, options, callback); + } +/** + * Get some aggregated metrics for a Key. This data can be used to build + * dashboards. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the requested metrics, in the format + * "projects/{project}/keys/{key}/metrics". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recaptchaenterprise.v1.Metrics|Metrics}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recaptcha_enterprise_service.get_metrics.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetMetrics_async + */ + getMetrics( + request?: protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IMetrics, + protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|undefined, {}|undefined + ]>; + getMetrics( + request: protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IMetrics, + protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|null|undefined, + {}|null|undefined>): void; + getMetrics( + request: protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IMetrics, + protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|null|undefined, + {}|null|undefined>): void; + getMetrics( + request?: protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1.IMetrics, + protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1.IMetrics, + protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IMetrics, + protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getMetrics(request, options, callback); + } + + /** + * Returns the list of all keys that belong to a project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project that contains the keys that will be + * listed, in the format "projects/{project}". + * @param {number} [request.pageSize] + * Optional. The maximum number of keys to return. Default is 10. Max limit is + * 1000. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous. + * ListKeysRequest, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.recaptchaenterprise.v1.Key|Key}. + * 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 `listKeysAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listKeys( + request?: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IKey[], + protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest|null, + protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse + ]>; + listKeys( + request: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IKey>): void; + listKeys( + request: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IKey>): void; + listKeys( + request?: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IKey>, + callback?: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IKey>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IKey[], + protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest|null, + protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listKeys(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 name of the project that contains the keys that will be + * listed, in the format "projects/{project}". + * @param {number} [request.pageSize] + * Optional. The maximum number of keys to return. Default is 10. Max limit is + * 1000. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous. + * ListKeysRequest, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.recaptchaenterprise.v1.Key|Key} 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 `listKeysAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listKeysStream( + request?: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + 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['listKeys']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listKeys.createStream( + this.innerApiCalls.listKeys as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listKeys`, 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 name of the project that contains the keys that will be + * listed, in the format "projects/{project}". + * @param {number} [request.pageSize] + * Optional. The maximum number of keys to return. Default is 10. Max limit is + * 1000. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous. + * ListKeysRequest, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.recaptchaenterprise.v1.Key|Key}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recaptcha_enterprise_service.list_keys.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListKeys_async + */ + listKeysAsync( + request?: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + 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['listKeys']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listKeys.asyncIterate( + this.innerApiCalls['listKeys'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * List groups of related accounts. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project to list related account groups from, in + * the format "projects/{project}". + * @param {number} [request.pageSize] + * Optional. The maximum number of groups to return. The service might return + * fewer than this value. If unspecified, at most 50 groups are returned. The + * maximum value is 1000; values above 1000 are coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListRelatedAccountGroups` + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * `ListRelatedAccountGroups` must match the call that provided the page + * token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup|RelatedAccountGroup}. + * 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 `listRelatedAccountGroupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listRelatedAccountGroups( + request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup[], + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest|null, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse + ]>; + listRelatedAccountGroups( + request: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup>): void; + listRelatedAccountGroups( + request: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup>): void; + listRelatedAccountGroups( + request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup>, + callback?: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup[], + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest|null, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listRelatedAccountGroups(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 name of the project to list related account groups from, in + * the format "projects/{project}". + * @param {number} [request.pageSize] + * Optional. The maximum number of groups to return. The service might return + * fewer than this value. If unspecified, at most 50 groups are returned. The + * maximum value is 1000; values above 1000 are coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListRelatedAccountGroups` + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * `ListRelatedAccountGroups` must match the call that provided the page + * token. + * @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 protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup|RelatedAccountGroup} 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 `listRelatedAccountGroupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listRelatedAccountGroupsStream( + request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, + 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['listRelatedAccountGroups']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRelatedAccountGroups.createStream( + this.innerApiCalls.listRelatedAccountGroups as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listRelatedAccountGroups`, 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 name of the project to list related account groups from, in + * the format "projects/{project}". + * @param {number} [request.pageSize] + * Optional. The maximum number of groups to return. The service might return + * fewer than this value. If unspecified, at most 50 groups are returned. The + * maximum value is 1000; values above 1000 are coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListRelatedAccountGroups` + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * `ListRelatedAccountGroups` must match the call that provided the 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup|RelatedAccountGroup}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recaptcha_enterprise_service.list_related_account_groups.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroups_async + */ + listRelatedAccountGroupsAsync( + request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, + 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['listRelatedAccountGroups']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRelatedAccountGroups.asyncIterate( + this.innerApiCalls['listRelatedAccountGroups'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Get memberships in a group of related accounts. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name for the related account group in the format + * `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of accounts to return. The service might + * return fewer than this value. If unspecified, at most 50 accounts are + * returned. The maximum value is 1000; values above 1000 are coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * `ListRelatedAccountGroupMemberships` call. + * + * When paginating, all other parameters provided to + * `ListRelatedAccountGroupMemberships` must match the call that provided the + * page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership|RelatedAccountGroupMembership}. + * 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 `listRelatedAccountGroupMembershipsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listRelatedAccountGroupMemberships( + request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[], + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest|null, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse + ]>; + listRelatedAccountGroupMemberships( + request: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): void; + listRelatedAccountGroupMemberships( + request: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): void; + listRelatedAccountGroupMemberships( + request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>, + callback?: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[], + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest|null, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listRelatedAccountGroupMemberships(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name for the related account group in the format + * `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of accounts to return. The service might + * return fewer than this value. If unspecified, at most 50 accounts are + * returned. The maximum value is 1000; values above 1000 are coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * `ListRelatedAccountGroupMemberships` call. + * + * When paginating, all other parameters provided to + * `ListRelatedAccountGroupMemberships` must match the call that provided the + * page token. + * @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 protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership|RelatedAccountGroupMembership} 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 `listRelatedAccountGroupMembershipsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listRelatedAccountGroupMembershipsStream( + request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, + 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['listRelatedAccountGroupMemberships']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRelatedAccountGroupMemberships.createStream( + this.innerApiCalls.listRelatedAccountGroupMemberships as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listRelatedAccountGroupMemberships`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name for the related account group in the format + * `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of accounts to return. The service might + * return fewer than this value. If unspecified, at most 50 accounts are + * returned. The maximum value is 1000; values above 1000 are coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * `ListRelatedAccountGroupMemberships` call. + * + * When paginating, all other parameters provided to + * `ListRelatedAccountGroupMemberships` must match the call that provided the + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership|RelatedAccountGroupMembership}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recaptcha_enterprise_service.list_related_account_group_memberships.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroupMemberships_async + */ + listRelatedAccountGroupMembershipsAsync( + request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, + 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['listRelatedAccountGroupMemberships']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate( + this.innerApiCalls['listRelatedAccountGroupMemberships'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Search group memberships related to a given account. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Required. The name of the project to search related account group + * memberships from. Specify the project name in the following format: + * "projects/{project}". + * @param {Buffer} [request.hashedAccountId] + * Optional. The unique stable hashed user identifier we should search + * connections to. The identifier should correspond to a `hashed_account_id` + * provided in a previous `CreateAssessment` or `AnnotateAssessment` call. + * @param {number} [request.pageSize] + * Optional. The maximum number of groups to return. The service might return + * fewer than this value. If unspecified, at most 50 groups are returned. The + * maximum value is 1000; values above 1000 are coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * `SearchRelatedAccountGroupMemberships` call. Provide this to retrieve the + * subsequent page. + * + * When paginating, all other parameters provided to + * `SearchRelatedAccountGroupMemberships` must match the call that provided + * the page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership|RelatedAccountGroupMembership}. + * 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 `searchRelatedAccountGroupMembershipsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + searchRelatedAccountGroupMemberships( + request?: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[], + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest|null, + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse + ]>; + searchRelatedAccountGroupMemberships( + request: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): void; + searchRelatedAccountGroupMemberships( + request: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): void; + searchRelatedAccountGroupMemberships( + request?: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>, + callback?: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[], + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest|null, + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.searchRelatedAccountGroupMemberships(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.project + * Required. The name of the project to search related account group + * memberships from. Specify the project name in the following format: + * "projects/{project}". + * @param {Buffer} [request.hashedAccountId] + * Optional. The unique stable hashed user identifier we should search + * connections to. The identifier should correspond to a `hashed_account_id` + * provided in a previous `CreateAssessment` or `AnnotateAssessment` call. + * @param {number} [request.pageSize] + * Optional. The maximum number of groups to return. The service might return + * fewer than this value. If unspecified, at most 50 groups are returned. The + * maximum value is 1000; values above 1000 are coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * `SearchRelatedAccountGroupMemberships` call. Provide this to retrieve the + * subsequent page. + * + * When paginating, all other parameters provided to + * `SearchRelatedAccountGroupMemberships` must match the call that provided + * the page token. + * @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 protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership|RelatedAccountGroupMembership} 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 `searchRelatedAccountGroupMembershipsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + searchRelatedAccountGroupMembershipsStream( + request?: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, + 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({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['searchRelatedAccountGroupMemberships']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchRelatedAccountGroupMemberships.createStream( + this.innerApiCalls.searchRelatedAccountGroupMemberships as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `searchRelatedAccountGroupMemberships`, 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.project + * Required. The name of the project to search related account group + * memberships from. Specify the project name in the following format: + * "projects/{project}". + * @param {Buffer} [request.hashedAccountId] + * Optional. The unique stable hashed user identifier we should search + * connections to. The identifier should correspond to a `hashed_account_id` + * provided in a previous `CreateAssessment` or `AnnotateAssessment` call. + * @param {number} [request.pageSize] + * Optional. The maximum number of groups to return. The service might return + * fewer than this value. If unspecified, at most 50 groups are returned. The + * maximum value is 1000; values above 1000 are coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * `SearchRelatedAccountGroupMemberships` call. Provide this to retrieve the + * subsequent page. + * + * When paginating, all other parameters provided to + * `SearchRelatedAccountGroupMemberships` must match the call that provided + * the 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership|RelatedAccountGroupMembership}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recaptcha_enterprise_service.search_related_account_group_memberships.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_SearchRelatedAccountGroupMemberships_async + */ + searchRelatedAccountGroupMembershipsAsync( + request?: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, + 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({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['searchRelatedAccountGroupMemberships']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate( + this.innerApiCalls['searchRelatedAccountGroupMemberships'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified assessment resource name string. + * + * @param {string} project + * @param {string} assessment + * @returns {string} Resource name string. + */ + assessmentPath(project:string,assessment:string) { + return this.pathTemplates.assessmentPathTemplate.render({ + project: project, + assessment: assessment, + }); + } + + /** + * Parse the project from Assessment resource. + * + * @param {string} assessmentName + * A fully-qualified path representing Assessment resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAssessmentName(assessmentName: string) { + return this.pathTemplates.assessmentPathTemplate.match(assessmentName).project; + } + + /** + * Parse the assessment from Assessment resource. + * + * @param {string} assessmentName + * A fully-qualified path representing Assessment resource. + * @returns {string} A string representing the assessment. + */ + matchAssessmentFromAssessmentName(assessmentName: string) { + return this.pathTemplates.assessmentPathTemplate.match(assessmentName).assessment; + } + + /** + * Return a fully-qualified key resource name string. + * + * @param {string} project + * @param {string} key + * @returns {string} Resource name string. + */ + keyPath(project:string,key:string) { + return this.pathTemplates.keyPathTemplate.render({ + project: project, + key: key, + }); + } + + /** + * Parse the project from Key resource. + * + * @param {string} keyName + * A fully-qualified path representing Key resource. + * @returns {string} A string representing the project. + */ + matchProjectFromKeyName(keyName: string) { + return this.pathTemplates.keyPathTemplate.match(keyName).project; + } + + /** + * Parse the key from Key resource. + * + * @param {string} keyName + * A fully-qualified path representing Key resource. + * @returns {string} A string representing the key. + */ + matchKeyFromKeyName(keyName: string) { + return this.pathTemplates.keyPathTemplate.match(keyName).key; + } + + /** + * Return a fully-qualified metrics resource name string. + * + * @param {string} project + * @param {string} key + * @returns {string} Resource name string. + */ + metricsPath(project:string,key:string) { + return this.pathTemplates.metricsPathTemplate.render({ + project: project, + key: key, + }); + } + + /** + * Parse the project from Metrics resource. + * + * @param {string} metricsName + * A fully-qualified path representing Metrics resource. + * @returns {string} A string representing the project. + */ + matchProjectFromMetricsName(metricsName: string) { + return this.pathTemplates.metricsPathTemplate.match(metricsName).project; + } + + /** + * Parse the key from Metrics resource. + * + * @param {string} metricsName + * A fully-qualified path representing Metrics resource. + * @returns {string} A string representing the key. + */ + matchKeyFromMetricsName(metricsName: string) { + return this.pathTemplates.metricsPathTemplate.match(metricsName).key; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified relatedAccountGroup resource name string. + * + * @param {string} project + * @param {string} relatedaccountgroup + * @returns {string} Resource name string. + */ + relatedAccountGroupPath(project:string,relatedaccountgroup:string) { + return this.pathTemplates.relatedAccountGroupPathTemplate.render({ + project: project, + relatedaccountgroup: relatedaccountgroup, + }); + } + + /** + * Parse the project from RelatedAccountGroup resource. + * + * @param {string} relatedAccountGroupName + * A fully-qualified path representing RelatedAccountGroup resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRelatedAccountGroupName(relatedAccountGroupName: string) { + return this.pathTemplates.relatedAccountGroupPathTemplate.match(relatedAccountGroupName).project; + } + + /** + * Parse the relatedaccountgroup from RelatedAccountGroup resource. + * + * @param {string} relatedAccountGroupName + * A fully-qualified path representing RelatedAccountGroup resource. + * @returns {string} A string representing the relatedaccountgroup. + */ + matchRelatedaccountgroupFromRelatedAccountGroupName(relatedAccountGroupName: string) { + return this.pathTemplates.relatedAccountGroupPathTemplate.match(relatedAccountGroupName).relatedaccountgroup; + } + + /** + * Return a fully-qualified relatedAccountGroupMembership resource name string. + * + * @param {string} project + * @param {string} relatedaccountgroup + * @param {string} membership + * @returns {string} Resource name string. + */ + relatedAccountGroupMembershipPath(project:string,relatedaccountgroup:string,membership:string) { + return this.pathTemplates.relatedAccountGroupMembershipPathTemplate.render({ + project: project, + relatedaccountgroup: relatedaccountgroup, + membership: membership, + }); + } + + /** + * Parse the project from RelatedAccountGroupMembership resource. + * + * @param {string} relatedAccountGroupMembershipName + * A fully-qualified path representing RelatedAccountGroupMembership resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRelatedAccountGroupMembershipName(relatedAccountGroupMembershipName: string) { + return this.pathTemplates.relatedAccountGroupMembershipPathTemplate.match(relatedAccountGroupMembershipName).project; + } + + /** + * Parse the relatedaccountgroup from RelatedAccountGroupMembership resource. + * + * @param {string} relatedAccountGroupMembershipName + * A fully-qualified path representing RelatedAccountGroupMembership resource. + * @returns {string} A string representing the relatedaccountgroup. + */ + matchRelatedaccountgroupFromRelatedAccountGroupMembershipName(relatedAccountGroupMembershipName: string) { + return this.pathTemplates.relatedAccountGroupMembershipPathTemplate.match(relatedAccountGroupMembershipName).relatedaccountgroup; + } + + /** + * Parse the membership from RelatedAccountGroupMembership resource. + * + * @param {string} relatedAccountGroupMembershipName + * A fully-qualified path representing RelatedAccountGroupMembership resource. + * @returns {string} A string representing the membership. + */ + matchMembershipFromRelatedAccountGroupMembershipName(relatedAccountGroupMembershipName: string) { + return this.pathTemplates.relatedAccountGroupMembershipPathTemplate.match(relatedAccountGroupMembershipName).membership; + } + + /** + * 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.recaptchaEnterpriseServiceStub && !this._terminated) { + return this.recaptchaEnterpriseServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_client_config.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_client_config.json new file mode 100644 index 00000000000..acb5f95bd9c --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_client_config.json @@ -0,0 +1,85 @@ +{ + "interfaces": { + "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService": { + "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": { + "CreateAssessment": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AnnotateAssessment": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateKey": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListKeys": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RetrieveLegacySecretKey": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetKey": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateKey": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteKey": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "MigrateKey": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetMetrics": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListRelatedAccountGroups": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListRelatedAccountGroupMemberships": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SearchRelatedAccountGroupMemberships": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_proto_list.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_proto_list.json new file mode 100644 index 00000000000..790fef960af --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto" +] diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..765861da444 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const recaptchaenterprise = require('@google-cloud/recaptcha-enterprise'); + +function main() { + const recaptchaEnterpriseServiceClient = new recaptchaenterprise.RecaptchaEnterpriseServiceClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..29561bc0841 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {RecaptchaEnterpriseServiceClient} from '@google-cloud/recaptcha-enterprise'; + +// check that the client class type name can be used +function doStuffWithRecaptchaEnterpriseServiceClient(client: RecaptchaEnterpriseServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient(); + doStuffWithRecaptchaEnterpriseServiceClient(recaptchaEnterpriseServiceClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/install.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/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-recaptchaenterprise/v1/test/gapic_recaptcha_enterprise_service_v1.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/test/gapic_recaptcha_enterprise_service_v1.ts new file mode 100644 index 00000000000..6caf38f8ca0 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/test/gapic_recaptcha_enterprise_service_v1.ts @@ -0,0 +1,2384 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 recaptchaenterpriseserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.RecaptchaEnterpriseServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.recaptchaEnterpriseServiceStub, undefined); + await client.initialize(); + assert(client.recaptchaEnterpriseServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.recaptchaEnterpriseServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.recaptchaEnterpriseServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + 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 recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + 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('createAssessment', () => { + it('invokes createAssessment without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Assessment() + ); + client.innerApiCalls.createAssessment = stubSimpleCall(expectedResponse); + const [response] = await client.createAssessment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createAssessment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createAssessment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createAssessment without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Assessment() + ); + client.innerApiCalls.createAssessment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createAssessment( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IAssessment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createAssessment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createAssessment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createAssessment with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createAssessment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createAssessment(request), expectedError); + const actualRequest = (client.innerApiCalls.createAssessment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createAssessment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createAssessment with closed client', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createAssessment(request), expectedError); + }); + }); + + describe('annotateAssessment', () => { + it('invokes annotateAssessment without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentResponse() + ); + client.innerApiCalls.annotateAssessment = stubSimpleCall(expectedResponse); + const [response] = await client.annotateAssessment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes annotateAssessment without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentResponse() + ); + client.innerApiCalls.annotateAssessment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.annotateAssessment( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes annotateAssessment with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.annotateAssessment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.annotateAssessment(request), expectedError); + const actualRequest = (client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes annotateAssessment with closed client', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.annotateAssessment(request), expectedError); + }); + }); + + describe('createKey', () => { + it('invokes createKey without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.CreateKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.CreateKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ); + client.innerApiCalls.createKey = stubSimpleCall(expectedResponse); + const [response] = await client.createKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createKey without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.CreateKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.CreateKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ); + client.innerApiCalls.createKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createKey( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createKey with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.CreateKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.CreateKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createKey(request), expectedError); + const actualRequest = (client.innerApiCalls.createKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createKey with closed client', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.CreateKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.CreateKeyRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createKey(request), expectedError); + }); + }); + + describe('retrieveLegacySecretKey', () => { + it('invokes retrieveLegacySecretKey without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyRequest', ['key']); + request.key = defaultValue1; + const expectedHeaderRequestParams = `key=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyResponse() + ); + client.innerApiCalls.retrieveLegacySecretKey = stubSimpleCall(expectedResponse); + const [response] = await client.retrieveLegacySecretKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.retrieveLegacySecretKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.retrieveLegacySecretKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes retrieveLegacySecretKey without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyRequest', ['key']); + request.key = defaultValue1; + const expectedHeaderRequestParams = `key=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyResponse() + ); + client.innerApiCalls.retrieveLegacySecretKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.retrieveLegacySecretKey( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.retrieveLegacySecretKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.retrieveLegacySecretKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes retrieveLegacySecretKey with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyRequest', ['key']); + request.key = defaultValue1; + const expectedHeaderRequestParams = `key=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.retrieveLegacySecretKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.retrieveLegacySecretKey(request), expectedError); + const actualRequest = (client.innerApiCalls.retrieveLegacySecretKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.retrieveLegacySecretKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes retrieveLegacySecretKey with closed client', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyRequest', ['key']); + request.key = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.retrieveLegacySecretKey(request), expectedError); + }); + }); + + describe('getKey', () => { + it('invokes getKey without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.GetKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.GetKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ); + client.innerApiCalls.getKey = stubSimpleCall(expectedResponse); + const [response] = await client.getKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getKey without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.GetKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.GetKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ); + client.innerApiCalls.getKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getKey( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getKey with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.GetKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.GetKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getKey(request), expectedError); + const actualRequest = (client.innerApiCalls.getKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getKey with closed client', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.GetKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.GetKeyRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getKey(request), expectedError); + }); + }); + + describe('updateKey', () => { + it('invokes updateKey without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest() + ); + request.key ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest', ['key', 'name']); + request.key.name = defaultValue1; + const expectedHeaderRequestParams = `key.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ); + client.innerApiCalls.updateKey = stubSimpleCall(expectedResponse); + const [response] = await client.updateKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateKey without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest() + ); + request.key ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest', ['key', 'name']); + request.key.name = defaultValue1; + const expectedHeaderRequestParams = `key.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ); + client.innerApiCalls.updateKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateKey( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateKey with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest() + ); + request.key ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest', ['key', 'name']); + request.key.name = defaultValue1; + const expectedHeaderRequestParams = `key.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateKey(request), expectedError); + const actualRequest = (client.innerApiCalls.updateKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateKey with closed client', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest() + ); + request.key ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest', ['key', 'name']); + request.key.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateKey(request), expectedError); + }); + }); + + describe('deleteKey', () => { + it('invokes deleteKey without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteKey = stubSimpleCall(expectedResponse); + const [response] = await client.deleteKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteKey without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteKey( + 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.deleteKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteKey with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteKey(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteKey with closed client', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteKey(request), expectedError); + }); + }); + + describe('migrateKey', () => { + it('invokes migrateKey without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.MigrateKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.MigrateKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ); + client.innerApiCalls.migrateKey = stubSimpleCall(expectedResponse); + const [response] = await client.migrateKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.migrateKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.migrateKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes migrateKey without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.MigrateKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.MigrateKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ); + client.innerApiCalls.migrateKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.migrateKey( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.migrateKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.migrateKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes migrateKey with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.MigrateKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.MigrateKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.migrateKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.migrateKey(request), expectedError); + const actualRequest = (client.innerApiCalls.migrateKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.migrateKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes migrateKey with closed client', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.MigrateKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.MigrateKeyRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.migrateKey(request), expectedError); + }); + }); + + describe('getMetrics', () => { + it('invokes getMetrics without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.GetMetricsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.GetMetricsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Metrics() + ); + client.innerApiCalls.getMetrics = stubSimpleCall(expectedResponse); + const [response] = await client.getMetrics(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getMetrics as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getMetrics as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getMetrics without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.GetMetricsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.GetMetricsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Metrics() + ); + client.innerApiCalls.getMetrics = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getMetrics( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IMetrics|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getMetrics as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getMetrics as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getMetrics with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.GetMetricsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.GetMetricsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getMetrics = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getMetrics(request), expectedError); + const actualRequest = (client.innerApiCalls.getMetrics as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getMetrics as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getMetrics with closed client', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.GetMetricsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.GetMetricsRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getMetrics(request), expectedError); + }); + }); + + describe('listKeys', () => { + it('invokes listKeys without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListKeysRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + ]; + client.innerApiCalls.listKeys = stubSimpleCall(expectedResponse); + const [response] = await client.listKeys(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listKeys as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listKeys as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listKeys without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListKeysRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + ]; + client.innerApiCalls.listKeys = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listKeys( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listKeys as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listKeys as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listKeys with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListKeysRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listKeys = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listKeys(request), expectedError); + const actualRequest = (client.innerApiCalls.listKeys as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listKeys as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listKeysStream without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListKeysRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + ]; + client.descriptors.page.listKeys.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listKeysStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1.Key[] = []; + stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.Key) => { + 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.listKeys.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listKeys, request)); + assert( + (client.descriptors.page.listKeys.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listKeysStream with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListKeysRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listKeys.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listKeysStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1.Key[] = []; + stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.Key) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listKeys.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listKeys, request)); + assert( + (client.descriptors.page.listKeys.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listKeys without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListKeysRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + ]; + client.descriptors.page.listKeys.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.recaptchaenterprise.v1.IKey[] = []; + const iterable = client.listKeysAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listKeys.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listKeys.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listKeys with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListKeysRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listKeys.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listKeysAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.recaptchaenterprise.v1.IKey[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listKeys.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listKeys.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listRelatedAccountGroups', () => { + it('invokes listRelatedAccountGroups without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + ]; + client.innerApiCalls.listRelatedAccountGroups = stubSimpleCall(expectedResponse); + const [response] = await client.listRelatedAccountGroups(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listRelatedAccountGroups as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRelatedAccountGroups as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRelatedAccountGroups without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + ]; + client.innerApiCalls.listRelatedAccountGroups = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listRelatedAccountGroups( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listRelatedAccountGroups as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRelatedAccountGroups as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRelatedAccountGroups with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listRelatedAccountGroups = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listRelatedAccountGroups(request), expectedError); + const actualRequest = (client.innerApiCalls.listRelatedAccountGroups as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRelatedAccountGroups as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRelatedAccountGroupsStream without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + ]; + client.descriptors.page.listRelatedAccountGroups.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listRelatedAccountGroupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup[] = []; + stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup) => { + 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.listRelatedAccountGroups.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRelatedAccountGroups, request)); + assert( + (client.descriptors.page.listRelatedAccountGroups.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listRelatedAccountGroupsStream with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRelatedAccountGroups.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listRelatedAccountGroupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup[] = []; + stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listRelatedAccountGroups.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRelatedAccountGroups, request)); + assert( + (client.descriptors.page.listRelatedAccountGroups.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listRelatedAccountGroups without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + ]; + client.descriptors.page.listRelatedAccountGroups.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup[] = []; + const iterable = client.listRelatedAccountGroupsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listRelatedAccountGroups.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listRelatedAccountGroups.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listRelatedAccountGroups with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRelatedAccountGroups.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listRelatedAccountGroupsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listRelatedAccountGroups.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listRelatedAccountGroups.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listRelatedAccountGroupMemberships', () => { + it('invokes listRelatedAccountGroupMemberships without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + ]; + client.innerApiCalls.listRelatedAccountGroupMemberships = stubSimpleCall(expectedResponse); + const [response] = await client.listRelatedAccountGroupMemberships(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listRelatedAccountGroupMemberships as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRelatedAccountGroupMemberships as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRelatedAccountGroupMemberships without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + ]; + client.innerApiCalls.listRelatedAccountGroupMemberships = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listRelatedAccountGroupMemberships( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listRelatedAccountGroupMemberships as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRelatedAccountGroupMemberships as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRelatedAccountGroupMemberships with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listRelatedAccountGroupMemberships = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listRelatedAccountGroupMemberships(request), expectedError); + const actualRequest = (client.innerApiCalls.listRelatedAccountGroupMemberships as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRelatedAccountGroupMemberships as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRelatedAccountGroupMembershipsStream without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + ]; + client.descriptors.page.listRelatedAccountGroupMemberships.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listRelatedAccountGroupMembershipsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership[] = []; + stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership) => { + 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.listRelatedAccountGroupMemberships.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRelatedAccountGroupMemberships, request)); + assert( + (client.descriptors.page.listRelatedAccountGroupMemberships.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listRelatedAccountGroupMembershipsStream with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRelatedAccountGroupMemberships.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listRelatedAccountGroupMembershipsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership[] = []; + stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listRelatedAccountGroupMemberships.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRelatedAccountGroupMemberships, request)); + assert( + (client.descriptors.page.listRelatedAccountGroupMemberships.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listRelatedAccountGroupMemberships without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + ]; + client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[] = []; + const iterable = client.listRelatedAccountGroupMembershipsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listRelatedAccountGroupMemberships with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listRelatedAccountGroupMembershipsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('searchRelatedAccountGroupMemberships', () => { + it('invokes searchRelatedAccountGroupMemberships without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + ]; + client.innerApiCalls.searchRelatedAccountGroupMemberships = stubSimpleCall(expectedResponse); + const [response] = await client.searchRelatedAccountGroupMemberships(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.searchRelatedAccountGroupMemberships as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.searchRelatedAccountGroupMemberships as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes searchRelatedAccountGroupMemberships without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + ]; + client.innerApiCalls.searchRelatedAccountGroupMemberships = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchRelatedAccountGroupMemberships( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.searchRelatedAccountGroupMemberships as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.searchRelatedAccountGroupMemberships as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes searchRelatedAccountGroupMemberships with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.searchRelatedAccountGroupMemberships = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.searchRelatedAccountGroupMemberships(request), expectedError); + const actualRequest = (client.innerApiCalls.searchRelatedAccountGroupMemberships as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.searchRelatedAccountGroupMemberships as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes searchRelatedAccountGroupMembershipsStream without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + ]; + client.descriptors.page.searchRelatedAccountGroupMemberships.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.searchRelatedAccountGroupMembershipsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership[] = []; + stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership) => { + 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.searchRelatedAccountGroupMemberships.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchRelatedAccountGroupMemberships, request)); + assert( + (client.descriptors.page.searchRelatedAccountGroupMemberships.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes searchRelatedAccountGroupMembershipsStream with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchRelatedAccountGroupMemberships.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.searchRelatedAccountGroupMembershipsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership[] = []; + stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.searchRelatedAccountGroupMemberships.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchRelatedAccountGroupMemberships, request)); + assert( + (client.descriptors.page.searchRelatedAccountGroupMemberships.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with searchRelatedAccountGroupMemberships without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + ]; + client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[] = []; + const iterable = client.searchRelatedAccountGroupMembershipsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with searchRelatedAccountGroupMemberships with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchRelatedAccountGroupMembershipsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('assessment', () => { + const fakePath = "/rendered/path/assessment"; + const expectedParameters = { + project: "projectValue", + assessment: "assessmentValue", + }; + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.assessmentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.assessmentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('assessmentPath', () => { + const result = client.assessmentPath("projectValue", "assessmentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.assessmentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAssessmentName', () => { + const result = client.matchProjectFromAssessmentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.assessmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchAssessmentFromAssessmentName', () => { + const result = client.matchAssessmentFromAssessmentName(fakePath); + assert.strictEqual(result, "assessmentValue"); + assert((client.pathTemplates.assessmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('key', () => { + const fakePath = "/rendered/path/key"; + const expectedParameters = { + project: "projectValue", + key: "keyValue", + }; + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.keyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.keyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('keyPath', () => { + const result = client.keyPath("projectValue", "keyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.keyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromKeyName', () => { + const result = client.matchProjectFromKeyName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.keyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchKeyFromKeyName', () => { + const result = client.matchKeyFromKeyName(fakePath); + assert.strictEqual(result, "keyValue"); + assert((client.pathTemplates.keyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('metrics', () => { + const fakePath = "/rendered/path/metrics"; + const expectedParameters = { + project: "projectValue", + key: "keyValue", + }; + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.metricsPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.metricsPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('metricsPath', () => { + const result = client.metricsPath("projectValue", "keyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.metricsPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromMetricsName', () => { + const result = client.matchProjectFromMetricsName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.metricsPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchKeyFromMetricsName', () => { + const result = client.matchKeyFromMetricsName(fakePath); + assert.strictEqual(result, "keyValue"); + assert((client.pathTemplates.metricsPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('relatedAccountGroup', () => { + const fakePath = "/rendered/path/relatedAccountGroup"; + const expectedParameters = { + project: "projectValue", + relatedaccountgroup: "relatedaccountgroupValue", + }; + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.relatedAccountGroupPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.relatedAccountGroupPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('relatedAccountGroupPath', () => { + const result = client.relatedAccountGroupPath("projectValue", "relatedaccountgroupValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.relatedAccountGroupPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRelatedAccountGroupName', () => { + const result = client.matchProjectFromRelatedAccountGroupName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.relatedAccountGroupPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRelatedaccountgroupFromRelatedAccountGroupName', () => { + const result = client.matchRelatedaccountgroupFromRelatedAccountGroupName(fakePath); + assert.strictEqual(result, "relatedaccountgroupValue"); + assert((client.pathTemplates.relatedAccountGroupPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('relatedAccountGroupMembership', () => { + const fakePath = "/rendered/path/relatedAccountGroupMembership"; + const expectedParameters = { + project: "projectValue", + relatedaccountgroup: "relatedaccountgroupValue", + membership: "membershipValue", + }; + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.relatedAccountGroupMembershipPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.relatedAccountGroupMembershipPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('relatedAccountGroupMembershipPath', () => { + const result = client.relatedAccountGroupMembershipPath("projectValue", "relatedaccountgroupValue", "membershipValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.relatedAccountGroupMembershipPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRelatedAccountGroupMembershipName', () => { + const result = client.matchProjectFromRelatedAccountGroupMembershipName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.relatedAccountGroupMembershipPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRelatedaccountgroupFromRelatedAccountGroupMembershipName', () => { + const result = client.matchRelatedaccountgroupFromRelatedAccountGroupMembershipName(fakePath); + assert.strictEqual(result, "relatedaccountgroupValue"); + assert((client.pathTemplates.relatedAccountGroupMembershipPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchMembershipFromRelatedAccountGroupMembershipName', () => { + const result = client.matchMembershipFromRelatedAccountGroupMembershipName(fakePath); + assert.strictEqual(result, "membershipValue"); + assert((client.pathTemplates.relatedAccountGroupMembershipPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/tsconfig.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/webpack.config.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/webpack.config.js new file mode 100644 index 00000000000..6a9d07da0f4 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'RecaptchaEnterpriseService', + filename: './recaptcha-enterprise-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-recaptchaenterprise/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.gitignore b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.jsdoc.js new file mode 100644 index 00000000000..495384476fc --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.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/recaptcha-enterprise', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.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-recaptchaenterprise/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.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-recaptchaenterprise/v1beta1/README.md b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/README.md new file mode 100644 index 00000000000..57a5e168123 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/README.md @@ -0,0 +1 @@ +Recaptchaenterprise: Nodejs Client diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/package.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/package.json new file mode 100644 index 00000000000..4461de9c2d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/recaptcha-enterprise", + "version": "0.1.0", + "description": "Recaptchaenterprise client for Node.js", + "repository": "googleapis/nodejs-recaptchaenterprise", + "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 recaptchaenterprise", + "recaptchaenterprise", + "recaptcha enterprise service v1 beta1" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto new file mode 100644 index 00000000000..8d44b92e411 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto @@ -0,0 +1,682 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.recaptchaenterprise.v1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.RecaptchaEnterprise.V1Beta1"; +option go_package = "cloud.google.com/go/recaptchaenterprise/v2/apiv1beta1/recaptchaenterprisepb;recaptchaenterprisepb"; +option java_multiple_files = true; +option java_outer_classname = "RecaptchaEnterpriseProto"; +option java_package = "com.google.recaptchaenterprise.v1beta1"; +option objc_class_prefix = "GCRE"; +option php_namespace = "Google\\Cloud\\RecaptchaEnterprise\\V1beta1"; +option ruby_package = "Google::Cloud::RecaptchaEnterprise::V1beta1"; + +// Service to determine the likelihood an event is legitimate. +service RecaptchaEnterpriseServiceV1Beta1 { + option (google.api.default_host) = "recaptchaenterprise.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates an Assessment of the likelihood an event is legitimate. + rpc CreateAssessment(CreateAssessmentRequest) returns (Assessment) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*}/assessments" + body: "assessment" + }; + option (google.api.method_signature) = "parent,assessment"; + } + + // Annotates a previously created Assessment to provide additional information + // on whether the event turned out to be authentic or fradulent. + rpc AnnotateAssessment(AnnotateAssessmentRequest) + returns (AnnotateAssessmentResponse) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/assessments/*}:annotate" + body: "*" + }; + option (google.api.method_signature) = "name,annotation"; + } +} + +// The create assessment request message. +message CreateAssessmentRequest { + // Required. The name of the project in which the assessment will be created, + // in the format "projects/{project_number}". + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Required. The assessment details. + Assessment assessment = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Describes an event in the lifecycle of a payment transaction. +message TransactionEvent { + // Enum that represents an event in the payment transaction lifecycle. + enum TransactionEventType { + // Default, unspecified event type. + TRANSACTION_EVENT_TYPE_UNSPECIFIED = 0; + + // Indicates that the transaction is approved by the merchant. The + // accompanying reasons can include terms such as 'INHOUSE', 'ACCERTIFY', + // 'CYBERSOURCE', or 'MANUAL_REVIEW'. + MERCHANT_APPROVE = 1; + + // Indicates that the transaction is denied and concluded due to risks + // detected by the merchant. The accompanying reasons can include terms such + // as 'INHOUSE', 'ACCERTIFY', 'CYBERSOURCE', or 'MANUAL_REVIEW'. + MERCHANT_DENY = 2; + + // Indicates that the transaction is being evaluated by a human, due to + // suspicion or risk. + MANUAL_REVIEW = 3; + + // Indicates that the authorization attempt with the card issuer succeeded. + AUTHORIZATION = 4; + + // Indicates that the authorization attempt with the card issuer failed. + // The accompanying reasons can include Visa's '54' indicating that the card + // is expired, or '82' indicating that the CVV is incorrect. + AUTHORIZATION_DECLINE = 5; + + // Indicates that the transaction is completed because the funds were + // settled. + PAYMENT_CAPTURE = 6; + + // Indicates that the transaction could not be completed because the funds + // were not settled. + PAYMENT_CAPTURE_DECLINE = 7; + + // Indicates that the transaction has been canceled. Specify the reason + // for the cancellation. For example, 'INSUFFICIENT_INVENTORY'. + CANCEL = 8; + + // Indicates that the merchant has received a chargeback inquiry due to + // fraud for the transaction, requesting additional information before a + // fraud chargeback is officially issued and a formal chargeback + // notification is sent. + CHARGEBACK_INQUIRY = 9; + + // Indicates that the merchant has received a chargeback alert due to fraud + // for the transaction. The process of resolving the dispute without + // involving the payment network is started. + CHARGEBACK_ALERT = 10; + + // Indicates that a fraud notification is issued for the transaction, sent + // by the payment instrument's issuing bank because the transaction appears + // to be fraudulent. We recommend including TC40 or SAFE data in the + // `reason` field for this event type. For partial chargebacks, we recommend + // that you include an amount in the `value` field. + FRAUD_NOTIFICATION = 11; + + // Indicates that the merchant is informed by the payment network that the + // transaction has entered the chargeback process due to fraud. Reason code + // examples include Discover's '6005' and '6041'. For partial chargebacks, + // we recommend that you include an amount in the `value` field. + CHARGEBACK = 12; + + // Indicates that the transaction has entered the chargeback process due to + // fraud, and that the merchant has chosen to enter representment. Reason + // examples include Discover's '6005' and '6041'. For partial chargebacks, + // we recommend that you include an amount in the `value` field. + CHARGEBACK_REPRESENTMENT = 13; + + // Indicates that the transaction has had a fraud chargeback which was + // illegitimate and was reversed as a result. For partial chargebacks, we + // recommend that you include an amount in the `value` field. + CHARGEBACK_REVERSE = 14; + + // Indicates that the merchant has received a refund for a completed + // transaction. For partial refunds, we recommend that you include an amount + // in the `value` field. Reason example: 'TAX_EXEMPT' (partial refund of + // exempt tax) + REFUND_REQUEST = 15; + + // Indicates that the merchant has received a refund request for this + // transaction, but that they have declined it. For partial refunds, we + // recommend that you include an amount in the `value` field. Reason + // example: 'TAX_EXEMPT' (partial refund of exempt tax) + REFUND_DECLINE = 16; + + // Indicates that the completed transaction was refunded by the merchant. + // For partial refunds, we recommend that you include an amount in the + // `value` field. Reason example: 'TAX_EXEMPT' (partial refund of exempt + // tax) + REFUND = 17; + + // Indicates that the completed transaction was refunded by the merchant, + // and that this refund was reversed. For partial refunds, we recommend that + // you include an amount in the `value` field. + REFUND_REVERSE = 18; + } + + // Optional. The type of this transaction event. + TransactionEventType event_type = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The reason or standardized code that corresponds with this + // transaction event, if one exists. For example, a CHARGEBACK event with code + // 6005. + string reason = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The value that corresponds with this transaction event, if one + // exists. For example, a refund event where $5.00 was refunded. Currency is + // obtained from the original transaction data. + double value = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Timestamp when this transaction event occurred; otherwise assumed + // to be the time of the API call. + google.protobuf.Timestamp event_time = 4 + [(google.api.field_behavior) = OPTIONAL]; +} + +// The request message to annotate an Assessment. +message AnnotateAssessmentRequest { + // Enum that represents the types of annotations. + enum Annotation { + // Default unspecified type. + ANNOTATION_UNSPECIFIED = 0; + + // Provides information that the event turned out to be legitimate. + LEGITIMATE = 1; + + // Provides information that the event turned out to be fraudulent. + FRAUDULENT = 2; + + // Provides information that the event was related to a login event in which + // the user typed the correct password. Deprecated, prefer indicating + // CORRECT_PASSWORD through the reasons field instead. + PASSWORD_CORRECT = 3 [deprecated = true]; + + // Provides information that the event was related to a login event in which + // the user typed the incorrect password. Deprecated, prefer indicating + // INCORRECT_PASSWORD through the reasons field instead. + PASSWORD_INCORRECT = 4 [deprecated = true]; + } + + // Enum that represents potential reasons for annotating an assessment. + enum Reason { + // Default unspecified reason. + REASON_UNSPECIFIED = 0; + + // Indicates that the transaction had a chargeback issued with no other + // details. When possible, specify the type by using CHARGEBACK_FRAUD or + // CHARGEBACK_DISPUTE instead. + CHARGEBACK = 1; + + // Indicates that the transaction had a chargeback issued related to an + // alleged unauthorized transaction from the cardholder's perspective (for + // example, the card number was stolen). + CHARGEBACK_FRAUD = 8; + + // Indicates that the transaction had a chargeback issued related to the + // cardholder having provided their card details but allegedly not being + // satisfied with the purchase (for example, misrepresentation, attempted + // cancellation). + CHARGEBACK_DISPUTE = 9; + + // Indicates that the completed payment transaction was refunded by the + // seller. + REFUND = 10; + + // Indicates that the completed payment transaction was determined to be + // fraudulent by the seller, and was cancelled and refunded as a result. + REFUND_FRAUD = 11; + + // Indicates that the payment transaction was accepted, and the user was + // charged. + TRANSACTION_ACCEPTED = 12; + + // Indicates that the payment transaction was declined, for example due to + // invalid card details. + TRANSACTION_DECLINED = 13; + + // Indicates the transaction associated with the assessment is suspected of + // being fraudulent based on the payment method, billing details, shipping + // address or other transaction information. + PAYMENT_HEURISTICS = 2; + + // Indicates that the user was served a 2FA challenge. An old assessment + // with `ENUM_VALUES.INITIATED_TWO_FACTOR` reason that has not been + // overwritten with `PASSED_TWO_FACTOR` is treated as an abandoned 2FA flow. + // This is equivalent to `FAILED_TWO_FACTOR`. + INITIATED_TWO_FACTOR = 7; + + // Indicates that the user passed a 2FA challenge. + PASSED_TWO_FACTOR = 3; + + // Indicates that the user failed a 2FA challenge. + FAILED_TWO_FACTOR = 4; + + // Indicates the user provided the correct password. + CORRECT_PASSWORD = 5; + + // Indicates the user provided an incorrect password. + INCORRECT_PASSWORD = 6; + + // Indicates that the user sent unwanted and abusive messages to other users + // of the platform, such as spam, scams, phishing, or social engineering. + SOCIAL_SPAM = 14; + } + + // Required. The resource name of the Assessment, in the format + // "projects/{project_number}/assessments/{assessment_id}". + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recaptchaenterprise.googleapis.com/Assessment" + } + ]; + + // Optional. The annotation that will be assigned to the Event. This field can + // be left empty to provide reasons that apply to an event without concluding + // whether the event is legitimate or fraudulent. + Annotation annotation = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Optional reasons for the annotation that will be assigned to the + // Event. + repeated Reason reasons = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Optional unique stable hashed user identifier to apply to the + // assessment. This is an alternative to setting the hashed_account_id in + // CreateAssessment, for example when the account identifier is not yet known + // in the initial request. It is recommended that the identifier is hashed + // using hmac-sha256 with stable secret. + bytes hashed_account_id = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If the assessment is part of a payment transaction, provide + // details on payment lifecycle events that occur in the transaction. + TransactionEvent transaction_event = 5 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Empty response for AnnotateAssessment. +message AnnotateAssessmentResponse {} + +// Password leak verification info. +message PasswordLeakVerification { + // Optional. Scrypt hash of the username+password that the customer wants to + // verify against a known password leak. + bytes hashed_user_credentials = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. Whether or not the user's credentials are present in a known + // leak. + bool credentials_leaked = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. The username part of the user credentials for which we want to + // trigger a leak check in canonicalized form. This is the same data used to + // create the hashed_user_credentials on the customer side. + string canonicalized_username = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// A reCAPTCHA Enterprise assessment resource. +message Assessment { + option (google.api.resource) = { + type: "recaptchaenterprise.googleapis.com/Assessment" + pattern: "projects/{project}/assessments/{assessment}" + }; + + // Reasons contributing to the risk analysis verdict. + enum ClassificationReason { + // Default unspecified type. + CLASSIFICATION_REASON_UNSPECIFIED = 0; + + // Interactions matched the behavior of an automated agent. + AUTOMATION = 1; + + // The event originated from an illegitimate environment. + UNEXPECTED_ENVIRONMENT = 2; + + // Traffic volume from the event source is higher than normal. + TOO_MUCH_TRAFFIC = 3; + + // Interactions with the site were significantly different than expected + // patterns. + UNEXPECTED_USAGE_PATTERNS = 4; + + // Too little traffic has been received from this site thus far to generate + // quality risk analysis. + LOW_CONFIDENCE_SCORE = 5; + + // The request matches behavioral characteristics of a carding attack. + SUSPECTED_CARDING = 6; + + // The request matches behavioral characteristics of chargebacks for fraud. + SUSPECTED_CHARGEBACK = 7; + } + + // Output only. The resource name for the Assessment in the format + // "projects/{project_number}/assessments/{assessment_id}". + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The event being assessed. + Event event = 2; + + // Output only. Legitimate event score from 0.0 to 1.0. + // (1.0 means very likely legitimate traffic while 0.0 means very likely + // non-legitimate traffic). + float score = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Properties of the provided event token. + TokenProperties token_properties = 4 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Reasons contributing to the risk analysis verdict. + repeated ClassificationReason reasons = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Information about the user's credentials used to check for leaks. + // This feature is part of the Early Access Program (EAP). Exercise caution, + // and do not deploy integrations based on this feature in a production + // environment. + PasswordLeakVerification password_leak_verification = 7; + + // Assessment returned by account defender when a hashed_account_id is + // provided. + AccountDefenderAssessment account_defender_assessment = 8; + + // Assessment returned by Fraud Prevention when TransactionData is provided. + FraudPreventionAssessment fraud_prevention_assessment = 11; +} + +message Event { + // Optional. The user response token provided by the reCAPTCHA Enterprise + // client-side integration on your site. + string token = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The site key that was used to invoke reCAPTCHA Enterprise on your + // site and generate the token. + string site_key = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The user agent present in the request from the user's device + // related to this event. + string user_agent = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The IP address in the request from the user's device related to + // this event. + string user_ip_address = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The expected action for this type of event. This should be the + // same action provided at token generation time on client-side platforms + // already integrated with recaptcha enterprise. + string expected_action = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Unique stable hashed user identifier for the request. The + // identifier must be hashed using hmac-sha256 with stable secret. + bytes hashed_account_id = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Data describing a payment transaction to be assessed. Sending + // this data enables reCAPTCHA Enterprise Fraud Prevention and the + // FraudPreventionAssessment component in the response. + TransactionData transaction_data = 13 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Transaction data associated with a payment protected by reCAPTCHA Enterprise. +// All fields are optional. +message TransactionData { + // Structured address format for billing and shipping addresses. + message Address { + // The recipient name, potentially including information such as "care of". + string recipient = 1; + + // The first lines of the address. The first line generally contains the + // street name and number, and further lines may include information such as + // an apartment number. + repeated string address = 2; + + // The town/city of the address. + string locality = 3; + + // The state, province, or otherwise administrative area of the address. + string administrative_area = 4; + + // The CLDR country/region of the address. + string region_code = 5; + + // The postal or ZIP code of the address. + string postal_code = 6; + } + + // Details about a user's account involved in the transaction. + message User { + // Unique account identifier for this user. If using account defender, + // this should match the hashed_account_id field. Otherwise, a unique and + // persistent identifier for this account. + string account_id = 6; + + // The epoch milliseconds of the user's account creation. + int64 creation_ms = 1; + + // The email address of the user. + string email = 2; + + // Whether the email has been verified to be accessible by the user (OTP or + // similar). + bool email_verified = 3; + + // The phone number of the user, with country code. + string phone_number = 4; + + // Whether the phone number has been verified to be accessible by the user + // (OTP or similar). + bool phone_verified = 5; + } + + // Line items being purchased in this transaction. + message Item { + // The full name of the item. + string name = 1; + + // The value per item that the user is paying, in the transaction currency, + // after discounts. + double value = 2; + + // The quantity of this item that is being purchased. + int64 quantity = 3; + + // When a merchant is specified, its corresponding account_id. Necessary to + // populate marketplace-style transactions. + string merchant_account_id = 4; + } + + // Details about the transaction from the gateway. + message GatewayInfo { + // Name of the gateway service (for example, stripe, square, paypal). + string name = 1; + + // Gateway response code describing the state of the transaction. + string gateway_response_code = 2; + + // AVS response code from the gateway + // (available only when reCAPTCHA Enterprise is called after authorization). + string avs_response_code = 3; + + // CVV response code from the gateway + // (available only when reCAPTCHA Enterprise is called after authorization). + string cvv_response_code = 4; + } + + // Unique identifier for the transaction. This custom identifier can be used + // to reference this transaction in the future, for example, labeling a refund + // or chargeback event. Two attempts at the same transaction should use the + // same transaction id. + optional string transaction_id = 11; + + // The payment method for the transaction. The allowed values are: + // + // * credit-card + // * debit-card + // * gift-card + // * processor-{name} (If a third-party is used, for example, + // processor-paypal) + // * custom-{name} (If an alternative method is used, for example, + // custom-crypto) + string payment_method = 1; + + // The Bank Identification Number - generally the first 6 or 8 digits of the + // card. + string card_bin = 2; + + // The last four digits of the card. + string card_last_four = 3; + + // The currency code in ISO-4217 format. + string currency_code = 4; + + // The decimal value of the transaction in the specified currency. + double value = 5; + + // The value of shipping in the specified currency. 0 for free or no shipping. + double shipping_value = 12; + + // Destination address if this transaction involves shipping a physical item. + Address shipping_address = 6; + + // Address associated with the payment method when applicable. + Address billing_address = 7; + + // Information about the user paying/initiating the transaction. + User user = 8; + + // Information about the user or users fulfilling the transaction. + repeated User merchants = 13; + + // Items purchased in this transaction. + repeated Item items = 14; + + // Information about the payment gateway's response to the transaction. + GatewayInfo gateway_info = 10; +} + +message TokenProperties { + // Enum that represents the types of invalid token reasons. + enum InvalidReason { + // Default unspecified type. + INVALID_REASON_UNSPECIFIED = 0; + + // If the failure reason was not accounted for. + UNKNOWN_INVALID_REASON = 1; + + // The provided user verification token was malformed. + MALFORMED = 2; + + // The user verification token had expired. + EXPIRED = 3; + + // The user verification had already been seen. + DUPE = 4; + + // The user verification token did not match the provided site key. + // This may be a configuration error (for example, development keys used in + // production) or end users trying to use verification tokens from other + // sites. + SITE_MISMATCH = 5 [deprecated = true]; + + // The user verification token was not present. It is a required input. + MISSING = 6; + + // A retriable error (such as network failure) occurred on the browser. + // Could easily be simulated by an attacker. + BROWSER_ERROR = 7; + } + + // Whether the provided user response token is valid. When valid = false, the + // reason could be specified in invalid_reason or it could also be due to + // a user failing to solve a challenge or a sitekey mismatch (i.e the sitekey + // used to generate the token was different than the one specified in the + // assessment). + bool valid = 1; + + // Reason associated with the response when valid = false. + InvalidReason invalid_reason = 2; + + // The timestamp corresponding to the generation of the token. + google.protobuf.Timestamp create_time = 3; + + // The hostname of the page on which the token was generated. + string hostname = 4; + + // Action name provided at token generation. + string action = 5; +} + +// Assessment for Fraud Prevention. +message FraudPreventionAssessment { + // Information about stolen instrument fraud, where the user is not the + // legitimate owner of the instrument being used for the purchase. + message StolenInstrumentVerdict { + // Probability (0-1) of this transaction being executed with a stolen + // instrument. + float risk = 1; + } + + // Information about card testing fraud, where an adversary is testing + // fraudulently obtained cards or brute forcing their details. + message CardTestingVerdict { + // Probability (0-1) of this transaction attempt being part of a card + // testing attack. + float risk = 1; + } + + // Probability (0-1) of this transaction being fraudulent. Summarizes the + // combined risk of attack vectors below. + float transaction_risk = 1; + + // Assessment of this transaction for risk of a stolen instrument. + StolenInstrumentVerdict stolen_instrument_verdict = 2; + + // Assessment of this transaction for risk of being part of a card testing + // attack. + CardTestingVerdict card_testing_verdict = 3; +} + +// Account defender risk assessment. +message AccountDefenderAssessment { + // Labels returned by account defender for this request. + enum AccountDefenderLabel { + // Default unspecified type. + ACCOUNT_DEFENDER_LABEL_UNSPECIFIED = 0; + + // The request matches a known good profile for the user. + PROFILE_MATCH = 1; + + // The request is potentially a suspicious login event and should be further + // verified either via multi-factor authentication or another system. + SUSPICIOUS_LOGIN_ACTIVITY = 2; + + // The request matched a profile that previously had suspicious account + // creation behavior. This could mean this is a fake account. + SUSPICIOUS_ACCOUNT_CREATION = 3; + + // The account in the request has a high number of related accounts. It does + // not necessarily imply that the account is bad but could require + // investigating. + RELATED_ACCOUNTS_NUMBER_HIGH = 4; + } + + // Labels for this request. + repeated AccountDefenderLabel labels = 1; +} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.annotate_assessment.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.annotate_assessment.js new file mode 100644 index 00000000000..9bc2f9269c6 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.annotate_assessment.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(name) { + // [START recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_AnnotateAssessment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 Assessment, in the format + * "projects/{project_number}/assessments/{assessment_id}". + */ + // const name = 'abc123' + /** + * Optional. The annotation that will be assigned to the Event. This field can + * be left empty to provide reasons that apply to an event without concluding + * whether the event is legitimate or fraudulent. + */ + // const annotation = {} + /** + * Optional. Optional reasons for the annotation that will be assigned to the + * Event. + */ + // const reasons = [1,2,3,4] + /** + * Optional. Optional unique stable hashed user identifier to apply to the + * assessment. This is an alternative to setting the hashed_account_id in + * CreateAssessment, for example when the account identifier is not yet known + * in the initial request. It is recommended that the identifier is hashed + * using hmac-sha256 with stable secret. + */ + // const hashedAccountId = Buffer.from('string') + /** + * Optional. If the assessment is part of a payment transaction, provide + * details on payment lifecycle events that occur in the transaction. + */ + // const transactionEvent = {} + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceV1Beta1Client} = require('@google-cloud/recaptcha-enterprise').v1beta1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceV1Beta1Client(); + + async function callAnnotateAssessment() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await recaptchaenterpriseClient.annotateAssessment(request); + console.log(response); + } + + callAnnotateAssessment(); + // [END recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_AnnotateAssessment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_assessment.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_assessment.js new file mode 100644 index 00000000000..f0192b59427 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_assessment.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(parent, assessment) { + // [START recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_CreateAssessment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 project in which the assessment will be created, + * in the format "projects/{project_number}". + */ + // const parent = 'abc123' + /** + * Required. The assessment details. + */ + // const assessment = {} + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceV1Beta1Client} = require('@google-cloud/recaptcha-enterprise').v1beta1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceV1Beta1Client(); + + async function callCreateAssessment() { + // Construct request + const request = { + parent, + assessment, + }; + + // Run request + const response = await recaptchaenterpriseClient.createAssessment(request); + console.log(response); + } + + callCreateAssessment(); + // [END recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_CreateAssessment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.recaptchaenterprise.v1beta1.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.recaptchaenterprise.v1beta1.json new file mode 100644 index 00000000000..a3466d51dda --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.recaptchaenterprise.v1beta1.json @@ -0,0 +1,115 @@ +{ + "clientLibrary": { + "name": "nodejs-recaptchaenterprise", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.recaptchaenterprise.v1beta1", + "version": "v1beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_CreateAssessment_async", + "title": "RecaptchaEnterpriseServiceV1Beta1 createAssessment Sample", + "origin": "API_DEFINITION", + "description": " Creates an Assessment of the likelihood an event is legitimate.", + "canonical": true, + "file": "recaptcha_enterprise_service_v1_beta1.create_assessment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateAssessment", + "fullName": "google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1.CreateAssessment", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "assessment", + "type": ".google.cloud.recaptchaenterprise.v1beta1.Assessment" + } + ], + "resultType": ".google.cloud.recaptchaenterprise.v1beta1.Assessment", + "client": { + "shortName": "RecaptchaEnterpriseServiceV1Beta1Client", + "fullName": "google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client" + }, + "method": { + "shortName": "CreateAssessment", + "fullName": "google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1.CreateAssessment", + "service": { + "shortName": "RecaptchaEnterpriseServiceV1Beta1", + "fullName": "google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1" + } + } + } + }, + { + "regionTag": "recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_AnnotateAssessment_async", + "title": "RecaptchaEnterpriseServiceV1Beta1 annotateAssessment Sample", + "origin": "API_DEFINITION", + "description": " Annotates a previously created Assessment to provide additional information on whether the event turned out to be authentic or fradulent.", + "canonical": true, + "file": "recaptcha_enterprise_service_v1_beta1.annotate_assessment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 78, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AnnotateAssessment", + "fullName": "google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1.AnnotateAssessment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "annotation", + "type": ".google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest.Annotation" + }, + { + "name": "reasons", + "type": "TYPE_ENUM[]" + }, + { + "name": "hashed_account_id", + "type": "TYPE_BYTES" + }, + { + "name": "transaction_event", + "type": ".google.cloud.recaptchaenterprise.v1beta1.TransactionEvent" + } + ], + "resultType": ".google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse", + "client": { + "shortName": "RecaptchaEnterpriseServiceV1Beta1Client", + "fullName": "google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client" + }, + "method": { + "shortName": "AnnotateAssessment", + "fullName": "google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1.AnnotateAssessment", + "service": { + "shortName": "RecaptchaEnterpriseServiceV1Beta1", + "fullName": "google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/index.ts new file mode 100644 index 00000000000..405eb8c9a51 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1beta1 from './v1beta1'; +const RecaptchaEnterpriseServiceV1Beta1Client = v1beta1.RecaptchaEnterpriseServiceV1Beta1Client; +type RecaptchaEnterpriseServiceV1Beta1Client = v1beta1.RecaptchaEnterpriseServiceV1Beta1Client; +export {v1beta1, RecaptchaEnterpriseServiceV1Beta1Client}; +export default {v1beta1, RecaptchaEnterpriseServiceV1Beta1Client}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/gapic_metadata.json new file mode 100644 index 00000000000..2a7ea778505 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/gapic_metadata.json @@ -0,0 +1,43 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.recaptchaenterprise.v1beta1", + "libraryPackage": "@google-cloud/recaptcha-enterprise", + "services": { + "RecaptchaEnterpriseServiceV1Beta1": { + "clients": { + "grpc": { + "libraryClient": "RecaptchaEnterpriseServiceV1Beta1Client", + "rpcs": { + "CreateAssessment": { + "methods": [ + "createAssessment" + ] + }, + "AnnotateAssessment": { + "methods": [ + "annotateAssessment" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RecaptchaEnterpriseServiceV1Beta1Client", + "rpcs": { + "CreateAssessment": { + "methods": [ + "createAssessment" + ] + }, + "AnnotateAssessment": { + "methods": [ + "annotateAssessment" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/index.ts new file mode 100644 index 00000000000..33e314fd5a2 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {RecaptchaEnterpriseServiceV1Beta1Client} from './recaptcha_enterprise_service_v1_beta1_client'; diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts new file mode 100644 index 00000000000..e16495d6b94 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts @@ -0,0 +1,542 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './recaptcha_enterprise_service_v1_beta1_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service to determine the likelihood an event is legitimate. + * @class + * @memberof v1beta1 + */ +export class RecaptchaEnterpriseServiceV1Beta1Client { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + recaptchaEnterpriseServiceV1Beta1Stub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RecaptchaEnterpriseServiceV1Beta1Client. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 RecaptchaEnterpriseServiceV1Beta1Client({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RecaptchaEnterpriseServiceV1Beta1Client; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + assessmentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/assessments/{assessment}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1', 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.recaptchaEnterpriseServiceV1Beta1Stub) { + return this.recaptchaEnterpriseServiceV1Beta1Stub; + } + + // Put together the "service stub" for + // google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1. + this.recaptchaEnterpriseServiceV1Beta1Stub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1, + 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 recaptchaEnterpriseServiceV1Beta1StubMethods = + ['createAssessment', 'annotateAssessment']; + for (const methodName of recaptchaEnterpriseServiceV1Beta1StubMethods) { + const callPromise = this.recaptchaEnterpriseServiceV1Beta1Stub.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.recaptchaEnterpriseServiceV1Beta1Stub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'recaptchaenterprise.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 'recaptchaenterprise.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 an Assessment of the likelihood an event is legitimate. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project in which the assessment will be created, + * in the format "projects/{project_number}". + * @param {google.cloud.recaptchaenterprise.v1beta1.Assessment} request.assessment + * Required. The assessment 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 protos.google.cloud.recaptchaenterprise.v1beta1.Assessment|Assessment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_assessment.js + * region_tag:recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_CreateAssessment_async + */ + createAssessment( + request?: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|undefined, {}|undefined + ]>; + createAssessment( + request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|null|undefined, + {}|null|undefined>): void; + createAssessment( + request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|null|undefined, + {}|null|undefined>): void; + createAssessment( + request?: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createAssessment(request, options, callback); + } +/** + * Annotates a previously created Assessment to provide additional information + * on whether the event turned out to be authentic or fradulent. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Assessment, in the format + * "projects/{project_number}/assessments/{assessment_id}". + * @param {google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest.Annotation} [request.annotation] + * Optional. The annotation that will be assigned to the Event. This field can + * be left empty to provide reasons that apply to an event without concluding + * whether the event is legitimate or fraudulent. + * @param {number[]} [request.reasons] + * Optional. Optional reasons for the annotation that will be assigned to the + * Event. + * @param {Buffer} [request.hashedAccountId] + * Optional. Optional unique stable hashed user identifier to apply to the + * assessment. This is an alternative to setting the hashed_account_id in + * CreateAssessment, for example when the account identifier is not yet known + * in the initial request. It is recommended that the identifier is hashed + * using hmac-sha256 with stable secret. + * @param {google.cloud.recaptchaenterprise.v1beta1.TransactionEvent} [request.transactionEvent] + * Optional. If the assessment is part of a payment transaction, provide + * details on payment lifecycle events that occur in the transaction. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse|AnnotateAssessmentResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.annotate_assessment.js + * region_tag:recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_AnnotateAssessment_async + */ + annotateAssessment( + request?: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|undefined, {}|undefined + ]>; + annotateAssessment( + request: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|null|undefined, + {}|null|undefined>): void; + annotateAssessment( + request: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|null|undefined, + {}|null|undefined>): void; + annotateAssessment( + request?: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.annotateAssessment(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified assessment resource name string. + * + * @param {string} project + * @param {string} assessment + * @returns {string} Resource name string. + */ + assessmentPath(project:string,assessment:string) { + return this.pathTemplates.assessmentPathTemplate.render({ + project: project, + assessment: assessment, + }); + } + + /** + * Parse the project from Assessment resource. + * + * @param {string} assessmentName + * A fully-qualified path representing Assessment resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAssessmentName(assessmentName: string) { + return this.pathTemplates.assessmentPathTemplate.match(assessmentName).project; + } + + /** + * Parse the assessment from Assessment resource. + * + * @param {string} assessmentName + * A fully-qualified path representing Assessment resource. + * @returns {string} A string representing the assessment. + */ + matchAssessmentFromAssessmentName(assessmentName: string) { + return this.pathTemplates.assessmentPathTemplate.match(assessmentName).assessment; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.recaptchaEnterpriseServiceV1Beta1Stub && !this._terminated) { + return this.recaptchaEnterpriseServiceV1Beta1Stub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json new file mode 100644 index 00000000000..7907ebe8f8e --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json @@ -0,0 +1,36 @@ +{ + "interfaces": { + "google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1": { + "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": { + "CreateAssessment": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AnnotateAssessment": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_proto_list.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_proto_list.json new file mode 100644 index 00000000000..35d2e7543ad --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto" +] diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..f81af678451 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const recaptchaenterprise = require('@google-cloud/recaptcha-enterprise'); + +function main() { + const recaptchaEnterpriseServiceV1Beta1Client = new recaptchaenterprise.RecaptchaEnterpriseServiceV1Beta1Client(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..79563939674 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {RecaptchaEnterpriseServiceV1Beta1Client} from '@google-cloud/recaptcha-enterprise'; + +// check that the client class type name can be used +function doStuffWithRecaptchaEnterpriseServiceV1Beta1Client(client: RecaptchaEnterpriseServiceV1Beta1Client) { + client.close(); +} + +function main() { + // check that the client instance can be created + const recaptchaEnterpriseServiceV1Beta1Client = new RecaptchaEnterpriseServiceV1Beta1Client(); + doStuffWithRecaptchaEnterpriseServiceV1Beta1Client(recaptchaEnterpriseServiceV1Beta1Client); +} + +main(); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/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-recaptchaenterprise/v1beta1/test/gapic_recaptcha_enterprise_service_v1_beta1_v1beta1.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/test/gapic_recaptcha_enterprise_service_v1_beta1_v1beta1.ts new file mode 100644 index 00000000000..751c9b12780 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/test/gapic_recaptcha_enterprise_service_v1_beta1_v1beta1.ts @@ -0,0 +1,437 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 recaptchaenterpriseservicev1beta1Module from '../src'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.recaptchaEnterpriseServiceV1Beta1Stub, undefined); + await client.initialize(); + assert(client.recaptchaEnterpriseServiceV1Beta1Stub); + }); + + it('has close method for the initialized client', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.recaptchaEnterpriseServiceV1Beta1Stub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.recaptchaEnterpriseServiceV1Beta1Stub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + 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 recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + 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('createAssessment', () => { + it('invokes createAssessment without error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Assessment() + ); + client.innerApiCalls.createAssessment = stubSimpleCall(expectedResponse); + const [response] = await client.createAssessment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createAssessment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createAssessment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createAssessment without error using callback', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Assessment() + ); + client.innerApiCalls.createAssessment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createAssessment( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createAssessment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createAssessment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createAssessment with error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createAssessment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createAssessment(request), expectedError); + const actualRequest = (client.innerApiCalls.createAssessment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createAssessment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createAssessment with closed client', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createAssessment(request), expectedError); + }); + }); + + describe('annotateAssessment', () => { + it('invokes annotateAssessment without error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse() + ); + client.innerApiCalls.annotateAssessment = stubSimpleCall(expectedResponse); + const [response] = await client.annotateAssessment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes annotateAssessment without error using callback', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse() + ); + client.innerApiCalls.annotateAssessment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.annotateAssessment( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes annotateAssessment with error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.annotateAssessment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.annotateAssessment(request), expectedError); + const actualRequest = (client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes annotateAssessment with closed client', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.annotateAssessment(request), expectedError); + }); + }); + + describe('Path templates', () => { + + describe('assessment', () => { + const fakePath = "/rendered/path/assessment"; + const expectedParameters = { + project: "projectValue", + assessment: "assessmentValue", + }; + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.assessmentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.assessmentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('assessmentPath', () => { + const result = client.assessmentPath("projectValue", "assessmentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.assessmentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAssessmentName', () => { + const result = client.matchProjectFromAssessmentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.assessmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchAssessmentFromAssessmentName', () => { + const result = client.matchAssessmentFromAssessmentName(fakePath); + assert.strictEqual(result, "assessmentValue"); + assert((client.pathTemplates.assessmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/webpack.config.js new file mode 100644 index 00000000000..a5030d63883 --- /dev/null +++ b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'RecaptchaEnterpriseServiceV1Beta1', + filename: './recaptcha-enterprise-service-v1-beta1.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-recommender/v1/.eslintignore b/owl-bot-staging/google-cloud-recommender/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-recommender/v1/.eslintrc.json b/owl-bot-staging/google-cloud-recommender/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-recommender/v1/.gitignore b/owl-bot-staging/google-cloud-recommender/v1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-recommender/v1/.jsdoc.js b/owl-bot-staging/google-cloud-recommender/v1/.jsdoc.js new file mode 100644 index 00000000000..c2e2fb04e21 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/.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/recommender', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-recommender/v1/.mocharc.js b/owl-bot-staging/google-cloud-recommender/v1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/.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-recommender/v1/.prettierrc.js b/owl-bot-staging/google-cloud-recommender/v1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/.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-recommender/v1/README.md b/owl-bot-staging/google-cloud-recommender/v1/README.md new file mode 100644 index 00000000000..59dc6bb7bb1 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/README.md @@ -0,0 +1 @@ +Recommender: Nodejs Client diff --git a/owl-bot-staging/google-cloud-recommender/v1/package.json b/owl-bot-staging/google-cloud-recommender/v1/package.json new file mode 100644 index 00000000000..5f3c60b1639 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/recommender", + "version": "0.1.0", + "description": "Recommender client for Node.js", + "repository": "googleapis/nodejs-recommender", + "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 recommender", + "recommender", + "recommender" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/insight.proto b/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/insight.proto new file mode 100644 index 00000000000..2d7c01339e3 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/insight.proto @@ -0,0 +1,162 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.recommender.v1; + +import "google/api/resource.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Recommender.V1"; +option go_package = "cloud.google.com/go/recommender/apiv1/recommenderpb;recommenderpb"; +option java_multiple_files = true; +option java_outer_classname = "InsightProto"; +option java_package = "com.google.cloud.recommender.v1"; +option objc_class_prefix = "CREC"; +option (google.api.resource_definition) = { + type: "recommender.googleapis.com/InsightType" + pattern: "projects/{project}/locations/{location}/insightTypes/{insight_type}" + pattern: "billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}" + pattern: "folders/{folder}/locations/{location}/insightTypes/{insight_type}" + pattern: "organizations/{organization}/locations/{location}/insightTypes/{insight_type}" +}; + +// An insight along with the information used to derive the insight. The insight +// may have associated recomendations as well. +message Insight { + option (google.api.resource) = { + type: "recommender.googleapis.com/Insight" + pattern: "projects/{project}/locations/{location}/insightTypes/{insight_type}/insights/{insight}" + pattern: "billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}/insights/{insight}" + pattern: "folders/{folder}/locations/{location}/insightTypes/{insight_type}/insights/{insight}" + pattern: "organizations/{organization}/locations/{location}/insightTypes/{insight_type}/insights/{insight}" + }; + + // Insight category. + enum Category { + // Unspecified category. + CATEGORY_UNSPECIFIED = 0; + + // The insight is related to cost. + COST = 1; + + // The insight is related to security. + SECURITY = 2; + + // The insight is related to performance. + PERFORMANCE = 3; + + // This insight is related to manageability. + MANAGEABILITY = 4; + } + + // Insight severity levels. + enum Severity { + // Insight has unspecified severity. + SEVERITY_UNSPECIFIED = 0; + + // Insight has low severity. + LOW = 1; + + // Insight has medium severity. + MEDIUM = 2; + + // Insight has high severity. + HIGH = 3; + + // Insight has critical severity. + CRITICAL = 4; + } + + // Reference to an associated recommendation. + message RecommendationReference { + // Recommendation resource name, e.g. + // projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/recommendations/[RECOMMENDATION_ID] + string recommendation = 1; + } + + // Name of the insight. + string name = 1; + + // Free-form human readable summary in English. The maximum length is 500 + // characters. + string description = 2; + + // Fully qualified resource names that this insight is targeting. + repeated string target_resources = 9; + + // Insight subtype. Insight content schema will be stable for a given subtype. + string insight_subtype = 10; + + // A struct of custom fields to explain the insight. + // Example: "grantedPermissionsCount": "1000" + google.protobuf.Struct content = 3; + + // Timestamp of the latest data used to generate the insight. + google.protobuf.Timestamp last_refresh_time = 4; + + // Observation period that led to the insight. The source data used to + // generate the insight ends at last_refresh_time and begins at + // (last_refresh_time - observation_period). + google.protobuf.Duration observation_period = 5; + + // Information state and metadata. + InsightStateInfo state_info = 6; + + // Category being targeted by the insight. + Category category = 7; + + // Insight's severity. + Severity severity = 15; + + // Fingerprint of the Insight. Provides optimistic locking when updating + // states. + string etag = 11; + + // Recommendations derived from this insight. + repeated RecommendationReference associated_recommendations = 8; +} + +// Information related to insight state. +message InsightStateInfo { + // Represents insight state. + enum State { + // Unspecified state. + STATE_UNSPECIFIED = 0; + + // Insight is active. Content for ACTIVE insights can be updated by Google. + // ACTIVE insights can be marked DISMISSED OR ACCEPTED. + ACTIVE = 1; + + // Some action has been taken based on this insight. Insights become + // accepted when a recommendation derived from the insight has been marked + // CLAIMED, SUCCEEDED, or FAILED. ACTIVE insights can also be marked + // ACCEPTED explicitly. Content for ACCEPTED insights is immutable. ACCEPTED + // insights can only be marked ACCEPTED (which may update state metadata). + ACCEPTED = 2; + + // Insight is dismissed. Content for DISMISSED insights can be updated by + // Google. DISMISSED insights can be marked as ACTIVE. + DISMISSED = 3; + } + + // Insight state. + State state = 1; + + // A map of metadata for the state, provided by user or automations systems. + map state_metadata = 2; +} diff --git a/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/insight_type_config.proto b/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/insight_type_config.proto new file mode 100644 index 00000000000..742864bc75b --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/insight_type_config.proto @@ -0,0 +1,85 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.recommender.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Recommender.V1"; +option go_package = "cloud.google.com/go/recommender/apiv1/recommenderpb;recommenderpb"; +option java_multiple_files = true; +option java_outer_classname = "InsightTypeConfigProto"; +option java_package = "com.google.cloud.recommender.v1"; +option objc_class_prefix = "CREC"; + +// Configuration for an InsightType. +message InsightTypeConfig { + option (google.api.resource) = { + type: "recommender.googleapis.com/InsightTypeConfig" + pattern: "projects/{project}/locations/{location}/insightTypes/{insight_type}/config" + pattern: "organizations/{organization}/locations/{location}/insightTypes/{insight_type}/config" + }; + + // Name of insight type config. + // Eg, + // projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config + string name = 1; + + // InsightTypeGenerationConfig which configures the generation of + // insights for this insight type. + InsightTypeGenerationConfig insight_type_generation_config = 2; + + // Fingerprint of the InsightTypeConfig. Provides optimistic locking when + // updating. + string etag = 3; + + // Last time when the config was updated. + google.protobuf.Timestamp update_time = 4; + + // Output only. Immutable. The revision ID of the config. + // A new revision is committed whenever the config is changed in any way. + // The format is an 8-character hexadecimal string. + string revision_id = 5 [ + (google.api.field_behavior) = IMMUTABLE, + (google.api.field_behavior) = OUTPUT_ONLY + ]; + + // Allows clients to store small amounts of arbitrary data. Annotations must + // follow the Kubernetes syntax. + // The total size of all keys and values combined is limited to 256k. + // Key can have 2 segments: prefix (optional) and name (required), + // separated by a slash (/). + // Prefix must be a DNS subdomain. + // Name must be 63 characters or less, begin and end with alphanumerics, + // with dashes (-), underscores (_), dots (.), and alphanumerics between. + map annotations = 6; + + // A user-settable field to provide a human-readable name to be used in user + // interfaces. + string display_name = 7; +} + +// A configuration to customize the generation of insights. +// Eg, customizing the lookback period considered when generating a +// insight. +message InsightTypeGenerationConfig { + // Parameters for this InsightTypeGenerationConfig. These configs can be used + // by or are applied to all subtypes. + google.protobuf.Struct params = 1; +} diff --git a/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommendation.proto b/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommendation.proto new file mode 100644 index 00000000000..fd153345688 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommendation.proto @@ -0,0 +1,343 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.recommender.v1; + +import "google/api/resource.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/money.proto"; + +option csharp_namespace = "Google.Cloud.Recommender.V1"; +option go_package = "cloud.google.com/go/recommender/apiv1/recommenderpb;recommenderpb"; +option java_multiple_files = true; +option java_package = "com.google.cloud.recommender.v1"; +option objc_class_prefix = "CREC"; +option (google.api.resource_definition) = { + type: "recommender.googleapis.com/Recommender" + pattern: "projects/{project}/locations/{location}/recommenders/{recommender}" + pattern: "billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}" + pattern: "folders/{folder}/locations/{location}/recommenders/{recommender}" + pattern: "organizations/{organization}/locations/{location}/recommenders/{recommender}" +}; + +// A recommendation along with a suggested action. E.g., a rightsizing +// recommendation for an underutilized VM, IAM role recommendations, etc +message Recommendation { + option (google.api.resource) = { + type: "recommender.googleapis.com/Recommendation" + pattern: "projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}" + pattern: "billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}" + pattern: "folders/{folder}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}" + pattern: "organizations/{organization}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}" + }; + + // Recommendation priority levels. + enum Priority { + // Recommendation has unspecified priority. + PRIORITY_UNSPECIFIED = 0; + + // Recommendation has P4 priority (lowest priority). + P4 = 1; + + // Recommendation has P3 priority (second lowest priority). + P3 = 2; + + // Recommendation has P2 priority (second highest priority). + P2 = 3; + + // Recommendation has P1 priority (highest priority). + P1 = 4; + } + + // Reference to an associated insight. + message InsightReference { + // Insight resource name, e.g. + // projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/insights/[INSIGHT_ID] + string insight = 1; + } + + // Name of recommendation. + string name = 1; + + // Free-form human readable summary in English. The maximum length is 500 + // characters. + string description = 2; + + // Contains an identifier for a subtype of recommendations produced for the + // same recommender. Subtype is a function of content and impact, meaning a + // new subtype might be added when significant changes to `content` or + // `primary_impact.category` are introduced. See the Recommenders section + // to see a list of subtypes for a given Recommender. + // + // Examples: + // For recommender = "google.iam.policy.Recommender", + // recommender_subtype can be one of "REMOVE_ROLE"/"REPLACE_ROLE" + string recommender_subtype = 12; + + // Last time this recommendation was refreshed by the system that created it + // in the first place. + google.protobuf.Timestamp last_refresh_time = 4; + + // The primary impact that this recommendation can have while trying to + // optimize for one category. + Impact primary_impact = 5; + + // Optional set of additional impact that this recommendation may have when + // trying to optimize for the primary category. These may be positive + // or negative. + repeated Impact additional_impact = 6; + + // Recommendation's priority. + Priority priority = 17; + + // Content of the recommendation describing recommended changes to resources. + RecommendationContent content = 7; + + // Information for state. Contains state and metadata. + RecommendationStateInfo state_info = 10; + + // Fingerprint of the Recommendation. Provides optimistic locking when + // updating states. + string etag = 11; + + // Insights that led to this recommendation. + repeated InsightReference associated_insights = 14; + + // Corresponds to a mutually exclusive group ID within a recommender. + // A non-empty ID indicates that the recommendation belongs to a mutually + // exclusive group. This means that only one recommendation within the group + // is suggested to be applied. + string xor_group_id = 18; +} + +// Contains what resources are changing and how they are changing. +message RecommendationContent { + // Operations to one or more Google Cloud resources grouped in such a way + // that, all operations within one group are expected to be performed + // atomically and in an order. + repeated OperationGroup operation_groups = 2; + + // Condensed overview information about the recommendation. + google.protobuf.Struct overview = 3; +} + +// Group of operations that need to be performed atomically. +message OperationGroup { + // List of operations across one or more resources that belong to this group. + // Loosely based on RFC6902 and should be performed in the order they appear. + repeated Operation operations = 1; +} + +// Contains an operation for a resource loosely based on the JSON-PATCH format +// with support for: +// +// * Custom filters for describing partial array patch. +// * Extended path values for describing nested arrays. +// * Custom fields for describing the resource for which the operation is being +// described. +// * Allows extension to custom operations not natively supported by RFC6902. +// See https://tools.ietf.org/html/rfc6902 for details on the original RFC. +message Operation { + // Type of this operation. Contains one of 'add', 'remove', 'replace', 'move', + // 'copy', 'test' and custom operations. This field is case-insensitive and + // always populated. + string action = 1; + + // Type of GCP resource being modified/tested. This field is always populated. + // Example: cloudresourcemanager.googleapis.com/Project, + // compute.googleapis.com/Instance + string resource_type = 2; + + // Contains the fully qualified resource name. This field is always populated. + // ex: //cloudresourcemanager.googleapis.com/projects/foo. + string resource = 3; + + // Path to the target field being operated on. If the operation is at the + // resource level, then path should be "/". This field is always populated. + string path = 4; + + // Can be set with action 'copy' to copy resource configuration across + // different resources of the same type. Example: A resource clone can be + // done via action = 'copy', path = "/", from = "/", + // source_resource = and resource_name = . + // This field is empty for all other values of `action`. + string source_resource = 5; + + // Can be set with action 'copy' or 'move' to indicate the source field within + // resource or source_resource, ignored if provided for other operation types. + string source_path = 6; + + // One of the fields in the following block will be set and intend to + // describe a value for 'path' field. + oneof path_value { + // Value for the `path` field. Will be set for actions:'add'/'replace'. + // Maybe set for action: 'test'. Either this or `value_matcher` will be set + // for 'test' operation. An exact match must be performed. + google.protobuf.Value value = 7; + + // Can be set for action 'test' for advanced matching for the value of + // 'path' field. Either this or `value` will be set for 'test' operation. + ValueMatcher value_matcher = 10; + } + + // Set of filters to apply if `path` refers to array elements or nested array + // elements in order to narrow down to a single unique element that is being + // tested/modified. + // This is intended to be an exact match per filter. To perform advanced + // matching, use path_value_matchers. + // + // * Example: + // ``` + // { + // "/versions/*/name" : "it-123" + // "/versions/*/targetSize/percent": 20 + // } + // ``` + // * Example: + // ``` + // { + // "/bindings/*/role": "roles/owner" + // "/bindings/*/condition" : null + // } + // ``` + // * Example: + // ``` + // { + // "/bindings/*/role": "roles/owner" + // "/bindings/*/members/*" : ["x@example.com", "y@example.com"] + // } + // ``` + // When both path_filters and path_value_matchers are set, an implicit AND + // must be performed. + map path_filters = 8; + + // Similar to path_filters, this contains set of filters to apply if `path` + // field refers to array elements. This is meant to support value matching + // beyond exact match. To perform exact match, use path_filters. + // When both path_filters and path_value_matchers are set, an implicit AND + // must be performed. + map path_value_matchers = 11; +} + +// Contains various matching options for values for a GCP resource field. +message ValueMatcher { + oneof match_variant { + // To be used for full regex matching. The regular expression is using the + // Google RE2 syntax (https://github.com/google/re2/wiki/Syntax), so to be + // used with RE2::FullMatch + string matches_pattern = 1; + } +} + +// Contains metadata about how much money a recommendation can save or incur. +message CostProjection { + // An approximate projection on amount saved or amount incurred. Negative cost + // units indicate cost savings and positive cost units indicate increase. + // See google.type.Money documentation for positive/negative units. + // + // A user's permissions may affect whether the cost is computed using list + // prices or custom contract prices. + google.type.Money cost = 1; + + // Duration for which this cost applies. + google.protobuf.Duration duration = 2; +} + +// Contains various ways of describing the impact on Security. +message SecurityProjection { + // Additional security impact details that is provided by the recommender. + google.protobuf.Struct details = 2; +} + +// Contains the impact a recommendation can have for a given category. +message Impact { + // The category of the impact. + enum Category { + // Default unspecified category. Don't use directly. + CATEGORY_UNSPECIFIED = 0; + + // Indicates a potential increase or decrease in cost. + COST = 1; + + // Indicates a potential increase or decrease in security. + SECURITY = 2; + + // Indicates a potential increase or decrease in performance. + PERFORMANCE = 3; + + // Indicates a potential increase or decrease in manageability. + MANAGEABILITY = 4; + } + + // Category that is being targeted. + Category category = 1; + + // Contains projections (if any) for this category. + oneof projection { + // Use with CategoryType.COST + CostProjection cost_projection = 100; + + // Use with CategoryType.SECURITY + SecurityProjection security_projection = 101; + } +} + +// Information for state. Contains state and metadata. +message RecommendationStateInfo { + // Represents Recommendation State. + enum State { + // Default state. Don't use directly. + STATE_UNSPECIFIED = 0; + + // Recommendation is active and can be applied. Recommendations content can + // be updated by Google. + // + // ACTIVE recommendations can be marked as CLAIMED, SUCCEEDED, or FAILED. + ACTIVE = 1; + + // Recommendation is in claimed state. Recommendations content is + // immutable and cannot be updated by Google. + // + // CLAIMED recommendations can be marked as CLAIMED, SUCCEEDED, or FAILED. + CLAIMED = 6; + + // Recommendation is in succeeded state. Recommendations content is + // immutable and cannot be updated by Google. + // + // SUCCEEDED recommendations can be marked as SUCCEEDED, or FAILED. + SUCCEEDED = 3; + + // Recommendation is in failed state. Recommendations content is immutable + // and cannot be updated by Google. + // + // FAILED recommendations can be marked as SUCCEEDED, or FAILED. + FAILED = 4; + + // Recommendation is in dismissed state. Recommendation content can be + // updated by Google. + // + // DISMISSED recommendations can be marked as ACTIVE. + DISMISSED = 5; + } + + // The state of the recommendation, Eg ACTIVE, SUCCEEDED, FAILED. + State state = 1; + + // A map of metadata for the state, provided by user or automations systems. + map state_metadata = 2; +} diff --git a/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommender_config.proto b/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommender_config.proto new file mode 100644 index 00000000000..0e0c613b982 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommender_config.proto @@ -0,0 +1,85 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.recommender.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Recommender.V1"; +option go_package = "cloud.google.com/go/recommender/apiv1/recommenderpb;recommenderpb"; +option java_multiple_files = true; +option java_outer_classname = "RecommenderConfigProto"; +option java_package = "com.google.cloud.recommender.v1"; +option objc_class_prefix = "CREC"; + +// Configuration for a Recommender. +message RecommenderConfig { + option (google.api.resource) = { + type: "recommender.googleapis.com/RecommenderConfig" + pattern: "projects/{project}/locations/{location}/recommenders/{recommender}/config" + pattern: "organizations/{organization}/locations/{location}/recommenders/{recommender}/config" + }; + + // Name of recommender config. + // Eg, + // projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config + string name = 1; + + // RecommenderGenerationConfig which configures the Generation of + // recommendations for this recommender. + RecommenderGenerationConfig recommender_generation_config = 2; + + // Fingerprint of the RecommenderConfig. Provides optimistic locking when + // updating. + string etag = 3; + + // Last time when the config was updated. + google.protobuf.Timestamp update_time = 4; + + // Output only. Immutable. The revision ID of the config. + // A new revision is committed whenever the config is changed in any way. + // The format is an 8-character hexadecimal string. + string revision_id = 5 [ + (google.api.field_behavior) = IMMUTABLE, + (google.api.field_behavior) = OUTPUT_ONLY + ]; + + // Allows clients to store small amounts of arbitrary data. Annotations must + // follow the Kubernetes syntax. + // The total size of all keys and values combined is limited to 256k. + // Key can have 2 segments: prefix (optional) and name (required), + // separated by a slash (/). + // Prefix must be a DNS subdomain. + // Name must be 63 characters or less, begin and end with alphanumerics, + // with dashes (-), underscores (_), dots (.), and alphanumerics between. + map annotations = 6; + + // A user-settable field to provide a human-readable name to be used in user + // interfaces. + string display_name = 7; +} + +// A Configuration to customize the generation of recommendations. +// Eg, customizing the lookback period considered when generating a +// recommendation. +message RecommenderGenerationConfig { + // Parameters for this RecommenderGenerationConfig. These configs can be used + // by or are applied to all subtypes. + google.protobuf.Struct params = 1; +} diff --git a/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommender_service.proto b/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommender_service.proto new file mode 100644 index 00000000000..947687639d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommender_service.proto @@ -0,0 +1,604 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.recommender.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/recommender/v1/insight.proto"; +import "google/cloud/recommender/v1/insight_type_config.proto"; +import "google/cloud/recommender/v1/recommendation.proto"; +import "google/cloud/recommender/v1/recommender_config.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Recommender.V1"; +option go_package = "cloud.google.com/go/recommender/apiv1/recommenderpb;recommenderpb"; +option java_multiple_files = true; +option java_outer_classname = "RecommenderProto"; +option java_package = "com.google.cloud.recommender.v1"; +option objc_class_prefix = "CREC"; + +// Provides insights and recommendations for cloud customers for various +// categories like performance optimization, cost savings, reliability, feature +// discovery, etc. Insights and recommendations are generated automatically +// based on analysis of user resources, configuration and monitoring metrics. +service Recommender { + option (google.api.default_host) = "recommender.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Lists insights for the specified Cloud Resource. Requires the + // recommender.*.list IAM permission for the specified insight type. + rpc ListInsights(ListInsightsRequest) returns (ListInsightsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*/insightTypes/*}/insights" + additional_bindings { + get: "/v1/{parent=billingAccounts/*/locations/*/insightTypes/*}/insights" + } + additional_bindings { + get: "/v1/{parent=folders/*/locations/*/insightTypes/*}/insights" + } + additional_bindings { + get: "/v1/{parent=organizations/*/locations/*/insightTypes/*}/insights" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Gets the requested insight. Requires the recommender.*.get IAM permission + // for the specified insight type. + rpc GetInsight(GetInsightRequest) returns (Insight) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/insightTypes/*/insights/*}" + additional_bindings { + get: "/v1/{name=billingAccounts/*/locations/*/insightTypes/*/insights/*}" + } + additional_bindings { + get: "/v1/{name=folders/*/locations/*/insightTypes/*/insights/*}" + } + additional_bindings { + get: "/v1/{name=organizations/*/locations/*/insightTypes/*/insights/*}" + } + }; + option (google.api.method_signature) = "name"; + } + + // Marks the Insight State as Accepted. Users can use this method to + // indicate to the Recommender API that they have applied some action based + // on the insight. This stops the insight content from being updated. + // + // MarkInsightAccepted can be applied to insights in ACTIVE state. Requires + // the recommender.*.update IAM permission for the specified insight. + rpc MarkInsightAccepted(MarkInsightAcceptedRequest) returns (Insight) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/insightTypes/*/insights/*}:markAccepted" + body: "*" + additional_bindings { + post: "/v1/{name=billingAccounts/*/locations/*/insightTypes/*/insights/*}:markAccepted" + body: "*" + } + additional_bindings { + post: "/v1/{name=folders/*/locations/*/insightTypes/*/insights/*}:markAccepted" + body: "*" + } + additional_bindings { + post: "/v1/{name=organizations/*/locations/*/insightTypes/*/insights/*}:markAccepted" + body: "*" + } + }; + option (google.api.method_signature) = "name,state_metadata,etag"; + } + + // Lists recommendations for the specified Cloud Resource. Requires the + // recommender.*.list IAM permission for the specified recommender. + rpc ListRecommendations(ListRecommendationsRequest) + returns (ListRecommendationsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*/recommenders/*}/recommendations" + additional_bindings { + get: "/v1/{parent=billingAccounts/*/locations/*/recommenders/*}/recommendations" + } + additional_bindings { + get: "/v1/{parent=folders/*/locations/*/recommenders/*}/recommendations" + } + additional_bindings { + get: "/v1/{parent=organizations/*/locations/*/recommenders/*}/recommendations" + } + }; + option (google.api.method_signature) = "parent"; + option (google.api.method_signature) = "parent,filter"; + } + + // Gets the requested recommendation. Requires the recommender.*.get + // IAM permission for the specified recommender. + rpc GetRecommendation(GetRecommendationRequest) returns (Recommendation) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/recommenders/*/recommendations/*}" + additional_bindings { + get: "/v1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}" + } + additional_bindings { + get: "/v1/{name=folders/*/locations/*/recommenders/*/recommendations/*}" + } + additional_bindings { + get: "/v1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}" + } + }; + option (google.api.method_signature) = "name"; + } + + // Marks the Recommendation State as Claimed. Users can use this method to + // indicate to the Recommender API that they are starting to apply the + // recommendation themselves. This stops the recommendation content from being + // updated. Associated insights are frozen and placed in the ACCEPTED state. + // + // MarkRecommendationClaimed can be applied to recommendations in CLAIMED, + // SUCCEEDED, FAILED, or ACTIVE state. + // + // Requires the recommender.*.update IAM permission for the specified + // recommender. + rpc MarkRecommendationClaimed(MarkRecommendationClaimedRequest) + returns (Recommendation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markClaimed" + body: "*" + additional_bindings { + post: "/v1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markClaimed" + body: "*" + } + additional_bindings { + post: "/v1/{name=folders/*/locations/*/recommenders/*/recommendations/*}:markClaimed" + body: "*" + } + additional_bindings { + post: "/v1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}:markClaimed" + body: "*" + } + }; + option (google.api.method_signature) = "name,state_metadata,etag"; + } + + // Marks the Recommendation State as Succeeded. Users can use this method to + // indicate to the Recommender API that they have applied the recommendation + // themselves, and the operation was successful. This stops the recommendation + // content from being updated. Associated insights are frozen and placed in + // the ACCEPTED state. + // + // MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, + // CLAIMED, SUCCEEDED, or FAILED state. + // + // Requires the recommender.*.update IAM permission for the specified + // recommender. + rpc MarkRecommendationSucceeded(MarkRecommendationSucceededRequest) + returns (Recommendation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markSucceeded" + body: "*" + additional_bindings { + post: "/v1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markSucceeded" + body: "*" + } + additional_bindings { + post: "/v1/{name=folders/*/locations/*/recommenders/*/recommendations/*}:markSucceeded" + body: "*" + } + additional_bindings { + post: "/v1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}:markSucceeded" + body: "*" + } + }; + option (google.api.method_signature) = "name,state_metadata,etag"; + } + + // Marks the Recommendation State as Failed. Users can use this method to + // indicate to the Recommender API that they have applied the recommendation + // themselves, and the operation failed. This stops the recommendation content + // from being updated. Associated insights are frozen and placed in the + // ACCEPTED state. + // + // MarkRecommendationFailed can be applied to recommendations in ACTIVE, + // CLAIMED, SUCCEEDED, or FAILED state. + // + // Requires the recommender.*.update IAM permission for the specified + // recommender. + rpc MarkRecommendationFailed(MarkRecommendationFailedRequest) + returns (Recommendation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markFailed" + body: "*" + additional_bindings { + post: "/v1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markFailed" + body: "*" + } + additional_bindings { + post: "/v1/{name=folders/*/locations/*/recommenders/*/recommendations/*}:markFailed" + body: "*" + } + additional_bindings { + post: "/v1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}:markFailed" + body: "*" + } + }; + option (google.api.method_signature) = "name,state_metadata,etag"; + } + + // Gets the requested Recommender Config. There is only one instance of the + // config for each Recommender. + rpc GetRecommenderConfig(GetRecommenderConfigRequest) + returns (RecommenderConfig) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/recommenders/*/config}" + additional_bindings { + get: "/v1/{name=organizations/*/locations/*/recommenders/*/config}" + } + }; + option (google.api.method_signature) = "name"; + } + + // Updates a Recommender Config. This will create a new revision of the + // config. + rpc UpdateRecommenderConfig(UpdateRecommenderConfigRequest) + returns (RecommenderConfig) { + option (google.api.http) = { + patch: "/v1/{recommender_config.name=projects/*/locations/*/recommenders/*/config}" + body: "recommender_config" + additional_bindings { + patch: "/v1/{recommender_config.name=organizations/*/locations/*/recommenders/*/config}" + body: "recommender_config" + } + }; + option (google.api.method_signature) = "recommender_config,update_mask"; + } + + // Gets the requested InsightTypeConfig. There is only one instance of the + // config for each InsightType. + rpc GetInsightTypeConfig(GetInsightTypeConfigRequest) + returns (InsightTypeConfig) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/insightTypes/*/config}" + additional_bindings { + get: "/v1/{name=organizations/*/locations/*/insightTypes/*/config}" + } + }; + option (google.api.method_signature) = "name"; + } + + // Updates an InsightTypeConfig change. This will create a new revision of the + // config. + rpc UpdateInsightTypeConfig(UpdateInsightTypeConfigRequest) + returns (InsightTypeConfig) { + option (google.api.http) = { + patch: "/v1/{insight_type_config.name=projects/*/locations/*/insightTypes/*/config}" + body: "insight_type_config" + additional_bindings { + patch: "/v1/{insight_type_config.name=organizations/*/locations/*/insightTypes/*/config}" + body: "insight_type_config" + } + }; + option (google.api.method_signature) = "insight_type_config,update_mask"; + } +} + +// Request for the `ListInsights` method. +message ListInsightsRequest { + // Required. The container resource on which to execute the request. + // Acceptable formats: + // + // * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + // + // * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + // + // * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + // + // * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + // + // * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + // + // LOCATION here refers to GCP Locations: + // https://cloud.google.com/about/locations/ + // INSIGHT_TYPE_ID refers to supported insight types: + // https://cloud.google.com/recommender/docs/insights/insight-types. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recommender.googleapis.com/InsightType" + } + ]; + + // Optional. The maximum number of results to return from this request. + // Non-positive values are ignored. If not specified, the server will + // determine the number of results to return. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If present, retrieves the next batch of results from the + // preceding call to this method. `page_token` must be the value of + // `next_page_token` from the previous response. The values of other method + // parameters must be identical to those in the previous call. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Filter expression to restrict the insights returned. Supported + // filter fields: + // + // * `stateInfo.state` + // + // * `insightSubtype` + // + // * `severity` + // + // Examples: + // + // * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` + // + // * `insightSubtype = PERMISSIONS_USAGE` + // + // * `severity = CRITICAL OR severity = HIGH` + // + // * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` + // + // (These expressions are based on the filter language described at + // https://google.aip.dev/160) + string filter = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response to the `ListInsights` method. +message ListInsightsResponse { + // The set of insights for the `parent` resource. + repeated Insight insights = 1; + + // A token that can be used to request the next page of results. This field is + // empty if there are no additional results. + string next_page_token = 2; +} + +// Request to the `GetInsight` method. +message GetInsightRequest { + // Required. Name of the insight. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recommender.googleapis.com/Insight" + } + ]; +} + +// Request for the `MarkInsightAccepted` method. +message MarkInsightAcceptedRequest { + // Required. Name of the insight. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recommender.googleapis.com/Insight" + } + ]; + + // Optional. State properties user wish to include with this state. Full + // replace of the current state_metadata. + map state_metadata = 2 + [(google.api.field_behavior) = OPTIONAL]; + + // Required. Fingerprint of the Insight. Provides optimistic locking. + string etag = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for the `ListRecommendations` method. +message ListRecommendationsRequest { + // Required. The container resource on which to execute the request. + // Acceptable formats: + // + // * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + // + // * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + // + // * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + // + // * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + // + // * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + // + // LOCATION here refers to GCP Locations: + // https://cloud.google.com/about/locations/ + // RECOMMENDER_ID refers to supported recommenders: + // https://cloud.google.com/recommender/docs/recommenders. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recommender.googleapis.com/Recommender" + } + ]; + + // Optional. The maximum number of results to return from this request. + // Non-positive values are ignored. If not specified, the server will + // determine the number of results to return. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If present, retrieves the next batch of results from the + // preceding call to this method. `page_token` must be the value of + // `next_page_token` from the previous response. The values of other method + // parameters must be identical to those in the previous call. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Filter expression to restrict the recommendations returned. Supported + // filter fields: + // + // * `state_info.state` + // + // * `recommenderSubtype` + // + // * `priority` + // + // Examples: + // + // * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` + // + // * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` + // + // * `priority = P1 OR priority = P2` + // + // * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` + // + // (These expressions are based on the filter language described at + // https://google.aip.dev/160) + string filter = 5; +} + +// Response to the `ListRecommendations` method. +message ListRecommendationsResponse { + // The set of recommendations for the `parent` resource. + repeated Recommendation recommendations = 1; + + // A token that can be used to request the next page of results. This field is + // empty if there are no additional results. + string next_page_token = 2; +} + +// Request to the `GetRecommendation` method. +message GetRecommendationRequest { + // Required. Name of the recommendation. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recommender.googleapis.com/Recommendation" + } + ]; +} + +// Request for the `MarkRecommendationClaimed` Method. +message MarkRecommendationClaimedRequest { + // Required. Name of the recommendation. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recommender.googleapis.com/Recommendation" + } + ]; + + // State properties to include with this state. Overwrites any existing + // `state_metadata`. + // Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. + // Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. + map state_metadata = 2; + + // Required. Fingerprint of the Recommendation. Provides optimistic locking. + string etag = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for the `MarkRecommendationSucceeded` Method. +message MarkRecommendationSucceededRequest { + // Required. Name of the recommendation. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recommender.googleapis.com/Recommendation" + } + ]; + + // State properties to include with this state. Overwrites any existing + // `state_metadata`. + // Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. + // Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. + map state_metadata = 2; + + // Required. Fingerprint of the Recommendation. Provides optimistic locking. + string etag = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for the `MarkRecommendationFailed` Method. +message MarkRecommendationFailedRequest { + // Required. Name of the recommendation. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recommender.googleapis.com/Recommendation" + } + ]; + + // State properties to include with this state. Overwrites any existing + // `state_metadata`. + // Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. + // Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. + map state_metadata = 2; + + // Required. Fingerprint of the Recommendation. Provides optimistic locking. + string etag = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for the GetRecommenderConfig` method. +message GetRecommenderConfigRequest { + // Required. Name of the Recommendation Config to get. + // + // Acceptable formats: + // + // * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` + // + // * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` + // + // * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recommender.googleapis.com/RecommenderConfig" + } + ]; +} + +// Request for the `UpdateRecommenderConfig` method. +message UpdateRecommenderConfigRequest { + // Required. The RecommenderConfig to update. + RecommenderConfig recommender_config = 1 + [(google.api.field_behavior) = REQUIRED]; + + // The list of fields to be updated. + google.protobuf.FieldMask update_mask = 2; + + // If true, validate the request and preview the change, but do not actually + // update it. + bool validate_only = 3; +} + +// Request for the GetInsightTypeConfig` method. +message GetInsightTypeConfigRequest { + // Required. Name of the InsightTypeConfig to get. + // + // Acceptable formats: + // + // * `projects/[PROJECT_NUMBER]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` + // + // * `projects/[PROJECT_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` + // + // * `organizations/[ORGANIZATION_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recommender.googleapis.com/InsightTypeConfig" + } + ]; +} + +// Request for the `UpdateInsightTypeConfig` method. +message UpdateInsightTypeConfigRequest { + // Required. The InsightTypeConfig to update. + InsightTypeConfig insight_type_config = 1 + [(google.api.field_behavior) = REQUIRED]; + + // The list of fields to be updated. + google.protobuf.FieldMask update_mask = 2; + + // If true, validate the request and preview the change, but do not actually + // update it. + bool validate_only = 3; +} diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_insight.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_insight.js new file mode 100644 index 00000000000..1bd5f590f46 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_insight.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(name) { + // [START recommender_v1_generated_Recommender_GetInsight_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the insight. + */ + // const name = 'abc123' + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callGetInsight() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await recommenderClient.getInsight(request); + console.log(response); + } + + callGetInsight(); + // [END recommender_v1_generated_Recommender_GetInsight_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_insight_type_config.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_insight_type_config.js new file mode 100644 index 00000000000..36551fb8396 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_insight_type_config.js @@ -0,0 +1,65 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START recommender_v1_generated_Recommender_GetInsightTypeConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the InsightTypeConfig to get. + * Acceptable formats: + * * `projects/[PROJECT_NUMBER]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` + * * `projects/[PROJECT_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` + * * `organizations/[ORGANIZATION_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` + */ + // const name = 'abc123' + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callGetInsightTypeConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await recommenderClient.getInsightTypeConfig(request); + console.log(response); + } + + callGetInsightTypeConfig(); + // [END recommender_v1_generated_Recommender_GetInsightTypeConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_recommendation.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_recommendation.js new file mode 100644 index 00000000000..5e5eb1c8a7f --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_recommendation.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(name) { + // [START recommender_v1_generated_Recommender_GetRecommendation_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the recommendation. + */ + // const name = 'abc123' + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callGetRecommendation() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await recommenderClient.getRecommendation(request); + console.log(response); + } + + callGetRecommendation(); + // [END recommender_v1_generated_Recommender_GetRecommendation_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_recommender_config.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_recommender_config.js new file mode 100644 index 00000000000..f3f43e99f7c --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_recommender_config.js @@ -0,0 +1,65 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START recommender_v1_generated_Recommender_GetRecommenderConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the Recommendation Config to get. + * Acceptable formats: + * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` + * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` + */ + // const name = 'abc123' + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callGetRecommenderConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await recommenderClient.getRecommenderConfig(request); + console.log(response); + } + + callGetRecommenderConfig(); + // [END recommender_v1_generated_Recommender_GetRecommenderConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.list_insights.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.list_insights.js new file mode 100644 index 00000000000..47c9e1f056c --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.list_insights.js @@ -0,0 +1,101 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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 recommender_v1_generated_Recommender_ListInsights_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The container resource on which to execute the request. + * Acceptable formats: + * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * LOCATION here refers to GCP Locations: + * https://cloud.google.com/about/locations/ + * INSIGHT_TYPE_ID refers to supported insight types: + * https://cloud.google.com/recommender/docs/insights/insight-types. + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. If not specified, the server will + * determine the number of results to return. + */ + // const pageSize = 1234 + /** + * Optional. If present, retrieves the next batch of results from the + * preceding call to this method. `page_token` must be the value of + * `next_page_token` from the previous response. The values of other method + * parameters must be identical to those in the previous call. + */ + // const pageToken = 'abc123' + /** + * Optional. Filter expression to restrict the insights returned. Supported + * filter fields: + * * `stateInfo.state` + * * `insightSubtype` + * * `severity` + * Examples: + * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` + * * `insightSubtype = PERMISSIONS_USAGE` + * * `severity = CRITICAL OR severity = HIGH` + * * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` + * (These expressions are based on the filter language described at + * https://google.aip.dev/160) + */ + // const filter = 'abc123' + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callListInsights() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await recommenderClient.listInsightsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListInsights(); + // [END recommender_v1_generated_Recommender_ListInsights_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.list_recommendations.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.list_recommendations.js new file mode 100644 index 00000000000..c21dcc38993 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.list_recommendations.js @@ -0,0 +1,101 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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 recommender_v1_generated_Recommender_ListRecommendations_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The container resource on which to execute the request. + * Acceptable formats: + * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * LOCATION here refers to GCP Locations: + * https://cloud.google.com/about/locations/ + * RECOMMENDER_ID refers to supported recommenders: + * https://cloud.google.com/recommender/docs/recommenders. + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. If not specified, the server will + * determine the number of results to return. + */ + // const pageSize = 1234 + /** + * Optional. If present, retrieves the next batch of results from the + * preceding call to this method. `page_token` must be the value of + * `next_page_token` from the previous response. The values of other method + * parameters must be identical to those in the previous call. + */ + // const pageToken = 'abc123' + /** + * Filter expression to restrict the recommendations returned. Supported + * filter fields: + * * `state_info.state` + * * `recommenderSubtype` + * * `priority` + * Examples: + * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` + * * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` + * * `priority = P1 OR priority = P2` + * * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` + * (These expressions are based on the filter language described at + * https://google.aip.dev/160) + */ + // const filter = 'abc123' + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callListRecommendations() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await recommenderClient.listRecommendationsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListRecommendations(); + // [END recommender_v1_generated_Recommender_ListRecommendations_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_insight_accepted.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_insight_accepted.js new file mode 100644 index 00000000000..0dff5d47d9b --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_insight_accepted.js @@ -0,0 +1,71 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, etag) { + // [START recommender_v1_generated_Recommender_MarkInsightAccepted_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the insight. + */ + // const name = 'abc123' + /** + * Optional. State properties user wish to include with this state. Full + * replace of the current state_metadata. + */ + // const stateMetadata = [1,2,3,4] + /** + * Required. Fingerprint of the Insight. Provides optimistic locking. + */ + // const etag = 'abc123' + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callMarkInsightAccepted() { + // Construct request + const request = { + name, + etag, + }; + + // Run request + const response = await recommenderClient.markInsightAccepted(request); + console.log(response); + } + + callMarkInsightAccepted(); + // [END recommender_v1_generated_Recommender_MarkInsightAccepted_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_claimed.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_claimed.js new file mode 100644 index 00000000000..f3b8ffdc89a --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_claimed.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(name, etag) { + // [START recommender_v1_generated_Recommender_MarkRecommendationClaimed_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the recommendation. + */ + // const name = 'abc123' + /** + * State properties to include with this state. Overwrites any existing + * `state_metadata`. + * Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. + * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. + */ + // const stateMetadata = [1,2,3,4] + /** + * Required. Fingerprint of the Recommendation. Provides optimistic locking. + */ + // const etag = 'abc123' + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callMarkRecommendationClaimed() { + // Construct request + const request = { + name, + etag, + }; + + // Run request + const response = await recommenderClient.markRecommendationClaimed(request); + console.log(response); + } + + callMarkRecommendationClaimed(); + // [END recommender_v1_generated_Recommender_MarkRecommendationClaimed_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_failed.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_failed.js new file mode 100644 index 00000000000..129aed6e91c --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_failed.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(name, etag) { + // [START recommender_v1_generated_Recommender_MarkRecommendationFailed_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the recommendation. + */ + // const name = 'abc123' + /** + * State properties to include with this state. Overwrites any existing + * `state_metadata`. + * Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. + * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. + */ + // const stateMetadata = [1,2,3,4] + /** + * Required. Fingerprint of the Recommendation. Provides optimistic locking. + */ + // const etag = 'abc123' + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callMarkRecommendationFailed() { + // Construct request + const request = { + name, + etag, + }; + + // Run request + const response = await recommenderClient.markRecommendationFailed(request); + console.log(response); + } + + callMarkRecommendationFailed(); + // [END recommender_v1_generated_Recommender_MarkRecommendationFailed_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_succeeded.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_succeeded.js new file mode 100644 index 00000000000..aff7d9418f7 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_succeeded.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(name, etag) { + // [START recommender_v1_generated_Recommender_MarkRecommendationSucceeded_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the recommendation. + */ + // const name = 'abc123' + /** + * State properties to include with this state. Overwrites any existing + * `state_metadata`. + * Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. + * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. + */ + // const stateMetadata = [1,2,3,4] + /** + * Required. Fingerprint of the Recommendation. Provides optimistic locking. + */ + // const etag = 'abc123' + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callMarkRecommendationSucceeded() { + // Construct request + const request = { + name, + etag, + }; + + // Run request + const response = await recommenderClient.markRecommendationSucceeded(request); + console.log(response); + } + + callMarkRecommendationSucceeded(); + // [END recommender_v1_generated_Recommender_MarkRecommendationSucceeded_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.update_insight_type_config.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.update_insight_type_config.js new file mode 100644 index 00000000000..1b370d8c471 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.update_insight_type_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(insightTypeConfig) { + // [START recommender_v1_generated_Recommender_UpdateInsightTypeConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The InsightTypeConfig to update. + */ + // const insightTypeConfig = {} + /** + * The list of fields to be updated. + */ + // const updateMask = {} + /** + * If true, validate the request and preview the change, but do not actually + * update it. + */ + // const validateOnly = true + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callUpdateInsightTypeConfig() { + // Construct request + const request = { + insightTypeConfig, + }; + + // Run request + const response = await recommenderClient.updateInsightTypeConfig(request); + console.log(response); + } + + callUpdateInsightTypeConfig(); + // [END recommender_v1_generated_Recommender_UpdateInsightTypeConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.update_recommender_config.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.update_recommender_config.js new file mode 100644 index 00000000000..e4ac74aba64 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.update_recommender_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(recommenderConfig) { + // [START recommender_v1_generated_Recommender_UpdateRecommenderConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The RecommenderConfig to update. + */ + // const recommenderConfig = {} + /** + * The list of fields to be updated. + */ + // const updateMask = {} + /** + * If true, validate the request and preview the change, but do not actually + * update it. + */ + // const validateOnly = true + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callUpdateRecommenderConfig() { + // Construct request + const request = { + recommenderConfig, + }; + + // Run request + const response = await recommenderClient.updateRecommenderConfig(request); + console.log(response); + } + + callUpdateRecommenderConfig(); + // [END recommender_v1_generated_Recommender_UpdateRecommenderConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/snippet_metadata_google.cloud.recommender.v1.json b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/snippet_metadata_google.cloud.recommender.v1.json new file mode 100644 index 00000000000..23f0e88e485 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/snippet_metadata_google.cloud.recommender.v1.json @@ -0,0 +1,567 @@ +{ + "clientLibrary": { + "name": "nodejs-recommender", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.recommender.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "recommender_v1_generated_Recommender_ListInsights_async", + "title": "Recommender listInsights Sample", + "origin": "API_DEFINITION", + "description": " Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.", + "canonical": true, + "file": "recommender.list_insights.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 93, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListInsights", + "fullName": "google.cloud.recommender.v1.Recommender.ListInsights", + "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.recommender.v1.ListInsightsResponse", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1.RecommenderClient" + }, + "method": { + "shortName": "ListInsights", + "fullName": "google.cloud.recommender.v1.Recommender.ListInsights", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1_generated_Recommender_GetInsight_async", + "title": "Recommender getInsight Sample", + "origin": "API_DEFINITION", + "description": " Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.", + "canonical": true, + "file": "recommender.get_insight.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetInsight", + "fullName": "google.cloud.recommender.v1.Recommender.GetInsight", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recommender.v1.Insight", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1.RecommenderClient" + }, + "method": { + "shortName": "GetInsight", + "fullName": "google.cloud.recommender.v1.Recommender.GetInsight", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1_generated_Recommender_MarkInsightAccepted_async", + "title": "Recommender markInsightAccepted Sample", + "origin": "API_DEFINITION", + "description": " Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated. MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.", + "canonical": true, + "file": "recommender.mark_insight_accepted.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "MarkInsightAccepted", + "fullName": "google.cloud.recommender.v1.Recommender.MarkInsightAccepted", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "state_metadata", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recommender.v1.Insight", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1.RecommenderClient" + }, + "method": { + "shortName": "MarkInsightAccepted", + "fullName": "google.cloud.recommender.v1.Recommender.MarkInsightAccepted", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1_generated_Recommender_ListRecommendations_async", + "title": "Recommender listRecommendations Sample", + "origin": "API_DEFINITION", + "description": " Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.", + "canonical": true, + "file": "recommender.list_recommendations.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 93, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListRecommendations", + "fullName": "google.cloud.recommender.v1.Recommender.ListRecommendations", + "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.recommender.v1.ListRecommendationsResponse", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1.RecommenderClient" + }, + "method": { + "shortName": "ListRecommendations", + "fullName": "google.cloud.recommender.v1.Recommender.ListRecommendations", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1_generated_Recommender_GetRecommendation_async", + "title": "Recommender getRecommendation Sample", + "origin": "API_DEFINITION", + "description": " Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.", + "canonical": true, + "file": "recommender.get_recommendation.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetRecommendation", + "fullName": "google.cloud.recommender.v1.Recommender.GetRecommendation", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recommender.v1.Recommendation", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1.RecommenderClient" + }, + "method": { + "shortName": "GetRecommendation", + "fullName": "google.cloud.recommender.v1.Recommender.GetRecommendation", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1_generated_Recommender_MarkRecommendationClaimed_async", + "title": "Recommender markRecommendationClaimed Sample", + "origin": "API_DEFINITION", + "description": " Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationClaimed can be applied to recommendations in CLAIMED, SUCCEEDED, FAILED, or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.", + "canonical": true, + "file": "recommender.mark_recommendation_claimed.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "MarkRecommendationClaimed", + "fullName": "google.cloud.recommender.v1.Recommender.MarkRecommendationClaimed", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "state_metadata", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recommender.v1.Recommendation", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1.RecommenderClient" + }, + "method": { + "shortName": "MarkRecommendationClaimed", + "fullName": "google.cloud.recommender.v1.Recommender.MarkRecommendationClaimed", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1_generated_Recommender_MarkRecommendationSucceeded_async", + "title": "Recommender markRecommendationSucceeded Sample", + "origin": "API_DEFINITION", + "description": " Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.", + "canonical": true, + "file": "recommender.mark_recommendation_succeeded.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "MarkRecommendationSucceeded", + "fullName": "google.cloud.recommender.v1.Recommender.MarkRecommendationSucceeded", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "state_metadata", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recommender.v1.Recommendation", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1.RecommenderClient" + }, + "method": { + "shortName": "MarkRecommendationSucceeded", + "fullName": "google.cloud.recommender.v1.Recommender.MarkRecommendationSucceeded", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1_generated_Recommender_MarkRecommendationFailed_async", + "title": "Recommender markRecommendationFailed Sample", + "origin": "API_DEFINITION", + "description": " Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.", + "canonical": true, + "file": "recommender.mark_recommendation_failed.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "MarkRecommendationFailed", + "fullName": "google.cloud.recommender.v1.Recommender.MarkRecommendationFailed", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "state_metadata", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recommender.v1.Recommendation", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1.RecommenderClient" + }, + "method": { + "shortName": "MarkRecommendationFailed", + "fullName": "google.cloud.recommender.v1.Recommender.MarkRecommendationFailed", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1_generated_Recommender_GetRecommenderConfig_async", + "title": "Recommender getRecommenderConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets the requested Recommender Config. There is only one instance of the config for each Recommender.", + "canonical": true, + "file": "recommender.get_recommender_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetRecommenderConfig", + "fullName": "google.cloud.recommender.v1.Recommender.GetRecommenderConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recommender.v1.RecommenderConfig", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1.RecommenderClient" + }, + "method": { + "shortName": "GetRecommenderConfig", + "fullName": "google.cloud.recommender.v1.Recommender.GetRecommenderConfig", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1_generated_Recommender_UpdateRecommenderConfig_async", + "title": "Recommender updateRecommenderConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates a Recommender Config. This will create a new revision of the config.", + "canonical": true, + "file": "recommender.update_recommender_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateRecommenderConfig", + "fullName": "google.cloud.recommender.v1.Recommender.UpdateRecommenderConfig", + "async": true, + "parameters": [ + { + "name": "recommender_config", + "type": ".google.cloud.recommender.v1.RecommenderConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.recommender.v1.RecommenderConfig", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1.RecommenderClient" + }, + "method": { + "shortName": "UpdateRecommenderConfig", + "fullName": "google.cloud.recommender.v1.Recommender.UpdateRecommenderConfig", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1_generated_Recommender_GetInsightTypeConfig_async", + "title": "Recommender getInsightTypeConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.", + "canonical": true, + "file": "recommender.get_insight_type_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetInsightTypeConfig", + "fullName": "google.cloud.recommender.v1.Recommender.GetInsightTypeConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recommender.v1.InsightTypeConfig", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1.RecommenderClient" + }, + "method": { + "shortName": "GetInsightTypeConfig", + "fullName": "google.cloud.recommender.v1.Recommender.GetInsightTypeConfig", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1_generated_Recommender_UpdateInsightTypeConfig_async", + "title": "Recommender updateInsightTypeConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates an InsightTypeConfig change. This will create a new revision of the config.", + "canonical": true, + "file": "recommender.update_insight_type_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateInsightTypeConfig", + "fullName": "google.cloud.recommender.v1.Recommender.UpdateInsightTypeConfig", + "async": true, + "parameters": [ + { + "name": "insight_type_config", + "type": ".google.cloud.recommender.v1.InsightTypeConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.recommender.v1.InsightTypeConfig", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1.RecommenderClient" + }, + "method": { + "shortName": "UpdateInsightTypeConfig", + "fullName": "google.cloud.recommender.v1.Recommender.UpdateInsightTypeConfig", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1.Recommender" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-recommender/v1/src/index.ts b/owl-bot-staging/google-cloud-recommender/v1/src/index.ts new file mode 100644 index 00000000000..9b1977ca960 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const RecommenderClient = v1.RecommenderClient; +type RecommenderClient = v1.RecommenderClient; +export {v1, RecommenderClient}; +export default {v1, RecommenderClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-recommender/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-recommender/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..ac3dc26d8b6 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/src/v1/gapic_metadata.json @@ -0,0 +1,151 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.recommender.v1", + "libraryPackage": "@google-cloud/recommender", + "services": { + "Recommender": { + "clients": { + "grpc": { + "libraryClient": "RecommenderClient", + "rpcs": { + "GetInsight": { + "methods": [ + "getInsight" + ] + }, + "MarkInsightAccepted": { + "methods": [ + "markInsightAccepted" + ] + }, + "GetRecommendation": { + "methods": [ + "getRecommendation" + ] + }, + "MarkRecommendationClaimed": { + "methods": [ + "markRecommendationClaimed" + ] + }, + "MarkRecommendationSucceeded": { + "methods": [ + "markRecommendationSucceeded" + ] + }, + "MarkRecommendationFailed": { + "methods": [ + "markRecommendationFailed" + ] + }, + "GetRecommenderConfig": { + "methods": [ + "getRecommenderConfig" + ] + }, + "UpdateRecommenderConfig": { + "methods": [ + "updateRecommenderConfig" + ] + }, + "GetInsightTypeConfig": { + "methods": [ + "getInsightTypeConfig" + ] + }, + "UpdateInsightTypeConfig": { + "methods": [ + "updateInsightTypeConfig" + ] + }, + "ListInsights": { + "methods": [ + "listInsights", + "listInsightsStream", + "listInsightsAsync" + ] + }, + "ListRecommendations": { + "methods": [ + "listRecommendations", + "listRecommendationsStream", + "listRecommendationsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RecommenderClient", + "rpcs": { + "GetInsight": { + "methods": [ + "getInsight" + ] + }, + "MarkInsightAccepted": { + "methods": [ + "markInsightAccepted" + ] + }, + "GetRecommendation": { + "methods": [ + "getRecommendation" + ] + }, + "MarkRecommendationClaimed": { + "methods": [ + "markRecommendationClaimed" + ] + }, + "MarkRecommendationSucceeded": { + "methods": [ + "markRecommendationSucceeded" + ] + }, + "MarkRecommendationFailed": { + "methods": [ + "markRecommendationFailed" + ] + }, + "GetRecommenderConfig": { + "methods": [ + "getRecommenderConfig" + ] + }, + "UpdateRecommenderConfig": { + "methods": [ + "updateRecommenderConfig" + ] + }, + "GetInsightTypeConfig": { + "methods": [ + "getInsightTypeConfig" + ] + }, + "UpdateInsightTypeConfig": { + "methods": [ + "updateInsightTypeConfig" + ] + }, + "ListInsights": { + "methods": [ + "listInsights", + "listInsightsStream", + "listInsightsAsync" + ] + }, + "ListRecommendations": { + "methods": [ + "listRecommendations", + "listRecommendationsStream", + "listRecommendationsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-recommender/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-recommender/v1/src/v1/index.ts new file mode 100644 index 00000000000..fbe6584bdf2 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {RecommenderClient} from './recommender_client'; diff --git a/owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_client.ts b/owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_client.ts new file mode 100644 index 00000000000..cc25dbaa309 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_client.ts @@ -0,0 +1,2866 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/recommender_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './recommender_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Provides insights and recommendations for cloud customers for various + * categories like performance optimization, cost savings, reliability, feature + * discovery, etc. Insights and recommendations are generated automatically + * based on analysis of user resources, configuration and monitoring metrics. + * @class + * @memberof v1 + */ +export class RecommenderClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + recommenderStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RecommenderClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 RecommenderClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RecommenderClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + billingAccountLocationInsightTypePathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}' + ), + billingAccountLocationInsightTypeInsightPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}/insights/{insight}' + ), + billingAccountLocationRecommenderPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}' + ), + billingAccountLocationRecommenderRecommendationPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}' + ), + folderLocationInsightTypePathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/locations/{location}/insightTypes/{insight_type}' + ), + folderLocationInsightTypeInsightPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/locations/{location}/insightTypes/{insight_type}/insights/{insight}' + ), + folderLocationRecommenderPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/locations/{location}/recommenders/{recommender}' + ), + folderLocationRecommenderRecommendationPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}' + ), + organizationLocationInsightTypePathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/insightTypes/{insight_type}' + ), + organizationLocationInsightTypeConfigPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/insightTypes/{insight_type}/config' + ), + organizationLocationInsightTypeInsightPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/insightTypes/{insight_type}/insights/{insight}' + ), + organizationLocationRecommenderPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/recommenders/{recommender}' + ), + organizationLocationRecommenderConfigPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/recommenders/{recommender}/config' + ), + organizationLocationRecommenderRecommendationPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}' + ), + projectLocationInsightTypePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/insightTypes/{insight_type}' + ), + projectLocationInsightTypeConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/insightTypes/{insight_type}/config' + ), + projectLocationInsightTypeInsightPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/insightTypes/{insight_type}/insights/{insight}' + ), + projectLocationRecommenderPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/recommenders/{recommender}' + ), + projectLocationRecommenderConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/recommenders/{recommender}/config' + ), + projectLocationRecommenderRecommendationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}' + ), + }; + + // 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 = { + listInsights: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'insights'), + listRecommendations: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'recommendations') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.recommender.v1.Recommender', 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.recommenderStub) { + return this.recommenderStub; + } + + // Put together the "service stub" for + // google.cloud.recommender.v1.Recommender. + this.recommenderStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.recommender.v1.Recommender') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.recommender.v1.Recommender, + 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 recommenderStubMethods = + ['listInsights', 'getInsight', 'markInsightAccepted', 'listRecommendations', 'getRecommendation', 'markRecommendationClaimed', 'markRecommendationSucceeded', 'markRecommendationFailed', 'getRecommenderConfig', 'updateRecommenderConfig', 'getInsightTypeConfig', 'updateInsightTypeConfig']; + for (const methodName of recommenderStubMethods) { + const callPromise = this.recommenderStub.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.recommenderStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'recommender.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 'recommender.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 the requested insight. Requires the recommender.*.get IAM permission + * for the specified insight type. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the insight. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1.Insight|Insight}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recommender.get_insight.js + * region_tag:recommender_v1_generated_Recommender_GetInsight_async + */ + getInsight( + request?: protos.google.cloud.recommender.v1.IGetInsightRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1.IInsight, + protos.google.cloud.recommender.v1.IGetInsightRequest|undefined, {}|undefined + ]>; + getInsight( + request: protos.google.cloud.recommender.v1.IGetInsightRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recommender.v1.IInsight, + protos.google.cloud.recommender.v1.IGetInsightRequest|null|undefined, + {}|null|undefined>): void; + getInsight( + request: protos.google.cloud.recommender.v1.IGetInsightRequest, + callback: Callback< + protos.google.cloud.recommender.v1.IInsight, + protos.google.cloud.recommender.v1.IGetInsightRequest|null|undefined, + {}|null|undefined>): void; + getInsight( + request?: protos.google.cloud.recommender.v1.IGetInsightRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recommender.v1.IInsight, + protos.google.cloud.recommender.v1.IGetInsightRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recommender.v1.IInsight, + protos.google.cloud.recommender.v1.IGetInsightRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recommender.v1.IInsight, + protos.google.cloud.recommender.v1.IGetInsightRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getInsight(request, options, callback); + } +/** + * Marks the Insight State as Accepted. Users can use this method to + * indicate to the Recommender API that they have applied some action based + * on the insight. This stops the insight content from being updated. + * + * MarkInsightAccepted can be applied to insights in ACTIVE state. Requires + * the recommender.*.update IAM permission for the specified insight. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the insight. + * @param {number[]} [request.stateMetadata] + * Optional. State properties user wish to include with this state. Full + * replace of the current state_metadata. + * @param {string} request.etag + * Required. Fingerprint of the Insight. Provides optimistic locking. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1.Insight|Insight}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recommender.mark_insight_accepted.js + * region_tag:recommender_v1_generated_Recommender_MarkInsightAccepted_async + */ + markInsightAccepted( + request?: protos.google.cloud.recommender.v1.IMarkInsightAcceptedRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1.IInsight, + protos.google.cloud.recommender.v1.IMarkInsightAcceptedRequest|undefined, {}|undefined + ]>; + markInsightAccepted( + request: protos.google.cloud.recommender.v1.IMarkInsightAcceptedRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recommender.v1.IInsight, + protos.google.cloud.recommender.v1.IMarkInsightAcceptedRequest|null|undefined, + {}|null|undefined>): void; + markInsightAccepted( + request: protos.google.cloud.recommender.v1.IMarkInsightAcceptedRequest, + callback: Callback< + protos.google.cloud.recommender.v1.IInsight, + protos.google.cloud.recommender.v1.IMarkInsightAcceptedRequest|null|undefined, + {}|null|undefined>): void; + markInsightAccepted( + request?: protos.google.cloud.recommender.v1.IMarkInsightAcceptedRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recommender.v1.IInsight, + protos.google.cloud.recommender.v1.IMarkInsightAcceptedRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recommender.v1.IInsight, + protos.google.cloud.recommender.v1.IMarkInsightAcceptedRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recommender.v1.IInsight, + protos.google.cloud.recommender.v1.IMarkInsightAcceptedRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.markInsightAccepted(request, options, callback); + } +/** + * Gets the requested recommendation. Requires the recommender.*.get + * IAM permission for the specified recommender. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the recommendation. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1.Recommendation|Recommendation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recommender.get_recommendation.js + * region_tag:recommender_v1_generated_Recommender_GetRecommendation_async + */ + getRecommendation( + request?: protos.google.cloud.recommender.v1.IGetRecommendationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IGetRecommendationRequest|undefined, {}|undefined + ]>; + getRecommendation( + request: protos.google.cloud.recommender.v1.IGetRecommendationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IGetRecommendationRequest|null|undefined, + {}|null|undefined>): void; + getRecommendation( + request: protos.google.cloud.recommender.v1.IGetRecommendationRequest, + callback: Callback< + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IGetRecommendationRequest|null|undefined, + {}|null|undefined>): void; + getRecommendation( + request?: protos.google.cloud.recommender.v1.IGetRecommendationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IGetRecommendationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IGetRecommendationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IGetRecommendationRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getRecommendation(request, options, callback); + } +/** + * Marks the Recommendation State as Claimed. Users can use this method to + * indicate to the Recommender API that they are starting to apply the + * recommendation themselves. This stops the recommendation content from being + * updated. Associated insights are frozen and placed in the ACCEPTED state. + * + * MarkRecommendationClaimed can be applied to recommendations in CLAIMED, + * SUCCEEDED, FAILED, or ACTIVE state. + * + * Requires the recommender.*.update IAM permission for the specified + * recommender. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the recommendation. + * @param {number[]} request.stateMetadata + * State properties to include with this state. Overwrites any existing + * `state_metadata`. + * Keys must match the regex `/^{@link protos.a-z0-9_.-|a-z0-9}{0,62}$/`. + * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. + * @param {string} request.etag + * Required. Fingerprint of the Recommendation. Provides optimistic locking. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1.Recommendation|Recommendation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recommender.mark_recommendation_claimed.js + * region_tag:recommender_v1_generated_Recommender_MarkRecommendationClaimed_async + */ + markRecommendationClaimed( + request?: protos.google.cloud.recommender.v1.IMarkRecommendationClaimedRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IMarkRecommendationClaimedRequest|undefined, {}|undefined + ]>; + markRecommendationClaimed( + request: protos.google.cloud.recommender.v1.IMarkRecommendationClaimedRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IMarkRecommendationClaimedRequest|null|undefined, + {}|null|undefined>): void; + markRecommendationClaimed( + request: protos.google.cloud.recommender.v1.IMarkRecommendationClaimedRequest, + callback: Callback< + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IMarkRecommendationClaimedRequest|null|undefined, + {}|null|undefined>): void; + markRecommendationClaimed( + request?: protos.google.cloud.recommender.v1.IMarkRecommendationClaimedRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IMarkRecommendationClaimedRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IMarkRecommendationClaimedRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IMarkRecommendationClaimedRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.markRecommendationClaimed(request, options, callback); + } +/** + * Marks the Recommendation State as Succeeded. Users can use this method to + * indicate to the Recommender API that they have applied the recommendation + * themselves, and the operation was successful. This stops the recommendation + * content from being updated. Associated insights are frozen and placed in + * the ACCEPTED state. + * + * MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, + * CLAIMED, SUCCEEDED, or FAILED state. + * + * Requires the recommender.*.update IAM permission for the specified + * recommender. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the recommendation. + * @param {number[]} request.stateMetadata + * State properties to include with this state. Overwrites any existing + * `state_metadata`. + * Keys must match the regex `/^{@link protos.a-z0-9_.-|a-z0-9}{0,62}$/`. + * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. + * @param {string} request.etag + * Required. Fingerprint of the Recommendation. Provides optimistic locking. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1.Recommendation|Recommendation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recommender.mark_recommendation_succeeded.js + * region_tag:recommender_v1_generated_Recommender_MarkRecommendationSucceeded_async + */ + markRecommendationSucceeded( + request?: protos.google.cloud.recommender.v1.IMarkRecommendationSucceededRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IMarkRecommendationSucceededRequest|undefined, {}|undefined + ]>; + markRecommendationSucceeded( + request: protos.google.cloud.recommender.v1.IMarkRecommendationSucceededRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IMarkRecommendationSucceededRequest|null|undefined, + {}|null|undefined>): void; + markRecommendationSucceeded( + request: protos.google.cloud.recommender.v1.IMarkRecommendationSucceededRequest, + callback: Callback< + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IMarkRecommendationSucceededRequest|null|undefined, + {}|null|undefined>): void; + markRecommendationSucceeded( + request?: protos.google.cloud.recommender.v1.IMarkRecommendationSucceededRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IMarkRecommendationSucceededRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IMarkRecommendationSucceededRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IMarkRecommendationSucceededRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.markRecommendationSucceeded(request, options, callback); + } +/** + * Marks the Recommendation State as Failed. Users can use this method to + * indicate to the Recommender API that they have applied the recommendation + * themselves, and the operation failed. This stops the recommendation content + * from being updated. Associated insights are frozen and placed in the + * ACCEPTED state. + * + * MarkRecommendationFailed can be applied to recommendations in ACTIVE, + * CLAIMED, SUCCEEDED, or FAILED state. + * + * Requires the recommender.*.update IAM permission for the specified + * recommender. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the recommendation. + * @param {number[]} request.stateMetadata + * State properties to include with this state. Overwrites any existing + * `state_metadata`. + * Keys must match the regex `/^{@link protos.a-z0-9_.-|a-z0-9}{0,62}$/`. + * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. + * @param {string} request.etag + * Required. Fingerprint of the Recommendation. Provides optimistic locking. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1.Recommendation|Recommendation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recommender.mark_recommendation_failed.js + * region_tag:recommender_v1_generated_Recommender_MarkRecommendationFailed_async + */ + markRecommendationFailed( + request?: protos.google.cloud.recommender.v1.IMarkRecommendationFailedRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IMarkRecommendationFailedRequest|undefined, {}|undefined + ]>; + markRecommendationFailed( + request: protos.google.cloud.recommender.v1.IMarkRecommendationFailedRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IMarkRecommendationFailedRequest|null|undefined, + {}|null|undefined>): void; + markRecommendationFailed( + request: protos.google.cloud.recommender.v1.IMarkRecommendationFailedRequest, + callback: Callback< + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IMarkRecommendationFailedRequest|null|undefined, + {}|null|undefined>): void; + markRecommendationFailed( + request?: protos.google.cloud.recommender.v1.IMarkRecommendationFailedRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IMarkRecommendationFailedRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IMarkRecommendationFailedRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recommender.v1.IRecommendation, + protos.google.cloud.recommender.v1.IMarkRecommendationFailedRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.markRecommendationFailed(request, options, callback); + } +/** + * Gets the requested Recommender Config. There is only one instance of the + * config for each Recommender. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the Recommendation Config to get. + * + * Acceptable formats: + * + * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` + * + * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` + * + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/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 protos.google.cloud.recommender.v1.RecommenderConfig|RecommenderConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recommender.get_recommender_config.js + * region_tag:recommender_v1_generated_Recommender_GetRecommenderConfig_async + */ + getRecommenderConfig( + request?: protos.google.cloud.recommender.v1.IGetRecommenderConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1.IRecommenderConfig, + protos.google.cloud.recommender.v1.IGetRecommenderConfigRequest|undefined, {}|undefined + ]>; + getRecommenderConfig( + request: protos.google.cloud.recommender.v1.IGetRecommenderConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recommender.v1.IRecommenderConfig, + protos.google.cloud.recommender.v1.IGetRecommenderConfigRequest|null|undefined, + {}|null|undefined>): void; + getRecommenderConfig( + request: protos.google.cloud.recommender.v1.IGetRecommenderConfigRequest, + callback: Callback< + protos.google.cloud.recommender.v1.IRecommenderConfig, + protos.google.cloud.recommender.v1.IGetRecommenderConfigRequest|null|undefined, + {}|null|undefined>): void; + getRecommenderConfig( + request?: protos.google.cloud.recommender.v1.IGetRecommenderConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recommender.v1.IRecommenderConfig, + protos.google.cloud.recommender.v1.IGetRecommenderConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recommender.v1.IRecommenderConfig, + protos.google.cloud.recommender.v1.IGetRecommenderConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recommender.v1.IRecommenderConfig, + protos.google.cloud.recommender.v1.IGetRecommenderConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getRecommenderConfig(request, options, callback); + } +/** + * Updates a Recommender Config. This will create a new revision of the + * config. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.recommender.v1.RecommenderConfig} request.recommenderConfig + * Required. The RecommenderConfig to update. + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields to be updated. + * @param {boolean} request.validateOnly + * If true, validate the request and preview the change, but do not actually + * update it. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1.RecommenderConfig|RecommenderConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recommender.update_recommender_config.js + * region_tag:recommender_v1_generated_Recommender_UpdateRecommenderConfig_async + */ + updateRecommenderConfig( + request?: protos.google.cloud.recommender.v1.IUpdateRecommenderConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1.IRecommenderConfig, + protos.google.cloud.recommender.v1.IUpdateRecommenderConfigRequest|undefined, {}|undefined + ]>; + updateRecommenderConfig( + request: protos.google.cloud.recommender.v1.IUpdateRecommenderConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recommender.v1.IRecommenderConfig, + protos.google.cloud.recommender.v1.IUpdateRecommenderConfigRequest|null|undefined, + {}|null|undefined>): void; + updateRecommenderConfig( + request: protos.google.cloud.recommender.v1.IUpdateRecommenderConfigRequest, + callback: Callback< + protos.google.cloud.recommender.v1.IRecommenderConfig, + protos.google.cloud.recommender.v1.IUpdateRecommenderConfigRequest|null|undefined, + {}|null|undefined>): void; + updateRecommenderConfig( + request?: protos.google.cloud.recommender.v1.IUpdateRecommenderConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recommender.v1.IRecommenderConfig, + protos.google.cloud.recommender.v1.IUpdateRecommenderConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recommender.v1.IRecommenderConfig, + protos.google.cloud.recommender.v1.IUpdateRecommenderConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recommender.v1.IRecommenderConfig, + protos.google.cloud.recommender.v1.IUpdateRecommenderConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'recommender_config.name': request.recommenderConfig!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateRecommenderConfig(request, options, callback); + } +/** + * Gets the requested InsightTypeConfig. There is only one instance of the + * config for each InsightType. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the InsightTypeConfig to get. + * + * Acceptable formats: + * + * * `projects/[PROJECT_NUMBER]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` + * + * * `projects/[PROJECT_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` + * + * * `organizations/[ORGANIZATION_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/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 protos.google.cloud.recommender.v1.InsightTypeConfig|InsightTypeConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recommender.get_insight_type_config.js + * region_tag:recommender_v1_generated_Recommender_GetInsightTypeConfig_async + */ + getInsightTypeConfig( + request?: protos.google.cloud.recommender.v1.IGetInsightTypeConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1.IInsightTypeConfig, + protos.google.cloud.recommender.v1.IGetInsightTypeConfigRequest|undefined, {}|undefined + ]>; + getInsightTypeConfig( + request: protos.google.cloud.recommender.v1.IGetInsightTypeConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recommender.v1.IInsightTypeConfig, + protos.google.cloud.recommender.v1.IGetInsightTypeConfigRequest|null|undefined, + {}|null|undefined>): void; + getInsightTypeConfig( + request: protos.google.cloud.recommender.v1.IGetInsightTypeConfigRequest, + callback: Callback< + protos.google.cloud.recommender.v1.IInsightTypeConfig, + protos.google.cloud.recommender.v1.IGetInsightTypeConfigRequest|null|undefined, + {}|null|undefined>): void; + getInsightTypeConfig( + request?: protos.google.cloud.recommender.v1.IGetInsightTypeConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recommender.v1.IInsightTypeConfig, + protos.google.cloud.recommender.v1.IGetInsightTypeConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recommender.v1.IInsightTypeConfig, + protos.google.cloud.recommender.v1.IGetInsightTypeConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recommender.v1.IInsightTypeConfig, + protos.google.cloud.recommender.v1.IGetInsightTypeConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getInsightTypeConfig(request, options, callback); + } +/** + * Updates an InsightTypeConfig change. This will create a new revision of the + * config. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.recommender.v1.InsightTypeConfig} request.insightTypeConfig + * Required. The InsightTypeConfig to update. + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields to be updated. + * @param {boolean} request.validateOnly + * If true, validate the request and preview the change, but do not actually + * update it. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1.InsightTypeConfig|InsightTypeConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recommender.update_insight_type_config.js + * region_tag:recommender_v1_generated_Recommender_UpdateInsightTypeConfig_async + */ + updateInsightTypeConfig( + request?: protos.google.cloud.recommender.v1.IUpdateInsightTypeConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1.IInsightTypeConfig, + protos.google.cloud.recommender.v1.IUpdateInsightTypeConfigRequest|undefined, {}|undefined + ]>; + updateInsightTypeConfig( + request: protos.google.cloud.recommender.v1.IUpdateInsightTypeConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recommender.v1.IInsightTypeConfig, + protos.google.cloud.recommender.v1.IUpdateInsightTypeConfigRequest|null|undefined, + {}|null|undefined>): void; + updateInsightTypeConfig( + request: protos.google.cloud.recommender.v1.IUpdateInsightTypeConfigRequest, + callback: Callback< + protos.google.cloud.recommender.v1.IInsightTypeConfig, + protos.google.cloud.recommender.v1.IUpdateInsightTypeConfigRequest|null|undefined, + {}|null|undefined>): void; + updateInsightTypeConfig( + request?: protos.google.cloud.recommender.v1.IUpdateInsightTypeConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recommender.v1.IInsightTypeConfig, + protos.google.cloud.recommender.v1.IUpdateInsightTypeConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recommender.v1.IInsightTypeConfig, + protos.google.cloud.recommender.v1.IUpdateInsightTypeConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recommender.v1.IInsightTypeConfig, + protos.google.cloud.recommender.v1.IUpdateInsightTypeConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'insight_type_config.name': request.insightTypeConfig!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateInsightTypeConfig(request, options, callback); + } + + /** + * Lists insights for the specified Cloud Resource. Requires the + * recommender.*.list IAM permission for the specified insight type. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The container resource on which to execute the request. + * Acceptable formats: + * + * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * LOCATION here refers to GCP Locations: + * https://cloud.google.com/about/locations/ + * INSIGHT_TYPE_ID refers to supported insight types: + * https://cloud.google.com/recommender/docs/insights/insight-types. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. If not specified, the server will + * determine the number of results to return. + * @param {string} [request.pageToken] + * Optional. If present, retrieves the next batch of results from the + * preceding call to this method. `page_token` must be the value of + * `next_page_token` from the previous response. The values of other method + * parameters must be identical to those in the previous call. + * @param {string} [request.filter] + * Optional. Filter expression to restrict the insights returned. Supported + * filter fields: + * + * * `stateInfo.state` + * + * * `insightSubtype` + * + * * `severity` + * + * Examples: + * + * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` + * + * * `insightSubtype = PERMISSIONS_USAGE` + * + * * `severity = CRITICAL OR severity = HIGH` + * + * * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` + * + * (These expressions are based on the filter language described at + * https://google.aip.dev/160) + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.recommender.v1.Insight|Insight}. + * 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 `listInsightsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listInsights( + request?: protos.google.cloud.recommender.v1.IListInsightsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1.IInsight[], + protos.google.cloud.recommender.v1.IListInsightsRequest|null, + protos.google.cloud.recommender.v1.IListInsightsResponse + ]>; + listInsights( + request: protos.google.cloud.recommender.v1.IListInsightsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.recommender.v1.IListInsightsRequest, + protos.google.cloud.recommender.v1.IListInsightsResponse|null|undefined, + protos.google.cloud.recommender.v1.IInsight>): void; + listInsights( + request: protos.google.cloud.recommender.v1.IListInsightsRequest, + callback: PaginationCallback< + protos.google.cloud.recommender.v1.IListInsightsRequest, + protos.google.cloud.recommender.v1.IListInsightsResponse|null|undefined, + protos.google.cloud.recommender.v1.IInsight>): void; + listInsights( + request?: protos.google.cloud.recommender.v1.IListInsightsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.recommender.v1.IListInsightsRequest, + protos.google.cloud.recommender.v1.IListInsightsResponse|null|undefined, + protos.google.cloud.recommender.v1.IInsight>, + callback?: PaginationCallback< + protos.google.cloud.recommender.v1.IListInsightsRequest, + protos.google.cloud.recommender.v1.IListInsightsResponse|null|undefined, + protos.google.cloud.recommender.v1.IInsight>): + Promise<[ + protos.google.cloud.recommender.v1.IInsight[], + protos.google.cloud.recommender.v1.IListInsightsRequest|null, + protos.google.cloud.recommender.v1.IListInsightsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listInsights(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 container resource on which to execute the request. + * Acceptable formats: + * + * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * LOCATION here refers to GCP Locations: + * https://cloud.google.com/about/locations/ + * INSIGHT_TYPE_ID refers to supported insight types: + * https://cloud.google.com/recommender/docs/insights/insight-types. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. If not specified, the server will + * determine the number of results to return. + * @param {string} [request.pageToken] + * Optional. If present, retrieves the next batch of results from the + * preceding call to this method. `page_token` must be the value of + * `next_page_token` from the previous response. The values of other method + * parameters must be identical to those in the previous call. + * @param {string} [request.filter] + * Optional. Filter expression to restrict the insights returned. Supported + * filter fields: + * + * * `stateInfo.state` + * + * * `insightSubtype` + * + * * `severity` + * + * Examples: + * + * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` + * + * * `insightSubtype = PERMISSIONS_USAGE` + * + * * `severity = CRITICAL OR severity = HIGH` + * + * * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` + * + * (These expressions are based on the filter language described at + * https://google.aip.dev/160) + * @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 protos.google.cloud.recommender.v1.Insight|Insight} 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 `listInsightsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listInsightsStream( + request?: protos.google.cloud.recommender.v1.IListInsightsRequest, + 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['listInsights']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInsights.createStream( + this.innerApiCalls.listInsights as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listInsights`, 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 container resource on which to execute the request. + * Acceptable formats: + * + * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * LOCATION here refers to GCP Locations: + * https://cloud.google.com/about/locations/ + * INSIGHT_TYPE_ID refers to supported insight types: + * https://cloud.google.com/recommender/docs/insights/insight-types. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. If not specified, the server will + * determine the number of results to return. + * @param {string} [request.pageToken] + * Optional. If present, retrieves the next batch of results from the + * preceding call to this method. `page_token` must be the value of + * `next_page_token` from the previous response. The values of other method + * parameters must be identical to those in the previous call. + * @param {string} [request.filter] + * Optional. Filter expression to restrict the insights returned. Supported + * filter fields: + * + * * `stateInfo.state` + * + * * `insightSubtype` + * + * * `severity` + * + * Examples: + * + * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` + * + * * `insightSubtype = PERMISSIONS_USAGE` + * + * * `severity = CRITICAL OR severity = HIGH` + * + * * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` + * + * (These expressions are based on the filter language described at + * https://google.aip.dev/160) + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.recommender.v1.Insight|Insight}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recommender.list_insights.js + * region_tag:recommender_v1_generated_Recommender_ListInsights_async + */ + listInsightsAsync( + request?: protos.google.cloud.recommender.v1.IListInsightsRequest, + 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['listInsights']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInsights.asyncIterate( + this.innerApiCalls['listInsights'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists recommendations for the specified Cloud Resource. Requires the + * recommender.*.list IAM permission for the specified recommender. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The container resource on which to execute the request. + * Acceptable formats: + * + * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * LOCATION here refers to GCP Locations: + * https://cloud.google.com/about/locations/ + * RECOMMENDER_ID refers to supported recommenders: + * https://cloud.google.com/recommender/docs/recommenders. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. If not specified, the server will + * determine the number of results to return. + * @param {string} [request.pageToken] + * Optional. If present, retrieves the next batch of results from the + * preceding call to this method. `page_token` must be the value of + * `next_page_token` from the previous response. The values of other method + * parameters must be identical to those in the previous call. + * @param {string} request.filter + * Filter expression to restrict the recommendations returned. Supported + * filter fields: + * + * * `state_info.state` + * + * * `recommenderSubtype` + * + * * `priority` + * + * Examples: + * + * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` + * + * * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` + * + * * `priority = P1 OR priority = P2` + * + * * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` + * + * (These expressions are based on the filter language described at + * https://google.aip.dev/160) + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.recommender.v1.Recommendation|Recommendation}. + * 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 `listRecommendationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listRecommendations( + request?: protos.google.cloud.recommender.v1.IListRecommendationsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1.IRecommendation[], + protos.google.cloud.recommender.v1.IListRecommendationsRequest|null, + protos.google.cloud.recommender.v1.IListRecommendationsResponse + ]>; + listRecommendations( + request: protos.google.cloud.recommender.v1.IListRecommendationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.recommender.v1.IListRecommendationsRequest, + protos.google.cloud.recommender.v1.IListRecommendationsResponse|null|undefined, + protos.google.cloud.recommender.v1.IRecommendation>): void; + listRecommendations( + request: protos.google.cloud.recommender.v1.IListRecommendationsRequest, + callback: PaginationCallback< + protos.google.cloud.recommender.v1.IListRecommendationsRequest, + protos.google.cloud.recommender.v1.IListRecommendationsResponse|null|undefined, + protos.google.cloud.recommender.v1.IRecommendation>): void; + listRecommendations( + request?: protos.google.cloud.recommender.v1.IListRecommendationsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.recommender.v1.IListRecommendationsRequest, + protos.google.cloud.recommender.v1.IListRecommendationsResponse|null|undefined, + protos.google.cloud.recommender.v1.IRecommendation>, + callback?: PaginationCallback< + protos.google.cloud.recommender.v1.IListRecommendationsRequest, + protos.google.cloud.recommender.v1.IListRecommendationsResponse|null|undefined, + protos.google.cloud.recommender.v1.IRecommendation>): + Promise<[ + protos.google.cloud.recommender.v1.IRecommendation[], + protos.google.cloud.recommender.v1.IListRecommendationsRequest|null, + protos.google.cloud.recommender.v1.IListRecommendationsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listRecommendations(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 container resource on which to execute the request. + * Acceptable formats: + * + * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * LOCATION here refers to GCP Locations: + * https://cloud.google.com/about/locations/ + * RECOMMENDER_ID refers to supported recommenders: + * https://cloud.google.com/recommender/docs/recommenders. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. If not specified, the server will + * determine the number of results to return. + * @param {string} [request.pageToken] + * Optional. If present, retrieves the next batch of results from the + * preceding call to this method. `page_token` must be the value of + * `next_page_token` from the previous response. The values of other method + * parameters must be identical to those in the previous call. + * @param {string} request.filter + * Filter expression to restrict the recommendations returned. Supported + * filter fields: + * + * * `state_info.state` + * + * * `recommenderSubtype` + * + * * `priority` + * + * Examples: + * + * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` + * + * * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` + * + * * `priority = P1 OR priority = P2` + * + * * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` + * + * (These expressions are based on the filter language described at + * https://google.aip.dev/160) + * @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 protos.google.cloud.recommender.v1.Recommendation|Recommendation} 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 `listRecommendationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listRecommendationsStream( + request?: protos.google.cloud.recommender.v1.IListRecommendationsRequest, + 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['listRecommendations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRecommendations.createStream( + this.innerApiCalls.listRecommendations as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listRecommendations`, 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 container resource on which to execute the request. + * Acceptable formats: + * + * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * LOCATION here refers to GCP Locations: + * https://cloud.google.com/about/locations/ + * RECOMMENDER_ID refers to supported recommenders: + * https://cloud.google.com/recommender/docs/recommenders. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. If not specified, the server will + * determine the number of results to return. + * @param {string} [request.pageToken] + * Optional. If present, retrieves the next batch of results from the + * preceding call to this method. `page_token` must be the value of + * `next_page_token` from the previous response. The values of other method + * parameters must be identical to those in the previous call. + * @param {string} request.filter + * Filter expression to restrict the recommendations returned. Supported + * filter fields: + * + * * `state_info.state` + * + * * `recommenderSubtype` + * + * * `priority` + * + * Examples: + * + * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` + * + * * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` + * + * * `priority = P1 OR priority = P2` + * + * * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` + * + * (These expressions are based on the filter language described at + * https://google.aip.dev/160) + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.recommender.v1.Recommendation|Recommendation}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/recommender.list_recommendations.js + * region_tag:recommender_v1_generated_Recommender_ListRecommendations_async + */ + listRecommendationsAsync( + request?: protos.google.cloud.recommender.v1.IListRecommendationsRequest, + 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['listRecommendations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRecommendations.asyncIterate( + this.innerApiCalls['listRecommendations'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified billingAccountLocationInsightType resource name string. + * + * @param {string} billing_account + * @param {string} location + * @param {string} insight_type + * @returns {string} Resource name string. + */ + billingAccountLocationInsightTypePath(billingAccount:string,location:string,insightType:string) { + return this.pathTemplates.billingAccountLocationInsightTypePathTemplate.render({ + billing_account: billingAccount, + location: location, + insight_type: insightType, + }); + } + + /** + * Parse the billing_account from BillingAccountLocationInsightType resource. + * + * @param {string} billingAccountLocationInsightTypeName + * A fully-qualified path representing billing_account_location_insight_type resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountLocationInsightTypeName(billingAccountLocationInsightTypeName: string) { + return this.pathTemplates.billingAccountLocationInsightTypePathTemplate.match(billingAccountLocationInsightTypeName).billing_account; + } + + /** + * Parse the location from BillingAccountLocationInsightType resource. + * + * @param {string} billingAccountLocationInsightTypeName + * A fully-qualified path representing billing_account_location_insight_type resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBillingAccountLocationInsightTypeName(billingAccountLocationInsightTypeName: string) { + return this.pathTemplates.billingAccountLocationInsightTypePathTemplate.match(billingAccountLocationInsightTypeName).location; + } + + /** + * Parse the insight_type from BillingAccountLocationInsightType resource. + * + * @param {string} billingAccountLocationInsightTypeName + * A fully-qualified path representing billing_account_location_insight_type resource. + * @returns {string} A string representing the insight_type. + */ + matchInsightTypeFromBillingAccountLocationInsightTypeName(billingAccountLocationInsightTypeName: string) { + return this.pathTemplates.billingAccountLocationInsightTypePathTemplate.match(billingAccountLocationInsightTypeName).insight_type; + } + + /** + * Return a fully-qualified billingAccountLocationInsightTypeInsight resource name string. + * + * @param {string} billing_account + * @param {string} location + * @param {string} insight_type + * @param {string} insight + * @returns {string} Resource name string. + */ + billingAccountLocationInsightTypeInsightPath(billingAccount:string,location:string,insightType:string,insight:string) { + return this.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.render({ + billing_account: billingAccount, + location: location, + insight_type: insightType, + insight: insight, + }); + } + + /** + * Parse the billing_account from BillingAccountLocationInsightTypeInsight resource. + * + * @param {string} billingAccountLocationInsightTypeInsightName + * A fully-qualified path representing billing_account_location_insight_type_insight resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountLocationInsightTypeInsightName(billingAccountLocationInsightTypeInsightName: string) { + return this.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match(billingAccountLocationInsightTypeInsightName).billing_account; + } + + /** + * Parse the location from BillingAccountLocationInsightTypeInsight resource. + * + * @param {string} billingAccountLocationInsightTypeInsightName + * A fully-qualified path representing billing_account_location_insight_type_insight resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBillingAccountLocationInsightTypeInsightName(billingAccountLocationInsightTypeInsightName: string) { + return this.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match(billingAccountLocationInsightTypeInsightName).location; + } + + /** + * Parse the insight_type from BillingAccountLocationInsightTypeInsight resource. + * + * @param {string} billingAccountLocationInsightTypeInsightName + * A fully-qualified path representing billing_account_location_insight_type_insight resource. + * @returns {string} A string representing the insight_type. + */ + matchInsightTypeFromBillingAccountLocationInsightTypeInsightName(billingAccountLocationInsightTypeInsightName: string) { + return this.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match(billingAccountLocationInsightTypeInsightName).insight_type; + } + + /** + * Parse the insight from BillingAccountLocationInsightTypeInsight resource. + * + * @param {string} billingAccountLocationInsightTypeInsightName + * A fully-qualified path representing billing_account_location_insight_type_insight resource. + * @returns {string} A string representing the insight. + */ + matchInsightFromBillingAccountLocationInsightTypeInsightName(billingAccountLocationInsightTypeInsightName: string) { + return this.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match(billingAccountLocationInsightTypeInsightName).insight; + } + + /** + * Return a fully-qualified billingAccountLocationRecommender resource name string. + * + * @param {string} billing_account + * @param {string} location + * @param {string} recommender + * @returns {string} Resource name string. + */ + billingAccountLocationRecommenderPath(billingAccount:string,location:string,recommender:string) { + return this.pathTemplates.billingAccountLocationRecommenderPathTemplate.render({ + billing_account: billingAccount, + location: location, + recommender: recommender, + }); + } + + /** + * Parse the billing_account from BillingAccountLocationRecommender resource. + * + * @param {string} billingAccountLocationRecommenderName + * A fully-qualified path representing billing_account_location_recommender resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountLocationRecommenderName(billingAccountLocationRecommenderName: string) { + return this.pathTemplates.billingAccountLocationRecommenderPathTemplate.match(billingAccountLocationRecommenderName).billing_account; + } + + /** + * Parse the location from BillingAccountLocationRecommender resource. + * + * @param {string} billingAccountLocationRecommenderName + * A fully-qualified path representing billing_account_location_recommender resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBillingAccountLocationRecommenderName(billingAccountLocationRecommenderName: string) { + return this.pathTemplates.billingAccountLocationRecommenderPathTemplate.match(billingAccountLocationRecommenderName).location; + } + + /** + * Parse the recommender from BillingAccountLocationRecommender resource. + * + * @param {string} billingAccountLocationRecommenderName + * A fully-qualified path representing billing_account_location_recommender resource. + * @returns {string} A string representing the recommender. + */ + matchRecommenderFromBillingAccountLocationRecommenderName(billingAccountLocationRecommenderName: string) { + return this.pathTemplates.billingAccountLocationRecommenderPathTemplate.match(billingAccountLocationRecommenderName).recommender; + } + + /** + * Return a fully-qualified billingAccountLocationRecommenderRecommendation resource name string. + * + * @param {string} billing_account + * @param {string} location + * @param {string} recommender + * @param {string} recommendation + * @returns {string} Resource name string. + */ + billingAccountLocationRecommenderRecommendationPath(billingAccount:string,location:string,recommender:string,recommendation:string) { + return this.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.render({ + billing_account: billingAccount, + location: location, + recommender: recommender, + recommendation: recommendation, + }); + } + + /** + * Parse the billing_account from BillingAccountLocationRecommenderRecommendation resource. + * + * @param {string} billingAccountLocationRecommenderRecommendationName + * A fully-qualified path representing billing_account_location_recommender_recommendation resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountLocationRecommenderRecommendationName(billingAccountLocationRecommenderRecommendationName: string) { + return this.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match(billingAccountLocationRecommenderRecommendationName).billing_account; + } + + /** + * Parse the location from BillingAccountLocationRecommenderRecommendation resource. + * + * @param {string} billingAccountLocationRecommenderRecommendationName + * A fully-qualified path representing billing_account_location_recommender_recommendation resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBillingAccountLocationRecommenderRecommendationName(billingAccountLocationRecommenderRecommendationName: string) { + return this.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match(billingAccountLocationRecommenderRecommendationName).location; + } + + /** + * Parse the recommender from BillingAccountLocationRecommenderRecommendation resource. + * + * @param {string} billingAccountLocationRecommenderRecommendationName + * A fully-qualified path representing billing_account_location_recommender_recommendation resource. + * @returns {string} A string representing the recommender. + */ + matchRecommenderFromBillingAccountLocationRecommenderRecommendationName(billingAccountLocationRecommenderRecommendationName: string) { + return this.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match(billingAccountLocationRecommenderRecommendationName).recommender; + } + + /** + * Parse the recommendation from BillingAccountLocationRecommenderRecommendation resource. + * + * @param {string} billingAccountLocationRecommenderRecommendationName + * A fully-qualified path representing billing_account_location_recommender_recommendation resource. + * @returns {string} A string representing the recommendation. + */ + matchRecommendationFromBillingAccountLocationRecommenderRecommendationName(billingAccountLocationRecommenderRecommendationName: string) { + return this.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match(billingAccountLocationRecommenderRecommendationName).recommendation; + } + + /** + * Return a fully-qualified folderLocationInsightType resource name string. + * + * @param {string} folder + * @param {string} location + * @param {string} insight_type + * @returns {string} Resource name string. + */ + folderLocationInsightTypePath(folder:string,location:string,insightType:string) { + return this.pathTemplates.folderLocationInsightTypePathTemplate.render({ + folder: folder, + location: location, + insight_type: insightType, + }); + } + + /** + * Parse the folder from FolderLocationInsightType resource. + * + * @param {string} folderLocationInsightTypeName + * A fully-qualified path representing folder_location_insight_type resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderLocationInsightTypeName(folderLocationInsightTypeName: string) { + return this.pathTemplates.folderLocationInsightTypePathTemplate.match(folderLocationInsightTypeName).folder; + } + + /** + * Parse the location from FolderLocationInsightType resource. + * + * @param {string} folderLocationInsightTypeName + * A fully-qualified path representing folder_location_insight_type resource. + * @returns {string} A string representing the location. + */ + matchLocationFromFolderLocationInsightTypeName(folderLocationInsightTypeName: string) { + return this.pathTemplates.folderLocationInsightTypePathTemplate.match(folderLocationInsightTypeName).location; + } + + /** + * Parse the insight_type from FolderLocationInsightType resource. + * + * @param {string} folderLocationInsightTypeName + * A fully-qualified path representing folder_location_insight_type resource. + * @returns {string} A string representing the insight_type. + */ + matchInsightTypeFromFolderLocationInsightTypeName(folderLocationInsightTypeName: string) { + return this.pathTemplates.folderLocationInsightTypePathTemplate.match(folderLocationInsightTypeName).insight_type; + } + + /** + * Return a fully-qualified folderLocationInsightTypeInsight resource name string. + * + * @param {string} folder + * @param {string} location + * @param {string} insight_type + * @param {string} insight + * @returns {string} Resource name string. + */ + folderLocationInsightTypeInsightPath(folder:string,location:string,insightType:string,insight:string) { + return this.pathTemplates.folderLocationInsightTypeInsightPathTemplate.render({ + folder: folder, + location: location, + insight_type: insightType, + insight: insight, + }); + } + + /** + * Parse the folder from FolderLocationInsightTypeInsight resource. + * + * @param {string} folderLocationInsightTypeInsightName + * A fully-qualified path representing folder_location_insight_type_insight resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderLocationInsightTypeInsightName(folderLocationInsightTypeInsightName: string) { + return this.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match(folderLocationInsightTypeInsightName).folder; + } + + /** + * Parse the location from FolderLocationInsightTypeInsight resource. + * + * @param {string} folderLocationInsightTypeInsightName + * A fully-qualified path representing folder_location_insight_type_insight resource. + * @returns {string} A string representing the location. + */ + matchLocationFromFolderLocationInsightTypeInsightName(folderLocationInsightTypeInsightName: string) { + return this.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match(folderLocationInsightTypeInsightName).location; + } + + /** + * Parse the insight_type from FolderLocationInsightTypeInsight resource. + * + * @param {string} folderLocationInsightTypeInsightName + * A fully-qualified path representing folder_location_insight_type_insight resource. + * @returns {string} A string representing the insight_type. + */ + matchInsightTypeFromFolderLocationInsightTypeInsightName(folderLocationInsightTypeInsightName: string) { + return this.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match(folderLocationInsightTypeInsightName).insight_type; + } + + /** + * Parse the insight from FolderLocationInsightTypeInsight resource. + * + * @param {string} folderLocationInsightTypeInsightName + * A fully-qualified path representing folder_location_insight_type_insight resource. + * @returns {string} A string representing the insight. + */ + matchInsightFromFolderLocationInsightTypeInsightName(folderLocationInsightTypeInsightName: string) { + return this.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match(folderLocationInsightTypeInsightName).insight; + } + + /** + * Return a fully-qualified folderLocationRecommender resource name string. + * + * @param {string} folder + * @param {string} location + * @param {string} recommender + * @returns {string} Resource name string. + */ + folderLocationRecommenderPath(folder:string,location:string,recommender:string) { + return this.pathTemplates.folderLocationRecommenderPathTemplate.render({ + folder: folder, + location: location, + recommender: recommender, + }); + } + + /** + * Parse the folder from FolderLocationRecommender resource. + * + * @param {string} folderLocationRecommenderName + * A fully-qualified path representing folder_location_recommender resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderLocationRecommenderName(folderLocationRecommenderName: string) { + return this.pathTemplates.folderLocationRecommenderPathTemplate.match(folderLocationRecommenderName).folder; + } + + /** + * Parse the location from FolderLocationRecommender resource. + * + * @param {string} folderLocationRecommenderName + * A fully-qualified path representing folder_location_recommender resource. + * @returns {string} A string representing the location. + */ + matchLocationFromFolderLocationRecommenderName(folderLocationRecommenderName: string) { + return this.pathTemplates.folderLocationRecommenderPathTemplate.match(folderLocationRecommenderName).location; + } + + /** + * Parse the recommender from FolderLocationRecommender resource. + * + * @param {string} folderLocationRecommenderName + * A fully-qualified path representing folder_location_recommender resource. + * @returns {string} A string representing the recommender. + */ + matchRecommenderFromFolderLocationRecommenderName(folderLocationRecommenderName: string) { + return this.pathTemplates.folderLocationRecommenderPathTemplate.match(folderLocationRecommenderName).recommender; + } + + /** + * Return a fully-qualified folderLocationRecommenderRecommendation resource name string. + * + * @param {string} folder + * @param {string} location + * @param {string} recommender + * @param {string} recommendation + * @returns {string} Resource name string. + */ + folderLocationRecommenderRecommendationPath(folder:string,location:string,recommender:string,recommendation:string) { + return this.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.render({ + folder: folder, + location: location, + recommender: recommender, + recommendation: recommendation, + }); + } + + /** + * Parse the folder from FolderLocationRecommenderRecommendation resource. + * + * @param {string} folderLocationRecommenderRecommendationName + * A fully-qualified path representing folder_location_recommender_recommendation resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderLocationRecommenderRecommendationName(folderLocationRecommenderRecommendationName: string) { + return this.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match(folderLocationRecommenderRecommendationName).folder; + } + + /** + * Parse the location from FolderLocationRecommenderRecommendation resource. + * + * @param {string} folderLocationRecommenderRecommendationName + * A fully-qualified path representing folder_location_recommender_recommendation resource. + * @returns {string} A string representing the location. + */ + matchLocationFromFolderLocationRecommenderRecommendationName(folderLocationRecommenderRecommendationName: string) { + return this.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match(folderLocationRecommenderRecommendationName).location; + } + + /** + * Parse the recommender from FolderLocationRecommenderRecommendation resource. + * + * @param {string} folderLocationRecommenderRecommendationName + * A fully-qualified path representing folder_location_recommender_recommendation resource. + * @returns {string} A string representing the recommender. + */ + matchRecommenderFromFolderLocationRecommenderRecommendationName(folderLocationRecommenderRecommendationName: string) { + return this.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match(folderLocationRecommenderRecommendationName).recommender; + } + + /** + * Parse the recommendation from FolderLocationRecommenderRecommendation resource. + * + * @param {string} folderLocationRecommenderRecommendationName + * A fully-qualified path representing folder_location_recommender_recommendation resource. + * @returns {string} A string representing the recommendation. + */ + matchRecommendationFromFolderLocationRecommenderRecommendationName(folderLocationRecommenderRecommendationName: string) { + return this.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match(folderLocationRecommenderRecommendationName).recommendation; + } + + /** + * Return a fully-qualified organizationLocationInsightType resource name string. + * + * @param {string} organization + * @param {string} location + * @param {string} insight_type + * @returns {string} Resource name string. + */ + organizationLocationInsightTypePath(organization:string,location:string,insightType:string) { + return this.pathTemplates.organizationLocationInsightTypePathTemplate.render({ + organization: organization, + location: location, + insight_type: insightType, + }); + } + + /** + * Parse the organization from OrganizationLocationInsightType resource. + * + * @param {string} organizationLocationInsightTypeName + * A fully-qualified path representing organization_location_insight_type resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLocationInsightTypeName(organizationLocationInsightTypeName: string) { + return this.pathTemplates.organizationLocationInsightTypePathTemplate.match(organizationLocationInsightTypeName).organization; + } + + /** + * Parse the location from OrganizationLocationInsightType resource. + * + * @param {string} organizationLocationInsightTypeName + * A fully-qualified path representing organization_location_insight_type resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOrganizationLocationInsightTypeName(organizationLocationInsightTypeName: string) { + return this.pathTemplates.organizationLocationInsightTypePathTemplate.match(organizationLocationInsightTypeName).location; + } + + /** + * Parse the insight_type from OrganizationLocationInsightType resource. + * + * @param {string} organizationLocationInsightTypeName + * A fully-qualified path representing organization_location_insight_type resource. + * @returns {string} A string representing the insight_type. + */ + matchInsightTypeFromOrganizationLocationInsightTypeName(organizationLocationInsightTypeName: string) { + return this.pathTemplates.organizationLocationInsightTypePathTemplate.match(organizationLocationInsightTypeName).insight_type; + } + + /** + * Return a fully-qualified organizationLocationInsightTypeConfig resource name string. + * + * @param {string} organization + * @param {string} location + * @param {string} insight_type + * @returns {string} Resource name string. + */ + organizationLocationInsightTypeConfigPath(organization:string,location:string,insightType:string) { + return this.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.render({ + organization: organization, + location: location, + insight_type: insightType, + }); + } + + /** + * Parse the organization from OrganizationLocationInsightTypeConfig resource. + * + * @param {string} organizationLocationInsightTypeConfigName + * A fully-qualified path representing organization_location_insight_type_config resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLocationInsightTypeConfigName(organizationLocationInsightTypeConfigName: string) { + return this.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match(organizationLocationInsightTypeConfigName).organization; + } + + /** + * Parse the location from OrganizationLocationInsightTypeConfig resource. + * + * @param {string} organizationLocationInsightTypeConfigName + * A fully-qualified path representing organization_location_insight_type_config resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOrganizationLocationInsightTypeConfigName(organizationLocationInsightTypeConfigName: string) { + return this.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match(organizationLocationInsightTypeConfigName).location; + } + + /** + * Parse the insight_type from OrganizationLocationInsightTypeConfig resource. + * + * @param {string} organizationLocationInsightTypeConfigName + * A fully-qualified path representing organization_location_insight_type_config resource. + * @returns {string} A string representing the insight_type. + */ + matchInsightTypeFromOrganizationLocationInsightTypeConfigName(organizationLocationInsightTypeConfigName: string) { + return this.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match(organizationLocationInsightTypeConfigName).insight_type; + } + + /** + * Return a fully-qualified organizationLocationInsightTypeInsight resource name string. + * + * @param {string} organization + * @param {string} location + * @param {string} insight_type + * @param {string} insight + * @returns {string} Resource name string. + */ + organizationLocationInsightTypeInsightPath(organization:string,location:string,insightType:string,insight:string) { + return this.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.render({ + organization: organization, + location: location, + insight_type: insightType, + insight: insight, + }); + } + + /** + * Parse the organization from OrganizationLocationInsightTypeInsight resource. + * + * @param {string} organizationLocationInsightTypeInsightName + * A fully-qualified path representing organization_location_insight_type_insight resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLocationInsightTypeInsightName(organizationLocationInsightTypeInsightName: string) { + return this.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match(organizationLocationInsightTypeInsightName).organization; + } + + /** + * Parse the location from OrganizationLocationInsightTypeInsight resource. + * + * @param {string} organizationLocationInsightTypeInsightName + * A fully-qualified path representing organization_location_insight_type_insight resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOrganizationLocationInsightTypeInsightName(organizationLocationInsightTypeInsightName: string) { + return this.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match(organizationLocationInsightTypeInsightName).location; + } + + /** + * Parse the insight_type from OrganizationLocationInsightTypeInsight resource. + * + * @param {string} organizationLocationInsightTypeInsightName + * A fully-qualified path representing organization_location_insight_type_insight resource. + * @returns {string} A string representing the insight_type. + */ + matchInsightTypeFromOrganizationLocationInsightTypeInsightName(organizationLocationInsightTypeInsightName: string) { + return this.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match(organizationLocationInsightTypeInsightName).insight_type; + } + + /** + * Parse the insight from OrganizationLocationInsightTypeInsight resource. + * + * @param {string} organizationLocationInsightTypeInsightName + * A fully-qualified path representing organization_location_insight_type_insight resource. + * @returns {string} A string representing the insight. + */ + matchInsightFromOrganizationLocationInsightTypeInsightName(organizationLocationInsightTypeInsightName: string) { + return this.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match(organizationLocationInsightTypeInsightName).insight; + } + + /** + * Return a fully-qualified organizationLocationRecommender resource name string. + * + * @param {string} organization + * @param {string} location + * @param {string} recommender + * @returns {string} Resource name string. + */ + organizationLocationRecommenderPath(organization:string,location:string,recommender:string) { + return this.pathTemplates.organizationLocationRecommenderPathTemplate.render({ + organization: organization, + location: location, + recommender: recommender, + }); + } + + /** + * Parse the organization from OrganizationLocationRecommender resource. + * + * @param {string} organizationLocationRecommenderName + * A fully-qualified path representing organization_location_recommender resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLocationRecommenderName(organizationLocationRecommenderName: string) { + return this.pathTemplates.organizationLocationRecommenderPathTemplate.match(organizationLocationRecommenderName).organization; + } + + /** + * Parse the location from OrganizationLocationRecommender resource. + * + * @param {string} organizationLocationRecommenderName + * A fully-qualified path representing organization_location_recommender resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOrganizationLocationRecommenderName(organizationLocationRecommenderName: string) { + return this.pathTemplates.organizationLocationRecommenderPathTemplate.match(organizationLocationRecommenderName).location; + } + + /** + * Parse the recommender from OrganizationLocationRecommender resource. + * + * @param {string} organizationLocationRecommenderName + * A fully-qualified path representing organization_location_recommender resource. + * @returns {string} A string representing the recommender. + */ + matchRecommenderFromOrganizationLocationRecommenderName(organizationLocationRecommenderName: string) { + return this.pathTemplates.organizationLocationRecommenderPathTemplate.match(organizationLocationRecommenderName).recommender; + } + + /** + * Return a fully-qualified organizationLocationRecommenderConfig resource name string. + * + * @param {string} organization + * @param {string} location + * @param {string} recommender + * @returns {string} Resource name string. + */ + organizationLocationRecommenderConfigPath(organization:string,location:string,recommender:string) { + return this.pathTemplates.organizationLocationRecommenderConfigPathTemplate.render({ + organization: organization, + location: location, + recommender: recommender, + }); + } + + /** + * Parse the organization from OrganizationLocationRecommenderConfig resource. + * + * @param {string} organizationLocationRecommenderConfigName + * A fully-qualified path representing organization_location_recommender_config resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLocationRecommenderConfigName(organizationLocationRecommenderConfigName: string) { + return this.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match(organizationLocationRecommenderConfigName).organization; + } + + /** + * Parse the location from OrganizationLocationRecommenderConfig resource. + * + * @param {string} organizationLocationRecommenderConfigName + * A fully-qualified path representing organization_location_recommender_config resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOrganizationLocationRecommenderConfigName(organizationLocationRecommenderConfigName: string) { + return this.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match(organizationLocationRecommenderConfigName).location; + } + + /** + * Parse the recommender from OrganizationLocationRecommenderConfig resource. + * + * @param {string} organizationLocationRecommenderConfigName + * A fully-qualified path representing organization_location_recommender_config resource. + * @returns {string} A string representing the recommender. + */ + matchRecommenderFromOrganizationLocationRecommenderConfigName(organizationLocationRecommenderConfigName: string) { + return this.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match(organizationLocationRecommenderConfigName).recommender; + } + + /** + * Return a fully-qualified organizationLocationRecommenderRecommendation resource name string. + * + * @param {string} organization + * @param {string} location + * @param {string} recommender + * @param {string} recommendation + * @returns {string} Resource name string. + */ + organizationLocationRecommenderRecommendationPath(organization:string,location:string,recommender:string,recommendation:string) { + return this.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.render({ + organization: organization, + location: location, + recommender: recommender, + recommendation: recommendation, + }); + } + + /** + * Parse the organization from OrganizationLocationRecommenderRecommendation resource. + * + * @param {string} organizationLocationRecommenderRecommendationName + * A fully-qualified path representing organization_location_recommender_recommendation resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLocationRecommenderRecommendationName(organizationLocationRecommenderRecommendationName: string) { + return this.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match(organizationLocationRecommenderRecommendationName).organization; + } + + /** + * Parse the location from OrganizationLocationRecommenderRecommendation resource. + * + * @param {string} organizationLocationRecommenderRecommendationName + * A fully-qualified path representing organization_location_recommender_recommendation resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOrganizationLocationRecommenderRecommendationName(organizationLocationRecommenderRecommendationName: string) { + return this.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match(organizationLocationRecommenderRecommendationName).location; + } + + /** + * Parse the recommender from OrganizationLocationRecommenderRecommendation resource. + * + * @param {string} organizationLocationRecommenderRecommendationName + * A fully-qualified path representing organization_location_recommender_recommendation resource. + * @returns {string} A string representing the recommender. + */ + matchRecommenderFromOrganizationLocationRecommenderRecommendationName(organizationLocationRecommenderRecommendationName: string) { + return this.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match(organizationLocationRecommenderRecommendationName).recommender; + } + + /** + * Parse the recommendation from OrganizationLocationRecommenderRecommendation resource. + * + * @param {string} organizationLocationRecommenderRecommendationName + * A fully-qualified path representing organization_location_recommender_recommendation resource. + * @returns {string} A string representing the recommendation. + */ + matchRecommendationFromOrganizationLocationRecommenderRecommendationName(organizationLocationRecommenderRecommendationName: string) { + return this.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match(organizationLocationRecommenderRecommendationName).recommendation; + } + + /** + * Return a fully-qualified projectLocationInsightType resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} insight_type + * @returns {string} Resource name string. + */ + projectLocationInsightTypePath(project:string,location:string,insightType:string) { + return this.pathTemplates.projectLocationInsightTypePathTemplate.render({ + project: project, + location: location, + insight_type: insightType, + }); + } + + /** + * Parse the project from ProjectLocationInsightType resource. + * + * @param {string} projectLocationInsightTypeName + * A fully-qualified path representing project_location_insight_type resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationInsightTypeName(projectLocationInsightTypeName: string) { + return this.pathTemplates.projectLocationInsightTypePathTemplate.match(projectLocationInsightTypeName).project; + } + + /** + * Parse the location from ProjectLocationInsightType resource. + * + * @param {string} projectLocationInsightTypeName + * A fully-qualified path representing project_location_insight_type resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationInsightTypeName(projectLocationInsightTypeName: string) { + return this.pathTemplates.projectLocationInsightTypePathTemplate.match(projectLocationInsightTypeName).location; + } + + /** + * Parse the insight_type from ProjectLocationInsightType resource. + * + * @param {string} projectLocationInsightTypeName + * A fully-qualified path representing project_location_insight_type resource. + * @returns {string} A string representing the insight_type. + */ + matchInsightTypeFromProjectLocationInsightTypeName(projectLocationInsightTypeName: string) { + return this.pathTemplates.projectLocationInsightTypePathTemplate.match(projectLocationInsightTypeName).insight_type; + } + + /** + * Return a fully-qualified projectLocationInsightTypeConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} insight_type + * @returns {string} Resource name string. + */ + projectLocationInsightTypeConfigPath(project:string,location:string,insightType:string) { + return this.pathTemplates.projectLocationInsightTypeConfigPathTemplate.render({ + project: project, + location: location, + insight_type: insightType, + }); + } + + /** + * Parse the project from ProjectLocationInsightTypeConfig resource. + * + * @param {string} projectLocationInsightTypeConfigName + * A fully-qualified path representing project_location_insight_type_config resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationInsightTypeConfigName(projectLocationInsightTypeConfigName: string) { + return this.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match(projectLocationInsightTypeConfigName).project; + } + + /** + * Parse the location from ProjectLocationInsightTypeConfig resource. + * + * @param {string} projectLocationInsightTypeConfigName + * A fully-qualified path representing project_location_insight_type_config resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationInsightTypeConfigName(projectLocationInsightTypeConfigName: string) { + return this.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match(projectLocationInsightTypeConfigName).location; + } + + /** + * Parse the insight_type from ProjectLocationInsightTypeConfig resource. + * + * @param {string} projectLocationInsightTypeConfigName + * A fully-qualified path representing project_location_insight_type_config resource. + * @returns {string} A string representing the insight_type. + */ + matchInsightTypeFromProjectLocationInsightTypeConfigName(projectLocationInsightTypeConfigName: string) { + return this.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match(projectLocationInsightTypeConfigName).insight_type; + } + + /** + * Return a fully-qualified projectLocationInsightTypeInsight resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} insight_type + * @param {string} insight + * @returns {string} Resource name string. + */ + projectLocationInsightTypeInsightPath(project:string,location:string,insightType:string,insight:string) { + return this.pathTemplates.projectLocationInsightTypeInsightPathTemplate.render({ + project: project, + location: location, + insight_type: insightType, + insight: insight, + }); + } + + /** + * Parse the project from ProjectLocationInsightTypeInsight resource. + * + * @param {string} projectLocationInsightTypeInsightName + * A fully-qualified path representing project_location_insight_type_insight resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationInsightTypeInsightName(projectLocationInsightTypeInsightName: string) { + return this.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match(projectLocationInsightTypeInsightName).project; + } + + /** + * Parse the location from ProjectLocationInsightTypeInsight resource. + * + * @param {string} projectLocationInsightTypeInsightName + * A fully-qualified path representing project_location_insight_type_insight resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationInsightTypeInsightName(projectLocationInsightTypeInsightName: string) { + return this.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match(projectLocationInsightTypeInsightName).location; + } + + /** + * Parse the insight_type from ProjectLocationInsightTypeInsight resource. + * + * @param {string} projectLocationInsightTypeInsightName + * A fully-qualified path representing project_location_insight_type_insight resource. + * @returns {string} A string representing the insight_type. + */ + matchInsightTypeFromProjectLocationInsightTypeInsightName(projectLocationInsightTypeInsightName: string) { + return this.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match(projectLocationInsightTypeInsightName).insight_type; + } + + /** + * Parse the insight from ProjectLocationInsightTypeInsight resource. + * + * @param {string} projectLocationInsightTypeInsightName + * A fully-qualified path representing project_location_insight_type_insight resource. + * @returns {string} A string representing the insight. + */ + matchInsightFromProjectLocationInsightTypeInsightName(projectLocationInsightTypeInsightName: string) { + return this.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match(projectLocationInsightTypeInsightName).insight; + } + + /** + * Return a fully-qualified projectLocationRecommender resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} recommender + * @returns {string} Resource name string. + */ + projectLocationRecommenderPath(project:string,location:string,recommender:string) { + return this.pathTemplates.projectLocationRecommenderPathTemplate.render({ + project: project, + location: location, + recommender: recommender, + }); + } + + /** + * Parse the project from ProjectLocationRecommender resource. + * + * @param {string} projectLocationRecommenderName + * A fully-qualified path representing project_location_recommender resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationRecommenderName(projectLocationRecommenderName: string) { + return this.pathTemplates.projectLocationRecommenderPathTemplate.match(projectLocationRecommenderName).project; + } + + /** + * Parse the location from ProjectLocationRecommender resource. + * + * @param {string} projectLocationRecommenderName + * A fully-qualified path representing project_location_recommender resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationRecommenderName(projectLocationRecommenderName: string) { + return this.pathTemplates.projectLocationRecommenderPathTemplate.match(projectLocationRecommenderName).location; + } + + /** + * Parse the recommender from ProjectLocationRecommender resource. + * + * @param {string} projectLocationRecommenderName + * A fully-qualified path representing project_location_recommender resource. + * @returns {string} A string representing the recommender. + */ + matchRecommenderFromProjectLocationRecommenderName(projectLocationRecommenderName: string) { + return this.pathTemplates.projectLocationRecommenderPathTemplate.match(projectLocationRecommenderName).recommender; + } + + /** + * Return a fully-qualified projectLocationRecommenderConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} recommender + * @returns {string} Resource name string. + */ + projectLocationRecommenderConfigPath(project:string,location:string,recommender:string) { + return this.pathTemplates.projectLocationRecommenderConfigPathTemplate.render({ + project: project, + location: location, + recommender: recommender, + }); + } + + /** + * Parse the project from ProjectLocationRecommenderConfig resource. + * + * @param {string} projectLocationRecommenderConfigName + * A fully-qualified path representing project_location_recommender_config resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationRecommenderConfigName(projectLocationRecommenderConfigName: string) { + return this.pathTemplates.projectLocationRecommenderConfigPathTemplate.match(projectLocationRecommenderConfigName).project; + } + + /** + * Parse the location from ProjectLocationRecommenderConfig resource. + * + * @param {string} projectLocationRecommenderConfigName + * A fully-qualified path representing project_location_recommender_config resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationRecommenderConfigName(projectLocationRecommenderConfigName: string) { + return this.pathTemplates.projectLocationRecommenderConfigPathTemplate.match(projectLocationRecommenderConfigName).location; + } + + /** + * Parse the recommender from ProjectLocationRecommenderConfig resource. + * + * @param {string} projectLocationRecommenderConfigName + * A fully-qualified path representing project_location_recommender_config resource. + * @returns {string} A string representing the recommender. + */ + matchRecommenderFromProjectLocationRecommenderConfigName(projectLocationRecommenderConfigName: string) { + return this.pathTemplates.projectLocationRecommenderConfigPathTemplate.match(projectLocationRecommenderConfigName).recommender; + } + + /** + * Return a fully-qualified projectLocationRecommenderRecommendation resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} recommender + * @param {string} recommendation + * @returns {string} Resource name string. + */ + projectLocationRecommenderRecommendationPath(project:string,location:string,recommender:string,recommendation:string) { + return this.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.render({ + project: project, + location: location, + recommender: recommender, + recommendation: recommendation, + }); + } + + /** + * Parse the project from ProjectLocationRecommenderRecommendation resource. + * + * @param {string} projectLocationRecommenderRecommendationName + * A fully-qualified path representing project_location_recommender_recommendation resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationRecommenderRecommendationName(projectLocationRecommenderRecommendationName: string) { + return this.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match(projectLocationRecommenderRecommendationName).project; + } + + /** + * Parse the location from ProjectLocationRecommenderRecommendation resource. + * + * @param {string} projectLocationRecommenderRecommendationName + * A fully-qualified path representing project_location_recommender_recommendation resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationRecommenderRecommendationName(projectLocationRecommenderRecommendationName: string) { + return this.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match(projectLocationRecommenderRecommendationName).location; + } + + /** + * Parse the recommender from ProjectLocationRecommenderRecommendation resource. + * + * @param {string} projectLocationRecommenderRecommendationName + * A fully-qualified path representing project_location_recommender_recommendation resource. + * @returns {string} A string representing the recommender. + */ + matchRecommenderFromProjectLocationRecommenderRecommendationName(projectLocationRecommenderRecommendationName: string) { + return this.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match(projectLocationRecommenderRecommendationName).recommender; + } + + /** + * Parse the recommendation from ProjectLocationRecommenderRecommendation resource. + * + * @param {string} projectLocationRecommenderRecommendationName + * A fully-qualified path representing project_location_recommender_recommendation resource. + * @returns {string} A string representing the recommendation. + */ + matchRecommendationFromProjectLocationRecommenderRecommendationName(projectLocationRecommenderRecommendationName: string) { + return this.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match(projectLocationRecommenderRecommendationName).recommendation; + } + + /** + * 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.recommenderStub && !this._terminated) { + return this.recommenderStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_client_config.json b/owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_client_config.json new file mode 100644 index 00000000000..a8ffdbb5b6e --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_client_config.json @@ -0,0 +1,82 @@ +{ + "interfaces": { + "google.cloud.recommender.v1.Recommender": { + "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": { + "ListInsights": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetInsight": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "MarkInsightAccepted": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListRecommendations": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetRecommendation": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "MarkRecommendationClaimed": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "MarkRecommendationSucceeded": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "MarkRecommendationFailed": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetRecommenderConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateRecommenderConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetInsightTypeConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateInsightTypeConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_proto_list.json b/owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_proto_list.json new file mode 100644 index 00000000000..016dc35c415 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_proto_list.json @@ -0,0 +1,7 @@ +[ + "../../protos/google/cloud/recommender/v1/insight.proto", + "../../protos/google/cloud/recommender/v1/insight_type_config.proto", + "../../protos/google/cloud/recommender/v1/recommendation.proto", + "../../protos/google/cloud/recommender/v1/recommender_config.proto", + "../../protos/google/cloud/recommender/v1/recommender_service.proto" +] diff --git a/owl-bot-staging/google-cloud-recommender/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-recommender/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..8db790db9d7 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const recommender = require('@google-cloud/recommender'); + +function main() { + const recommenderClient = new recommender.RecommenderClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-recommender/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-recommender/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..5142e8f3f3e --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {RecommenderClient} from '@google-cloud/recommender'; + +// check that the client class type name can be used +function doStuffWithRecommenderClient(client: RecommenderClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const recommenderClient = new RecommenderClient(); + doStuffWithRecommenderClient(recommenderClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-recommender/v1/system-test/install.ts b/owl-bot-staging/google-cloud-recommender/v1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/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-recommender/v1/test/gapic_recommender_v1.ts b/owl-bot-staging/google-cloud-recommender/v1/test/gapic_recommender_v1.ts new file mode 100644 index 00000000000..244e152f69f --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/test/gapic_recommender_v1.ts @@ -0,0 +1,2762 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 recommenderModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.RecommenderClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = recommenderModule.v1.RecommenderClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = recommenderModule.v1.RecommenderClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = recommenderModule.v1.RecommenderClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new recommenderModule.v1.RecommenderClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new recommenderModule.v1.RecommenderClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.recommenderStub, undefined); + await client.initialize(); + assert(client.recommenderStub); + }); + + it('has close method for the initialized client', done => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.recommenderStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.recommenderStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new recommenderModule.v1.RecommenderClient({ + 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 recommenderModule.v1.RecommenderClient({ + 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('getInsight', () => { + it('invokes getInsight without error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.GetInsightRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.GetInsightRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1.Insight() + ); + client.innerApiCalls.getInsight = stubSimpleCall(expectedResponse); + const [response] = await client.getInsight(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInsight as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInsight as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInsight without error using callback', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.GetInsightRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.GetInsightRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1.Insight() + ); + client.innerApiCalls.getInsight = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInsight( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1.IInsight|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInsight as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInsight as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInsight with error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.GetInsightRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.GetInsightRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInsight = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getInsight(request), expectedError); + const actualRequest = (client.innerApiCalls.getInsight as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInsight as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInsight with closed client', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.GetInsightRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.GetInsightRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getInsight(request), expectedError); + }); + }); + + describe('markInsightAccepted', () => { + it('invokes markInsightAccepted without error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.MarkInsightAcceptedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.MarkInsightAcceptedRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1.Insight() + ); + client.innerApiCalls.markInsightAccepted = stubSimpleCall(expectedResponse); + const [response] = await client.markInsightAccepted(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.markInsightAccepted as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markInsightAccepted as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markInsightAccepted without error using callback', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.MarkInsightAcceptedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.MarkInsightAcceptedRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1.Insight() + ); + client.innerApiCalls.markInsightAccepted = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.markInsightAccepted( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1.IInsight|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.markInsightAccepted as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markInsightAccepted as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markInsightAccepted with error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.MarkInsightAcceptedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.MarkInsightAcceptedRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.markInsightAccepted = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.markInsightAccepted(request), expectedError); + const actualRequest = (client.innerApiCalls.markInsightAccepted as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markInsightAccepted as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markInsightAccepted with closed client', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.MarkInsightAcceptedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.MarkInsightAcceptedRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.markInsightAccepted(request), expectedError); + }); + }); + + describe('getRecommendation', () => { + it('invokes getRecommendation without error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.GetRecommendationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.GetRecommendationRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1.Recommendation() + ); + client.innerApiCalls.getRecommendation = stubSimpleCall(expectedResponse); + const [response] = await client.getRecommendation(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRecommendation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRecommendation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRecommendation without error using callback', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.GetRecommendationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.GetRecommendationRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1.Recommendation() + ); + client.innerApiCalls.getRecommendation = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRecommendation( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1.IRecommendation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRecommendation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRecommendation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRecommendation with error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.GetRecommendationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.GetRecommendationRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getRecommendation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getRecommendation(request), expectedError); + const actualRequest = (client.innerApiCalls.getRecommendation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRecommendation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRecommendation with closed client', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.GetRecommendationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.GetRecommendationRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getRecommendation(request), expectedError); + }); + }); + + describe('markRecommendationClaimed', () => { + it('invokes markRecommendationClaimed without error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.MarkRecommendationClaimedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationClaimedRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1.Recommendation() + ); + client.innerApiCalls.markRecommendationClaimed = stubSimpleCall(expectedResponse); + const [response] = await client.markRecommendationClaimed(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.markRecommendationClaimed as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationClaimed as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markRecommendationClaimed without error using callback', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.MarkRecommendationClaimedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationClaimedRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1.Recommendation() + ); + client.innerApiCalls.markRecommendationClaimed = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.markRecommendationClaimed( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1.IRecommendation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.markRecommendationClaimed as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationClaimed as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markRecommendationClaimed with error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.MarkRecommendationClaimedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationClaimedRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.markRecommendationClaimed = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.markRecommendationClaimed(request), expectedError); + const actualRequest = (client.innerApiCalls.markRecommendationClaimed as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationClaimed as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markRecommendationClaimed with closed client', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.MarkRecommendationClaimedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationClaimedRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.markRecommendationClaimed(request), expectedError); + }); + }); + + describe('markRecommendationSucceeded', () => { + it('invokes markRecommendationSucceeded without error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.MarkRecommendationSucceededRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationSucceededRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1.Recommendation() + ); + client.innerApiCalls.markRecommendationSucceeded = stubSimpleCall(expectedResponse); + const [response] = await client.markRecommendationSucceeded(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markRecommendationSucceeded without error using callback', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.MarkRecommendationSucceededRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationSucceededRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1.Recommendation() + ); + client.innerApiCalls.markRecommendationSucceeded = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.markRecommendationSucceeded( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1.IRecommendation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markRecommendationSucceeded with error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.MarkRecommendationSucceededRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationSucceededRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.markRecommendationSucceeded = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.markRecommendationSucceeded(request), expectedError); + const actualRequest = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markRecommendationSucceeded with closed client', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.MarkRecommendationSucceededRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationSucceededRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.markRecommendationSucceeded(request), expectedError); + }); + }); + + describe('markRecommendationFailed', () => { + it('invokes markRecommendationFailed without error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.MarkRecommendationFailedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationFailedRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1.Recommendation() + ); + client.innerApiCalls.markRecommendationFailed = stubSimpleCall(expectedResponse); + const [response] = await client.markRecommendationFailed(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.markRecommendationFailed as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationFailed as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markRecommendationFailed without error using callback', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.MarkRecommendationFailedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationFailedRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1.Recommendation() + ); + client.innerApiCalls.markRecommendationFailed = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.markRecommendationFailed( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1.IRecommendation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.markRecommendationFailed as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationFailed as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markRecommendationFailed with error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.MarkRecommendationFailedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationFailedRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.markRecommendationFailed = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.markRecommendationFailed(request), expectedError); + const actualRequest = (client.innerApiCalls.markRecommendationFailed as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationFailed as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markRecommendationFailed with closed client', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.MarkRecommendationFailedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationFailedRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.markRecommendationFailed(request), expectedError); + }); + }); + + describe('getRecommenderConfig', () => { + it('invokes getRecommenderConfig without error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.GetRecommenderConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.GetRecommenderConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1.RecommenderConfig() + ); + client.innerApiCalls.getRecommenderConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getRecommenderConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRecommenderConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRecommenderConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRecommenderConfig without error using callback', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.GetRecommenderConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.GetRecommenderConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1.RecommenderConfig() + ); + client.innerApiCalls.getRecommenderConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRecommenderConfig( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1.IRecommenderConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRecommenderConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRecommenderConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRecommenderConfig with error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.GetRecommenderConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.GetRecommenderConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getRecommenderConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getRecommenderConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.getRecommenderConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRecommenderConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRecommenderConfig with closed client', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.GetRecommenderConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.GetRecommenderConfigRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getRecommenderConfig(request), expectedError); + }); + }); + + describe('updateRecommenderConfig', () => { + it('invokes updateRecommenderConfig without error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.UpdateRecommenderConfigRequest() + ); + request.recommenderConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.UpdateRecommenderConfigRequest', ['recommenderConfig', 'name']); + request.recommenderConfig.name = defaultValue1; + const expectedHeaderRequestParams = `recommender_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1.RecommenderConfig() + ); + client.innerApiCalls.updateRecommenderConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateRecommenderConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateRecommenderConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateRecommenderConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateRecommenderConfig without error using callback', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.UpdateRecommenderConfigRequest() + ); + request.recommenderConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.UpdateRecommenderConfigRequest', ['recommenderConfig', 'name']); + request.recommenderConfig.name = defaultValue1; + const expectedHeaderRequestParams = `recommender_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1.RecommenderConfig() + ); + client.innerApiCalls.updateRecommenderConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateRecommenderConfig( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1.IRecommenderConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateRecommenderConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateRecommenderConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateRecommenderConfig with error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.UpdateRecommenderConfigRequest() + ); + request.recommenderConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.UpdateRecommenderConfigRequest', ['recommenderConfig', 'name']); + request.recommenderConfig.name = defaultValue1; + const expectedHeaderRequestParams = `recommender_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateRecommenderConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateRecommenderConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.updateRecommenderConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateRecommenderConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateRecommenderConfig with closed client', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.UpdateRecommenderConfigRequest() + ); + request.recommenderConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.UpdateRecommenderConfigRequest', ['recommenderConfig', 'name']); + request.recommenderConfig.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateRecommenderConfig(request), expectedError); + }); + }); + + describe('getInsightTypeConfig', () => { + it('invokes getInsightTypeConfig without error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.GetInsightTypeConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.GetInsightTypeConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1.InsightTypeConfig() + ); + client.innerApiCalls.getInsightTypeConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getInsightTypeConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInsightTypeConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInsightTypeConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInsightTypeConfig without error using callback', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.GetInsightTypeConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.GetInsightTypeConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1.InsightTypeConfig() + ); + client.innerApiCalls.getInsightTypeConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInsightTypeConfig( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1.IInsightTypeConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInsightTypeConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInsightTypeConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInsightTypeConfig with error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.GetInsightTypeConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.GetInsightTypeConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInsightTypeConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getInsightTypeConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.getInsightTypeConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInsightTypeConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInsightTypeConfig with closed client', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.GetInsightTypeConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.GetInsightTypeConfigRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getInsightTypeConfig(request), expectedError); + }); + }); + + describe('updateInsightTypeConfig', () => { + it('invokes updateInsightTypeConfig without error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.UpdateInsightTypeConfigRequest() + ); + request.insightTypeConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.UpdateInsightTypeConfigRequest', ['insightTypeConfig', 'name']); + request.insightTypeConfig.name = defaultValue1; + const expectedHeaderRequestParams = `insight_type_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1.InsightTypeConfig() + ); + client.innerApiCalls.updateInsightTypeConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateInsightTypeConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInsightTypeConfig without error using callback', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.UpdateInsightTypeConfigRequest() + ); + request.insightTypeConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.UpdateInsightTypeConfigRequest', ['insightTypeConfig', 'name']); + request.insightTypeConfig.name = defaultValue1; + const expectedHeaderRequestParams = `insight_type_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1.InsightTypeConfig() + ); + client.innerApiCalls.updateInsightTypeConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateInsightTypeConfig( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1.IInsightTypeConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInsightTypeConfig with error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.UpdateInsightTypeConfigRequest() + ); + request.insightTypeConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.UpdateInsightTypeConfigRequest', ['insightTypeConfig', 'name']); + request.insightTypeConfig.name = defaultValue1; + const expectedHeaderRequestParams = `insight_type_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInsightTypeConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateInsightTypeConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInsightTypeConfig with closed client', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.UpdateInsightTypeConfigRequest() + ); + request.insightTypeConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.UpdateInsightTypeConfigRequest', ['insightTypeConfig', 'name']); + request.insightTypeConfig.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateInsightTypeConfig(request), expectedError); + }); + }); + + describe('listInsights', () => { + it('invokes listInsights without error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.ListInsightsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.ListInsightsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), + generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), + generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), + ]; + client.innerApiCalls.listInsights = stubSimpleCall(expectedResponse); + const [response] = await client.listInsights(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInsights as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInsights as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInsights without error using callback', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.ListInsightsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.ListInsightsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), + generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), + generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), + ]; + client.innerApiCalls.listInsights = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInsights( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1.IInsight[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInsights as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInsights as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInsights with error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.ListInsightsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.ListInsightsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInsights = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listInsights(request), expectedError); + const actualRequest = (client.innerApiCalls.listInsights as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInsights as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInsightsStream without error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.ListInsightsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.ListInsightsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), + generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), + generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), + ]; + client.descriptors.page.listInsights.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listInsightsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recommender.v1.Insight[] = []; + stream.on('data', (response: protos.google.cloud.recommender.v1.Insight) => { + 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.listInsights.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInsights, request)); + assert( + (client.descriptors.page.listInsights.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listInsightsStream with error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.ListInsightsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.ListInsightsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInsights.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listInsightsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recommender.v1.Insight[] = []; + stream.on('data', (response: protos.google.cloud.recommender.v1.Insight) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listInsights.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInsights, request)); + assert( + (client.descriptors.page.listInsights.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInsights without error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.ListInsightsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.ListInsightsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), + generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), + generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), + ]; + client.descriptors.page.listInsights.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.recommender.v1.IInsight[] = []; + const iterable = client.listInsightsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listInsights.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInsights.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInsights with error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.ListInsightsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.ListInsightsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInsights.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInsightsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.recommender.v1.IInsight[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listInsights.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInsights.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listRecommendations', () => { + it('invokes listRecommendations without error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.ListRecommendationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.ListRecommendationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), + generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), + generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), + ]; + client.innerApiCalls.listRecommendations = stubSimpleCall(expectedResponse); + const [response] = await client.listRecommendations(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listRecommendations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRecommendations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRecommendations without error using callback', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.ListRecommendationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.ListRecommendationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), + generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), + generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), + ]; + client.innerApiCalls.listRecommendations = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listRecommendations( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1.IRecommendation[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listRecommendations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRecommendations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRecommendations with error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.ListRecommendationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.ListRecommendationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listRecommendations = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listRecommendations(request), expectedError); + const actualRequest = (client.innerApiCalls.listRecommendations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRecommendations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRecommendationsStream without error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.ListRecommendationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.ListRecommendationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), + generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), + generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), + ]; + client.descriptors.page.listRecommendations.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listRecommendationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recommender.v1.Recommendation[] = []; + stream.on('data', (response: protos.google.cloud.recommender.v1.Recommendation) => { + 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.listRecommendations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRecommendations, request)); + assert( + (client.descriptors.page.listRecommendations.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listRecommendationsStream with error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.ListRecommendationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.ListRecommendationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRecommendations.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listRecommendationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recommender.v1.Recommendation[] = []; + stream.on('data', (response: protos.google.cloud.recommender.v1.Recommendation) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listRecommendations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRecommendations, request)); + assert( + (client.descriptors.page.listRecommendations.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listRecommendations without error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.ListRecommendationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.ListRecommendationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), + generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), + generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), + ]; + client.descriptors.page.listRecommendations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.recommender.v1.IRecommendation[] = []; + const iterable = client.listRecommendationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listRecommendations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listRecommendations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listRecommendations with error', async () => { + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1.ListRecommendationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1.ListRecommendationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRecommendations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listRecommendationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.recommender.v1.IRecommendation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listRecommendations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listRecommendations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('billingAccountLocationInsightType', () => { + const fakePath = "/rendered/path/billingAccountLocationInsightType"; + const expectedParameters = { + billing_account: "billingAccountValue", + location: "locationValue", + insight_type: "insightTypeValue", + }; + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.billingAccountLocationInsightTypePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.billingAccountLocationInsightTypePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('billingAccountLocationInsightTypePath', () => { + const result = client.billingAccountLocationInsightTypePath("billingAccountValue", "locationValue", "insightTypeValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.billingAccountLocationInsightTypePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchBillingAccountFromBillingAccountLocationInsightTypeName', () => { + const result = client.matchBillingAccountFromBillingAccountLocationInsightTypeName(fakePath); + assert.strictEqual(result, "billingAccountValue"); + assert((client.pathTemplates.billingAccountLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBillingAccountLocationInsightTypeName', () => { + const result = client.matchLocationFromBillingAccountLocationInsightTypeName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.billingAccountLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightTypeFromBillingAccountLocationInsightTypeName', () => { + const result = client.matchInsightTypeFromBillingAccountLocationInsightTypeName(fakePath); + assert.strictEqual(result, "insightTypeValue"); + assert((client.pathTemplates.billingAccountLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('billingAccountLocationInsightTypeInsight', () => { + const fakePath = "/rendered/path/billingAccountLocationInsightTypeInsight"; + const expectedParameters = { + billing_account: "billingAccountValue", + location: "locationValue", + insight_type: "insightTypeValue", + insight: "insightValue", + }; + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('billingAccountLocationInsightTypeInsightPath', () => { + const result = client.billingAccountLocationInsightTypeInsightPath("billingAccountValue", "locationValue", "insightTypeValue", "insightValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchBillingAccountFromBillingAccountLocationInsightTypeInsightName', () => { + const result = client.matchBillingAccountFromBillingAccountLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "billingAccountValue"); + assert((client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBillingAccountLocationInsightTypeInsightName', () => { + const result = client.matchLocationFromBillingAccountLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightTypeFromBillingAccountLocationInsightTypeInsightName', () => { + const result = client.matchInsightTypeFromBillingAccountLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "insightTypeValue"); + assert((client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightFromBillingAccountLocationInsightTypeInsightName', () => { + const result = client.matchInsightFromBillingAccountLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "insightValue"); + assert((client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('billingAccountLocationRecommender', () => { + const fakePath = "/rendered/path/billingAccountLocationRecommender"; + const expectedParameters = { + billing_account: "billingAccountValue", + location: "locationValue", + recommender: "recommenderValue", + }; + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.billingAccountLocationRecommenderPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.billingAccountLocationRecommenderPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('billingAccountLocationRecommenderPath', () => { + const result = client.billingAccountLocationRecommenderPath("billingAccountValue", "locationValue", "recommenderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.billingAccountLocationRecommenderPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchBillingAccountFromBillingAccountLocationRecommenderName', () => { + const result = client.matchBillingAccountFromBillingAccountLocationRecommenderName(fakePath); + assert.strictEqual(result, "billingAccountValue"); + assert((client.pathTemplates.billingAccountLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBillingAccountLocationRecommenderName', () => { + const result = client.matchLocationFromBillingAccountLocationRecommenderName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.billingAccountLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommenderFromBillingAccountLocationRecommenderName', () => { + const result = client.matchRecommenderFromBillingAccountLocationRecommenderName(fakePath); + assert.strictEqual(result, "recommenderValue"); + assert((client.pathTemplates.billingAccountLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('billingAccountLocationRecommenderRecommendation', () => { + const fakePath = "/rendered/path/billingAccountLocationRecommenderRecommendation"; + const expectedParameters = { + billing_account: "billingAccountValue", + location: "locationValue", + recommender: "recommenderValue", + recommendation: "recommendationValue", + }; + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('billingAccountLocationRecommenderRecommendationPath', () => { + const result = client.billingAccountLocationRecommenderRecommendationPath("billingAccountValue", "locationValue", "recommenderValue", "recommendationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchBillingAccountFromBillingAccountLocationRecommenderRecommendationName', () => { + const result = client.matchBillingAccountFromBillingAccountLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "billingAccountValue"); + assert((client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBillingAccountLocationRecommenderRecommendationName', () => { + const result = client.matchLocationFromBillingAccountLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommenderFromBillingAccountLocationRecommenderRecommendationName', () => { + const result = client.matchRecommenderFromBillingAccountLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "recommenderValue"); + assert((client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommendationFromBillingAccountLocationRecommenderRecommendationName', () => { + const result = client.matchRecommendationFromBillingAccountLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "recommendationValue"); + assert((client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('folderLocationInsightType', () => { + const fakePath = "/rendered/path/folderLocationInsightType"; + const expectedParameters = { + folder: "folderValue", + location: "locationValue", + insight_type: "insightTypeValue", + }; + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderLocationInsightTypePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderLocationInsightTypePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderLocationInsightTypePath', () => { + const result = client.folderLocationInsightTypePath("folderValue", "locationValue", "insightTypeValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderLocationInsightTypePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderLocationInsightTypeName', () => { + const result = client.matchFolderFromFolderLocationInsightTypeName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromFolderLocationInsightTypeName', () => { + const result = client.matchLocationFromFolderLocationInsightTypeName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.folderLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightTypeFromFolderLocationInsightTypeName', () => { + const result = client.matchInsightTypeFromFolderLocationInsightTypeName(fakePath); + assert.strictEqual(result, "insightTypeValue"); + assert((client.pathTemplates.folderLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('folderLocationInsightTypeInsight', () => { + const fakePath = "/rendered/path/folderLocationInsightTypeInsight"; + const expectedParameters = { + folder: "folderValue", + location: "locationValue", + insight_type: "insightTypeValue", + insight: "insightValue", + }; + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderLocationInsightTypeInsightPath', () => { + const result = client.folderLocationInsightTypeInsightPath("folderValue", "locationValue", "insightTypeValue", "insightValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderLocationInsightTypeInsightName', () => { + const result = client.matchFolderFromFolderLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromFolderLocationInsightTypeInsightName', () => { + const result = client.matchLocationFromFolderLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightTypeFromFolderLocationInsightTypeInsightName', () => { + const result = client.matchInsightTypeFromFolderLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "insightTypeValue"); + assert((client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightFromFolderLocationInsightTypeInsightName', () => { + const result = client.matchInsightFromFolderLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "insightValue"); + assert((client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('folderLocationRecommender', () => { + const fakePath = "/rendered/path/folderLocationRecommender"; + const expectedParameters = { + folder: "folderValue", + location: "locationValue", + recommender: "recommenderValue", + }; + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderLocationRecommenderPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderLocationRecommenderPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderLocationRecommenderPath', () => { + const result = client.folderLocationRecommenderPath("folderValue", "locationValue", "recommenderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderLocationRecommenderPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderLocationRecommenderName', () => { + const result = client.matchFolderFromFolderLocationRecommenderName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromFolderLocationRecommenderName', () => { + const result = client.matchLocationFromFolderLocationRecommenderName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.folderLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommenderFromFolderLocationRecommenderName', () => { + const result = client.matchRecommenderFromFolderLocationRecommenderName(fakePath); + assert.strictEqual(result, "recommenderValue"); + assert((client.pathTemplates.folderLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('folderLocationRecommenderRecommendation', () => { + const fakePath = "/rendered/path/folderLocationRecommenderRecommendation"; + const expectedParameters = { + folder: "folderValue", + location: "locationValue", + recommender: "recommenderValue", + recommendation: "recommendationValue", + }; + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderLocationRecommenderRecommendationPath', () => { + const result = client.folderLocationRecommenderRecommendationPath("folderValue", "locationValue", "recommenderValue", "recommendationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderLocationRecommenderRecommendationName', () => { + const result = client.matchFolderFromFolderLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromFolderLocationRecommenderRecommendationName', () => { + const result = client.matchLocationFromFolderLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommenderFromFolderLocationRecommenderRecommendationName', () => { + const result = client.matchRecommenderFromFolderLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "recommenderValue"); + assert((client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommendationFromFolderLocationRecommenderRecommendationName', () => { + const result = client.matchRecommendationFromFolderLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "recommendationValue"); + assert((client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organizationLocationInsightType', () => { + const fakePath = "/rendered/path/organizationLocationInsightType"; + const expectedParameters = { + organization: "organizationValue", + location: "locationValue", + insight_type: "insightTypeValue", + }; + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationLocationInsightTypePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationLocationInsightTypePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationLocationInsightTypePath', () => { + const result = client.organizationLocationInsightTypePath("organizationValue", "locationValue", "insightTypeValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationLocationInsightTypePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationLocationInsightTypeName', () => { + const result = client.matchOrganizationFromOrganizationLocationInsightTypeName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromOrganizationLocationInsightTypeName', () => { + const result = client.matchLocationFromOrganizationLocationInsightTypeName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.organizationLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightTypeFromOrganizationLocationInsightTypeName', () => { + const result = client.matchInsightTypeFromOrganizationLocationInsightTypeName(fakePath); + assert.strictEqual(result, "insightTypeValue"); + assert((client.pathTemplates.organizationLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organizationLocationInsightTypeConfig', () => { + const fakePath = "/rendered/path/organizationLocationInsightTypeConfig"; + const expectedParameters = { + organization: "organizationValue", + location: "locationValue", + insight_type: "insightTypeValue", + }; + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationLocationInsightTypeConfigPath', () => { + const result = client.organizationLocationInsightTypeConfigPath("organizationValue", "locationValue", "insightTypeValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationLocationInsightTypeConfigName', () => { + const result = client.matchOrganizationFromOrganizationLocationInsightTypeConfigName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromOrganizationLocationInsightTypeConfigName', () => { + const result = client.matchLocationFromOrganizationLocationInsightTypeConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightTypeFromOrganizationLocationInsightTypeConfigName', () => { + const result = client.matchInsightTypeFromOrganizationLocationInsightTypeConfigName(fakePath); + assert.strictEqual(result, "insightTypeValue"); + assert((client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organizationLocationInsightTypeInsight', () => { + const fakePath = "/rendered/path/organizationLocationInsightTypeInsight"; + const expectedParameters = { + organization: "organizationValue", + location: "locationValue", + insight_type: "insightTypeValue", + insight: "insightValue", + }; + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationLocationInsightTypeInsightPath', () => { + const result = client.organizationLocationInsightTypeInsightPath("organizationValue", "locationValue", "insightTypeValue", "insightValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationLocationInsightTypeInsightName', () => { + const result = client.matchOrganizationFromOrganizationLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromOrganizationLocationInsightTypeInsightName', () => { + const result = client.matchLocationFromOrganizationLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightTypeFromOrganizationLocationInsightTypeInsightName', () => { + const result = client.matchInsightTypeFromOrganizationLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "insightTypeValue"); + assert((client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightFromOrganizationLocationInsightTypeInsightName', () => { + const result = client.matchInsightFromOrganizationLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "insightValue"); + assert((client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organizationLocationRecommender', () => { + const fakePath = "/rendered/path/organizationLocationRecommender"; + const expectedParameters = { + organization: "organizationValue", + location: "locationValue", + recommender: "recommenderValue", + }; + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationLocationRecommenderPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationLocationRecommenderPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationLocationRecommenderPath', () => { + const result = client.organizationLocationRecommenderPath("organizationValue", "locationValue", "recommenderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationLocationRecommenderPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationLocationRecommenderName', () => { + const result = client.matchOrganizationFromOrganizationLocationRecommenderName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromOrganizationLocationRecommenderName', () => { + const result = client.matchLocationFromOrganizationLocationRecommenderName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.organizationLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommenderFromOrganizationLocationRecommenderName', () => { + const result = client.matchRecommenderFromOrganizationLocationRecommenderName(fakePath); + assert.strictEqual(result, "recommenderValue"); + assert((client.pathTemplates.organizationLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organizationLocationRecommenderConfig', () => { + const fakePath = "/rendered/path/organizationLocationRecommenderConfig"; + const expectedParameters = { + organization: "organizationValue", + location: "locationValue", + recommender: "recommenderValue", + }; + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationLocationRecommenderConfigPath', () => { + const result = client.organizationLocationRecommenderConfigPath("organizationValue", "locationValue", "recommenderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationLocationRecommenderConfigName', () => { + const result = client.matchOrganizationFromOrganizationLocationRecommenderConfigName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromOrganizationLocationRecommenderConfigName', () => { + const result = client.matchLocationFromOrganizationLocationRecommenderConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommenderFromOrganizationLocationRecommenderConfigName', () => { + const result = client.matchRecommenderFromOrganizationLocationRecommenderConfigName(fakePath); + assert.strictEqual(result, "recommenderValue"); + assert((client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organizationLocationRecommenderRecommendation', () => { + const fakePath = "/rendered/path/organizationLocationRecommenderRecommendation"; + const expectedParameters = { + organization: "organizationValue", + location: "locationValue", + recommender: "recommenderValue", + recommendation: "recommendationValue", + }; + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationLocationRecommenderRecommendationPath', () => { + const result = client.organizationLocationRecommenderRecommendationPath("organizationValue", "locationValue", "recommenderValue", "recommendationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationLocationRecommenderRecommendationName', () => { + const result = client.matchOrganizationFromOrganizationLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromOrganizationLocationRecommenderRecommendationName', () => { + const result = client.matchLocationFromOrganizationLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommenderFromOrganizationLocationRecommenderRecommendationName', () => { + const result = client.matchRecommenderFromOrganizationLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "recommenderValue"); + assert((client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommendationFromOrganizationLocationRecommenderRecommendationName', () => { + const result = client.matchRecommendationFromOrganizationLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "recommendationValue"); + assert((client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationInsightType', () => { + const fakePath = "/rendered/path/projectLocationInsightType"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + insight_type: "insightTypeValue", + }; + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationInsightTypePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationInsightTypePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationInsightTypePath', () => { + const result = client.projectLocationInsightTypePath("projectValue", "locationValue", "insightTypeValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationInsightTypePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationInsightTypeName', () => { + const result = client.matchProjectFromProjectLocationInsightTypeName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationInsightTypeName', () => { + const result = client.matchLocationFromProjectLocationInsightTypeName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightTypeFromProjectLocationInsightTypeName', () => { + const result = client.matchInsightTypeFromProjectLocationInsightTypeName(fakePath); + assert.strictEqual(result, "insightTypeValue"); + assert((client.pathTemplates.projectLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationInsightTypeConfig', () => { + const fakePath = "/rendered/path/projectLocationInsightTypeConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + insight_type: "insightTypeValue", + }; + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationInsightTypeConfigPath', () => { + const result = client.projectLocationInsightTypeConfigPath("projectValue", "locationValue", "insightTypeValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationInsightTypeConfigName', () => { + const result = client.matchProjectFromProjectLocationInsightTypeConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationInsightTypeConfigName', () => { + const result = client.matchLocationFromProjectLocationInsightTypeConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightTypeFromProjectLocationInsightTypeConfigName', () => { + const result = client.matchInsightTypeFromProjectLocationInsightTypeConfigName(fakePath); + assert.strictEqual(result, "insightTypeValue"); + assert((client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationInsightTypeInsight', () => { + const fakePath = "/rendered/path/projectLocationInsightTypeInsight"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + insight_type: "insightTypeValue", + insight: "insightValue", + }; + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationInsightTypeInsightPath', () => { + const result = client.projectLocationInsightTypeInsightPath("projectValue", "locationValue", "insightTypeValue", "insightValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationInsightTypeInsightName', () => { + const result = client.matchProjectFromProjectLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationInsightTypeInsightName', () => { + const result = client.matchLocationFromProjectLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightTypeFromProjectLocationInsightTypeInsightName', () => { + const result = client.matchInsightTypeFromProjectLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "insightTypeValue"); + assert((client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightFromProjectLocationInsightTypeInsightName', () => { + const result = client.matchInsightFromProjectLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "insightValue"); + assert((client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationRecommender', () => { + const fakePath = "/rendered/path/projectLocationRecommender"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + recommender: "recommenderValue", + }; + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationRecommenderPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationRecommenderPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationRecommenderPath', () => { + const result = client.projectLocationRecommenderPath("projectValue", "locationValue", "recommenderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationRecommenderPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationRecommenderName', () => { + const result = client.matchProjectFromProjectLocationRecommenderName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationRecommenderName', () => { + const result = client.matchLocationFromProjectLocationRecommenderName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommenderFromProjectLocationRecommenderName', () => { + const result = client.matchRecommenderFromProjectLocationRecommenderName(fakePath); + assert.strictEqual(result, "recommenderValue"); + assert((client.pathTemplates.projectLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationRecommenderConfig', () => { + const fakePath = "/rendered/path/projectLocationRecommenderConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + recommender: "recommenderValue", + }; + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationRecommenderConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationRecommenderConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationRecommenderConfigPath', () => { + const result = client.projectLocationRecommenderConfigPath("projectValue", "locationValue", "recommenderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationRecommenderConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationRecommenderConfigName', () => { + const result = client.matchProjectFromProjectLocationRecommenderConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationRecommenderConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationRecommenderConfigName', () => { + const result = client.matchLocationFromProjectLocationRecommenderConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationRecommenderConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommenderFromProjectLocationRecommenderConfigName', () => { + const result = client.matchRecommenderFromProjectLocationRecommenderConfigName(fakePath); + assert.strictEqual(result, "recommenderValue"); + assert((client.pathTemplates.projectLocationRecommenderConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationRecommenderRecommendation', () => { + const fakePath = "/rendered/path/projectLocationRecommenderRecommendation"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + recommender: "recommenderValue", + recommendation: "recommendationValue", + }; + const client = new recommenderModule.v1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationRecommenderRecommendationPath', () => { + const result = client.projectLocationRecommenderRecommendationPath("projectValue", "locationValue", "recommenderValue", "recommendationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationRecommenderRecommendationName', () => { + const result = client.matchProjectFromProjectLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationRecommenderRecommendationName', () => { + const result = client.matchLocationFromProjectLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommenderFromProjectLocationRecommenderRecommendationName', () => { + const result = client.matchRecommenderFromProjectLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "recommenderValue"); + assert((client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommendationFromProjectLocationRecommenderRecommendationName', () => { + const result = client.matchRecommendationFromProjectLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "recommendationValue"); + assert((client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-recommender/v1/tsconfig.json b/owl-bot-staging/google-cloud-recommender/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-recommender/v1/webpack.config.js b/owl-bot-staging/google-cloud-recommender/v1/webpack.config.js new file mode 100644 index 00000000000..a74f57c48a0 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'Recommender', + filename: './recommender.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-recommender/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-recommender/v1beta1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-recommender/v1beta1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/.gitignore b/owl-bot-staging/google-cloud-recommender/v1beta1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-recommender/v1beta1/.jsdoc.js new file mode 100644 index 00000000000..c2e2fb04e21 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/.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/recommender', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-recommender/v1beta1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/.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-recommender/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-recommender/v1beta1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/.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-recommender/v1beta1/README.md b/owl-bot-staging/google-cloud-recommender/v1beta1/README.md new file mode 100644 index 00000000000..59dc6bb7bb1 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/README.md @@ -0,0 +1 @@ +Recommender: Nodejs Client diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/package.json b/owl-bot-staging/google-cloud-recommender/v1beta1/package.json new file mode 100644 index 00000000000..5f3c60b1639 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/recommender", + "version": "0.1.0", + "description": "Recommender client for Node.js", + "repository": "googleapis/nodejs-recommender", + "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 recommender", + "recommender", + "recommender" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/insight.proto b/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/insight.proto new file mode 100644 index 00000000000..2fc7f6477e6 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/insight.proto @@ -0,0 +1,161 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.recommender.v1beta1; + +import "google/api/resource.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Recommender.V1Beta1"; +option go_package = "cloud.google.com/go/recommender/apiv1beta1/recommenderpb;recommenderpb"; +option java_multiple_files = true; +option java_package = "com.google.cloud.recommender.v1beta1"; +option objc_class_prefix = "CREC"; +option (google.api.resource_definition) = { + type: "recommender.googleapis.com/InsightType" + pattern: "projects/{project}/locations/{location}/insightTypes/{insight_type}" + pattern: "billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}" + pattern: "folders/{folder}/locations/{location}/insightTypes/{insight_type}" + pattern: "organizations/{organization}/locations/{location}/insightTypes/{insight_type}" +}; + +// An insight along with the information used to derive the insight. The insight +// may have associated recomendations as well. +message Insight { + option (google.api.resource) = { + type: "recommender.googleapis.com/Insight" + pattern: "projects/{project}/locations/{location}/insightTypes/{insight_type}/insights/{insight}" + pattern: "billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}/insights/{insight}" + pattern: "folders/{folder}/locations/{location}/insightTypes/{insight_type}/insights/{insight}" + pattern: "organizations/{organization}/locations/{location}/insightTypes/{insight_type}/insights/{insight}" + }; + + // Insight category. + enum Category { + // Unspecified category. + CATEGORY_UNSPECIFIED = 0; + + // The insight is related to cost. + COST = 1; + + // The insight is related to security. + SECURITY = 2; + + // The insight is related to performance. + PERFORMANCE = 3; + + // This insight is related to manageability. + MANAGEABILITY = 4; + } + + // Insight severity levels. + enum Severity { + // Insight has unspecified severity. + SEVERITY_UNSPECIFIED = 0; + + // Insight has low severity. + LOW = 1; + + // Insight has medium severity. + MEDIUM = 2; + + // Insight has high severity. + HIGH = 3; + + // Insight has critical severity. + CRITICAL = 4; + } + + // Reference to an associated recommendation. + message RecommendationReference { + // Recommendation resource name, e.g. + // projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/recommendations/[RECOMMENDATION_ID] + string recommendation = 1; + } + + // Name of the insight. + string name = 1; + + // Free-form human readable summary in English. The maximum length is 500 + // characters. + string description = 2; + + // Fully qualified resource names that this insight is targeting. + repeated string target_resources = 9; + + // Insight subtype. Insight content schema will be stable for a given subtype. + string insight_subtype = 10; + + // A struct of custom fields to explain the insight. + // Example: "grantedPermissionsCount": "1000" + google.protobuf.Struct content = 3; + + // Timestamp of the latest data used to generate the insight. + google.protobuf.Timestamp last_refresh_time = 4; + + // Observation period that led to the insight. The source data used to + // generate the insight ends at last_refresh_time and begins at + // (last_refresh_time - observation_period). + google.protobuf.Duration observation_period = 5; + + // Information state and metadata. + InsightStateInfo state_info = 6; + + // Category being targeted by the insight. + Category category = 7; + + // Insight's severity. + Severity severity = 15; + + // Fingerprint of the Insight. Provides optimistic locking when updating + // states. + string etag = 11; + + // Recommendations derived from this insight. + repeated RecommendationReference associated_recommendations = 8; +} + +// Information related to insight state. +message InsightStateInfo { + // Represents insight state. + enum State { + // Unspecified state. + STATE_UNSPECIFIED = 0; + + // Insight is active. Content for ACTIVE insights can be updated by Google. + // ACTIVE insights can be marked DISMISSED OR ACCEPTED. + ACTIVE = 1; + + // Some action has been taken based on this insight. Insights become + // accepted when a recommendation derived from the insight has been marked + // CLAIMED, SUCCEEDED, or FAILED. ACTIVE insights can also be marked + // ACCEPTED explicitly. Content for ACCEPTED insights is immutable. ACCEPTED + // insights can only be marked ACCEPTED (which may update state metadata). + ACCEPTED = 2; + + // Insight is dismissed. Content for DISMISSED insights can be updated by + // Google. DISMISSED insights can be marked as ACTIVE. + DISMISSED = 3; + } + + // Insight state. + State state = 1; + + // A map of metadata for the state, provided by user or automations systems. + map state_metadata = 2; +} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/insight_type_config.proto b/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/insight_type_config.proto new file mode 100644 index 00000000000..e910a3d26d3 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/insight_type_config.proto @@ -0,0 +1,85 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.recommender.v1beta1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Recommender.V1Beta1"; +option go_package = "cloud.google.com/go/recommender/apiv1beta1/recommenderpb;recommenderpb"; +option java_multiple_files = true; +option java_outer_classname = "InsightTypeConfigProto"; +option java_package = "com.google.cloud.recommender.v1beta1"; +option objc_class_prefix = "CREC"; + +// Configuration for an InsightType. +message InsightTypeConfig { + option (google.api.resource) = { + type: "recommender.googleapis.com/InsightTypeConfig" + pattern: "projects/{project}/locations/{location}/insightTypes/{insight_type}/config" + pattern: "organizations/{organization}/locations/{location}/insightTypes/{insight_type}/config" + }; + + // Name of insight type config. + // Eg, + // projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config + string name = 1; + + // InsightTypeGenerationConfig which configures the generation of + // insights for this insight type. + InsightTypeGenerationConfig insight_type_generation_config = 2; + + // Fingerprint of the InsightTypeConfig. Provides optimistic locking when + // updating. + string etag = 3; + + // Last time when the config was updated. + google.protobuf.Timestamp update_time = 4; + + // Output only. Immutable. The revision ID of the config. + // A new revision is committed whenever the config is changed in any way. + // The format is an 8-character hexadecimal string. + string revision_id = 5 [ + (google.api.field_behavior) = IMMUTABLE, + (google.api.field_behavior) = OUTPUT_ONLY + ]; + + // Allows clients to store small amounts of arbitrary data. Annotations must + // follow the Kubernetes syntax. + // The total size of all keys and values combined is limited to 256k. + // Key can have 2 segments: prefix (optional) and name (required), + // separated by a slash (/). + // Prefix must be a DNS subdomain. + // Name must be 63 characters or less, begin and end with alphanumerics, + // with dashes (-), underscores (_), dots (.), and alphanumerics between. + map annotations = 6; + + // A user-settable field to provide a human-readable name to be used in user + // interfaces. + string display_name = 7; +} + +// A configuration to customize the generation of insights. +// Eg, customizing the lookback period considered when generating a +// insight. +message InsightTypeGenerationConfig { + // Parameters for this InsightTypeGenerationConfig. These configs can be used + // by or are applied to all subtypes. + google.protobuf.Struct params = 1; +} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommendation.proto b/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommendation.proto new file mode 100644 index 00000000000..390958c62ce --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommendation.proto @@ -0,0 +1,361 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.recommender.v1beta1; + +import "google/api/resource.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/money.proto"; + +option csharp_namespace = "Google.Cloud.Recommender.V1Beta1"; +option go_package = "cloud.google.com/go/recommender/apiv1beta1/recommenderpb;recommenderpb"; +option java_multiple_files = true; +option java_package = "com.google.cloud.recommender.v1beta1"; +option objc_class_prefix = "CREC"; +option (google.api.resource_definition) = { + type: "recommender.googleapis.com/Recommender" + pattern: "projects/{project}/locations/{location}/recommenders/{recommender}" + pattern: "billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}" + pattern: "folders/{folder}/locations/{location}/recommenders/{recommender}" + pattern: "organizations/{organization}/locations/{location}/recommenders/{recommender}" +}; + +// A recommendation along with a suggested action. E.g., a rightsizing +// recommendation for an underutilized VM, IAM role recommendations, etc +message Recommendation { + option (google.api.resource) = { + type: "recommender.googleapis.com/Recommendation" + pattern: "projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}" + pattern: "billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}" + pattern: "folders/{folder}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}" + pattern: "organizations/{organization}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}" + }; + + // Recommendation priority levels. + enum Priority { + // Recommendation has unspecified priority. + PRIORITY_UNSPECIFIED = 0; + + // Recommendation has P4 priority (lowest priority). + P4 = 1; + + // Recommendation has P3 priority (second lowest priority). + P3 = 2; + + // Recommendation has P2 priority (second highest priority). + P2 = 3; + + // Recommendation has P1 priority (highest priority). + P1 = 4; + } + + // Reference to an associated insight. + message InsightReference { + // Insight resource name, e.g. + // projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/insights/[INSIGHT_ID] + string insight = 1; + } + + // Name of recommendation. + string name = 1; + + // Free-form human readable summary in English. The maximum length is 500 + // characters. + string description = 2; + + // Contains an identifier for a subtype of recommendations produced for the + // same recommender. Subtype is a function of content and impact, meaning a + // new subtype might be added when significant changes to `content` or + // `primary_impact.category` are introduced. See the Recommenders section + // to see a list of subtypes for a given Recommender. + // + // Examples: + // For recommender = "google.iam.policy.Recommender", + // recommender_subtype can be one of "REMOVE_ROLE"/"REPLACE_ROLE" + string recommender_subtype = 12; + + // Last time this recommendation was refreshed by the system that created it + // in the first place. + google.protobuf.Timestamp last_refresh_time = 4; + + // The primary impact that this recommendation can have while trying to + // optimize for one category. + Impact primary_impact = 5; + + // Optional set of additional impact that this recommendation may have when + // trying to optimize for the primary category. These may be positive + // or negative. + repeated Impact additional_impact = 6; + + // Recommendation's priority. + Priority priority = 17; + + // Content of the recommendation describing recommended changes to resources. + RecommendationContent content = 7; + + // Information for state. Contains state and metadata. + RecommendationStateInfo state_info = 10; + + // Fingerprint of the Recommendation. Provides optimistic locking when + // updating states. + string etag = 11; + + // Insights that led to this recommendation. + repeated InsightReference associated_insights = 14; + + // Corresponds to a mutually exclusive group ID within a recommender. + // A non-empty ID indicates that the recommendation belongs to a mutually + // exclusive group. This means that only one recommendation within the group + // is suggested to be applied. + string xor_group_id = 18; +} + +// Contains what resources are changing and how they are changing. +message RecommendationContent { + // Operations to one or more Google Cloud resources grouped in such a way + // that, all operations within one group are expected to be performed + // atomically and in an order. + repeated OperationGroup operation_groups = 2; + + // Condensed overview information about the recommendation. + google.protobuf.Struct overview = 3; +} + +// Group of operations that need to be performed atomically. +message OperationGroup { + // List of operations across one or more resources that belong to this group. + // Loosely based on RFC6902 and should be performed in the order they appear. + repeated Operation operations = 1; +} + +// Contains an operation for a resource loosely based on the JSON-PATCH format +// with support for: +// +// * Custom filters for describing partial array patch. +// * Extended path values for describing nested arrays. +// * Custom fields for describing the resource for which the operation is being +// described. +// * Allows extension to custom operations not natively supported by RFC6902. +// See https://tools.ietf.org/html/rfc6902 for details on the original RFC. +message Operation { + // Type of this operation. Contains one of 'add', 'remove', 'replace', 'move', + // 'copy', 'test' and 'custom' operations. This field is case-insensitive and + // always populated. + string action = 1; + + // Type of GCP resource being modified/tested. This field is always populated. + // Example: cloudresourcemanager.googleapis.com/Project, + // compute.googleapis.com/Instance + string resource_type = 2; + + // Contains the fully qualified resource name. This field is always populated. + // ex: //cloudresourcemanager.googleapis.com/projects/foo. + string resource = 3; + + // Path to the target field being operated on. If the operation is at the + // resource level, then path should be "/". This field is always populated. + string path = 4; + + // Can be set with action 'copy' to copy resource configuration across + // different resources of the same type. Example: A resource clone can be + // done via action = 'copy', path = "/", from = "/", + // source_resource = and resource_name = . + // This field is empty for all other values of `action`. + string source_resource = 5; + + // Can be set with action 'copy' or 'move' to indicate the source field within + // resource or source_resource, ignored if provided for other operation types. + string source_path = 6; + + // One of the fields in the following block will be set and intend to + // describe a value for 'path' field. + oneof path_value { + // Value for the `path` field. Will be set for actions:'add'/'replace'. + // Maybe set for action: 'test'. Either this or `value_matcher` will be set + // for 'test' operation. An exact match must be performed. + google.protobuf.Value value = 7; + + // Can be set for action 'test' for advanced matching for the value of + // 'path' field. Either this or `value` will be set for 'test' operation. + ValueMatcher value_matcher = 10; + } + + // Set of filters to apply if `path` refers to array elements or nested array + // elements in order to narrow down to a single unique element that is being + // tested/modified. + // This is intended to be an exact match per filter. To perform advanced + // matching, use path_value_matchers. + // + // * Example: + // ``` + // { + // "/versions/*/name" : "it-123" + // "/versions/*/targetSize/percent": 20 + // } + // ``` + // * Example: + // ``` + // { + // "/bindings/*/role": "roles/owner" + // "/bindings/*/condition" : null + // } + // ``` + // * Example: + // ``` + // { + // "/bindings/*/role": "roles/owner" + // "/bindings/*/members/*" : ["x@example.com", "y@example.com"] + // } + // ``` + // When both path_filters and path_value_matchers are set, an implicit AND + // must be performed. + map path_filters = 8; + + // Similar to path_filters, this contains set of filters to apply if `path` + // field refers to array elements. This is meant to support value matching + // beyond exact match. To perform exact match, use path_filters. + // When both path_filters and path_value_matchers are set, an implicit AND + // must be performed. + map path_value_matchers = 11; +} + +// Contains various matching options for values for a GCP resource field. +message ValueMatcher { + oneof match_variant { + // To be used for full regex matching. The regular expression is using the + // Google RE2 syntax (https://github.com/google/re2/wiki/Syntax), so to be + // used with RE2::FullMatch + string matches_pattern = 1; + } +} + +// Contains metadata about how much money a recommendation can save or incur. +message CostProjection { + // An approximate projection on amount saved or amount incurred. Negative cost + // units indicate cost savings and positive cost units indicate increase. + // See google.type.Money documentation for positive/negative units. + // + // A user's permissions may affect whether the cost is computed using list + // prices or custom contract prices. + google.type.Money cost = 1; + + // Duration for which this cost applies. + google.protobuf.Duration duration = 2; +} + +// Contains various ways of describing the impact on Security. +message SecurityProjection { + // This field can be used by the recommender to define details specific to + // security impact. + google.protobuf.Struct details = 2; +} + +// Contains metadata about how much sustainability a recommendation can save or +// incur. +message SustainabilityProjection { + // Carbon Footprint generated in kg of CO2 equivalent. + // Chose kg_c_o2e so that the name renders correctly in camelCase (kgCO2e). + double kg_c_o2e = 1; + + // Duration for which this sustanability applies. + google.protobuf.Duration duration = 2; +} + +// Contains the impact a recommendation can have for a given category. +message Impact { + // The category of the impact. + enum Category { + // Default unspecified category. Don't use directly. + CATEGORY_UNSPECIFIED = 0; + + // Indicates a potential increase or decrease in cost. + COST = 1; + + // Indicates a potential increase or decrease in security. + SECURITY = 2; + + // Indicates a potential increase or decrease in performance. + PERFORMANCE = 3; + + // Indicates a potential increase or decrease in manageability. + MANAGEABILITY = 4; + + // Indicates a potential increase or decrease in sustainability. + SUSTAINABILITY = 5; + } + + // Category that is being targeted. + Category category = 1; + + // Contains projections (if any) for this category. + oneof projection { + // Use with CategoryType.COST + CostProjection cost_projection = 100; + + // Use with CategoryType.SECURITY + SecurityProjection security_projection = 101; + + // Use with CategoryType.SUSTAINABILITY + SustainabilityProjection sustainability_projection = 102; + } +} + +// Information for state. Contains state and metadata. +message RecommendationStateInfo { + // Represents Recommendation State. + enum State { + // Default state. Don't use directly. + STATE_UNSPECIFIED = 0; + + // Recommendation is active and can be applied. Recommendations content can + // be updated by Google. + // + // ACTIVE recommendations can be marked as CLAIMED, SUCCEEDED, or FAILED. + ACTIVE = 1; + + // Recommendation is in claimed state. Recommendations content is + // immutable and cannot be updated by Google. + // + // CLAIMED recommendations can be marked as CLAIMED, SUCCEEDED, or FAILED. + CLAIMED = 6; + + // Recommendation is in succeeded state. Recommendations content is + // immutable and cannot be updated by Google. + // + // SUCCEEDED recommendations can be marked as SUCCEEDED, or FAILED. + SUCCEEDED = 3; + + // Recommendation is in failed state. Recommendations content is immutable + // and cannot be updated by Google. + // + // FAILED recommendations can be marked as SUCCEEDED, or FAILED. + FAILED = 4; + + // Recommendation is in dismissed state. Recommendation content can be + // updated by Google. + // + // DISMISSED recommendations can be marked as ACTIVE. + DISMISSED = 5; + } + + // The state of the recommendation, Eg ACTIVE, SUCCEEDED, FAILED. + State state = 1; + + // A map of metadata for the state, provided by user or automations systems. + map state_metadata = 2; +} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommender_config.proto b/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommender_config.proto new file mode 100644 index 00000000000..834f17beadb --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommender_config.proto @@ -0,0 +1,85 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.recommender.v1beta1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Recommender.V1Beta1"; +option go_package = "cloud.google.com/go/recommender/apiv1beta1/recommenderpb;recommenderpb"; +option java_multiple_files = true; +option java_outer_classname = "RecommenderConfigProto"; +option java_package = "com.google.cloud.recommender.v1beta1"; +option objc_class_prefix = "CREC"; + +// Configuration for a Recommender. +message RecommenderConfig { + option (google.api.resource) = { + type: "recommender.googleapis.com/RecommenderConfig" + pattern: "projects/{project}/locations/{location}/recommenders/{recommender}/config" + pattern: "organizations/{organization}/locations/{location}/recommenders/{recommender}/config" + }; + + // Name of recommender config. + // Eg, + // projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config + string name = 1; + + // RecommenderGenerationConfig which configures the Generation of + // recommendations for this recommender. + RecommenderGenerationConfig recommender_generation_config = 2; + + // Fingerprint of the RecommenderConfig. Provides optimistic locking when + // updating. + string etag = 3; + + // Last time when the config was updated. + google.protobuf.Timestamp update_time = 4; + + // Output only. Immutable. The revision ID of the config. + // A new revision is committed whenever the config is changed in any way. + // The format is an 8-character hexadecimal string. + string revision_id = 5 [ + (google.api.field_behavior) = IMMUTABLE, + (google.api.field_behavior) = OUTPUT_ONLY + ]; + + // Allows clients to store small amounts of arbitrary data. Annotations must + // follow the Kubernetes syntax. + // The total size of all keys and values combined is limited to 256k. + // Key can have 2 segments: prefix (optional) and name (required), + // separated by a slash (/). + // Prefix must be a DNS subdomain. + // Name must be 63 characters or less, begin and end with alphanumerics, + // with dashes (-), underscores (_), dots (.), and alphanumerics between. + map annotations = 6; + + // A user-settable field to provide a human-readable name to be used in user + // interfaces. + string display_name = 7; +} + +// A Configuration to customize the generation of recommendations. +// Eg, customizing the lookback period considered when generating a +// recommendation. +message RecommenderGenerationConfig { + // Parameters for this RecommenderGenerationConfig. These configs can be used + // by or are applied to all subtypes. + google.protobuf.Struct params = 1; +} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommender_service.proto b/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommender_service.proto new file mode 100644 index 00000000000..80829a90c01 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommender_service.proto @@ -0,0 +1,591 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.recommender.v1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/recommender/v1beta1/insight.proto"; +import "google/cloud/recommender/v1beta1/insight_type_config.proto"; +import "google/cloud/recommender/v1beta1/recommendation.proto"; +import "google/cloud/recommender/v1beta1/recommender_config.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Recommender.V1Beta1"; +option go_package = "cloud.google.com/go/recommender/apiv1beta1/recommenderpb;recommenderpb"; +option java_multiple_files = true; +option java_outer_classname = "RecommenderProto"; +option java_package = "com.google.cloud.recommender.v1beta1"; +option objc_class_prefix = "CREC"; + +// Provides insights and recommendations for cloud customers for various +// categories like performance optimization, cost savings, reliability, feature +// discovery, etc. Insights and recommendations are generated automatically +// based on analysis of user resources, configuration and monitoring metrics. +service Recommender { + option (google.api.default_host) = "recommender.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Lists insights for the specified Cloud Resource. Requires the + // recommender.*.list IAM permission for the specified insight type. + rpc ListInsights(ListInsightsRequest) returns (ListInsightsResponse) { + option (google.api.http) = { + get: "/v1beta1/{parent=projects/*/locations/*/insightTypes/*}/insights" + additional_bindings { + get: "/v1beta1/{parent=billingAccounts/*/locations/*/insightTypes/*}/insights" + } + additional_bindings { + get: "/v1beta1/{parent=folders/*/locations/*/insightTypes/*}/insights" + } + additional_bindings { + get: "/v1beta1/{parent=organizations/*/locations/*/insightTypes/*}/insights" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Gets the requested insight. Requires the recommender.*.get IAM permission + // for the specified insight type. + rpc GetInsight(GetInsightRequest) returns (Insight) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/locations/*/insightTypes/*/insights/*}" + additional_bindings { + get: "/v1beta1/{name=billingAccounts/*/locations/*/insightTypes/*/insights/*}" + } + additional_bindings { + get: "/v1beta1/{name=folders/*/locations/*/insightTypes/*/insights/*}" + } + additional_bindings { + get: "/v1beta1/{name=organizations/*/locations/*/insightTypes/*/insights/*}" + } + }; + option (google.api.method_signature) = "name"; + } + + // Marks the Insight State as Accepted. Users can use this method to + // indicate to the Recommender API that they have applied some action based + // on the insight. This stops the insight content from being updated. + // + // MarkInsightAccepted can be applied to insights in ACTIVE state. Requires + // the recommender.*.update IAM permission for the specified insight. + rpc MarkInsightAccepted(MarkInsightAcceptedRequest) returns (Insight) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/insightTypes/*/insights/*}:markAccepted" + body: "*" + additional_bindings { + post: "/v1beta1/{name=billingAccounts/*/locations/*/insightTypes/*/insights/*}:markAccepted" + body: "*" + } + additional_bindings { + post: "/v1beta1/{name=folders/*/locations/*/insightTypes/*/insights/*}:markAccepted" + body: "*" + } + additional_bindings { + post: "/v1beta1/{name=organizations/*/locations/*/insightTypes/*/insights/*}:markAccepted" + body: "*" + } + }; + option (google.api.method_signature) = "name,state_metadata,etag"; + } + + // Lists recommendations for the specified Cloud Resource. Requires the + // recommender.*.list IAM permission for the specified recommender. + rpc ListRecommendations(ListRecommendationsRequest) returns (ListRecommendationsResponse) { + option (google.api.http) = { + get: "/v1beta1/{parent=projects/*/locations/*/recommenders/*}/recommendations" + additional_bindings { + get: "/v1beta1/{parent=billingAccounts/*/locations/*/recommenders/*}/recommendations" + } + additional_bindings { + get: "/v1beta1/{parent=folders/*/locations/*/recommenders/*}/recommendations" + } + additional_bindings { + get: "/v1beta1/{parent=organizations/*/locations/*/recommenders/*}/recommendations" + } + }; + option (google.api.method_signature) = "parent,filter"; + } + + // Gets the requested recommendation. Requires the recommender.*.get + // IAM permission for the specified recommender. + rpc GetRecommendation(GetRecommendationRequest) returns (Recommendation) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}" + additional_bindings { + get: "/v1beta1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}" + } + additional_bindings { + get: "/v1beta1/{name=folders/*/locations/*/recommenders/*/recommendations/*}" + } + additional_bindings { + get: "/v1beta1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}" + } + }; + option (google.api.method_signature) = "name"; + } + + // Marks the Recommendation State as Claimed. Users can use this method to + // indicate to the Recommender API that they are starting to apply the + // recommendation themselves. This stops the recommendation content from being + // updated. Associated insights are frozen and placed in the ACCEPTED state. + // + // MarkRecommendationClaimed can be applied to recommendations in CLAIMED or + // ACTIVE state. + // + // Requires the recommender.*.update IAM permission for the specified + // recommender. + rpc MarkRecommendationClaimed(MarkRecommendationClaimedRequest) returns (Recommendation) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markClaimed" + body: "*" + additional_bindings { + post: "/v1beta1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markClaimed" + body: "*" + } + additional_bindings { + post: "/v1beta1/{name=folders/*/locations/*/recommenders/*/recommendations/*}:markClaimed" + body: "*" + } + additional_bindings { + post: "/v1beta1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}:markClaimed" + body: "*" + } + }; + option (google.api.method_signature) = "name,state_metadata,etag"; + } + + // Marks the Recommendation State as Succeeded. Users can use this method to + // indicate to the Recommender API that they have applied the recommendation + // themselves, and the operation was successful. This stops the recommendation + // content from being updated. Associated insights are frozen and placed in + // the ACCEPTED state. + // + // MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, + // CLAIMED, SUCCEEDED, or FAILED state. + // + // Requires the recommender.*.update IAM permission for the specified + // recommender. + rpc MarkRecommendationSucceeded(MarkRecommendationSucceededRequest) returns (Recommendation) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markSucceeded" + body: "*" + additional_bindings { + post: "/v1beta1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markSucceeded" + body: "*" + } + additional_bindings { + post: "/v1beta1/{name=folders/*/locations/*/recommenders/*/recommendations/*}:markSucceeded" + body: "*" + } + additional_bindings { + post: "/v1beta1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}:markSucceeded" + body: "*" + } + }; + option (google.api.method_signature) = "name,state_metadata,etag"; + } + + // Marks the Recommendation State as Failed. Users can use this method to + // indicate to the Recommender API that they have applied the recommendation + // themselves, and the operation failed. This stops the recommendation content + // from being updated. Associated insights are frozen and placed in the + // ACCEPTED state. + // + // MarkRecommendationFailed can be applied to recommendations in ACTIVE, + // CLAIMED, SUCCEEDED, or FAILED state. + // + // Requires the recommender.*.update IAM permission for the specified + // recommender. + rpc MarkRecommendationFailed(MarkRecommendationFailedRequest) returns (Recommendation) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markFailed" + body: "*" + additional_bindings { + post: "/v1beta1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markFailed" + body: "*" + } + additional_bindings { + post: "/v1beta1/{name=folders/*/locations/*/recommenders/*/recommendations/*}:markFailed" + body: "*" + } + additional_bindings { + post: "/v1beta1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}:markFailed" + body: "*" + } + }; + option (google.api.method_signature) = "name,state_metadata,etag"; + } + + // Gets the requested Recommender Config. There is only one instance of the + // config for each Recommender. + rpc GetRecommenderConfig(GetRecommenderConfigRequest) returns (RecommenderConfig) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/locations/*/recommenders/*/config}" + additional_bindings { + get: "/v1beta1/{name=organizations/*/locations/*/recommenders/*/config}" + } + }; + option (google.api.method_signature) = "name"; + } + + // Updates a Recommender Config. This will create a new revision of the + // config. + rpc UpdateRecommenderConfig(UpdateRecommenderConfigRequest) returns (RecommenderConfig) { + option (google.api.http) = { + patch: "/v1beta1/{recommender_config.name=projects/*/locations/*/recommenders/*/config}" + body: "recommender_config" + additional_bindings { + post: "/v1beta1/{recommender_config.name=organizations/*/locations/*/recommenders/*/config}" + body: "recommender_config" + } + }; + option (google.api.method_signature) = "recommender_config,update_mask"; + } + + // Gets the requested InsightTypeConfig. There is only one instance of the + // config for each InsightType. + rpc GetInsightTypeConfig(GetInsightTypeConfigRequest) returns (InsightTypeConfig) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/locations/*/insightTypes/*/config}" + additional_bindings { + get: "/v1beta1/{name=organizations/*/locations/*/insightTypes/*/config}" + } + }; + option (google.api.method_signature) = "name"; + } + + // Updates an InsightTypeConfig change. This will create a new revision of the + // config. + rpc UpdateInsightTypeConfig(UpdateInsightTypeConfigRequest) returns (InsightTypeConfig) { + option (google.api.http) = { + patch: "/v1beta1/{insight_type_config.name=projects/*/locations/*/insightTypes/*/config}" + body: "insight_type_config" + additional_bindings { + post: "/v1beta1/{insight_type_config.name=organizations/*/locations/*/insightTypes/*/config}" + body: "insight_type_config" + } + }; + option (google.api.method_signature) = "insight_type_config,update_mask"; + } +} + +// Request for the `ListInsights` method. +message ListInsightsRequest { + // Required. The container resource on which to execute the request. + // Acceptable formats: + // + // * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + // + // * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + // + // * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + // + // * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + // + // * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + // + // LOCATION here refers to GCP Locations: + // https://cloud.google.com/about/locations/ + // INSIGHT_TYPE_ID refers to supported insight types: + // https://cloud.google.com/recommender/docs/insights/insight-types. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recommender.googleapis.com/InsightType" + } + ]; + + // Optional. The maximum number of results to return from this request. Non-positive + // values are ignored. If not specified, the server will determine the number + // of results to return. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If present, retrieves the next batch of results from the preceding call to + // this method. `page_token` must be the value of `next_page_token` from the + // previous response. The values of other method parameters must be identical + // to those in the previous call. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Filter expression to restrict the insights returned. Supported + // filter fields: + // + // * `stateInfo.state` + // + // * `insightSubtype` + // + // * `severity` + // + // Examples: + // + // * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` + // + // * `insightSubtype = PERMISSIONS_USAGE` + // + // * `severity = CRITICAL OR severity = HIGH` + // + // * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` + // + // (These expressions are based on the filter language described at + // https://google.aip.dev/160) + string filter = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response to the `ListInsights` method. +message ListInsightsResponse { + // The set of insights for the `parent` resource. + repeated Insight insights = 1; + + // A token that can be used to request the next page of results. This field is + // empty if there are no additional results. + string next_page_token = 2; +} + +// Request to the `GetInsight` method. +message GetInsightRequest { + // Required. Name of the insight. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recommender.googleapis.com/Insight" + } + ]; +} + +// Request for the `MarkInsightAccepted` method. +message MarkInsightAcceptedRequest { + // Required. Name of the insight. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recommender.googleapis.com/Insight" + } + ]; + + // Optional. State properties user wish to include with this state. Full replace of the + // current state_metadata. + map state_metadata = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Required. Fingerprint of the Insight. Provides optimistic locking. + string etag = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for the `ListRecommendations` method. +message ListRecommendationsRequest { + // Required. The container resource on which to execute the request. + // Acceptable formats: + // + // * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + // + // * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + // + // * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + // + // * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + // + // * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + // + // LOCATION here refers to GCP Locations: + // https://cloud.google.com/about/locations/ + // RECOMMENDER_ID refers to supported recommenders: + // https://cloud.google.com/recommender/docs/recommenders. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recommender.googleapis.com/Recommender" + } + ]; + + // Optional. The maximum number of results to return from this request. Non-positive + // values are ignored. If not specified, the server will determine the number + // of results to return. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If present, retrieves the next batch of results from the preceding call to + // this method. `page_token` must be the value of `next_page_token` from the + // previous response. The values of other method parameters must be identical + // to those in the previous call. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Filter expression to restrict the recommendations returned. Supported + // filter fields: + // + // * `state_info.state` + // + // * `recommenderSubtype` + // + // * `priority` + // + // Examples: + // + // * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` + // + // * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` + // + // * `priority = P1 OR priority = P2` + // + // * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` + // + // (These expressions are based on the filter language described at + // https://google.aip.dev/160) + string filter = 5; +} + +// Response to the `ListRecommendations` method. +message ListRecommendationsResponse { + // The set of recommendations for the `parent` resource. + repeated Recommendation recommendations = 1; + + // A token that can be used to request the next page of results. This field is + // empty if there are no additional results. + string next_page_token = 2; +} + +// Request to the `GetRecommendation` method. +message GetRecommendationRequest { + // Required. Name of the recommendation. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recommender.googleapis.com/Recommendation" + } + ]; +} + +// Request for the `MarkRecommendationClaimed` Method. +message MarkRecommendationClaimedRequest { + // Required. Name of the recommendation. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recommender.googleapis.com/Recommendation" + } + ]; + + // State properties to include with this state. Overwrites any existing + // `state_metadata`. + // Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. + // Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. + map state_metadata = 2; + + // Required. Fingerprint of the Recommendation. Provides optimistic locking. + string etag = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for the `MarkRecommendationSucceeded` Method. +message MarkRecommendationSucceededRequest { + // Required. Name of the recommendation. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recommender.googleapis.com/Recommendation" + } + ]; + + // State properties to include with this state. Overwrites any existing + // `state_metadata`. + // Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. + // Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. + map state_metadata = 2; + + // Required. Fingerprint of the Recommendation. Provides optimistic locking. + string etag = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for the `MarkRecommendationFailed` Method. +message MarkRecommendationFailedRequest { + // Required. Name of the recommendation. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recommender.googleapis.com/Recommendation" + } + ]; + + // State properties to include with this state. Overwrites any existing + // `state_metadata`. + // Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. + // Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. + map state_metadata = 2; + + // Required. Fingerprint of the Recommendation. Provides optimistic locking. + string etag = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for the GetRecommenderConfig` method. +message GetRecommenderConfigRequest { + // Required. Name of the Recommendation Config to get. + // + // Acceptable formats: + // + // * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` + // + // * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` + // + // * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recommender.googleapis.com/RecommenderConfig" + } + ]; +} + +// Request for the `UpdateRecommenderConfig` method. +message UpdateRecommenderConfigRequest { + // Required. The RecommenderConfig to update. + RecommenderConfig recommender_config = 1 [(google.api.field_behavior) = REQUIRED]; + + // The list of fields to be updated. + google.protobuf.FieldMask update_mask = 2; + + // If true, validate the request and preview the change, but do not actually + // update it. + bool validate_only = 3; +} + +// Request for the GetInsightTypeConfig` method. +message GetInsightTypeConfigRequest { + // Required. Name of the InsightTypeConfig to get. + // + // Acceptable formats: + // + // * `projects/[PROJECT_NUMBER]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` + // + // * `projects/[PROJECT_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` + // + // * `organizations/[ORGANIZATION_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recommender.googleapis.com/InsightTypeConfig" + } + ]; +} + +// Request for the `UpdateInsightTypeConfig` method. +message UpdateInsightTypeConfigRequest { + // Required. The InsightTypeConfig to update. + InsightTypeConfig insight_type_config = 1 [(google.api.field_behavior) = REQUIRED]; + + // The list of fields to be updated. + google.protobuf.FieldMask update_mask = 2; + + // If true, validate the request and preview the change, but do not actually + // update it. + bool validate_only = 3; +} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_insight.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_insight.js new file mode 100644 index 00000000000..9fe532fc4a1 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_insight.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(name) { + // [START recommender_v1beta1_generated_Recommender_GetInsight_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the insight. + */ + // const name = 'abc123' + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callGetInsight() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await recommenderClient.getInsight(request); + console.log(response); + } + + callGetInsight(); + // [END recommender_v1beta1_generated_Recommender_GetInsight_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_insight_type_config.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_insight_type_config.js new file mode 100644 index 00000000000..a10fda24e5e --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_insight_type_config.js @@ -0,0 +1,65 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START recommender_v1beta1_generated_Recommender_GetInsightTypeConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the InsightTypeConfig to get. + * Acceptable formats: + * * `projects/[PROJECT_NUMBER]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` + * * `projects/[PROJECT_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` + * * `organizations/[ORGANIZATION_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` + */ + // const name = 'abc123' + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callGetInsightTypeConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await recommenderClient.getInsightTypeConfig(request); + console.log(response); + } + + callGetInsightTypeConfig(); + // [END recommender_v1beta1_generated_Recommender_GetInsightTypeConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_recommendation.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_recommendation.js new file mode 100644 index 00000000000..1eec74a9226 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_recommendation.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(name) { + // [START recommender_v1beta1_generated_Recommender_GetRecommendation_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the recommendation. + */ + // const name = 'abc123' + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callGetRecommendation() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await recommenderClient.getRecommendation(request); + console.log(response); + } + + callGetRecommendation(); + // [END recommender_v1beta1_generated_Recommender_GetRecommendation_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_recommender_config.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_recommender_config.js new file mode 100644 index 00000000000..714bfb6daa3 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_recommender_config.js @@ -0,0 +1,65 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START recommender_v1beta1_generated_Recommender_GetRecommenderConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the Recommendation Config to get. + * Acceptable formats: + * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` + * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` + */ + // const name = 'abc123' + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callGetRecommenderConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await recommenderClient.getRecommenderConfig(request); + console.log(response); + } + + callGetRecommenderConfig(); + // [END recommender_v1beta1_generated_Recommender_GetRecommenderConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.list_insights.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.list_insights.js new file mode 100644 index 00000000000..4021b57de47 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.list_insights.js @@ -0,0 +1,101 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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 recommender_v1beta1_generated_Recommender_ListInsights_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The container resource on which to execute the request. + * Acceptable formats: + * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * LOCATION here refers to GCP Locations: + * https://cloud.google.com/about/locations/ + * INSIGHT_TYPE_ID refers to supported insight types: + * https://cloud.google.com/recommender/docs/insights/insight-types. + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of results to return from this request. Non-positive + * values are ignored. If not specified, the server will determine the number + * of results to return. + */ + // const pageSize = 1234 + /** + * Optional. If present, retrieves the next batch of results from the preceding call to + * this method. `page_token` must be the value of `next_page_token` from the + * previous response. The values of other method parameters must be identical + * to those in the previous call. + */ + // const pageToken = 'abc123' + /** + * Optional. Filter expression to restrict the insights returned. Supported + * filter fields: + * * `stateInfo.state` + * * `insightSubtype` + * * `severity` + * Examples: + * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` + * * `insightSubtype = PERMISSIONS_USAGE` + * * `severity = CRITICAL OR severity = HIGH` + * * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` + * (These expressions are based on the filter language described at + * https://google.aip.dev/160) + */ + // const filter = 'abc123' + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callListInsights() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await recommenderClient.listInsightsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListInsights(); + // [END recommender_v1beta1_generated_Recommender_ListInsights_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.list_recommendations.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.list_recommendations.js new file mode 100644 index 00000000000..85973f13f6b --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.list_recommendations.js @@ -0,0 +1,101 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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 recommender_v1beta1_generated_Recommender_ListRecommendations_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The container resource on which to execute the request. + * Acceptable formats: + * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * LOCATION here refers to GCP Locations: + * https://cloud.google.com/about/locations/ + * RECOMMENDER_ID refers to supported recommenders: + * https://cloud.google.com/recommender/docs/recommenders. + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of results to return from this request. Non-positive + * values are ignored. If not specified, the server will determine the number + * of results to return. + */ + // const pageSize = 1234 + /** + * Optional. If present, retrieves the next batch of results from the preceding call to + * this method. `page_token` must be the value of `next_page_token` from the + * previous response. The values of other method parameters must be identical + * to those in the previous call. + */ + // const pageToken = 'abc123' + /** + * Filter expression to restrict the recommendations returned. Supported + * filter fields: + * * `state_info.state` + * * `recommenderSubtype` + * * `priority` + * Examples: + * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` + * * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` + * * `priority = P1 OR priority = P2` + * * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` + * (These expressions are based on the filter language described at + * https://google.aip.dev/160) + */ + // const filter = 'abc123' + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callListRecommendations() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await recommenderClient.listRecommendationsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListRecommendations(); + // [END recommender_v1beta1_generated_Recommender_ListRecommendations_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_insight_accepted.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_insight_accepted.js new file mode 100644 index 00000000000..29c50b7343c --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_insight_accepted.js @@ -0,0 +1,71 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, etag) { + // [START recommender_v1beta1_generated_Recommender_MarkInsightAccepted_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the insight. + */ + // const name = 'abc123' + /** + * Optional. State properties user wish to include with this state. Full replace of the + * current state_metadata. + */ + // const stateMetadata = [1,2,3,4] + /** + * Required. Fingerprint of the Insight. Provides optimistic locking. + */ + // const etag = 'abc123' + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callMarkInsightAccepted() { + // Construct request + const request = { + name, + etag, + }; + + // Run request + const response = await recommenderClient.markInsightAccepted(request); + console.log(response); + } + + callMarkInsightAccepted(); + // [END recommender_v1beta1_generated_Recommender_MarkInsightAccepted_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_claimed.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_claimed.js new file mode 100644 index 00000000000..560fdcb421f --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_claimed.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(name, etag) { + // [START recommender_v1beta1_generated_Recommender_MarkRecommendationClaimed_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the recommendation. + */ + // const name = 'abc123' + /** + * State properties to include with this state. Overwrites any existing + * `state_metadata`. + * Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. + * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. + */ + // const stateMetadata = [1,2,3,4] + /** + * Required. Fingerprint of the Recommendation. Provides optimistic locking. + */ + // const etag = 'abc123' + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callMarkRecommendationClaimed() { + // Construct request + const request = { + name, + etag, + }; + + // Run request + const response = await recommenderClient.markRecommendationClaimed(request); + console.log(response); + } + + callMarkRecommendationClaimed(); + // [END recommender_v1beta1_generated_Recommender_MarkRecommendationClaimed_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_failed.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_failed.js new file mode 100644 index 00000000000..de9056d402f --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_failed.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(name, etag) { + // [START recommender_v1beta1_generated_Recommender_MarkRecommendationFailed_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the recommendation. + */ + // const name = 'abc123' + /** + * State properties to include with this state. Overwrites any existing + * `state_metadata`. + * Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. + * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. + */ + // const stateMetadata = [1,2,3,4] + /** + * Required. Fingerprint of the Recommendation. Provides optimistic locking. + */ + // const etag = 'abc123' + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callMarkRecommendationFailed() { + // Construct request + const request = { + name, + etag, + }; + + // Run request + const response = await recommenderClient.markRecommendationFailed(request); + console.log(response); + } + + callMarkRecommendationFailed(); + // [END recommender_v1beta1_generated_Recommender_MarkRecommendationFailed_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_succeeded.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_succeeded.js new file mode 100644 index 00000000000..8d6245faba3 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_succeeded.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(name, etag) { + // [START recommender_v1beta1_generated_Recommender_MarkRecommendationSucceeded_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the recommendation. + */ + // const name = 'abc123' + /** + * State properties to include with this state. Overwrites any existing + * `state_metadata`. + * Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. + * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. + */ + // const stateMetadata = [1,2,3,4] + /** + * Required. Fingerprint of the Recommendation. Provides optimistic locking. + */ + // const etag = 'abc123' + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callMarkRecommendationSucceeded() { + // Construct request + const request = { + name, + etag, + }; + + // Run request + const response = await recommenderClient.markRecommendationSucceeded(request); + console.log(response); + } + + callMarkRecommendationSucceeded(); + // [END recommender_v1beta1_generated_Recommender_MarkRecommendationSucceeded_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.update_insight_type_config.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.update_insight_type_config.js new file mode 100644 index 00000000000..d5e4ee4bdb8 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.update_insight_type_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(insightTypeConfig) { + // [START recommender_v1beta1_generated_Recommender_UpdateInsightTypeConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The InsightTypeConfig to update. + */ + // const insightTypeConfig = {} + /** + * The list of fields to be updated. + */ + // const updateMask = {} + /** + * If true, validate the request and preview the change, but do not actually + * update it. + */ + // const validateOnly = true + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callUpdateInsightTypeConfig() { + // Construct request + const request = { + insightTypeConfig, + }; + + // Run request + const response = await recommenderClient.updateInsightTypeConfig(request); + console.log(response); + } + + callUpdateInsightTypeConfig(); + // [END recommender_v1beta1_generated_Recommender_UpdateInsightTypeConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.update_recommender_config.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.update_recommender_config.js new file mode 100644 index 00000000000..a34d8e21c88 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.update_recommender_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(recommenderConfig) { + // [START recommender_v1beta1_generated_Recommender_UpdateRecommenderConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The RecommenderConfig to update. + */ + // const recommenderConfig = {} + /** + * The list of fields to be updated. + */ + // const updateMask = {} + /** + * If true, validate the request and preview the change, but do not actually + * update it. + */ + // const validateOnly = true + + // Imports the Recommender library + const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; + + // Instantiates a client + const recommenderClient = new RecommenderClient(); + + async function callUpdateRecommenderConfig() { + // Construct request + const request = { + recommenderConfig, + }; + + // Run request + const response = await recommenderClient.updateRecommenderConfig(request); + console.log(response); + } + + callUpdateRecommenderConfig(); + // [END recommender_v1beta1_generated_Recommender_UpdateRecommenderConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.recommender.v1beta1.json b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.recommender.v1beta1.json new file mode 100644 index 00000000000..ce02de64676 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.recommender.v1beta1.json @@ -0,0 +1,567 @@ +{ + "clientLibrary": { + "name": "nodejs-recommender", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.recommender.v1beta1", + "version": "v1beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "recommender_v1beta1_generated_Recommender_ListInsights_async", + "title": "Recommender listInsights Sample", + "origin": "API_DEFINITION", + "description": " Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.", + "canonical": true, + "file": "recommender.list_insights.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 93, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListInsights", + "fullName": "google.cloud.recommender.v1beta1.Recommender.ListInsights", + "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.recommender.v1beta1.ListInsightsResponse", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" + }, + "method": { + "shortName": "ListInsights", + "fullName": "google.cloud.recommender.v1beta1.Recommender.ListInsights", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1beta1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1beta1_generated_Recommender_GetInsight_async", + "title": "Recommender getInsight Sample", + "origin": "API_DEFINITION", + "description": " Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.", + "canonical": true, + "file": "recommender.get_insight.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetInsight", + "fullName": "google.cloud.recommender.v1beta1.Recommender.GetInsight", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recommender.v1beta1.Insight", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" + }, + "method": { + "shortName": "GetInsight", + "fullName": "google.cloud.recommender.v1beta1.Recommender.GetInsight", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1beta1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1beta1_generated_Recommender_MarkInsightAccepted_async", + "title": "Recommender markInsightAccepted Sample", + "origin": "API_DEFINITION", + "description": " Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated. MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.", + "canonical": true, + "file": "recommender.mark_insight_accepted.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "MarkInsightAccepted", + "fullName": "google.cloud.recommender.v1beta1.Recommender.MarkInsightAccepted", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "state_metadata", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recommender.v1beta1.Insight", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" + }, + "method": { + "shortName": "MarkInsightAccepted", + "fullName": "google.cloud.recommender.v1beta1.Recommender.MarkInsightAccepted", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1beta1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1beta1_generated_Recommender_ListRecommendations_async", + "title": "Recommender listRecommendations Sample", + "origin": "API_DEFINITION", + "description": " Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.", + "canonical": true, + "file": "recommender.list_recommendations.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 93, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListRecommendations", + "fullName": "google.cloud.recommender.v1beta1.Recommender.ListRecommendations", + "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.recommender.v1beta1.ListRecommendationsResponse", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" + }, + "method": { + "shortName": "ListRecommendations", + "fullName": "google.cloud.recommender.v1beta1.Recommender.ListRecommendations", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1beta1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1beta1_generated_Recommender_GetRecommendation_async", + "title": "Recommender getRecommendation Sample", + "origin": "API_DEFINITION", + "description": " Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.", + "canonical": true, + "file": "recommender.get_recommendation.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetRecommendation", + "fullName": "google.cloud.recommender.v1beta1.Recommender.GetRecommendation", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recommender.v1beta1.Recommendation", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" + }, + "method": { + "shortName": "GetRecommendation", + "fullName": "google.cloud.recommender.v1beta1.Recommender.GetRecommendation", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1beta1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1beta1_generated_Recommender_MarkRecommendationClaimed_async", + "title": "Recommender markRecommendationClaimed Sample", + "origin": "API_DEFINITION", + "description": " Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationClaimed can be applied to recommendations in CLAIMED or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.", + "canonical": true, + "file": "recommender.mark_recommendation_claimed.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "MarkRecommendationClaimed", + "fullName": "google.cloud.recommender.v1beta1.Recommender.MarkRecommendationClaimed", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "state_metadata", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recommender.v1beta1.Recommendation", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" + }, + "method": { + "shortName": "MarkRecommendationClaimed", + "fullName": "google.cloud.recommender.v1beta1.Recommender.MarkRecommendationClaimed", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1beta1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1beta1_generated_Recommender_MarkRecommendationSucceeded_async", + "title": "Recommender markRecommendationSucceeded Sample", + "origin": "API_DEFINITION", + "description": " Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.", + "canonical": true, + "file": "recommender.mark_recommendation_succeeded.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "MarkRecommendationSucceeded", + "fullName": "google.cloud.recommender.v1beta1.Recommender.MarkRecommendationSucceeded", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "state_metadata", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recommender.v1beta1.Recommendation", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" + }, + "method": { + "shortName": "MarkRecommendationSucceeded", + "fullName": "google.cloud.recommender.v1beta1.Recommender.MarkRecommendationSucceeded", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1beta1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1beta1_generated_Recommender_MarkRecommendationFailed_async", + "title": "Recommender markRecommendationFailed Sample", + "origin": "API_DEFINITION", + "description": " Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.", + "canonical": true, + "file": "recommender.mark_recommendation_failed.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "MarkRecommendationFailed", + "fullName": "google.cloud.recommender.v1beta1.Recommender.MarkRecommendationFailed", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "state_metadata", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recommender.v1beta1.Recommendation", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" + }, + "method": { + "shortName": "MarkRecommendationFailed", + "fullName": "google.cloud.recommender.v1beta1.Recommender.MarkRecommendationFailed", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1beta1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1beta1_generated_Recommender_GetRecommenderConfig_async", + "title": "Recommender getRecommenderConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets the requested Recommender Config. There is only one instance of the config for each Recommender.", + "canonical": true, + "file": "recommender.get_recommender_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetRecommenderConfig", + "fullName": "google.cloud.recommender.v1beta1.Recommender.GetRecommenderConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recommender.v1beta1.RecommenderConfig", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" + }, + "method": { + "shortName": "GetRecommenderConfig", + "fullName": "google.cloud.recommender.v1beta1.Recommender.GetRecommenderConfig", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1beta1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1beta1_generated_Recommender_UpdateRecommenderConfig_async", + "title": "Recommender updateRecommenderConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates a Recommender Config. This will create a new revision of the config.", + "canonical": true, + "file": "recommender.update_recommender_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateRecommenderConfig", + "fullName": "google.cloud.recommender.v1beta1.Recommender.UpdateRecommenderConfig", + "async": true, + "parameters": [ + { + "name": "recommender_config", + "type": ".google.cloud.recommender.v1beta1.RecommenderConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.recommender.v1beta1.RecommenderConfig", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" + }, + "method": { + "shortName": "UpdateRecommenderConfig", + "fullName": "google.cloud.recommender.v1beta1.Recommender.UpdateRecommenderConfig", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1beta1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1beta1_generated_Recommender_GetInsightTypeConfig_async", + "title": "Recommender getInsightTypeConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.", + "canonical": true, + "file": "recommender.get_insight_type_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetInsightTypeConfig", + "fullName": "google.cloud.recommender.v1beta1.Recommender.GetInsightTypeConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.recommender.v1beta1.InsightTypeConfig", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" + }, + "method": { + "shortName": "GetInsightTypeConfig", + "fullName": "google.cloud.recommender.v1beta1.Recommender.GetInsightTypeConfig", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1beta1.Recommender" + } + } + } + }, + { + "regionTag": "recommender_v1beta1_generated_Recommender_UpdateInsightTypeConfig_async", + "title": "Recommender updateInsightTypeConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates an InsightTypeConfig change. This will create a new revision of the config.", + "canonical": true, + "file": "recommender.update_insight_type_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateInsightTypeConfig", + "fullName": "google.cloud.recommender.v1beta1.Recommender.UpdateInsightTypeConfig", + "async": true, + "parameters": [ + { + "name": "insight_type_config", + "type": ".google.cloud.recommender.v1beta1.InsightTypeConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.recommender.v1beta1.InsightTypeConfig", + "client": { + "shortName": "RecommenderClient", + "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" + }, + "method": { + "shortName": "UpdateInsightTypeConfig", + "fullName": "google.cloud.recommender.v1beta1.Recommender.UpdateInsightTypeConfig", + "service": { + "shortName": "Recommender", + "fullName": "google.cloud.recommender.v1beta1.Recommender" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-recommender/v1beta1/src/index.ts new file mode 100644 index 00000000000..01acf655919 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1beta1 from './v1beta1'; +const RecommenderClient = v1beta1.RecommenderClient; +type RecommenderClient = v1beta1.RecommenderClient; +export {v1beta1, RecommenderClient}; +export default {v1beta1, RecommenderClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/gapic_metadata.json new file mode 100644 index 00000000000..7728d04eacb --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/gapic_metadata.json @@ -0,0 +1,151 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.recommender.v1beta1", + "libraryPackage": "@google-cloud/recommender", + "services": { + "Recommender": { + "clients": { + "grpc": { + "libraryClient": "RecommenderClient", + "rpcs": { + "GetInsight": { + "methods": [ + "getInsight" + ] + }, + "MarkInsightAccepted": { + "methods": [ + "markInsightAccepted" + ] + }, + "GetRecommendation": { + "methods": [ + "getRecommendation" + ] + }, + "MarkRecommendationClaimed": { + "methods": [ + "markRecommendationClaimed" + ] + }, + "MarkRecommendationSucceeded": { + "methods": [ + "markRecommendationSucceeded" + ] + }, + "MarkRecommendationFailed": { + "methods": [ + "markRecommendationFailed" + ] + }, + "GetRecommenderConfig": { + "methods": [ + "getRecommenderConfig" + ] + }, + "UpdateRecommenderConfig": { + "methods": [ + "updateRecommenderConfig" + ] + }, + "GetInsightTypeConfig": { + "methods": [ + "getInsightTypeConfig" + ] + }, + "UpdateInsightTypeConfig": { + "methods": [ + "updateInsightTypeConfig" + ] + }, + "ListInsights": { + "methods": [ + "listInsights", + "listInsightsStream", + "listInsightsAsync" + ] + }, + "ListRecommendations": { + "methods": [ + "listRecommendations", + "listRecommendationsStream", + "listRecommendationsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RecommenderClient", + "rpcs": { + "GetInsight": { + "methods": [ + "getInsight" + ] + }, + "MarkInsightAccepted": { + "methods": [ + "markInsightAccepted" + ] + }, + "GetRecommendation": { + "methods": [ + "getRecommendation" + ] + }, + "MarkRecommendationClaimed": { + "methods": [ + "markRecommendationClaimed" + ] + }, + "MarkRecommendationSucceeded": { + "methods": [ + "markRecommendationSucceeded" + ] + }, + "MarkRecommendationFailed": { + "methods": [ + "markRecommendationFailed" + ] + }, + "GetRecommenderConfig": { + "methods": [ + "getRecommenderConfig" + ] + }, + "UpdateRecommenderConfig": { + "methods": [ + "updateRecommenderConfig" + ] + }, + "GetInsightTypeConfig": { + "methods": [ + "getInsightTypeConfig" + ] + }, + "UpdateInsightTypeConfig": { + "methods": [ + "updateInsightTypeConfig" + ] + }, + "ListInsights": { + "methods": [ + "listInsights", + "listInsightsStream", + "listInsightsAsync" + ] + }, + "ListRecommendations": { + "methods": [ + "listRecommendations", + "listRecommendationsStream", + "listRecommendationsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/index.ts new file mode 100644 index 00000000000..fbe6584bdf2 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {RecommenderClient} from './recommender_client'; diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_client.ts b/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_client.ts new file mode 100644 index 00000000000..3319a7b463a --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_client.ts @@ -0,0 +1,2866 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta1/recommender_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './recommender_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Provides insights and recommendations for cloud customers for various + * categories like performance optimization, cost savings, reliability, feature + * discovery, etc. Insights and recommendations are generated automatically + * based on analysis of user resources, configuration and monitoring metrics. + * @class + * @memberof v1beta1 + */ +export class RecommenderClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + recommenderStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RecommenderClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 RecommenderClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RecommenderClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + billingAccountLocationInsightTypePathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}' + ), + billingAccountLocationInsightTypeInsightPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}/insights/{insight}' + ), + billingAccountLocationRecommenderPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}' + ), + billingAccountLocationRecommenderRecommendationPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}' + ), + folderLocationInsightTypePathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/locations/{location}/insightTypes/{insight_type}' + ), + folderLocationInsightTypeInsightPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/locations/{location}/insightTypes/{insight_type}/insights/{insight}' + ), + folderLocationRecommenderPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/locations/{location}/recommenders/{recommender}' + ), + folderLocationRecommenderRecommendationPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}' + ), + organizationLocationInsightTypePathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/insightTypes/{insight_type}' + ), + organizationLocationInsightTypeConfigPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/insightTypes/{insight_type}/config' + ), + organizationLocationInsightTypeInsightPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/insightTypes/{insight_type}/insights/{insight}' + ), + organizationLocationRecommenderPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/recommenders/{recommender}' + ), + organizationLocationRecommenderConfigPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/recommenders/{recommender}/config' + ), + organizationLocationRecommenderRecommendationPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}' + ), + projectLocationInsightTypePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/insightTypes/{insight_type}' + ), + projectLocationInsightTypeConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/insightTypes/{insight_type}/config' + ), + projectLocationInsightTypeInsightPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/insightTypes/{insight_type}/insights/{insight}' + ), + projectLocationRecommenderPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/recommenders/{recommender}' + ), + projectLocationRecommenderConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/recommenders/{recommender}/config' + ), + projectLocationRecommenderRecommendationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}' + ), + }; + + // 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 = { + listInsights: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'insights'), + listRecommendations: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'recommendations') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.recommender.v1beta1.Recommender', 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.recommenderStub) { + return this.recommenderStub; + } + + // Put together the "service stub" for + // google.cloud.recommender.v1beta1.Recommender. + this.recommenderStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.recommender.v1beta1.Recommender') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.recommender.v1beta1.Recommender, + 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 recommenderStubMethods = + ['listInsights', 'getInsight', 'markInsightAccepted', 'listRecommendations', 'getRecommendation', 'markRecommendationClaimed', 'markRecommendationSucceeded', 'markRecommendationFailed', 'getRecommenderConfig', 'updateRecommenderConfig', 'getInsightTypeConfig', 'updateInsightTypeConfig']; + for (const methodName of recommenderStubMethods) { + const callPromise = this.recommenderStub.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.recommenderStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'recommender.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 'recommender.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 the requested insight. Requires the recommender.*.get IAM permission + * for the specified insight type. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the insight. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1beta1.Insight|Insight}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/recommender.get_insight.js + * region_tag:recommender_v1beta1_generated_Recommender_GetInsight_async + */ + getInsight( + request?: protos.google.cloud.recommender.v1beta1.IGetInsightRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1beta1.IInsight, + protos.google.cloud.recommender.v1beta1.IGetInsightRequest|undefined, {}|undefined + ]>; + getInsight( + request: protos.google.cloud.recommender.v1beta1.IGetInsightRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recommender.v1beta1.IInsight, + protos.google.cloud.recommender.v1beta1.IGetInsightRequest|null|undefined, + {}|null|undefined>): void; + getInsight( + request: protos.google.cloud.recommender.v1beta1.IGetInsightRequest, + callback: Callback< + protos.google.cloud.recommender.v1beta1.IInsight, + protos.google.cloud.recommender.v1beta1.IGetInsightRequest|null|undefined, + {}|null|undefined>): void; + getInsight( + request?: protos.google.cloud.recommender.v1beta1.IGetInsightRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recommender.v1beta1.IInsight, + protos.google.cloud.recommender.v1beta1.IGetInsightRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recommender.v1beta1.IInsight, + protos.google.cloud.recommender.v1beta1.IGetInsightRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recommender.v1beta1.IInsight, + protos.google.cloud.recommender.v1beta1.IGetInsightRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getInsight(request, options, callback); + } +/** + * Marks the Insight State as Accepted. Users can use this method to + * indicate to the Recommender API that they have applied some action based + * on the insight. This stops the insight content from being updated. + * + * MarkInsightAccepted can be applied to insights in ACTIVE state. Requires + * the recommender.*.update IAM permission for the specified insight. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the insight. + * @param {number[]} [request.stateMetadata] + * Optional. State properties user wish to include with this state. Full replace of the + * current state_metadata. + * @param {string} request.etag + * Required. Fingerprint of the Insight. Provides optimistic locking. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1beta1.Insight|Insight}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/recommender.mark_insight_accepted.js + * region_tag:recommender_v1beta1_generated_Recommender_MarkInsightAccepted_async + */ + markInsightAccepted( + request?: protos.google.cloud.recommender.v1beta1.IMarkInsightAcceptedRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1beta1.IInsight, + protos.google.cloud.recommender.v1beta1.IMarkInsightAcceptedRequest|undefined, {}|undefined + ]>; + markInsightAccepted( + request: protos.google.cloud.recommender.v1beta1.IMarkInsightAcceptedRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recommender.v1beta1.IInsight, + protos.google.cloud.recommender.v1beta1.IMarkInsightAcceptedRequest|null|undefined, + {}|null|undefined>): void; + markInsightAccepted( + request: protos.google.cloud.recommender.v1beta1.IMarkInsightAcceptedRequest, + callback: Callback< + protos.google.cloud.recommender.v1beta1.IInsight, + protos.google.cloud.recommender.v1beta1.IMarkInsightAcceptedRequest|null|undefined, + {}|null|undefined>): void; + markInsightAccepted( + request?: protos.google.cloud.recommender.v1beta1.IMarkInsightAcceptedRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recommender.v1beta1.IInsight, + protos.google.cloud.recommender.v1beta1.IMarkInsightAcceptedRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recommender.v1beta1.IInsight, + protos.google.cloud.recommender.v1beta1.IMarkInsightAcceptedRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recommender.v1beta1.IInsight, + protos.google.cloud.recommender.v1beta1.IMarkInsightAcceptedRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.markInsightAccepted(request, options, callback); + } +/** + * Gets the requested recommendation. Requires the recommender.*.get + * IAM permission for the specified recommender. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the recommendation. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1beta1.Recommendation|Recommendation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/recommender.get_recommendation.js + * region_tag:recommender_v1beta1_generated_Recommender_GetRecommendation_async + */ + getRecommendation( + request?: protos.google.cloud.recommender.v1beta1.IGetRecommendationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IGetRecommendationRequest|undefined, {}|undefined + ]>; + getRecommendation( + request: protos.google.cloud.recommender.v1beta1.IGetRecommendationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IGetRecommendationRequest|null|undefined, + {}|null|undefined>): void; + getRecommendation( + request: protos.google.cloud.recommender.v1beta1.IGetRecommendationRequest, + callback: Callback< + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IGetRecommendationRequest|null|undefined, + {}|null|undefined>): void; + getRecommendation( + request?: protos.google.cloud.recommender.v1beta1.IGetRecommendationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IGetRecommendationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IGetRecommendationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IGetRecommendationRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getRecommendation(request, options, callback); + } +/** + * Marks the Recommendation State as Claimed. Users can use this method to + * indicate to the Recommender API that they are starting to apply the + * recommendation themselves. This stops the recommendation content from being + * updated. Associated insights are frozen and placed in the ACCEPTED state. + * + * MarkRecommendationClaimed can be applied to recommendations in CLAIMED or + * ACTIVE state. + * + * Requires the recommender.*.update IAM permission for the specified + * recommender. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the recommendation. + * @param {number[]} request.stateMetadata + * State properties to include with this state. Overwrites any existing + * `state_metadata`. + * Keys must match the regex `/^{@link protos.a-z0-9_.-|a-z0-9}{0,62}$/`. + * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. + * @param {string} request.etag + * Required. Fingerprint of the Recommendation. Provides optimistic locking. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1beta1.Recommendation|Recommendation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/recommender.mark_recommendation_claimed.js + * region_tag:recommender_v1beta1_generated_Recommender_MarkRecommendationClaimed_async + */ + markRecommendationClaimed( + request?: protos.google.cloud.recommender.v1beta1.IMarkRecommendationClaimedRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IMarkRecommendationClaimedRequest|undefined, {}|undefined + ]>; + markRecommendationClaimed( + request: protos.google.cloud.recommender.v1beta1.IMarkRecommendationClaimedRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IMarkRecommendationClaimedRequest|null|undefined, + {}|null|undefined>): void; + markRecommendationClaimed( + request: protos.google.cloud.recommender.v1beta1.IMarkRecommendationClaimedRequest, + callback: Callback< + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IMarkRecommendationClaimedRequest|null|undefined, + {}|null|undefined>): void; + markRecommendationClaimed( + request?: protos.google.cloud.recommender.v1beta1.IMarkRecommendationClaimedRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IMarkRecommendationClaimedRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IMarkRecommendationClaimedRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IMarkRecommendationClaimedRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.markRecommendationClaimed(request, options, callback); + } +/** + * Marks the Recommendation State as Succeeded. Users can use this method to + * indicate to the Recommender API that they have applied the recommendation + * themselves, and the operation was successful. This stops the recommendation + * content from being updated. Associated insights are frozen and placed in + * the ACCEPTED state. + * + * MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, + * CLAIMED, SUCCEEDED, or FAILED state. + * + * Requires the recommender.*.update IAM permission for the specified + * recommender. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the recommendation. + * @param {number[]} request.stateMetadata + * State properties to include with this state. Overwrites any existing + * `state_metadata`. + * Keys must match the regex `/^{@link protos.a-z0-9_.-|a-z0-9}{0,62}$/`. + * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. + * @param {string} request.etag + * Required. Fingerprint of the Recommendation. Provides optimistic locking. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1beta1.Recommendation|Recommendation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/recommender.mark_recommendation_succeeded.js + * region_tag:recommender_v1beta1_generated_Recommender_MarkRecommendationSucceeded_async + */ + markRecommendationSucceeded( + request?: protos.google.cloud.recommender.v1beta1.IMarkRecommendationSucceededRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IMarkRecommendationSucceededRequest|undefined, {}|undefined + ]>; + markRecommendationSucceeded( + request: protos.google.cloud.recommender.v1beta1.IMarkRecommendationSucceededRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IMarkRecommendationSucceededRequest|null|undefined, + {}|null|undefined>): void; + markRecommendationSucceeded( + request: protos.google.cloud.recommender.v1beta1.IMarkRecommendationSucceededRequest, + callback: Callback< + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IMarkRecommendationSucceededRequest|null|undefined, + {}|null|undefined>): void; + markRecommendationSucceeded( + request?: protos.google.cloud.recommender.v1beta1.IMarkRecommendationSucceededRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IMarkRecommendationSucceededRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IMarkRecommendationSucceededRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IMarkRecommendationSucceededRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.markRecommendationSucceeded(request, options, callback); + } +/** + * Marks the Recommendation State as Failed. Users can use this method to + * indicate to the Recommender API that they have applied the recommendation + * themselves, and the operation failed. This stops the recommendation content + * from being updated. Associated insights are frozen and placed in the + * ACCEPTED state. + * + * MarkRecommendationFailed can be applied to recommendations in ACTIVE, + * CLAIMED, SUCCEEDED, or FAILED state. + * + * Requires the recommender.*.update IAM permission for the specified + * recommender. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the recommendation. + * @param {number[]} request.stateMetadata + * State properties to include with this state. Overwrites any existing + * `state_metadata`. + * Keys must match the regex `/^{@link protos.a-z0-9_.-|a-z0-9}{0,62}$/`. + * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. + * @param {string} request.etag + * Required. Fingerprint of the Recommendation. Provides optimistic locking. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1beta1.Recommendation|Recommendation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/recommender.mark_recommendation_failed.js + * region_tag:recommender_v1beta1_generated_Recommender_MarkRecommendationFailed_async + */ + markRecommendationFailed( + request?: protos.google.cloud.recommender.v1beta1.IMarkRecommendationFailedRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IMarkRecommendationFailedRequest|undefined, {}|undefined + ]>; + markRecommendationFailed( + request: protos.google.cloud.recommender.v1beta1.IMarkRecommendationFailedRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IMarkRecommendationFailedRequest|null|undefined, + {}|null|undefined>): void; + markRecommendationFailed( + request: protos.google.cloud.recommender.v1beta1.IMarkRecommendationFailedRequest, + callback: Callback< + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IMarkRecommendationFailedRequest|null|undefined, + {}|null|undefined>): void; + markRecommendationFailed( + request?: protos.google.cloud.recommender.v1beta1.IMarkRecommendationFailedRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IMarkRecommendationFailedRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IMarkRecommendationFailedRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recommender.v1beta1.IRecommendation, + protos.google.cloud.recommender.v1beta1.IMarkRecommendationFailedRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.markRecommendationFailed(request, options, callback); + } +/** + * Gets the requested Recommender Config. There is only one instance of the + * config for each Recommender. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the Recommendation Config to get. + * + * Acceptable formats: + * + * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` + * + * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` + * + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/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 protos.google.cloud.recommender.v1beta1.RecommenderConfig|RecommenderConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/recommender.get_recommender_config.js + * region_tag:recommender_v1beta1_generated_Recommender_GetRecommenderConfig_async + */ + getRecommenderConfig( + request?: protos.google.cloud.recommender.v1beta1.IGetRecommenderConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1beta1.IRecommenderConfig, + protos.google.cloud.recommender.v1beta1.IGetRecommenderConfigRequest|undefined, {}|undefined + ]>; + getRecommenderConfig( + request: protos.google.cloud.recommender.v1beta1.IGetRecommenderConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recommender.v1beta1.IRecommenderConfig, + protos.google.cloud.recommender.v1beta1.IGetRecommenderConfigRequest|null|undefined, + {}|null|undefined>): void; + getRecommenderConfig( + request: protos.google.cloud.recommender.v1beta1.IGetRecommenderConfigRequest, + callback: Callback< + protos.google.cloud.recommender.v1beta1.IRecommenderConfig, + protos.google.cloud.recommender.v1beta1.IGetRecommenderConfigRequest|null|undefined, + {}|null|undefined>): void; + getRecommenderConfig( + request?: protos.google.cloud.recommender.v1beta1.IGetRecommenderConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recommender.v1beta1.IRecommenderConfig, + protos.google.cloud.recommender.v1beta1.IGetRecommenderConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recommender.v1beta1.IRecommenderConfig, + protos.google.cloud.recommender.v1beta1.IGetRecommenderConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recommender.v1beta1.IRecommenderConfig, + protos.google.cloud.recommender.v1beta1.IGetRecommenderConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getRecommenderConfig(request, options, callback); + } +/** + * Updates a Recommender Config. This will create a new revision of the + * config. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.recommender.v1beta1.RecommenderConfig} request.recommenderConfig + * Required. The RecommenderConfig to update. + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields to be updated. + * @param {boolean} request.validateOnly + * If true, validate the request and preview the change, but do not actually + * update it. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1beta1.RecommenderConfig|RecommenderConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/recommender.update_recommender_config.js + * region_tag:recommender_v1beta1_generated_Recommender_UpdateRecommenderConfig_async + */ + updateRecommenderConfig( + request?: protos.google.cloud.recommender.v1beta1.IUpdateRecommenderConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1beta1.IRecommenderConfig, + protos.google.cloud.recommender.v1beta1.IUpdateRecommenderConfigRequest|undefined, {}|undefined + ]>; + updateRecommenderConfig( + request: protos.google.cloud.recommender.v1beta1.IUpdateRecommenderConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recommender.v1beta1.IRecommenderConfig, + protos.google.cloud.recommender.v1beta1.IUpdateRecommenderConfigRequest|null|undefined, + {}|null|undefined>): void; + updateRecommenderConfig( + request: protos.google.cloud.recommender.v1beta1.IUpdateRecommenderConfigRequest, + callback: Callback< + protos.google.cloud.recommender.v1beta1.IRecommenderConfig, + protos.google.cloud.recommender.v1beta1.IUpdateRecommenderConfigRequest|null|undefined, + {}|null|undefined>): void; + updateRecommenderConfig( + request?: protos.google.cloud.recommender.v1beta1.IUpdateRecommenderConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recommender.v1beta1.IRecommenderConfig, + protos.google.cloud.recommender.v1beta1.IUpdateRecommenderConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recommender.v1beta1.IRecommenderConfig, + protos.google.cloud.recommender.v1beta1.IUpdateRecommenderConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recommender.v1beta1.IRecommenderConfig, + protos.google.cloud.recommender.v1beta1.IUpdateRecommenderConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'recommender_config.name': request.recommenderConfig!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateRecommenderConfig(request, options, callback); + } +/** + * Gets the requested InsightTypeConfig. There is only one instance of the + * config for each InsightType. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the InsightTypeConfig to get. + * + * Acceptable formats: + * + * * `projects/[PROJECT_NUMBER]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` + * + * * `projects/[PROJECT_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` + * + * * `organizations/[ORGANIZATION_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/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 protos.google.cloud.recommender.v1beta1.InsightTypeConfig|InsightTypeConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/recommender.get_insight_type_config.js + * region_tag:recommender_v1beta1_generated_Recommender_GetInsightTypeConfig_async + */ + getInsightTypeConfig( + request?: protos.google.cloud.recommender.v1beta1.IGetInsightTypeConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, + protos.google.cloud.recommender.v1beta1.IGetInsightTypeConfigRequest|undefined, {}|undefined + ]>; + getInsightTypeConfig( + request: protos.google.cloud.recommender.v1beta1.IGetInsightTypeConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, + protos.google.cloud.recommender.v1beta1.IGetInsightTypeConfigRequest|null|undefined, + {}|null|undefined>): void; + getInsightTypeConfig( + request: protos.google.cloud.recommender.v1beta1.IGetInsightTypeConfigRequest, + callback: Callback< + protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, + protos.google.cloud.recommender.v1beta1.IGetInsightTypeConfigRequest|null|undefined, + {}|null|undefined>): void; + getInsightTypeConfig( + request?: protos.google.cloud.recommender.v1beta1.IGetInsightTypeConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, + protos.google.cloud.recommender.v1beta1.IGetInsightTypeConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, + protos.google.cloud.recommender.v1beta1.IGetInsightTypeConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, + protos.google.cloud.recommender.v1beta1.IGetInsightTypeConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getInsightTypeConfig(request, options, callback); + } +/** + * Updates an InsightTypeConfig change. This will create a new revision of the + * config. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.recommender.v1beta1.InsightTypeConfig} request.insightTypeConfig + * Required. The InsightTypeConfig to update. + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields to be updated. + * @param {boolean} request.validateOnly + * If true, validate the request and preview the change, but do not actually + * update it. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1beta1.InsightTypeConfig|InsightTypeConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/recommender.update_insight_type_config.js + * region_tag:recommender_v1beta1_generated_Recommender_UpdateInsightTypeConfig_async + */ + updateInsightTypeConfig( + request?: protos.google.cloud.recommender.v1beta1.IUpdateInsightTypeConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, + protos.google.cloud.recommender.v1beta1.IUpdateInsightTypeConfigRequest|undefined, {}|undefined + ]>; + updateInsightTypeConfig( + request: protos.google.cloud.recommender.v1beta1.IUpdateInsightTypeConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, + protos.google.cloud.recommender.v1beta1.IUpdateInsightTypeConfigRequest|null|undefined, + {}|null|undefined>): void; + updateInsightTypeConfig( + request: protos.google.cloud.recommender.v1beta1.IUpdateInsightTypeConfigRequest, + callback: Callback< + protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, + protos.google.cloud.recommender.v1beta1.IUpdateInsightTypeConfigRequest|null|undefined, + {}|null|undefined>): void; + updateInsightTypeConfig( + request?: protos.google.cloud.recommender.v1beta1.IUpdateInsightTypeConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, + protos.google.cloud.recommender.v1beta1.IUpdateInsightTypeConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, + protos.google.cloud.recommender.v1beta1.IUpdateInsightTypeConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, + protos.google.cloud.recommender.v1beta1.IUpdateInsightTypeConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'insight_type_config.name': request.insightTypeConfig!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateInsightTypeConfig(request, options, callback); + } + + /** + * Lists insights for the specified Cloud Resource. Requires the + * recommender.*.list IAM permission for the specified insight type. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The container resource on which to execute the request. + * Acceptable formats: + * + * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * LOCATION here refers to GCP Locations: + * https://cloud.google.com/about/locations/ + * INSIGHT_TYPE_ID refers to supported insight types: + * https://cloud.google.com/recommender/docs/insights/insight-types. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. Non-positive + * values are ignored. If not specified, the server will determine the number + * of results to return. + * @param {string} [request.pageToken] + * Optional. If present, retrieves the next batch of results from the preceding call to + * this method. `page_token` must be the value of `next_page_token` from the + * previous response. The values of other method parameters must be identical + * to those in the previous call. + * @param {string} [request.filter] + * Optional. Filter expression to restrict the insights returned. Supported + * filter fields: + * + * * `stateInfo.state` + * + * * `insightSubtype` + * + * * `severity` + * + * Examples: + * + * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` + * + * * `insightSubtype = PERMISSIONS_USAGE` + * + * * `severity = CRITICAL OR severity = HIGH` + * + * * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` + * + * (These expressions are based on the filter language described at + * https://google.aip.dev/160) + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.recommender.v1beta1.Insight|Insight}. + * 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 `listInsightsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listInsights( + request?: protos.google.cloud.recommender.v1beta1.IListInsightsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1beta1.IInsight[], + protos.google.cloud.recommender.v1beta1.IListInsightsRequest|null, + protos.google.cloud.recommender.v1beta1.IListInsightsResponse + ]>; + listInsights( + request: protos.google.cloud.recommender.v1beta1.IListInsightsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.recommender.v1beta1.IListInsightsRequest, + protos.google.cloud.recommender.v1beta1.IListInsightsResponse|null|undefined, + protos.google.cloud.recommender.v1beta1.IInsight>): void; + listInsights( + request: protos.google.cloud.recommender.v1beta1.IListInsightsRequest, + callback: PaginationCallback< + protos.google.cloud.recommender.v1beta1.IListInsightsRequest, + protos.google.cloud.recommender.v1beta1.IListInsightsResponse|null|undefined, + protos.google.cloud.recommender.v1beta1.IInsight>): void; + listInsights( + request?: protos.google.cloud.recommender.v1beta1.IListInsightsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.recommender.v1beta1.IListInsightsRequest, + protos.google.cloud.recommender.v1beta1.IListInsightsResponse|null|undefined, + protos.google.cloud.recommender.v1beta1.IInsight>, + callback?: PaginationCallback< + protos.google.cloud.recommender.v1beta1.IListInsightsRequest, + protos.google.cloud.recommender.v1beta1.IListInsightsResponse|null|undefined, + protos.google.cloud.recommender.v1beta1.IInsight>): + Promise<[ + protos.google.cloud.recommender.v1beta1.IInsight[], + protos.google.cloud.recommender.v1beta1.IListInsightsRequest|null, + protos.google.cloud.recommender.v1beta1.IListInsightsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listInsights(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 container resource on which to execute the request. + * Acceptable formats: + * + * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * LOCATION here refers to GCP Locations: + * https://cloud.google.com/about/locations/ + * INSIGHT_TYPE_ID refers to supported insight types: + * https://cloud.google.com/recommender/docs/insights/insight-types. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. Non-positive + * values are ignored. If not specified, the server will determine the number + * of results to return. + * @param {string} [request.pageToken] + * Optional. If present, retrieves the next batch of results from the preceding call to + * this method. `page_token` must be the value of `next_page_token` from the + * previous response. The values of other method parameters must be identical + * to those in the previous call. + * @param {string} [request.filter] + * Optional. Filter expression to restrict the insights returned. Supported + * filter fields: + * + * * `stateInfo.state` + * + * * `insightSubtype` + * + * * `severity` + * + * Examples: + * + * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` + * + * * `insightSubtype = PERMISSIONS_USAGE` + * + * * `severity = CRITICAL OR severity = HIGH` + * + * * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` + * + * (These expressions are based on the filter language described at + * https://google.aip.dev/160) + * @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 protos.google.cloud.recommender.v1beta1.Insight|Insight} 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 `listInsightsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listInsightsStream( + request?: protos.google.cloud.recommender.v1beta1.IListInsightsRequest, + 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['listInsights']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInsights.createStream( + this.innerApiCalls.listInsights as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listInsights`, 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 container resource on which to execute the request. + * Acceptable formats: + * + * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` + * + * LOCATION here refers to GCP Locations: + * https://cloud.google.com/about/locations/ + * INSIGHT_TYPE_ID refers to supported insight types: + * https://cloud.google.com/recommender/docs/insights/insight-types. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. Non-positive + * values are ignored. If not specified, the server will determine the number + * of results to return. + * @param {string} [request.pageToken] + * Optional. If present, retrieves the next batch of results from the preceding call to + * this method. `page_token` must be the value of `next_page_token` from the + * previous response. The values of other method parameters must be identical + * to those in the previous call. + * @param {string} [request.filter] + * Optional. Filter expression to restrict the insights returned. Supported + * filter fields: + * + * * `stateInfo.state` + * + * * `insightSubtype` + * + * * `severity` + * + * Examples: + * + * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` + * + * * `insightSubtype = PERMISSIONS_USAGE` + * + * * `severity = CRITICAL OR severity = HIGH` + * + * * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` + * + * (These expressions are based on the filter language described at + * https://google.aip.dev/160) + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.recommender.v1beta1.Insight|Insight}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/recommender.list_insights.js + * region_tag:recommender_v1beta1_generated_Recommender_ListInsights_async + */ + listInsightsAsync( + request?: protos.google.cloud.recommender.v1beta1.IListInsightsRequest, + 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['listInsights']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInsights.asyncIterate( + this.innerApiCalls['listInsights'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists recommendations for the specified Cloud Resource. Requires the + * recommender.*.list IAM permission for the specified recommender. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The container resource on which to execute the request. + * Acceptable formats: + * + * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * LOCATION here refers to GCP Locations: + * https://cloud.google.com/about/locations/ + * RECOMMENDER_ID refers to supported recommenders: + * https://cloud.google.com/recommender/docs/recommenders. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. Non-positive + * values are ignored. If not specified, the server will determine the number + * of results to return. + * @param {string} [request.pageToken] + * Optional. If present, retrieves the next batch of results from the preceding call to + * this method. `page_token` must be the value of `next_page_token` from the + * previous response. The values of other method parameters must be identical + * to those in the previous call. + * @param {string} request.filter + * Filter expression to restrict the recommendations returned. Supported + * filter fields: + * + * * `state_info.state` + * + * * `recommenderSubtype` + * + * * `priority` + * + * Examples: + * + * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` + * + * * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` + * + * * `priority = P1 OR priority = P2` + * + * * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` + * + * (These expressions are based on the filter language described at + * https://google.aip.dev/160) + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.recommender.v1beta1.Recommendation|Recommendation}. + * 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 `listRecommendationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listRecommendations( + request?: protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recommender.v1beta1.IRecommendation[], + protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest|null, + protos.google.cloud.recommender.v1beta1.IListRecommendationsResponse + ]>; + listRecommendations( + request: protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest, + protos.google.cloud.recommender.v1beta1.IListRecommendationsResponse|null|undefined, + protos.google.cloud.recommender.v1beta1.IRecommendation>): void; + listRecommendations( + request: protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest, + callback: PaginationCallback< + protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest, + protos.google.cloud.recommender.v1beta1.IListRecommendationsResponse|null|undefined, + protos.google.cloud.recommender.v1beta1.IRecommendation>): void; + listRecommendations( + request?: protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest, + protos.google.cloud.recommender.v1beta1.IListRecommendationsResponse|null|undefined, + protos.google.cloud.recommender.v1beta1.IRecommendation>, + callback?: PaginationCallback< + protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest, + protos.google.cloud.recommender.v1beta1.IListRecommendationsResponse|null|undefined, + protos.google.cloud.recommender.v1beta1.IRecommendation>): + Promise<[ + protos.google.cloud.recommender.v1beta1.IRecommendation[], + protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest|null, + protos.google.cloud.recommender.v1beta1.IListRecommendationsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listRecommendations(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 container resource on which to execute the request. + * Acceptable formats: + * + * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * LOCATION here refers to GCP Locations: + * https://cloud.google.com/about/locations/ + * RECOMMENDER_ID refers to supported recommenders: + * https://cloud.google.com/recommender/docs/recommenders. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. Non-positive + * values are ignored. If not specified, the server will determine the number + * of results to return. + * @param {string} [request.pageToken] + * Optional. If present, retrieves the next batch of results from the preceding call to + * this method. `page_token` must be the value of `next_page_token` from the + * previous response. The values of other method parameters must be identical + * to those in the previous call. + * @param {string} request.filter + * Filter expression to restrict the recommendations returned. Supported + * filter fields: + * + * * `state_info.state` + * + * * `recommenderSubtype` + * + * * `priority` + * + * Examples: + * + * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` + * + * * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` + * + * * `priority = P1 OR priority = P2` + * + * * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` + * + * (These expressions are based on the filter language described at + * https://google.aip.dev/160) + * @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 protos.google.cloud.recommender.v1beta1.Recommendation|Recommendation} 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 `listRecommendationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listRecommendationsStream( + request?: protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest, + 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['listRecommendations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRecommendations.createStream( + this.innerApiCalls.listRecommendations as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listRecommendations`, 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 container resource on which to execute the request. + * Acceptable formats: + * + * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` + * + * LOCATION here refers to GCP Locations: + * https://cloud.google.com/about/locations/ + * RECOMMENDER_ID refers to supported recommenders: + * https://cloud.google.com/recommender/docs/recommenders. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. Non-positive + * values are ignored. If not specified, the server will determine the number + * of results to return. + * @param {string} [request.pageToken] + * Optional. If present, retrieves the next batch of results from the preceding call to + * this method. `page_token` must be the value of `next_page_token` from the + * previous response. The values of other method parameters must be identical + * to those in the previous call. + * @param {string} request.filter + * Filter expression to restrict the recommendations returned. Supported + * filter fields: + * + * * `state_info.state` + * + * * `recommenderSubtype` + * + * * `priority` + * + * Examples: + * + * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` + * + * * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` + * + * * `priority = P1 OR priority = P2` + * + * * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` + * + * (These expressions are based on the filter language described at + * https://google.aip.dev/160) + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.recommender.v1beta1.Recommendation|Recommendation}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/recommender.list_recommendations.js + * region_tag:recommender_v1beta1_generated_Recommender_ListRecommendations_async + */ + listRecommendationsAsync( + request?: protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest, + 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['listRecommendations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRecommendations.asyncIterate( + this.innerApiCalls['listRecommendations'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified billingAccountLocationInsightType resource name string. + * + * @param {string} billing_account + * @param {string} location + * @param {string} insight_type + * @returns {string} Resource name string. + */ + billingAccountLocationInsightTypePath(billingAccount:string,location:string,insightType:string) { + return this.pathTemplates.billingAccountLocationInsightTypePathTemplate.render({ + billing_account: billingAccount, + location: location, + insight_type: insightType, + }); + } + + /** + * Parse the billing_account from BillingAccountLocationInsightType resource. + * + * @param {string} billingAccountLocationInsightTypeName + * A fully-qualified path representing billing_account_location_insight_type resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountLocationInsightTypeName(billingAccountLocationInsightTypeName: string) { + return this.pathTemplates.billingAccountLocationInsightTypePathTemplate.match(billingAccountLocationInsightTypeName).billing_account; + } + + /** + * Parse the location from BillingAccountLocationInsightType resource. + * + * @param {string} billingAccountLocationInsightTypeName + * A fully-qualified path representing billing_account_location_insight_type resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBillingAccountLocationInsightTypeName(billingAccountLocationInsightTypeName: string) { + return this.pathTemplates.billingAccountLocationInsightTypePathTemplate.match(billingAccountLocationInsightTypeName).location; + } + + /** + * Parse the insight_type from BillingAccountLocationInsightType resource. + * + * @param {string} billingAccountLocationInsightTypeName + * A fully-qualified path representing billing_account_location_insight_type resource. + * @returns {string} A string representing the insight_type. + */ + matchInsightTypeFromBillingAccountLocationInsightTypeName(billingAccountLocationInsightTypeName: string) { + return this.pathTemplates.billingAccountLocationInsightTypePathTemplate.match(billingAccountLocationInsightTypeName).insight_type; + } + + /** + * Return a fully-qualified billingAccountLocationInsightTypeInsight resource name string. + * + * @param {string} billing_account + * @param {string} location + * @param {string} insight_type + * @param {string} insight + * @returns {string} Resource name string. + */ + billingAccountLocationInsightTypeInsightPath(billingAccount:string,location:string,insightType:string,insight:string) { + return this.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.render({ + billing_account: billingAccount, + location: location, + insight_type: insightType, + insight: insight, + }); + } + + /** + * Parse the billing_account from BillingAccountLocationInsightTypeInsight resource. + * + * @param {string} billingAccountLocationInsightTypeInsightName + * A fully-qualified path representing billing_account_location_insight_type_insight resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountLocationInsightTypeInsightName(billingAccountLocationInsightTypeInsightName: string) { + return this.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match(billingAccountLocationInsightTypeInsightName).billing_account; + } + + /** + * Parse the location from BillingAccountLocationInsightTypeInsight resource. + * + * @param {string} billingAccountLocationInsightTypeInsightName + * A fully-qualified path representing billing_account_location_insight_type_insight resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBillingAccountLocationInsightTypeInsightName(billingAccountLocationInsightTypeInsightName: string) { + return this.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match(billingAccountLocationInsightTypeInsightName).location; + } + + /** + * Parse the insight_type from BillingAccountLocationInsightTypeInsight resource. + * + * @param {string} billingAccountLocationInsightTypeInsightName + * A fully-qualified path representing billing_account_location_insight_type_insight resource. + * @returns {string} A string representing the insight_type. + */ + matchInsightTypeFromBillingAccountLocationInsightTypeInsightName(billingAccountLocationInsightTypeInsightName: string) { + return this.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match(billingAccountLocationInsightTypeInsightName).insight_type; + } + + /** + * Parse the insight from BillingAccountLocationInsightTypeInsight resource. + * + * @param {string} billingAccountLocationInsightTypeInsightName + * A fully-qualified path representing billing_account_location_insight_type_insight resource. + * @returns {string} A string representing the insight. + */ + matchInsightFromBillingAccountLocationInsightTypeInsightName(billingAccountLocationInsightTypeInsightName: string) { + return this.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match(billingAccountLocationInsightTypeInsightName).insight; + } + + /** + * Return a fully-qualified billingAccountLocationRecommender resource name string. + * + * @param {string} billing_account + * @param {string} location + * @param {string} recommender + * @returns {string} Resource name string. + */ + billingAccountLocationRecommenderPath(billingAccount:string,location:string,recommender:string) { + return this.pathTemplates.billingAccountLocationRecommenderPathTemplate.render({ + billing_account: billingAccount, + location: location, + recommender: recommender, + }); + } + + /** + * Parse the billing_account from BillingAccountLocationRecommender resource. + * + * @param {string} billingAccountLocationRecommenderName + * A fully-qualified path representing billing_account_location_recommender resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountLocationRecommenderName(billingAccountLocationRecommenderName: string) { + return this.pathTemplates.billingAccountLocationRecommenderPathTemplate.match(billingAccountLocationRecommenderName).billing_account; + } + + /** + * Parse the location from BillingAccountLocationRecommender resource. + * + * @param {string} billingAccountLocationRecommenderName + * A fully-qualified path representing billing_account_location_recommender resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBillingAccountLocationRecommenderName(billingAccountLocationRecommenderName: string) { + return this.pathTemplates.billingAccountLocationRecommenderPathTemplate.match(billingAccountLocationRecommenderName).location; + } + + /** + * Parse the recommender from BillingAccountLocationRecommender resource. + * + * @param {string} billingAccountLocationRecommenderName + * A fully-qualified path representing billing_account_location_recommender resource. + * @returns {string} A string representing the recommender. + */ + matchRecommenderFromBillingAccountLocationRecommenderName(billingAccountLocationRecommenderName: string) { + return this.pathTemplates.billingAccountLocationRecommenderPathTemplate.match(billingAccountLocationRecommenderName).recommender; + } + + /** + * Return a fully-qualified billingAccountLocationRecommenderRecommendation resource name string. + * + * @param {string} billing_account + * @param {string} location + * @param {string} recommender + * @param {string} recommendation + * @returns {string} Resource name string. + */ + billingAccountLocationRecommenderRecommendationPath(billingAccount:string,location:string,recommender:string,recommendation:string) { + return this.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.render({ + billing_account: billingAccount, + location: location, + recommender: recommender, + recommendation: recommendation, + }); + } + + /** + * Parse the billing_account from BillingAccountLocationRecommenderRecommendation resource. + * + * @param {string} billingAccountLocationRecommenderRecommendationName + * A fully-qualified path representing billing_account_location_recommender_recommendation resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountLocationRecommenderRecommendationName(billingAccountLocationRecommenderRecommendationName: string) { + return this.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match(billingAccountLocationRecommenderRecommendationName).billing_account; + } + + /** + * Parse the location from BillingAccountLocationRecommenderRecommendation resource. + * + * @param {string} billingAccountLocationRecommenderRecommendationName + * A fully-qualified path representing billing_account_location_recommender_recommendation resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBillingAccountLocationRecommenderRecommendationName(billingAccountLocationRecommenderRecommendationName: string) { + return this.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match(billingAccountLocationRecommenderRecommendationName).location; + } + + /** + * Parse the recommender from BillingAccountLocationRecommenderRecommendation resource. + * + * @param {string} billingAccountLocationRecommenderRecommendationName + * A fully-qualified path representing billing_account_location_recommender_recommendation resource. + * @returns {string} A string representing the recommender. + */ + matchRecommenderFromBillingAccountLocationRecommenderRecommendationName(billingAccountLocationRecommenderRecommendationName: string) { + return this.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match(billingAccountLocationRecommenderRecommendationName).recommender; + } + + /** + * Parse the recommendation from BillingAccountLocationRecommenderRecommendation resource. + * + * @param {string} billingAccountLocationRecommenderRecommendationName + * A fully-qualified path representing billing_account_location_recommender_recommendation resource. + * @returns {string} A string representing the recommendation. + */ + matchRecommendationFromBillingAccountLocationRecommenderRecommendationName(billingAccountLocationRecommenderRecommendationName: string) { + return this.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match(billingAccountLocationRecommenderRecommendationName).recommendation; + } + + /** + * Return a fully-qualified folderLocationInsightType resource name string. + * + * @param {string} folder + * @param {string} location + * @param {string} insight_type + * @returns {string} Resource name string. + */ + folderLocationInsightTypePath(folder:string,location:string,insightType:string) { + return this.pathTemplates.folderLocationInsightTypePathTemplate.render({ + folder: folder, + location: location, + insight_type: insightType, + }); + } + + /** + * Parse the folder from FolderLocationInsightType resource. + * + * @param {string} folderLocationInsightTypeName + * A fully-qualified path representing folder_location_insight_type resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderLocationInsightTypeName(folderLocationInsightTypeName: string) { + return this.pathTemplates.folderLocationInsightTypePathTemplate.match(folderLocationInsightTypeName).folder; + } + + /** + * Parse the location from FolderLocationInsightType resource. + * + * @param {string} folderLocationInsightTypeName + * A fully-qualified path representing folder_location_insight_type resource. + * @returns {string} A string representing the location. + */ + matchLocationFromFolderLocationInsightTypeName(folderLocationInsightTypeName: string) { + return this.pathTemplates.folderLocationInsightTypePathTemplate.match(folderLocationInsightTypeName).location; + } + + /** + * Parse the insight_type from FolderLocationInsightType resource. + * + * @param {string} folderLocationInsightTypeName + * A fully-qualified path representing folder_location_insight_type resource. + * @returns {string} A string representing the insight_type. + */ + matchInsightTypeFromFolderLocationInsightTypeName(folderLocationInsightTypeName: string) { + return this.pathTemplates.folderLocationInsightTypePathTemplate.match(folderLocationInsightTypeName).insight_type; + } + + /** + * Return a fully-qualified folderLocationInsightTypeInsight resource name string. + * + * @param {string} folder + * @param {string} location + * @param {string} insight_type + * @param {string} insight + * @returns {string} Resource name string. + */ + folderLocationInsightTypeInsightPath(folder:string,location:string,insightType:string,insight:string) { + return this.pathTemplates.folderLocationInsightTypeInsightPathTemplate.render({ + folder: folder, + location: location, + insight_type: insightType, + insight: insight, + }); + } + + /** + * Parse the folder from FolderLocationInsightTypeInsight resource. + * + * @param {string} folderLocationInsightTypeInsightName + * A fully-qualified path representing folder_location_insight_type_insight resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderLocationInsightTypeInsightName(folderLocationInsightTypeInsightName: string) { + return this.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match(folderLocationInsightTypeInsightName).folder; + } + + /** + * Parse the location from FolderLocationInsightTypeInsight resource. + * + * @param {string} folderLocationInsightTypeInsightName + * A fully-qualified path representing folder_location_insight_type_insight resource. + * @returns {string} A string representing the location. + */ + matchLocationFromFolderLocationInsightTypeInsightName(folderLocationInsightTypeInsightName: string) { + return this.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match(folderLocationInsightTypeInsightName).location; + } + + /** + * Parse the insight_type from FolderLocationInsightTypeInsight resource. + * + * @param {string} folderLocationInsightTypeInsightName + * A fully-qualified path representing folder_location_insight_type_insight resource. + * @returns {string} A string representing the insight_type. + */ + matchInsightTypeFromFolderLocationInsightTypeInsightName(folderLocationInsightTypeInsightName: string) { + return this.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match(folderLocationInsightTypeInsightName).insight_type; + } + + /** + * Parse the insight from FolderLocationInsightTypeInsight resource. + * + * @param {string} folderLocationInsightTypeInsightName + * A fully-qualified path representing folder_location_insight_type_insight resource. + * @returns {string} A string representing the insight. + */ + matchInsightFromFolderLocationInsightTypeInsightName(folderLocationInsightTypeInsightName: string) { + return this.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match(folderLocationInsightTypeInsightName).insight; + } + + /** + * Return a fully-qualified folderLocationRecommender resource name string. + * + * @param {string} folder + * @param {string} location + * @param {string} recommender + * @returns {string} Resource name string. + */ + folderLocationRecommenderPath(folder:string,location:string,recommender:string) { + return this.pathTemplates.folderLocationRecommenderPathTemplate.render({ + folder: folder, + location: location, + recommender: recommender, + }); + } + + /** + * Parse the folder from FolderLocationRecommender resource. + * + * @param {string} folderLocationRecommenderName + * A fully-qualified path representing folder_location_recommender resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderLocationRecommenderName(folderLocationRecommenderName: string) { + return this.pathTemplates.folderLocationRecommenderPathTemplate.match(folderLocationRecommenderName).folder; + } + + /** + * Parse the location from FolderLocationRecommender resource. + * + * @param {string} folderLocationRecommenderName + * A fully-qualified path representing folder_location_recommender resource. + * @returns {string} A string representing the location. + */ + matchLocationFromFolderLocationRecommenderName(folderLocationRecommenderName: string) { + return this.pathTemplates.folderLocationRecommenderPathTemplate.match(folderLocationRecommenderName).location; + } + + /** + * Parse the recommender from FolderLocationRecommender resource. + * + * @param {string} folderLocationRecommenderName + * A fully-qualified path representing folder_location_recommender resource. + * @returns {string} A string representing the recommender. + */ + matchRecommenderFromFolderLocationRecommenderName(folderLocationRecommenderName: string) { + return this.pathTemplates.folderLocationRecommenderPathTemplate.match(folderLocationRecommenderName).recommender; + } + + /** + * Return a fully-qualified folderLocationRecommenderRecommendation resource name string. + * + * @param {string} folder + * @param {string} location + * @param {string} recommender + * @param {string} recommendation + * @returns {string} Resource name string. + */ + folderLocationRecommenderRecommendationPath(folder:string,location:string,recommender:string,recommendation:string) { + return this.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.render({ + folder: folder, + location: location, + recommender: recommender, + recommendation: recommendation, + }); + } + + /** + * Parse the folder from FolderLocationRecommenderRecommendation resource. + * + * @param {string} folderLocationRecommenderRecommendationName + * A fully-qualified path representing folder_location_recommender_recommendation resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderLocationRecommenderRecommendationName(folderLocationRecommenderRecommendationName: string) { + return this.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match(folderLocationRecommenderRecommendationName).folder; + } + + /** + * Parse the location from FolderLocationRecommenderRecommendation resource. + * + * @param {string} folderLocationRecommenderRecommendationName + * A fully-qualified path representing folder_location_recommender_recommendation resource. + * @returns {string} A string representing the location. + */ + matchLocationFromFolderLocationRecommenderRecommendationName(folderLocationRecommenderRecommendationName: string) { + return this.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match(folderLocationRecommenderRecommendationName).location; + } + + /** + * Parse the recommender from FolderLocationRecommenderRecommendation resource. + * + * @param {string} folderLocationRecommenderRecommendationName + * A fully-qualified path representing folder_location_recommender_recommendation resource. + * @returns {string} A string representing the recommender. + */ + matchRecommenderFromFolderLocationRecommenderRecommendationName(folderLocationRecommenderRecommendationName: string) { + return this.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match(folderLocationRecommenderRecommendationName).recommender; + } + + /** + * Parse the recommendation from FolderLocationRecommenderRecommendation resource. + * + * @param {string} folderLocationRecommenderRecommendationName + * A fully-qualified path representing folder_location_recommender_recommendation resource. + * @returns {string} A string representing the recommendation. + */ + matchRecommendationFromFolderLocationRecommenderRecommendationName(folderLocationRecommenderRecommendationName: string) { + return this.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match(folderLocationRecommenderRecommendationName).recommendation; + } + + /** + * Return a fully-qualified organizationLocationInsightType resource name string. + * + * @param {string} organization + * @param {string} location + * @param {string} insight_type + * @returns {string} Resource name string. + */ + organizationLocationInsightTypePath(organization:string,location:string,insightType:string) { + return this.pathTemplates.organizationLocationInsightTypePathTemplate.render({ + organization: organization, + location: location, + insight_type: insightType, + }); + } + + /** + * Parse the organization from OrganizationLocationInsightType resource. + * + * @param {string} organizationLocationInsightTypeName + * A fully-qualified path representing organization_location_insight_type resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLocationInsightTypeName(organizationLocationInsightTypeName: string) { + return this.pathTemplates.organizationLocationInsightTypePathTemplate.match(organizationLocationInsightTypeName).organization; + } + + /** + * Parse the location from OrganizationLocationInsightType resource. + * + * @param {string} organizationLocationInsightTypeName + * A fully-qualified path representing organization_location_insight_type resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOrganizationLocationInsightTypeName(organizationLocationInsightTypeName: string) { + return this.pathTemplates.organizationLocationInsightTypePathTemplate.match(organizationLocationInsightTypeName).location; + } + + /** + * Parse the insight_type from OrganizationLocationInsightType resource. + * + * @param {string} organizationLocationInsightTypeName + * A fully-qualified path representing organization_location_insight_type resource. + * @returns {string} A string representing the insight_type. + */ + matchInsightTypeFromOrganizationLocationInsightTypeName(organizationLocationInsightTypeName: string) { + return this.pathTemplates.organizationLocationInsightTypePathTemplate.match(organizationLocationInsightTypeName).insight_type; + } + + /** + * Return a fully-qualified organizationLocationInsightTypeConfig resource name string. + * + * @param {string} organization + * @param {string} location + * @param {string} insight_type + * @returns {string} Resource name string. + */ + organizationLocationInsightTypeConfigPath(organization:string,location:string,insightType:string) { + return this.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.render({ + organization: organization, + location: location, + insight_type: insightType, + }); + } + + /** + * Parse the organization from OrganizationLocationInsightTypeConfig resource. + * + * @param {string} organizationLocationInsightTypeConfigName + * A fully-qualified path representing organization_location_insight_type_config resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLocationInsightTypeConfigName(organizationLocationInsightTypeConfigName: string) { + return this.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match(organizationLocationInsightTypeConfigName).organization; + } + + /** + * Parse the location from OrganizationLocationInsightTypeConfig resource. + * + * @param {string} organizationLocationInsightTypeConfigName + * A fully-qualified path representing organization_location_insight_type_config resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOrganizationLocationInsightTypeConfigName(organizationLocationInsightTypeConfigName: string) { + return this.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match(organizationLocationInsightTypeConfigName).location; + } + + /** + * Parse the insight_type from OrganizationLocationInsightTypeConfig resource. + * + * @param {string} organizationLocationInsightTypeConfigName + * A fully-qualified path representing organization_location_insight_type_config resource. + * @returns {string} A string representing the insight_type. + */ + matchInsightTypeFromOrganizationLocationInsightTypeConfigName(organizationLocationInsightTypeConfigName: string) { + return this.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match(organizationLocationInsightTypeConfigName).insight_type; + } + + /** + * Return a fully-qualified organizationLocationInsightTypeInsight resource name string. + * + * @param {string} organization + * @param {string} location + * @param {string} insight_type + * @param {string} insight + * @returns {string} Resource name string. + */ + organizationLocationInsightTypeInsightPath(organization:string,location:string,insightType:string,insight:string) { + return this.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.render({ + organization: organization, + location: location, + insight_type: insightType, + insight: insight, + }); + } + + /** + * Parse the organization from OrganizationLocationInsightTypeInsight resource. + * + * @param {string} organizationLocationInsightTypeInsightName + * A fully-qualified path representing organization_location_insight_type_insight resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLocationInsightTypeInsightName(organizationLocationInsightTypeInsightName: string) { + return this.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match(organizationLocationInsightTypeInsightName).organization; + } + + /** + * Parse the location from OrganizationLocationInsightTypeInsight resource. + * + * @param {string} organizationLocationInsightTypeInsightName + * A fully-qualified path representing organization_location_insight_type_insight resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOrganizationLocationInsightTypeInsightName(organizationLocationInsightTypeInsightName: string) { + return this.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match(organizationLocationInsightTypeInsightName).location; + } + + /** + * Parse the insight_type from OrganizationLocationInsightTypeInsight resource. + * + * @param {string} organizationLocationInsightTypeInsightName + * A fully-qualified path representing organization_location_insight_type_insight resource. + * @returns {string} A string representing the insight_type. + */ + matchInsightTypeFromOrganizationLocationInsightTypeInsightName(organizationLocationInsightTypeInsightName: string) { + return this.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match(organizationLocationInsightTypeInsightName).insight_type; + } + + /** + * Parse the insight from OrganizationLocationInsightTypeInsight resource. + * + * @param {string} organizationLocationInsightTypeInsightName + * A fully-qualified path representing organization_location_insight_type_insight resource. + * @returns {string} A string representing the insight. + */ + matchInsightFromOrganizationLocationInsightTypeInsightName(organizationLocationInsightTypeInsightName: string) { + return this.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match(organizationLocationInsightTypeInsightName).insight; + } + + /** + * Return a fully-qualified organizationLocationRecommender resource name string. + * + * @param {string} organization + * @param {string} location + * @param {string} recommender + * @returns {string} Resource name string. + */ + organizationLocationRecommenderPath(organization:string,location:string,recommender:string) { + return this.pathTemplates.organizationLocationRecommenderPathTemplate.render({ + organization: organization, + location: location, + recommender: recommender, + }); + } + + /** + * Parse the organization from OrganizationLocationRecommender resource. + * + * @param {string} organizationLocationRecommenderName + * A fully-qualified path representing organization_location_recommender resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLocationRecommenderName(organizationLocationRecommenderName: string) { + return this.pathTemplates.organizationLocationRecommenderPathTemplate.match(organizationLocationRecommenderName).organization; + } + + /** + * Parse the location from OrganizationLocationRecommender resource. + * + * @param {string} organizationLocationRecommenderName + * A fully-qualified path representing organization_location_recommender resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOrganizationLocationRecommenderName(organizationLocationRecommenderName: string) { + return this.pathTemplates.organizationLocationRecommenderPathTemplate.match(organizationLocationRecommenderName).location; + } + + /** + * Parse the recommender from OrganizationLocationRecommender resource. + * + * @param {string} organizationLocationRecommenderName + * A fully-qualified path representing organization_location_recommender resource. + * @returns {string} A string representing the recommender. + */ + matchRecommenderFromOrganizationLocationRecommenderName(organizationLocationRecommenderName: string) { + return this.pathTemplates.organizationLocationRecommenderPathTemplate.match(organizationLocationRecommenderName).recommender; + } + + /** + * Return a fully-qualified organizationLocationRecommenderConfig resource name string. + * + * @param {string} organization + * @param {string} location + * @param {string} recommender + * @returns {string} Resource name string. + */ + organizationLocationRecommenderConfigPath(organization:string,location:string,recommender:string) { + return this.pathTemplates.organizationLocationRecommenderConfigPathTemplate.render({ + organization: organization, + location: location, + recommender: recommender, + }); + } + + /** + * Parse the organization from OrganizationLocationRecommenderConfig resource. + * + * @param {string} organizationLocationRecommenderConfigName + * A fully-qualified path representing organization_location_recommender_config resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLocationRecommenderConfigName(organizationLocationRecommenderConfigName: string) { + return this.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match(organizationLocationRecommenderConfigName).organization; + } + + /** + * Parse the location from OrganizationLocationRecommenderConfig resource. + * + * @param {string} organizationLocationRecommenderConfigName + * A fully-qualified path representing organization_location_recommender_config resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOrganizationLocationRecommenderConfigName(organizationLocationRecommenderConfigName: string) { + return this.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match(organizationLocationRecommenderConfigName).location; + } + + /** + * Parse the recommender from OrganizationLocationRecommenderConfig resource. + * + * @param {string} organizationLocationRecommenderConfigName + * A fully-qualified path representing organization_location_recommender_config resource. + * @returns {string} A string representing the recommender. + */ + matchRecommenderFromOrganizationLocationRecommenderConfigName(organizationLocationRecommenderConfigName: string) { + return this.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match(organizationLocationRecommenderConfigName).recommender; + } + + /** + * Return a fully-qualified organizationLocationRecommenderRecommendation resource name string. + * + * @param {string} organization + * @param {string} location + * @param {string} recommender + * @param {string} recommendation + * @returns {string} Resource name string. + */ + organizationLocationRecommenderRecommendationPath(organization:string,location:string,recommender:string,recommendation:string) { + return this.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.render({ + organization: organization, + location: location, + recommender: recommender, + recommendation: recommendation, + }); + } + + /** + * Parse the organization from OrganizationLocationRecommenderRecommendation resource. + * + * @param {string} organizationLocationRecommenderRecommendationName + * A fully-qualified path representing organization_location_recommender_recommendation resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLocationRecommenderRecommendationName(organizationLocationRecommenderRecommendationName: string) { + return this.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match(organizationLocationRecommenderRecommendationName).organization; + } + + /** + * Parse the location from OrganizationLocationRecommenderRecommendation resource. + * + * @param {string} organizationLocationRecommenderRecommendationName + * A fully-qualified path representing organization_location_recommender_recommendation resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOrganizationLocationRecommenderRecommendationName(organizationLocationRecommenderRecommendationName: string) { + return this.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match(organizationLocationRecommenderRecommendationName).location; + } + + /** + * Parse the recommender from OrganizationLocationRecommenderRecommendation resource. + * + * @param {string} organizationLocationRecommenderRecommendationName + * A fully-qualified path representing organization_location_recommender_recommendation resource. + * @returns {string} A string representing the recommender. + */ + matchRecommenderFromOrganizationLocationRecommenderRecommendationName(organizationLocationRecommenderRecommendationName: string) { + return this.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match(organizationLocationRecommenderRecommendationName).recommender; + } + + /** + * Parse the recommendation from OrganizationLocationRecommenderRecommendation resource. + * + * @param {string} organizationLocationRecommenderRecommendationName + * A fully-qualified path representing organization_location_recommender_recommendation resource. + * @returns {string} A string representing the recommendation. + */ + matchRecommendationFromOrganizationLocationRecommenderRecommendationName(organizationLocationRecommenderRecommendationName: string) { + return this.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match(organizationLocationRecommenderRecommendationName).recommendation; + } + + /** + * Return a fully-qualified projectLocationInsightType resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} insight_type + * @returns {string} Resource name string. + */ + projectLocationInsightTypePath(project:string,location:string,insightType:string) { + return this.pathTemplates.projectLocationInsightTypePathTemplate.render({ + project: project, + location: location, + insight_type: insightType, + }); + } + + /** + * Parse the project from ProjectLocationInsightType resource. + * + * @param {string} projectLocationInsightTypeName + * A fully-qualified path representing project_location_insight_type resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationInsightTypeName(projectLocationInsightTypeName: string) { + return this.pathTemplates.projectLocationInsightTypePathTemplate.match(projectLocationInsightTypeName).project; + } + + /** + * Parse the location from ProjectLocationInsightType resource. + * + * @param {string} projectLocationInsightTypeName + * A fully-qualified path representing project_location_insight_type resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationInsightTypeName(projectLocationInsightTypeName: string) { + return this.pathTemplates.projectLocationInsightTypePathTemplate.match(projectLocationInsightTypeName).location; + } + + /** + * Parse the insight_type from ProjectLocationInsightType resource. + * + * @param {string} projectLocationInsightTypeName + * A fully-qualified path representing project_location_insight_type resource. + * @returns {string} A string representing the insight_type. + */ + matchInsightTypeFromProjectLocationInsightTypeName(projectLocationInsightTypeName: string) { + return this.pathTemplates.projectLocationInsightTypePathTemplate.match(projectLocationInsightTypeName).insight_type; + } + + /** + * Return a fully-qualified projectLocationInsightTypeConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} insight_type + * @returns {string} Resource name string. + */ + projectLocationInsightTypeConfigPath(project:string,location:string,insightType:string) { + return this.pathTemplates.projectLocationInsightTypeConfigPathTemplate.render({ + project: project, + location: location, + insight_type: insightType, + }); + } + + /** + * Parse the project from ProjectLocationInsightTypeConfig resource. + * + * @param {string} projectLocationInsightTypeConfigName + * A fully-qualified path representing project_location_insight_type_config resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationInsightTypeConfigName(projectLocationInsightTypeConfigName: string) { + return this.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match(projectLocationInsightTypeConfigName).project; + } + + /** + * Parse the location from ProjectLocationInsightTypeConfig resource. + * + * @param {string} projectLocationInsightTypeConfigName + * A fully-qualified path representing project_location_insight_type_config resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationInsightTypeConfigName(projectLocationInsightTypeConfigName: string) { + return this.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match(projectLocationInsightTypeConfigName).location; + } + + /** + * Parse the insight_type from ProjectLocationInsightTypeConfig resource. + * + * @param {string} projectLocationInsightTypeConfigName + * A fully-qualified path representing project_location_insight_type_config resource. + * @returns {string} A string representing the insight_type. + */ + matchInsightTypeFromProjectLocationInsightTypeConfigName(projectLocationInsightTypeConfigName: string) { + return this.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match(projectLocationInsightTypeConfigName).insight_type; + } + + /** + * Return a fully-qualified projectLocationInsightTypeInsight resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} insight_type + * @param {string} insight + * @returns {string} Resource name string. + */ + projectLocationInsightTypeInsightPath(project:string,location:string,insightType:string,insight:string) { + return this.pathTemplates.projectLocationInsightTypeInsightPathTemplate.render({ + project: project, + location: location, + insight_type: insightType, + insight: insight, + }); + } + + /** + * Parse the project from ProjectLocationInsightTypeInsight resource. + * + * @param {string} projectLocationInsightTypeInsightName + * A fully-qualified path representing project_location_insight_type_insight resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationInsightTypeInsightName(projectLocationInsightTypeInsightName: string) { + return this.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match(projectLocationInsightTypeInsightName).project; + } + + /** + * Parse the location from ProjectLocationInsightTypeInsight resource. + * + * @param {string} projectLocationInsightTypeInsightName + * A fully-qualified path representing project_location_insight_type_insight resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationInsightTypeInsightName(projectLocationInsightTypeInsightName: string) { + return this.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match(projectLocationInsightTypeInsightName).location; + } + + /** + * Parse the insight_type from ProjectLocationInsightTypeInsight resource. + * + * @param {string} projectLocationInsightTypeInsightName + * A fully-qualified path representing project_location_insight_type_insight resource. + * @returns {string} A string representing the insight_type. + */ + matchInsightTypeFromProjectLocationInsightTypeInsightName(projectLocationInsightTypeInsightName: string) { + return this.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match(projectLocationInsightTypeInsightName).insight_type; + } + + /** + * Parse the insight from ProjectLocationInsightTypeInsight resource. + * + * @param {string} projectLocationInsightTypeInsightName + * A fully-qualified path representing project_location_insight_type_insight resource. + * @returns {string} A string representing the insight. + */ + matchInsightFromProjectLocationInsightTypeInsightName(projectLocationInsightTypeInsightName: string) { + return this.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match(projectLocationInsightTypeInsightName).insight; + } + + /** + * Return a fully-qualified projectLocationRecommender resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} recommender + * @returns {string} Resource name string. + */ + projectLocationRecommenderPath(project:string,location:string,recommender:string) { + return this.pathTemplates.projectLocationRecommenderPathTemplate.render({ + project: project, + location: location, + recommender: recommender, + }); + } + + /** + * Parse the project from ProjectLocationRecommender resource. + * + * @param {string} projectLocationRecommenderName + * A fully-qualified path representing project_location_recommender resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationRecommenderName(projectLocationRecommenderName: string) { + return this.pathTemplates.projectLocationRecommenderPathTemplate.match(projectLocationRecommenderName).project; + } + + /** + * Parse the location from ProjectLocationRecommender resource. + * + * @param {string} projectLocationRecommenderName + * A fully-qualified path representing project_location_recommender resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationRecommenderName(projectLocationRecommenderName: string) { + return this.pathTemplates.projectLocationRecommenderPathTemplate.match(projectLocationRecommenderName).location; + } + + /** + * Parse the recommender from ProjectLocationRecommender resource. + * + * @param {string} projectLocationRecommenderName + * A fully-qualified path representing project_location_recommender resource. + * @returns {string} A string representing the recommender. + */ + matchRecommenderFromProjectLocationRecommenderName(projectLocationRecommenderName: string) { + return this.pathTemplates.projectLocationRecommenderPathTemplate.match(projectLocationRecommenderName).recommender; + } + + /** + * Return a fully-qualified projectLocationRecommenderConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} recommender + * @returns {string} Resource name string. + */ + projectLocationRecommenderConfigPath(project:string,location:string,recommender:string) { + return this.pathTemplates.projectLocationRecommenderConfigPathTemplate.render({ + project: project, + location: location, + recommender: recommender, + }); + } + + /** + * Parse the project from ProjectLocationRecommenderConfig resource. + * + * @param {string} projectLocationRecommenderConfigName + * A fully-qualified path representing project_location_recommender_config resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationRecommenderConfigName(projectLocationRecommenderConfigName: string) { + return this.pathTemplates.projectLocationRecommenderConfigPathTemplate.match(projectLocationRecommenderConfigName).project; + } + + /** + * Parse the location from ProjectLocationRecommenderConfig resource. + * + * @param {string} projectLocationRecommenderConfigName + * A fully-qualified path representing project_location_recommender_config resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationRecommenderConfigName(projectLocationRecommenderConfigName: string) { + return this.pathTemplates.projectLocationRecommenderConfigPathTemplate.match(projectLocationRecommenderConfigName).location; + } + + /** + * Parse the recommender from ProjectLocationRecommenderConfig resource. + * + * @param {string} projectLocationRecommenderConfigName + * A fully-qualified path representing project_location_recommender_config resource. + * @returns {string} A string representing the recommender. + */ + matchRecommenderFromProjectLocationRecommenderConfigName(projectLocationRecommenderConfigName: string) { + return this.pathTemplates.projectLocationRecommenderConfigPathTemplate.match(projectLocationRecommenderConfigName).recommender; + } + + /** + * Return a fully-qualified projectLocationRecommenderRecommendation resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} recommender + * @param {string} recommendation + * @returns {string} Resource name string. + */ + projectLocationRecommenderRecommendationPath(project:string,location:string,recommender:string,recommendation:string) { + return this.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.render({ + project: project, + location: location, + recommender: recommender, + recommendation: recommendation, + }); + } + + /** + * Parse the project from ProjectLocationRecommenderRecommendation resource. + * + * @param {string} projectLocationRecommenderRecommendationName + * A fully-qualified path representing project_location_recommender_recommendation resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationRecommenderRecommendationName(projectLocationRecommenderRecommendationName: string) { + return this.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match(projectLocationRecommenderRecommendationName).project; + } + + /** + * Parse the location from ProjectLocationRecommenderRecommendation resource. + * + * @param {string} projectLocationRecommenderRecommendationName + * A fully-qualified path representing project_location_recommender_recommendation resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationRecommenderRecommendationName(projectLocationRecommenderRecommendationName: string) { + return this.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match(projectLocationRecommenderRecommendationName).location; + } + + /** + * Parse the recommender from ProjectLocationRecommenderRecommendation resource. + * + * @param {string} projectLocationRecommenderRecommendationName + * A fully-qualified path representing project_location_recommender_recommendation resource. + * @returns {string} A string representing the recommender. + */ + matchRecommenderFromProjectLocationRecommenderRecommendationName(projectLocationRecommenderRecommendationName: string) { + return this.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match(projectLocationRecommenderRecommendationName).recommender; + } + + /** + * Parse the recommendation from ProjectLocationRecommenderRecommendation resource. + * + * @param {string} projectLocationRecommenderRecommendationName + * A fully-qualified path representing project_location_recommender_recommendation resource. + * @returns {string} A string representing the recommendation. + */ + matchRecommendationFromProjectLocationRecommenderRecommendationName(projectLocationRecommenderRecommendationName: string) { + return this.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match(projectLocationRecommenderRecommendationName).recommendation; + } + + /** + * 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.recommenderStub && !this._terminated) { + return this.recommenderStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_client_config.json b/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_client_config.json new file mode 100644 index 00000000000..76661e8589b --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_client_config.json @@ -0,0 +1,82 @@ +{ + "interfaces": { + "google.cloud.recommender.v1beta1.Recommender": { + "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": { + "ListInsights": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetInsight": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "MarkInsightAccepted": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListRecommendations": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetRecommendation": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "MarkRecommendationClaimed": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "MarkRecommendationSucceeded": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "MarkRecommendationFailed": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetRecommenderConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateRecommenderConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetInsightTypeConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateInsightTypeConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_proto_list.json b/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_proto_list.json new file mode 100644 index 00000000000..7e1fb4b4ee6 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_proto_list.json @@ -0,0 +1,7 @@ +[ + "../../protos/google/cloud/recommender/v1beta1/insight.proto", + "../../protos/google/cloud/recommender/v1beta1/insight_type_config.proto", + "../../protos/google/cloud/recommender/v1beta1/recommendation.proto", + "../../protos/google/cloud/recommender/v1beta1/recommender_config.proto", + "../../protos/google/cloud/recommender/v1beta1/recommender_service.proto" +] diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-recommender/v1beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..8db790db9d7 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const recommender = require('@google-cloud/recommender'); + +function main() { + const recommenderClient = new recommender.RecommenderClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-recommender/v1beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..5142e8f3f3e --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {RecommenderClient} from '@google-cloud/recommender'; + +// check that the client class type name can be used +function doStuffWithRecommenderClient(client: RecommenderClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const recommenderClient = new RecommenderClient(); + doStuffWithRecommenderClient(recommenderClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-recommender/v1beta1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/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-recommender/v1beta1/test/gapic_recommender_v1beta1.ts b/owl-bot-staging/google-cloud-recommender/v1beta1/test/gapic_recommender_v1beta1.ts new file mode 100644 index 00000000000..a8277cf581c --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/test/gapic_recommender_v1beta1.ts @@ -0,0 +1,2762 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 recommenderModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +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('v1beta1.RecommenderClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = recommenderModule.v1beta1.RecommenderClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = recommenderModule.v1beta1.RecommenderClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = recommenderModule.v1beta1.RecommenderClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new recommenderModule.v1beta1.RecommenderClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.recommenderStub, undefined); + await client.initialize(); + assert(client.recommenderStub); + }); + + it('has close method for the initialized client', done => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.recommenderStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.recommenderStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new recommenderModule.v1beta1.RecommenderClient({ + 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 recommenderModule.v1beta1.RecommenderClient({ + 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('getInsight', () => { + it('invokes getInsight without error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.GetInsightRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetInsightRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.Insight() + ); + client.innerApiCalls.getInsight = stubSimpleCall(expectedResponse); + const [response] = await client.getInsight(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInsight as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInsight as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInsight without error using callback', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.GetInsightRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetInsightRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.Insight() + ); + client.innerApiCalls.getInsight = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInsight( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IInsight|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInsight as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInsight as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInsight with error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.GetInsightRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetInsightRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInsight = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getInsight(request), expectedError); + const actualRequest = (client.innerApiCalls.getInsight as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInsight as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInsight with closed client', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.GetInsightRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetInsightRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getInsight(request), expectedError); + }); + }); + + describe('markInsightAccepted', () => { + it('invokes markInsightAccepted without error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.MarkInsightAcceptedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkInsightAcceptedRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.Insight() + ); + client.innerApiCalls.markInsightAccepted = stubSimpleCall(expectedResponse); + const [response] = await client.markInsightAccepted(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.markInsightAccepted as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markInsightAccepted as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markInsightAccepted without error using callback', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.MarkInsightAcceptedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkInsightAcceptedRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.Insight() + ); + client.innerApiCalls.markInsightAccepted = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.markInsightAccepted( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IInsight|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.markInsightAccepted as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markInsightAccepted as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markInsightAccepted with error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.MarkInsightAcceptedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkInsightAcceptedRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.markInsightAccepted = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.markInsightAccepted(request), expectedError); + const actualRequest = (client.innerApiCalls.markInsightAccepted as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markInsightAccepted as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markInsightAccepted with closed client', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.MarkInsightAcceptedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkInsightAcceptedRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.markInsightAccepted(request), expectedError); + }); + }); + + describe('getRecommendation', () => { + it('invokes getRecommendation without error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.GetRecommendationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetRecommendationRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.Recommendation() + ); + client.innerApiCalls.getRecommendation = stubSimpleCall(expectedResponse); + const [response] = await client.getRecommendation(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRecommendation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRecommendation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRecommendation without error using callback', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.GetRecommendationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetRecommendationRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.Recommendation() + ); + client.innerApiCalls.getRecommendation = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRecommendation( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IRecommendation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRecommendation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRecommendation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRecommendation with error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.GetRecommendationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetRecommendationRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getRecommendation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getRecommendation(request), expectedError); + const actualRequest = (client.innerApiCalls.getRecommendation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRecommendation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRecommendation with closed client', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.GetRecommendationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetRecommendationRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getRecommendation(request), expectedError); + }); + }); + + describe('markRecommendationClaimed', () => { + it('invokes markRecommendationClaimed without error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.Recommendation() + ); + client.innerApiCalls.markRecommendationClaimed = stubSimpleCall(expectedResponse); + const [response] = await client.markRecommendationClaimed(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.markRecommendationClaimed as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationClaimed as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markRecommendationClaimed without error using callback', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.Recommendation() + ); + client.innerApiCalls.markRecommendationClaimed = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.markRecommendationClaimed( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IRecommendation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.markRecommendationClaimed as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationClaimed as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markRecommendationClaimed with error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.markRecommendationClaimed = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.markRecommendationClaimed(request), expectedError); + const actualRequest = (client.innerApiCalls.markRecommendationClaimed as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationClaimed as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markRecommendationClaimed with closed client', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.markRecommendationClaimed(request), expectedError); + }); + }); + + describe('markRecommendationSucceeded', () => { + it('invokes markRecommendationSucceeded without error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.Recommendation() + ); + client.innerApiCalls.markRecommendationSucceeded = stubSimpleCall(expectedResponse); + const [response] = await client.markRecommendationSucceeded(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markRecommendationSucceeded without error using callback', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.Recommendation() + ); + client.innerApiCalls.markRecommendationSucceeded = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.markRecommendationSucceeded( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IRecommendation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markRecommendationSucceeded with error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.markRecommendationSucceeded = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.markRecommendationSucceeded(request), expectedError); + const actualRequest = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markRecommendationSucceeded with closed client', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.markRecommendationSucceeded(request), expectedError); + }); + }); + + describe('markRecommendationFailed', () => { + it('invokes markRecommendationFailed without error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.Recommendation() + ); + client.innerApiCalls.markRecommendationFailed = stubSimpleCall(expectedResponse); + const [response] = await client.markRecommendationFailed(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.markRecommendationFailed as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationFailed as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markRecommendationFailed without error using callback', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.Recommendation() + ); + client.innerApiCalls.markRecommendationFailed = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.markRecommendationFailed( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IRecommendation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.markRecommendationFailed as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationFailed as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markRecommendationFailed with error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.markRecommendationFailed = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.markRecommendationFailed(request), expectedError); + const actualRequest = (client.innerApiCalls.markRecommendationFailed as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationFailed as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes markRecommendationFailed with closed client', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.markRecommendationFailed(request), expectedError); + }); + }); + + describe('getRecommenderConfig', () => { + it('invokes getRecommenderConfig without error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.GetRecommenderConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetRecommenderConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.RecommenderConfig() + ); + client.innerApiCalls.getRecommenderConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getRecommenderConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRecommenderConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRecommenderConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRecommenderConfig without error using callback', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.GetRecommenderConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetRecommenderConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.RecommenderConfig() + ); + client.innerApiCalls.getRecommenderConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRecommenderConfig( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IRecommenderConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRecommenderConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRecommenderConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRecommenderConfig with error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.GetRecommenderConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetRecommenderConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getRecommenderConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getRecommenderConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.getRecommenderConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRecommenderConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRecommenderConfig with closed client', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.GetRecommenderConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetRecommenderConfigRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getRecommenderConfig(request), expectedError); + }); + }); + + describe('updateRecommenderConfig', () => { + it('invokes updateRecommenderConfig without error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.UpdateRecommenderConfigRequest() + ); + request.recommenderConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.UpdateRecommenderConfigRequest', ['recommenderConfig', 'name']); + request.recommenderConfig.name = defaultValue1; + const expectedHeaderRequestParams = `recommender_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.RecommenderConfig() + ); + client.innerApiCalls.updateRecommenderConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateRecommenderConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateRecommenderConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateRecommenderConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateRecommenderConfig without error using callback', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.UpdateRecommenderConfigRequest() + ); + request.recommenderConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.UpdateRecommenderConfigRequest', ['recommenderConfig', 'name']); + request.recommenderConfig.name = defaultValue1; + const expectedHeaderRequestParams = `recommender_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.RecommenderConfig() + ); + client.innerApiCalls.updateRecommenderConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateRecommenderConfig( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IRecommenderConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateRecommenderConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateRecommenderConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateRecommenderConfig with error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.UpdateRecommenderConfigRequest() + ); + request.recommenderConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.UpdateRecommenderConfigRequest', ['recommenderConfig', 'name']); + request.recommenderConfig.name = defaultValue1; + const expectedHeaderRequestParams = `recommender_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateRecommenderConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateRecommenderConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.updateRecommenderConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateRecommenderConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateRecommenderConfig with closed client', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.UpdateRecommenderConfigRequest() + ); + request.recommenderConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.UpdateRecommenderConfigRequest', ['recommenderConfig', 'name']); + request.recommenderConfig.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateRecommenderConfig(request), expectedError); + }); + }); + + describe('getInsightTypeConfig', () => { + it('invokes getInsightTypeConfig without error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.GetInsightTypeConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetInsightTypeConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.InsightTypeConfig() + ); + client.innerApiCalls.getInsightTypeConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getInsightTypeConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInsightTypeConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInsightTypeConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInsightTypeConfig without error using callback', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.GetInsightTypeConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetInsightTypeConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.InsightTypeConfig() + ); + client.innerApiCalls.getInsightTypeConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInsightTypeConfig( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IInsightTypeConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInsightTypeConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInsightTypeConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInsightTypeConfig with error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.GetInsightTypeConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetInsightTypeConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInsightTypeConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getInsightTypeConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.getInsightTypeConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInsightTypeConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInsightTypeConfig with closed client', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.GetInsightTypeConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetInsightTypeConfigRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getInsightTypeConfig(request), expectedError); + }); + }); + + describe('updateInsightTypeConfig', () => { + it('invokes updateInsightTypeConfig without error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.UpdateInsightTypeConfigRequest() + ); + request.insightTypeConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.UpdateInsightTypeConfigRequest', ['insightTypeConfig', 'name']); + request.insightTypeConfig.name = defaultValue1; + const expectedHeaderRequestParams = `insight_type_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.InsightTypeConfig() + ); + client.innerApiCalls.updateInsightTypeConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateInsightTypeConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInsightTypeConfig without error using callback', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.UpdateInsightTypeConfigRequest() + ); + request.insightTypeConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.UpdateInsightTypeConfigRequest', ['insightTypeConfig', 'name']); + request.insightTypeConfig.name = defaultValue1; + const expectedHeaderRequestParams = `insight_type_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.InsightTypeConfig() + ); + client.innerApiCalls.updateInsightTypeConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateInsightTypeConfig( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IInsightTypeConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInsightTypeConfig with error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.UpdateInsightTypeConfigRequest() + ); + request.insightTypeConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.UpdateInsightTypeConfigRequest', ['insightTypeConfig', 'name']); + request.insightTypeConfig.name = defaultValue1; + const expectedHeaderRequestParams = `insight_type_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInsightTypeConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateInsightTypeConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInsightTypeConfig with closed client', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.UpdateInsightTypeConfigRequest() + ); + request.insightTypeConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.UpdateInsightTypeConfigRequest', ['insightTypeConfig', 'name']); + request.insightTypeConfig.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateInsightTypeConfig(request), expectedError); + }); + }); + + describe('listInsights', () => { + it('invokes listInsights without error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.ListInsightsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListInsightsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), + ]; + client.innerApiCalls.listInsights = stubSimpleCall(expectedResponse); + const [response] = await client.listInsights(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInsights as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInsights as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInsights without error using callback', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.ListInsightsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListInsightsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), + ]; + client.innerApiCalls.listInsights = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInsights( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IInsight[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInsights as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInsights as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInsights with error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.ListInsightsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListInsightsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInsights = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listInsights(request), expectedError); + const actualRequest = (client.innerApiCalls.listInsights as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInsights as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInsightsStream without error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.ListInsightsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListInsightsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), + ]; + client.descriptors.page.listInsights.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listInsightsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recommender.v1beta1.Insight[] = []; + stream.on('data', (response: protos.google.cloud.recommender.v1beta1.Insight) => { + 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.listInsights.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInsights, request)); + assert( + (client.descriptors.page.listInsights.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listInsightsStream with error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.ListInsightsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListInsightsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInsights.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listInsightsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recommender.v1beta1.Insight[] = []; + stream.on('data', (response: protos.google.cloud.recommender.v1beta1.Insight) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listInsights.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInsights, request)); + assert( + (client.descriptors.page.listInsights.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInsights without error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.ListInsightsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListInsightsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), + ]; + client.descriptors.page.listInsights.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.recommender.v1beta1.IInsight[] = []; + const iterable = client.listInsightsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listInsights.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInsights.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInsights with error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.ListInsightsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListInsightsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInsights.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInsightsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.recommender.v1beta1.IInsight[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listInsights.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInsights.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listRecommendations', () => { + it('invokes listRecommendations without error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.ListRecommendationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListRecommendationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), + ]; + client.innerApiCalls.listRecommendations = stubSimpleCall(expectedResponse); + const [response] = await client.listRecommendations(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listRecommendations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRecommendations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRecommendations without error using callback', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.ListRecommendationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListRecommendationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), + ]; + client.innerApiCalls.listRecommendations = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listRecommendations( + request, + (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IRecommendation[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listRecommendations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRecommendations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRecommendations with error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.ListRecommendationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListRecommendationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listRecommendations = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listRecommendations(request), expectedError); + const actualRequest = (client.innerApiCalls.listRecommendations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRecommendations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRecommendationsStream without error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.ListRecommendationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListRecommendationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), + ]; + client.descriptors.page.listRecommendations.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listRecommendationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recommender.v1beta1.Recommendation[] = []; + stream.on('data', (response: protos.google.cloud.recommender.v1beta1.Recommendation) => { + 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.listRecommendations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRecommendations, request)); + assert( + (client.descriptors.page.listRecommendations.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listRecommendationsStream with error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.ListRecommendationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListRecommendationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRecommendations.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listRecommendationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recommender.v1beta1.Recommendation[] = []; + stream.on('data', (response: protos.google.cloud.recommender.v1beta1.Recommendation) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listRecommendations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRecommendations, request)); + assert( + (client.descriptors.page.listRecommendations.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listRecommendations without error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.ListRecommendationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListRecommendationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), + generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), + ]; + client.descriptors.page.listRecommendations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.recommender.v1beta1.IRecommendation[] = []; + const iterable = client.listRecommendationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listRecommendations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listRecommendations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listRecommendations with error', async () => { + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recommender.v1beta1.ListRecommendationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListRecommendationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRecommendations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listRecommendationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.recommender.v1beta1.IRecommendation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listRecommendations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listRecommendations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('billingAccountLocationInsightType', () => { + const fakePath = "/rendered/path/billingAccountLocationInsightType"; + const expectedParameters = { + billing_account: "billingAccountValue", + location: "locationValue", + insight_type: "insightTypeValue", + }; + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.billingAccountLocationInsightTypePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.billingAccountLocationInsightTypePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('billingAccountLocationInsightTypePath', () => { + const result = client.billingAccountLocationInsightTypePath("billingAccountValue", "locationValue", "insightTypeValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.billingAccountLocationInsightTypePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchBillingAccountFromBillingAccountLocationInsightTypeName', () => { + const result = client.matchBillingAccountFromBillingAccountLocationInsightTypeName(fakePath); + assert.strictEqual(result, "billingAccountValue"); + assert((client.pathTemplates.billingAccountLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBillingAccountLocationInsightTypeName', () => { + const result = client.matchLocationFromBillingAccountLocationInsightTypeName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.billingAccountLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightTypeFromBillingAccountLocationInsightTypeName', () => { + const result = client.matchInsightTypeFromBillingAccountLocationInsightTypeName(fakePath); + assert.strictEqual(result, "insightTypeValue"); + assert((client.pathTemplates.billingAccountLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('billingAccountLocationInsightTypeInsight', () => { + const fakePath = "/rendered/path/billingAccountLocationInsightTypeInsight"; + const expectedParameters = { + billing_account: "billingAccountValue", + location: "locationValue", + insight_type: "insightTypeValue", + insight: "insightValue", + }; + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('billingAccountLocationInsightTypeInsightPath', () => { + const result = client.billingAccountLocationInsightTypeInsightPath("billingAccountValue", "locationValue", "insightTypeValue", "insightValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchBillingAccountFromBillingAccountLocationInsightTypeInsightName', () => { + const result = client.matchBillingAccountFromBillingAccountLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "billingAccountValue"); + assert((client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBillingAccountLocationInsightTypeInsightName', () => { + const result = client.matchLocationFromBillingAccountLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightTypeFromBillingAccountLocationInsightTypeInsightName', () => { + const result = client.matchInsightTypeFromBillingAccountLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "insightTypeValue"); + assert((client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightFromBillingAccountLocationInsightTypeInsightName', () => { + const result = client.matchInsightFromBillingAccountLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "insightValue"); + assert((client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('billingAccountLocationRecommender', () => { + const fakePath = "/rendered/path/billingAccountLocationRecommender"; + const expectedParameters = { + billing_account: "billingAccountValue", + location: "locationValue", + recommender: "recommenderValue", + }; + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.billingAccountLocationRecommenderPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.billingAccountLocationRecommenderPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('billingAccountLocationRecommenderPath', () => { + const result = client.billingAccountLocationRecommenderPath("billingAccountValue", "locationValue", "recommenderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.billingAccountLocationRecommenderPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchBillingAccountFromBillingAccountLocationRecommenderName', () => { + const result = client.matchBillingAccountFromBillingAccountLocationRecommenderName(fakePath); + assert.strictEqual(result, "billingAccountValue"); + assert((client.pathTemplates.billingAccountLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBillingAccountLocationRecommenderName', () => { + const result = client.matchLocationFromBillingAccountLocationRecommenderName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.billingAccountLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommenderFromBillingAccountLocationRecommenderName', () => { + const result = client.matchRecommenderFromBillingAccountLocationRecommenderName(fakePath); + assert.strictEqual(result, "recommenderValue"); + assert((client.pathTemplates.billingAccountLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('billingAccountLocationRecommenderRecommendation', () => { + const fakePath = "/rendered/path/billingAccountLocationRecommenderRecommendation"; + const expectedParameters = { + billing_account: "billingAccountValue", + location: "locationValue", + recommender: "recommenderValue", + recommendation: "recommendationValue", + }; + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('billingAccountLocationRecommenderRecommendationPath', () => { + const result = client.billingAccountLocationRecommenderRecommendationPath("billingAccountValue", "locationValue", "recommenderValue", "recommendationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchBillingAccountFromBillingAccountLocationRecommenderRecommendationName', () => { + const result = client.matchBillingAccountFromBillingAccountLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "billingAccountValue"); + assert((client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBillingAccountLocationRecommenderRecommendationName', () => { + const result = client.matchLocationFromBillingAccountLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommenderFromBillingAccountLocationRecommenderRecommendationName', () => { + const result = client.matchRecommenderFromBillingAccountLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "recommenderValue"); + assert((client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommendationFromBillingAccountLocationRecommenderRecommendationName', () => { + const result = client.matchRecommendationFromBillingAccountLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "recommendationValue"); + assert((client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('folderLocationInsightType', () => { + const fakePath = "/rendered/path/folderLocationInsightType"; + const expectedParameters = { + folder: "folderValue", + location: "locationValue", + insight_type: "insightTypeValue", + }; + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderLocationInsightTypePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderLocationInsightTypePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderLocationInsightTypePath', () => { + const result = client.folderLocationInsightTypePath("folderValue", "locationValue", "insightTypeValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderLocationInsightTypePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderLocationInsightTypeName', () => { + const result = client.matchFolderFromFolderLocationInsightTypeName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromFolderLocationInsightTypeName', () => { + const result = client.matchLocationFromFolderLocationInsightTypeName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.folderLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightTypeFromFolderLocationInsightTypeName', () => { + const result = client.matchInsightTypeFromFolderLocationInsightTypeName(fakePath); + assert.strictEqual(result, "insightTypeValue"); + assert((client.pathTemplates.folderLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('folderLocationInsightTypeInsight', () => { + const fakePath = "/rendered/path/folderLocationInsightTypeInsight"; + const expectedParameters = { + folder: "folderValue", + location: "locationValue", + insight_type: "insightTypeValue", + insight: "insightValue", + }; + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderLocationInsightTypeInsightPath', () => { + const result = client.folderLocationInsightTypeInsightPath("folderValue", "locationValue", "insightTypeValue", "insightValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderLocationInsightTypeInsightName', () => { + const result = client.matchFolderFromFolderLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromFolderLocationInsightTypeInsightName', () => { + const result = client.matchLocationFromFolderLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightTypeFromFolderLocationInsightTypeInsightName', () => { + const result = client.matchInsightTypeFromFolderLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "insightTypeValue"); + assert((client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightFromFolderLocationInsightTypeInsightName', () => { + const result = client.matchInsightFromFolderLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "insightValue"); + assert((client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('folderLocationRecommender', () => { + const fakePath = "/rendered/path/folderLocationRecommender"; + const expectedParameters = { + folder: "folderValue", + location: "locationValue", + recommender: "recommenderValue", + }; + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderLocationRecommenderPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderLocationRecommenderPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderLocationRecommenderPath', () => { + const result = client.folderLocationRecommenderPath("folderValue", "locationValue", "recommenderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderLocationRecommenderPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderLocationRecommenderName', () => { + const result = client.matchFolderFromFolderLocationRecommenderName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromFolderLocationRecommenderName', () => { + const result = client.matchLocationFromFolderLocationRecommenderName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.folderLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommenderFromFolderLocationRecommenderName', () => { + const result = client.matchRecommenderFromFolderLocationRecommenderName(fakePath); + assert.strictEqual(result, "recommenderValue"); + assert((client.pathTemplates.folderLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('folderLocationRecommenderRecommendation', () => { + const fakePath = "/rendered/path/folderLocationRecommenderRecommendation"; + const expectedParameters = { + folder: "folderValue", + location: "locationValue", + recommender: "recommenderValue", + recommendation: "recommendationValue", + }; + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderLocationRecommenderRecommendationPath', () => { + const result = client.folderLocationRecommenderRecommendationPath("folderValue", "locationValue", "recommenderValue", "recommendationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderLocationRecommenderRecommendationName', () => { + const result = client.matchFolderFromFolderLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromFolderLocationRecommenderRecommendationName', () => { + const result = client.matchLocationFromFolderLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommenderFromFolderLocationRecommenderRecommendationName', () => { + const result = client.matchRecommenderFromFolderLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "recommenderValue"); + assert((client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommendationFromFolderLocationRecommenderRecommendationName', () => { + const result = client.matchRecommendationFromFolderLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "recommendationValue"); + assert((client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organizationLocationInsightType', () => { + const fakePath = "/rendered/path/organizationLocationInsightType"; + const expectedParameters = { + organization: "organizationValue", + location: "locationValue", + insight_type: "insightTypeValue", + }; + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationLocationInsightTypePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationLocationInsightTypePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationLocationInsightTypePath', () => { + const result = client.organizationLocationInsightTypePath("organizationValue", "locationValue", "insightTypeValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationLocationInsightTypePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationLocationInsightTypeName', () => { + const result = client.matchOrganizationFromOrganizationLocationInsightTypeName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromOrganizationLocationInsightTypeName', () => { + const result = client.matchLocationFromOrganizationLocationInsightTypeName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.organizationLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightTypeFromOrganizationLocationInsightTypeName', () => { + const result = client.matchInsightTypeFromOrganizationLocationInsightTypeName(fakePath); + assert.strictEqual(result, "insightTypeValue"); + assert((client.pathTemplates.organizationLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organizationLocationInsightTypeConfig', () => { + const fakePath = "/rendered/path/organizationLocationInsightTypeConfig"; + const expectedParameters = { + organization: "organizationValue", + location: "locationValue", + insight_type: "insightTypeValue", + }; + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationLocationInsightTypeConfigPath', () => { + const result = client.organizationLocationInsightTypeConfigPath("organizationValue", "locationValue", "insightTypeValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationLocationInsightTypeConfigName', () => { + const result = client.matchOrganizationFromOrganizationLocationInsightTypeConfigName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromOrganizationLocationInsightTypeConfigName', () => { + const result = client.matchLocationFromOrganizationLocationInsightTypeConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightTypeFromOrganizationLocationInsightTypeConfigName', () => { + const result = client.matchInsightTypeFromOrganizationLocationInsightTypeConfigName(fakePath); + assert.strictEqual(result, "insightTypeValue"); + assert((client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organizationLocationInsightTypeInsight', () => { + const fakePath = "/rendered/path/organizationLocationInsightTypeInsight"; + const expectedParameters = { + organization: "organizationValue", + location: "locationValue", + insight_type: "insightTypeValue", + insight: "insightValue", + }; + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationLocationInsightTypeInsightPath', () => { + const result = client.organizationLocationInsightTypeInsightPath("organizationValue", "locationValue", "insightTypeValue", "insightValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationLocationInsightTypeInsightName', () => { + const result = client.matchOrganizationFromOrganizationLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromOrganizationLocationInsightTypeInsightName', () => { + const result = client.matchLocationFromOrganizationLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightTypeFromOrganizationLocationInsightTypeInsightName', () => { + const result = client.matchInsightTypeFromOrganizationLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "insightTypeValue"); + assert((client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightFromOrganizationLocationInsightTypeInsightName', () => { + const result = client.matchInsightFromOrganizationLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "insightValue"); + assert((client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organizationLocationRecommender', () => { + const fakePath = "/rendered/path/organizationLocationRecommender"; + const expectedParameters = { + organization: "organizationValue", + location: "locationValue", + recommender: "recommenderValue", + }; + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationLocationRecommenderPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationLocationRecommenderPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationLocationRecommenderPath', () => { + const result = client.organizationLocationRecommenderPath("organizationValue", "locationValue", "recommenderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationLocationRecommenderPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationLocationRecommenderName', () => { + const result = client.matchOrganizationFromOrganizationLocationRecommenderName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromOrganizationLocationRecommenderName', () => { + const result = client.matchLocationFromOrganizationLocationRecommenderName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.organizationLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommenderFromOrganizationLocationRecommenderName', () => { + const result = client.matchRecommenderFromOrganizationLocationRecommenderName(fakePath); + assert.strictEqual(result, "recommenderValue"); + assert((client.pathTemplates.organizationLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organizationLocationRecommenderConfig', () => { + const fakePath = "/rendered/path/organizationLocationRecommenderConfig"; + const expectedParameters = { + organization: "organizationValue", + location: "locationValue", + recommender: "recommenderValue", + }; + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationLocationRecommenderConfigPath', () => { + const result = client.organizationLocationRecommenderConfigPath("organizationValue", "locationValue", "recommenderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationLocationRecommenderConfigName', () => { + const result = client.matchOrganizationFromOrganizationLocationRecommenderConfigName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromOrganizationLocationRecommenderConfigName', () => { + const result = client.matchLocationFromOrganizationLocationRecommenderConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommenderFromOrganizationLocationRecommenderConfigName', () => { + const result = client.matchRecommenderFromOrganizationLocationRecommenderConfigName(fakePath); + assert.strictEqual(result, "recommenderValue"); + assert((client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organizationLocationRecommenderRecommendation', () => { + const fakePath = "/rendered/path/organizationLocationRecommenderRecommendation"; + const expectedParameters = { + organization: "organizationValue", + location: "locationValue", + recommender: "recommenderValue", + recommendation: "recommendationValue", + }; + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationLocationRecommenderRecommendationPath', () => { + const result = client.organizationLocationRecommenderRecommendationPath("organizationValue", "locationValue", "recommenderValue", "recommendationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationLocationRecommenderRecommendationName', () => { + const result = client.matchOrganizationFromOrganizationLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromOrganizationLocationRecommenderRecommendationName', () => { + const result = client.matchLocationFromOrganizationLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommenderFromOrganizationLocationRecommenderRecommendationName', () => { + const result = client.matchRecommenderFromOrganizationLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "recommenderValue"); + assert((client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommendationFromOrganizationLocationRecommenderRecommendationName', () => { + const result = client.matchRecommendationFromOrganizationLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "recommendationValue"); + assert((client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationInsightType', () => { + const fakePath = "/rendered/path/projectLocationInsightType"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + insight_type: "insightTypeValue", + }; + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationInsightTypePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationInsightTypePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationInsightTypePath', () => { + const result = client.projectLocationInsightTypePath("projectValue", "locationValue", "insightTypeValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationInsightTypePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationInsightTypeName', () => { + const result = client.matchProjectFromProjectLocationInsightTypeName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationInsightTypeName', () => { + const result = client.matchLocationFromProjectLocationInsightTypeName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightTypeFromProjectLocationInsightTypeName', () => { + const result = client.matchInsightTypeFromProjectLocationInsightTypeName(fakePath); + assert.strictEqual(result, "insightTypeValue"); + assert((client.pathTemplates.projectLocationInsightTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationInsightTypeConfig', () => { + const fakePath = "/rendered/path/projectLocationInsightTypeConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + insight_type: "insightTypeValue", + }; + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationInsightTypeConfigPath', () => { + const result = client.projectLocationInsightTypeConfigPath("projectValue", "locationValue", "insightTypeValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationInsightTypeConfigName', () => { + const result = client.matchProjectFromProjectLocationInsightTypeConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationInsightTypeConfigName', () => { + const result = client.matchLocationFromProjectLocationInsightTypeConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightTypeFromProjectLocationInsightTypeConfigName', () => { + const result = client.matchInsightTypeFromProjectLocationInsightTypeConfigName(fakePath); + assert.strictEqual(result, "insightTypeValue"); + assert((client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationInsightTypeInsight', () => { + const fakePath = "/rendered/path/projectLocationInsightTypeInsight"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + insight_type: "insightTypeValue", + insight: "insightValue", + }; + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationInsightTypeInsightPath', () => { + const result = client.projectLocationInsightTypeInsightPath("projectValue", "locationValue", "insightTypeValue", "insightValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationInsightTypeInsightName', () => { + const result = client.matchProjectFromProjectLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationInsightTypeInsightName', () => { + const result = client.matchLocationFromProjectLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightTypeFromProjectLocationInsightTypeInsightName', () => { + const result = client.matchInsightTypeFromProjectLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "insightTypeValue"); + assert((client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInsightFromProjectLocationInsightTypeInsightName', () => { + const result = client.matchInsightFromProjectLocationInsightTypeInsightName(fakePath); + assert.strictEqual(result, "insightValue"); + assert((client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationRecommender', () => { + const fakePath = "/rendered/path/projectLocationRecommender"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + recommender: "recommenderValue", + }; + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationRecommenderPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationRecommenderPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationRecommenderPath', () => { + const result = client.projectLocationRecommenderPath("projectValue", "locationValue", "recommenderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationRecommenderPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationRecommenderName', () => { + const result = client.matchProjectFromProjectLocationRecommenderName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationRecommenderName', () => { + const result = client.matchLocationFromProjectLocationRecommenderName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommenderFromProjectLocationRecommenderName', () => { + const result = client.matchRecommenderFromProjectLocationRecommenderName(fakePath); + assert.strictEqual(result, "recommenderValue"); + assert((client.pathTemplates.projectLocationRecommenderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationRecommenderConfig', () => { + const fakePath = "/rendered/path/projectLocationRecommenderConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + recommender: "recommenderValue", + }; + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationRecommenderConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationRecommenderConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationRecommenderConfigPath', () => { + const result = client.projectLocationRecommenderConfigPath("projectValue", "locationValue", "recommenderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationRecommenderConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationRecommenderConfigName', () => { + const result = client.matchProjectFromProjectLocationRecommenderConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationRecommenderConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationRecommenderConfigName', () => { + const result = client.matchLocationFromProjectLocationRecommenderConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationRecommenderConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommenderFromProjectLocationRecommenderConfigName', () => { + const result = client.matchRecommenderFromProjectLocationRecommenderConfigName(fakePath); + assert.strictEqual(result, "recommenderValue"); + assert((client.pathTemplates.projectLocationRecommenderConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationRecommenderRecommendation', () => { + const fakePath = "/rendered/path/projectLocationRecommenderRecommendation"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + recommender: "recommenderValue", + recommendation: "recommendationValue", + }; + const client = new recommenderModule.v1beta1.RecommenderClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationRecommenderRecommendationPath', () => { + const result = client.projectLocationRecommenderRecommendationPath("projectValue", "locationValue", "recommenderValue", "recommendationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationRecommenderRecommendationName', () => { + const result = client.matchProjectFromProjectLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationRecommenderRecommendationName', () => { + const result = client.matchLocationFromProjectLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommenderFromProjectLocationRecommenderRecommendationName', () => { + const result = client.matchRecommenderFromProjectLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "recommenderValue"); + assert((client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRecommendationFromProjectLocationRecommenderRecommendationName', () => { + const result = client.matchRecommendationFromProjectLocationRecommenderRecommendationName(fakePath); + assert.strictEqual(result, "recommendationValue"); + assert((client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-recommender/v1beta1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-recommender/v1beta1/webpack.config.js new file mode 100644 index 00000000000..a74f57c48a0 --- /dev/null +++ b/owl-bot-staging/google-cloud-recommender/v1beta1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'Recommender', + filename: './recommender.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-redis/v1/.eslintignore b/owl-bot-staging/google-cloud-redis/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-redis/v1/.eslintrc.json b/owl-bot-staging/google-cloud-redis/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-redis/v1/.gitignore b/owl-bot-staging/google-cloud-redis/v1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-redis/v1/.jsdoc.js b/owl-bot-staging/google-cloud-redis/v1/.jsdoc.js new file mode 100644 index 00000000000..58332656788 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/.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/redis', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-redis/v1/.mocharc.js b/owl-bot-staging/google-cloud-redis/v1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/.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-redis/v1/.prettierrc.js b/owl-bot-staging/google-cloud-redis/v1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/.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-redis/v1/README.md b/owl-bot-staging/google-cloud-redis/v1/README.md new file mode 100644 index 00000000000..3c11909fadc --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/README.md @@ -0,0 +1 @@ +Redis: Nodejs Client diff --git a/owl-bot-staging/google-cloud-redis/v1/package.json b/owl-bot-staging/google-cloud-redis/v1/package.json new file mode 100644 index 00000000000..0a5bbcc4645 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/redis", + "version": "0.1.0", + "description": "Redis client for Node.js", + "repository": "googleapis/nodejs-redis", + "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 redis", + "redis", + "cloud redis" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-redis/v1/protos/google/cloud/redis/v1/cloud_redis.proto b/owl-bot-staging/google-cloud-redis/v1/protos/google/cloud/redis/v1/cloud_redis.proto new file mode 100644 index 00000000000..5ff9e9c8b4d --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/protos/google/cloud/redis/v1/cloud_redis.proto @@ -0,0 +1,1000 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.redis.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/dayofweek.proto"; +import "google/type/timeofday.proto"; + +option go_package = "cloud.google.com/go/redis/apiv1/redispb;redispb"; +option java_multiple_files = true; +option java_outer_classname = "CloudRedisServiceV1Proto"; +option java_package = "com.google.cloud.redis.v1"; + +// Configures and manages Cloud Memorystore for Redis instances +// +// Google Cloud Memorystore for Redis v1 +// +// The `redis.googleapis.com` service implements the Google Cloud Memorystore +// for Redis API and defines the following resource model for managing Redis +// instances: +// * The service works with a collection of cloud projects, named: `/projects/*` +// * Each project has a collection of available locations, named: `/locations/*` +// * Each location has a collection of Redis instances, named: `/instances/*` +// * As such, Redis instances are resources of the form: +// `/projects/{project_id}/locations/{location_id}/instances/{instance_id}` +// +// Note that location_id must be referring to a GCP `region`; for example: +// * `projects/redpepper-1290/locations/us-central1/instances/my-redis` +service CloudRedis { + option (google.api.default_host) = "redis.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Lists all Redis instances owned by a project in either the specified + // location (region) or all locations. + // + // The location should have the following format: + // + // * `projects/{project_id}/locations/{location_id}` + // + // If `location_id` is specified as `-` (wildcard), then all regions + // available to the project are queried, and the results are aggregated. + rpc ListInstances(ListInstancesRequest) returns (ListInstancesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/instances" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets the details of a specific Redis instance. + rpc GetInstance(GetInstanceRequest) returns (Instance) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/instances/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets the AUTH string for a Redis instance. If AUTH is not enabled for the + // instance the response will be empty. This information is not included in + // the details returned to GetInstance. + rpc GetInstanceAuthString(GetInstanceAuthStringRequest) + returns (InstanceAuthString) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/instances/*}/authString" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a Redis instance based on the specified tier and memory size. + // + // By default, the instance is accessible from the project's + // [default network](https://cloud.google.com/vpc/docs/vpc). + // + // The creation is executed asynchronously and callers may check the returned + // operation to track its progress. Once the operation is completed the Redis + // instance will be fully functional. Completed longrunning.Operation will + // contain the new instance object in the response field. + // + // The returned operation is automatically deleted after a few hours, so there + // is no need to call DeleteOperation. + rpc CreateInstance(CreateInstanceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/instances" + body: "instance" + }; + option (google.api.method_signature) = "parent,instance_id,instance"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.redis.v1.Instance" + metadata_type: "google.cloud.redis.v1.OperationMetadata" + }; + } + + // Updates the metadata and configuration of a specific Redis instance. + // + // Completed longrunning.Operation will contain the new instance object + // in the response field. The returned operation is automatically deleted + // after a few hours, so there is no need to call DeleteOperation. + rpc UpdateInstance(UpdateInstanceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{instance.name=projects/*/locations/*/instances/*}" + body: "instance" + }; + option (google.api.method_signature) = "update_mask,instance"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.redis.v1.Instance" + metadata_type: "google.cloud.redis.v1.OperationMetadata" + }; + } + + // Upgrades Redis instance to the newer Redis version specified in the + // request. + rpc UpgradeInstance(UpgradeInstanceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/instances/*}:upgrade" + body: "*" + }; + option (google.api.method_signature) = "name,redis_version"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.redis.v1.Instance" + metadata_type: "google.cloud.redis.v1.OperationMetadata" + }; + } + + // Import a Redis RDB snapshot file from Cloud Storage into a Redis instance. + // + // Redis may stop serving during this operation. Instance state will be + // IMPORTING for entire operation. When complete, the instance will contain + // only data from the imported file. + // + // The returned operation is automatically deleted after a few hours, so + // there is no need to call DeleteOperation. + rpc ImportInstance(ImportInstanceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/instances/*}:import" + body: "*" + }; + option (google.api.method_signature) = "name,input_config"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.redis.v1.Instance" + metadata_type: "google.cloud.redis.v1.OperationMetadata" + }; + } + + // Export Redis instance data into a Redis RDB format file in Cloud Storage. + // + // Redis will continue serving during this operation. + // + // The returned operation is automatically deleted after a few hours, so + // there is no need to call DeleteOperation. + rpc ExportInstance(ExportInstanceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/instances/*}:export" + body: "*" + }; + option (google.api.method_signature) = "name,output_config"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.redis.v1.Instance" + metadata_type: "google.cloud.redis.v1.OperationMetadata" + }; + } + + // Initiates a failover of the primary node to current replica node for a + // specific STANDARD tier Cloud Memorystore for Redis instance. + rpc FailoverInstance(FailoverInstanceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/instances/*}:failover" + body: "*" + }; + option (google.api.method_signature) = "name,data_protection_mode"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.redis.v1.Instance" + metadata_type: "google.cloud.redis.v1.OperationMetadata" + }; + } + + // Deletes a specific Redis instance. Instance stops serving and data is + // deleted. + rpc DeleteInstance(DeleteInstanceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/instances/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "google.cloud.redis.v1.OperationMetadata" + }; + } + + // Reschedule maintenance for a given instance in a given project and + // location. + rpc RescheduleMaintenance(RescheduleMaintenanceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/instances/*}:rescheduleMaintenance" + body: "*" + }; + option (google.api.method_signature) = + "name, reschedule_type, schedule_time"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.redis.v1.Instance" + metadata_type: "google.cloud.redis.v1.OperationMetadata" + }; + } +} + +// Node specific properties. +message NodeInfo { + // Output only. Node identifying string. e.g. 'node-0', 'node-1' + string id = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Location of the node. + string zone = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A Memorystore for Redis instance. +message Instance { + option (google.api.resource) = { + type: "redis.googleapis.com/Instance" + pattern: "projects/{project}/locations/{location}/instances/{instance}" + }; + + // Represents the different states of a Redis instance. + enum State { + // Not set. + STATE_UNSPECIFIED = 0; + + // Redis instance is being created. + CREATING = 1; + + // Redis instance has been created and is fully usable. + READY = 2; + + // Redis instance configuration is being updated. Certain kinds of updates + // may cause the instance to become unusable while the update is in + // progress. + UPDATING = 3; + + // Redis instance is being deleted. + DELETING = 4; + + // Redis instance is being repaired and may be unusable. + REPAIRING = 5; + + // Maintenance is being performed on this Redis instance. + MAINTENANCE = 6; + + // Redis instance is importing data (availability may be affected). + IMPORTING = 8; + + // Redis instance is failing over (availability may be affected). + FAILING_OVER = 9; + } + + // Available service tiers to choose from + enum Tier { + // Not set. + TIER_UNSPECIFIED = 0; + + // BASIC tier: standalone instance + BASIC = 1; + + // STANDARD_HA tier: highly available primary/replica instances + STANDARD_HA = 3; + } + + // Available connection modes. + enum ConnectMode { + // Not set. + CONNECT_MODE_UNSPECIFIED = 0; + + // Connect via direct peering to the Memorystore for Redis hosted service. + DIRECT_PEERING = 1; + + // Connect your Memorystore for Redis instance using Private Service + // Access. Private services access provides an IP address range for multiple + // Google Cloud services, including Memorystore. + PRIVATE_SERVICE_ACCESS = 2; + } + + // Available TLS modes. + enum TransitEncryptionMode { + // Not set. + TRANSIT_ENCRYPTION_MODE_UNSPECIFIED = 0; + + // Client to Server traffic encryption enabled with server authentication. + SERVER_AUTHENTICATION = 1; + + // TLS is disabled for the instance. + DISABLED = 2; + } + + // Read replicas mode. + enum ReadReplicasMode { + // If not set, Memorystore Redis backend will default to + // READ_REPLICAS_DISABLED. + READ_REPLICAS_MODE_UNSPECIFIED = 0; + + // If disabled, read endpoint will not be provided and the instance cannot + // scale up or down the number of replicas. + READ_REPLICAS_DISABLED = 1; + + // If enabled, read endpoint will be provided and the instance can scale + // up and down the number of replicas. Not valid for basic tier. + READ_REPLICAS_ENABLED = 2; + } + + // Possible reasons for the instance to be in a "SUSPENDED" state. + enum SuspensionReason { + // Not set. + SUSPENSION_REASON_UNSPECIFIED = 0; + + // Something wrong with the CMEK key provided by customer. + CUSTOMER_MANAGED_KEY_ISSUE = 1; + } + + // Required. Unique name of the resource in this scope including project and + // location using the form: + // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + // + // Note: Redis instances are managed and addressed at regional level so + // location_id here refers to a GCP region; however, users may choose which + // specific zone (or collection of zones for cross-zone instances) an instance + // should be provisioned in. Refer to + // [location_id][google.cloud.redis.v1.Instance.location_id] and + // [alternative_location_id][google.cloud.redis.v1.Instance.alternative_location_id] + // fields for more details. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // An arbitrary and optional user-provided name for the instance. + string display_name = 2; + + // Resource labels to represent user provided metadata + map labels = 3; + + // Optional. The zone where the instance will be provisioned. If not provided, + // the service will choose a zone from the specified region for the instance. + // For standard tier, additional nodes will be added across multiple zones for + // protection against zonal failures. If specified, at least one node will be + // provisioned in this zone. + string location_id = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If specified, at least one node will be provisioned in this zone + // in addition to the zone specified in location_id. Only applicable to + // standard tier. If provided, it must be a different zone from the one + // provided in [location_id]. Additional nodes beyond the first 2 will be + // placed in zones selected by the service. + string alternative_location_id = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The version of Redis software. + // If not provided, latest supported version will be used. Currently, the + // supported values are: + // + // * `REDIS_3_2` for Redis 3.2 compatibility + // * `REDIS_4_0` for Redis 4.0 compatibility (default) + // * `REDIS_5_0` for Redis 5.0 compatibility + // * `REDIS_6_X` for Redis 6.x compatibility + string redis_version = 7 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. For DIRECT_PEERING mode, the CIDR range of internal addresses + // that are reserved for this instance. Range must + // be unique and non-overlapping with existing subnets in an authorized + // network. For PRIVATE_SERVICE_ACCESS mode, the name of one allocated IP + // address ranges associated with this private service access connection. + // If not provided, the service will choose an unused /29 block, for + // example, 10.0.0.0/29 or 192.168.0.0/29. For READ_REPLICAS_ENABLED + // the default block size is /28. + string reserved_ip_range = 9 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Additional IP range for node placement. Required when enabling + // read replicas on an existing instance. For DIRECT_PEERING mode value must + // be a CIDR range of size /28, or "auto". For PRIVATE_SERVICE_ACCESS mode + // value must be the name of an allocated address range associated with the + // private service access connection, or "auto". + string secondary_ip_range = 30 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. Hostname or IP address of the exposed Redis endpoint used by + // clients to connect to the service. + string host = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The port number of the exposed Redis endpoint. + int32 port = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The current zone where the Redis primary node is located. In + // basic tier, this will always be the same as [location_id]. In + // standard tier, this can be the zone of any node in the instance. + string current_location_id = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time the instance was created. + google.protobuf.Timestamp create_time = 13 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The current state of this instance. + State state = 14 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Additional information about the current status of this + // instance, if available. + string status_message = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Redis configuration parameters, according to + // http://redis.io/topics/config. Currently, the only supported parameters + // are: + // + // Redis version 3.2 and newer: + // + // * maxmemory-policy + // * notify-keyspace-events + // + // Redis version 4.0 and newer: + // + // * activedefrag + // * lfu-decay-time + // * lfu-log-factor + // * maxmemory-gb + // + // Redis version 5.0 and newer: + // + // * stream-node-max-bytes + // * stream-node-max-entries + map redis_configs = 16 + [(google.api.field_behavior) = OPTIONAL]; + + // Required. The service tier of the instance. + Tier tier = 17 [(google.api.field_behavior) = REQUIRED]; + + // Required. Redis memory size in GiB. + int32 memory_size_gb = 18 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The full name of the Google Compute Engine + // [network](https://cloud.google.com/vpc/docs/vpc) to which the + // instance is connected. If left unspecified, the `default` network + // will be used. + string authorized_network = 20 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. Cloud IAM identity used by import / export operations to + // transfer data to/from Cloud Storage. Format is + // "serviceAccount:". The value may change over time + // for a given instance so should be checked before each import/export + // operation. + string persistence_iam_identity = 21 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. The network connect mode of the Redis instance. + // If not provided, the connect mode defaults to DIRECT_PEERING. + ConnectMode connect_mode = 22 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Indicates whether OSS Redis AUTH is enabled for the instance. If + // set to "true" AUTH is enabled on the instance. Default value is "false" + // meaning AUTH is disabled. + bool auth_enabled = 23 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. List of server CA certificates for the instance. + repeated TlsCertificate server_ca_certs = 25 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. The TLS mode of the Redis instance. + // If not provided, TLS is disabled for the instance. + TransitEncryptionMode transit_encryption_mode = 26 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maintenance policy for the instance. If not provided, + // maintenance events can be performed at any time. + MaintenancePolicy maintenance_policy = 27 + [(google.api.field_behavior) = OPTIONAL]; + + // Output only. Date and time of upcoming maintenance events which have been + // scheduled. + MaintenanceSchedule maintenance_schedule = 28 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. The number of replica nodes. The valid range for the Standard + // Tier with read replicas enabled is [1-5] and defaults to 2. If read + // replicas are not enabled for a Standard Tier instance, the only valid value + // is 1 and the default is 1. The valid value for basic tier is 0 and the + // default is also 0. + int32 replica_count = 31 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. Info per node. + repeated NodeInfo nodes = 32 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Hostname or IP address of the exposed readonly Redis + // endpoint. Standard tier only. Targets all healthy replica nodes in + // instance. Replication is asynchronous and replica nodes will exhibit some + // lag behind the primary. Write requests must target 'host'. + string read_endpoint = 33 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The port number of the exposed readonly redis + // endpoint. Standard tier only. Write requests should target 'port'. + int32 read_endpoint_port = 34 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Read replicas mode for the instance. Defaults to + // READ_REPLICAS_DISABLED. + ReadReplicasMode read_replicas_mode = 35 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The KMS key reference that the customer provides when trying to + // create the instance. + string customer_managed_key = 36 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Persistence configuration parameters + PersistenceConfig persistence_config = 37 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. reasons that causes instance in "SUSPENDED" state. + repeated SuspensionReason suspension_reasons = 38 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The self service update maintenance version. + // The version is date based such as "20210712_00_00". + string maintenance_version = 39 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The available maintenance versions that an instance could update + // to. + repeated string available_maintenance_versions = 40 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Configuration of the persistence functionality. +message PersistenceConfig { + // Available Persistence modes. + enum PersistenceMode { + // Not set. + PERSISTENCE_MODE_UNSPECIFIED = 0; + + // Persistence is disabled for the instance, + // and any existing snapshots are deleted. + DISABLED = 1; + + // RDB based Persistence is enabled. + RDB = 2; + } + + // Available snapshot periods for scheduling. + enum SnapshotPeriod { + // Not set. + SNAPSHOT_PERIOD_UNSPECIFIED = 0; + + // Snapshot every 1 hour. + ONE_HOUR = 3; + + // Snapshot every 6 hours. + SIX_HOURS = 4; + + // Snapshot every 12 hours. + TWELVE_HOURS = 5; + + // Snapshot every 24 hours. + TWENTY_FOUR_HOURS = 6; + } + + // Optional. Controls whether Persistence features are enabled. + // If not provided, the existing value will be used. + PersistenceMode persistence_mode = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Period between RDB snapshots. Snapshots will be attempted every + // period starting from the provided snapshot start time. For example, a start + // time of 01/01/2033 06:45 and SIX_HOURS snapshot period will do nothing + // until 01/01/2033, and then trigger snapshots every day at 06:45, 12:45, + // 18:45, and 00:45 the next day, and so on. If not provided, + // TWENTY_FOUR_HOURS will be used as default. + SnapshotPeriod rdb_snapshot_period = 2 + [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The next time that a snapshot attempt is scheduled to occur. + google.protobuf.Timestamp rdb_next_snapshot_time = 4 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Date and time that the first snapshot was/will be attempted, and + // to which future snapshots will be aligned. If not provided, the current + // time will be used. + google.protobuf.Timestamp rdb_snapshot_start_time = 5 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for +// [RescheduleMaintenance][google.cloud.redis.v1.CloudRedis.RescheduleMaintenance]. +message RescheduleMaintenanceRequest { + // Reschedule options. + enum RescheduleType { + // Not set. + RESCHEDULE_TYPE_UNSPECIFIED = 0; + + // If the user wants to schedule the maintenance to happen now. + IMMEDIATE = 1; + + // If the user wants to use the existing maintenance policy to find the + // next available window. + NEXT_AVAILABLE_WINDOW = 2; + + // If the user wants to reschedule the maintenance to a specific time. + SPECIFIC_TIME = 3; + } + + // Required. Redis instance resource name using the form: + // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + // where `location_id` refers to a GCP region. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "redis.googleapis.com/Instance" } + ]; + + // Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as + // well. + RescheduleType reschedule_type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Timestamp when the maintenance shall be rescheduled to if + // reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for + // example `2012-11-15T16:19:00.094Z`. + google.protobuf.Timestamp schedule_time = 3 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Maintenance policy for an instance. +message MaintenancePolicy { + // Output only. The time when the policy was created. + google.protobuf.Timestamp create_time = 1 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time when the policy was last updated. + google.protobuf.Timestamp update_time = 2 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Description of what this policy is for. Create/Update methods + // return INVALID_ARGUMENT if the length is greater than 512. + string description = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Maintenance window that is applied to resources covered by this + // policy. Minimum 1. For the current version, the maximum number of + // weekly_window is expected to be one. + repeated WeeklyMaintenanceWindow weekly_maintenance_window = 4 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Time window in which disruptive maintenance updates occur. Non-disruptive +// updates can occur inside or outside this window. +message WeeklyMaintenanceWindow { + // Required. The day of week that maintenance updates occur. + google.type.DayOfWeek day = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Start time of the window in UTC time. + google.type.TimeOfDay start_time = 2 [(google.api.field_behavior) = REQUIRED]; + + // Output only. Duration of the maintenance window. The current window is + // fixed at 1 hour. + google.protobuf.Duration duration = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Upcoming maintenance schedule. If no maintenance is scheduled, fields are not +// populated. +message MaintenanceSchedule { + // Output only. The start time of any upcoming scheduled maintenance for this + // instance. + google.protobuf.Timestamp start_time = 1 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The end time of any upcoming scheduled maintenance for this + // instance. + google.protobuf.Timestamp end_time = 2 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // If the scheduled maintenance can be rescheduled, default is true. + bool can_reschedule = 3 [deprecated = true]; + + // Output only. The deadline that the maintenance schedule start time can not + // go beyond, including reschedule. + google.protobuf.Timestamp schedule_deadline_time = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Request for [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances]. +message ListInstancesRequest { + // Required. The resource name of the instance location using the form: + // `projects/{project_id}/locations/{location_id}` + // where `location_id` refers to a GCP region. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. + // + // If not specified, a default value of 1000 will be used by the service. + // Regardless of the page_size value, the response may include a partial list + // and a caller should only rely on response's + // [`next_page_token`][google.cloud.redis.v1.ListInstancesResponse.next_page_token] + // to determine if there are more instances left to be queried. + int32 page_size = 2; + + // The `next_page_token` value returned from a previous + // [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances] request, if + // any. + string page_token = 3; +} + +// Response for [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances]. +message ListInstancesResponse { + // A list of Redis instances in the project in the specified location, + // or across all locations. + // + // If the `location_id` in the parent field of the request is "-", all regions + // available to the project are queried, and the results aggregated. + // If in such an aggregated query a location is unavailable, a placeholder + // Redis entry is included in the response with the `name` field set to a + // value of the form + // `projects/{project_id}/locations/{location_id}/instances/`- and the + // `status` field set to ERROR and `status_message` field set to "location not + // available for ListInstances". + repeated Instance instances = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; + + // Locations that could not be reached. + repeated string unreachable = 3; +} + +// Request for [GetInstance][google.cloud.redis.v1.CloudRedis.GetInstance]. +message GetInstanceRequest { + // Required. Redis instance resource name using the form: + // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + // where `location_id` refers to a GCP region. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "redis.googleapis.com/Instance" } + ]; +} + +// Request for +// [GetInstanceAuthString][google.cloud.redis.v1.CloudRedis.GetInstanceAuthString]. +message GetInstanceAuthStringRequest { + // Required. Redis instance resource name using the form: + // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + // where `location_id` refers to a GCP region. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "redis.googleapis.com/Instance" } + ]; +} + +// Instance AUTH string details. +message InstanceAuthString { + // AUTH string set on the instance. + string auth_string = 1; +} + +// Request for +// [CreateInstance][google.cloud.redis.v1.CloudRedis.CreateInstance]. +message CreateInstanceRequest { + // Required. The resource name of the instance location using the form: + // `projects/{project_id}/locations/{location_id}` + // where `location_id` refers to a GCP region. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The logical name of the Redis instance in the customer project + // with the following restrictions: + // + // * Must contain only lowercase letters, numbers, and hyphens. + // * Must start with a letter. + // * Must be between 1-40 characters. + // * Must end with a number or a letter. + // * Must be unique within the customer project / location + string instance_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. A Redis [Instance] resource + Instance instance = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for +// [UpdateInstance][google.cloud.redis.v1.CloudRedis.UpdateInstance]. +message UpdateInstanceRequest { + // Required. Mask of fields to update. At least one path must be supplied in + // this field. The elements of the repeated paths field may only include these + // fields from [Instance][google.cloud.redis.v1.Instance]: + // + // * `displayName` + // * `labels` + // * `memorySizeGb` + // * `redisConfig` + // * `replica_count` + google.protobuf.FieldMask update_mask = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Update description. + // Only fields specified in update_mask are updated. + Instance instance = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for +// [UpgradeInstance][google.cloud.redis.v1.CloudRedis.UpgradeInstance]. +message UpgradeInstanceRequest { + // Required. Redis instance resource name using the form: + // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + // where `location_id` refers to a GCP region. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "redis.googleapis.com/Instance" } + ]; + + // Required. Specifies the target version of Redis software to upgrade to. + string redis_version = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for +// [DeleteInstance][google.cloud.redis.v1.CloudRedis.DeleteInstance]. +message DeleteInstanceRequest { + // Required. Redis instance resource name using the form: + // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + // where `location_id` refers to a GCP region. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "redis.googleapis.com/Instance" } + ]; +} + +// The Cloud Storage location for the input content +message GcsSource { + // Required. Source data URI. (e.g. 'gs://my_bucket/my_object'). + string uri = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The input content +message InputConfig { + // Required. Specify source location of input data + oneof source { + // Google Cloud Storage location where input content is located. + GcsSource gcs_source = 1; + } +} + +// Request for [Import][google.cloud.redis.v1.CloudRedis.ImportInstance]. +message ImportInstanceRequest { + // Required. Redis instance resource name using the form: + // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + // where `location_id` refers to a GCP region. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Specify data to be imported. + InputConfig input_config = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// The Cloud Storage location for the output content +message GcsDestination { + // Required. Data destination URI (e.g. + // 'gs://my_bucket/my_object'). Existing files will be overwritten. + string uri = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The output content +message OutputConfig { + // Required. Specify destination location of output data + oneof destination { + // Google Cloud Storage destination for output content. + GcsDestination gcs_destination = 1; + } +} + +// Request for [Export][google.cloud.redis.v1.CloudRedis.ExportInstance]. +message ExportInstanceRequest { + // Required. Redis instance resource name using the form: + // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + // where `location_id` refers to a GCP region. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Specify data to be exported. + OutputConfig output_config = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for [Failover][google.cloud.redis.v1.CloudRedis.FailoverInstance]. +message FailoverInstanceRequest { + // Specifies different modes of operation in relation to the data retention. + enum DataProtectionMode { + // Defaults to LIMITED_DATA_LOSS if a data protection mode is not + // specified. + DATA_PROTECTION_MODE_UNSPECIFIED = 0; + + // Instance failover will be protected with data loss control. More + // specifically, the failover will only be performed if the current + // replication offset diff between primary and replica is under a certain + // threshold. + LIMITED_DATA_LOSS = 1; + + // Instance failover will be performed without data loss control. + FORCE_DATA_LOSS = 2; + } + + // Required. Redis instance resource name using the form: + // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + // where `location_id` refers to a GCP region. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "redis.googleapis.com/Instance" } + ]; + + // Optional. Available data protection modes that the user can choose. If it's + // unspecified, data protection mode will be LIMITED_DATA_LOSS by default. + DataProtectionMode data_protection_mode = 2 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Represents the v1 metadata of the long-running operation. +message OperationMetadata { + // Creation timestamp. + google.protobuf.Timestamp create_time = 1; + + // End timestamp. + google.protobuf.Timestamp end_time = 2; + + // Operation target. + string target = 3; + + // Operation verb. + string verb = 4; + + // Operation status details. + string status_detail = 5; + + // Specifies if cancellation was requested for the operation. + bool cancel_requested = 6; + + // API version. + string api_version = 7; +} + +// This location metadata represents additional configuration options for a +// given location where a Redis instance may be created. All fields are output +// only. It is returned as content of the +// `google.cloud.location.Location.metadata` field. +message LocationMetadata { + // Output only. The set of available zones in the location. The map is keyed + // by the lowercase ID of each zone, as defined by GCE. These keys can be + // specified in `location_id` or `alternative_location_id` fields when + // creating a Redis instance. + map available_zones = 1 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Defines specific information for a particular zone. Currently empty and +// reserved for future use only. +message ZoneMetadata {} + +// TlsCertificate Resource +message TlsCertificate { + // Serial number, as extracted from the certificate. + string serial_number = 1; + + // PEM representation. + string cert = 2; + + // Output only. The time when the certificate was created in [RFC + // 3339](https://tools.ietf.org/html/rfc3339) format, for example + // `2020-05-18T00:00:00.094Z`. + google.protobuf.Timestamp create_time = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time when the certificate expires in [RFC + // 3339](https://tools.ietf.org/html/rfc3339) format, for example + // `2020-05-18T00:00:00.094Z`. + google.protobuf.Timestamp expire_time = 4 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Sha1 Fingerprint of the certificate. + string sha1_fingerprint = 5; +} diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.create_instance.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.create_instance.js new file mode 100644 index 00000000000..44ec7a006d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.create_instance.js @@ -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. ** + + + +'use strict'; + +function main(parent, instanceId, instance) { + // [START redis_v1_generated_CloudRedis_CreateInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 instance location using the form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a GCP region. + */ + // const parent = 'abc123' + /** + * Required. The logical name of the Redis instance in the customer project + * with the following restrictions: + * * Must contain only lowercase letters, numbers, and hyphens. + * * Must start with a letter. + * * Must be between 1-40 characters. + * * Must end with a number or a letter. + * * Must be unique within the customer project / location + */ + // const instanceId = 'abc123' + /** + * Required. A Redis Instance resource + */ + // const instance = {} + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callCreateInstance() { + // Construct request + const request = { + parent, + instanceId, + instance, + }; + + // Run request + const [operation] = await redisClient.createInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateInstance(); + // [END redis_v1_generated_CloudRedis_CreateInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.delete_instance.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.delete_instance.js new file mode 100644 index 00000000000..bf8aa68a10f --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.delete_instance.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 redis_v1_generated_CloudRedis_DeleteInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + */ + // const name = 'abc123' + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callDeleteInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await redisClient.deleteInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteInstance(); + // [END redis_v1_generated_CloudRedis_DeleteInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.export_instance.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.export_instance.js new file mode 100644 index 00000000000..e016826720e --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.export_instance.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(name, outputConfig) { + // [START redis_v1_generated_CloudRedis_ExportInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + */ + // const name = 'abc123' + /** + * Required. Specify data to be exported. + */ + // const outputConfig = {} + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callExportInstance() { + // Construct request + const request = { + name, + outputConfig, + }; + + // Run request + const [operation] = await redisClient.exportInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callExportInstance(); + // [END redis_v1_generated_CloudRedis_ExportInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.failover_instance.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.failover_instance.js new file mode 100644 index 00000000000..c045c6abb8c --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.failover_instance.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(name) { + // [START redis_v1_generated_CloudRedis_FailoverInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + */ + // const name = 'abc123' + /** + * Optional. Available data protection modes that the user can choose. If it's + * unspecified, data protection mode will be LIMITED_DATA_LOSS by default. + */ + // const dataProtectionMode = {} + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callFailoverInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await redisClient.failoverInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callFailoverInstance(); + // [END redis_v1_generated_CloudRedis_FailoverInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.get_instance.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.get_instance.js new file mode 100644 index 00000000000..4d1b5de8b86 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.get_instance.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 redis_v1_generated_CloudRedis_GetInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + */ + // const name = 'abc123' + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callGetInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await redisClient.getInstance(request); + console.log(response); + } + + callGetInstance(); + // [END redis_v1_generated_CloudRedis_GetInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.get_instance_auth_string.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.get_instance_auth_string.js new file mode 100644 index 00000000000..351348a5564 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.get_instance_auth_string.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 redis_v1_generated_CloudRedis_GetInstanceAuthString_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + */ + // const name = 'abc123' + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callGetInstanceAuthString() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await redisClient.getInstanceAuthString(request); + console.log(response); + } + + callGetInstanceAuthString(); + // [END redis_v1_generated_CloudRedis_GetInstanceAuthString_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.import_instance.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.import_instance.js new file mode 100644 index 00000000000..af82752a890 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.import_instance.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(name, inputConfig) { + // [START redis_v1_generated_CloudRedis_ImportInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + */ + // const name = 'abc123' + /** + * Required. Specify data to be imported. + */ + // const inputConfig = {} + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callImportInstance() { + // Construct request + const request = { + name, + inputConfig, + }; + + // Run request + const [operation] = await redisClient.importInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportInstance(); + // [END redis_v1_generated_CloudRedis_ImportInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.list_instances.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.list_instances.js new file mode 100644 index 00000000000..03d418c4679 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.list_instances.js @@ -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. ** + + + +'use strict'; + +function main(parent) { + // [START redis_v1_generated_CloudRedis_ListInstances_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 instance location using the form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a GCP region. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. + * If not specified, a default value of 1000 will be used by the service. + * Regardless of the page_size value, the response may include a partial list + * and a caller should only rely on response's + * `next_page_token` google.cloud.redis.v1.ListInstancesResponse.next_page_token + * to determine if there are more instances left to be queried. + */ + // const pageSize = 1234 + /** + * The `next_page_token` value returned from a previous + * ListInstances google.cloud.redis.v1.CloudRedis.ListInstances request, if + * any. + */ + // const pageToken = 'abc123' + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callListInstances() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await redisClient.listInstancesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListInstances(); + // [END redis_v1_generated_CloudRedis_ListInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.reschedule_maintenance.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.reschedule_maintenance.js new file mode 100644 index 00000000000..99f271bcea7 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.reschedule_maintenance.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(name, rescheduleType) { + // [START redis_v1_generated_CloudRedis_RescheduleMaintenance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + */ + // const name = 'abc123' + /** + * Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as + * well. + */ + // const rescheduleType = {} + /** + * Optional. Timestamp when the maintenance shall be rescheduled to if + * reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for + * example `2012-11-15T16:19:00.094Z`. + */ + // const scheduleTime = {} + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callRescheduleMaintenance() { + // Construct request + const request = { + name, + rescheduleType, + }; + + // Run request + const [operation] = await redisClient.rescheduleMaintenance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRescheduleMaintenance(); + // [END redis_v1_generated_CloudRedis_RescheduleMaintenance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.update_instance.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.update_instance.js new file mode 100644 index 00000000000..ecff8e6f8e8 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.update_instance.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(updateMask, instance) { + // [START redis_v1_generated_CloudRedis_UpdateInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Mask of fields to update. At least one path must be supplied in + * this field. The elements of the repeated paths field may only include these + * fields from Instance google.cloud.redis.v1.Instance: + * * `displayName` + * * `labels` + * * `memorySizeGb` + * * `redisConfig` + * * `replica_count` + */ + // const updateMask = {} + /** + * Required. Update description. + * Only fields specified in update_mask are updated. + */ + // const instance = {} + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callUpdateInstance() { + // Construct request + const request = { + updateMask, + instance, + }; + + // Run request + const [operation] = await redisClient.updateInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateInstance(); + // [END redis_v1_generated_CloudRedis_UpdateInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.upgrade_instance.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.upgrade_instance.js new file mode 100644 index 00000000000..7d695208636 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.upgrade_instance.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(name, redisVersion) { + // [START redis_v1_generated_CloudRedis_UpgradeInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + */ + // const name = 'abc123' + /** + * Required. Specifies the target version of Redis software to upgrade to. + */ + // const redisVersion = 'abc123' + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callUpgradeInstance() { + // Construct request + const request = { + name, + redisVersion, + }; + + // Run request + const [operation] = await redisClient.upgradeInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpgradeInstance(); + // [END redis_v1_generated_CloudRedis_UpgradeInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/snippet_metadata_google.cloud.redis.v1.json b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/snippet_metadata_google.cloud.redis.v1.json new file mode 100644 index 00000000000..0f896b00319 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/snippet_metadata_google.cloud.redis.v1.json @@ -0,0 +1,499 @@ +{ + "clientLibrary": { + "name": "nodejs-redis", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.redis.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "redis_v1_generated_CloudRedis_ListInstances_async", + "title": "CloudRedis listInstances Sample", + "origin": "API_DEFINITION", + "description": " Lists all Redis instances owned by a project in either the specified location (region) or all locations. The location should have the following format: * `projects/{project_id}/locations/{location_id}` If `location_id` is specified as `-` (wildcard), then all regions available to the project are queried, and the results are aggregated.", + "canonical": true, + "file": "cloud_redis.list_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListInstances", + "fullName": "google.cloud.redis.v1.CloudRedis.ListInstances", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.redis.v1.ListInstancesResponse", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1.CloudRedisClient" + }, + "method": { + "shortName": "ListInstances", + "fullName": "google.cloud.redis.v1.CloudRedis.ListInstances", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1.CloudRedis" + } + } + } + }, + { + "regionTag": "redis_v1_generated_CloudRedis_GetInstance_async", + "title": "CloudRedis getInstance Sample", + "origin": "API_DEFINITION", + "description": " Gets the details of a specific Redis instance.", + "canonical": true, + "file": "cloud_redis.get_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetInstance", + "fullName": "google.cloud.redis.v1.CloudRedis.GetInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.redis.v1.Instance", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1.CloudRedisClient" + }, + "method": { + "shortName": "GetInstance", + "fullName": "google.cloud.redis.v1.CloudRedis.GetInstance", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1.CloudRedis" + } + } + } + }, + { + "regionTag": "redis_v1_generated_CloudRedis_GetInstanceAuthString_async", + "title": "CloudRedis getInstanceAuthString Sample", + "origin": "API_DEFINITION", + "description": " Gets the AUTH string for a Redis instance. If AUTH is not enabled for the instance the response will be empty. This information is not included in the details returned to GetInstance.", + "canonical": true, + "file": "cloud_redis.get_instance_auth_string.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetInstanceAuthString", + "fullName": "google.cloud.redis.v1.CloudRedis.GetInstanceAuthString", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.redis.v1.InstanceAuthString", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1.CloudRedisClient" + }, + "method": { + "shortName": "GetInstanceAuthString", + "fullName": "google.cloud.redis.v1.CloudRedis.GetInstanceAuthString", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1.CloudRedis" + } + } + } + }, + { + "regionTag": "redis_v1_generated_CloudRedis_CreateInstance_async", + "title": "CloudRedis createInstance Sample", + "origin": "API_DEFINITION", + "description": " Creates a Redis instance based on the specified tier and memory size. By default, the instance is accessible from the project's [default network](https://cloud.google.com/vpc/docs/vpc). The creation is executed asynchronously and callers may check the returned operation to track its progress. Once the operation is completed the Redis instance will be fully functional. Completed longrunning.Operation will contain the new instance object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.", + "canonical": true, + "file": "cloud_redis.create_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateInstance", + "fullName": "google.cloud.redis.v1.CloudRedis.CreateInstance", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "instance_id", + "type": "TYPE_STRING" + }, + { + "name": "instance", + "type": ".google.cloud.redis.v1.Instance" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1.CloudRedisClient" + }, + "method": { + "shortName": "CreateInstance", + "fullName": "google.cloud.redis.v1.CloudRedis.CreateInstance", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1.CloudRedis" + } + } + } + }, + { + "regionTag": "redis_v1_generated_CloudRedis_UpdateInstance_async", + "title": "CloudRedis updateInstance Sample", + "origin": "API_DEFINITION", + "description": " Updates the metadata and configuration of a specific Redis instance. Completed longrunning.Operation will contain the new instance object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.", + "canonical": true, + "file": "cloud_redis.update_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateInstance", + "fullName": "google.cloud.redis.v1.CloudRedis.UpdateInstance", + "async": true, + "parameters": [ + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "instance", + "type": ".google.cloud.redis.v1.Instance" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1.CloudRedisClient" + }, + "method": { + "shortName": "UpdateInstance", + "fullName": "google.cloud.redis.v1.CloudRedis.UpdateInstance", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1.CloudRedis" + } + } + } + }, + { + "regionTag": "redis_v1_generated_CloudRedis_UpgradeInstance_async", + "title": "CloudRedis upgradeInstance Sample", + "origin": "API_DEFINITION", + "description": " Upgrades Redis instance to the newer Redis version specified in the request.", + "canonical": true, + "file": "cloud_redis.upgrade_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpgradeInstance", + "fullName": "google.cloud.redis.v1.CloudRedis.UpgradeInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "redis_version", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1.CloudRedisClient" + }, + "method": { + "shortName": "UpgradeInstance", + "fullName": "google.cloud.redis.v1.CloudRedis.UpgradeInstance", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1.CloudRedis" + } + } + } + }, + { + "regionTag": "redis_v1_generated_CloudRedis_ImportInstance_async", + "title": "CloudRedis importInstance Sample", + "origin": "API_DEFINITION", + "description": " Import a Redis RDB snapshot file from Cloud Storage into a Redis instance. Redis may stop serving during this operation. Instance state will be IMPORTING for entire operation. When complete, the instance will contain only data from the imported file. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.", + "canonical": true, + "file": "cloud_redis.import_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportInstance", + "fullName": "google.cloud.redis.v1.CloudRedis.ImportInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.redis.v1.InputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1.CloudRedisClient" + }, + "method": { + "shortName": "ImportInstance", + "fullName": "google.cloud.redis.v1.CloudRedis.ImportInstance", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1.CloudRedis" + } + } + } + }, + { + "regionTag": "redis_v1_generated_CloudRedis_ExportInstance_async", + "title": "CloudRedis exportInstance Sample", + "origin": "API_DEFINITION", + "description": " Export Redis instance data into a Redis RDB format file in Cloud Storage. Redis will continue serving during this operation. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.", + "canonical": true, + "file": "cloud_redis.export_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ExportInstance", + "fullName": "google.cloud.redis.v1.CloudRedis.ExportInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "output_config", + "type": ".google.cloud.redis.v1.OutputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1.CloudRedisClient" + }, + "method": { + "shortName": "ExportInstance", + "fullName": "google.cloud.redis.v1.CloudRedis.ExportInstance", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1.CloudRedis" + } + } + } + }, + { + "regionTag": "redis_v1_generated_CloudRedis_FailoverInstance_async", + "title": "CloudRedis failoverInstance Sample", + "origin": "API_DEFINITION", + "description": " Initiates a failover of the primary node to current replica node for a specific STANDARD tier Cloud Memorystore for Redis instance.", + "canonical": true, + "file": "cloud_redis.failover_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "FailoverInstance", + "fullName": "google.cloud.redis.v1.CloudRedis.FailoverInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "data_protection_mode", + "type": ".google.cloud.redis.v1.FailoverInstanceRequest.DataProtectionMode" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1.CloudRedisClient" + }, + "method": { + "shortName": "FailoverInstance", + "fullName": "google.cloud.redis.v1.CloudRedis.FailoverInstance", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1.CloudRedis" + } + } + } + }, + { + "regionTag": "redis_v1_generated_CloudRedis_DeleteInstance_async", + "title": "CloudRedis deleteInstance Sample", + "origin": "API_DEFINITION", + "description": " Deletes a specific Redis instance. Instance stops serving and data is deleted.", + "canonical": true, + "file": "cloud_redis.delete_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteInstance", + "fullName": "google.cloud.redis.v1.CloudRedis.DeleteInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1.CloudRedisClient" + }, + "method": { + "shortName": "DeleteInstance", + "fullName": "google.cloud.redis.v1.CloudRedis.DeleteInstance", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1.CloudRedis" + } + } + } + }, + { + "regionTag": "redis_v1_generated_CloudRedis_RescheduleMaintenance_async", + "title": "CloudRedis rescheduleMaintenance Sample", + "origin": "API_DEFINITION", + "description": " Reschedule maintenance for a given instance in a given project and location.", + "canonical": true, + "file": "cloud_redis.reschedule_maintenance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RescheduleMaintenance", + "fullName": "google.cloud.redis.v1.CloudRedis.RescheduleMaintenance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "reschedule_type", + "type": ".google.cloud.redis.v1.RescheduleMaintenanceRequest.RescheduleType" + }, + { + "name": "schedule_time", + "type": ".google.protobuf.Timestamp" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1.CloudRedisClient" + }, + "method": { + "shortName": "RescheduleMaintenance", + "fullName": "google.cloud.redis.v1.CloudRedis.RescheduleMaintenance", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1.CloudRedis" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-redis/v1/src/index.ts b/owl-bot-staging/google-cloud-redis/v1/src/index.ts new file mode 100644 index 00000000000..634b7700cdd --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const CloudRedisClient = v1.CloudRedisClient; +type CloudRedisClient = v1.CloudRedisClient; +export {v1, CloudRedisClient}; +export default {v1, CloudRedisClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_client.ts b/owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_client.ts new file mode 100644 index 00000000000..ca0520900a5 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_client.ts @@ -0,0 +1,1923 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/cloud_redis_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './cloud_redis_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Configures and manages Cloud Memorystore for Redis instances + * + * Google Cloud Memorystore for Redis v1 + * + * The `redis.googleapis.com` service implements the Google Cloud Memorystore + * for Redis API and defines the following resource model for managing Redis + * instances: + * * The service works with a collection of cloud projects, named: `/projects/*` + * * Each project has a collection of available locations, named: `/locations/*` + * * Each location has a collection of Redis instances, named: `/instances/*` + * * As such, Redis instances are resources of the form: + * `/projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * + * Note that location_id must be referring to a GCP `region`; for example: + * * `projects/redpepper-1290/locations/us-central1/instances/my-redis` + * @class + * @memberof v1 + */ +export class CloudRedisClient { + 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; + cloudRedisStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CloudRedisClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 CloudRedisClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CloudRedisClient; + 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 { + 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 = { + instancePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/instances/{instance}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + }; + + // 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 = { + listInstances: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instances') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.redis.v1.Instance') as gax.protobuf.Type; + const createInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.redis.v1.OperationMetadata') as gax.protobuf.Type; + const updateInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.redis.v1.Instance') as gax.protobuf.Type; + const updateInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.redis.v1.OperationMetadata') as gax.protobuf.Type; + const upgradeInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.redis.v1.Instance') as gax.protobuf.Type; + const upgradeInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.redis.v1.OperationMetadata') as gax.protobuf.Type; + const importInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.redis.v1.Instance') as gax.protobuf.Type; + const importInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.redis.v1.OperationMetadata') as gax.protobuf.Type; + const exportInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.redis.v1.Instance') as gax.protobuf.Type; + const exportInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.redis.v1.OperationMetadata') as gax.protobuf.Type; + const failoverInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.redis.v1.Instance') as gax.protobuf.Type; + const failoverInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.redis.v1.OperationMetadata') as gax.protobuf.Type; + const deleteInstanceResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteInstanceMetadata = protoFilesRoot.lookup( + '.google.cloud.redis.v1.OperationMetadata') as gax.protobuf.Type; + const rescheduleMaintenanceResponse = protoFilesRoot.lookup( + '.google.cloud.redis.v1.Instance') as gax.protobuf.Type; + const rescheduleMaintenanceMetadata = protoFilesRoot.lookup( + '.google.cloud.redis.v1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createInstanceResponse.decode.bind(createInstanceResponse), + createInstanceMetadata.decode.bind(createInstanceMetadata)), + updateInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateInstanceResponse.decode.bind(updateInstanceResponse), + updateInstanceMetadata.decode.bind(updateInstanceMetadata)), + upgradeInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + upgradeInstanceResponse.decode.bind(upgradeInstanceResponse), + upgradeInstanceMetadata.decode.bind(upgradeInstanceMetadata)), + importInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importInstanceResponse.decode.bind(importInstanceResponse), + importInstanceMetadata.decode.bind(importInstanceMetadata)), + exportInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + exportInstanceResponse.decode.bind(exportInstanceResponse), + exportInstanceMetadata.decode.bind(exportInstanceMetadata)), + failoverInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + failoverInstanceResponse.decode.bind(failoverInstanceResponse), + failoverInstanceMetadata.decode.bind(failoverInstanceMetadata)), + deleteInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteInstanceResponse.decode.bind(deleteInstanceResponse), + deleteInstanceMetadata.decode.bind(deleteInstanceMetadata)), + rescheduleMaintenance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + rescheduleMaintenanceResponse.decode.bind(rescheduleMaintenanceResponse), + rescheduleMaintenanceMetadata.decode.bind(rescheduleMaintenanceMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.redis.v1.CloudRedis', 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.cloudRedisStub) { + return this.cloudRedisStub; + } + + // Put together the "service stub" for + // google.cloud.redis.v1.CloudRedis. + this.cloudRedisStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.redis.v1.CloudRedis') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.redis.v1.CloudRedis, + 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 cloudRedisStubMethods = + ['listInstances', 'getInstance', 'getInstanceAuthString', 'createInstance', 'updateInstance', 'upgradeInstance', 'importInstance', 'exportInstance', 'failoverInstance', 'deleteInstance', 'rescheduleMaintenance']; + for (const methodName of cloudRedisStubMethods) { + const callPromise = this.cloudRedisStub.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.cloudRedisStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'redis.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 'redis.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 the details of a specific Redis instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.redis.v1.Instance|Instance}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_redis.get_instance.js + * region_tag:redis_v1_generated_CloudRedis_GetInstance_async + */ + getInstance( + request?: protos.google.cloud.redis.v1.IGetInstanceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.redis.v1.IInstance, + protos.google.cloud.redis.v1.IGetInstanceRequest|undefined, {}|undefined + ]>; + getInstance( + request: protos.google.cloud.redis.v1.IGetInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.redis.v1.IInstance, + protos.google.cloud.redis.v1.IGetInstanceRequest|null|undefined, + {}|null|undefined>): void; + getInstance( + request: protos.google.cloud.redis.v1.IGetInstanceRequest, + callback: Callback< + protos.google.cloud.redis.v1.IInstance, + protos.google.cloud.redis.v1.IGetInstanceRequest|null|undefined, + {}|null|undefined>): void; + getInstance( + request?: protos.google.cloud.redis.v1.IGetInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.redis.v1.IInstance, + protos.google.cloud.redis.v1.IGetInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.redis.v1.IInstance, + protos.google.cloud.redis.v1.IGetInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.redis.v1.IInstance, + protos.google.cloud.redis.v1.IGetInstanceRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getInstance(request, options, callback); + } +/** + * Gets the AUTH string for a Redis instance. If AUTH is not enabled for the + * instance the response will be empty. This information is not included in + * the details returned to GetInstance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.redis.v1.InstanceAuthString|InstanceAuthString}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_redis.get_instance_auth_string.js + * region_tag:redis_v1_generated_CloudRedis_GetInstanceAuthString_async + */ + getInstanceAuthString( + request?: protos.google.cloud.redis.v1.IGetInstanceAuthStringRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.redis.v1.IInstanceAuthString, + protos.google.cloud.redis.v1.IGetInstanceAuthStringRequest|undefined, {}|undefined + ]>; + getInstanceAuthString( + request: protos.google.cloud.redis.v1.IGetInstanceAuthStringRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.redis.v1.IInstanceAuthString, + protos.google.cloud.redis.v1.IGetInstanceAuthStringRequest|null|undefined, + {}|null|undefined>): void; + getInstanceAuthString( + request: protos.google.cloud.redis.v1.IGetInstanceAuthStringRequest, + callback: Callback< + protos.google.cloud.redis.v1.IInstanceAuthString, + protos.google.cloud.redis.v1.IGetInstanceAuthStringRequest|null|undefined, + {}|null|undefined>): void; + getInstanceAuthString( + request?: protos.google.cloud.redis.v1.IGetInstanceAuthStringRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.redis.v1.IInstanceAuthString, + protos.google.cloud.redis.v1.IGetInstanceAuthStringRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.redis.v1.IInstanceAuthString, + protos.google.cloud.redis.v1.IGetInstanceAuthStringRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.redis.v1.IInstanceAuthString, + protos.google.cloud.redis.v1.IGetInstanceAuthStringRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getInstanceAuthString(request, options, callback); + } + +/** + * Creates a Redis instance based on the specified tier and memory size. + * + * By default, the instance is accessible from the project's + * [default network](https://cloud.google.com/vpc/docs/vpc). + * + * The creation is executed asynchronously and callers may check the returned + * operation to track its progress. Once the operation is completed the Redis + * instance will be fully functional. Completed longrunning.Operation will + * contain the new instance object in the response field. + * + * The returned operation is automatically deleted after a few hours, so there + * is no need to call DeleteOperation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the instance location using the form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a GCP region. + * @param {string} request.instanceId + * Required. The logical name of the Redis instance in the customer project + * with the following restrictions: + * + * * Must contain only lowercase letters, numbers, and hyphens. + * * Must start with a letter. + * * Must be between 1-40 characters. + * * Must end with a number or a letter. + * * Must be unique within the customer project / location + * @param {google.cloud.redis.v1.Instance} request.instance + * Required. A Redis [Instance] resource + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_redis.create_instance.js + * region_tag:redis_v1_generated_CloudRedis_CreateInstance_async + */ + createInstance( + request?: protos.google.cloud.redis.v1.ICreateInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createInstance( + request: protos.google.cloud.redis.v1.ICreateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createInstance( + request: protos.google.cloud.redis.v1.ICreateInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createInstance( + request?: protos.google.cloud.redis.v1.ICreateInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_redis.create_instance.js + * region_tag:redis_v1_generated_CloudRedis_CreateInstance_async + */ + async checkCreateInstanceProgress(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.createInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the metadata and configuration of a specific Redis instance. + * + * Completed longrunning.Operation will contain the new instance object + * in the response field. The returned operation is automatically deleted + * after a few hours, so there is no need to call DeleteOperation. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields to update. At least one path must be supplied in + * this field. The elements of the repeated paths field may only include these + * fields from {@link protos.google.cloud.redis.v1.Instance|Instance}: + * + * * `displayName` + * * `labels` + * * `memorySizeGb` + * * `redisConfig` + * * `replica_count` + * @param {google.cloud.redis.v1.Instance} request.instance + * Required. Update description. + * Only fields specified in update_mask 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_redis.update_instance.js + * region_tag:redis_v1_generated_CloudRedis_UpdateInstance_async + */ + updateInstance( + request?: protos.google.cloud.redis.v1.IUpdateInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateInstance( + request: protos.google.cloud.redis.v1.IUpdateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateInstance( + request: protos.google.cloud.redis.v1.IUpdateInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateInstance( + request?: protos.google.cloud.redis.v1.IUpdateInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'instance.name': request.instance!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_redis.update_instance.js + * region_tag:redis_v1_generated_CloudRedis_UpdateInstance_async + */ + async checkUpdateInstanceProgress(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.updateInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Upgrades Redis instance to the newer Redis version specified in the + * request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + * @param {string} request.redisVersion + * Required. Specifies the target version of Redis software to upgrade to. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_redis.upgrade_instance.js + * region_tag:redis_v1_generated_CloudRedis_UpgradeInstance_async + */ + upgradeInstance( + request?: protos.google.cloud.redis.v1.IUpgradeInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + upgradeInstance( + request: protos.google.cloud.redis.v1.IUpgradeInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + upgradeInstance( + request: protos.google.cloud.redis.v1.IUpgradeInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + upgradeInstance( + request?: protos.google.cloud.redis.v1.IUpgradeInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.upgradeInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `upgradeInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_redis.upgrade_instance.js + * region_tag:redis_v1_generated_CloudRedis_UpgradeInstance_async + */ + async checkUpgradeInstanceProgress(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.upgradeInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Import a Redis RDB snapshot file from Cloud Storage into a Redis instance. + * + * Redis may stop serving during this operation. Instance state will be + * IMPORTING for entire operation. When complete, the instance will contain + * only data from the imported file. + * + * The returned operation is automatically deleted after a few hours, so + * there is no need to call DeleteOperation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + * @param {google.cloud.redis.v1.InputConfig} request.inputConfig + * Required. Specify data to be imported. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_redis.import_instance.js + * region_tag:redis_v1_generated_CloudRedis_ImportInstance_async + */ + importInstance( + request?: protos.google.cloud.redis.v1.IImportInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importInstance( + request: protos.google.cloud.redis.v1.IImportInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importInstance( + request: protos.google.cloud.redis.v1.IImportInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importInstance( + request?: protos.google.cloud.redis.v1.IImportInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.importInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_redis.import_instance.js + * region_tag:redis_v1_generated_CloudRedis_ImportInstance_async + */ + async checkImportInstanceProgress(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.importInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Export Redis instance data into a Redis RDB format file in Cloud Storage. + * + * Redis will continue serving during this operation. + * + * The returned operation is automatically deleted after a few hours, so + * there is no need to call DeleteOperation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + * @param {google.cloud.redis.v1.OutputConfig} request.outputConfig + * Required. Specify data to be exported. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_redis.export_instance.js + * region_tag:redis_v1_generated_CloudRedis_ExportInstance_async + */ + exportInstance( + request?: protos.google.cloud.redis.v1.IExportInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + exportInstance( + request: protos.google.cloud.redis.v1.IExportInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + exportInstance( + request: protos.google.cloud.redis.v1.IExportInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + exportInstance( + request?: protos.google.cloud.redis.v1.IExportInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.exportInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `exportInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_redis.export_instance.js + * region_tag:redis_v1_generated_CloudRedis_ExportInstance_async + */ + async checkExportInstanceProgress(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.exportInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Initiates a failover of the primary node to current replica node for a + * specific STANDARD tier Cloud Memorystore for Redis instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + * @param {google.cloud.redis.v1.FailoverInstanceRequest.DataProtectionMode} [request.dataProtectionMode] + * Optional. Available data protection modes that the user can choose. If it's + * unspecified, data protection mode will be LIMITED_DATA_LOSS by default. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_redis.failover_instance.js + * region_tag:redis_v1_generated_CloudRedis_FailoverInstance_async + */ + failoverInstance( + request?: protos.google.cloud.redis.v1.IFailoverInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + failoverInstance( + request: protos.google.cloud.redis.v1.IFailoverInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + failoverInstance( + request: protos.google.cloud.redis.v1.IFailoverInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + failoverInstance( + request?: protos.google.cloud.redis.v1.IFailoverInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.failoverInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `failoverInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_redis.failover_instance.js + * region_tag:redis_v1_generated_CloudRedis_FailoverInstance_async + */ + async checkFailoverInstanceProgress(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.failoverInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a specific Redis instance. Instance stops serving and data is + * deleted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_redis.delete_instance.js + * region_tag:redis_v1_generated_CloudRedis_DeleteInstance_async + */ + deleteInstance( + request?: protos.google.cloud.redis.v1.IDeleteInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteInstance( + request: protos.google.cloud.redis.v1.IDeleteInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteInstance( + request: protos.google.cloud.redis.v1.IDeleteInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteInstance( + request?: protos.google.cloud.redis.v1.IDeleteInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_redis.delete_instance.js + * region_tag:redis_v1_generated_CloudRedis_DeleteInstance_async + */ + async checkDeleteInstanceProgress(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.deleteInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Reschedule maintenance for a given instance in a given project and + * location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + * @param {google.cloud.redis.v1.RescheduleMaintenanceRequest.RescheduleType} request.rescheduleType + * Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as + * well. + * @param {google.protobuf.Timestamp} [request.scheduleTime] + * Optional. Timestamp when the maintenance shall be rescheduled to if + * reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for + * example `2012-11-15T16:19:00.094Z`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_redis.reschedule_maintenance.js + * region_tag:redis_v1_generated_CloudRedis_RescheduleMaintenance_async + */ + rescheduleMaintenance( + request?: protos.google.cloud.redis.v1.IRescheduleMaintenanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + rescheduleMaintenance( + request: protos.google.cloud.redis.v1.IRescheduleMaintenanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + rescheduleMaintenance( + request: protos.google.cloud.redis.v1.IRescheduleMaintenanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + rescheduleMaintenance( + request?: protos.google.cloud.redis.v1.IRescheduleMaintenanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.rescheduleMaintenance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `rescheduleMaintenance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_redis.reschedule_maintenance.js + * region_tag:redis_v1_generated_CloudRedis_RescheduleMaintenance_async + */ + async checkRescheduleMaintenanceProgress(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.rescheduleMaintenance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists all Redis instances owned by a project in either the specified + * location (region) or all locations. + * + * The location should have the following format: + * + * * `projects/{project_id}/locations/{location_id}` + * + * If `location_id` is specified as `-` (wildcard), then all regions + * available to the project are queried, and the results are aggregated. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the instance location using the form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a GCP region. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 1000 will be used by the service. + * Regardless of the page_size value, the response may include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.redis.v1.ListInstancesResponse.next_page_token|`next_page_token`} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous + * {@link protos.google.cloud.redis.v1.CloudRedis.ListInstances|ListInstances} request, if + * any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.redis.v1.Instance|Instance}. + * 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 `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listInstances( + request?: protos.google.cloud.redis.v1.IListInstancesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.redis.v1.IInstance[], + protos.google.cloud.redis.v1.IListInstancesRequest|null, + protos.google.cloud.redis.v1.IListInstancesResponse + ]>; + listInstances( + request: protos.google.cloud.redis.v1.IListInstancesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.redis.v1.IListInstancesRequest, + protos.google.cloud.redis.v1.IListInstancesResponse|null|undefined, + protos.google.cloud.redis.v1.IInstance>): void; + listInstances( + request: protos.google.cloud.redis.v1.IListInstancesRequest, + callback: PaginationCallback< + protos.google.cloud.redis.v1.IListInstancesRequest, + protos.google.cloud.redis.v1.IListInstancesResponse|null|undefined, + protos.google.cloud.redis.v1.IInstance>): void; + listInstances( + request?: protos.google.cloud.redis.v1.IListInstancesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.redis.v1.IListInstancesRequest, + protos.google.cloud.redis.v1.IListInstancesResponse|null|undefined, + protos.google.cloud.redis.v1.IInstance>, + callback?: PaginationCallback< + protos.google.cloud.redis.v1.IListInstancesRequest, + protos.google.cloud.redis.v1.IListInstancesResponse|null|undefined, + protos.google.cloud.redis.v1.IInstance>): + Promise<[ + protos.google.cloud.redis.v1.IInstance[], + protos.google.cloud.redis.v1.IListInstancesRequest|null, + protos.google.cloud.redis.v1.IListInstancesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listInstances(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the instance location using the form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a GCP region. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 1000 will be used by the service. + * Regardless of the page_size value, the response may include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.redis.v1.ListInstancesResponse.next_page_token|`next_page_token`} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous + * {@link protos.google.cloud.redis.v1.CloudRedis.ListInstances|ListInstances} request, if + * any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.redis.v1.Instance|Instance} 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 `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listInstancesStream( + request?: protos.google.cloud.redis.v1.IListInstancesRequest, + 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['listInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInstances.createStream( + this.innerApiCalls.listInstances as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listInstances`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the instance location using the form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a GCP region. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 1000 will be used by the service. + * Regardless of the page_size value, the response may include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.redis.v1.ListInstancesResponse.next_page_token|`next_page_token`} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous + * {@link protos.google.cloud.redis.v1.CloudRedis.ListInstances|ListInstances} request, if + * any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.redis.v1.Instance|Instance}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_redis.list_instances.js + * region_tag:redis_v1_generated_CloudRedis_ListInstances_async + */ + listInstancesAsync( + request?: protos.google.cloud.redis.v1.IListInstancesRequest, + 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['listInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInstances.asyncIterate( + this.innerApiCalls['listInstances'] 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 instance resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} instance + * @returns {string} Resource name string. + */ + instancePath(project:string,location:string,instance:string) { + return this.pathTemplates.instancePathTemplate.render({ + project: project, + location: location, + instance: instance, + }); + } + + /** + * Parse the project from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the project. + */ + matchProjectFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).project; + } + + /** + * Parse the location from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the location. + */ + matchLocationFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).location; + } + + /** + * Parse the instance from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).instance; + } + + /** + * 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; + } + + /** + * 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.cloudRedisStub && !this._terminated) { + return this.cloudRedisStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_client_config.json b/owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_client_config.json new file mode 100644 index 00000000000..72ac0d962a3 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_client_config.json @@ -0,0 +1,81 @@ +{ + "interfaces": { + "google.cloud.redis.v1.CloudRedis": { + "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": { + "ListInstances": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetInstance": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetInstanceAuthString": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateInstance": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateInstance": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpgradeInstance": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ImportInstance": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ExportInstance": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "FailoverInstance": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteInstance": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RescheduleMaintenance": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_proto_list.json b/owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_proto_list.json new file mode 100644 index 00000000000..ddb165dbe38 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/redis/v1/cloud_redis.proto" +] diff --git a/owl-bot-staging/google-cloud-redis/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-redis/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..4390968e4b6 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/src/v1/gapic_metadata.json @@ -0,0 +1,137 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.redis.v1", + "libraryPackage": "@google-cloud/redis", + "services": { + "CloudRedis": { + "clients": { + "grpc": { + "libraryClient": "CloudRedisClient", + "rpcs": { + "GetInstance": { + "methods": [ + "getInstance" + ] + }, + "GetInstanceAuthString": { + "methods": [ + "getInstanceAuthString" + ] + }, + "CreateInstance": { + "methods": [ + "createInstance" + ] + }, + "UpdateInstance": { + "methods": [ + "updateInstance" + ] + }, + "UpgradeInstance": { + "methods": [ + "upgradeInstance" + ] + }, + "ImportInstance": { + "methods": [ + "importInstance" + ] + }, + "ExportInstance": { + "methods": [ + "exportInstance" + ] + }, + "FailoverInstance": { + "methods": [ + "failoverInstance" + ] + }, + "DeleteInstance": { + "methods": [ + "deleteInstance" + ] + }, + "RescheduleMaintenance": { + "methods": [ + "rescheduleMaintenance" + ] + }, + "ListInstances": { + "methods": [ + "listInstances", + "listInstancesStream", + "listInstancesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CloudRedisClient", + "rpcs": { + "GetInstance": { + "methods": [ + "getInstance" + ] + }, + "GetInstanceAuthString": { + "methods": [ + "getInstanceAuthString" + ] + }, + "CreateInstance": { + "methods": [ + "createInstance" + ] + }, + "UpdateInstance": { + "methods": [ + "updateInstance" + ] + }, + "UpgradeInstance": { + "methods": [ + "upgradeInstance" + ] + }, + "ImportInstance": { + "methods": [ + "importInstance" + ] + }, + "ExportInstance": { + "methods": [ + "exportInstance" + ] + }, + "FailoverInstance": { + "methods": [ + "failoverInstance" + ] + }, + "DeleteInstance": { + "methods": [ + "deleteInstance" + ] + }, + "RescheduleMaintenance": { + "methods": [ + "rescheduleMaintenance" + ] + }, + "ListInstances": { + "methods": [ + "listInstances", + "listInstancesStream", + "listInstancesAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-redis/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-redis/v1/src/v1/index.ts new file mode 100644 index 00000000000..036e9efba28 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {CloudRedisClient} from './cloud_redis_client'; diff --git a/owl-bot-staging/google-cloud-redis/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-redis/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..bb242f40531 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const redis = require('@google-cloud/redis'); + +function main() { + const cloudRedisClient = new redis.CloudRedisClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-redis/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-redis/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..b6c5a1f5f69 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {CloudRedisClient} from '@google-cloud/redis'; + +// check that the client class type name can be used +function doStuffWithCloudRedisClient(client: CloudRedisClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const cloudRedisClient = new CloudRedisClient(); + doStuffWithCloudRedisClient(cloudRedisClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-redis/v1/system-test/install.ts b/owl-bot-staging/google-cloud-redis/v1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/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-redis/v1/test/gapic_cloud_redis_v1.ts b/owl-bot-staging/google-cloud-redis/v1/test/gapic_cloud_redis_v1.ts new file mode 100644 index 00000000000..0e8cbab978c --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/test/gapic_cloud_redis_v1.ts @@ -0,0 +1,2418 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 cloudredisModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.CloudRedisClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = cloudredisModule.v1.CloudRedisClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = cloudredisModule.v1.CloudRedisClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = cloudredisModule.v1.CloudRedisClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new cloudredisModule.v1.CloudRedisClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudRedisStub, undefined); + await client.initialize(); + assert(client.cloudRedisStub); + }); + + it('has close method for the initialized client', done => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.cloudRedisStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudRedisStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudredisModule.v1.CloudRedisClient({ + 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 cloudredisModule.v1.CloudRedisClient({ + 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('getInstance', () => { + it('invokes getInstance without error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.redis.v1.Instance() + ); + client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); + const [response] = await client.getInstance(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstance without error using callback', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.redis.v1.Instance() + ); + client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstance( + request, + (err?: Error|null, result?: protos.google.cloud.redis.v1.IInstance|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstance with error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstance with closed client', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getInstance(request), expectedError); + }); + }); + + describe('getInstanceAuthString', () => { + it('invokes getInstanceAuthString without error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.GetInstanceAuthStringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.GetInstanceAuthStringRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.redis.v1.InstanceAuthString() + ); + client.innerApiCalls.getInstanceAuthString = stubSimpleCall(expectedResponse); + const [response] = await client.getInstanceAuthString(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstanceAuthString as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstanceAuthString as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstanceAuthString without error using callback', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.GetInstanceAuthStringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.GetInstanceAuthStringRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.redis.v1.InstanceAuthString() + ); + client.innerApiCalls.getInstanceAuthString = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstanceAuthString( + request, + (err?: Error|null, result?: protos.google.cloud.redis.v1.IInstanceAuthString|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstanceAuthString as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstanceAuthString as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstanceAuthString with error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.GetInstanceAuthStringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.GetInstanceAuthStringRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstanceAuthString = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getInstanceAuthString(request), expectedError); + const actualRequest = (client.innerApiCalls.getInstanceAuthString as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstanceAuthString as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstanceAuthString with closed client', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.GetInstanceAuthStringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.GetInstanceAuthStringRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getInstanceAuthString(request), expectedError); + }); + }); + + describe('createInstance', () => { + it('invokes createInstance without error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.createInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstance without error using callback', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createInstance( + request, + (err?: Error|null, + result?: 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.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstance with call error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstance with LRO error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateInstanceProgress without error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateInstanceProgress with error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateInstance', () => { + it('invokes updateInstance without error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.UpdateInstanceRequest() + ); + request.instance ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.UpdateInstanceRequest', ['instance', 'name']); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstance without error using callback', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.UpdateInstanceRequest() + ); + request.instance ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.UpdateInstanceRequest', ['instance', 'name']); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateInstance( + request, + (err?: Error|null, + result?: 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.updateInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstance with call error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.UpdateInstanceRequest() + ); + request.instance ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.UpdateInstanceRequest', ['instance', 'name']); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstance with LRO error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.UpdateInstanceRequest() + ); + request.instance ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.UpdateInstanceRequest', ['instance', 'name']); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateInstanceProgress without error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateInstanceProgress with error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('upgradeInstance', () => { + it('invokes upgradeInstance without error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.UpgradeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.UpgradeInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.upgradeInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.upgradeInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeInstance without error using callback', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.UpgradeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.UpgradeInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.upgradeInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.upgradeInstance( + request, + (err?: Error|null, + result?: 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.upgradeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeInstance with call error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.UpgradeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.UpgradeInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.upgradeInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeInstance with LRO error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.UpgradeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.UpgradeInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.upgradeInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpgradeInstanceProgress without error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpgradeInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpgradeInstanceProgress with error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpgradeInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('importInstance', () => { + it('invokes importInstance without error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.ImportInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.ImportInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.importInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.importInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importInstance without error using callback', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.ImportInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.ImportInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importInstance( + request, + (err?: Error|null, + result?: 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.importInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importInstance with call error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.ImportInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.ImportInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.importInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importInstance with LRO error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.ImportInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.ImportInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportInstanceProgress without error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportInstanceProgress with error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('exportInstance', () => { + it('invokes exportInstance without error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.ExportInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.ExportInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.exportInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.exportInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.exportInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.exportInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes exportInstance without error using callback', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.ExportInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.ExportInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.exportInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.exportInstance( + request, + (err?: Error|null, + result?: 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.exportInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.exportInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes exportInstance with call error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.ExportInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.ExportInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.exportInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.exportInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.exportInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.exportInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes exportInstance with LRO error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.ExportInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.ExportInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.exportInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.exportInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.exportInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.exportInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkExportInstanceProgress without error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkExportInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkExportInstanceProgress with error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkExportInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('failoverInstance', () => { + it('invokes failoverInstance without error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.FailoverInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.FailoverInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.failoverInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.failoverInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.failoverInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.failoverInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes failoverInstance without error using callback', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.FailoverInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.FailoverInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.failoverInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.failoverInstance( + request, + (err?: Error|null, + result?: 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.failoverInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.failoverInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes failoverInstance with call error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.FailoverInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.FailoverInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.failoverInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.failoverInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.failoverInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.failoverInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes failoverInstance with LRO error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.FailoverInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.FailoverInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.failoverInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.failoverInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.failoverInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.failoverInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkFailoverInstanceProgress without error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkFailoverInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkFailoverInstanceProgress with error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkFailoverInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteInstance', () => { + it('invokes deleteInstance without error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstance without error using callback', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteInstance( + request, + (err?: Error|null, + result?: 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.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstance with call error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstance with LRO error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteInstanceProgress without error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteInstanceProgress with error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('rescheduleMaintenance', () => { + it('invokes rescheduleMaintenance without error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.RescheduleMaintenanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.RescheduleMaintenanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall(expectedResponse); + const [operation] = await client.rescheduleMaintenance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rescheduleMaintenance without error using callback', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.RescheduleMaintenanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.RescheduleMaintenanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.rescheduleMaintenance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rescheduleMaintenance( + request, + (err?: Error|null, + result?: 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.rescheduleMaintenance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rescheduleMaintenance with call error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.RescheduleMaintenanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.RescheduleMaintenanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.rescheduleMaintenance(request), expectedError); + const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rescheduleMaintenance with LRO error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.RescheduleMaintenanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.RescheduleMaintenanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.rescheduleMaintenance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkRescheduleMaintenanceProgress without error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRescheduleMaintenanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRescheduleMaintenanceProgress with error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRescheduleMaintenanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listInstances', () => { + it('invokes listInstances without error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), + generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), + generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), + ]; + client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); + const [response] = await client.listInstances(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstances without error using callback', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), + generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), + generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), + ]; + client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstances( + request, + (err?: Error|null, result?: protos.google.cloud.redis.v1.IInstance[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstances with error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listInstances(request), expectedError); + const actualRequest = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstancesStream without error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), + generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), + generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), + ]; + client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.redis.v1.Instance[] = []; + stream.on('data', (response: protos.google.cloud.redis.v1.Instance) => { + 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.listInstances.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listInstancesStream with error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.redis.v1.Instance[] = []; + stream.on('data', (response: protos.google.cloud.redis.v1.Instance) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstances without error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), + generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), + generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), + ]; + client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.redis.v1.IInstance[] = []; + const iterable = client.listInstancesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstances with error', async () => { + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInstancesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.redis.v1.IInstance[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInstances.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 cloudredisModule.v1.CloudRedisClient({ + 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 cloudredisModule.v1.CloudRedisClient({ + 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 cloudredisModule.v1.CloudRedisClient({ + 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 cloudredisModule.v1.CloudRedisClient({ + 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 cloudredisModule.v1.CloudRedisClient({ + 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 cloudredisModule.v1.CloudRedisClient({ + 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 cloudredisModule.v1.CloudRedisClient({ + 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 cloudredisModule.v1.CloudRedisClient({ + 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 cloudredisModule.v1.CloudRedisClient({ + 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 cloudredisModule.v1.CloudRedisClient({ + 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 cloudredisModule.v1.CloudRedisClient({ + 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 cloudredisModule.v1.CloudRedisClient({ + 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 cloudredisModule.v1.CloudRedisClient({ + 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 cloudredisModule.v1.CloudRedisClient({ + 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 cloudredisModule.v1.CloudRedisClient({ + 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 cloudredisModule.v1.CloudRedisClient({ + 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('instance', () => { + const fakePath = "/rendered/path/instance"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + instance: "instanceValue", + }; + const client = new cloudredisModule.v1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.instancePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.instancePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath("projectValue", "locationValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromInstanceName', () => { + const result = client.matchLocationFromInstanceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new cloudredisModule.v1.CloudRedisClient({ + 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)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-redis/v1/tsconfig.json b/owl-bot-staging/google-cloud-redis/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-redis/v1/webpack.config.js b/owl-bot-staging/google-cloud-redis/v1/webpack.config.js new file mode 100644 index 00000000000..c8446c2163e --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'CloudRedis', + filename: './cloud-redis.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-redis/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-redis/v1beta1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-redis/v1beta1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/.gitignore b/owl-bot-staging/google-cloud-redis/v1beta1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-redis/v1beta1/.jsdoc.js new file mode 100644 index 00000000000..58332656788 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/.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/redis', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-redis/v1beta1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/.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-redis/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-redis/v1beta1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/.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-redis/v1beta1/README.md b/owl-bot-staging/google-cloud-redis/v1beta1/README.md new file mode 100644 index 00000000000..3c11909fadc --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/README.md @@ -0,0 +1 @@ +Redis: Nodejs Client diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/package.json b/owl-bot-staging/google-cloud-redis/v1beta1/package.json new file mode 100644 index 00000000000..0a5bbcc4645 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/redis", + "version": "0.1.0", + "description": "Redis client for Node.js", + "repository": "googleapis/nodejs-redis", + "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 redis", + "redis", + "cloud redis" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/protos/google/cloud/redis/v1beta1/cloud_redis.proto b/owl-bot-staging/google-cloud-redis/v1beta1/protos/google/cloud/redis/v1beta1/cloud_redis.proto new file mode 100644 index 00000000000..037c93aeb5c --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/protos/google/cloud/redis/v1beta1/cloud_redis.proto @@ -0,0 +1,913 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.redis.v1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/dayofweek.proto"; +import "google/type/timeofday.proto"; + +option go_package = "cloud.google.com/go/redis/apiv1beta1/redispb;redispb"; +option java_multiple_files = true; +option java_outer_classname = "CloudRedisServiceBetaProto"; +option java_package = "com.google.cloud.redis.v1beta1"; + +// Configures and manages Cloud Memorystore for Redis instances +// +// Google Cloud Memorystore for Redis v1beta1 +// +// The `redis.googleapis.com` service implements the Google Cloud Memorystore +// for Redis API and defines the following resource model for managing Redis +// instances: +// * The service works with a collection of cloud projects, named: `/projects/*` +// * Each project has a collection of available locations, named: `/locations/*` +// * Each location has a collection of Redis instances, named: `/instances/*` +// * As such, Redis instances are resources of the form: +// `/projects/{project_id}/locations/{location_id}/instances/{instance_id}` +// +// Note that location_id must be referring to a GCP `region`; for example: +// * `projects/redpepper-1290/locations/us-central1/instances/my-redis` +service CloudRedis { + option (google.api.default_host) = "redis.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Lists all Redis instances owned by a project in either the specified + // location (region) or all locations. + // + // The location should have the following format: + // + // * `projects/{project_id}/locations/{location_id}` + // + // If `location_id` is specified as `-` (wildcard), then all regions + // available to the project are queried, and the results are aggregated. + rpc ListInstances(ListInstancesRequest) returns (ListInstancesResponse) { + option (google.api.http) = { + get: "/v1beta1/{parent=projects/*/locations/*}/instances" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets the details of a specific Redis instance. + rpc GetInstance(GetInstanceRequest) returns (Instance) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/locations/*/instances/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets the AUTH string for a Redis instance. If AUTH is not enabled for the + // instance the response will be empty. This information is not included in + // the details returned to GetInstance. + rpc GetInstanceAuthString(GetInstanceAuthStringRequest) returns (InstanceAuthString) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/locations/*/instances/*}/authString" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a Redis instance based on the specified tier and memory size. + // + // By default, the instance is accessible from the project's + // [default network](https://cloud.google.com/vpc/docs/vpc). + // + // The creation is executed asynchronously and callers may check the returned + // operation to track its progress. Once the operation is completed the Redis + // instance will be fully functional. The completed longrunning.Operation will + // contain the new instance object in the response field. + // + // The returned operation is automatically deleted after a few hours, so there + // is no need to call DeleteOperation. + rpc CreateInstance(CreateInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*/locations/*}/instances" + body: "instance" + }; + option (google.api.method_signature) = "parent,instance_id,instance"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.redis.v1beta1.Instance" + metadata_type: "google.protobuf.Any" + }; + } + + // Updates the metadata and configuration of a specific Redis instance. + // + // Completed longrunning.Operation will contain the new instance object + // in the response field. The returned operation is automatically deleted + // after a few hours, so there is no need to call DeleteOperation. + rpc UpdateInstance(UpdateInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1beta1/{instance.name=projects/*/locations/*/instances/*}" + body: "instance" + }; + option (google.api.method_signature) = "update_mask,instance"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.redis.v1beta1.Instance" + metadata_type: "google.protobuf.Any" + }; + } + + // Upgrades Redis instance to the newer Redis version specified in the + // request. + rpc UpgradeInstance(UpgradeInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/instances/*}:upgrade" + body: "*" + }; + option (google.api.method_signature) = "name,redis_version"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.redis.v1beta1.Instance" + metadata_type: "google.protobuf.Any" + }; + } + + // Import a Redis RDB snapshot file from Cloud Storage into a Redis instance. + // + // Redis may stop serving during this operation. Instance state will be + // IMPORTING for entire operation. When complete, the instance will contain + // only data from the imported file. + // + // The returned operation is automatically deleted after a few hours, so + // there is no need to call DeleteOperation. + rpc ImportInstance(ImportInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/instances/*}:import" + body: "*" + }; + option (google.api.method_signature) = "name,input_config"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.redis.v1beta1.Instance" + metadata_type: "google.protobuf.Any" + }; + } + + // Export Redis instance data into a Redis RDB format file in Cloud Storage. + // + // Redis will continue serving during this operation. + // + // The returned operation is automatically deleted after a few hours, so + // there is no need to call DeleteOperation. + rpc ExportInstance(ExportInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/instances/*}:export" + body: "*" + }; + option (google.api.method_signature) = "name,output_config"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.redis.v1beta1.Instance" + metadata_type: "google.protobuf.Any" + }; + } + + // Initiates a failover of the primary node to current replica node for a + // specific STANDARD tier Cloud Memorystore for Redis instance. + rpc FailoverInstance(FailoverInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/instances/*}:failover" + body: "*" + }; + option (google.api.method_signature) = "name,data_protection_mode"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.redis.v1beta1.Instance" + metadata_type: "google.protobuf.Any" + }; + } + + // Deletes a specific Redis instance. Instance stops serving and data is + // deleted. + rpc DeleteInstance(DeleteInstanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1beta1/{name=projects/*/locations/*/instances/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "google.protobuf.Any" + }; + } + + // Reschedule maintenance for a given instance in a given project and + // location. + rpc RescheduleMaintenance(RescheduleMaintenanceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/instances/*}:rescheduleMaintenance" + body: "*" + }; + option (google.api.method_signature) = "name, reschedule_type, schedule_time"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.redis.v1beta1.Instance" + metadata_type: "google.protobuf.Any" + }; + } +} + +// Node specific properties. +message NodeInfo { + // Output only. Node identifying string. e.g. 'node-0', 'node-1' + string id = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Location of the node. + string zone = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A Memorystore for Redis instance. +message Instance { + option (google.api.resource) = { + type: "redis.googleapis.com/Instance" + pattern: "projects/{project}/locations/{location}/instances/{instance}" + }; + + // Represents the different states of a Redis instance. + enum State { + // Not set. + STATE_UNSPECIFIED = 0; + + // Redis instance is being created. + CREATING = 1; + + // Redis instance has been created and is fully usable. + READY = 2; + + // Redis instance configuration is being updated. Certain kinds of updates + // may cause the instance to become unusable while the update is in + // progress. + UPDATING = 3; + + // Redis instance is being deleted. + DELETING = 4; + + // Redis instance is being repaired and may be unusable. + REPAIRING = 5; + + // Maintenance is being performed on this Redis instance. + MAINTENANCE = 6; + + // Redis instance is importing data (availability may be affected). + IMPORTING = 8; + + // Redis instance is failing over (availability may be affected). + FAILING_OVER = 10; + } + + // Available service tiers to choose from + enum Tier { + // Not set. + TIER_UNSPECIFIED = 0; + + // BASIC tier: standalone instance + BASIC = 1; + + // STANDARD_HA tier: highly available primary/replica instances + STANDARD_HA = 3; + } + + // Available connection modes. + enum ConnectMode { + // Not set. + CONNECT_MODE_UNSPECIFIED = 0; + + // Connect via direct peering to the Memorystore for Redis hosted service. + DIRECT_PEERING = 1; + + // Connect your Memorystore for Redis instance using Private Service + // Access. Private services access provides an IP address range for multiple + // Google Cloud services, including Memorystore. + PRIVATE_SERVICE_ACCESS = 2; + } + + // Available TLS modes. + enum TransitEncryptionMode { + // Not set. + TRANSIT_ENCRYPTION_MODE_UNSPECIFIED = 0; + + // Client to Server traffic encryption enabled with server authentication. + SERVER_AUTHENTICATION = 1; + + // TLS is disabled for the instance. + DISABLED = 2; + } + + // Read replicas mode. + enum ReadReplicasMode { + // If not set, Memorystore Redis backend will default to + // READ_REPLICAS_DISABLED. + READ_REPLICAS_MODE_UNSPECIFIED = 0; + + // If disabled, read endpoint will not be provided and the instance cannot + // scale up or down the number of replicas. + READ_REPLICAS_DISABLED = 1; + + // If enabled, read endpoint will be provided and the instance can scale + // up and down the number of replicas. Not valid for basic tier. + READ_REPLICAS_ENABLED = 2; + } + + // Required. Unique name of the resource in this scope including project and + // location using the form: + // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + // + // Note: Redis instances are managed and addressed at regional level so + // location_id here refers to a GCP region; however, users may choose which + // specific zone (or collection of zones for cross-zone instances) an instance + // should be provisioned in. Refer to [location_id][google.cloud.redis.v1beta1.Instance.location_id] and + // [alternative_location_id][google.cloud.redis.v1beta1.Instance.alternative_location_id] fields for more details. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // An arbitrary and optional user-provided name for the instance. + string display_name = 2; + + // Resource labels to represent user provided metadata + map labels = 3; + + // Optional. The zone where the instance will be provisioned. If not provided, + // the service will choose a zone from the specified region for the instance. + // For standard tier, additional nodes will be added across multiple zones for + // protection against zonal failures. If specified, at least one node will be + // provisioned in this zone. + string location_id = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If specified, at least one node will be provisioned in this zone + // in addition to the zone specified in location_id. Only applicable to + // standard tier. If provided, it must be a different zone from the one + // provided in [location_id]. Additional nodes beyond the first 2 will be + // placed in zones selected by the service. + string alternative_location_id = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The version of Redis software. + // If not provided, latest supported version will be used. Currently, the + // supported values are: + // + // * `REDIS_3_2` for Redis 3.2 compatibility + // * `REDIS_4_0` for Redis 4.0 compatibility (default) + // * `REDIS_5_0` for Redis 5.0 compatibility + // * `REDIS_6_X` for Redis 6.x compatibility + string redis_version = 7 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. For DIRECT_PEERING mode, the CIDR range of internal addresses + // that are reserved for this instance. Range must + // be unique and non-overlapping with existing subnets in an authorized + // network. For PRIVATE_SERVICE_ACCESS mode, the name of one allocated IP + // address ranges associated with this private service access connection. + // If not provided, the service will choose an unused /29 block, for + // example, 10.0.0.0/29 or 192.168.0.0/29. For READ_REPLICAS_ENABLED + // the default block size is /28. + string reserved_ip_range = 9 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Additional IP range for node placement. Required when enabling read + // replicas on an existing instance. For DIRECT_PEERING mode value must be a + // CIDR range of size /28, or "auto". For PRIVATE_SERVICE_ACCESS mode value + // must be the name of an allocated address range associated with the private + // service access connection, or "auto". + string secondary_ip_range = 30 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. Hostname or IP address of the exposed Redis endpoint used by + // clients to connect to the service. + string host = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The port number of the exposed Redis endpoint. + int32 port = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The current zone where the Redis primary node is located. In + // basic tier, this will always be the same as [location_id]. In + // standard tier, this can be the zone of any node in the instance. + string current_location_id = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time the instance was created. + google.protobuf.Timestamp create_time = 13 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The current state of this instance. + State state = 14 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Additional information about the current status of this + // instance, if available. + string status_message = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Redis configuration parameters, according to + // http://redis.io/topics/config. Currently, the only supported parameters + // are: + // + // Redis version 3.2 and newer: + // + // * maxmemory-policy + // * notify-keyspace-events + // + // Redis version 4.0 and newer: + // + // * activedefrag + // * lfu-decay-time + // * lfu-log-factor + // * maxmemory-gb + // + // Redis version 5.0 and newer: + // + // * stream-node-max-bytes + // * stream-node-max-entries + map redis_configs = 16 [(google.api.field_behavior) = OPTIONAL]; + + // Required. The service tier of the instance. + Tier tier = 17 [(google.api.field_behavior) = REQUIRED]; + + // Required. Redis memory size in GiB. + int32 memory_size_gb = 18 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The full name of the Google Compute Engine + // [network](https://cloud.google.com/vpc/docs/vpc) to which the + // instance is connected. If left unspecified, the `default` network + // will be used. + string authorized_network = 20 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. Cloud IAM identity used by import / export operations to + // transfer data to/from Cloud Storage. Format is + // "serviceAccount:". The value may change over time + // for a given instance so should be checked before each import/export + // operation. + string persistence_iam_identity = 21 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. The network connect mode of the Redis instance. + // If not provided, the connect mode defaults to DIRECT_PEERING. + ConnectMode connect_mode = 22 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Indicates whether OSS Redis AUTH is enabled for the instance. If set to + // "true" AUTH is enabled on the instance. Default value is "false" meaning + // AUTH is disabled. + bool auth_enabled = 23 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. List of server CA certificates for the instance. + repeated TlsCertificate server_ca_certs = 25 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. The TLS mode of the Redis instance. + // If not provided, TLS is disabled for the instance. + TransitEncryptionMode transit_encryption_mode = 26 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maintenance policy for the instance. If not provided, + // maintenance events can be performed at any time. + MaintenancePolicy maintenance_policy = 27 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. Date and time of upcoming maintenance events which have been + // scheduled. + MaintenanceSchedule maintenance_schedule = 28 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. The number of replica nodes. The valid range for the Standard Tier with + // read replicas enabled is [1-5] and defaults to 2. If read replicas are not + // enabled for a Standard Tier instance, the only valid value is 1 and the + // default is 1. The valid value for basic tier is 0 and the default is also + // 0. + int32 replica_count = 31 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. Info per node. + repeated NodeInfo nodes = 32 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Hostname or IP address of the exposed readonly Redis + // endpoint. Standard tier only. Targets all healthy replica nodes in + // instance. Replication is asynchronous and replica nodes will exhibit some + // lag behind the primary. Write requests must target 'host'. + string read_endpoint = 33 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The port number of the exposed readonly redis + // endpoint. Standard tier only. Write requests should target 'port'. + int32 read_endpoint_port = 34 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Read replicas mode for the instance. Defaults to READ_REPLICAS_DISABLED. + ReadReplicasMode read_replicas_mode = 35 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Persistence configuration parameters + PersistenceConfig persistence_config = 37 [(google.api.field_behavior) = OPTIONAL]; +} + +// Configuration of the persistence functionality. +message PersistenceConfig { + // Available Persistence modes. + enum PersistenceMode { + // Not set. + PERSISTENCE_MODE_UNSPECIFIED = 0; + + // Persistence is disabled for the instance, + // and any existing snapshots are deleted. + DISABLED = 1; + + // RDB based Persistence is enabled. + RDB = 2; + } + + // Available snapshot periods for scheduling. + enum SnapshotPeriod { + // Not set. + SNAPSHOT_PERIOD_UNSPECIFIED = 0; + + // Snapshot every 1 hour. + ONE_HOUR = 3; + + // Snapshot every 6 hours. + SIX_HOURS = 4; + + // Snapshot every 12 hours. + TWELVE_HOURS = 5; + + // Snapshot every 24 hours. + TWENTY_FOUR_HOURS = 6; + } + + // Optional. Controls whether Persistence features are enabled. + // If not provided, the existing value will be used. + PersistenceMode persistence_mode = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Period between RDB snapshots. Snapshots will be attempted every period + // starting from the provided snapshot start time. For example, a start time + // of 01/01/2033 06:45 and SIX_HOURS snapshot period will do nothing until + // 01/01/2033, and then trigger snapshots every day at 06:45, 12:45, 18:45, + // and 00:45 the next day, and so on. + // If not provided, TWENTY_FOUR_HOURS will be used as default. + SnapshotPeriod rdb_snapshot_period = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The next time that a snapshot attempt is scheduled to occur. + google.protobuf.Timestamp rdb_next_snapshot_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Date and time that the first snapshot was/will be attempted, and to which + // future snapshots will be aligned. + // If not provided, the current time will be used. + google.protobuf.Timestamp rdb_snapshot_start_time = 5 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for [RescheduleMaintenance][google.cloud.redis.v1beta1.CloudRedis.RescheduleMaintenance]. +message RescheduleMaintenanceRequest { + // Reschedule options. + enum RescheduleType { + // Not set. + RESCHEDULE_TYPE_UNSPECIFIED = 0; + + // If the user wants to schedule the maintenance to happen now. + IMMEDIATE = 1; + + // If the user wants to use the existing maintenance policy to find the + // next available window. + NEXT_AVAILABLE_WINDOW = 2; + + // If the user wants to reschedule the maintenance to a specific time. + SPECIFIC_TIME = 3; + } + + // Required. Redis instance resource name using the form: + // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + // where `location_id` refers to a GCP region. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "redis.googleapis.com/Instance" + } + ]; + + // Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well. + RescheduleType reschedule_type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Timestamp when the maintenance shall be rescheduled to if + // reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for + // example `2012-11-15T16:19:00.094Z`. + google.protobuf.Timestamp schedule_time = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Maintenance policy for an instance. +message MaintenancePolicy { + // Output only. The time when the policy was created. + google.protobuf.Timestamp create_time = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time when the policy was last updated. + google.protobuf.Timestamp update_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Description of what this policy is for. Create/Update methods + // return INVALID_ARGUMENT if the length is greater than 512. + string description = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Maintenance window that is applied to resources covered by this + // policy. Minimum 1. For the current version, the maximum number of + // weekly_window is expected to be one. + repeated WeeklyMaintenanceWindow weekly_maintenance_window = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Time window in which disruptive maintenance updates occur. Non-disruptive +// updates can occur inside or outside this window. +message WeeklyMaintenanceWindow { + // Required. The day of week that maintenance updates occur. + google.type.DayOfWeek day = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Start time of the window in UTC time. + google.type.TimeOfDay start_time = 2 [(google.api.field_behavior) = REQUIRED]; + + // Output only. Duration of the maintenance window. The current window is fixed at 1 hour. + google.protobuf.Duration duration = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Upcoming maintenance schedule. If no maintenance is scheduled, fields are not +// populated. +message MaintenanceSchedule { + // Output only. The start time of any upcoming scheduled maintenance for this instance. + google.protobuf.Timestamp start_time = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The end time of any upcoming scheduled maintenance for this instance. + google.protobuf.Timestamp end_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // If the scheduled maintenance can be rescheduled, default is true. + bool can_reschedule = 3 [deprecated = true]; + + // Output only. The deadline that the maintenance schedule start time can not go beyond, + // including reschedule. + google.protobuf.Timestamp schedule_deadline_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Request for [ListInstances][google.cloud.redis.v1beta1.CloudRedis.ListInstances]. +message ListInstancesRequest { + // Required. The resource name of the instance location using the form: + // `projects/{project_id}/locations/{location_id}` + // where `location_id` refers to a GCP region. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. + // + // If not specified, a default value of 1000 will be used by the service. + // Regardless of the page_size value, the response may include a partial list + // and a caller should only rely on response's + // [`next_page_token`][google.cloud.redis.v1beta1.ListInstancesResponse.next_page_token] + // to determine if there are more instances left to be queried. + int32 page_size = 2; + + // The `next_page_token` value returned from a previous + // [ListInstances][google.cloud.redis.v1beta1.CloudRedis.ListInstances] request, if any. + string page_token = 3; +} + +// Response for [ListInstances][google.cloud.redis.v1beta1.CloudRedis.ListInstances]. +message ListInstancesResponse { + // A list of Redis instances in the project in the specified location, + // or across all locations. + // + // If the `location_id` in the parent field of the request is "-", all regions + // available to the project are queried, and the results aggregated. + // If in such an aggregated query a location is unavailable, a placeholder + // Redis entry is included in the response with the `name` field set to a + // value of the form + // `projects/{project_id}/locations/{location_id}/instances/`- and the + // `status` field set to ERROR and `status_message` field set to "location not + // available for ListInstances". + repeated Instance instances = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; + + // Locations that could not be reached. + repeated string unreachable = 3; +} + +// Request for [GetInstance][google.cloud.redis.v1beta1.CloudRedis.GetInstance]. +message GetInstanceRequest { + // Required. Redis instance resource name using the form: + // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + // where `location_id` refers to a GCP region. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "redis.googleapis.com/Instance" + } + ]; +} + +// Request for [GetInstanceAuthString][google.cloud.redis.v1beta1.CloudRedis.GetInstanceAuthString]. +message GetInstanceAuthStringRequest { + // Required. Redis instance resource name using the form: + // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + // where `location_id` refers to a GCP region. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "redis.googleapis.com/Instance" + } + ]; +} + +// Instance AUTH string details. +message InstanceAuthString { + // AUTH string set on the instance. + string auth_string = 1; +} + +// Request for [CreateInstance][google.cloud.redis.v1beta1.CloudRedis.CreateInstance]. +message CreateInstanceRequest { + // Required. The resource name of the instance location using the form: + // `projects/{project_id}/locations/{location_id}` + // where `location_id` refers to a GCP region. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The logical name of the Redis instance in the customer project + // with the following restrictions: + // + // * Must contain only lowercase letters, numbers, and hyphens. + // * Must start with a letter. + // * Must be between 1-40 characters. + // * Must end with a number or a letter. + // * Must be unique within the customer project / location + string instance_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. A Redis [Instance] resource + Instance instance = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for [UpdateInstance][google.cloud.redis.v1beta1.CloudRedis.UpdateInstance]. +message UpdateInstanceRequest { + // Required. Mask of fields to update. At least one path must be supplied in + // this field. The elements of the repeated paths field may only include these + // fields from [Instance][google.cloud.redis.v1beta1.Instance]: + // + // * `displayName` + // * `labels` + // * `memorySizeGb` + // * `redisConfig` + // * `replica_count` + google.protobuf.FieldMask update_mask = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Update description. + // Only fields specified in update_mask are updated. + Instance instance = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for [UpgradeInstance][google.cloud.redis.v1beta1.CloudRedis.UpgradeInstance]. +message UpgradeInstanceRequest { + // Required. Redis instance resource name using the form: + // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + // where `location_id` refers to a GCP region. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "redis.googleapis.com/Instance" + } + ]; + + // Required. Specifies the target version of Redis software to upgrade to. + string redis_version = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for [DeleteInstance][google.cloud.redis.v1beta1.CloudRedis.DeleteInstance]. +message DeleteInstanceRequest { + // Required. Redis instance resource name using the form: + // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + // where `location_id` refers to a GCP region. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "redis.googleapis.com/Instance" + } + ]; +} + +// The Cloud Storage location for the input content +message GcsSource { + // Required. Source data URI. (e.g. 'gs://my_bucket/my_object'). + string uri = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The input content +message InputConfig { + // Required. Specify source location of input data + oneof source { + // Google Cloud Storage location where input content is located. + GcsSource gcs_source = 1; + } +} + +// Request for [Import][google.cloud.redis.v1beta1.CloudRedis.ImportInstance]. +message ImportInstanceRequest { + // Required. Redis instance resource name using the form: + // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + // where `location_id` refers to a GCP region. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Specify data to be imported. + InputConfig input_config = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// The Cloud Storage location for the output content +message GcsDestination { + // Required. Data destination URI (e.g. + // 'gs://my_bucket/my_object'). Existing files will be overwritten. + string uri = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The output content +message OutputConfig { + // Required. Specify destination location of output data + oneof destination { + // Google Cloud Storage destination for output content. + GcsDestination gcs_destination = 1; + } +} + +// Request for [Export][google.cloud.redis.v1beta1.CloudRedis.ExportInstance]. +message ExportInstanceRequest { + // Required. Redis instance resource name using the form: + // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + // where `location_id` refers to a GCP region. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Specify data to be exported. + OutputConfig output_config = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for [Failover][google.cloud.redis.v1beta1.CloudRedis.FailoverInstance]. +message FailoverInstanceRequest { + // Specifies different modes of operation in relation to the data retention. + enum DataProtectionMode { + // Defaults to LIMITED_DATA_LOSS if a data protection mode is not + // specified. + DATA_PROTECTION_MODE_UNSPECIFIED = 0; + + // Instance failover will be protected with data loss control. More + // specifically, the failover will only be performed if the current + // replication offset diff between primary and replica is under a certain + // threshold. + LIMITED_DATA_LOSS = 1; + + // Instance failover will be performed without data loss control. + FORCE_DATA_LOSS = 2; + } + + // Required. Redis instance resource name using the form: + // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + // where `location_id` refers to a GCP region. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "redis.googleapis.com/Instance" + } + ]; + + // Optional. Available data protection modes that the user can choose. If it's + // unspecified, data protection mode will be LIMITED_DATA_LOSS by default. + DataProtectionMode data_protection_mode = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// This location metadata represents additional configuration options for a +// given location where a Redis instance may be created. All fields are output +// only. It is returned as content of the +// `google.cloud.location.Location.metadata` field. +message LocationMetadata { + // Output only. The set of available zones in the location. The map is keyed + // by the lowercase ID of each zone, as defined by GCE. These keys can be + // specified in `location_id` or `alternative_location_id` fields when + // creating a Redis instance. + map available_zones = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Defines specific information for a particular zone. Currently empty and +// reserved for future use only. +message ZoneMetadata { + +} + +// TlsCertificate Resource +message TlsCertificate { + // Serial number, as extracted from the certificate. + string serial_number = 1; + + // PEM representation. + string cert = 2; + + // Output only. The time when the certificate was created in [RFC + // 3339](https://tools.ietf.org/html/rfc3339) format, for example + // `2020-05-18T00:00:00.094Z`. + google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time when the certificate expires in [RFC + // 3339](https://tools.ietf.org/html/rfc3339) format, for example + // `2020-05-18T00:00:00.094Z`. + google.protobuf.Timestamp expire_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Sha1 Fingerprint of the certificate. + string sha1_fingerprint = 5; +} diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.create_instance.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.create_instance.js new file mode 100644 index 00000000000..0f58130158a --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.create_instance.js @@ -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. ** + + + +'use strict'; + +function main(parent, instanceId, instance) { + // [START redis_v1beta1_generated_CloudRedis_CreateInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 instance location using the form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a GCP region. + */ + // const parent = 'abc123' + /** + * Required. The logical name of the Redis instance in the customer project + * with the following restrictions: + * * Must contain only lowercase letters, numbers, and hyphens. + * * Must start with a letter. + * * Must be between 1-40 characters. + * * Must end with a number or a letter. + * * Must be unique within the customer project / location + */ + // const instanceId = 'abc123' + /** + * Required. A Redis Instance resource + */ + // const instance = {} + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callCreateInstance() { + // Construct request + const request = { + parent, + instanceId, + instance, + }; + + // Run request + const [operation] = await redisClient.createInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateInstance(); + // [END redis_v1beta1_generated_CloudRedis_CreateInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.delete_instance.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.delete_instance.js new file mode 100644 index 00000000000..f6cb7ce1609 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.delete_instance.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 redis_v1beta1_generated_CloudRedis_DeleteInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + */ + // const name = 'abc123' + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callDeleteInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await redisClient.deleteInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteInstance(); + // [END redis_v1beta1_generated_CloudRedis_DeleteInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.export_instance.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.export_instance.js new file mode 100644 index 00000000000..f7b3d6fc38c --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.export_instance.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(name, outputConfig) { + // [START redis_v1beta1_generated_CloudRedis_ExportInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + */ + // const name = 'abc123' + /** + * Required. Specify data to be exported. + */ + // const outputConfig = {} + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callExportInstance() { + // Construct request + const request = { + name, + outputConfig, + }; + + // Run request + const [operation] = await redisClient.exportInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callExportInstance(); + // [END redis_v1beta1_generated_CloudRedis_ExportInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.failover_instance.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.failover_instance.js new file mode 100644 index 00000000000..601319e7ebc --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.failover_instance.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(name) { + // [START redis_v1beta1_generated_CloudRedis_FailoverInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + */ + // const name = 'abc123' + /** + * Optional. Available data protection modes that the user can choose. If it's + * unspecified, data protection mode will be LIMITED_DATA_LOSS by default. + */ + // const dataProtectionMode = {} + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callFailoverInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await redisClient.failoverInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callFailoverInstance(); + // [END redis_v1beta1_generated_CloudRedis_FailoverInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.get_instance.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.get_instance.js new file mode 100644 index 00000000000..aede7491307 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.get_instance.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 redis_v1beta1_generated_CloudRedis_GetInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + */ + // const name = 'abc123' + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callGetInstance() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await redisClient.getInstance(request); + console.log(response); + } + + callGetInstance(); + // [END redis_v1beta1_generated_CloudRedis_GetInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.get_instance_auth_string.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.get_instance_auth_string.js new file mode 100644 index 00000000000..ce4f6592647 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.get_instance_auth_string.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 redis_v1beta1_generated_CloudRedis_GetInstanceAuthString_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + */ + // const name = 'abc123' + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callGetInstanceAuthString() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await redisClient.getInstanceAuthString(request); + console.log(response); + } + + callGetInstanceAuthString(); + // [END redis_v1beta1_generated_CloudRedis_GetInstanceAuthString_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.import_instance.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.import_instance.js new file mode 100644 index 00000000000..74756e85745 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.import_instance.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(name, inputConfig) { + // [START redis_v1beta1_generated_CloudRedis_ImportInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + */ + // const name = 'abc123' + /** + * Required. Specify data to be imported. + */ + // const inputConfig = {} + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callImportInstance() { + // Construct request + const request = { + name, + inputConfig, + }; + + // Run request + const [operation] = await redisClient.importInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportInstance(); + // [END redis_v1beta1_generated_CloudRedis_ImportInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.list_instances.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.list_instances.js new file mode 100644 index 00000000000..1914b707c71 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.list_instances.js @@ -0,0 +1,79 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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 redis_v1beta1_generated_CloudRedis_ListInstances_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 instance location using the form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a GCP region. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. + * If not specified, a default value of 1000 will be used by the service. + * Regardless of the page_size value, the response may include a partial list + * and a caller should only rely on response's + * `next_page_token` google.cloud.redis.v1beta1.ListInstancesResponse.next_page_token + * to determine if there are more instances left to be queried. + */ + // const pageSize = 1234 + /** + * The `next_page_token` value returned from a previous + * ListInstances google.cloud.redis.v1beta1.CloudRedis.ListInstances request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callListInstances() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await redisClient.listInstancesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListInstances(); + // [END redis_v1beta1_generated_CloudRedis_ListInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.reschedule_maintenance.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.reschedule_maintenance.js new file mode 100644 index 00000000000..c7b2b459326 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.reschedule_maintenance.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(name, rescheduleType) { + // [START redis_v1beta1_generated_CloudRedis_RescheduleMaintenance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + */ + // const name = 'abc123' + /** + * Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well. + */ + // const rescheduleType = {} + /** + * Optional. Timestamp when the maintenance shall be rescheduled to if + * reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for + * example `2012-11-15T16:19:00.094Z`. + */ + // const scheduleTime = {} + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callRescheduleMaintenance() { + // Construct request + const request = { + name, + rescheduleType, + }; + + // Run request + const [operation] = await redisClient.rescheduleMaintenance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRescheduleMaintenance(); + // [END redis_v1beta1_generated_CloudRedis_RescheduleMaintenance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.update_instance.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.update_instance.js new file mode 100644 index 00000000000..3024cd3c736 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.update_instance.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(updateMask, instance) { + // [START redis_v1beta1_generated_CloudRedis_UpdateInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Mask of fields to update. At least one path must be supplied in + * this field. The elements of the repeated paths field may only include these + * fields from Instance google.cloud.redis.v1beta1.Instance: + * * `displayName` + * * `labels` + * * `memorySizeGb` + * * `redisConfig` + * * `replica_count` + */ + // const updateMask = {} + /** + * Required. Update description. + * Only fields specified in update_mask are updated. + */ + // const instance = {} + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callUpdateInstance() { + // Construct request + const request = { + updateMask, + instance, + }; + + // Run request + const [operation] = await redisClient.updateInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateInstance(); + // [END redis_v1beta1_generated_CloudRedis_UpdateInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.upgrade_instance.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.upgrade_instance.js new file mode 100644 index 00000000000..85c9c26c058 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.upgrade_instance.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(name, redisVersion) { + // [START redis_v1beta1_generated_CloudRedis_UpgradeInstance_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + */ + // const name = 'abc123' + /** + * Required. Specifies the target version of Redis software to upgrade to. + */ + // const redisVersion = 'abc123' + + // Imports the Redis library + const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; + + // Instantiates a client + const redisClient = new CloudRedisClient(); + + async function callUpgradeInstance() { + // Construct request + const request = { + name, + redisVersion, + }; + + // Run request + const [operation] = await redisClient.upgradeInstance(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpgradeInstance(); + // [END redis_v1beta1_generated_CloudRedis_UpgradeInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.redis.v1beta1.json b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.redis.v1beta1.json new file mode 100644 index 00000000000..8354487f3c4 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.redis.v1beta1.json @@ -0,0 +1,499 @@ +{ + "clientLibrary": { + "name": "nodejs-redis", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.redis.v1beta1", + "version": "v1beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "redis_v1beta1_generated_CloudRedis_ListInstances_async", + "title": "CloudRedis listInstances Sample", + "origin": "API_DEFINITION", + "description": " Lists all Redis instances owned by a project in either the specified location (region) or all locations. The location should have the following format: * `projects/{project_id}/locations/{location_id}` If `location_id` is specified as `-` (wildcard), then all regions available to the project are queried, and the results are aggregated.", + "canonical": true, + "file": "cloud_redis.list_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListInstances", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.ListInstances", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.redis.v1beta1.ListInstancesResponse", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" + }, + "method": { + "shortName": "ListInstances", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.ListInstances", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1beta1.CloudRedis" + } + } + } + }, + { + "regionTag": "redis_v1beta1_generated_CloudRedis_GetInstance_async", + "title": "CloudRedis getInstance Sample", + "origin": "API_DEFINITION", + "description": " Gets the details of a specific Redis instance.", + "canonical": true, + "file": "cloud_redis.get_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetInstance", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.GetInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.redis.v1beta1.Instance", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" + }, + "method": { + "shortName": "GetInstance", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.GetInstance", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1beta1.CloudRedis" + } + } + } + }, + { + "regionTag": "redis_v1beta1_generated_CloudRedis_GetInstanceAuthString_async", + "title": "CloudRedis getInstanceAuthString Sample", + "origin": "API_DEFINITION", + "description": " Gets the AUTH string for a Redis instance. If AUTH is not enabled for the instance the response will be empty. This information is not included in the details returned to GetInstance.", + "canonical": true, + "file": "cloud_redis.get_instance_auth_string.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetInstanceAuthString", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.GetInstanceAuthString", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.redis.v1beta1.InstanceAuthString", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" + }, + "method": { + "shortName": "GetInstanceAuthString", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.GetInstanceAuthString", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1beta1.CloudRedis" + } + } + } + }, + { + "regionTag": "redis_v1beta1_generated_CloudRedis_CreateInstance_async", + "title": "CloudRedis createInstance Sample", + "origin": "API_DEFINITION", + "description": " Creates a Redis instance based on the specified tier and memory size. By default, the instance is accessible from the project's [default network](https://cloud.google.com/vpc/docs/vpc). The creation is executed asynchronously and callers may check the returned operation to track its progress. Once the operation is completed the Redis instance will be fully functional. The completed longrunning.Operation will contain the new instance object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.", + "canonical": true, + "file": "cloud_redis.create_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateInstance", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.CreateInstance", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "instance_id", + "type": "TYPE_STRING" + }, + { + "name": "instance", + "type": ".google.cloud.redis.v1beta1.Instance" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" + }, + "method": { + "shortName": "CreateInstance", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.CreateInstance", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1beta1.CloudRedis" + } + } + } + }, + { + "regionTag": "redis_v1beta1_generated_CloudRedis_UpdateInstance_async", + "title": "CloudRedis updateInstance Sample", + "origin": "API_DEFINITION", + "description": " Updates the metadata and configuration of a specific Redis instance. Completed longrunning.Operation will contain the new instance object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.", + "canonical": true, + "file": "cloud_redis.update_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateInstance", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.UpdateInstance", + "async": true, + "parameters": [ + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "instance", + "type": ".google.cloud.redis.v1beta1.Instance" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" + }, + "method": { + "shortName": "UpdateInstance", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.UpdateInstance", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1beta1.CloudRedis" + } + } + } + }, + { + "regionTag": "redis_v1beta1_generated_CloudRedis_UpgradeInstance_async", + "title": "CloudRedis upgradeInstance Sample", + "origin": "API_DEFINITION", + "description": " Upgrades Redis instance to the newer Redis version specified in the request.", + "canonical": true, + "file": "cloud_redis.upgrade_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpgradeInstance", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.UpgradeInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "redis_version", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" + }, + "method": { + "shortName": "UpgradeInstance", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.UpgradeInstance", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1beta1.CloudRedis" + } + } + } + }, + { + "regionTag": "redis_v1beta1_generated_CloudRedis_ImportInstance_async", + "title": "CloudRedis importInstance Sample", + "origin": "API_DEFINITION", + "description": " Import a Redis RDB snapshot file from Cloud Storage into a Redis instance. Redis may stop serving during this operation. Instance state will be IMPORTING for entire operation. When complete, the instance will contain only data from the imported file. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.", + "canonical": true, + "file": "cloud_redis.import_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportInstance", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.ImportInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.redis.v1beta1.InputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" + }, + "method": { + "shortName": "ImportInstance", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.ImportInstance", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1beta1.CloudRedis" + } + } + } + }, + { + "regionTag": "redis_v1beta1_generated_CloudRedis_ExportInstance_async", + "title": "CloudRedis exportInstance Sample", + "origin": "API_DEFINITION", + "description": " Export Redis instance data into a Redis RDB format file in Cloud Storage. Redis will continue serving during this operation. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.", + "canonical": true, + "file": "cloud_redis.export_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ExportInstance", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.ExportInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "output_config", + "type": ".google.cloud.redis.v1beta1.OutputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" + }, + "method": { + "shortName": "ExportInstance", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.ExportInstance", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1beta1.CloudRedis" + } + } + } + }, + { + "regionTag": "redis_v1beta1_generated_CloudRedis_FailoverInstance_async", + "title": "CloudRedis failoverInstance Sample", + "origin": "API_DEFINITION", + "description": " Initiates a failover of the primary node to current replica node for a specific STANDARD tier Cloud Memorystore for Redis instance.", + "canonical": true, + "file": "cloud_redis.failover_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "FailoverInstance", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.FailoverInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "data_protection_mode", + "type": ".google.cloud.redis.v1beta1.FailoverInstanceRequest.DataProtectionMode" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" + }, + "method": { + "shortName": "FailoverInstance", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.FailoverInstance", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1beta1.CloudRedis" + } + } + } + }, + { + "regionTag": "redis_v1beta1_generated_CloudRedis_DeleteInstance_async", + "title": "CloudRedis deleteInstance Sample", + "origin": "API_DEFINITION", + "description": " Deletes a specific Redis instance. Instance stops serving and data is deleted.", + "canonical": true, + "file": "cloud_redis.delete_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteInstance", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.DeleteInstance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" + }, + "method": { + "shortName": "DeleteInstance", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.DeleteInstance", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1beta1.CloudRedis" + } + } + } + }, + { + "regionTag": "redis_v1beta1_generated_CloudRedis_RescheduleMaintenance_async", + "title": "CloudRedis rescheduleMaintenance Sample", + "origin": "API_DEFINITION", + "description": " Reschedule maintenance for a given instance in a given project and location.", + "canonical": true, + "file": "cloud_redis.reschedule_maintenance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RescheduleMaintenance", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.RescheduleMaintenance", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "reschedule_type", + "type": ".google.cloud.redis.v1beta1.RescheduleMaintenanceRequest.RescheduleType" + }, + { + "name": "schedule_time", + "type": ".google.protobuf.Timestamp" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CloudRedisClient", + "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" + }, + "method": { + "shortName": "RescheduleMaintenance", + "fullName": "google.cloud.redis.v1beta1.CloudRedis.RescheduleMaintenance", + "service": { + "shortName": "CloudRedis", + "fullName": "google.cloud.redis.v1beta1.CloudRedis" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-redis/v1beta1/src/index.ts new file mode 100644 index 00000000000..2ece0fa6907 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1beta1 from './v1beta1'; +const CloudRedisClient = v1beta1.CloudRedisClient; +type CloudRedisClient = v1beta1.CloudRedisClient; +export {v1beta1, CloudRedisClient}; +export default {v1beta1, CloudRedisClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_client.ts b/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_client.ts new file mode 100644 index 00000000000..01fe717f251 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_client.ts @@ -0,0 +1,1659 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta1/cloud_redis_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './cloud_redis_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Configures and manages Cloud Memorystore for Redis instances + * + * Google Cloud Memorystore for Redis v1beta1 + * + * The `redis.googleapis.com` service implements the Google Cloud Memorystore + * for Redis API and defines the following resource model for managing Redis + * instances: + * * The service works with a collection of cloud projects, named: `/projects/*` + * * Each project has a collection of available locations, named: `/locations/*` + * * Each location has a collection of Redis instances, named: `/instances/*` + * * As such, Redis instances are resources of the form: + * `/projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * + * Note that location_id must be referring to a GCP `region`; for example: + * * `projects/redpepper-1290/locations/us-central1/instances/my-redis` + * @class + * @memberof v1beta1 + */ +export class CloudRedisClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + cloudRedisStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CloudRedisClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 CloudRedisClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CloudRedisClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + instancePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/instances/{instance}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + }; + + // 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 = { + listInstances: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instances') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta1/{name=projects/*}/locations',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta1/{name=projects/*/locations/*/operations/*}:cancel',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta1/{name=projects/*/locations/*}/operations',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.redis.v1beta1.Instance') as gax.protobuf.Type; + const createInstanceMetadata = protoFilesRoot.lookup( + '.google.protobuf.Any') as gax.protobuf.Type; + const updateInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.redis.v1beta1.Instance') as gax.protobuf.Type; + const updateInstanceMetadata = protoFilesRoot.lookup( + '.google.protobuf.Any') as gax.protobuf.Type; + const upgradeInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.redis.v1beta1.Instance') as gax.protobuf.Type; + const upgradeInstanceMetadata = protoFilesRoot.lookup( + '.google.protobuf.Any') as gax.protobuf.Type; + const importInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.redis.v1beta1.Instance') as gax.protobuf.Type; + const importInstanceMetadata = protoFilesRoot.lookup( + '.google.protobuf.Any') as gax.protobuf.Type; + const exportInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.redis.v1beta1.Instance') as gax.protobuf.Type; + const exportInstanceMetadata = protoFilesRoot.lookup( + '.google.protobuf.Any') as gax.protobuf.Type; + const failoverInstanceResponse = protoFilesRoot.lookup( + '.google.cloud.redis.v1beta1.Instance') as gax.protobuf.Type; + const failoverInstanceMetadata = protoFilesRoot.lookup( + '.google.protobuf.Any') as gax.protobuf.Type; + const deleteInstanceResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteInstanceMetadata = protoFilesRoot.lookup( + '.google.protobuf.Any') as gax.protobuf.Type; + const rescheduleMaintenanceResponse = protoFilesRoot.lookup( + '.google.cloud.redis.v1beta1.Instance') as gax.protobuf.Type; + const rescheduleMaintenanceMetadata = protoFilesRoot.lookup( + '.google.protobuf.Any') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createInstanceResponse.decode.bind(createInstanceResponse), + createInstanceMetadata.decode.bind(createInstanceMetadata)), + updateInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateInstanceResponse.decode.bind(updateInstanceResponse), + updateInstanceMetadata.decode.bind(updateInstanceMetadata)), + upgradeInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + upgradeInstanceResponse.decode.bind(upgradeInstanceResponse), + upgradeInstanceMetadata.decode.bind(upgradeInstanceMetadata)), + importInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importInstanceResponse.decode.bind(importInstanceResponse), + importInstanceMetadata.decode.bind(importInstanceMetadata)), + exportInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + exportInstanceResponse.decode.bind(exportInstanceResponse), + exportInstanceMetadata.decode.bind(exportInstanceMetadata)), + failoverInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + failoverInstanceResponse.decode.bind(failoverInstanceResponse), + failoverInstanceMetadata.decode.bind(failoverInstanceMetadata)), + deleteInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteInstanceResponse.decode.bind(deleteInstanceResponse), + deleteInstanceMetadata.decode.bind(deleteInstanceMetadata)), + rescheduleMaintenance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + rescheduleMaintenanceResponse.decode.bind(rescheduleMaintenanceResponse), + rescheduleMaintenanceMetadata.decode.bind(rescheduleMaintenanceMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.redis.v1beta1.CloudRedis', 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.cloudRedisStub) { + return this.cloudRedisStub; + } + + // Put together the "service stub" for + // google.cloud.redis.v1beta1.CloudRedis. + this.cloudRedisStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.redis.v1beta1.CloudRedis') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.redis.v1beta1.CloudRedis, + 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 cloudRedisStubMethods = + ['listInstances', 'getInstance', 'getInstanceAuthString', 'createInstance', 'updateInstance', 'upgradeInstance', 'importInstance', 'exportInstance', 'failoverInstance', 'deleteInstance', 'rescheduleMaintenance']; + for (const methodName of cloudRedisStubMethods) { + const callPromise = this.cloudRedisStub.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.cloudRedisStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'redis.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 'redis.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 the details of a specific Redis instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.redis.v1beta1.Instance|Instance}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_redis.get_instance.js + * region_tag:redis_v1beta1_generated_CloudRedis_GetInstance_async + */ + getInstance( + request?: protos.google.cloud.redis.v1beta1.IGetInstanceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.redis.v1beta1.IInstance, + protos.google.cloud.redis.v1beta1.IGetInstanceRequest|undefined, {}|undefined + ]>; + getInstance( + request: protos.google.cloud.redis.v1beta1.IGetInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.redis.v1beta1.IInstance, + protos.google.cloud.redis.v1beta1.IGetInstanceRequest|null|undefined, + {}|null|undefined>): void; + getInstance( + request: protos.google.cloud.redis.v1beta1.IGetInstanceRequest, + callback: Callback< + protos.google.cloud.redis.v1beta1.IInstance, + protos.google.cloud.redis.v1beta1.IGetInstanceRequest|null|undefined, + {}|null|undefined>): void; + getInstance( + request?: protos.google.cloud.redis.v1beta1.IGetInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.redis.v1beta1.IInstance, + protos.google.cloud.redis.v1beta1.IGetInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.redis.v1beta1.IInstance, + protos.google.cloud.redis.v1beta1.IGetInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.redis.v1beta1.IInstance, + protos.google.cloud.redis.v1beta1.IGetInstanceRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getInstance(request, options, callback); + } +/** + * Gets the AUTH string for a Redis instance. If AUTH is not enabled for the + * instance the response will be empty. This information is not included in + * the details returned to GetInstance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.redis.v1beta1.InstanceAuthString|InstanceAuthString}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_redis.get_instance_auth_string.js + * region_tag:redis_v1beta1_generated_CloudRedis_GetInstanceAuthString_async + */ + getInstanceAuthString( + request?: protos.google.cloud.redis.v1beta1.IGetInstanceAuthStringRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.redis.v1beta1.IInstanceAuthString, + protos.google.cloud.redis.v1beta1.IGetInstanceAuthStringRequest|undefined, {}|undefined + ]>; + getInstanceAuthString( + request: protos.google.cloud.redis.v1beta1.IGetInstanceAuthStringRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.redis.v1beta1.IInstanceAuthString, + protos.google.cloud.redis.v1beta1.IGetInstanceAuthStringRequest|null|undefined, + {}|null|undefined>): void; + getInstanceAuthString( + request: protos.google.cloud.redis.v1beta1.IGetInstanceAuthStringRequest, + callback: Callback< + protos.google.cloud.redis.v1beta1.IInstanceAuthString, + protos.google.cloud.redis.v1beta1.IGetInstanceAuthStringRequest|null|undefined, + {}|null|undefined>): void; + getInstanceAuthString( + request?: protos.google.cloud.redis.v1beta1.IGetInstanceAuthStringRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.redis.v1beta1.IInstanceAuthString, + protos.google.cloud.redis.v1beta1.IGetInstanceAuthStringRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.redis.v1beta1.IInstanceAuthString, + protos.google.cloud.redis.v1beta1.IGetInstanceAuthStringRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.redis.v1beta1.IInstanceAuthString, + protos.google.cloud.redis.v1beta1.IGetInstanceAuthStringRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getInstanceAuthString(request, options, callback); + } + +/** + * Creates a Redis instance based on the specified tier and memory size. + * + * By default, the instance is accessible from the project's + * [default network](https://cloud.google.com/vpc/docs/vpc). + * + * The creation is executed asynchronously and callers may check the returned + * operation to track its progress. Once the operation is completed the Redis + * instance will be fully functional. The completed longrunning.Operation will + * contain the new instance object in the response field. + * + * The returned operation is automatically deleted after a few hours, so there + * is no need to call DeleteOperation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the instance location using the form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a GCP region. + * @param {string} request.instanceId + * Required. The logical name of the Redis instance in the customer project + * with the following restrictions: + * + * * Must contain only lowercase letters, numbers, and hyphens. + * * Must start with a letter. + * * Must be between 1-40 characters. + * * Must end with a number or a letter. + * * Must be unique within the customer project / location + * @param {google.cloud.redis.v1beta1.Instance} request.instance + * Required. A Redis [Instance] resource + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_redis.create_instance.js + * region_tag:redis_v1beta1_generated_CloudRedis_CreateInstance_async + */ + createInstance( + request?: protos.google.cloud.redis.v1beta1.ICreateInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createInstance( + request: protos.google.cloud.redis.v1beta1.ICreateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createInstance( + request: protos.google.cloud.redis.v1beta1.ICreateInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createInstance( + request?: protos.google.cloud.redis.v1beta1.ICreateInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_redis.create_instance.js + * region_tag:redis_v1beta1_generated_CloudRedis_CreateInstance_async + */ + async checkCreateInstanceProgress(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.createInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the metadata and configuration of a specific Redis instance. + * + * Completed longrunning.Operation will contain the new instance object + * in the response field. The returned operation is automatically deleted + * after a few hours, so there is no need to call DeleteOperation. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields to update. At least one path must be supplied in + * this field. The elements of the repeated paths field may only include these + * fields from {@link protos.google.cloud.redis.v1beta1.Instance|Instance}: + * + * * `displayName` + * * `labels` + * * `memorySizeGb` + * * `redisConfig` + * * `replica_count` + * @param {google.cloud.redis.v1beta1.Instance} request.instance + * Required. Update description. + * Only fields specified in update_mask 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_redis.update_instance.js + * region_tag:redis_v1beta1_generated_CloudRedis_UpdateInstance_async + */ + updateInstance( + request?: protos.google.cloud.redis.v1beta1.IUpdateInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateInstance( + request: protos.google.cloud.redis.v1beta1.IUpdateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateInstance( + request: protos.google.cloud.redis.v1beta1.IUpdateInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateInstance( + request?: protos.google.cloud.redis.v1beta1.IUpdateInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'instance.name': request.instance!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_redis.update_instance.js + * region_tag:redis_v1beta1_generated_CloudRedis_UpdateInstance_async + */ + async checkUpdateInstanceProgress(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.updateInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Upgrades Redis instance to the newer Redis version specified in the + * request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + * @param {string} request.redisVersion + * Required. Specifies the target version of Redis software to upgrade to. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_redis.upgrade_instance.js + * region_tag:redis_v1beta1_generated_CloudRedis_UpgradeInstance_async + */ + upgradeInstance( + request?: protos.google.cloud.redis.v1beta1.IUpgradeInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + upgradeInstance( + request: protos.google.cloud.redis.v1beta1.IUpgradeInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + upgradeInstance( + request: protos.google.cloud.redis.v1beta1.IUpgradeInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + upgradeInstance( + request?: protos.google.cloud.redis.v1beta1.IUpgradeInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.upgradeInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `upgradeInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_redis.upgrade_instance.js + * region_tag:redis_v1beta1_generated_CloudRedis_UpgradeInstance_async + */ + async checkUpgradeInstanceProgress(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.upgradeInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Import a Redis RDB snapshot file from Cloud Storage into a Redis instance. + * + * Redis may stop serving during this operation. Instance state will be + * IMPORTING for entire operation. When complete, the instance will contain + * only data from the imported file. + * + * The returned operation is automatically deleted after a few hours, so + * there is no need to call DeleteOperation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + * @param {google.cloud.redis.v1beta1.InputConfig} request.inputConfig + * Required. Specify data to be imported. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_redis.import_instance.js + * region_tag:redis_v1beta1_generated_CloudRedis_ImportInstance_async + */ + importInstance( + request?: protos.google.cloud.redis.v1beta1.IImportInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importInstance( + request: protos.google.cloud.redis.v1beta1.IImportInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importInstance( + request: protos.google.cloud.redis.v1beta1.IImportInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importInstance( + request?: protos.google.cloud.redis.v1beta1.IImportInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.importInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_redis.import_instance.js + * region_tag:redis_v1beta1_generated_CloudRedis_ImportInstance_async + */ + async checkImportInstanceProgress(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.importInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Export Redis instance data into a Redis RDB format file in Cloud Storage. + * + * Redis will continue serving during this operation. + * + * The returned operation is automatically deleted after a few hours, so + * there is no need to call DeleteOperation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + * @param {google.cloud.redis.v1beta1.OutputConfig} request.outputConfig + * Required. Specify data to be exported. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_redis.export_instance.js + * region_tag:redis_v1beta1_generated_CloudRedis_ExportInstance_async + */ + exportInstance( + request?: protos.google.cloud.redis.v1beta1.IExportInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + exportInstance( + request: protos.google.cloud.redis.v1beta1.IExportInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + exportInstance( + request: protos.google.cloud.redis.v1beta1.IExportInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + exportInstance( + request?: protos.google.cloud.redis.v1beta1.IExportInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.exportInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `exportInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_redis.export_instance.js + * region_tag:redis_v1beta1_generated_CloudRedis_ExportInstance_async + */ + async checkExportInstanceProgress(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.exportInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Initiates a failover of the primary node to current replica node for a + * specific STANDARD tier Cloud Memorystore for Redis instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + * @param {google.cloud.redis.v1beta1.FailoverInstanceRequest.DataProtectionMode} [request.dataProtectionMode] + * Optional. Available data protection modes that the user can choose. If it's + * unspecified, data protection mode will be LIMITED_DATA_LOSS by default. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_redis.failover_instance.js + * region_tag:redis_v1beta1_generated_CloudRedis_FailoverInstance_async + */ + failoverInstance( + request?: protos.google.cloud.redis.v1beta1.IFailoverInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + failoverInstance( + request: protos.google.cloud.redis.v1beta1.IFailoverInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + failoverInstance( + request: protos.google.cloud.redis.v1beta1.IFailoverInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + failoverInstance( + request?: protos.google.cloud.redis.v1beta1.IFailoverInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.failoverInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `failoverInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_redis.failover_instance.js + * region_tag:redis_v1beta1_generated_CloudRedis_FailoverInstance_async + */ + async checkFailoverInstanceProgress(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.failoverInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a specific Redis instance. Instance stops serving and data is + * deleted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_redis.delete_instance.js + * region_tag:redis_v1beta1_generated_CloudRedis_DeleteInstance_async + */ + deleteInstance( + request?: protos.google.cloud.redis.v1beta1.IDeleteInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteInstance( + request: protos.google.cloud.redis.v1beta1.IDeleteInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteInstance( + request: protos.google.cloud.redis.v1beta1.IDeleteInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteInstance( + request?: protos.google.cloud.redis.v1beta1.IDeleteInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_redis.delete_instance.js + * region_tag:redis_v1beta1_generated_CloudRedis_DeleteInstance_async + */ + async checkDeleteInstanceProgress(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.deleteInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Reschedule maintenance for a given instance in a given project and + * location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Redis instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + * @param {google.cloud.redis.v1beta1.RescheduleMaintenanceRequest.RescheduleType} request.rescheduleType + * Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well. + * @param {google.protobuf.Timestamp} [request.scheduleTime] + * Optional. Timestamp when the maintenance shall be rescheduled to if + * reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for + * example `2012-11-15T16:19:00.094Z`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_redis.reschedule_maintenance.js + * region_tag:redis_v1beta1_generated_CloudRedis_RescheduleMaintenance_async + */ + rescheduleMaintenance( + request?: protos.google.cloud.redis.v1beta1.IRescheduleMaintenanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + rescheduleMaintenance( + request: protos.google.cloud.redis.v1beta1.IRescheduleMaintenanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + rescheduleMaintenance( + request: protos.google.cloud.redis.v1beta1.IRescheduleMaintenanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + rescheduleMaintenance( + request?: protos.google.cloud.redis.v1beta1.IRescheduleMaintenanceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.rescheduleMaintenance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `rescheduleMaintenance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_redis.reschedule_maintenance.js + * region_tag:redis_v1beta1_generated_CloudRedis_RescheduleMaintenance_async + */ + async checkRescheduleMaintenanceProgress(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.rescheduleMaintenance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists all Redis instances owned by a project in either the specified + * location (region) or all locations. + * + * The location should have the following format: + * + * * `projects/{project_id}/locations/{location_id}` + * + * If `location_id` is specified as `-` (wildcard), then all regions + * available to the project are queried, and the results are aggregated. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the instance location using the form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a GCP region. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 1000 will be used by the service. + * Regardless of the page_size value, the response may include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.redis.v1beta1.ListInstancesResponse.next_page_token|`next_page_token`} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous + * {@link protos.google.cloud.redis.v1beta1.CloudRedis.ListInstances|ListInstances} request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.redis.v1beta1.Instance|Instance}. + * 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 `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listInstances( + request?: protos.google.cloud.redis.v1beta1.IListInstancesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.redis.v1beta1.IInstance[], + protos.google.cloud.redis.v1beta1.IListInstancesRequest|null, + protos.google.cloud.redis.v1beta1.IListInstancesResponse + ]>; + listInstances( + request: protos.google.cloud.redis.v1beta1.IListInstancesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.redis.v1beta1.IListInstancesRequest, + protos.google.cloud.redis.v1beta1.IListInstancesResponse|null|undefined, + protos.google.cloud.redis.v1beta1.IInstance>): void; + listInstances( + request: protos.google.cloud.redis.v1beta1.IListInstancesRequest, + callback: PaginationCallback< + protos.google.cloud.redis.v1beta1.IListInstancesRequest, + protos.google.cloud.redis.v1beta1.IListInstancesResponse|null|undefined, + protos.google.cloud.redis.v1beta1.IInstance>): void; + listInstances( + request?: protos.google.cloud.redis.v1beta1.IListInstancesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.redis.v1beta1.IListInstancesRequest, + protos.google.cloud.redis.v1beta1.IListInstancesResponse|null|undefined, + protos.google.cloud.redis.v1beta1.IInstance>, + callback?: PaginationCallback< + protos.google.cloud.redis.v1beta1.IListInstancesRequest, + protos.google.cloud.redis.v1beta1.IListInstancesResponse|null|undefined, + protos.google.cloud.redis.v1beta1.IInstance>): + Promise<[ + protos.google.cloud.redis.v1beta1.IInstance[], + protos.google.cloud.redis.v1beta1.IListInstancesRequest|null, + protos.google.cloud.redis.v1beta1.IListInstancesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listInstances(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the instance location using the form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a GCP region. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 1000 will be used by the service. + * Regardless of the page_size value, the response may include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.redis.v1beta1.ListInstancesResponse.next_page_token|`next_page_token`} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous + * {@link protos.google.cloud.redis.v1beta1.CloudRedis.ListInstances|ListInstances} request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.redis.v1beta1.Instance|Instance} 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 `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listInstancesStream( + request?: protos.google.cloud.redis.v1beta1.IListInstancesRequest, + 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['listInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInstances.createStream( + this.innerApiCalls.listInstances as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listInstances`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the instance location using the form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a GCP region. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 1000 will be used by the service. + * Regardless of the page_size value, the response may include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.redis.v1beta1.ListInstancesResponse.next_page_token|`next_page_token`} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous + * {@link protos.google.cloud.redis.v1beta1.CloudRedis.ListInstances|ListInstances} request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.redis.v1beta1.Instance|Instance}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_redis.list_instances.js + * region_tag:redis_v1beta1_generated_CloudRedis_ListInstances_async + */ + listInstancesAsync( + request?: protos.google.cloud.redis.v1beta1.IListInstancesRequest, + 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['listInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInstances.asyncIterate( + this.innerApiCalls['listInstances'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified instance resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} instance + * @returns {string} Resource name string. + */ + instancePath(project:string,location:string,instance:string) { + return this.pathTemplates.instancePathTemplate.render({ + project: project, + location: location, + instance: instance, + }); + } + + /** + * Parse the project from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the project. + */ + matchProjectFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).project; + } + + /** + * Parse the location from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the location. + */ + matchLocationFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).location; + } + + /** + * Parse the instance from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).instance; + } + + /** + * 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; + } + + /** + * 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.cloudRedisStub && !this._terminated) { + return this.cloudRedisStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_client_config.json b/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_client_config.json new file mode 100644 index 00000000000..fc33fa45d6f --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_client_config.json @@ -0,0 +1,80 @@ +{ + "interfaces": { + "google.cloud.redis.v1beta1.CloudRedis": { + "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": { + "ListInstances": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetInstance": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetInstanceAuthString": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateInstance": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateInstance": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpgradeInstance": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ImportInstance": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ExportInstance": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "FailoverInstance": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteInstance": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RescheduleMaintenance": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_proto_list.json b/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_proto_list.json new file mode 100644 index 00000000000..6cd14735515 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/redis/v1beta1/cloud_redis.proto" +] diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/gapic_metadata.json new file mode 100644 index 00000000000..6ec65068a1d --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/gapic_metadata.json @@ -0,0 +1,137 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.redis.v1beta1", + "libraryPackage": "@google-cloud/redis", + "services": { + "CloudRedis": { + "clients": { + "grpc": { + "libraryClient": "CloudRedisClient", + "rpcs": { + "GetInstance": { + "methods": [ + "getInstance" + ] + }, + "GetInstanceAuthString": { + "methods": [ + "getInstanceAuthString" + ] + }, + "CreateInstance": { + "methods": [ + "createInstance" + ] + }, + "UpdateInstance": { + "methods": [ + "updateInstance" + ] + }, + "UpgradeInstance": { + "methods": [ + "upgradeInstance" + ] + }, + "ImportInstance": { + "methods": [ + "importInstance" + ] + }, + "ExportInstance": { + "methods": [ + "exportInstance" + ] + }, + "FailoverInstance": { + "methods": [ + "failoverInstance" + ] + }, + "DeleteInstance": { + "methods": [ + "deleteInstance" + ] + }, + "RescheduleMaintenance": { + "methods": [ + "rescheduleMaintenance" + ] + }, + "ListInstances": { + "methods": [ + "listInstances", + "listInstancesStream", + "listInstancesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CloudRedisClient", + "rpcs": { + "GetInstance": { + "methods": [ + "getInstance" + ] + }, + "GetInstanceAuthString": { + "methods": [ + "getInstanceAuthString" + ] + }, + "CreateInstance": { + "methods": [ + "createInstance" + ] + }, + "UpdateInstance": { + "methods": [ + "updateInstance" + ] + }, + "UpgradeInstance": { + "methods": [ + "upgradeInstance" + ] + }, + "ImportInstance": { + "methods": [ + "importInstance" + ] + }, + "ExportInstance": { + "methods": [ + "exportInstance" + ] + }, + "FailoverInstance": { + "methods": [ + "failoverInstance" + ] + }, + "DeleteInstance": { + "methods": [ + "deleteInstance" + ] + }, + "RescheduleMaintenance": { + "methods": [ + "rescheduleMaintenance" + ] + }, + "ListInstances": { + "methods": [ + "listInstances", + "listInstancesStream", + "listInstancesAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/index.ts new file mode 100644 index 00000000000..036e9efba28 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {CloudRedisClient} from './cloud_redis_client'; diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-redis/v1beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..bb242f40531 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const redis = require('@google-cloud/redis'); + +function main() { + const cloudRedisClient = new redis.CloudRedisClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-redis/v1beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..b6c5a1f5f69 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {CloudRedisClient} from '@google-cloud/redis'; + +// check that the client class type name can be used +function doStuffWithCloudRedisClient(client: CloudRedisClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const cloudRedisClient = new CloudRedisClient(); + doStuffWithCloudRedisClient(cloudRedisClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-redis/v1beta1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/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-redis/v1beta1/test/gapic_cloud_redis_v1beta1.ts b/owl-bot-staging/google-cloud-redis/v1beta1/test/gapic_cloud_redis_v1beta1.ts new file mode 100644 index 00000000000..18ca04c7686 --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/test/gapic_cloud_redis_v1beta1.ts @@ -0,0 +1,1997 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 cloudredisModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1beta1.CloudRedisClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = cloudredisModule.v1beta1.CloudRedisClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = cloudredisModule.v1beta1.CloudRedisClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = cloudredisModule.v1beta1.CloudRedisClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudRedisStub, undefined); + await client.initialize(); + assert(client.cloudRedisStub); + }); + + it('has close method for the initialized client', done => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.cloudRedisStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudRedisStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + 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 cloudredisModule.v1beta1.CloudRedisClient({ + 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('getInstance', () => { + it('invokes getInstance without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.Instance() + ); + client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); + const [response] = await client.getInstance(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstance without error using callback', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.Instance() + ); + client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstance( + request, + (err?: Error|null, result?: protos.google.cloud.redis.v1beta1.IInstance|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstance with error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstance with closed client', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getInstance(request), expectedError); + }); + }); + + describe('getInstanceAuthString', () => { + it('invokes getInstanceAuthString without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.GetInstanceAuthStringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.GetInstanceAuthStringRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.InstanceAuthString() + ); + client.innerApiCalls.getInstanceAuthString = stubSimpleCall(expectedResponse); + const [response] = await client.getInstanceAuthString(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstanceAuthString as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstanceAuthString as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstanceAuthString without error using callback', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.GetInstanceAuthStringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.GetInstanceAuthStringRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.InstanceAuthString() + ); + client.innerApiCalls.getInstanceAuthString = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstanceAuthString( + request, + (err?: Error|null, result?: protos.google.cloud.redis.v1beta1.IInstanceAuthString|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstanceAuthString as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstanceAuthString as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstanceAuthString with error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.GetInstanceAuthStringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.GetInstanceAuthStringRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstanceAuthString = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getInstanceAuthString(request), expectedError); + const actualRequest = (client.innerApiCalls.getInstanceAuthString as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstanceAuthString as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstanceAuthString with closed client', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.GetInstanceAuthStringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.GetInstanceAuthStringRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getInstanceAuthString(request), expectedError); + }); + }); + + describe('createInstance', () => { + it('invokes createInstance without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.createInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstance without error using callback', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createInstance( + request, + (err?: Error|null, + result?: 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.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstance with call error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstance with LRO error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateInstanceProgress without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateInstanceProgress with error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateInstance', () => { + it('invokes updateInstance without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.UpdateInstanceRequest() + ); + request.instance ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.UpdateInstanceRequest', ['instance', 'name']); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstance without error using callback', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.UpdateInstanceRequest() + ); + request.instance ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.UpdateInstanceRequest', ['instance', 'name']); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateInstance( + request, + (err?: Error|null, + result?: 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.updateInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstance with call error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.UpdateInstanceRequest() + ); + request.instance ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.UpdateInstanceRequest', ['instance', 'name']); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstance with LRO error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.UpdateInstanceRequest() + ); + request.instance ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.UpdateInstanceRequest', ['instance', 'name']); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateInstanceProgress without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateInstanceProgress with error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('upgradeInstance', () => { + it('invokes upgradeInstance without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.UpgradeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.UpgradeInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.upgradeInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.upgradeInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeInstance without error using callback', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.UpgradeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.UpgradeInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.upgradeInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.upgradeInstance( + request, + (err?: Error|null, + result?: 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.upgradeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeInstance with call error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.UpgradeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.UpgradeInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.upgradeInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes upgradeInstance with LRO error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.UpgradeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.UpgradeInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.upgradeInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpgradeInstanceProgress without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpgradeInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpgradeInstanceProgress with error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpgradeInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('importInstance', () => { + it('invokes importInstance without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.ImportInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.ImportInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.importInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.importInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importInstance without error using callback', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.ImportInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.ImportInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importInstance( + request, + (err?: Error|null, + result?: 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.importInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importInstance with call error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.ImportInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.ImportInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.importInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importInstance with LRO error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.ImportInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.ImportInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportInstanceProgress without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportInstanceProgress with error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('exportInstance', () => { + it('invokes exportInstance without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.ExportInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.ExportInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.exportInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.exportInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.exportInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.exportInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes exportInstance without error using callback', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.ExportInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.ExportInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.exportInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.exportInstance( + request, + (err?: Error|null, + result?: 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.exportInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.exportInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes exportInstance with call error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.ExportInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.ExportInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.exportInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.exportInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.exportInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.exportInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes exportInstance with LRO error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.ExportInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.ExportInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.exportInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.exportInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.exportInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.exportInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkExportInstanceProgress without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkExportInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkExportInstanceProgress with error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkExportInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('failoverInstance', () => { + it('invokes failoverInstance without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.FailoverInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.FailoverInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.failoverInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.failoverInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.failoverInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.failoverInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes failoverInstance without error using callback', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.FailoverInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.FailoverInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.failoverInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.failoverInstance( + request, + (err?: Error|null, + result?: 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.failoverInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.failoverInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes failoverInstance with call error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.FailoverInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.FailoverInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.failoverInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.failoverInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.failoverInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.failoverInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes failoverInstance with LRO error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.FailoverInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.FailoverInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.failoverInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.failoverInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.failoverInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.failoverInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkFailoverInstanceProgress without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkFailoverInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkFailoverInstanceProgress with error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkFailoverInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteInstance', () => { + it('invokes deleteInstance without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstance without error using callback', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteInstance( + request, + (err?: Error|null, + result?: 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.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstance with call error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstance with LRO error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteInstanceProgress without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteInstanceProgress with error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('rescheduleMaintenance', () => { + it('invokes rescheduleMaintenance without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.RescheduleMaintenanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.RescheduleMaintenanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall(expectedResponse); + const [operation] = await client.rescheduleMaintenance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rescheduleMaintenance without error using callback', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.RescheduleMaintenanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.RescheduleMaintenanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.rescheduleMaintenance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rescheduleMaintenance( + request, + (err?: Error|null, + result?: 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.rescheduleMaintenance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rescheduleMaintenance with call error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.RescheduleMaintenanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.RescheduleMaintenanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.rescheduleMaintenance(request), expectedError); + const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rescheduleMaintenance with LRO error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.RescheduleMaintenanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.RescheduleMaintenanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.rescheduleMaintenance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkRescheduleMaintenanceProgress without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRescheduleMaintenanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRescheduleMaintenanceProgress with error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRescheduleMaintenanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listInstances', () => { + it('invokes listInstances without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), + generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), + generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), + ]; + client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); + const [response] = await client.listInstances(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstances without error using callback', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), + generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), + generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), + ]; + client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstances( + request, + (err?: Error|null, result?: protos.google.cloud.redis.v1beta1.IInstance[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstances with error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listInstances(request), expectedError); + const actualRequest = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstancesStream without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), + generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), + generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), + ]; + client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.redis.v1beta1.Instance[] = []; + stream.on('data', (response: protos.google.cloud.redis.v1beta1.Instance) => { + 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.listInstances.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listInstancesStream with error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.redis.v1beta1.Instance[] = []; + stream.on('data', (response: protos.google.cloud.redis.v1beta1.Instance) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstances without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), + generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), + generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), + ]; + client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.redis.v1beta1.IInstance[] = []; + const iterable = client.listInstancesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstances with error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.redis.v1beta1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.redis.v1beta1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInstancesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.redis.v1beta1.IInstance[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('instance', () => { + const fakePath = "/rendered/path/instance"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + instance: "instanceValue", + }; + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.instancePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.instancePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath("projectValue", "locationValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromInstanceName', () => { + const result = client.matchLocationFromInstanceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + 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)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-redis/v1beta1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-redis/v1beta1/webpack.config.js new file mode 100644 index 00000000000..c8446c2163e --- /dev/null +++ b/owl-bot-staging/google-cloud-redis/v1beta1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'CloudRedis', + filename: './cloud-redis.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-resourcemanager/v3/.eslintignore b/owl-bot-staging/google-cloud-resourcemanager/v3/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/.eslintrc.json b/owl-bot-staging/google-cloud-resourcemanager/v3/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/.gitignore b/owl-bot-staging/google-cloud-resourcemanager/v3/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/.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-resourcemanager/v3/.jsdoc.js b/owl-bot-staging/google-cloud-resourcemanager/v3/.jsdoc.js new file mode 100644 index 00000000000..fb2b789c019 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/.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/resource-manager', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/.mocharc.js b/owl-bot-staging/google-cloud-resourcemanager/v3/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/.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-resourcemanager/v3/.prettierrc.js b/owl-bot-staging/google-cloud-resourcemanager/v3/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/.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-resourcemanager/v3/README.md b/owl-bot-staging/google-cloud-resourcemanager/v3/README.md new file mode 100644 index 00000000000..3dd631a1a59 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/README.md @@ -0,0 +1 @@ +Resourcemanager: Nodejs Client diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/package.json b/owl-bot-staging/google-cloud-resourcemanager/v3/package.json new file mode 100644 index 00000000000..ce74d8d0989 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/resource-manager", + "version": "0.1.0", + "description": "Resourcemanager client for Node.js", + "repository": "googleapis/nodejs-resourcemanager", + "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 resourcemanager", + "resourcemanager", + "folders", + "organizations", + "projects", + "tag bindings", + "tag holds", + "tag keys", + "tag values" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/folders.proto b/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/folders.proto new file mode 100644 index 00000000000..036bf4e6daf --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/folders.proto @@ -0,0 +1,546 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.resourcemanager.v3; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.ResourceManager.V3"; +option go_package = "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb;resourcemanagerpb"; +option java_multiple_files = true; +option java_outer_classname = "FoldersProto"; +option java_package = "com.google.cloud.resourcemanager.v3"; +option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; +option ruby_package = "Google::Cloud::ResourceManager::V3"; + +// Manages Cloud Platform folder resources. +// Folders can be used to organize the resources under an +// organization and to control the policies applied to groups of resources. +service Folders { + option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-platform.read-only"; + + // Retrieves a folder identified by the supplied resource name. + // Valid folder resource names have the format `folders/{folder_id}` + // (for example, `folders/1234`). + // The caller must have `resourcemanager.folders.get` permission on the + // identified folder. + rpc GetFolder(GetFolderRequest) returns (Folder) { + option (google.api.http) = { + get: "/v3/{name=folders/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists the folders that are direct descendants of supplied parent resource. + // `list()` provides a strongly consistent view of the folders underneath + // the specified parent resource. + // `list()` returns folders sorted based upon the (ascending) lexical ordering + // of their display_name. + // The caller must have `resourcemanager.folders.list` permission on the + // identified parent. + rpc ListFolders(ListFoldersRequest) returns (ListFoldersResponse) { + option (google.api.http) = { + get: "/v3/folders" + }; + option (google.api.method_signature) = "parent"; + } + + // Search for folders that match specific filter criteria. + // `search()` provides an eventually consistent view of the folders a user has + // access to which meet the specified filter criteria. + // + // This will only return folders on which the caller has the + // permission `resourcemanager.folders.get`. + rpc SearchFolders(SearchFoldersRequest) returns (SearchFoldersResponse) { + option (google.api.http) = { + get: "/v3/folders:search" + }; + option (google.api.method_signature) = "query"; + } + + // Creates a folder in the resource hierarchy. + // Returns an `Operation` which can be used to track the progress of the + // folder creation workflow. + // Upon success, the `Operation.response` field will be populated with the + // created Folder. + // + // In order to succeed, the addition of this new folder must not violate + // the folder naming, height, or fanout constraints. + // + // + The folder's `display_name` must be distinct from all other folders that + // share its parent. + // + The addition of the folder must not cause the active folder hierarchy + // to exceed a height of 10. Note, the full active + deleted folder hierarchy + // is allowed to reach a height of 20; this provides additional headroom when + // moving folders that contain deleted folders. + // + The addition of the folder must not cause the total number of folders + // under its parent to exceed 300. + // + // If the operation fails due to a folder constraint violation, some errors + // may be returned by the `CreateFolder` request, with status code + // `FAILED_PRECONDITION` and an error description. Other folder constraint + // violations will be communicated in the `Operation`, with the specific + // `PreconditionFailure` returned in the details list in the `Operation.error` + // field. + // + // The caller must have `resourcemanager.folders.create` permission on the + // identified parent. + rpc CreateFolder(CreateFolderRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v3/folders" + body: "folder" + }; + option (google.api.method_signature) = "folder"; + option (google.longrunning.operation_info) = { + response_type: "Folder" + metadata_type: "CreateFolderMetadata" + }; + } + + // Updates a folder, changing its `display_name`. + // Changes to the folder `display_name` will be rejected if they violate + // either the `display_name` formatting rules or the naming constraints + // described in the + // [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] + // documentation. + // + // The folder's `display_name` must start and end with a letter or digit, + // may contain letters, digits, spaces, hyphens and underscores and can be + // between 3 and 30 characters. This is captured by the regular expression: + // `[\p{L}\p{N}][\p{L}\p{N}_- ]{1,28}[\p{L}\p{N}]`. + // The caller must have `resourcemanager.folders.update` permission on the + // identified folder. + // + // If the update fails due to the unique name constraint then a + // `PreconditionFailure` explaining this violation will be returned + // in the Status.details field. + rpc UpdateFolder(UpdateFolderRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v3/{folder.name=folders/*}" + body: "folder" + }; + option (google.api.method_signature) = "folder,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "Folder" + metadata_type: "UpdateFolderMetadata" + }; + } + + // Moves a folder under a new resource parent. + // Returns an `Operation` which can be used to track the progress of the + // folder move workflow. + // Upon success, the `Operation.response` field will be populated with the + // moved folder. + // Upon failure, a `FolderOperationError` categorizing the failure cause will + // be returned - if the failure occurs synchronously then the + // `FolderOperationError` will be returned in the `Status.details` field. + // If it occurs asynchronously, then the FolderOperation will be returned + // in the `Operation.error` field. + // In addition, the `Operation.metadata` field will be populated with a + // `FolderOperation` message as an aid to stateless clients. + // Folder moves will be rejected if they violate either the naming, height, + // or fanout constraints described in the + // [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] + // documentation. The caller must have `resourcemanager.folders.move` + // permission on the folder's current and proposed new parent. + rpc MoveFolder(MoveFolderRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v3/{name=folders/*}:move" + body: "*" + }; + option (google.api.method_signature) = "name,destination_parent"; + option (google.longrunning.operation_info) = { + response_type: "Folder" + metadata_type: "MoveFolderMetadata" + }; + } + + // Requests deletion of a folder. The folder is moved into the + // [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] + // state immediately, and is deleted approximately 30 days later. This method + // may only be called on an empty folder, where a folder is empty if it + // doesn't contain any folders or projects in the + // [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. If + // called on a folder in + // [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] + // state the operation will result in a no-op success. + // The caller must have `resourcemanager.folders.delete` permission on the + // identified folder. + rpc DeleteFolder(DeleteFolderRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v3/{name=folders/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Folder" + metadata_type: "DeleteFolderMetadata" + }; + } + + // Cancels the deletion request for a folder. This method may be called on a + // folder in any state. If the folder is in the + // [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state the + // result will be a no-op success. In order to succeed, the folder's parent + // must be in the + // [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. In + // addition, reintroducing the folder into the tree must not violate folder + // naming, height, and fanout constraints described in the + // [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] + // documentation. The caller must have `resourcemanager.folders.undelete` + // permission on the identified folder. + rpc UndeleteFolder(UndeleteFolderRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v3/{name=folders/*}:undelete" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Folder" + metadata_type: "UndeleteFolderMetadata" + }; + } + + // Gets the access control policy for a folder. The returned policy may be + // empty if no such policy or resource exists. The `resource` field should + // be the folder's resource name, for example: "folders/1234". + // The caller must have `resourcemanager.folders.getIamPolicy` permission + // on the identified folder. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) + returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v3/{resource=folders/*}:getIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource"; + } + + // Sets the access control policy on a folder, replacing any existing policy. + // The `resource` field should be the folder's resource name, for example: + // "folders/1234". + // The caller must have `resourcemanager.folders.setIamPolicy` permission + // on the identified folder. + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) + returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v3/{resource=folders/*}:setIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource,policy"; + } + + // Returns permissions that a caller has on the specified folder. + // The `resource` field should be the folder's resource name, + // for example: "folders/1234". + // + // There are no permissions required for making this API call. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) + returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v3/{resource=folders/*}:testIamPermissions" + body: "*" + }; + option (google.api.method_signature) = "resource,permissions"; + } +} + +// A folder in an organization's resource hierarchy, used to +// organize that organization's resources. +message Folder { + option (google.api.resource) = { + type: "cloudresourcemanager.googleapis.com/Folder" + pattern: "folders/{folder}" + style: DECLARATIVE_FRIENDLY + }; + + // Folder lifecycle states. + enum State { + // Unspecified state. + STATE_UNSPECIFIED = 0; + + // The normal and active state. + ACTIVE = 1; + + // The folder has been marked for deletion by the user. + DELETE_REQUESTED = 2; + } + + // Output only. The resource name of the folder. + // Its format is `folders/{folder_id}`, for example: "folders/1234". + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. The folder's parent's resource name. + // Updates to the folder's parent must be performed using + // [MoveFolder][google.cloud.resourcemanager.v3.Folders.MoveFolder]. + string parent = 2 [(google.api.field_behavior) = REQUIRED]; + + // The folder's display name. + // A folder's display name must be unique amongst its siblings. For example, + // no two folders with the same parent can share the same display name. + // The display name must start and end with a letter or digit, may contain + // letters, digits, spaces, hyphens and underscores and can be no longer + // than 30 characters. This is captured by the regular expression: + // `[\p{L}\p{N}]([\p{L}\p{N}_- ]{0,28}[\p{L}\p{N}])?`. + string display_name = 3; + + // Output only. The lifecycle state of the folder. + // Updates to the state must be performed using + // [DeleteFolder][google.cloud.resourcemanager.v3.Folders.DeleteFolder] and + // [UndeleteFolder][google.cloud.resourcemanager.v3.Folders.UndeleteFolder]. + State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp when the folder was created. + google.protobuf.Timestamp create_time = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp when the folder was last modified. + google.protobuf.Timestamp update_time = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp when the folder was requested to be deleted. + google.protobuf.Timestamp delete_time = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A checksum computed by the server based on the current value + // of the folder resource. This may be sent on update and delete requests to + // ensure the client has an up-to-date value before proceeding. + string etag = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The GetFolder request message. +message GetFolderRequest { + // Required. The resource name of the folder to retrieve. + // Must be of the form `folders/{folder_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Folder" + } + ]; +} + +// The ListFolders request message. +message ListFoldersRequest { + // Required. The name of the parent resource whose folders are being listed. + // Only children of this parent resource are listed; descendants are not + // listed. + // + // If the parent is a folder, use the value `folders/{folder_id}`. If the + // parent is an organization, use the value `organizations/{org_id}`. + // + // Access to this method is controlled by checking the + // `resourcemanager.folders.list` permission on the `parent`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { child_type: "*" } + ]; + + // Optional. The maximum number of folders to return in the response. The + // server can return fewer folders than requested. If unspecified, server + // picks an appropriate default. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A pagination token returned from a previous call to `ListFolders` + // that indicates where this listing should continue from. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Controls whether folders in the + // [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] + // state should be returned. Defaults to false. + bool show_deleted = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// The ListFolders response message. +message ListFoldersResponse { + // A possibly paginated list of folders that are direct descendants of + // the specified parent resource. + repeated Folder folders = 1; + + // A pagination token returned from a previous call to `ListFolders` + // that indicates from where listing should continue. + string next_page_token = 2; +} + +// The request message for searching folders. +message SearchFoldersRequest { + // Optional. The maximum number of folders to return in the response. The + // server can return fewer folders than requested. If unspecified, server + // picks an appropriate default. + int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A pagination token returned from a previous call to + // `SearchFolders` that indicates from where search should continue. + string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Search criteria used to select the folders to return. + // If no search criteria is specified then all accessible folders will be + // returned. + // + // Query expressions can be used to restrict results based upon displayName, + // state and parent, where the operators `=` (`:`) `NOT`, `AND` and `OR` + // can be used along with the suffix wildcard symbol `*`. + // + // The `displayName` field in a query expression should use escaped quotes + // for values that include whitespace to prevent unexpected behavior. + // + // ``` + // | Field | Description | + // |-------------------------|----------------------------------------| + // | displayName | Filters by displayName. | + // | parent | Filters by parent (for example: folders/123). | + // | state, lifecycleState | Filters by state. | + // ``` + // + // Some example queries are: + // + // * Query `displayName=Test*` returns Folder resources whose display name + // starts with "Test". + // * Query `state=ACTIVE` returns Folder resources with + // `state` set to `ACTIVE`. + // * Query `parent=folders/123` returns Folder resources that have + // `folders/123` as a parent resource. + // * Query `parent=folders/123 AND state=ACTIVE` returns active + // Folder resources that have `folders/123` as a parent resource. + // * Query `displayName=\\"Test String\\"` returns Folder resources with + // display names that include both "Test" and "String". + string query = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response message for searching folders. +message SearchFoldersResponse { + // A possibly paginated folder search results. + // the specified parent resource. + repeated Folder folders = 1; + + // A pagination token returned from a previous call to `SearchFolders` + // that indicates from where searching should continue. + string next_page_token = 2; +} + +// The CreateFolder request message. +message CreateFolderRequest { + // Required. The folder being created, only the display name and parent will + // be consulted. All other fields will be ignored. + Folder folder = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Metadata pertaining to the Folder creation process. +message CreateFolderMetadata { + // The display name of the folder. + string display_name = 1; + + // The resource name of the folder or organization we are creating the folder + // under. + string parent = 2; +} + +// The request sent to the +// [UpdateFolder][google.cloud.resourcemanager.v3.Folder.UpdateFolder] +// method. +// +// Only the `display_name` field can be changed. All other fields will be +// ignored. Use the +// [MoveFolder][google.cloud.resourcemanager.v3.Folders.MoveFolder] method to +// change the `parent` field. +message UpdateFolderRequest { + // Required. The new definition of the Folder. It must include the `name` + // field, which cannot be changed. + Folder folder = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Fields to be updated. + // Only the `display_name` can be updated. + google.protobuf.FieldMask update_mask = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// A status object which is used as the `metadata` field for the Operation +// returned by UpdateFolder. +message UpdateFolderMetadata {} + +// The MoveFolder request message. +message MoveFolderRequest { + // Required. The resource name of the Folder to move. + // Must be of the form folders/{folder_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Folder" + } + ]; + + // Required. The resource name of the folder or organization which should be + // the folder's new parent. Must be of the form `folders/{folder_id}` or + // `organizations/{org_id}`. + string destination_parent = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { child_type: "*" } + ]; +} + +// Metadata pertaining to the folder move process. +message MoveFolderMetadata { + // The display name of the folder. + string display_name = 1; + + // The resource name of the folder's parent. + string source_parent = 2; + + // The resource name of the folder or organization to move the folder to. + string destination_parent = 3; +} + +// The DeleteFolder request message. +message DeleteFolderRequest { + // Required. The resource name of the folder to be deleted. + // Must be of the form `folders/{folder_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Folder" + } + ]; +} + +// A status object which is used as the `metadata` field for the `Operation` +// returned by `DeleteFolder`. +message DeleteFolderMetadata {} + +// The UndeleteFolder request message. +message UndeleteFolderRequest { + // Required. The resource name of the folder to undelete. + // Must be of the form `folders/{folder_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Folder" + } + ]; +} + +// A status object which is used as the `metadata` field for the `Operation` +// returned by `UndeleteFolder`. +message UndeleteFolderMetadata {} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/organizations.proto b/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/organizations.proto new file mode 100644 index 00000000000..7b0ed95a501 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/organizations.proto @@ -0,0 +1,241 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.resourcemanager.v3; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.ResourceManager.V3"; +option go_package = "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb;resourcemanagerpb"; +option java_multiple_files = true; +option java_outer_classname = "OrganizationsProto"; +option java_package = "com.google.cloud.resourcemanager.v3"; +option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; +option ruby_package = "Google::Cloud::ResourceManager::V3"; + +// Allows users to manage their organization resources. +service Organizations { + option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-platform.read-only"; + + // Fetches an organization resource identified by the specified resource name. + rpc GetOrganization(GetOrganizationRequest) returns (Organization) { + option (google.api.http) = { + get: "/v3/{name=organizations/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Searches organization resources that are visible to the user and satisfy + // the specified filter. This method returns organizations in an unspecified + // order. New organizations do not necessarily appear at the end of the + // results, and may take a small amount of time to appear. + // + // Search will only return organizations on which the user has the permission + // `resourcemanager.organizations.get` + rpc SearchOrganizations(SearchOrganizationsRequest) + returns (SearchOrganizationsResponse) { + option (google.api.http) = { + get: "/v3/organizations:search" + }; + option (google.api.method_signature) = "query"; + } + + // Gets the access control policy for an organization resource. The policy may + // be empty if no such policy or resource exists. The `resource` field should + // be the organization's resource name, for example: "organizations/123". + // + // Authorization requires the IAM permission + // `resourcemanager.organizations.getIamPolicy` on the specified organization. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) + returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v3/{resource=organizations/*}:getIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource"; + } + + // Sets the access control policy on an organization resource. Replaces any + // existing policy. The `resource` field should be the organization's resource + // name, for example: "organizations/123". + // + // Authorization requires the IAM permission + // `resourcemanager.organizations.setIamPolicy` on the specified organization. + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) + returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v3/{resource=organizations/*}:setIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource"; + } + + // Returns the permissions that a caller has on the specified organization. + // The `resource` field should be the organization's resource name, + // for example: "organizations/123". + // + // There are no permissions required for making this API call. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) + returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v3/{resource=organizations/*}:testIamPermissions" + body: "*" + }; + option (google.api.method_signature) = "resource,permissions"; + } +} + +// The root node in the resource hierarchy to which a particular entity's +// (a company, for example) resources belong. +message Organization { + option (google.api.resource) = { + type: "cloudresourcemanager.googleapis.com/Organization" + pattern: "organizations/{organization}" + style: DECLARATIVE_FRIENDLY + }; + + // Organization lifecycle states. + enum State { + // Unspecified state. This is only useful for distinguishing unset values. + STATE_UNSPECIFIED = 0; + + // The normal and active state. + ACTIVE = 1; + + // The organization has been marked for deletion by the user. + DELETE_REQUESTED = 2; + } + + // Output only. The resource name of the organization. This is the + // organization's relative path in the API. Its format is + // "organizations/[organization_id]". For example, "organizations/1234". + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A human-readable string that refers to the organization in the + // Google Cloud Console. This string is set by the server and cannot be + // changed. The string will be set to the primary domain (for example, + // "google.com") of the Google Workspace customer that owns the organization. + string display_name = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The owner of this organization. The owner should be specified on + // creation. Once set, it cannot be changed. + // + // The lifetime of the organization and all of its descendants are bound to + // the owner. If the owner is deleted, the organization and all its + // descendants will be deleted. + oneof owner { + // Immutable. The G Suite / Workspace customer id used in the Directory API. + string directory_customer_id = 3 [(google.api.field_behavior) = IMMUTABLE]; + } + + // Output only. The organization's current lifecycle state. + State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp when the Organization was created. + google.protobuf.Timestamp create_time = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp when the Organization was last modified. + google.protobuf.Timestamp update_time = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp when the Organization was requested for deletion. + google.protobuf.Timestamp delete_time = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A checksum computed by the server based on the current value + // of the Organization resource. This may be sent on update and delete + // requests to ensure the client has an up-to-date value before proceeding. + string etag = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The request sent to the `GetOrganization` method. The `name` field is +// required. `organization_id` is no longer accepted. +message GetOrganizationRequest { + // Required. The resource name of the Organization to fetch. This is the + // organization's relative path in the API, formatted as + // "organizations/[organizationId]". For example, "organizations/1234". + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Organization" + } + ]; +} + +// The request sent to the `SearchOrganizations` method. +message SearchOrganizationsRequest { + // Optional. The maximum number of organizations to return in the response. + // The server can return fewer organizations than requested. If unspecified, + // server picks an appropriate default. + int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A pagination token returned from a previous call to + // `SearchOrganizations` that indicates from where listing should continue. + string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. An optional query string used to filter the Organizations to + // return in the response. Query rules are case-insensitive. + // + // + // ``` + // | Field | Description | + // |------------------|--------------------------------------------| + // | directoryCustomerId, owner.directoryCustomerId | Filters by directory + // customer id. | + // | domain | Filters by domain. | + // ``` + // + // Organizations may be queried by `directoryCustomerId` or by + // `domain`, where the domain is a G Suite domain, for example: + // + // * Query `directorycustomerid:123456789` returns Organization + // resources with `owner.directory_customer_id` equal to `123456789`. + // * Query `domain:google.com` returns Organization resources corresponding + // to the domain `google.com`. + string query = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response returned from the `SearchOrganizations` method. +message SearchOrganizationsResponse { + // The list of Organizations that matched the search query, possibly + // paginated. + repeated Organization organizations = 1; + + // A pagination token to be used to retrieve the next page of results. If the + // result is too large to fit within the page size specified in the request, + // this field will be set with a token that can be used to fetch the next page + // of results. If this field is empty, it indicates that this response + // contains the last page of results. + string next_page_token = 2; +} + +// A status object which is used as the `metadata` field for the operation +// returned by DeleteOrganization. +message DeleteOrganizationMetadata {} + +// A status object which is used as the `metadata` field for the Operation +// returned by UndeleteOrganization. +message UndeleteOrganizationMetadata {} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/projects.proto b/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/projects.proto new file mode 100644 index 00000000000..5128147109a --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/projects.proto @@ -0,0 +1,638 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.resourcemanager.v3; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.ResourceManager.V3"; +option go_package = "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb;resourcemanagerpb"; +option java_multiple_files = true; +option java_outer_classname = "ProjectsProto"; +option java_package = "com.google.cloud.resourcemanager.v3"; +option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; +option ruby_package = "Google::Cloud::ResourceManager::V3"; + +// Manages Google Cloud Projects. +service Projects { + option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-platform.read-only"; + + // Retrieves the project identified by the specified `name` (for example, + // `projects/415104041262`). + // + // The caller must have `resourcemanager.projects.get` permission + // for this project. + rpc GetProject(GetProjectRequest) returns (Project) { + option (google.api.http) = { + get: "/v3/{name=projects/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists projects that are direct children of the specified folder or + // organization resource. `list()` provides a strongly consistent view of the + // projects underneath the specified parent resource. `list()` returns + // projects sorted based upon the (ascending) lexical ordering of their + // `display_name`. The caller must have `resourcemanager.projects.list` + // permission on the identified parent. + rpc ListProjects(ListProjectsRequest) returns (ListProjectsResponse) { + option (google.api.http) = { + get: "/v3/projects" + }; + option (google.api.method_signature) = "parent"; + } + + // Search for projects that the caller has both `resourcemanager.projects.get` + // permission on, and also satisfy the specified query. + // + // This method returns projects in an unspecified order. + // + // This method is eventually consistent with project mutations; this means + // that a newly created project may not appear in the results or recent + // updates to an existing project may not be reflected in the results. To + // retrieve the latest state of a project, use the + // [GetProject][google.cloud.resourcemanager.v3.Projects.GetProject] method. + rpc SearchProjects(SearchProjectsRequest) returns (SearchProjectsResponse) { + option (google.api.http) = { + get: "/v3/projects:search" + }; + option (google.api.method_signature) = "query"; + } + + // Request that a new project be created. The result is an `Operation` which + // can be used to track the creation process. This process usually takes a few + // seconds, but can sometimes take much longer. The tracking `Operation` is + // automatically deleted after a few hours, so there is no need to call + // `DeleteOperation`. + rpc CreateProject(CreateProjectRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v3/projects" + body: "project" + }; + option (google.api.method_signature) = "project"; + option (google.longrunning.operation_info) = { + response_type: "Project" + metadata_type: "CreateProjectMetadata" + }; + } + + // Updates the `display_name` and labels of the project identified by the + // specified `name` (for example, `projects/415104041262`). Deleting all + // labels requires an update mask for labels field. + // + // The caller must have `resourcemanager.projects.update` permission for this + // project. + rpc UpdateProject(UpdateProjectRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v3/{project.name=projects/*}" + body: "project" + }; + option (google.api.method_signature) = "project,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "Project" + metadata_type: "UpdateProjectMetadata" + }; + } + + // Move a project to another place in your resource hierarchy, under a new + // resource parent. + // + // Returns an operation which can be used to track the process of the project + // move workflow. + // Upon success, the `Operation.response` field will be populated with the + // moved project. + // + // The caller must have `resourcemanager.projects.move` permission on the + // project, on the project's current and proposed new parent. + // + // If project has no current parent, or it currently does not have an + // associated organization resource, you will also need the + // `resourcemanager.projects.setIamPolicy` permission in the project. + // + // + rpc MoveProject(MoveProjectRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v3/{name=projects/*}:move" + body: "*" + }; + option (google.api.method_signature) = "name, destination_parent"; + option (google.longrunning.operation_info) = { + response_type: "Project" + metadata_type: "MoveProjectMetadata" + }; + } + + // Marks the project identified by the specified + // `name` (for example, `projects/415104041262`) for deletion. + // + // This method will only affect the project if it has a lifecycle state of + // [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE]. + // + // This method changes the Project's lifecycle state from + // [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE] + // to + // [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Project.State.DELETE_REQUESTED]. + // The deletion starts at an unspecified time, + // at which point the Project is no longer accessible. + // + // Until the deletion completes, you can check the lifecycle state + // checked by retrieving the project with [GetProject] + // [google.cloud.resourcemanager.v3.Projects.GetProject], + // and the project remains visible to [ListProjects] + // [google.cloud.resourcemanager.v3.Projects.ListProjects]. + // However, you cannot update the project. + // + // After the deletion completes, the project is not retrievable by + // the [GetProject] + // [google.cloud.resourcemanager.v3.Projects.GetProject], + // [ListProjects] + // [google.cloud.resourcemanager.v3.Projects.ListProjects], and + // [SearchProjects][google.cloud.resourcemanager.v3.Projects.SearchProjects] + // methods. + // + // This method behaves idempotently, such that deleting a `DELETE_REQUESTED` + // project will not cause an error, but also won't do anything. + // + // The caller must have `resourcemanager.projects.delete` permissions for this + // project. + rpc DeleteProject(DeleteProjectRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v3/{name=projects/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Project" + metadata_type: "DeleteProjectMetadata" + }; + } + + // Restores the project identified by the specified + // `name` (for example, `projects/415104041262`). + // You can only use this method for a project that has a lifecycle state of + // [DELETE_REQUESTED] + // [Projects.State.DELETE_REQUESTED]. + // After deletion starts, the project cannot be restored. + // + // The caller must have `resourcemanager.projects.undelete` permission for + // this project. + rpc UndeleteProject(UndeleteProjectRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v3/{name=projects/*}:undelete" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Project" + metadata_type: "UndeleteProjectMetadata" + }; + } + + // Returns the IAM access control policy for the specified project, in the + // format `projects/{ProjectIdOrNumber}` e.g. projects/123. + // Permission is denied if the policy or the resource do not exist. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) + returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v3/{resource=projects/*}:getIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource"; + } + + // Sets the IAM access control policy for the specified project, in the + // format `projects/{ProjectIdOrNumber}` e.g. projects/123. + // + // CAUTION: This method will replace the existing policy, and cannot be used + // to append additional IAM settings. + // + // Note: Removing service accounts from policies or changing their roles can + // render services completely inoperable. It is important to understand how + // the service account is being used before removing or updating its roles. + // + // The following constraints apply when using `setIamPolicy()`: + // + // + Project does not support `allUsers` and `allAuthenticatedUsers` as + // `members` in a `Binding` of a `Policy`. + // + // + The owner role can be granted to a `user`, `serviceAccount`, or a group + // that is part of an organization. For example, + // group@myownpersonaldomain.com could be added as an owner to a project in + // the myownpersonaldomain.com organization, but not the examplepetstore.com + // organization. + // + // + Service accounts can be made owners of a project directly + // without any restrictions. However, to be added as an owner, a user must be + // invited using the Cloud Platform console and must accept the invitation. + // + // + A user cannot be granted the owner role using `setIamPolicy()`. The user + // must be granted the owner role using the Cloud Platform Console and must + // explicitly accept the invitation. + // + // + Invitations to grant the owner role cannot be sent using + // `setIamPolicy()`; + // they must be sent only using the Cloud Platform Console. + // + // + If the project is not part of an organization, there must be at least + // one owner who has accepted the Terms of Service (ToS) agreement in the + // policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner + // from the policy will fail. This restriction also applies to legacy + // projects that no longer have owners who have accepted the ToS. Edits to + // IAM policies will be rejected until the lack of a ToS-accepting owner is + // rectified. If the project is part of an organization, you can remove all + // owners, potentially making the organization inaccessible. + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) + returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v3/{resource=projects/*}:setIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource, policy"; + } + + // Returns permissions that a caller has on the specified project, in the + // format `projects/{ProjectIdOrNumber}` e.g. projects/123.. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) + returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v3/{resource=projects/*}:testIamPermissions" + body: "*" + }; + option (google.api.method_signature) = "resource, permissions"; + } +} + +// A project is a high-level Google Cloud entity. It is a +// container for ACLs, APIs, App Engine Apps, VMs, and other +// Google Cloud Platform resources. +message Project { + option (google.api.resource) = { + type: "cloudresourcemanager.googleapis.com/Project" + pattern: "projects/{project}" + style: DECLARATIVE_FRIENDLY + }; + + // Project lifecycle states. + enum State { + // Unspecified state. This is only used/useful for distinguishing + // unset values. + STATE_UNSPECIFIED = 0; + + // The normal and active state. + ACTIVE = 1; + + // The project has been marked for deletion by the user + // (by invoking + // [DeleteProject][google.cloud.resourcemanager.v3.Projects.DeleteProject]) + // or by the system (Google Cloud Platform). + // This can generally be reversed by invoking [UndeleteProject] + // [google.cloud.resourcemanager.v3.Projects.UndeleteProject]. + DELETE_REQUESTED = 2; + } + + // Output only. The unique resource name of the project. It is an int64 + // generated number prefixed by "projects/". + // + // Example: `projects/415104041262` + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. A reference to a parent Resource. eg., `organizations/123` or + // `folders/876`. + string parent = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Immutable. The unique, user-assigned id of the project. + // It must be 6 to 30 lowercase ASCII letters, digits, or hyphens. + // It must start with a letter. + // Trailing hyphens are prohibited. + // + // Example: `tokyo-rain-123` + string project_id = 3 [(google.api.field_behavior) = IMMUTABLE]; + + // Output only. The project lifecycle state. + State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. A user-assigned display name of the project. + // When present it must be between 4 to 30 characters. + // Allowed characters are: lowercase and uppercase letters, numbers, + // hyphen, single-quote, double-quote, space, and exclamation point. + // + // Example: `My Project` + string display_name = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. Creation time. + google.protobuf.Timestamp create_time = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The most recent time this resource was modified. + google.protobuf.Timestamp update_time = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time at which this resource was requested for deletion. + google.protobuf.Timestamp delete_time = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A checksum computed by the server based on the current value + // of the Project resource. This may be sent on update and delete requests to + // ensure the client has an up-to-date value before proceeding. + string etag = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. The labels associated with this project. + // + // Label keys must be between 1 and 63 characters long and must conform + // to the following regular expression: \[a-z\](\[-a-z0-9\]*\[a-z0-9\])?. + // + // Label values must be between 0 and 63 characters long and must conform + // to the regular expression (\[a-z\](\[-a-z0-9\]*\[a-z0-9\])?)?. + // + // No more than 64 labels can be associated with a given resource. + // + // Clients should store labels in a representation such as JSON that does not + // depend on specific characters being disallowed. + // + // Example: `"myBusinessDimension" : "businessValue"` + map labels = 10 [(google.api.field_behavior) = OPTIONAL]; +} + +// The request sent to the +// [GetProject][google.cloud.resourcemanager.v3.Projects.GetProject] +// method. +message GetProjectRequest { + // Required. The name of the project (for example, `projects/415104041262`). + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; +} + +// The request sent to the +// [ListProjects][google.cloud.resourcemanager.v3.Projects.ListProjects] +// method. +message ListProjectsRequest { + // Required. The name of the parent resource whose projects are being listed. + // Only children of this parent resource are listed; descendants are not + // listed. + // + // If the parent is a folder, use the value `folders/{folder_id}`. If the + // parent is an organization, use the value `organizations/{org_id}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { child_type: "*" } + ]; + + // Optional. A pagination token returned from a previous call to + // [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects] that + // indicates from where listing should continue. + string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maximum number of projects to return in the response. + // The server can return fewer projects than requested. + // If unspecified, server picks an appropriate default. + int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Indicate that projects in the `DELETE_REQUESTED` state should + // also be returned. Normally only `ACTIVE` projects are returned. + bool show_deleted = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// A page of the response received from the +// [ListProjects][google.cloud.resourcemanager.v3.Projects.ListProjects] +// method. +// +// A paginated response where more pages are available has +// `next_page_token` set. This token can be used in a subsequent request to +// retrieve the next request page. +// +// NOTE: A response may contain fewer elements than the request `page_size` and +// still have a `next_page_token`. +message ListProjectsResponse { + // The list of Projects under the parent. This list can be paginated. + repeated Project projects = 1; + + // Pagination token. + // + // If the result set is too large to fit in a single response, this token + // is returned. It encodes the position of the current result cursor. + // Feeding this value into a new list request with the `page_token` parameter + // gives the next page of the results. + // + // When `next_page_token` is not filled in, there is no next page and + // the list returned is the last page in the result set. + // + // Pagination tokens have a limited lifetime. + string next_page_token = 2; +} + +// The request sent to the +// [SearchProjects][google.cloud.resourcemanager.v3.Projects.SearchProjects] +// method. +message SearchProjectsRequest { + // Optional. A query string for searching for projects that the caller has + // `resourcemanager.projects.get` permission to. If multiple fields are + // included in the query, then it will return results that match any of the + // fields. Some eligible fields are: + // + // - **`displayName`, `name`**: Filters by displayName. + // - **`parent`**: Project's parent (for example: `folders/123`, + // `organizations/*`). Prefer `parent` field over `parent.type` and + // `parent.id`. + // - **`parent.type`**: Parent's type: `folder` or `organization`. + // - **`parent.id`**: Parent's id number (for example: `123`). + // - **`id`, `projectId`**: Filters by projectId. + // - **`state`, `lifecycleState`**: Filters by state. + // - **`labels`**: Filters by label name or value. + // - **`labels.` (where `` is the name of a label)**: Filters by label + // name. + // + // Search expressions are case insensitive. + // + // Some examples queries: + // + // + // - **`name:how*`**: The project's name starts with "how". + // - **`name:Howl`**: The project's name is `Howl` or `howl`. + // - **`name:HOWL`**: Equivalent to above. + // - **`NAME:howl`**: Equivalent to above. + // - **`labels.color:*`**: The project has the label `color`. + // - **`labels.color:red`**: The project's label `color` has the value `red`. + // - **`labels.color:red labels.size:big`**: The project's label `color` has + // the value `red` or its label `size` has the value `big`. + // + // If no query is specified, the call will return projects for which the user + // has the `resourcemanager.projects.get` permission. + string query = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A pagination token returned from a previous call to + // [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects] that + // indicates from where listing should continue. + string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maximum number of projects to return in the response. + // The server can return fewer projects than requested. + // If unspecified, server picks an appropriate default. + int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// A page of the response received from the +// [SearchProjects][google.cloud.resourcemanager.v3.Projects.SearchProjects] +// method. +// +// A paginated response where more pages are available has +// `next_page_token` set. This token can be used in a subsequent request to +// retrieve the next request page. +message SearchProjectsResponse { + // The list of Projects that matched the list filter query. This list can + // be paginated. + repeated Project projects = 1; + + // Pagination token. + // + // If the result set is too large to fit in a single response, this token + // is returned. It encodes the position of the current result cursor. + // Feeding this value into a new list request with the `page_token` parameter + // gives the next page of the results. + // + // When `next_page_token` is not filled in, there is no next page and + // the list returned is the last page in the result set. + // + // Pagination tokens have a limited lifetime. + string next_page_token = 2; +} + +// The request sent to the +// [CreateProject][google.cloud.resourcemanager.v3.Projects.CreateProject] +// method. +message CreateProjectRequest { + // Required. The Project to create. + // + // Project ID is required. If the requested ID is unavailable, the request + // fails. + // + // If the `parent` field is set, the `resourcemanager.projects.create` + // permission is checked on the parent resource. If no parent is set and + // the authorization credentials belong to an Organization, the parent + // will be set to that Organization. + Project project = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// A status object which is used as the `metadata` field for the Operation +// returned by CreateProject. It provides insight for when significant phases of +// Project creation have completed. +message CreateProjectMetadata { + // Creation time of the project creation workflow. + google.protobuf.Timestamp create_time = 1; + + // True if the project can be retrieved using `GetProject`. No other + // operations on the project are guaranteed to work until the project creation + // is complete. + bool gettable = 2; + + // True if the project creation process is complete. + bool ready = 3; +} + +// The request sent to the +// [UpdateProject][google.cloud.resourcemanager.v3.Projects.UpdateProject] +// method. +// +// Only the `display_name` and `labels` fields can be change. Use the +// [MoveProject][google.cloud.resourcemanager.v3.Projects.MoveProject] method to +// change the `parent` field. +message UpdateProjectRequest { + // Required. The new definition of the project. + Project project = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. An update mask to selectively update fields. + google.protobuf.FieldMask update_mask = 2 + [(google.api.field_behavior) = OPTIONAL]; +} + +// A status object which is used as the `metadata` field for the Operation +// returned by UpdateProject. +message UpdateProjectMetadata {} + +// The request sent to +// [MoveProject][google.cloud.resourcemanager.v3.Projects.MoveProject] +// method. +message MoveProjectRequest { + // Required. The name of the project to move. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Required. The new parent to move the Project under. + string destination_parent = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { child_type: "*" } + ]; +} + +// A status object which is used as the `metadata` field for the Operation +// returned by MoveProject. +message MoveProjectMetadata {} + +// [DeleteProject][google.cloud.resourcemanager.v3.Projects.DeleteProject] +// method. +message DeleteProjectRequest { + // Required. The name of the Project (for example, `projects/415104041262`). + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; +} + +// A status object which is used as the `metadata` field for the Operation +// returned by `DeleteProject`. +message DeleteProjectMetadata {} + +// The request sent to the [UndeleteProject] +// [google.cloud.resourcemanager.v3.Projects.UndeleteProject] +// method. +message UndeleteProjectRequest { + // Required. The name of the project (for example, `projects/415104041262`). + // + // Required. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; +} + +// A status object which is used as the `metadata` field for the Operation +// returned by `UndeleteProject`. +message UndeleteProjectMetadata {} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_bindings.proto b/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_bindings.proto new file mode 100644 index 00000000000..6e94b888459 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_bindings.proto @@ -0,0 +1,268 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.resourcemanager.v3; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; + +option csharp_namespace = "Google.Cloud.ResourceManager.V3"; +option go_package = "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb;resourcemanagerpb"; +option java_multiple_files = true; +option java_outer_classname = "TagBindingsProto"; +option java_package = "com.google.cloud.resourcemanager.v3"; +option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; +option ruby_package = "Google::Cloud::ResourceManager::V3"; + +// Allow users to create and manage TagBindings between TagValues and +// different Google Cloud resources throughout the GCP resource hierarchy. +service TagBindings { + option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-platform.read-only"; + + // Lists the TagBindings for the given Google Cloud resource, as specified + // with `parent`. + // + // NOTE: The `parent` field is expected to be a full resource name: + // https://cloud.google.com/apis/design/resource_names#full_resource_name + rpc ListTagBindings(ListTagBindingsRequest) + returns (ListTagBindingsResponse) { + option (google.api.http) = { + get: "/v3/tagBindings" + }; + option (google.api.method_signature) = "parent"; + } + + // Creates a TagBinding between a TagValue and a Google Cloud resource. + rpc CreateTagBinding(CreateTagBindingRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v3/tagBindings" + body: "tag_binding" + }; + option (google.api.method_signature) = "tag_binding"; + option (google.longrunning.operation_info) = { + response_type: "TagBinding" + metadata_type: "CreateTagBindingMetadata" + }; + } + + // Deletes a TagBinding. + rpc DeleteTagBinding(DeleteTagBindingRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v3/{name=tagBindings/**}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "DeleteTagBindingMetadata" + }; + } + + // Return a list of effective tags for the given Google Cloud resource, as + // specified in `parent`. + rpc ListEffectiveTags(ListEffectiveTagsRequest) + returns (ListEffectiveTagsResponse) { + option (google.api.http) = { + get: "/v3/effectiveTags" + }; + option (google.api.method_signature) = "parent"; + } +} + +// A TagBinding represents a connection between a TagValue and a cloud +// resource Once a TagBinding is created, the TagValue is applied to all the +// descendants of the Google Cloud resource. +message TagBinding { + option (google.api.resource) = { + type: "cloudresourcemanager.googleapis.com/TagBinding" + pattern: "tagBindings/{tag_binding}" + }; + + // Output only. The name of the TagBinding. This is a String of the form: + // `tagBindings/{full-resource-name}/{tag-value-name}` (e.g. + // `tagBindings/%2F%2Fcloudresourcemanager.googleapis.com%2Fprojects%2F123/tagValues/456`). + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The full resource name of the resource the TagValue is bound to. + // E.g. `//cloudresourcemanager.googleapis.com/projects/123` + string parent = 2; + + // The TagValue of the TagBinding. + // Must be of the form `tagValues/456`. + string tag_value = 3; + + // The namespaced name for the TagValue of the TagBinding. + // Must be in the format + // `{parent_id}/{tag_key_short_name}/{short_name}`. + // + // For methods that support TagValue namespaced name, only one of + // tag_value_namespaced_name or tag_value may be filled. Requests with both + // fields will be rejected. + string tag_value_namespaced_name = 4; +} + +// Runtime operation information for creating a TagValue. +message CreateTagBindingMetadata {} + +// The request message to create a TagBinding. +message CreateTagBindingRequest { + // Required. The TagBinding to be created. + TagBinding tag_binding = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Set to true to perform the validations necessary for creating the + // resource, but not actually perform the action. + bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Runtime operation information for deleting a TagBinding. +message DeleteTagBindingMetadata {} + +// The request message to delete a TagBinding. +message DeleteTagBindingRequest { + // Required. The name of the TagBinding. This is a String of the form: + // `tagBindings/{id}` (e.g. + // `tagBindings/%2F%2Fcloudresourcemanager.googleapis.com%2Fprojects%2F123/tagValues/456`). + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/TagBinding" + } + ]; +} + +// The request message to list all TagBindings for a parent. +message ListTagBindingsRequest { + // Required. The full resource name of a resource for which you want to list + // existing TagBindings. E.g. + // "//cloudresourcemanager.googleapis.com/projects/123" + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { child_type: "*" } + ]; + + // Optional. The maximum number of TagBindings to return in the response. The + // server allows a maximum of 300 TagBindings to return. If unspecified, the + // server will use 100 as the default. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A pagination token returned from a previous call to + // `ListTagBindings` that indicates where this listing should continue from. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The ListTagBindings response. +message ListTagBindingsResponse { + // A possibly paginated list of TagBindings for the specified resource. + repeated TagBinding tag_bindings = 1; + + // Pagination token. + // + // If the result set is too large to fit in a single response, this token + // is returned. It encodes the position of the current result cursor. + // Feeding this value into a new list request with the `page_token` parameter + // gives the next page of the results. + // + // When `next_page_token` is not filled in, there is no next page and + // the list returned is the last page in the result set. + // + // Pagination tokens have a limited lifetime. + string next_page_token = 2; +} + +// The request message to ListEffectiveTags +message ListEffectiveTagsRequest { + // Required. The full resource name of a resource for which you want to list + // the effective tags. E.g. + // "//cloudresourcemanager.googleapis.com/projects/123" + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The maximum number of effective tags to return in the response. + // The server allows a maximum of 300 effective tags to return in a single + // page. If unspecified, the server will use 100 as the default. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A pagination token returned from a previous call to + // `ListEffectiveTags` that indicates from where this listing should continue. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response of ListEffectiveTags. +message ListEffectiveTagsResponse { + // A possibly paginated list of effective tags for the specified resource. + repeated EffectiveTag effective_tags = 1; + + // Pagination token. + // + // If the result set is too large to fit in a single response, this token + // is returned. It encodes the position of the current result cursor. + // Feeding this value into a new list request with the `page_token` parameter + // gives the next page of the results. + // + // When `next_page_token` is not filled in, there is no next page and + // the list returned is the last page in the result set. + // + // Pagination tokens have a limited lifetime. + string next_page_token = 2; +} + +// An EffectiveTag represents a tag that applies to a resource during policy +// evaluation. Tags can be either directly bound to a resource or inherited from +// its ancestor. EffectiveTag contains the name and +// namespaced_name of the tag value and tag key, with additional fields of +// `inherited` to indicate the inheritance status of the effective tag. +message EffectiveTag { + // Resource name for TagValue in the format `tagValues/456`. + string tag_value = 1 [(google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/TagValue" + }]; + + // The namespaced name of the TagValue. Can be in the form + // `{organization_id}/{tag_key_short_name}/{tag_value_short_name}` or + // `{project_id}/{tag_key_short_name}/{tag_value_short_name}` or + // `{project_number}/{tag_key_short_name}/{tag_value_short_name}`. + string namespaced_tag_value = 2; + + // The name of the TagKey, in the format `tagKeys/{id}`, such as + // `tagKeys/123`. + string tag_key = 3 [(google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/TagKey" + }]; + + // The namespaced name of the TagKey. Can be in the form + // `{organization_id}/{tag_key_short_name}` or + // `{project_id}/{tag_key_short_name}` or + // `{project_number}/{tag_key_short_name}`. + string namespaced_tag_key = 4; + + // The parent name of the tag key. + // Must be in the format `organizations/{organization_id}` or + // `projects/{project_number}` + string tag_key_parent_name = 6; + + // Indicates the inheritance status of a tag value + // attached to the given resource. If the tag value is inherited from one of + // the resource's ancestors, inherited will be true. If false, then the tag + // value is directly attached to the resource, inherited will be false. + bool inherited = 5; +} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_holds.proto b/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_holds.proto new file mode 100644 index 00000000000..15c446913f2 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_holds.proto @@ -0,0 +1,216 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.resourcemanager.v3; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.ResourceManager.V3"; +option go_package = "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb;resourcemanagerpb"; +option java_multiple_files = true; +option java_outer_classname = "TagHoldsProto"; +option java_package = "com.google.cloud.resourcemanager.v3"; +option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; +option ruby_package = "Google::Cloud::ResourceManager::V3"; + +// Allow users to create and manage TagHolds for TagValues. TagHolds represent +// the use of a Tag Value that is not captured by TagBindings but +// should still block TagValue deletion (such as a reference in a policy +// condition). This service provides isolated failure domains by cloud location +// so that TagHolds can be managed in the same location as their usage. +service TagHolds { + option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-platform.read-only"; + + // Creates a TagHold. Returns ALREADY_EXISTS if a TagHold with the same + // resource and origin exists under the same TagValue. + rpc CreateTagHold(CreateTagHoldRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v3/{parent=tagValues/*}/tagHolds" + body: "tag_hold" + }; + option (google.api.method_signature) = "parent,tag_hold"; + option (google.longrunning.operation_info) = { + response_type: "TagHold" + metadata_type: "CreateTagHoldMetadata" + }; + } + + // Deletes a TagHold. + rpc DeleteTagHold(DeleteTagHoldRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v3/{name=tagValues/*/tagHolds/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "DeleteTagHoldMetadata" + }; + } + + // Lists TagHolds under a TagValue. + rpc ListTagHolds(ListTagHoldsRequest) returns (ListTagHoldsResponse) { + option (google.api.http) = { + get: "/v3/{parent=tagValues/*}/tagHolds" + }; + option (google.api.method_signature) = "parent"; + } +} + +// A TagHold represents the use of a TagValue that is not captured by +// TagBindings. If a TagValue has any TagHolds, deletion will be blocked. +// This resource is intended to be created in the same cloud location as the +// `holder`. +message TagHold { + option (google.api.resource) = { + type: "cloudresourcemanager.googleapis.com/TagHold" + pattern: "tagValues/{tag_value}/tagHolds/{tag_hold}" + }; + + // Output only. The resource name of a TagHold. This is a String of the form: + // `tagValues/{tag-value-id}/tagHolds/{tag-hold-id}` + // (e.g. `tagValues/123/tagHolds/456`). This resource name is generated by + // the server. + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. The name of the resource where the TagValue is being used. Must + // be less than 200 characters. E.g. + // `//compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group` + string holder = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. An optional string representing the origin of this request. This + // field should include human-understandable information to distinguish + // origins from each other. Must be less than 200 characters. E.g. + // `migs-35678234` + string origin = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A URL where an end user can learn more about removing this hold. + // E.g. + // `https://cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing` + string help_link = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The time this TagHold was created. + google.protobuf.Timestamp create_time = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The request message to create a TagHold. +message CreateTagHoldRequest { + // Required. The resource name of the TagHold's parent TagValue. Must be of + // the form: `tagValues/{tag-value-id}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "cloudresourcemanager.googleapis.com/TagHold" + } + ]; + + // Required. The TagHold to be created. + TagHold tag_hold = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Set to true to perform the validations necessary for creating the + // resource, but not actually perform the action. + bool validate_only = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Runtime operation information for creating a TagHold. +// (-- The metadata is currently empty, but may include information in the +// future. --) +message CreateTagHoldMetadata {} + +// The request message to delete a TagHold. +message DeleteTagHoldRequest { + // Required. The resource name of the TagHold to delete. Must be of the form: + // `tagValues/{tag-value-id}/tagHolds/{tag-hold-id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/TagHold" + } + ]; + + // Optional. Set to true to perform the validations necessary for deleting the + // resource, but not actually perform the action. + bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Runtime operation information for deleting a TagHold. +// (-- The metadata is currently empty, but may include information in the +// future. --) +message DeleteTagHoldMetadata {} + +// The request message for listing the TagHolds under a TagValue. +message ListTagHoldsRequest { + // Required. The resource name of the parent TagValue. Must be of the form: + // `tagValues/{tag-value-id}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "cloudresourcemanager.googleapis.com/TagHold" + } + ]; + + // Optional. The maximum number of TagHolds to return in the response. The + // server allows a maximum of 300 TagHolds to return. If unspecified, the + // server will use 100 as the default. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A pagination token returned from a previous call to + // `ListTagHolds` that indicates where this listing should continue from. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Criteria used to select a subset of TagHolds parented by the + // TagValue to return. This field follows the syntax defined by aip.dev/160; + // the `holder` and `origin` fields are supported for filtering. Currently + // only `AND` syntax is supported. Some example queries are: + // + // * `holder = + // //compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group` + // * `origin = 35678234` + // * `holder = + // //compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group + // AND origin = 35678234` + string filter = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// The ListTagHolds response. +message ListTagHoldsResponse { + // A possibly paginated list of TagHolds. + repeated TagHold tag_holds = 1; + + // Pagination token. + // + // If the result set is too large to fit in a single response, this token + // is returned. It encodes the position of the current result cursor. + // Feeding this value into a new list request with the `page_token` parameter + // gives the next page of the results. + // + // When `next_page_token` is not filled in, there is no next page and + // the list returned is the last page in the result set. + // + // Pagination tokens have a limited lifetime. + string next_page_token = 2; +} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_keys.proto b/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_keys.proto new file mode 100644 index 00000000000..72881b22659 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_keys.proto @@ -0,0 +1,367 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.resourcemanager.v3; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.ResourceManager.V3"; +option go_package = "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb;resourcemanagerpb"; +option java_multiple_files = true; +option java_outer_classname = "TagKeysProto"; +option java_package = "com.google.cloud.resourcemanager.v3"; +option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; +option ruby_package = "Google::Cloud::ResourceManager::V3"; + +// Allow users to create and manage tag keys. +service TagKeys { + option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-platform.read-only"; + + // Lists all TagKeys for a parent resource. + rpc ListTagKeys(ListTagKeysRequest) returns (ListTagKeysResponse) { + option (google.api.http) = { + get: "/v3/tagKeys" + }; + option (google.api.method_signature) = "parent"; + } + + // Retrieves a TagKey. This method will return `PERMISSION_DENIED` if the + // key does not exist or the user does not have permission to view it. + rpc GetTagKey(GetTagKeyRequest) returns (TagKey) { + option (google.api.http) = { + get: "/v3/{name=tagKeys/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Retrieves a TagKey by its namespaced name. + // This method will return `PERMISSION_DENIED` if the key does not exist + // or the user does not have permission to view it. + rpc GetNamespacedTagKey(GetNamespacedTagKeyRequest) returns (TagKey) { + option (google.api.http) = { + get: "/v3/tagKeys/namespaced" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new TagKey. If another request with the same parameters is + // sent while the original request is in process, the second request + // will receive an error. A maximum of 1000 TagKeys can exist under a parent + // at any given time. + rpc CreateTagKey(CreateTagKeyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v3/tagKeys" + body: "tag_key" + }; + option (google.api.method_signature) = "tag_key"; + option (google.longrunning.operation_info) = { + response_type: "TagKey" + metadata_type: "CreateTagKeyMetadata" + }; + } + + // Updates the attributes of the TagKey resource. + rpc UpdateTagKey(UpdateTagKeyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v3/{tag_key.name=tagKeys/*}" + body: "tag_key" + }; + option (google.api.method_signature) = "tag_key,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "TagKey" + metadata_type: "UpdateTagKeyMetadata" + }; + } + + // Deletes a TagKey. The TagKey cannot be deleted if it has any child + // TagValues. + rpc DeleteTagKey(DeleteTagKeyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v3/{name=tagKeys/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "TagKey" + metadata_type: "DeleteTagKeyMetadata" + }; + } + + // Gets the access control policy for a TagKey. The returned policy may be + // empty if no such policy or resource exists. The `resource` field should + // be the TagKey's resource name. For example, "tagKeys/1234". + // The caller must have + // `cloudresourcemanager.googleapis.com/tagKeys.getIamPolicy` permission on + // the specified TagKey. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) + returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v3/{resource=tagKeys/*}:getIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource"; + } + + // Sets the access control policy on a TagKey, replacing any existing + // policy. The `resource` field should be the TagKey's resource name. + // For example, "tagKeys/1234". + // The caller must have `resourcemanager.tagKeys.setIamPolicy` permission + // on the identified tagValue. + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) + returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v3/{resource=tagKeys/*}:setIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource,policy"; + } + + // Returns permissions that a caller has on the specified TagKey. + // The `resource` field should be the TagKey's resource name. + // For example, "tagKeys/1234". + // + // There are no permissions required for making this API call. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) + returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v3/{resource=tagKeys/*}:testIamPermissions" + body: "*" + }; + option (google.api.method_signature) = "resource,permissions"; + } +} + +// A TagKey, used to group a set of TagValues. +message TagKey { + option (google.api.resource) = { + type: "cloudresourcemanager.googleapis.com/TagKey" + pattern: "tagKeys/{tag_key}" + style: DECLARATIVE_FRIENDLY + }; + + // Immutable. The resource name for a TagKey. Must be in the format + // `tagKeys/{tag_key_id}`, where `tag_key_id` is the generated numeric id for + // the TagKey. + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. The resource name of the TagKey's parent. A TagKey can be + // parented by an Organization or a Project. For a TagKey parented by an + // Organization, its parent must be in the form `organizations/{org_id}`. For + // a TagKey parented by a Project, its parent can be in the form + // `projects/{project_id}` or `projects/{project_number}`. + string parent = 2 [(google.api.field_behavior) = IMMUTABLE]; + + // Required. Immutable. The user friendly name for a TagKey. The short name + // should be unique for TagKeys within the same tag namespace. + // + // The short name must be 1-63 characters, beginning and ending with + // an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), + // dots (.), and alphanumerics between. + string short_name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Output only. Immutable. Namespaced name of the TagKey. + string namespaced_name = 4 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Optional. User-assigned description of the TagKey. Must not exceed 256 + // characters. + // + // Read-write. + string description = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. Creation time. + google.protobuf.Timestamp create_time = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Update time. + google.protobuf.Timestamp update_time = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Entity tag which users can pass to prevent race conditions. This + // field is always set in server responses. See UpdateTagKeyRequest for + // details. + string etag = 8 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A purpose denotes that this Tag is intended for use in policies + // of a specific policy engine, and will involve that policy engine in + // management operations involving this Tag. A purpose does not grant a + // policy engine exclusive rights to the Tag, and it may be referenced by + // other policy engines. + // + // A purpose cannot be changed once set. + Purpose purpose = 11 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Purpose data corresponds to the policy system that the tag is + // intended for. See documentation for `Purpose` for formatting of this field. + // + // Purpose data cannot be changed once set. + map purpose_data = 12 + [(google.api.field_behavior) = OPTIONAL]; +} + +// The request message for listing all TagKeys under a parent resource. +message ListTagKeysRequest { + // Required. The resource name of the TagKey's parent. + // Must be of the form `organizations/{org_id}` or `projects/{project_id}` or + // `projects/{project_number}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { child_type: "*" } + ]; + + // Optional. The maximum number of TagKeys to return in the response. The + // server allows a maximum of 300 TagKeys to return. If unspecified, the + // server will use 100 as the default. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A pagination token returned from a previous call to `ListTagKey` + // that indicates where this listing should continue from. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The ListTagKeys response message. +message ListTagKeysResponse { + // List of TagKeys that live under the specified parent in the request. + repeated TagKey tag_keys = 1; + + // A pagination token returned from a previous call to `ListTagKeys` + // that indicates from where listing should continue. + string next_page_token = 2; +} + +// The request message for getting a TagKey. +message GetTagKeyRequest { + // Required. A resource name in the format `tagKeys/{id}`, such as + // `tagKeys/123`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/TagKey" + } + ]; +} + +// The request message for getting a TagKey by its namespaced name. +message GetNamespacedTagKeyRequest { + // Required. A namespaced tag key name in the format + // `{parentId}/{tagKeyShort}`, such as `42/foo` for a key with short name + // "foo" under the organization with ID 42 or `r2-d2/bar` for a key with short + // name "bar" under the project `r2-d2`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/TagKey" + } + ]; +} + +// The request message for creating a TagKey. +message CreateTagKeyRequest { + // Required. The TagKey to be created. Only fields `short_name`, + // `description`, and `parent` are considered during the creation request. + TagKey tag_key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Set to true to perform validations necessary for creating the + // resource, but not actually perform the action. + bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Runtime operation information for creating a TagKey. +message CreateTagKeyMetadata {} + +// The request message for updating a TagKey. +message UpdateTagKeyRequest { + // Required. The new definition of the TagKey. Only the `description` and + // `etag` fields can be updated by this request. If the `etag` field is not + // empty, it must match the `etag` field of the existing tag key. Otherwise, + // `ABORTED` will be returned. + TagKey tag_key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Fields to be updated. The mask may only contain `description` or + // `etag`. If omitted entirely, both `description` and `etag` are assumed to + // be significant. + google.protobuf.FieldMask update_mask = 2; + + // Set as true to perform validations necessary for updating the resource, but + // not actually perform the action. + bool validate_only = 3; +} + +// Runtime operation information for updating a TagKey. +message UpdateTagKeyMetadata {} + +// The request message for deleting a TagKey. +message DeleteTagKeyRequest { + // Required. The resource name of a TagKey to be deleted in the format + // `tagKeys/123`. The TagKey cannot be a parent of any existing TagValues or + // it will not be deleted successfully. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/TagKey" + } + ]; + + // Optional. Set as true to perform validations necessary for deletion, but + // not actually perform the action. + bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The etag known to the client for the expected state of the + // TagKey. This is to be used for optimistic concurrency. + string etag = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Runtime operation information for deleting a TagKey. +message DeleteTagKeyMetadata {} + +// A purpose for each policy engine requiring such an integration. A single +// policy engine may have multiple purposes defined, however a TagKey may only +// specify a single purpose. +enum Purpose { + // Unspecified purpose. + PURPOSE_UNSPECIFIED = 0; + + // Purpose for Compute Engine firewalls. + // A corresponding `purpose_data` should be set for the network the tag is + // intended for. The key should be `network` and the value should be in + // either of these two formats: + // + // - + // `https://www.googleapis.com/compute/{compute_version}/projects/{project_id}/global/networks/{network_id}` + // - `{project_id}/{network_name}` + // + // Examples: + // + // - + // `https://www.googleapis.com/compute/staging_v1/projects/fail-closed-load-testing/global/networks/6992953698831725600` + // - `fail-closed-load-testing/load-testing-network` + GCE_FIREWALL = 1; +} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_values.proto b/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_values.proto new file mode 100644 index 00000000000..9a5bd7f1ffb --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_values.proto @@ -0,0 +1,331 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.resourcemanager.v3; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.ResourceManager.V3"; +option go_package = "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb;resourcemanagerpb"; +option java_multiple_files = true; +option java_outer_classname = "TagValuesProto"; +option java_package = "com.google.cloud.resourcemanager.v3"; +option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; +option ruby_package = "Google::Cloud::ResourceManager::V3"; + +// Allow users to create and manage tag values. +service TagValues { + option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-platform.read-only"; + + // Lists all TagValues for a specific TagKey. + rpc ListTagValues(ListTagValuesRequest) returns (ListTagValuesResponse) { + option (google.api.http) = { + get: "/v3/tagValues" + }; + option (google.api.method_signature) = "parent"; + } + + // Retrieves a TagValue. This method will return `PERMISSION_DENIED` if the + // value does not exist or the user does not have permission to view it. + rpc GetTagValue(GetTagValueRequest) returns (TagValue) { + option (google.api.http) = { + get: "/v3/{name=tagValues/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Retrieves a TagValue by its namespaced name. + // This method will return `PERMISSION_DENIED` if the value does not exist + // or the user does not have permission to view it. + rpc GetNamespacedTagValue(GetNamespacedTagValueRequest) returns (TagValue) { + option (google.api.http) = { + get: "/v3/tagValues/namespaced" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a TagValue as a child of the specified TagKey. If a another + // request with the same parameters is sent while the original request is in + // process the second request will receive an error. A maximum of 1000 + // TagValues can exist under a TagKey at any given time. + rpc CreateTagValue(CreateTagValueRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v3/tagValues" + body: "tag_value" + }; + option (google.api.method_signature) = "tag_value"; + option (google.longrunning.operation_info) = { + response_type: "TagValue" + metadata_type: "CreateTagValueMetadata" + }; + } + + // Updates the attributes of the TagValue resource. + rpc UpdateTagValue(UpdateTagValueRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v3/{tag_value.name=tagValues/*}" + body: "tag_value" + }; + option (google.api.method_signature) = "tag_value,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "TagValue" + metadata_type: "UpdateTagValueMetadata" + }; + } + + // Deletes a TagValue. The TagValue cannot have any bindings when it is + // deleted. + rpc DeleteTagValue(DeleteTagValueRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v3/{name=tagValues/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "TagValue" + metadata_type: "DeleteTagValueMetadata" + }; + } + + // Gets the access control policy for a TagValue. The returned policy may be + // empty if no such policy or resource exists. The `resource` field should + // be the TagValue's resource name. For example: `tagValues/1234`. + // The caller must have the + // `cloudresourcemanager.googleapis.com/tagValues.getIamPolicy` permission on + // the identified TagValue to get the access control policy. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) + returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v3/{resource=tagValues/*}:getIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource"; + } + + // Sets the access control policy on a TagValue, replacing any existing + // policy. The `resource` field should be the TagValue's resource name. + // For example: `tagValues/1234`. + // The caller must have `resourcemanager.tagValues.setIamPolicy` permission + // on the identified tagValue. + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) + returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v3/{resource=tagValues/*}:setIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource,policy"; + } + + // Returns permissions that a caller has on the specified TagValue. + // The `resource` field should be the TagValue's resource name. For example: + // `tagValues/1234`. + // + // There are no permissions required for making this API call. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) + returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v3/{resource=tagValues/*}:testIamPermissions" + body: "*" + }; + option (google.api.method_signature) = "resource,permissions"; + } +} + +// A TagValue is a child of a particular TagKey. This is used to group +// cloud resources for the purpose of controlling them using policies. +message TagValue { + option (google.api.resource) = { + type: "cloudresourcemanager.googleapis.com/TagValue" + pattern: "tagValues/{tag_value}" + style: DECLARATIVE_FRIENDLY + }; + + // Immutable. Resource name for TagValue in the format `tagValues/456`. + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. The resource name of the new TagValue's parent TagKey. + // Must be of the form `tagKeys/{tag_key_id}`. + string parent = 2 [(google.api.field_behavior) = IMMUTABLE]; + + // Required. Immutable. User-assigned short name for TagValue. The short name + // should be unique for TagValues within the same parent TagKey. + // + // The short name must be 63 characters or less, beginning and ending with + // an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), + // dots (.), and alphanumerics between. + string short_name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Output only. The namespaced name of the TagValue. Can be in the form + // `{organization_id}/{tag_key_short_name}/{tag_value_short_name}` or + // `{project_id}/{tag_key_short_name}/{tag_value_short_name}` or + // `{project_number}/{tag_key_short_name}/{tag_value_short_name}`. + string namespaced_name = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. User-assigned description of the TagValue. + // Must not exceed 256 characters. + // + // Read-write. + string description = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. Creation time. + google.protobuf.Timestamp create_time = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Update time. + google.protobuf.Timestamp update_time = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Entity tag which users can pass to prevent race conditions. This + // field is always set in server responses. See UpdateTagValueRequest for + // details. + string etag = 8 [(google.api.field_behavior) = OPTIONAL]; +} + +// The request message for listing TagValues for the specified TagKey. +// Resource name for TagKey, parent of the TagValues to be listed, +// in the format `tagKeys/123`. +message ListTagValuesRequest { + // Required. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { child_type: "*" } + ]; + + // Optional. The maximum number of TagValues to return in the response. The + // server allows a maximum of 300 TagValues to return. If unspecified, the + // server will use 100 as the default. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A pagination token returned from a previous call to + // `ListTagValues` that indicates where this listing should continue from. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The ListTagValues response. +message ListTagValuesResponse { + // A possibly paginated list of TagValues that are direct descendants of + // the specified parent TagKey. + repeated TagValue tag_values = 1; + + // A pagination token returned from a previous call to `ListTagValues` + // that indicates from where listing should continue. This is currently not + // used, but the server may at any point start supplying a valid token. + string next_page_token = 2; +} + +// The request message for getting a TagValue. +message GetTagValueRequest { + // Required. Resource name for TagValue to be fetched in the format + // `tagValues/456`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/TagValue" + } + ]; +} + +// The request message for getting a TagValue by its namespaced name. +message GetNamespacedTagValueRequest { + // Required. A namespaced tag value name in the following format: + // + // `{parentId}/{tagKeyShort}/{tagValueShort}` + // + // Examples: + // - `42/foo/abc` for a value with short name "abc" under the key with short + // name "foo" under the organization with ID 42 + // - `r2-d2/bar/xyz` for a value with short name "xyz" under the key with + // short name "bar" under the project with ID "r2-d2" + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/TagValue" + } + ]; +} + +// The request message for creating a TagValue. +message CreateTagValueRequest { + // Required. The TagValue to be created. Only fields `short_name`, + // `description`, and `parent` are considered during the creation request. + TagValue tag_value = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Set as true to perform the validations necessary for creating the + // resource, but not actually perform the action. + bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Runtime operation information for creating a TagValue. +message CreateTagValueMetadata {} + +// The request message for updating a TagValue. +message UpdateTagValueRequest { + // Required. The new definition of the TagValue. Only fields `description` and + // `etag` fields can be updated by this request. If the `etag` field is + // nonempty, it must match the `etag` field of the existing ControlGroup. + // Otherwise, `ABORTED` will be returned. + TagValue tag_value = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Fields to be updated. + google.protobuf.FieldMask update_mask = 2 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. True to perform validations necessary for updating the resource, + // but not actually perform the action. + bool validate_only = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Runtime operation information for updating a TagValue. +message UpdateTagValueMetadata {} + +// The request message for deleting a TagValue. +message DeleteTagValueRequest { + // Required. Resource name for TagValue to be deleted in the format + // tagValues/456. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/TagValue" + } + ]; + + // Optional. Set as true to perform the validations necessary for deletion, + // but not actually perform the action. + bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The etag known to the client for the expected state of the + // TagValue. This is to be used for optimistic concurrency. + string etag = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Runtime operation information for deleting a TagValue. +message DeleteTagValueMetadata {} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.create_folder.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.create_folder.js new file mode 100644 index 00000000000..8a5c3872277 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.create_folder.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(folder) { + // [START cloudresourcemanager_v3_generated_Folders_CreateFolder_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The folder being created, only the display name and parent will + * be consulted. All other fields will be ignored. + */ + // const folder = {} + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callCreateFolder() { + // Construct request + const request = { + folder, + }; + + // Run request + const [operation] = await resourcemanagerClient.createFolder(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateFolder(); + // [END cloudresourcemanager_v3_generated_Folders_CreateFolder_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.delete_folder.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.delete_folder.js new file mode 100644 index 00000000000..fa200d20783 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.delete_folder.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 cloudresourcemanager_v3_generated_Folders_DeleteFolder_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 folder to be deleted. + * Must be of the form `folders/{folder_id}`. + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callDeleteFolder() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await resourcemanagerClient.deleteFolder(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteFolder(); + // [END cloudresourcemanager_v3_generated_Folders_DeleteFolder_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.get_folder.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.get_folder.js new file mode 100644 index 00000000000..1ae3c1fd09e --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.get_folder.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 cloudresourcemanager_v3_generated_Folders_GetFolder_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 folder to retrieve. + * Must be of the form `folders/{folder_id}`. + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callGetFolder() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await resourcemanagerClient.getFolder(request); + console.log(response); + } + + callGetFolder(); + // [END cloudresourcemanager_v3_generated_Folders_GetFolder_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.get_iam_policy.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.get_iam_policy.js new file mode 100644 index 00000000000..325e23e3e20 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.get_iam_policy.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(resource) { + // [START cloudresourcemanager_v3_generated_Folders_GetIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + */ + // const options = {} + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await resourcemanagerClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END cloudresourcemanager_v3_generated_Folders_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.list_folders.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.list_folders.js new file mode 100644 index 00000000000..ace19a6ceb7 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.list_folders.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 cloudresourcemanager_v3_generated_Folders_ListFolders_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 parent resource whose folders are being listed. + * Only children of this parent resource are listed; descendants are not + * listed. + * If the parent is a folder, use the value `folders/{folder_id}`. If the + * parent is an organization, use the value `organizations/{org_id}`. + * Access to this method is controlled by checking the + * `resourcemanager.folders.list` permission on the `parent`. + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of folders to return in the response. The + * server can return fewer folders than requested. If unspecified, server + * picks an appropriate default. + */ + // const pageSize = 1234 + /** + * Optional. A pagination token returned from a previous call to `ListFolders` + * that indicates where this listing should continue from. + */ + // const pageToken = 'abc123' + /** + * Optional. Controls whether folders in the + * DELETE_REQUESTED google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED + * state should be returned. Defaults to false. + */ + // const showDeleted = true + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callListFolders() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await resourcemanagerClient.listFoldersAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListFolders(); + // [END cloudresourcemanager_v3_generated_Folders_ListFolders_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.move_folder.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.move_folder.js new file mode 100644 index 00000000000..b279ea6393a --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.move_folder.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(name, destinationParent) { + // [START cloudresourcemanager_v3_generated_Folders_MoveFolder_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 Folder to move. + * Must be of the form folders/{folder_id} + */ + // const name = 'abc123' + /** + * Required. The resource name of the folder or organization which should be + * the folder's new parent. Must be of the form `folders/{folder_id}` or + * `organizations/{org_id}`. + */ + // const destinationParent = 'abc123' + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callMoveFolder() { + // Construct request + const request = { + name, + destinationParent, + }; + + // Run request + const [operation] = await resourcemanagerClient.moveFolder(request); + const [response] = await operation.promise(); + console.log(response); + } + + callMoveFolder(); + // [END cloudresourcemanager_v3_generated_Folders_MoveFolder_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.search_folders.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.search_folders.js new file mode 100644 index 00000000000..4cc9c93c7f3 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.search_folders.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() { + // [START cloudresourcemanager_v3_generated_Folders_SearchFolders_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Optional. The maximum number of folders to return in the response. The + * server can return fewer folders than requested. If unspecified, server + * picks an appropriate default. + */ + // const pageSize = 1234 + /** + * Optional. A pagination token returned from a previous call to + * `SearchFolders` that indicates from where search should continue. + */ + // const pageToken = 'abc123' + /** + * Optional. Search criteria used to select the folders to return. + * If no search criteria is specified then all accessible folders will be + * returned. + * Query expressions can be used to restrict results based upon displayName, + * state and parent, where the operators `=` (`:`) `NOT`, `AND` and `OR` + * can be used along with the suffix wildcard symbol `*`. + * The `displayName` field in a query expression should use escaped quotes + * for values that include whitespace to prevent unexpected behavior. + * ``` + * | Field | Description | + * |-------------------------|----------------------------------------| + * | displayName | Filters by displayName. | + * | parent | Filters by parent (for example: folders/123). | + * | state, lifecycleState | Filters by state. | + * ``` + * Some example queries are: + * * Query `displayName=Test*` returns Folder resources whose display name + * starts with "Test". + * * Query `state=ACTIVE` returns Folder resources with + * `state` set to `ACTIVE`. + * * Query `parent=folders/123` returns Folder resources that have + * `folders/123` as a parent resource. + * * Query `parent=folders/123 AND state=ACTIVE` returns active + * Folder resources that have `folders/123` as a parent resource. + * * Query `displayName=\\"Test String\\"` returns Folder resources with + * display names that include both "Test" and "String". + */ + // const query = 'abc123' + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callSearchFolders() { + // Construct request + const request = { + }; + + // Run request + const iterable = await resourcemanagerClient.searchFoldersAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearchFolders(); + // [END cloudresourcemanager_v3_generated_Folders_SearchFolders_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.set_iam_policy.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.set_iam_policy.js new file mode 100644 index 00000000000..7f681424e22 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.set_iam_policy.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(resource, policy) { + // [START cloudresourcemanager_v3_generated_Folders_SetIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + */ + // const policy = {} + /** + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * `paths: "bindings, etag"` + */ + // const updateMask = {} + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + resource, + policy, + }; + + // Run request + const response = await resourcemanagerClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END cloudresourcemanager_v3_generated_Folders_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.test_iam_permissions.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.test_iam_permissions.js new file mode 100644 index 00000000000..2a5cedde3a1 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.test_iam_permissions.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(resource, permissions) { + // [START cloudresourcemanager_v3_generated_Folders_TestIamPermissions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). + */ + // const permissions = ['abc','def'] + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + resource, + permissions, + }; + + // Run request + const response = await resourcemanagerClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END cloudresourcemanager_v3_generated_Folders_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.undelete_folder.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.undelete_folder.js new file mode 100644 index 00000000000..0173813c8be --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.undelete_folder.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 cloudresourcemanager_v3_generated_Folders_UndeleteFolder_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 folder to undelete. + * Must be of the form `folders/{folder_id}`. + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callUndeleteFolder() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await resourcemanagerClient.undeleteFolder(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUndeleteFolder(); + // [END cloudresourcemanager_v3_generated_Folders_UndeleteFolder_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.update_folder.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.update_folder.js new file mode 100644 index 00000000000..40d265b5847 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.update_folder.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(folder, updateMask) { + // [START cloudresourcemanager_v3_generated_Folders_UpdateFolder_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The new definition of the Folder. It must include the `name` + * field, which cannot be changed. + */ + // const folder = {} + /** + * Required. Fields to be updated. + * Only the `display_name` can be updated. + */ + // const updateMask = {} + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callUpdateFolder() { + // Construct request + const request = { + folder, + updateMask, + }; + + // Run request + const [operation] = await resourcemanagerClient.updateFolder(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateFolder(); + // [END cloudresourcemanager_v3_generated_Folders_UpdateFolder_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.get_iam_policy.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.get_iam_policy.js new file mode 100644 index 00000000000..ed4e78879f2 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.get_iam_policy.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(resource) { + // [START cloudresourcemanager_v3_generated_Organizations_GetIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + */ + // const options = {} + + // Imports the Resourcemanager library + const {OrganizationsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new OrganizationsClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await resourcemanagerClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END cloudresourcemanager_v3_generated_Organizations_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.get_organization.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.get_organization.js new file mode 100644 index 00000000000..674d25d155a --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.get_organization.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 cloudresourcemanager_v3_generated_Organizations_GetOrganization_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 Organization to fetch. This is the + * organization's relative path in the API, formatted as + * "organizations/[organizationId]". For example, "organizations/1234". + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {OrganizationsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new OrganizationsClient(); + + async function callGetOrganization() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await resourcemanagerClient.getOrganization(request); + console.log(response); + } + + callGetOrganization(); + // [END cloudresourcemanager_v3_generated_Organizations_GetOrganization_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.search_organizations.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.search_organizations.js new file mode 100644 index 00000000000..25a484a1d21 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.search_organizations.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() { + // [START cloudresourcemanager_v3_generated_Organizations_SearchOrganizations_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Optional. The maximum number of organizations to return in the response. + * The server can return fewer organizations than requested. If unspecified, + * server picks an appropriate default. + */ + // const pageSize = 1234 + /** + * Optional. A pagination token returned from a previous call to + * `SearchOrganizations` that indicates from where listing should continue. + */ + // const pageToken = 'abc123' + /** + * Optional. An optional query string used to filter the Organizations to + * return in the response. Query rules are case-insensitive. + * ``` + * | Field | Description | + * |------------------|--------------------------------------------| + * | directoryCustomerId, owner.directoryCustomerId | Filters by directory + * customer id. | + * | domain | Filters by domain. | + * ``` + * Organizations may be queried by `directoryCustomerId` or by + * `domain`, where the domain is a G Suite domain, for example: + * * Query `directorycustomerid:123456789` returns Organization + * resources with `owner.directory_customer_id` equal to `123456789`. + * * Query `domain:google.com` returns Organization resources corresponding + * to the domain `google.com`. + */ + // const query = 'abc123' + + // Imports the Resourcemanager library + const {OrganizationsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new OrganizationsClient(); + + async function callSearchOrganizations() { + // Construct request + const request = { + }; + + // Run request + const iterable = await resourcemanagerClient.searchOrganizationsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearchOrganizations(); + // [END cloudresourcemanager_v3_generated_Organizations_SearchOrganizations_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.set_iam_policy.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.set_iam_policy.js new file mode 100644 index 00000000000..2ff146e29d2 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.set_iam_policy.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(resource, policy) { + // [START cloudresourcemanager_v3_generated_Organizations_SetIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + */ + // const policy = {} + /** + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * `paths: "bindings, etag"` + */ + // const updateMask = {} + + // Imports the Resourcemanager library + const {OrganizationsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new OrganizationsClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + resource, + policy, + }; + + // Run request + const response = await resourcemanagerClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END cloudresourcemanager_v3_generated_Organizations_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.test_iam_permissions.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.test_iam_permissions.js new file mode 100644 index 00000000000..b2745aba020 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.test_iam_permissions.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(resource, permissions) { + // [START cloudresourcemanager_v3_generated_Organizations_TestIamPermissions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). + */ + // const permissions = ['abc','def'] + + // Imports the Resourcemanager library + const {OrganizationsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new OrganizationsClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + resource, + permissions, + }; + + // Run request + const response = await resourcemanagerClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END cloudresourcemanager_v3_generated_Organizations_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.create_project.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.create_project.js new file mode 100644 index 00000000000..73a6f5a6e67 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.create_project.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(project) { + // [START cloudresourcemanager_v3_generated_Projects_CreateProject_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Project to create. + * Project ID is required. If the requested ID is unavailable, the request + * fails. + * If the `parent` field is set, the `resourcemanager.projects.create` + * permission is checked on the parent resource. If no parent is set and + * the authorization credentials belong to an Organization, the parent + * will be set to that Organization. + */ + // const project = 'my-project' + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callCreateProject() { + // Construct request + const request = { + project, + }; + + // Run request + const [operation] = await resourcemanagerClient.createProject(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateProject(); + // [END cloudresourcemanager_v3_generated_Projects_CreateProject_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.delete_project.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.delete_project.js new file mode 100644 index 00000000000..7f8e2b71edd --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.delete_project.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 cloudresourcemanager_v3_generated_Projects_DeleteProject_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 Project (for example, `projects/415104041262`). + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callDeleteProject() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await resourcemanagerClient.deleteProject(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteProject(); + // [END cloudresourcemanager_v3_generated_Projects_DeleteProject_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.get_iam_policy.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.get_iam_policy.js new file mode 100644 index 00000000000..7caeec14912 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.get_iam_policy.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(resource) { + // [START cloudresourcemanager_v3_generated_Projects_GetIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + */ + // const options = {} + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await resourcemanagerClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END cloudresourcemanager_v3_generated_Projects_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.get_project.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.get_project.js new file mode 100644 index 00000000000..7e7a5b05c38 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.get_project.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(name) { + // [START cloudresourcemanager_v3_generated_Projects_GetProject_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 project (for example, `projects/415104041262`). + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callGetProject() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await resourcemanagerClient.getProject(request); + console.log(response); + } + + callGetProject(); + // [END cloudresourcemanager_v3_generated_Projects_GetProject_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.list_projects.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.list_projects.js new file mode 100644 index 00000000000..826637d500b --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.list_projects.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(parent) { + // [START cloudresourcemanager_v3_generated_Projects_ListProjects_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 parent resource whose projects are being listed. + * Only children of this parent resource are listed; descendants are not + * listed. + * If the parent is a folder, use the value `folders/{folder_id}`. If the + * parent is an organization, use the value `organizations/{org_id}`. + */ + // const parent = 'abc123' + /** + * Optional. A pagination token returned from a previous call to + * ListProjects google.cloud.resourcemanager.v3.Projects.ListProjects that + * indicates from where listing should continue. + */ + // const pageToken = 'abc123' + /** + * Optional. The maximum number of projects to return in the response. + * The server can return fewer projects than requested. + * If unspecified, server picks an appropriate default. + */ + // const pageSize = 1234 + /** + * Optional. Indicate that projects in the `DELETE_REQUESTED` state should + * also be returned. Normally only `ACTIVE` projects are returned. + */ + // const showDeleted = true + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callListProjects() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await resourcemanagerClient.listProjectsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProjects(); + // [END cloudresourcemanager_v3_generated_Projects_ListProjects_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.move_project.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.move_project.js new file mode 100644 index 00000000000..ce98dbc473e --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.move_project.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(name, destinationParent) { + // [START cloudresourcemanager_v3_generated_Projects_MoveProject_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 project to move. + */ + // const name = 'abc123' + /** + * Required. The new parent to move the Project under. + */ + // const destinationParent = 'abc123' + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callMoveProject() { + // Construct request + const request = { + name, + destinationParent, + }; + + // Run request + const [operation] = await resourcemanagerClient.moveProject(request); + const [response] = await operation.promise(); + console.log(response); + } + + callMoveProject(); + // [END cloudresourcemanager_v3_generated_Projects_MoveProject_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.search_projects.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.search_projects.js new file mode 100644 index 00000000000..e6faf50a836 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.search_projects.js @@ -0,0 +1,100 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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 cloudresourcemanager_v3_generated_Projects_SearchProjects_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Optional. A query string for searching for projects that the caller has + * `resourcemanager.projects.get` permission to. If multiple fields are + * included in the query, then it will return results that match any of the + * fields. Some eligible fields are: + * - **`displayName`, `name`**: Filters by displayName. + * - **`parent`**: Project's parent (for example: `folders/123`, + * `organizations/*`). Prefer `parent` field over `parent.type` and + * `parent.id`. + * - **`parent.type`**: Parent's type: `folder` or `organization`. + * - **`parent.id`**: Parent's id number (for example: `123`). + * - **`id`, `projectId`**: Filters by projectId. + * - **`state`, `lifecycleState`**: Filters by state. + * - **`labels`**: Filters by label name or value. + * - **`labels.` (where `` is the name of a label)**: Filters by label + * name. + * Search expressions are case insensitive. + * Some examples queries: + * - **`name:how*`**: The project's name starts with "how". + * - **`name:Howl`**: The project's name is `Howl` or `howl`. + * - **`name:HOWL`**: Equivalent to above. + * - **`NAME:howl`**: Equivalent to above. + * - **`labels.color:*`**: The project has the label `color`. + * - **`labels.color:red`**: The project's label `color` has the value `red`. + * - **`labels.color:red labels.size:big`**: The project's label `color` has + * the value `red` or its label `size` has the value `big`. + * If no query is specified, the call will return projects for which the user + * has the `resourcemanager.projects.get` permission. + */ + // const query = 'abc123' + /** + * Optional. A pagination token returned from a previous call to + * ListProjects google.cloud.resourcemanager.v3.Projects.ListProjects that + * indicates from where listing should continue. + */ + // const pageToken = 'abc123' + /** + * Optional. The maximum number of projects to return in the response. + * The server can return fewer projects than requested. + * If unspecified, server picks an appropriate default. + */ + // const pageSize = 1234 + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callSearchProjects() { + // Construct request + const request = { + }; + + // Run request + const iterable = await resourcemanagerClient.searchProjectsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearchProjects(); + // [END cloudresourcemanager_v3_generated_Projects_SearchProjects_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.set_iam_policy.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.set_iam_policy.js new file mode 100644 index 00000000000..dfa4711b253 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.set_iam_policy.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(resource, policy) { + // [START cloudresourcemanager_v3_generated_Projects_SetIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + */ + // const policy = {} + /** + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * `paths: "bindings, etag"` + */ + // const updateMask = {} + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + resource, + policy, + }; + + // Run request + const response = await resourcemanagerClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END cloudresourcemanager_v3_generated_Projects_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.test_iam_permissions.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.test_iam_permissions.js new file mode 100644 index 00000000000..acdf505b3a0 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.test_iam_permissions.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(resource, permissions) { + // [START cloudresourcemanager_v3_generated_Projects_TestIamPermissions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). + */ + // const permissions = ['abc','def'] + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + resource, + permissions, + }; + + // Run request + const response = await resourcemanagerClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END cloudresourcemanager_v3_generated_Projects_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.undelete_project.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.undelete_project.js new file mode 100644 index 00000000000..44a3a80bbac --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.undelete_project.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 cloudresourcemanager_v3_generated_Projects_UndeleteProject_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 project (for example, `projects/415104041262`). + * Required. + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callUndeleteProject() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await resourcemanagerClient.undeleteProject(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUndeleteProject(); + // [END cloudresourcemanager_v3_generated_Projects_UndeleteProject_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.update_project.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.update_project.js new file mode 100644 index 00000000000..45bb46af51c --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.update_project.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(project) { + // [START cloudresourcemanager_v3_generated_Projects_UpdateProject_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The new definition of the project. + */ + // const project = 'my-project' + /** + * Optional. An update mask to selectively update fields. + */ + // const updateMask = {} + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callUpdateProject() { + // Construct request + const request = { + project, + }; + + // Run request + const [operation] = await resourcemanagerClient.updateProject(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateProject(); + // [END cloudresourcemanager_v3_generated_Projects_UpdateProject_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/snippet_metadata_google.cloud.resourcemanager.v3.json b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/snippet_metadata_google.cloud.resourcemanager.v3.json new file mode 100644 index 00000000000..289856dddca --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/snippet_metadata_google.cloud.resourcemanager.v3.json @@ -0,0 +1,2339 @@ +{ + "clientLibrary": { + "name": "nodejs-resourcemanager", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.resourcemanager.v3", + "version": "v3" + } + ] + }, + "snippets": [ + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_GetFolder_async", + "title": "Folders getFolder Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a folder identified by the supplied resource name. Valid folder resource names have the format `folders/{folder_id}` (for example, `folders/1234`). The caller must have `resourcemanager.folders.get` permission on the identified folder.", + "canonical": true, + "file": "folders.get_folder.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.GetFolder", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.Folder", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "GetFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.GetFolder", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_ListFolders_async", + "title": "Folders listFolders Sample", + "origin": "API_DEFINITION", + "description": " Lists the folders that are direct descendants of supplied parent resource. `list()` provides a strongly consistent view of the folders underneath the specified parent resource. `list()` returns folders sorted based upon the (ascending) lexical ordering of their display_name. The caller must have `resourcemanager.folders.list` permission on the identified parent.", + "canonical": true, + "file": "folders.list_folders.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 78, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListFolders", + "fullName": "google.cloud.resourcemanager.v3.Folders.ListFolders", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "show_deleted", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.ListFoldersResponse", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "ListFolders", + "fullName": "google.cloud.resourcemanager.v3.Folders.ListFolders", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_SearchFolders_async", + "title": "Folders searchFolders Sample", + "origin": "API_DEFINITION", + "description": " Search for folders that match specific filter criteria. `search()` provides an eventually consistent view of the folders a user has access to which meet the specified filter criteria. This will only return folders on which the caller has the permission `resourcemanager.folders.get`.", + "canonical": true, + "file": "folders.search_folders.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 90, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SearchFolders", + "fullName": "google.cloud.resourcemanager.v3.Folders.SearchFolders", + "async": true, + "parameters": [ + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.SearchFoldersResponse", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "SearchFolders", + "fullName": "google.cloud.resourcemanager.v3.Folders.SearchFolders", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_CreateFolder_async", + "title": "Folders createFolder Sample", + "origin": "API_DEFINITION", + "description": " Creates a folder in the resource hierarchy. Returns an `Operation` which can be used to track the progress of the folder creation workflow. Upon success, the `Operation.response` field will be populated with the created Folder. In order to succeed, the addition of this new folder must not violate the folder naming, height, or fanout constraints. + The folder's `display_name` must be distinct from all other folders that share its parent. + The addition of the folder must not cause the active folder hierarchy to exceed a height of 10. Note, the full active + deleted folder hierarchy is allowed to reach a height of 20; this provides additional headroom when moving folders that contain deleted folders. + The addition of the folder must not cause the total number of folders under its parent to exceed 300. If the operation fails due to a folder constraint violation, some errors may be returned by the `CreateFolder` request, with status code `FAILED_PRECONDITION` and an error description. Other folder constraint violations will be communicated in the `Operation`, with the specific `PreconditionFailure` returned in the details list in the `Operation.error` field. The caller must have `resourcemanager.folders.create` permission on the identified parent.", + "canonical": true, + "file": "folders.create_folder.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.CreateFolder", + "async": true, + "parameters": [ + { + "name": "folder", + "type": ".google.cloud.resourcemanager.v3.Folder" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "CreateFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.CreateFolder", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_UpdateFolder_async", + "title": "Folders updateFolder Sample", + "origin": "API_DEFINITION", + "description": " Updates a folder, changing its `display_name`. Changes to the folder `display_name` will be rejected if they violate either the `display_name` formatting rules or the naming constraints described in the [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] documentation. The folder's `display_name` must start and end with a letter or digit, may contain letters, digits, spaces, hyphens and underscores and can be between 3 and 30 characters. This is captured by the regular expression: `[\\p{L}\\p{N}][\\p{L}\\p{N}_- ]{1,28}[\\p{L}\\p{N}]`. The caller must have `resourcemanager.folders.update` permission on the identified folder. If the update fails due to the unique name constraint then a `PreconditionFailure` explaining this violation will be returned in the Status.details field.", + "canonical": true, + "file": "folders.update_folder.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.UpdateFolder", + "async": true, + "parameters": [ + { + "name": "folder", + "type": ".google.cloud.resourcemanager.v3.Folder" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "UpdateFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.UpdateFolder", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_MoveFolder_async", + "title": "Folders moveFolder Sample", + "origin": "API_DEFINITION", + "description": " Moves a folder under a new resource parent. Returns an `Operation` which can be used to track the progress of the folder move workflow. Upon success, the `Operation.response` field will be populated with the moved folder. Upon failure, a `FolderOperationError` categorizing the failure cause will be returned - if the failure occurs synchronously then the `FolderOperationError` will be returned in the `Status.details` field. If it occurs asynchronously, then the FolderOperation will be returned in the `Operation.error` field. In addition, the `Operation.metadata` field will be populated with a `FolderOperation` message as an aid to stateless clients. Folder moves will be rejected if they violate either the naming, height, or fanout constraints described in the [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] documentation. The caller must have `resourcemanager.folders.move` permission on the folder's current and proposed new parent.", + "canonical": true, + "file": "folders.move_folder.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "MoveFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.MoveFolder", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "destination_parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "MoveFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.MoveFolder", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_DeleteFolder_async", + "title": "Folders deleteFolder Sample", + "origin": "API_DEFINITION", + "description": " Requests deletion of a folder. The folder is moved into the [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] state immediately, and is deleted approximately 30 days later. This method may only be called on an empty folder, where a folder is empty if it doesn't contain any folders or projects in the [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. If called on a folder in [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] state the operation will result in a no-op success. The caller must have `resourcemanager.folders.delete` permission on the identified folder.", + "canonical": true, + "file": "folders.delete_folder.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.DeleteFolder", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "DeleteFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.DeleteFolder", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_UndeleteFolder_async", + "title": "Folders undeleteFolder Sample", + "origin": "API_DEFINITION", + "description": " Cancels the deletion request for a folder. This method may be called on a folder in any state. If the folder is in the [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state the result will be a no-op success. In order to succeed, the folder's parent must be in the [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. In addition, reintroducing the folder into the tree must not violate folder naming, height, and fanout constraints described in the [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] documentation. The caller must have `resourcemanager.folders.undelete` permission on the identified folder.", + "canonical": true, + "file": "folders.undelete_folder.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UndeleteFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.UndeleteFolder", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "UndeleteFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.UndeleteFolder", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_GetIamPolicy_async", + "title": "Folders getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a folder. The returned policy may be empty if no such policy or resource exists. The `resource` field should be the folder's resource name, for example: \"folders/1234\". The caller must have `resourcemanager.folders.getIamPolicy` permission on the identified folder.", + "canonical": true, + "file": "folders.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Folders.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.iam.v1.GetPolicyOptions" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Folders.GetIamPolicy", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_SetIamPolicy_async", + "title": "Folders setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on a folder, replacing any existing policy. The `resource` field should be the folder's resource name, for example: \"folders/1234\". The caller must have `resourcemanager.folders.setIamPolicy` permission on the identified folder.", + "canonical": true, + "file": "folders.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Folders.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "policy", + "type": ".google.iam.v1.Policy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Folders.SetIamPolicy", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_TestIamPermissions_async", + "title": "Folders testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified folder. The `resource` field should be the folder's resource name, for example: \"folders/1234\". There are no permissions required for making this API call.", + "canonical": true, + "file": "folders.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.resourcemanager.v3.Folders.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "permissions", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.iam.v1.TestIamPermissionsResponse", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.resourcemanager.v3.Folders.TestIamPermissions", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Organizations_GetOrganization_async", + "title": "Folders getOrganization Sample", + "origin": "API_DEFINITION", + "description": " Fetches an organization resource identified by the specified resource name.", + "canonical": true, + "file": "organizations.get_organization.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetOrganization", + "fullName": "google.cloud.resourcemanager.v3.Organizations.GetOrganization", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.Organization", + "client": { + "shortName": "OrganizationsClient", + "fullName": "google.cloud.resourcemanager.v3.OrganizationsClient" + }, + "method": { + "shortName": "GetOrganization", + "fullName": "google.cloud.resourcemanager.v3.Organizations.GetOrganization", + "service": { + "shortName": "Organizations", + "fullName": "google.cloud.resourcemanager.v3.Organizations" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Organizations_SearchOrganizations_async", + "title": "Folders searchOrganizations Sample", + "origin": "API_DEFINITION", + "description": " Searches organization resources that are visible to the user and satisfy the specified filter. This method returns organizations in an unspecified order. New organizations do not necessarily appear at the end of the results, and may take a small amount of time to appear. Search will only return organizations on which the user has the permission `resourcemanager.organizations.get`", + "canonical": true, + "file": "organizations.search_organizations.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SearchOrganizations", + "fullName": "google.cloud.resourcemanager.v3.Organizations.SearchOrganizations", + "async": true, + "parameters": [ + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.SearchOrganizationsResponse", + "client": { + "shortName": "OrganizationsClient", + "fullName": "google.cloud.resourcemanager.v3.OrganizationsClient" + }, + "method": { + "shortName": "SearchOrganizations", + "fullName": "google.cloud.resourcemanager.v3.Organizations.SearchOrganizations", + "service": { + "shortName": "Organizations", + "fullName": "google.cloud.resourcemanager.v3.Organizations" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Organizations_GetIamPolicy_async", + "title": "Folders getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for an organization resource. The policy may be empty if no such policy or resource exists. The `resource` field should be the organization's resource name, for example: \"organizations/123\". Authorization requires the IAM permission `resourcemanager.organizations.getIamPolicy` on the specified organization.", + "canonical": true, + "file": "organizations.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Organizations.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.iam.v1.GetPolicyOptions" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "OrganizationsClient", + "fullName": "google.cloud.resourcemanager.v3.OrganizationsClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Organizations.GetIamPolicy", + "service": { + "shortName": "Organizations", + "fullName": "google.cloud.resourcemanager.v3.Organizations" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Organizations_SetIamPolicy_async", + "title": "Folders setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on an organization resource. Replaces any existing policy. The `resource` field should be the organization's resource name, for example: \"organizations/123\". Authorization requires the IAM permission `resourcemanager.organizations.setIamPolicy` on the specified organization.", + "canonical": true, + "file": "organizations.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Organizations.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "policy", + "type": ".google.iam.v1.Policy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "OrganizationsClient", + "fullName": "google.cloud.resourcemanager.v3.OrganizationsClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Organizations.SetIamPolicy", + "service": { + "shortName": "Organizations", + "fullName": "google.cloud.resourcemanager.v3.Organizations" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Organizations_TestIamPermissions_async", + "title": "Folders testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns the permissions that a caller has on the specified organization. The `resource` field should be the organization's resource name, for example: \"organizations/123\". There are no permissions required for making this API call.", + "canonical": true, + "file": "organizations.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.resourcemanager.v3.Organizations.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "permissions", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.iam.v1.TestIamPermissionsResponse", + "client": { + "shortName": "OrganizationsClient", + "fullName": "google.cloud.resourcemanager.v3.OrganizationsClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.resourcemanager.v3.Organizations.TestIamPermissions", + "service": { + "shortName": "Organizations", + "fullName": "google.cloud.resourcemanager.v3.Organizations" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_GetProject_async", + "title": "Folders getProject Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the project identified by the specified `name` (for example, `projects/415104041262`). The caller must have `resourcemanager.projects.get` permission for this project.", + "canonical": true, + "file": "projects.get_project.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.GetProject", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.Project", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "GetProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.GetProject", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_ListProjects_async", + "title": "Folders listProjects Sample", + "origin": "API_DEFINITION", + "description": " Lists projects that are direct children of the specified folder or organization resource. `list()` provides a strongly consistent view of the projects underneath the specified parent resource. `list()` returns projects sorted based upon the (ascending) lexical ordering of their `display_name`. The caller must have `resourcemanager.projects.list` permission on the identified parent.", + "canonical": true, + "file": "projects.list_projects.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 76, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProjects", + "fullName": "google.cloud.resourcemanager.v3.Projects.ListProjects", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "show_deleted", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.ListProjectsResponse", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "ListProjects", + "fullName": "google.cloud.resourcemanager.v3.Projects.ListProjects", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_SearchProjects_async", + "title": "Folders searchProjects Sample", + "origin": "API_DEFINITION", + "description": " Search for projects that the caller has both `resourcemanager.projects.get` permission on, and also satisfy the specified query. This method returns projects in an unspecified order. This method is eventually consistent with project mutations; this means that a newly created project may not appear in the results or recent updates to an existing project may not be reflected in the results. To retrieve the latest state of a project, use the [GetProject][google.cloud.resourcemanager.v3.Projects.GetProject] method.", + "canonical": true, + "file": "projects.search_projects.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 92, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SearchProjects", + "fullName": "google.cloud.resourcemanager.v3.Projects.SearchProjects", + "async": true, + "parameters": [ + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.SearchProjectsResponse", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "SearchProjects", + "fullName": "google.cloud.resourcemanager.v3.Projects.SearchProjects", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_CreateProject_async", + "title": "Folders createProject Sample", + "origin": "API_DEFINITION", + "description": " Request that a new project be created. The result is an `Operation` which can be used to track the creation process. This process usually takes a few seconds, but can sometimes take much longer. The tracking `Operation` is automatically deleted after a few hours, so there is no need to call `DeleteOperation`.", + "canonical": true, + "file": "projects.create_project.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.CreateProject", + "async": true, + "parameters": [ + { + "name": "project", + "type": ".google.cloud.resourcemanager.v3.Project" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "CreateProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.CreateProject", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_UpdateProject_async", + "title": "Folders updateProject Sample", + "origin": "API_DEFINITION", + "description": " Updates the `display_name` and labels of the project identified by the specified `name` (for example, `projects/415104041262`). Deleting all labels requires an update mask for labels field. The caller must have `resourcemanager.projects.update` permission for this project.", + "canonical": true, + "file": "projects.update_project.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.UpdateProject", + "async": true, + "parameters": [ + { + "name": "project", + "type": ".google.cloud.resourcemanager.v3.Project" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "UpdateProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.UpdateProject", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_MoveProject_async", + "title": "Folders moveProject Sample", + "origin": "API_DEFINITION", + "description": " Move a project to another place in your resource hierarchy, under a new resource parent. Returns an operation which can be used to track the process of the project move workflow. Upon success, the `Operation.response` field will be populated with the moved project. The caller must have `resourcemanager.projects.move` permission on the project, on the project's current and proposed new parent. If project has no current parent, or it currently does not have an associated organization resource, you will also need the `resourcemanager.projects.setIamPolicy` permission in the project.", + "canonical": true, + "file": "projects.move_project.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "MoveProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.MoveProject", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "destination_parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "MoveProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.MoveProject", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_DeleteProject_async", + "title": "Folders deleteProject Sample", + "origin": "API_DEFINITION", + "description": " Marks the project identified by the specified `name` (for example, `projects/415104041262`) for deletion. This method will only affect the project if it has a lifecycle state of [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE]. This method changes the Project's lifecycle state from [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE] to [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Project.State.DELETE_REQUESTED]. The deletion starts at an unspecified time, at which point the Project is no longer accessible. Until the deletion completes, you can check the lifecycle state checked by retrieving the project with [GetProject] [google.cloud.resourcemanager.v3.Projects.GetProject], and the project remains visible to [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects]. However, you cannot update the project. After the deletion completes, the project is not retrievable by the [GetProject] [google.cloud.resourcemanager.v3.Projects.GetProject], [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects], and [SearchProjects][google.cloud.resourcemanager.v3.Projects.SearchProjects] methods. This method behaves idempotently, such that deleting a `DELETE_REQUESTED` project will not cause an error, but also won't do anything. The caller must have `resourcemanager.projects.delete` permissions for this project.", + "canonical": true, + "file": "projects.delete_project.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.DeleteProject", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "DeleteProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.DeleteProject", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_UndeleteProject_async", + "title": "Folders undeleteProject Sample", + "origin": "API_DEFINITION", + "description": " Restores the project identified by the specified `name` (for example, `projects/415104041262`). You can only use this method for a project that has a lifecycle state of [DELETE_REQUESTED] [Projects.State.DELETE_REQUESTED]. After deletion starts, the project cannot be restored. The caller must have `resourcemanager.projects.undelete` permission for this project.", + "canonical": true, + "file": "projects.undelete_project.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UndeleteProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.UndeleteProject", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "UndeleteProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.UndeleteProject", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_GetIamPolicy_async", + "title": "Folders getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Returns the IAM access control policy for the specified project, in the format `projects/{ProjectIdOrNumber}` e.g. projects/123. Permission is denied if the policy or the resource do not exist.", + "canonical": true, + "file": "projects.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Projects.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.iam.v1.GetPolicyOptions" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Projects.GetIamPolicy", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_SetIamPolicy_async", + "title": "Folders setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the IAM access control policy for the specified project, in the format `projects/{ProjectIdOrNumber}` e.g. projects/123. CAUTION: This method will replace the existing policy, and cannot be used to append additional IAM settings. Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles. The following constraints apply when using `setIamPolicy()`: + Project does not support `allUsers` and `allAuthenticatedUsers` as `members` in a `Binding` of a `Policy`. + The owner role can be granted to a `user`, `serviceAccount`, or a group that is part of an organization. For example, group@myownpersonaldomain.com could be added as an owner to a project in the myownpersonaldomain.com organization, but not the examplepetstore.com organization. + Service accounts can be made owners of a project directly without any restrictions. However, to be added as an owner, a user must be invited using the Cloud Platform console and must accept the invitation. + A user cannot be granted the owner role using `setIamPolicy()`. The user must be granted the owner role using the Cloud Platform Console and must explicitly accept the invitation. + Invitations to grant the owner role cannot be sent using `setIamPolicy()`; they must be sent only using the Cloud Platform Console. + If the project is not part of an organization, there must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner from the policy will fail. This restriction also applies to legacy projects that no longer have owners who have accepted the ToS. Edits to IAM policies will be rejected until the lack of a ToS-accepting owner is rectified. If the project is part of an organization, you can remove all owners, potentially making the organization inaccessible.", + "canonical": true, + "file": "projects.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Projects.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "policy", + "type": ".google.iam.v1.Policy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Projects.SetIamPolicy", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_TestIamPermissions_async", + "title": "Folders testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified project, in the format `projects/{ProjectIdOrNumber}` e.g. projects/123..", + "canonical": true, + "file": "projects.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.resourcemanager.v3.Projects.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "permissions", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.iam.v1.TestIamPermissionsResponse", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.resourcemanager.v3.Projects.TestIamPermissions", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagBindings_ListTagBindings_async", + "title": "Folders listTagBindings Sample", + "origin": "API_DEFINITION", + "description": " Lists the TagBindings for the given Google Cloud resource, as specified with `parent`. NOTE: The `parent` field is expected to be a full resource name: https://cloud.google.com/apis/design/resource_names#full_resource_name", + "canonical": true, + "file": "tag_bindings.list_tag_bindings.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListTagBindings", + "fullName": "google.cloud.resourcemanager.v3.TagBindings.ListTagBindings", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.ListTagBindingsResponse", + "client": { + "shortName": "TagBindingsClient", + "fullName": "google.cloud.resourcemanager.v3.TagBindingsClient" + }, + "method": { + "shortName": "ListTagBindings", + "fullName": "google.cloud.resourcemanager.v3.TagBindings.ListTagBindings", + "service": { + "shortName": "TagBindings", + "fullName": "google.cloud.resourcemanager.v3.TagBindings" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagBindings_CreateTagBinding_async", + "title": "Folders createTagBinding Sample", + "origin": "API_DEFINITION", + "description": " Creates a TagBinding between a TagValue and a Google Cloud resource.", + "canonical": true, + "file": "tag_bindings.create_tag_binding.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateTagBinding", + "fullName": "google.cloud.resourcemanager.v3.TagBindings.CreateTagBinding", + "async": true, + "parameters": [ + { + "name": "tag_binding", + "type": ".google.cloud.resourcemanager.v3.TagBinding" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TagBindingsClient", + "fullName": "google.cloud.resourcemanager.v3.TagBindingsClient" + }, + "method": { + "shortName": "CreateTagBinding", + "fullName": "google.cloud.resourcemanager.v3.TagBindings.CreateTagBinding", + "service": { + "shortName": "TagBindings", + "fullName": "google.cloud.resourcemanager.v3.TagBindings" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagBindings_DeleteTagBinding_async", + "title": "Folders deleteTagBinding Sample", + "origin": "API_DEFINITION", + "description": " Deletes a TagBinding.", + "canonical": true, + "file": "tag_bindings.delete_tag_binding.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteTagBinding", + "fullName": "google.cloud.resourcemanager.v3.TagBindings.DeleteTagBinding", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TagBindingsClient", + "fullName": "google.cloud.resourcemanager.v3.TagBindingsClient" + }, + "method": { + "shortName": "DeleteTagBinding", + "fullName": "google.cloud.resourcemanager.v3.TagBindings.DeleteTagBinding", + "service": { + "shortName": "TagBindings", + "fullName": "google.cloud.resourcemanager.v3.TagBindings" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagBindings_ListEffectiveTags_async", + "title": "Folders listEffectiveTags Sample", + "origin": "API_DEFINITION", + "description": " Return a list of effective tags for the given Google Cloud resource, as specified in `parent`.", + "canonical": true, + "file": "tag_bindings.list_effective_tags.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListEffectiveTags", + "fullName": "google.cloud.resourcemanager.v3.TagBindings.ListEffectiveTags", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.ListEffectiveTagsResponse", + "client": { + "shortName": "TagBindingsClient", + "fullName": "google.cloud.resourcemanager.v3.TagBindingsClient" + }, + "method": { + "shortName": "ListEffectiveTags", + "fullName": "google.cloud.resourcemanager.v3.TagBindings.ListEffectiveTags", + "service": { + "shortName": "TagBindings", + "fullName": "google.cloud.resourcemanager.v3.TagBindings" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagHolds_CreateTagHold_async", + "title": "Folders createTagHold Sample", + "origin": "API_DEFINITION", + "description": " Creates a TagHold. Returns ALREADY_EXISTS if a TagHold with the same resource and origin exists under the same TagValue.", + "canonical": true, + "file": "tag_holds.create_tag_hold.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateTagHold", + "fullName": "google.cloud.resourcemanager.v3.TagHolds.CreateTagHold", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "tag_hold", + "type": ".google.cloud.resourcemanager.v3.TagHold" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TagHoldsClient", + "fullName": "google.cloud.resourcemanager.v3.TagHoldsClient" + }, + "method": { + "shortName": "CreateTagHold", + "fullName": "google.cloud.resourcemanager.v3.TagHolds.CreateTagHold", + "service": { + "shortName": "TagHolds", + "fullName": "google.cloud.resourcemanager.v3.TagHolds" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagHolds_DeleteTagHold_async", + "title": "Folders deleteTagHold Sample", + "origin": "API_DEFINITION", + "description": " Deletes a TagHold.", + "canonical": true, + "file": "tag_holds.delete_tag_hold.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteTagHold", + "fullName": "google.cloud.resourcemanager.v3.TagHolds.DeleteTagHold", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TagHoldsClient", + "fullName": "google.cloud.resourcemanager.v3.TagHoldsClient" + }, + "method": { + "shortName": "DeleteTagHold", + "fullName": "google.cloud.resourcemanager.v3.TagHolds.DeleteTagHold", + "service": { + "shortName": "TagHolds", + "fullName": "google.cloud.resourcemanager.v3.TagHolds" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagHolds_ListTagHolds_async", + "title": "Folders listTagHolds Sample", + "origin": "API_DEFINITION", + "description": " Lists TagHolds under a TagValue.", + "canonical": true, + "file": "tag_holds.list_tag_holds.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListTagHolds", + "fullName": "google.cloud.resourcemanager.v3.TagHolds.ListTagHolds", + "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.resourcemanager.v3.ListTagHoldsResponse", + "client": { + "shortName": "TagHoldsClient", + "fullName": "google.cloud.resourcemanager.v3.TagHoldsClient" + }, + "method": { + "shortName": "ListTagHolds", + "fullName": "google.cloud.resourcemanager.v3.TagHolds.ListTagHolds", + "service": { + "shortName": "TagHolds", + "fullName": "google.cloud.resourcemanager.v3.TagHolds" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagKeys_ListTagKeys_async", + "title": "Folders listTagKeys Sample", + "origin": "API_DEFINITION", + "description": " Lists all TagKeys for a parent resource.", + "canonical": true, + "file": "tag_keys.list_tag_keys.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListTagKeys", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.ListTagKeys", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.ListTagKeysResponse", + "client": { + "shortName": "TagKeysClient", + "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" + }, + "method": { + "shortName": "ListTagKeys", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.ListTagKeys", + "service": { + "shortName": "TagKeys", + "fullName": "google.cloud.resourcemanager.v3.TagKeys" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagKeys_GetTagKey_async", + "title": "Folders getTagKey Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a TagKey. This method will return `PERMISSION_DENIED` if the key does not exist or the user does not have permission to view it.", + "canonical": true, + "file": "tag_keys.get_tag_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetTagKey", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.GetTagKey", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.TagKey", + "client": { + "shortName": "TagKeysClient", + "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" + }, + "method": { + "shortName": "GetTagKey", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.GetTagKey", + "service": { + "shortName": "TagKeys", + "fullName": "google.cloud.resourcemanager.v3.TagKeys" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagKeys_GetNamespacedTagKey_async", + "title": "Folders getNamespacedTagKey Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a TagKey by its namespaced name. This method will return `PERMISSION_DENIED` if the key does not exist or the user does not have permission to view it.", + "canonical": true, + "file": "tag_keys.get_namespaced_tag_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetNamespacedTagKey", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.GetNamespacedTagKey", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.TagKey", + "client": { + "shortName": "TagKeysClient", + "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" + }, + "method": { + "shortName": "GetNamespacedTagKey", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.GetNamespacedTagKey", + "service": { + "shortName": "TagKeys", + "fullName": "google.cloud.resourcemanager.v3.TagKeys" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagKeys_CreateTagKey_async", + "title": "Folders createTagKey Sample", + "origin": "API_DEFINITION", + "description": " Creates a new TagKey. If another request with the same parameters is sent while the original request is in process, the second request will receive an error. A maximum of 1000 TagKeys can exist under a parent at any given time.", + "canonical": true, + "file": "tag_keys.create_tag_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateTagKey", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.CreateTagKey", + "async": true, + "parameters": [ + { + "name": "tag_key", + "type": ".google.cloud.resourcemanager.v3.TagKey" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TagKeysClient", + "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" + }, + "method": { + "shortName": "CreateTagKey", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.CreateTagKey", + "service": { + "shortName": "TagKeys", + "fullName": "google.cloud.resourcemanager.v3.TagKeys" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagKeys_UpdateTagKey_async", + "title": "Folders updateTagKey Sample", + "origin": "API_DEFINITION", + "description": " Updates the attributes of the TagKey resource.", + "canonical": true, + "file": "tag_keys.update_tag_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateTagKey", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.UpdateTagKey", + "async": true, + "parameters": [ + { + "name": "tag_key", + "type": ".google.cloud.resourcemanager.v3.TagKey" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TagKeysClient", + "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" + }, + "method": { + "shortName": "UpdateTagKey", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.UpdateTagKey", + "service": { + "shortName": "TagKeys", + "fullName": "google.cloud.resourcemanager.v3.TagKeys" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagKeys_DeleteTagKey_async", + "title": "Folders deleteTagKey Sample", + "origin": "API_DEFINITION", + "description": " Deletes a TagKey. The TagKey cannot be deleted if it has any child TagValues.", + "canonical": true, + "file": "tag_keys.delete_tag_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteTagKey", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.DeleteTagKey", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TagKeysClient", + "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" + }, + "method": { + "shortName": "DeleteTagKey", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.DeleteTagKey", + "service": { + "shortName": "TagKeys", + "fullName": "google.cloud.resourcemanager.v3.TagKeys" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagKeys_GetIamPolicy_async", + "title": "Folders getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a TagKey. The returned policy may be empty if no such policy or resource exists. The `resource` field should be the TagKey's resource name. For example, \"tagKeys/1234\". The caller must have `cloudresourcemanager.googleapis.com/tagKeys.getIamPolicy` permission on the specified TagKey.", + "canonical": true, + "file": "tag_keys.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.iam.v1.GetPolicyOptions" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "TagKeysClient", + "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.GetIamPolicy", + "service": { + "shortName": "TagKeys", + "fullName": "google.cloud.resourcemanager.v3.TagKeys" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagKeys_SetIamPolicy_async", + "title": "Folders setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on a TagKey, replacing any existing policy. The `resource` field should be the TagKey's resource name. For example, \"tagKeys/1234\". The caller must have `resourcemanager.tagKeys.setIamPolicy` permission on the identified tagValue.", + "canonical": true, + "file": "tag_keys.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "policy", + "type": ".google.iam.v1.Policy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "TagKeysClient", + "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.SetIamPolicy", + "service": { + "shortName": "TagKeys", + "fullName": "google.cloud.resourcemanager.v3.TagKeys" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagKeys_TestIamPermissions_async", + "title": "Folders testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified TagKey. The `resource` field should be the TagKey's resource name. For example, \"tagKeys/1234\". There are no permissions required for making this API call.", + "canonical": true, + "file": "tag_keys.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "permissions", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.iam.v1.TestIamPermissionsResponse", + "client": { + "shortName": "TagKeysClient", + "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.TestIamPermissions", + "service": { + "shortName": "TagKeys", + "fullName": "google.cloud.resourcemanager.v3.TagKeys" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagValues_ListTagValues_async", + "title": "Folders listTagValues Sample", + "origin": "API_DEFINITION", + "description": " Lists all TagValues for a specific TagKey.", + "canonical": true, + "file": "tag_values.list_tag_values.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListTagValues", + "fullName": "google.cloud.resourcemanager.v3.TagValues.ListTagValues", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.ListTagValuesResponse", + "client": { + "shortName": "TagValuesClient", + "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" + }, + "method": { + "shortName": "ListTagValues", + "fullName": "google.cloud.resourcemanager.v3.TagValues.ListTagValues", + "service": { + "shortName": "TagValues", + "fullName": "google.cloud.resourcemanager.v3.TagValues" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagValues_GetTagValue_async", + "title": "Folders getTagValue Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a TagValue. This method will return `PERMISSION_DENIED` if the value does not exist or the user does not have permission to view it.", + "canonical": true, + "file": "tag_values.get_tag_value.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetTagValue", + "fullName": "google.cloud.resourcemanager.v3.TagValues.GetTagValue", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.TagValue", + "client": { + "shortName": "TagValuesClient", + "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" + }, + "method": { + "shortName": "GetTagValue", + "fullName": "google.cloud.resourcemanager.v3.TagValues.GetTagValue", + "service": { + "shortName": "TagValues", + "fullName": "google.cloud.resourcemanager.v3.TagValues" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagValues_GetNamespacedTagValue_async", + "title": "Folders getNamespacedTagValue Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a TagValue by its namespaced name. This method will return `PERMISSION_DENIED` if the value does not exist or the user does not have permission to view it.", + "canonical": true, + "file": "tag_values.get_namespaced_tag_value.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetNamespacedTagValue", + "fullName": "google.cloud.resourcemanager.v3.TagValues.GetNamespacedTagValue", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.TagValue", + "client": { + "shortName": "TagValuesClient", + "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" + }, + "method": { + "shortName": "GetNamespacedTagValue", + "fullName": "google.cloud.resourcemanager.v3.TagValues.GetNamespacedTagValue", + "service": { + "shortName": "TagValues", + "fullName": "google.cloud.resourcemanager.v3.TagValues" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagValues_CreateTagValue_async", + "title": "Folders createTagValue Sample", + "origin": "API_DEFINITION", + "description": " Creates a TagValue as a child of the specified TagKey. If a another request with the same parameters is sent while the original request is in process the second request will receive an error. A maximum of 1000 TagValues can exist under a TagKey at any given time.", + "canonical": true, + "file": "tag_values.create_tag_value.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateTagValue", + "fullName": "google.cloud.resourcemanager.v3.TagValues.CreateTagValue", + "async": true, + "parameters": [ + { + "name": "tag_value", + "type": ".google.cloud.resourcemanager.v3.TagValue" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TagValuesClient", + "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" + }, + "method": { + "shortName": "CreateTagValue", + "fullName": "google.cloud.resourcemanager.v3.TagValues.CreateTagValue", + "service": { + "shortName": "TagValues", + "fullName": "google.cloud.resourcemanager.v3.TagValues" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagValues_UpdateTagValue_async", + "title": "Folders updateTagValue Sample", + "origin": "API_DEFINITION", + "description": " Updates the attributes of the TagValue resource.", + "canonical": true, + "file": "tag_values.update_tag_value.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateTagValue", + "fullName": "google.cloud.resourcemanager.v3.TagValues.UpdateTagValue", + "async": true, + "parameters": [ + { + "name": "tag_value", + "type": ".google.cloud.resourcemanager.v3.TagValue" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TagValuesClient", + "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" + }, + "method": { + "shortName": "UpdateTagValue", + "fullName": "google.cloud.resourcemanager.v3.TagValues.UpdateTagValue", + "service": { + "shortName": "TagValues", + "fullName": "google.cloud.resourcemanager.v3.TagValues" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagValues_DeleteTagValue_async", + "title": "Folders deleteTagValue Sample", + "origin": "API_DEFINITION", + "description": " Deletes a TagValue. The TagValue cannot have any bindings when it is deleted.", + "canonical": true, + "file": "tag_values.delete_tag_value.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteTagValue", + "fullName": "google.cloud.resourcemanager.v3.TagValues.DeleteTagValue", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TagValuesClient", + "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" + }, + "method": { + "shortName": "DeleteTagValue", + "fullName": "google.cloud.resourcemanager.v3.TagValues.DeleteTagValue", + "service": { + "shortName": "TagValues", + "fullName": "google.cloud.resourcemanager.v3.TagValues" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagValues_GetIamPolicy_async", + "title": "Folders getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a TagValue. The returned policy may be empty if no such policy or resource exists. The `resource` field should be the TagValue's resource name. For example: `tagValues/1234`. The caller must have the `cloudresourcemanager.googleapis.com/tagValues.getIamPolicy` permission on the identified TagValue to get the access control policy.", + "canonical": true, + "file": "tag_values.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.TagValues.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.iam.v1.GetPolicyOptions" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "TagValuesClient", + "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.TagValues.GetIamPolicy", + "service": { + "shortName": "TagValues", + "fullName": "google.cloud.resourcemanager.v3.TagValues" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagValues_SetIamPolicy_async", + "title": "Folders setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on a TagValue, replacing any existing policy. The `resource` field should be the TagValue's resource name. For example: `tagValues/1234`. The caller must have `resourcemanager.tagValues.setIamPolicy` permission on the identified tagValue.", + "canonical": true, + "file": "tag_values.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.TagValues.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "policy", + "type": ".google.iam.v1.Policy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "TagValuesClient", + "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.TagValues.SetIamPolicy", + "service": { + "shortName": "TagValues", + "fullName": "google.cloud.resourcemanager.v3.TagValues" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagValues_TestIamPermissions_async", + "title": "Folders testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified TagValue. The `resource` field should be the TagValue's resource name. For example: `tagValues/1234`. There are no permissions required for making this API call.", + "canonical": true, + "file": "tag_values.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.resourcemanager.v3.TagValues.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "permissions", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.iam.v1.TestIamPermissionsResponse", + "client": { + "shortName": "TagValuesClient", + "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.resourcemanager.v3.TagValues.TestIamPermissions", + "service": { + "shortName": "TagValues", + "fullName": "google.cloud.resourcemanager.v3.TagValues" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.create_tag_binding.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.create_tag_binding.js new file mode 100644 index 00000000000..ad6a2166043 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.create_tag_binding.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(tagBinding) { + // [START cloudresourcemanager_v3_generated_TagBindings_CreateTagBinding_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The TagBinding to be created. + */ + // const tagBinding = {} + /** + * Optional. Set to true to perform the validations necessary for creating the + * resource, but not actually perform the action. + */ + // const validateOnly = true + + // Imports the Resourcemanager library + const {TagBindingsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagBindingsClient(); + + async function callCreateTagBinding() { + // Construct request + const request = { + tagBinding, + }; + + // Run request + const [operation] = await resourcemanagerClient.createTagBinding(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateTagBinding(); + // [END cloudresourcemanager_v3_generated_TagBindings_CreateTagBinding_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.delete_tag_binding.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.delete_tag_binding.js new file mode 100644 index 00000000000..aa7e97c641d --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.delete_tag_binding.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 cloudresourcemanager_v3_generated_TagBindings_DeleteTagBinding_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 TagBinding. This is a String of the form: + * `tagBindings/{id}` (e.g. + * `tagBindings/%2F%2Fcloudresourcemanager.googleapis.com%2Fprojects%2F123/tagValues/456`). + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {TagBindingsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagBindingsClient(); + + async function callDeleteTagBinding() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await resourcemanagerClient.deleteTagBinding(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteTagBinding(); + // [END cloudresourcemanager_v3_generated_TagBindings_DeleteTagBinding_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.list_effective_tags.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.list_effective_tags.js new file mode 100644 index 00000000000..fb1d0a24397 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.list_effective_tags.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) { + // [START cloudresourcemanager_v3_generated_TagBindings_ListEffectiveTags_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The full resource name of a resource for which you want to list + * the effective tags. E.g. + * "//cloudresourcemanager.googleapis.com/projects/123" + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of effective tags to return in the response. + * The server allows a maximum of 300 effective tags to return in a single + * page. If unspecified, the server will use 100 as the default. + */ + // const pageSize = 1234 + /** + * Optional. A pagination token returned from a previous call to + * `ListEffectiveTags` that indicates from where this listing should continue. + */ + // const pageToken = 'abc123' + + // Imports the Resourcemanager library + const {TagBindingsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagBindingsClient(); + + async function callListEffectiveTags() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await resourcemanagerClient.listEffectiveTagsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListEffectiveTags(); + // [END cloudresourcemanager_v3_generated_TagBindings_ListEffectiveTags_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.list_tag_bindings.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.list_tag_bindings.js new file mode 100644 index 00000000000..5858d932c6c --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.list_tag_bindings.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) { + // [START cloudresourcemanager_v3_generated_TagBindings_ListTagBindings_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The full resource name of a resource for which you want to list + * existing TagBindings. E.g. + * "//cloudresourcemanager.googleapis.com/projects/123" + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of TagBindings to return in the response. The + * server allows a maximum of 300 TagBindings to return. If unspecified, the + * server will use 100 as the default. + */ + // const pageSize = 1234 + /** + * Optional. A pagination token returned from a previous call to + * `ListTagBindings` that indicates where this listing should continue from. + */ + // const pageToken = 'abc123' + + // Imports the Resourcemanager library + const {TagBindingsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagBindingsClient(); + + async function callListTagBindings() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await resourcemanagerClient.listTagBindingsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListTagBindings(); + // [END cloudresourcemanager_v3_generated_TagBindings_ListTagBindings_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.create_tag_hold.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.create_tag_hold.js new file mode 100644 index 00000000000..ff05a49aa50 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.create_tag_hold.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(parent, tagHold) { + // [START cloudresourcemanager_v3_generated_TagHolds_CreateTagHold_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 TagHold's parent TagValue. Must be of + * the form: `tagValues/{tag-value-id}`. + */ + // const parent = 'abc123' + /** + * Required. The TagHold to be created. + */ + // const tagHold = {} + /** + * Optional. Set to true to perform the validations necessary for creating the + * resource, but not actually perform the action. + */ + // const validateOnly = true + + // Imports the Resourcemanager library + const {TagHoldsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagHoldsClient(); + + async function callCreateTagHold() { + // Construct request + const request = { + parent, + tagHold, + }; + + // Run request + const [operation] = await resourcemanagerClient.createTagHold(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateTagHold(); + // [END cloudresourcemanager_v3_generated_TagHolds_CreateTagHold_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.delete_tag_hold.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.delete_tag_hold.js new file mode 100644 index 00000000000..4d6a10c5f97 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.delete_tag_hold.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 cloudresourcemanager_v3_generated_TagHolds_DeleteTagHold_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 TagHold to delete. Must be of the form: + * `tagValues/{tag-value-id}/tagHolds/{tag-hold-id}`. + */ + // const name = 'abc123' + /** + * Optional. Set to true to perform the validations necessary for deleting the + * resource, but not actually perform the action. + */ + // const validateOnly = true + + // Imports the Resourcemanager library + const {TagHoldsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagHoldsClient(); + + async function callDeleteTagHold() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await resourcemanagerClient.deleteTagHold(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteTagHold(); + // [END cloudresourcemanager_v3_generated_TagHolds_DeleteTagHold_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.list_tag_holds.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.list_tag_holds.js new file mode 100644 index 00000000000..d40a1c095ce --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.list_tag_holds.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(parent) { + // [START cloudresourcemanager_v3_generated_TagHolds_ListTagHolds_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 parent TagValue. Must be of the form: + * `tagValues/{tag-value-id}`. + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of TagHolds to return in the response. The + * server allows a maximum of 300 TagHolds to return. If unspecified, the + * server will use 100 as the default. + */ + // const pageSize = 1234 + /** + * Optional. A pagination token returned from a previous call to + * `ListTagHolds` that indicates where this listing should continue from. + */ + // const pageToken = 'abc123' + /** + * Optional. Criteria used to select a subset of TagHolds parented by the + * TagValue to return. This field follows the syntax defined by aip.dev/160; + * the `holder` and `origin` fields are supported for filtering. Currently + * only `AND` syntax is supported. Some example queries are: + * * `holder = + * //compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group` + * * `origin = 35678234` + * * `holder = + * //compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group + * AND origin = 35678234` + */ + // const filter = 'abc123' + + // Imports the Resourcemanager library + const {TagHoldsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagHoldsClient(); + + async function callListTagHolds() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await resourcemanagerClient.listTagHoldsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListTagHolds(); + // [END cloudresourcemanager_v3_generated_TagHolds_ListTagHolds_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.create_tag_key.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.create_tag_key.js new file mode 100644 index 00000000000..b54df253335 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.create_tag_key.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(tagKey) { + // [START cloudresourcemanager_v3_generated_TagKeys_CreateTagKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The TagKey to be created. Only fields `short_name`, + * `description`, and `parent` are considered during the creation request. + */ + // const tagKey = {} + /** + * Optional. Set to true to perform validations necessary for creating the + * resource, but not actually perform the action. + */ + // const validateOnly = true + + // Imports the Resourcemanager library + const {TagKeysClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagKeysClient(); + + async function callCreateTagKey() { + // Construct request + const request = { + tagKey, + }; + + // Run request + const [operation] = await resourcemanagerClient.createTagKey(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateTagKey(); + // [END cloudresourcemanager_v3_generated_TagKeys_CreateTagKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.delete_tag_key.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.delete_tag_key.js new file mode 100644 index 00000000000..d9b671be828 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.delete_tag_key.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(name) { + // [START cloudresourcemanager_v3_generated_TagKeys_DeleteTagKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 a TagKey to be deleted in the format + * `tagKeys/123`. The TagKey cannot be a parent of any existing TagValues or + * it will not be deleted successfully. + */ + // const name = 'abc123' + /** + * Optional. Set as true to perform validations necessary for deletion, but + * not actually perform the action. + */ + // const validateOnly = true + /** + * Optional. The etag known to the client for the expected state of the + * TagKey. This is to be used for optimistic concurrency. + */ + // const etag = 'abc123' + + // Imports the Resourcemanager library + const {TagKeysClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagKeysClient(); + + async function callDeleteTagKey() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await resourcemanagerClient.deleteTagKey(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteTagKey(); + // [END cloudresourcemanager_v3_generated_TagKeys_DeleteTagKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_iam_policy.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_iam_policy.js new file mode 100644 index 00000000000..14cedb29219 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_iam_policy.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(resource) { + // [START cloudresourcemanager_v3_generated_TagKeys_GetIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + */ + // const options = {} + + // Imports the Resourcemanager library + const {TagKeysClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagKeysClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await resourcemanagerClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END cloudresourcemanager_v3_generated_TagKeys_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_namespaced_tag_key.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_namespaced_tag_key.js new file mode 100644 index 00000000000..7861fabb92b --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_namespaced_tag_key.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 cloudresourcemanager_v3_generated_TagKeys_GetNamespacedTagKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A namespaced tag key name in the format + * `{parentId}/{tagKeyShort}`, such as `42/foo` for a key with short name + * "foo" under the organization with ID 42 or `r2-d2/bar` for a key with short + * name "bar" under the project `r2-d2`. + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {TagKeysClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagKeysClient(); + + async function callGetNamespacedTagKey() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await resourcemanagerClient.getNamespacedTagKey(request); + console.log(response); + } + + callGetNamespacedTagKey(); + // [END cloudresourcemanager_v3_generated_TagKeys_GetNamespacedTagKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_tag_key.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_tag_key.js new file mode 100644 index 00000000000..a0823e8df19 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_tag_key.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 cloudresourcemanager_v3_generated_TagKeys_GetTagKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A resource name in the format `tagKeys/{id}`, such as + * `tagKeys/123`. + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {TagKeysClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagKeysClient(); + + async function callGetTagKey() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await resourcemanagerClient.getTagKey(request); + console.log(response); + } + + callGetTagKey(); + // [END cloudresourcemanager_v3_generated_TagKeys_GetTagKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.list_tag_keys.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.list_tag_keys.js new file mode 100644 index 00000000000..d141a4cfa26 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.list_tag_keys.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) { + // [START cloudresourcemanager_v3_generated_TagKeys_ListTagKeys_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 TagKey's parent. + * Must be of the form `organizations/{org_id}` or `projects/{project_id}` or + * `projects/{project_number}` + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of TagKeys to return in the response. The + * server allows a maximum of 300 TagKeys to return. If unspecified, the + * server will use 100 as the default. + */ + // const pageSize = 1234 + /** + * Optional. A pagination token returned from a previous call to `ListTagKey` + * that indicates where this listing should continue from. + */ + // const pageToken = 'abc123' + + // Imports the Resourcemanager library + const {TagKeysClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagKeysClient(); + + async function callListTagKeys() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await resourcemanagerClient.listTagKeysAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListTagKeys(); + // [END cloudresourcemanager_v3_generated_TagKeys_ListTagKeys_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.set_iam_policy.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.set_iam_policy.js new file mode 100644 index 00000000000..603a420647b --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.set_iam_policy.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(resource, policy) { + // [START cloudresourcemanager_v3_generated_TagKeys_SetIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + */ + // const policy = {} + /** + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * `paths: "bindings, etag"` + */ + // const updateMask = {} + + // Imports the Resourcemanager library + const {TagKeysClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagKeysClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + resource, + policy, + }; + + // Run request + const response = await resourcemanagerClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END cloudresourcemanager_v3_generated_TagKeys_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.test_iam_permissions.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.test_iam_permissions.js new file mode 100644 index 00000000000..be64a032154 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.test_iam_permissions.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(resource, permissions) { + // [START cloudresourcemanager_v3_generated_TagKeys_TestIamPermissions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). + */ + // const permissions = ['abc','def'] + + // Imports the Resourcemanager library + const {TagKeysClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagKeysClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + resource, + permissions, + }; + + // Run request + const response = await resourcemanagerClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END cloudresourcemanager_v3_generated_TagKeys_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.update_tag_key.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.update_tag_key.js new file mode 100644 index 00000000000..3c3eca4f3a7 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.update_tag_key.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(tagKey) { + // [START cloudresourcemanager_v3_generated_TagKeys_UpdateTagKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The new definition of the TagKey. Only the `description` and + * `etag` fields can be updated by this request. If the `etag` field is not + * empty, it must match the `etag` field of the existing tag key. Otherwise, + * `ABORTED` will be returned. + */ + // const tagKey = {} + /** + * Fields to be updated. The mask may only contain `description` or + * `etag`. If omitted entirely, both `description` and `etag` are assumed to + * be significant. + */ + // const updateMask = {} + /** + * Set as true to perform validations necessary for updating the resource, but + * not actually perform the action. + */ + // const validateOnly = true + + // Imports the Resourcemanager library + const {TagKeysClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagKeysClient(); + + async function callUpdateTagKey() { + // Construct request + const request = { + tagKey, + }; + + // Run request + const [operation] = await resourcemanagerClient.updateTagKey(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateTagKey(); + // [END cloudresourcemanager_v3_generated_TagKeys_UpdateTagKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.create_tag_value.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.create_tag_value.js new file mode 100644 index 00000000000..63f9675d3ef --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.create_tag_value.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(tagValue) { + // [START cloudresourcemanager_v3_generated_TagValues_CreateTagValue_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The TagValue to be created. Only fields `short_name`, + * `description`, and `parent` are considered during the creation request. + */ + // const tagValue = {} + /** + * Optional. Set as true to perform the validations necessary for creating the + * resource, but not actually perform the action. + */ + // const validateOnly = true + + // Imports the Resourcemanager library + const {TagValuesClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagValuesClient(); + + async function callCreateTagValue() { + // Construct request + const request = { + tagValue, + }; + + // Run request + const [operation] = await resourcemanagerClient.createTagValue(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateTagValue(); + // [END cloudresourcemanager_v3_generated_TagValues_CreateTagValue_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.delete_tag_value.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.delete_tag_value.js new file mode 100644 index 00000000000..1f0b1b768ad --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.delete_tag_value.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(name) { + // [START cloudresourcemanager_v3_generated_TagValues_DeleteTagValue_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name for TagValue to be deleted in the format + * tagValues/456. + */ + // const name = 'abc123' + /** + * Optional. Set as true to perform the validations necessary for deletion, + * but not actually perform the action. + */ + // const validateOnly = true + /** + * Optional. The etag known to the client for the expected state of the + * TagValue. This is to be used for optimistic concurrency. + */ + // const etag = 'abc123' + + // Imports the Resourcemanager library + const {TagValuesClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagValuesClient(); + + async function callDeleteTagValue() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await resourcemanagerClient.deleteTagValue(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteTagValue(); + // [END cloudresourcemanager_v3_generated_TagValues_DeleteTagValue_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_iam_policy.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_iam_policy.js new file mode 100644 index 00000000000..fc92e14923a --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_iam_policy.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(resource) { + // [START cloudresourcemanager_v3_generated_TagValues_GetIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + */ + // const options = {} + + // Imports the Resourcemanager library + const {TagValuesClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagValuesClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await resourcemanagerClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END cloudresourcemanager_v3_generated_TagValues_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_namespaced_tag_value.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_namespaced_tag_value.js new file mode 100644 index 00000000000..019c16379c3 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_namespaced_tag_value.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(name) { + // [START cloudresourcemanager_v3_generated_TagValues_GetNamespacedTagValue_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A namespaced tag value name in the following format: + * `{parentId}/{tagKeyShort}/{tagValueShort}` + * Examples: + * - `42/foo/abc` for a value with short name "abc" under the key with short + * name "foo" under the organization with ID 42 + * - `r2-d2/bar/xyz` for a value with short name "xyz" under the key with + * short name "bar" under the project with ID "r2-d2" + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {TagValuesClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagValuesClient(); + + async function callGetNamespacedTagValue() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await resourcemanagerClient.getNamespacedTagValue(request); + console.log(response); + } + + callGetNamespacedTagValue(); + // [END cloudresourcemanager_v3_generated_TagValues_GetNamespacedTagValue_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_tag_value.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_tag_value.js new file mode 100644 index 00000000000..42eedb7b807 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_tag_value.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 cloudresourcemanager_v3_generated_TagValues_GetTagValue_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name for TagValue to be fetched in the format + * `tagValues/456`. + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {TagValuesClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagValuesClient(); + + async function callGetTagValue() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await resourcemanagerClient.getTagValue(request); + console.log(response); + } + + callGetTagValue(); + // [END cloudresourcemanager_v3_generated_TagValues_GetTagValue_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.list_tag_values.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.list_tag_values.js new file mode 100644 index 00000000000..fef7f2b88b1 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.list_tag_values.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) { + // [START cloudresourcemanager_v3_generated_TagValues_ListTagValues_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of TagValues to return in the response. The + * server allows a maximum of 300 TagValues to return. If unspecified, the + * server will use 100 as the default. + */ + // const pageSize = 1234 + /** + * Optional. A pagination token returned from a previous call to + * `ListTagValues` that indicates where this listing should continue from. + */ + // const pageToken = 'abc123' + + // Imports the Resourcemanager library + const {TagValuesClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagValuesClient(); + + async function callListTagValues() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await resourcemanagerClient.listTagValuesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListTagValues(); + // [END cloudresourcemanager_v3_generated_TagValues_ListTagValues_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.set_iam_policy.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.set_iam_policy.js new file mode 100644 index 00000000000..ba06fbe4b79 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.set_iam_policy.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(resource, policy) { + // [START cloudresourcemanager_v3_generated_TagValues_SetIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + */ + // const policy = {} + /** + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * `paths: "bindings, etag"` + */ + // const updateMask = {} + + // Imports the Resourcemanager library + const {TagValuesClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagValuesClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + resource, + policy, + }; + + // Run request + const response = await resourcemanagerClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END cloudresourcemanager_v3_generated_TagValues_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.test_iam_permissions.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.test_iam_permissions.js new file mode 100644 index 00000000000..2e491e73c76 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.test_iam_permissions.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(resource, permissions) { + // [START cloudresourcemanager_v3_generated_TagValues_TestIamPermissions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). + */ + // const permissions = ['abc','def'] + + // Imports the Resourcemanager library + const {TagValuesClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagValuesClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + resource, + permissions, + }; + + // Run request + const response = await resourcemanagerClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END cloudresourcemanager_v3_generated_TagValues_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.update_tag_value.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.update_tag_value.js new file mode 100644 index 00000000000..8bc38601371 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.update_tag_value.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(tagValue) { + // [START cloudresourcemanager_v3_generated_TagValues_UpdateTagValue_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The new definition of the TagValue. Only fields `description` and + * `etag` fields can be updated by this request. If the `etag` field is + * nonempty, it must match the `etag` field of the existing ControlGroup. + * Otherwise, `ABORTED` will be returned. + */ + // const tagValue = {} + /** + * Optional. Fields to be updated. + */ + // const updateMask = {} + /** + * Optional. True to perform validations necessary for updating the resource, + * but not actually perform the action. + */ + // const validateOnly = true + + // Imports the Resourcemanager library + const {TagValuesClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagValuesClient(); + + async function callUpdateTagValue() { + // Construct request + const request = { + tagValue, + }; + + // Run request + const [operation] = await resourcemanagerClient.updateTagValue(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateTagValue(); + // [END cloudresourcemanager_v3_generated_TagValues_UpdateTagValue_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/index.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/src/index.ts new file mode 100644 index 00000000000..59cb34f53d5 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/index.ts @@ -0,0 +1,37 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v3 from './v3'; +const FoldersClient = v3.FoldersClient; +type FoldersClient = v3.FoldersClient; +const OrganizationsClient = v3.OrganizationsClient; +type OrganizationsClient = v3.OrganizationsClient; +const ProjectsClient = v3.ProjectsClient; +type ProjectsClient = v3.ProjectsClient; +const TagBindingsClient = v3.TagBindingsClient; +type TagBindingsClient = v3.TagBindingsClient; +const TagHoldsClient = v3.TagHoldsClient; +type TagHoldsClient = v3.TagHoldsClient; +const TagKeysClient = v3.TagKeysClient; +type TagKeysClient = v3.TagKeysClient; +const TagValuesClient = v3.TagValuesClient; +type TagValuesClient = v3.TagValuesClient; +export {v3, FoldersClient, OrganizationsClient, ProjectsClient, TagBindingsClient, TagHoldsClient, TagKeysClient, TagValuesClient}; +export default {v3, FoldersClient, OrganizationsClient, ProjectsClient, TagBindingsClient, TagHoldsClient, TagKeysClient, TagValuesClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_client.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_client.ts new file mode 100644 index 00000000000..04ba3a356af --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_client.ts @@ -0,0 +1,2074 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v3/folders_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './folders_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Manages Cloud Platform folder resources. + * Folders can be used to organize the resources under an + * organization and to control the policies applied to groups of resources. + * @class + * @memberof v3 + */ +export class FoldersClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + foldersStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of FoldersClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 FoldersClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof FoldersClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + folderPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}' + ), + organizationPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + tagBindingPathTemplate: new this._gaxModule.PathTemplate( + 'tagBindings/{tag_binding}' + ), + tagHoldPathTemplate: new this._gaxModule.PathTemplate( + 'tagValues/{tag_value}/tagHolds/{tag_hold}' + ), + tagKeyPathTemplate: new this._gaxModule.PathTemplate( + 'tagKeys/{tag_key}' + ), + tagValuePathTemplate: new this._gaxModule.PathTemplate( + 'tagValues/{tag_value}' + ), + }; + + // 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 = { + listFolders: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'folders'), + searchFolders: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'folders') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v3/{name=operations/**}',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createFolderResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.Folder') as gax.protobuf.Type; + const createFolderMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.CreateFolderMetadata') as gax.protobuf.Type; + const updateFolderResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.Folder') as gax.protobuf.Type; + const updateFolderMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.UpdateFolderMetadata') as gax.protobuf.Type; + const moveFolderResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.Folder') as gax.protobuf.Type; + const moveFolderMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.MoveFolderMetadata') as gax.protobuf.Type; + const deleteFolderResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.Folder') as gax.protobuf.Type; + const deleteFolderMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.DeleteFolderMetadata') as gax.protobuf.Type; + const undeleteFolderResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.Folder') as gax.protobuf.Type; + const undeleteFolderMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.UndeleteFolderMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createFolder: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createFolderResponse.decode.bind(createFolderResponse), + createFolderMetadata.decode.bind(createFolderMetadata)), + updateFolder: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateFolderResponse.decode.bind(updateFolderResponse), + updateFolderMetadata.decode.bind(updateFolderMetadata)), + moveFolder: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + moveFolderResponse.decode.bind(moveFolderResponse), + moveFolderMetadata.decode.bind(moveFolderMetadata)), + deleteFolder: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteFolderResponse.decode.bind(deleteFolderResponse), + deleteFolderMetadata.decode.bind(deleteFolderMetadata)), + undeleteFolder: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + undeleteFolderResponse.decode.bind(undeleteFolderResponse), + undeleteFolderMetadata.decode.bind(undeleteFolderMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.resourcemanager.v3.Folders', 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.foldersStub) { + return this.foldersStub; + } + + // Put together the "service stub" for + // google.cloud.resourcemanager.v3.Folders. + this.foldersStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.Folders') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.resourcemanager.v3.Folders, + 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 foldersStubMethods = + ['getFolder', 'listFolders', 'searchFolders', 'createFolder', 'updateFolder', 'moveFolder', 'deleteFolder', 'undeleteFolder', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of foldersStubMethods) { + const callPromise = this.foldersStub.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.foldersStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudresourcemanager.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 'cloudresourcemanager.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only' + ]; + } + + 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 -- + // ------------------- +/** + * Retrieves a folder identified by the supplied resource name. + * Valid folder resource names have the format `folders/{folder_id}` + * (for example, `folders/1234`). + * The caller must have `resourcemanager.folders.get` permission on the + * identified folder. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the folder to retrieve. + * Must be of the form `folders/{folder_id}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.resourcemanager.v3.Folder|Folder}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/folders.get_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_GetFolder_async + */ + getFolder( + request?: protos.google.cloud.resourcemanager.v3.IGetFolderRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.IFolder, + protos.google.cloud.resourcemanager.v3.IGetFolderRequest|undefined, {}|undefined + ]>; + getFolder( + request: protos.google.cloud.resourcemanager.v3.IGetFolderRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.resourcemanager.v3.IFolder, + protos.google.cloud.resourcemanager.v3.IGetFolderRequest|null|undefined, + {}|null|undefined>): void; + getFolder( + request: protos.google.cloud.resourcemanager.v3.IGetFolderRequest, + callback: Callback< + protos.google.cloud.resourcemanager.v3.IFolder, + protos.google.cloud.resourcemanager.v3.IGetFolderRequest|null|undefined, + {}|null|undefined>): void; + getFolder( + request?: protos.google.cloud.resourcemanager.v3.IGetFolderRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.resourcemanager.v3.IFolder, + protos.google.cloud.resourcemanager.v3.IGetFolderRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.resourcemanager.v3.IFolder, + protos.google.cloud.resourcemanager.v3.IGetFolderRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.resourcemanager.v3.IFolder, + protos.google.cloud.resourcemanager.v3.IGetFolderRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getFolder(request, options, callback); + } +/** + * Gets the access control policy for a folder. The returned policy may be + * empty if no such policy or resource exists. The `resource` field should + * be the folder's resource name, for example: "folders/1234". + * The caller must have `resourcemanager.folders.getIamPolicy` permission + * on the identified folder. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/folders.get_iam_policy.js + * region_tag:cloudresourcemanager_v3_generated_Folders_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Sets the access control policy on a folder, replacing any existing policy. + * The `resource` field should be the folder's resource name, for example: + * "folders/1234". + * The caller must have `resourcemanager.folders.setIamPolicy` permission + * on the identified folder. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/folders.set_iam_policy.js + * region_tag:cloudresourcemanager_v3_generated_Folders_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified folder. + * The `resource` field should be the folder's resource name, + * for example: "folders/1234". + * + * There are no permissions required for making this API call. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/folders.test_iam_permissions.js + * region_tag:cloudresourcemanager_v3_generated_Folders_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + +/** + * Creates a folder in the resource hierarchy. + * Returns an `Operation` which can be used to track the progress of the + * folder creation workflow. + * Upon success, the `Operation.response` field will be populated with the + * created Folder. + * + * In order to succeed, the addition of this new folder must not violate + * the folder naming, height, or fanout constraints. + * + * + The folder's `display_name` must be distinct from all other folders that + * share its parent. + * + The addition of the folder must not cause the active folder hierarchy + * to exceed a height of 10. Note, the full active + deleted folder hierarchy + * is allowed to reach a height of 20; this provides additional headroom when + * moving folders that contain deleted folders. + * + The addition of the folder must not cause the total number of folders + * under its parent to exceed 300. + * + * If the operation fails due to a folder constraint violation, some errors + * may be returned by the `CreateFolder` request, with status code + * `FAILED_PRECONDITION` and an error description. Other folder constraint + * violations will be communicated in the `Operation`, with the specific + * `PreconditionFailure` returned in the details list in the `Operation.error` + * field. + * + * The caller must have `resourcemanager.folders.create` permission on the + * identified parent. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.resourcemanager.v3.Folder} request.folder + * Required. The folder being created, only the display name and parent will + * be consulted. All other fields will be 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/folders.create_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_CreateFolder_async + */ + createFolder( + request?: protos.google.cloud.resourcemanager.v3.ICreateFolderRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createFolder( + request: protos.google.cloud.resourcemanager.v3.ICreateFolderRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createFolder( + request: protos.google.cloud.resourcemanager.v3.ICreateFolderRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createFolder( + request?: protos.google.cloud.resourcemanager.v3.ICreateFolderRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.createFolder(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createFolder()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/folders.create_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_CreateFolder_async + */ + async checkCreateFolderProgress(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.createFolder, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates a folder, changing its `display_name`. + * Changes to the folder `display_name` will be rejected if they violate + * either the `display_name` formatting rules or the naming constraints + * described in the + * {@link protos.google.cloud.resourcemanager.v3.Folders.CreateFolder|CreateFolder} + * documentation. + * + * The folder's `display_name` must start and end with a letter or digit, + * may contain letters, digits, spaces, hyphens and underscores and can be + * between 3 and 30 characters. This is captured by the regular expression: + * `{@link protos.\p{L}\p{N}_- |\p{L}\p{N}}{1,28}[\p{L}\p{N}]`. + * The caller must have `resourcemanager.folders.update` permission on the + * identified folder. + * + * If the update fails due to the unique name constraint then a + * `PreconditionFailure` explaining this violation will be returned + * in the Status.details field. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.resourcemanager.v3.Folder} request.folder + * Required. The new definition of the Folder. It must include the `name` + * field, which cannot be changed. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Fields to be updated. + * Only the `display_name` can be 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/folders.update_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_UpdateFolder_async + */ + updateFolder( + request?: protos.google.cloud.resourcemanager.v3.IUpdateFolderRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateFolder( + request: protos.google.cloud.resourcemanager.v3.IUpdateFolderRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateFolder( + request: protos.google.cloud.resourcemanager.v3.IUpdateFolderRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateFolder( + request?: protos.google.cloud.resourcemanager.v3.IUpdateFolderRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'folder.name': request.folder!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateFolder(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateFolder()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/folders.update_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_UpdateFolder_async + */ + async checkUpdateFolderProgress(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.updateFolder, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Moves a folder under a new resource parent. + * Returns an `Operation` which can be used to track the progress of the + * folder move workflow. + * Upon success, the `Operation.response` field will be populated with the + * moved folder. + * Upon failure, a `FolderOperationError` categorizing the failure cause will + * be returned - if the failure occurs synchronously then the + * `FolderOperationError` will be returned in the `Status.details` field. + * If it occurs asynchronously, then the FolderOperation will be returned + * in the `Operation.error` field. + * In addition, the `Operation.metadata` field will be populated with a + * `FolderOperation` message as an aid to stateless clients. + * Folder moves will be rejected if they violate either the naming, height, + * or fanout constraints described in the + * {@link protos.google.cloud.resourcemanager.v3.Folders.CreateFolder|CreateFolder} + * documentation. The caller must have `resourcemanager.folders.move` + * permission on the folder's current and proposed new parent. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Folder to move. + * Must be of the form folders/{folder_id} + * @param {string} request.destinationParent + * Required. The resource name of the folder or organization which should be + * the folder's new parent. Must be of the form `folders/{folder_id}` or + * `organizations/{org_id}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/folders.move_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_MoveFolder_async + */ + moveFolder( + request?: protos.google.cloud.resourcemanager.v3.IMoveFolderRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + moveFolder( + request: protos.google.cloud.resourcemanager.v3.IMoveFolderRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + moveFolder( + request: protos.google.cloud.resourcemanager.v3.IMoveFolderRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + moveFolder( + request?: protos.google.cloud.resourcemanager.v3.IMoveFolderRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.moveFolder(request, options, callback); + } +/** + * Check the status of the long running operation returned by `moveFolder()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/folders.move_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_MoveFolder_async + */ + async checkMoveFolderProgress(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.moveFolder, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Requests deletion of a folder. The folder is moved into the + * {@link protos.google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED|DELETE_REQUESTED} + * state immediately, and is deleted approximately 30 days later. This method + * may only be called on an empty folder, where a folder is empty if it + * doesn't contain any folders or projects in the + * {@link protos.google.cloud.resourcemanager.v3.Folder.State.ACTIVE|ACTIVE} state. If + * called on a folder in + * {@link protos.google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED|DELETE_REQUESTED} + * state the operation will result in a no-op success. + * The caller must have `resourcemanager.folders.delete` permission on the + * identified folder. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the folder to be deleted. + * Must be of the form `folders/{folder_id}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/folders.delete_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_DeleteFolder_async + */ + deleteFolder( + request?: protos.google.cloud.resourcemanager.v3.IDeleteFolderRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteFolder( + request: protos.google.cloud.resourcemanager.v3.IDeleteFolderRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteFolder( + request: protos.google.cloud.resourcemanager.v3.IDeleteFolderRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteFolder( + request?: protos.google.cloud.resourcemanager.v3.IDeleteFolderRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteFolder(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteFolder()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/folders.delete_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_DeleteFolder_async + */ + async checkDeleteFolderProgress(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.deleteFolder, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Cancels the deletion request for a folder. This method may be called on a + * folder in any state. If the folder is in the + * {@link protos.google.cloud.resourcemanager.v3.Folder.State.ACTIVE|ACTIVE} state the + * result will be a no-op success. In order to succeed, the folder's parent + * must be in the + * {@link protos.google.cloud.resourcemanager.v3.Folder.State.ACTIVE|ACTIVE} state. In + * addition, reintroducing the folder into the tree must not violate folder + * naming, height, and fanout constraints described in the + * {@link protos.google.cloud.resourcemanager.v3.Folders.CreateFolder|CreateFolder} + * documentation. The caller must have `resourcemanager.folders.undelete` + * permission on the identified folder. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the folder to undelete. + * Must be of the form `folders/{folder_id}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/folders.undelete_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_UndeleteFolder_async + */ + undeleteFolder( + request?: protos.google.cloud.resourcemanager.v3.IUndeleteFolderRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + undeleteFolder( + request: protos.google.cloud.resourcemanager.v3.IUndeleteFolderRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + undeleteFolder( + request: protos.google.cloud.resourcemanager.v3.IUndeleteFolderRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + undeleteFolder( + request?: protos.google.cloud.resourcemanager.v3.IUndeleteFolderRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.undeleteFolder(request, options, callback); + } +/** + * Check the status of the long running operation returned by `undeleteFolder()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/folders.undelete_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_UndeleteFolder_async + */ + async checkUndeleteFolderProgress(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.undeleteFolder, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists the folders that are direct descendants of supplied parent resource. + * `list()` provides a strongly consistent view of the folders underneath + * the specified parent resource. + * `list()` returns folders sorted based upon the (ascending) lexical ordering + * of their display_name. + * The caller must have `resourcemanager.folders.list` permission on the + * identified parent. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource whose folders are being listed. + * Only children of this parent resource are listed; descendants are not + * listed. + * + * If the parent is a folder, use the value `folders/{folder_id}`. If the + * parent is an organization, use the value `organizations/{org_id}`. + * + * Access to this method is controlled by checking the + * `resourcemanager.folders.list` permission on the `parent`. + * @param {number} [request.pageSize] + * Optional. The maximum number of folders to return in the response. The + * server can return fewer folders than requested. If unspecified, server + * picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `ListFolders` + * that indicates where this listing should continue from. + * @param {boolean} [request.showDeleted] + * Optional. Controls whether folders in the + * {@link protos.google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED|DELETE_REQUESTED} + * state should be returned. Defaults to false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.resourcemanager.v3.Folder|Folder}. + * 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 `listFoldersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listFolders( + request?: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.IFolder[], + protos.google.cloud.resourcemanager.v3.IListFoldersRequest|null, + protos.google.cloud.resourcemanager.v3.IListFoldersResponse + ]>; + listFolders( + request: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListFoldersRequest, + protos.google.cloud.resourcemanager.v3.IListFoldersResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IFolder>): void; + listFolders( + request: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListFoldersRequest, + protos.google.cloud.resourcemanager.v3.IListFoldersResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IFolder>): void; + listFolders( + request?: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListFoldersRequest, + protos.google.cloud.resourcemanager.v3.IListFoldersResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IFolder>, + callback?: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListFoldersRequest, + protos.google.cloud.resourcemanager.v3.IListFoldersResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IFolder>): + Promise<[ + protos.google.cloud.resourcemanager.v3.IFolder[], + protos.google.cloud.resourcemanager.v3.IListFoldersRequest|null, + protos.google.cloud.resourcemanager.v3.IListFoldersResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.listFolders(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 name of the parent resource whose folders are being listed. + * Only children of this parent resource are listed; descendants are not + * listed. + * + * If the parent is a folder, use the value `folders/{folder_id}`. If the + * parent is an organization, use the value `organizations/{org_id}`. + * + * Access to this method is controlled by checking the + * `resourcemanager.folders.list` permission on the `parent`. + * @param {number} [request.pageSize] + * Optional. The maximum number of folders to return in the response. The + * server can return fewer folders than requested. If unspecified, server + * picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `ListFolders` + * that indicates where this listing should continue from. + * @param {boolean} [request.showDeleted] + * Optional. Controls whether folders in the + * {@link protos.google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED|DELETE_REQUESTED} + * state should be returned. Defaults to false. + * @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 protos.google.cloud.resourcemanager.v3.Folder|Folder} 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 `listFoldersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listFoldersStream( + request?: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listFolders']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listFolders.createStream( + this.innerApiCalls.listFolders as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listFolders`, 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 name of the parent resource whose folders are being listed. + * Only children of this parent resource are listed; descendants are not + * listed. + * + * If the parent is a folder, use the value `folders/{folder_id}`. If the + * parent is an organization, use the value `organizations/{org_id}`. + * + * Access to this method is controlled by checking the + * `resourcemanager.folders.list` permission on the `parent`. + * @param {number} [request.pageSize] + * Optional. The maximum number of folders to return in the response. The + * server can return fewer folders than requested. If unspecified, server + * picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `ListFolders` + * that indicates where this listing should continue from. + * @param {boolean} [request.showDeleted] + * Optional. Controls whether folders in the + * {@link protos.google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED|DELETE_REQUESTED} + * state should be returned. Defaults to false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.resourcemanager.v3.Folder|Folder}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v3/folders.list_folders.js + * region_tag:cloudresourcemanager_v3_generated_Folders_ListFolders_async + */ + listFoldersAsync( + request?: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listFolders']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listFolders.asyncIterate( + this.innerApiCalls['listFolders'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Search for folders that match specific filter criteria. + * `search()` provides an eventually consistent view of the folders a user has + * access to which meet the specified filter criteria. + * + * This will only return folders on which the caller has the + * permission `resourcemanager.folders.get`. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} [request.pageSize] + * Optional. The maximum number of folders to return in the response. The + * server can return fewer folders than requested. If unspecified, server + * picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * `SearchFolders` that indicates from where search should continue. + * @param {string} [request.query] + * Optional. Search criteria used to select the folders to return. + * If no search criteria is specified then all accessible folders will be + * returned. + * + * Query expressions can be used to restrict results based upon displayName, + * state and parent, where the operators `=` (`:`) `NOT`, `AND` and `OR` + * can be used along with the suffix wildcard symbol `*`. + * + * The `displayName` field in a query expression should use escaped quotes + * for values that include whitespace to prevent unexpected behavior. + * + * ``` + * | Field | Description | + * |-------------------------|----------------------------------------| + * | displayName | Filters by displayName. | + * | parent | Filters by parent (for example: folders/123). | + * | state, lifecycleState | Filters by state. | + * ``` + * + * Some example queries are: + * + * * Query `displayName=Test*` returns Folder resources whose display name + * starts with "Test". + * * Query `state=ACTIVE` returns Folder resources with + * `state` set to `ACTIVE`. + * * Query `parent=folders/123` returns Folder resources that have + * `folders/123` as a parent resource. + * * Query `parent=folders/123 AND state=ACTIVE` returns active + * Folder resources that have `folders/123` as a parent resource. + * * Query `displayName=\\"Test String\\"` returns Folder resources with + * display names that include both "Test" and "String". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.resourcemanager.v3.Folder|Folder}. + * 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 `searchFoldersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + searchFolders( + request?: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.IFolder[], + protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest|null, + protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse + ]>; + searchFolders( + request: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, + protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IFolder>): void; + searchFolders( + request: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, + protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IFolder>): void; + searchFolders( + request?: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, + protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IFolder>, + callback?: PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, + protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IFolder>): + Promise<[ + protos.google.cloud.resourcemanager.v3.IFolder[], + protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest|null, + protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.searchFolders(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 {number} [request.pageSize] + * Optional. The maximum number of folders to return in the response. The + * server can return fewer folders than requested. If unspecified, server + * picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * `SearchFolders` that indicates from where search should continue. + * @param {string} [request.query] + * Optional. Search criteria used to select the folders to return. + * If no search criteria is specified then all accessible folders will be + * returned. + * + * Query expressions can be used to restrict results based upon displayName, + * state and parent, where the operators `=` (`:`) `NOT`, `AND` and `OR` + * can be used along with the suffix wildcard symbol `*`. + * + * The `displayName` field in a query expression should use escaped quotes + * for values that include whitespace to prevent unexpected behavior. + * + * ``` + * | Field | Description | + * |-------------------------|----------------------------------------| + * | displayName | Filters by displayName. | + * | parent | Filters by parent (for example: folders/123). | + * | state, lifecycleState | Filters by state. | + * ``` + * + * Some example queries are: + * + * * Query `displayName=Test*` returns Folder resources whose display name + * starts with "Test". + * * Query `state=ACTIVE` returns Folder resources with + * `state` set to `ACTIVE`. + * * Query `parent=folders/123` returns Folder resources that have + * `folders/123` as a parent resource. + * * Query `parent=folders/123 AND state=ACTIVE` returns active + * Folder resources that have `folders/123` as a parent resource. + * * Query `displayName=\\"Test String\\"` returns Folder resources with + * display names that include both "Test" and "String". + * @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 protos.google.cloud.resourcemanager.v3.Folder|Folder} 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 `searchFoldersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + searchFoldersStream( + request?: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['searchFolders']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchFolders.createStream( + this.innerApiCalls.searchFolders as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `searchFolders`, 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 {number} [request.pageSize] + * Optional. The maximum number of folders to return in the response. The + * server can return fewer folders than requested. If unspecified, server + * picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * `SearchFolders` that indicates from where search should continue. + * @param {string} [request.query] + * Optional. Search criteria used to select the folders to return. + * If no search criteria is specified then all accessible folders will be + * returned. + * + * Query expressions can be used to restrict results based upon displayName, + * state and parent, where the operators `=` (`:`) `NOT`, `AND` and `OR` + * can be used along with the suffix wildcard symbol `*`. + * + * The `displayName` field in a query expression should use escaped quotes + * for values that include whitespace to prevent unexpected behavior. + * + * ``` + * | Field | Description | + * |-------------------------|----------------------------------------| + * | displayName | Filters by displayName. | + * | parent | Filters by parent (for example: folders/123). | + * | state, lifecycleState | Filters by state. | + * ``` + * + * Some example queries are: + * + * * Query `displayName=Test*` returns Folder resources whose display name + * starts with "Test". + * * Query `state=ACTIVE` returns Folder resources with + * `state` set to `ACTIVE`. + * * Query `parent=folders/123` returns Folder resources that have + * `folders/123` as a parent resource. + * * Query `parent=folders/123 AND state=ACTIVE` returns active + * Folder resources that have `folders/123` as a parent resource. + * * Query `displayName=\\"Test String\\"` returns Folder resources with + * display names that include both "Test" and "String". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.resourcemanager.v3.Folder|Folder}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v3/folders.search_folders.js + * region_tag:cloudresourcemanager_v3_generated_Folders_SearchFolders_async + */ + searchFoldersAsync( + request?: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['searchFolders']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchFolders.asyncIterate( + this.innerApiCalls['searchFolders'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * 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 folder resource name string. + * + * @param {string} folder + * @returns {string} Resource name string. + */ + folderPath(folder:string) { + return this.pathTemplates.folderPathTemplate.render({ + folder: folder, + }); + } + + /** + * Parse the folder from Folder resource. + * + * @param {string} folderName + * A fully-qualified path representing Folder resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderName(folderName: string) { + return this.pathTemplates.folderPathTemplate.match(folderName).folder; + } + + /** + * Return a fully-qualified organization resource name string. + * + * @param {string} organization + * @returns {string} Resource name string. + */ + organizationPath(organization:string) { + return this.pathTemplates.organizationPathTemplate.render({ + organization: organization, + }); + } + + /** + * Parse the organization from Organization resource. + * + * @param {string} organizationName + * A fully-qualified path representing Organization resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationName(organizationName: string) { + return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified tagBinding resource name string. + * + * @param {string} tag_binding + * @returns {string} Resource name string. + */ + tagBindingPath(tagBinding:string) { + return this.pathTemplates.tagBindingPathTemplate.render({ + tag_binding: tagBinding, + }); + } + + /** + * Parse the tag_binding from TagBinding resource. + * + * @param {string} tagBindingName + * A fully-qualified path representing TagBinding resource. + * @returns {string} A string representing the tag_binding. + */ + matchTagBindingFromTagBindingName(tagBindingName: string) { + return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; + } + + /** + * Return a fully-qualified tagHold resource name string. + * + * @param {string} tag_value + * @param {string} tag_hold + * @returns {string} Resource name string. + */ + tagHoldPath(tagValue:string,tagHold:string) { + return this.pathTemplates.tagHoldPathTemplate.render({ + tag_value: tagValue, + tag_hold: tagHold, + }); + } + + /** + * Parse the tag_value from TagHold resource. + * + * @param {string} tagHoldName + * A fully-qualified path representing TagHold resource. + * @returns {string} A string representing the tag_value. + */ + matchTagValueFromTagHoldName(tagHoldName: string) { + return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_value; + } + + /** + * Parse the tag_hold from TagHold resource. + * + * @param {string} tagHoldName + * A fully-qualified path representing TagHold resource. + * @returns {string} A string representing the tag_hold. + */ + matchTagHoldFromTagHoldName(tagHoldName: string) { + return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_hold; + } + + /** + * Return a fully-qualified tagKey resource name string. + * + * @param {string} tag_key + * @returns {string} Resource name string. + */ + tagKeyPath(tagKey:string) { + return this.pathTemplates.tagKeyPathTemplate.render({ + tag_key: tagKey, + }); + } + + /** + * Parse the tag_key from TagKey resource. + * + * @param {string} tagKeyName + * A fully-qualified path representing TagKey resource. + * @returns {string} A string representing the tag_key. + */ + matchTagKeyFromTagKeyName(tagKeyName: string) { + return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; + } + + /** + * Return a fully-qualified tagValue resource name string. + * + * @param {string} tag_value + * @returns {string} Resource name string. + */ + tagValuePath(tagValue:string) { + return this.pathTemplates.tagValuePathTemplate.render({ + tag_value: tagValue, + }); + } + + /** + * Parse the tag_value from TagValue resource. + * + * @param {string} tagValueName + * A fully-qualified path representing TagValue resource. + * @returns {string} A string representing the tag_value. + */ + matchTagValueFromTagValueName(tagValueName: string) { + return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; + } + + /** + * 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.foldersStub && !this._terminated) { + return this.foldersStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_client_config.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_client_config.json new file mode 100644 index 00000000000..a2bed85d6e8 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_client_config.json @@ -0,0 +1,83 @@ +{ + "interfaces": { + "google.cloud.resourcemanager.v3.Folders": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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": { + "GetFolder": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "ListFolders": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "SearchFolders": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateFolder": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateFolder": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "MoveFolder": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteFolder": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UndeleteFolder": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_proto_list.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_proto_list.json new file mode 100644 index 00000000000..639794aadd4 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/cloud/resourcemanager/v3/folders.proto", + "../../protos/google/cloud/resourcemanager/v3/organizations.proto", + "../../protos/google/cloud/resourcemanager/v3/projects.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_holds.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" +] diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/gapic_metadata.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/gapic_metadata.json new file mode 100644 index 00000000000..c68b1fa08e0 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/gapic_metadata.json @@ -0,0 +1,667 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.resourcemanager.v3", + "libraryPackage": "@google-cloud/resource-manager", + "services": { + "Folders": { + "clients": { + "grpc": { + "libraryClient": "FoldersClient", + "rpcs": { + "GetFolder": { + "methods": [ + "getFolder" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateFolder": { + "methods": [ + "createFolder" + ] + }, + "UpdateFolder": { + "methods": [ + "updateFolder" + ] + }, + "MoveFolder": { + "methods": [ + "moveFolder" + ] + }, + "DeleteFolder": { + "methods": [ + "deleteFolder" + ] + }, + "UndeleteFolder": { + "methods": [ + "undeleteFolder" + ] + }, + "ListFolders": { + "methods": [ + "listFolders", + "listFoldersStream", + "listFoldersAsync" + ] + }, + "SearchFolders": { + "methods": [ + "searchFolders", + "searchFoldersStream", + "searchFoldersAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "FoldersClient", + "rpcs": { + "GetFolder": { + "methods": [ + "getFolder" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateFolder": { + "methods": [ + "createFolder" + ] + }, + "UpdateFolder": { + "methods": [ + "updateFolder" + ] + }, + "MoveFolder": { + "methods": [ + "moveFolder" + ] + }, + "DeleteFolder": { + "methods": [ + "deleteFolder" + ] + }, + "UndeleteFolder": { + "methods": [ + "undeleteFolder" + ] + }, + "ListFolders": { + "methods": [ + "listFolders", + "listFoldersStream", + "listFoldersAsync" + ] + }, + "SearchFolders": { + "methods": [ + "searchFolders", + "searchFoldersStream", + "searchFoldersAsync" + ] + } + } + } + } + }, + "Organizations": { + "clients": { + "grpc": { + "libraryClient": "OrganizationsClient", + "rpcs": { + "GetOrganization": { + "methods": [ + "getOrganization" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "SearchOrganizations": { + "methods": [ + "searchOrganizations", + "searchOrganizationsStream", + "searchOrganizationsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "OrganizationsClient", + "rpcs": { + "GetOrganization": { + "methods": [ + "getOrganization" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "SearchOrganizations": { + "methods": [ + "searchOrganizations", + "searchOrganizationsStream", + "searchOrganizationsAsync" + ] + } + } + } + } + }, + "Projects": { + "clients": { + "grpc": { + "libraryClient": "ProjectsClient", + "rpcs": { + "GetProject": { + "methods": [ + "getProject" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateProject": { + "methods": [ + "createProject" + ] + }, + "UpdateProject": { + "methods": [ + "updateProject" + ] + }, + "MoveProject": { + "methods": [ + "moveProject" + ] + }, + "DeleteProject": { + "methods": [ + "deleteProject" + ] + }, + "UndeleteProject": { + "methods": [ + "undeleteProject" + ] + }, + "ListProjects": { + "methods": [ + "listProjects", + "listProjectsStream", + "listProjectsAsync" + ] + }, + "SearchProjects": { + "methods": [ + "searchProjects", + "searchProjectsStream", + "searchProjectsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProjectsClient", + "rpcs": { + "GetProject": { + "methods": [ + "getProject" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateProject": { + "methods": [ + "createProject" + ] + }, + "UpdateProject": { + "methods": [ + "updateProject" + ] + }, + "MoveProject": { + "methods": [ + "moveProject" + ] + }, + "DeleteProject": { + "methods": [ + "deleteProject" + ] + }, + "UndeleteProject": { + "methods": [ + "undeleteProject" + ] + }, + "ListProjects": { + "methods": [ + "listProjects", + "listProjectsStream", + "listProjectsAsync" + ] + }, + "SearchProjects": { + "methods": [ + "searchProjects", + "searchProjectsStream", + "searchProjectsAsync" + ] + } + } + } + } + }, + "TagBindings": { + "clients": { + "grpc": { + "libraryClient": "TagBindingsClient", + "rpcs": { + "CreateTagBinding": { + "methods": [ + "createTagBinding" + ] + }, + "DeleteTagBinding": { + "methods": [ + "deleteTagBinding" + ] + }, + "ListTagBindings": { + "methods": [ + "listTagBindings", + "listTagBindingsStream", + "listTagBindingsAsync" + ] + }, + "ListEffectiveTags": { + "methods": [ + "listEffectiveTags", + "listEffectiveTagsStream", + "listEffectiveTagsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "TagBindingsClient", + "rpcs": { + "CreateTagBinding": { + "methods": [ + "createTagBinding" + ] + }, + "DeleteTagBinding": { + "methods": [ + "deleteTagBinding" + ] + }, + "ListTagBindings": { + "methods": [ + "listTagBindings", + "listTagBindingsStream", + "listTagBindingsAsync" + ] + }, + "ListEffectiveTags": { + "methods": [ + "listEffectiveTags", + "listEffectiveTagsStream", + "listEffectiveTagsAsync" + ] + } + } + } + } + }, + "TagHolds": { + "clients": { + "grpc": { + "libraryClient": "TagHoldsClient", + "rpcs": { + "CreateTagHold": { + "methods": [ + "createTagHold" + ] + }, + "DeleteTagHold": { + "methods": [ + "deleteTagHold" + ] + }, + "ListTagHolds": { + "methods": [ + "listTagHolds", + "listTagHoldsStream", + "listTagHoldsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "TagHoldsClient", + "rpcs": { + "CreateTagHold": { + "methods": [ + "createTagHold" + ] + }, + "DeleteTagHold": { + "methods": [ + "deleteTagHold" + ] + }, + "ListTagHolds": { + "methods": [ + "listTagHolds", + "listTagHoldsStream", + "listTagHoldsAsync" + ] + } + } + } + } + }, + "TagKeys": { + "clients": { + "grpc": { + "libraryClient": "TagKeysClient", + "rpcs": { + "GetTagKey": { + "methods": [ + "getTagKey" + ] + }, + "GetNamespacedTagKey": { + "methods": [ + "getNamespacedTagKey" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateTagKey": { + "methods": [ + "createTagKey" + ] + }, + "UpdateTagKey": { + "methods": [ + "updateTagKey" + ] + }, + "DeleteTagKey": { + "methods": [ + "deleteTagKey" + ] + }, + "ListTagKeys": { + "methods": [ + "listTagKeys", + "listTagKeysStream", + "listTagKeysAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "TagKeysClient", + "rpcs": { + "GetTagKey": { + "methods": [ + "getTagKey" + ] + }, + "GetNamespacedTagKey": { + "methods": [ + "getNamespacedTagKey" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateTagKey": { + "methods": [ + "createTagKey" + ] + }, + "UpdateTagKey": { + "methods": [ + "updateTagKey" + ] + }, + "DeleteTagKey": { + "methods": [ + "deleteTagKey" + ] + }, + "ListTagKeys": { + "methods": [ + "listTagKeys", + "listTagKeysStream", + "listTagKeysAsync" + ] + } + } + } + } + }, + "TagValues": { + "clients": { + "grpc": { + "libraryClient": "TagValuesClient", + "rpcs": { + "GetTagValue": { + "methods": [ + "getTagValue" + ] + }, + "GetNamespacedTagValue": { + "methods": [ + "getNamespacedTagValue" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateTagValue": { + "methods": [ + "createTagValue" + ] + }, + "UpdateTagValue": { + "methods": [ + "updateTagValue" + ] + }, + "DeleteTagValue": { + "methods": [ + "deleteTagValue" + ] + }, + "ListTagValues": { + "methods": [ + "listTagValues", + "listTagValuesStream", + "listTagValuesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "TagValuesClient", + "rpcs": { + "GetTagValue": { + "methods": [ + "getTagValue" + ] + }, + "GetNamespacedTagValue": { + "methods": [ + "getNamespacedTagValue" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateTagValue": { + "methods": [ + "createTagValue" + ] + }, + "UpdateTagValue": { + "methods": [ + "updateTagValue" + ] + }, + "DeleteTagValue": { + "methods": [ + "deleteTagValue" + ] + }, + "ListTagValues": { + "methods": [ + "listTagValues", + "listTagValuesStream", + "listTagValuesAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/index.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/index.ts new file mode 100644 index 00000000000..a6fde064886 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {FoldersClient} from './folders_client'; +export {OrganizationsClient} from './organizations_client'; +export {ProjectsClient} from './projects_client'; +export {TagBindingsClient} from './tag_bindings_client'; +export {TagHoldsClient} from './tag_holds_client'; +export {TagKeysClient} from './tag_keys_client'; +export {TagValuesClient} from './tag_values_client'; diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_client.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_client.ts new file mode 100644 index 00000000000..71e727d549f --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_client.ts @@ -0,0 +1,1063 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v3/organizations_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './organizations_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Allows users to manage their organization resources. + * @class + * @memberof v3 + */ +export class OrganizationsClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + organizationsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of OrganizationsClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 OrganizationsClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof OrganizationsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + folderPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}' + ), + organizationPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + tagBindingPathTemplate: new this._gaxModule.PathTemplate( + 'tagBindings/{tag_binding}' + ), + tagHoldPathTemplate: new this._gaxModule.PathTemplate( + 'tagValues/{tag_value}/tagHolds/{tag_hold}' + ), + tagKeyPathTemplate: new this._gaxModule.PathTemplate( + 'tagKeys/{tag_key}' + ), + tagValuePathTemplate: new this._gaxModule.PathTemplate( + 'tagValues/{tag_value}' + ), + }; + + // 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 = { + searchOrganizations: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'organizations') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.resourcemanager.v3.Organizations', 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.organizationsStub) { + return this.organizationsStub; + } + + // Put together the "service stub" for + // google.cloud.resourcemanager.v3.Organizations. + this.organizationsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.Organizations') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.resourcemanager.v3.Organizations, + 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 organizationsStubMethods = + ['getOrganization', 'searchOrganizations', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of organizationsStubMethods) { + const callPromise = this.organizationsStub.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.organizationsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudresourcemanager.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 'cloudresourcemanager.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only' + ]; + } + + 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 -- + // ------------------- +/** + * Fetches an organization resource identified by the specified resource name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Organization to fetch. This is the + * organization's relative path in the API, formatted as + * "organizations/[organizationId]". For example, "organizations/1234". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.resourcemanager.v3.Organization|Organization}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/organizations.get_organization.js + * region_tag:cloudresourcemanager_v3_generated_Organizations_GetOrganization_async + */ + getOrganization( + request?: protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.IOrganization, + protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|undefined, {}|undefined + ]>; + getOrganization( + request: protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.resourcemanager.v3.IOrganization, + protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|null|undefined, + {}|null|undefined>): void; + getOrganization( + request: protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest, + callback: Callback< + protos.google.cloud.resourcemanager.v3.IOrganization, + protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|null|undefined, + {}|null|undefined>): void; + getOrganization( + request?: protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.resourcemanager.v3.IOrganization, + protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.resourcemanager.v3.IOrganization, + protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.resourcemanager.v3.IOrganization, + protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getOrganization(request, options, callback); + } +/** + * Gets the access control policy for an organization resource. The policy may + * be empty if no such policy or resource exists. The `resource` field should + * be the organization's resource name, for example: "organizations/123". + * + * Authorization requires the IAM permission + * `resourcemanager.organizations.getIamPolicy` on the specified organization. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/organizations.get_iam_policy.js + * region_tag:cloudresourcemanager_v3_generated_Organizations_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Sets the access control policy on an organization resource. Replaces any + * existing policy. The `resource` field should be the organization's resource + * name, for example: "organizations/123". + * + * Authorization requires the IAM permission + * `resourcemanager.organizations.setIamPolicy` on the specified organization. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/organizations.set_iam_policy.js + * region_tag:cloudresourcemanager_v3_generated_Organizations_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns the permissions that a caller has on the specified organization. + * The `resource` field should be the organization's resource name, + * for example: "organizations/123". + * + * There are no permissions required for making this API call. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/organizations.test_iam_permissions.js + * region_tag:cloudresourcemanager_v3_generated_Organizations_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + /** + * Searches organization resources that are visible to the user and satisfy + * the specified filter. This method returns organizations in an unspecified + * order. New organizations do not necessarily appear at the end of the + * results, and may take a small amount of time to appear. + * + * Search will only return organizations on which the user has the permission + * `resourcemanager.organizations.get` + * + * @param {Object} request + * The request object that will be sent. + * @param {number} [request.pageSize] + * Optional. The maximum number of organizations to return in the response. + * The server can return fewer organizations than requested. If unspecified, + * server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * `SearchOrganizations` that indicates from where listing should continue. + * @param {string} [request.query] + * Optional. An optional query string used to filter the Organizations to + * return in the response. Query rules are case-insensitive. + * + * + * ``` + * | Field | Description | + * |------------------|--------------------------------------------| + * | directoryCustomerId, owner.directoryCustomerId | Filters by directory + * customer id. | + * | domain | Filters by domain. | + * ``` + * + * Organizations may be queried by `directoryCustomerId` or by + * `domain`, where the domain is a G Suite domain, for example: + * + * * Query `directorycustomerid:123456789` returns Organization + * resources with `owner.directory_customer_id` equal to `123456789`. + * * Query `domain:google.com` returns Organization resources corresponding + * to the domain `google.com`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.resourcemanager.v3.Organization|Organization}. + * 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 `searchOrganizationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + searchOrganizations( + request?: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.IOrganization[], + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest|null, + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse + ]>; + searchOrganizations( + request: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IOrganization>): void; + searchOrganizations( + request: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IOrganization>): void; + searchOrganizations( + request?: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IOrganization>, + callback?: PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IOrganization>): + Promise<[ + protos.google.cloud.resourcemanager.v3.IOrganization[], + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest|null, + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.searchOrganizations(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 {number} [request.pageSize] + * Optional. The maximum number of organizations to return in the response. + * The server can return fewer organizations than requested. If unspecified, + * server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * `SearchOrganizations` that indicates from where listing should continue. + * @param {string} [request.query] + * Optional. An optional query string used to filter the Organizations to + * return in the response. Query rules are case-insensitive. + * + * + * ``` + * | Field | Description | + * |------------------|--------------------------------------------| + * | directoryCustomerId, owner.directoryCustomerId | Filters by directory + * customer id. | + * | domain | Filters by domain. | + * ``` + * + * Organizations may be queried by `directoryCustomerId` or by + * `domain`, where the domain is a G Suite domain, for example: + * + * * Query `directorycustomerid:123456789` returns Organization + * resources with `owner.directory_customer_id` equal to `123456789`. + * * Query `domain:google.com` returns Organization resources corresponding + * to the domain `google.com`. + * @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 protos.google.cloud.resourcemanager.v3.Organization|Organization} 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 `searchOrganizationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + searchOrganizationsStream( + request?: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['searchOrganizations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchOrganizations.createStream( + this.innerApiCalls.searchOrganizations as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `searchOrganizations`, 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 {number} [request.pageSize] + * Optional. The maximum number of organizations to return in the response. + * The server can return fewer organizations than requested. If unspecified, + * server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * `SearchOrganizations` that indicates from where listing should continue. + * @param {string} [request.query] + * Optional. An optional query string used to filter the Organizations to + * return in the response. Query rules are case-insensitive. + * + * + * ``` + * | Field | Description | + * |------------------|--------------------------------------------| + * | directoryCustomerId, owner.directoryCustomerId | Filters by directory + * customer id. | + * | domain | Filters by domain. | + * ``` + * + * Organizations may be queried by `directoryCustomerId` or by + * `domain`, where the domain is a G Suite domain, for example: + * + * * Query `directorycustomerid:123456789` returns Organization + * resources with `owner.directory_customer_id` equal to `123456789`. + * * Query `domain:google.com` returns Organization resources corresponding + * to the domain `google.com`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.resourcemanager.v3.Organization|Organization}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v3/organizations.search_organizations.js + * region_tag:cloudresourcemanager_v3_generated_Organizations_SearchOrganizations_async + */ + searchOrganizationsAsync( + request?: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['searchOrganizations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchOrganizations.asyncIterate( + this.innerApiCalls['searchOrganizations'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified folder resource name string. + * + * @param {string} folder + * @returns {string} Resource name string. + */ + folderPath(folder:string) { + return this.pathTemplates.folderPathTemplate.render({ + folder: folder, + }); + } + + /** + * Parse the folder from Folder resource. + * + * @param {string} folderName + * A fully-qualified path representing Folder resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderName(folderName: string) { + return this.pathTemplates.folderPathTemplate.match(folderName).folder; + } + + /** + * Return a fully-qualified organization resource name string. + * + * @param {string} organization + * @returns {string} Resource name string. + */ + organizationPath(organization:string) { + return this.pathTemplates.organizationPathTemplate.render({ + organization: organization, + }); + } + + /** + * Parse the organization from Organization resource. + * + * @param {string} organizationName + * A fully-qualified path representing Organization resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationName(organizationName: string) { + return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified tagBinding resource name string. + * + * @param {string} tag_binding + * @returns {string} Resource name string. + */ + tagBindingPath(tagBinding:string) { + return this.pathTemplates.tagBindingPathTemplate.render({ + tag_binding: tagBinding, + }); + } + + /** + * Parse the tag_binding from TagBinding resource. + * + * @param {string} tagBindingName + * A fully-qualified path representing TagBinding resource. + * @returns {string} A string representing the tag_binding. + */ + matchTagBindingFromTagBindingName(tagBindingName: string) { + return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; + } + + /** + * Return a fully-qualified tagHold resource name string. + * + * @param {string} tag_value + * @param {string} tag_hold + * @returns {string} Resource name string. + */ + tagHoldPath(tagValue:string,tagHold:string) { + return this.pathTemplates.tagHoldPathTemplate.render({ + tag_value: tagValue, + tag_hold: tagHold, + }); + } + + /** + * Parse the tag_value from TagHold resource. + * + * @param {string} tagHoldName + * A fully-qualified path representing TagHold resource. + * @returns {string} A string representing the tag_value. + */ + matchTagValueFromTagHoldName(tagHoldName: string) { + return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_value; + } + + /** + * Parse the tag_hold from TagHold resource. + * + * @param {string} tagHoldName + * A fully-qualified path representing TagHold resource. + * @returns {string} A string representing the tag_hold. + */ + matchTagHoldFromTagHoldName(tagHoldName: string) { + return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_hold; + } + + /** + * Return a fully-qualified tagKey resource name string. + * + * @param {string} tag_key + * @returns {string} Resource name string. + */ + tagKeyPath(tagKey:string) { + return this.pathTemplates.tagKeyPathTemplate.render({ + tag_key: tagKey, + }); + } + + /** + * Parse the tag_key from TagKey resource. + * + * @param {string} tagKeyName + * A fully-qualified path representing TagKey resource. + * @returns {string} A string representing the tag_key. + */ + matchTagKeyFromTagKeyName(tagKeyName: string) { + return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; + } + + /** + * Return a fully-qualified tagValue resource name string. + * + * @param {string} tag_value + * @returns {string} Resource name string. + */ + tagValuePath(tagValue:string) { + return this.pathTemplates.tagValuePathTemplate.render({ + tag_value: tagValue, + }); + } + + /** + * Parse the tag_value from TagValue resource. + * + * @param {string} tagValueName + * A fully-qualified path representing TagValue resource. + * @returns {string} A string representing the tag_value. + */ + matchTagValueFromTagValueName(tagValueName: string) { + return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; + } + + /** + * 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.organizationsStub && !this._terminated) { + return this.organizationsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_client_config.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_client_config.json new file mode 100644 index 00000000000..ca62d9146f1 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_client_config.json @@ -0,0 +1,53 @@ +{ + "interfaces": { + "google.cloud.resourcemanager.v3.Organizations": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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": { + "GetOrganization": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "SearchOrganizations": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_proto_list.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_proto_list.json new file mode 100644 index 00000000000..639794aadd4 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/cloud/resourcemanager/v3/folders.proto", + "../../protos/google/cloud/resourcemanager/v3/organizations.proto", + "../../protos/google/cloud/resourcemanager/v3/projects.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_holds.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" +] diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_client.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_client.ts new file mode 100644 index 00000000000..e30e12dcbf6 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_client.ts @@ -0,0 +1,2093 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v3/projects_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './projects_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Manages Google Cloud Projects. + * @class + * @memberof v3 + */ +export class ProjectsClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + projectsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProjectsClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 ProjectsClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ProjectsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + folderPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}' + ), + organizationPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + tagBindingPathTemplate: new this._gaxModule.PathTemplate( + 'tagBindings/{tag_binding}' + ), + tagHoldPathTemplate: new this._gaxModule.PathTemplate( + 'tagValues/{tag_value}/tagHolds/{tag_hold}' + ), + tagKeyPathTemplate: new this._gaxModule.PathTemplate( + 'tagKeys/{tag_key}' + ), + tagValuePathTemplate: new this._gaxModule.PathTemplate( + 'tagValues/{tag_value}' + ), + }; + + // 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 = { + listProjects: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'projects'), + searchProjects: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'projects') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v3/{name=operations/**}',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createProjectResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.Project') as gax.protobuf.Type; + const createProjectMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.CreateProjectMetadata') as gax.protobuf.Type; + const updateProjectResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.Project') as gax.protobuf.Type; + const updateProjectMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.UpdateProjectMetadata') as gax.protobuf.Type; + const moveProjectResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.Project') as gax.protobuf.Type; + const moveProjectMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.MoveProjectMetadata') as gax.protobuf.Type; + const deleteProjectResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.Project') as gax.protobuf.Type; + const deleteProjectMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.DeleteProjectMetadata') as gax.protobuf.Type; + const undeleteProjectResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.Project') as gax.protobuf.Type; + const undeleteProjectMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.UndeleteProjectMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createProject: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createProjectResponse.decode.bind(createProjectResponse), + createProjectMetadata.decode.bind(createProjectMetadata)), + updateProject: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateProjectResponse.decode.bind(updateProjectResponse), + updateProjectMetadata.decode.bind(updateProjectMetadata)), + moveProject: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + moveProjectResponse.decode.bind(moveProjectResponse), + moveProjectMetadata.decode.bind(moveProjectMetadata)), + deleteProject: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteProjectResponse.decode.bind(deleteProjectResponse), + deleteProjectMetadata.decode.bind(deleteProjectMetadata)), + undeleteProject: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + undeleteProjectResponse.decode.bind(undeleteProjectResponse), + undeleteProjectMetadata.decode.bind(undeleteProjectMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.resourcemanager.v3.Projects', 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.projectsStub) { + return this.projectsStub; + } + + // Put together the "service stub" for + // google.cloud.resourcemanager.v3.Projects. + this.projectsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.Projects') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.resourcemanager.v3.Projects, + 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 projectsStubMethods = + ['getProject', 'listProjects', 'searchProjects', 'createProject', 'updateProject', 'moveProject', 'deleteProject', 'undeleteProject', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of projectsStubMethods) { + const callPromise = this.projectsStub.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.projectsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudresourcemanager.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 'cloudresourcemanager.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only' + ]; + } + + 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 -- + // ------------------- +/** + * Retrieves the project identified by the specified `name` (for example, + * `projects/415104041262`). + * + * The caller must have `resourcemanager.projects.get` permission + * for this project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the project (for example, `projects/415104041262`). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.resourcemanager.v3.Project|Project}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/projects.get_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_GetProject_async + */ + getProject( + request?: protos.google.cloud.resourcemanager.v3.IGetProjectRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.IProject, + protos.google.cloud.resourcemanager.v3.IGetProjectRequest|undefined, {}|undefined + ]>; + getProject( + request: protos.google.cloud.resourcemanager.v3.IGetProjectRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.resourcemanager.v3.IProject, + protos.google.cloud.resourcemanager.v3.IGetProjectRequest|null|undefined, + {}|null|undefined>): void; + getProject( + request: protos.google.cloud.resourcemanager.v3.IGetProjectRequest, + callback: Callback< + protos.google.cloud.resourcemanager.v3.IProject, + protos.google.cloud.resourcemanager.v3.IGetProjectRequest|null|undefined, + {}|null|undefined>): void; + getProject( + request?: protos.google.cloud.resourcemanager.v3.IGetProjectRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.resourcemanager.v3.IProject, + protos.google.cloud.resourcemanager.v3.IGetProjectRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.resourcemanager.v3.IProject, + protos.google.cloud.resourcemanager.v3.IGetProjectRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.resourcemanager.v3.IProject, + protos.google.cloud.resourcemanager.v3.IGetProjectRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getProject(request, options, callback); + } +/** + * Returns the IAM access control policy for the specified project, in the + * format `projects/{ProjectIdOrNumber}` e.g. projects/123. + * Permission is denied if the policy or the resource do not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/projects.get_iam_policy.js + * region_tag:cloudresourcemanager_v3_generated_Projects_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Sets the IAM access control policy for the specified project, in the + * format `projects/{ProjectIdOrNumber}` e.g. projects/123. + * + * CAUTION: This method will replace the existing policy, and cannot be used + * to append additional IAM settings. + * + * Note: Removing service accounts from policies or changing their roles can + * render services completely inoperable. It is important to understand how + * the service account is being used before removing or updating its roles. + * + * The following constraints apply when using `setIamPolicy()`: + * + * + Project does not support `allUsers` and `allAuthenticatedUsers` as + * `members` in a `Binding` of a `Policy`. + * + * + The owner role can be granted to a `user`, `serviceAccount`, or a group + * that is part of an organization. For example, + * group@myownpersonaldomain.com could be added as an owner to a project in + * the myownpersonaldomain.com organization, but not the examplepetstore.com + * organization. + * + * + Service accounts can be made owners of a project directly + * without any restrictions. However, to be added as an owner, a user must be + * invited using the Cloud Platform console and must accept the invitation. + * + * + A user cannot be granted the owner role using `setIamPolicy()`. The user + * must be granted the owner role using the Cloud Platform Console and must + * explicitly accept the invitation. + * + * + Invitations to grant the owner role cannot be sent using + * `setIamPolicy()`; + * they must be sent only using the Cloud Platform Console. + * + * + If the project is not part of an organization, there must be at least + * one owner who has accepted the Terms of Service (ToS) agreement in the + * policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner + * from the policy will fail. This restriction also applies to legacy + * projects that no longer have owners who have accepted the ToS. Edits to + * IAM policies will be rejected until the lack of a ToS-accepting owner is + * rectified. If the project is part of an organization, you can remove all + * owners, potentially making the organization inaccessible. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/projects.set_iam_policy.js + * region_tag:cloudresourcemanager_v3_generated_Projects_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified project, in the + * format `projects/{ProjectIdOrNumber}` e.g. projects/123.. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/projects.test_iam_permissions.js + * region_tag:cloudresourcemanager_v3_generated_Projects_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + +/** + * Request that a new project be created. The result is an `Operation` which + * can be used to track the creation process. This process usually takes a few + * seconds, but can sometimes take much longer. The tracking `Operation` is + * automatically deleted after a few hours, so there is no need to call + * `DeleteOperation`. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.resourcemanager.v3.Project} request.project + * Required. The Project to create. + * + * Project ID is required. If the requested ID is unavailable, the request + * fails. + * + * If the `parent` field is set, the `resourcemanager.projects.create` + * permission is checked on the parent resource. If no parent is set and + * the authorization credentials belong to an Organization, the parent + * will be set to that Organization. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/projects.create_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_CreateProject_async + */ + createProject( + request?: protos.google.cloud.resourcemanager.v3.ICreateProjectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createProject( + request: protos.google.cloud.resourcemanager.v3.ICreateProjectRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createProject( + request: protos.google.cloud.resourcemanager.v3.ICreateProjectRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createProject( + request?: protos.google.cloud.resourcemanager.v3.ICreateProjectRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.createProject(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createProject()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/projects.create_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_CreateProject_async + */ + async checkCreateProjectProgress(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.createProject, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the `display_name` and labels of the project identified by the + * specified `name` (for example, `projects/415104041262`). Deleting all + * labels requires an update mask for labels field. + * + * The caller must have `resourcemanager.projects.update` permission for this + * project. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.resourcemanager.v3.Project} request.project + * Required. The new definition of the project. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. An update mask to selectively update 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/projects.update_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_UpdateProject_async + */ + updateProject( + request?: protos.google.cloud.resourcemanager.v3.IUpdateProjectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateProject( + request: protos.google.cloud.resourcemanager.v3.IUpdateProjectRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateProject( + request: protos.google.cloud.resourcemanager.v3.IUpdateProjectRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateProject( + request?: protos.google.cloud.resourcemanager.v3.IUpdateProjectRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project.name': request.project!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateProject(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateProject()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/projects.update_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_UpdateProject_async + */ + async checkUpdateProjectProgress(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.updateProject, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Move a project to another place in your resource hierarchy, under a new + * resource parent. + * + * Returns an operation which can be used to track the process of the project + * move workflow. + * Upon success, the `Operation.response` field will be populated with the + * moved project. + * + * The caller must have `resourcemanager.projects.move` permission on the + * project, on the project's current and proposed new parent. + * + * If project has no current parent, or it currently does not have an + * associated organization resource, you will also need the + * `resourcemanager.projects.setIamPolicy` permission in the project. + * + * + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the project to move. + * @param {string} request.destinationParent + * Required. The new parent to move the Project under. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/projects.move_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_MoveProject_async + */ + moveProject( + request?: protos.google.cloud.resourcemanager.v3.IMoveProjectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + moveProject( + request: protos.google.cloud.resourcemanager.v3.IMoveProjectRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + moveProject( + request: protos.google.cloud.resourcemanager.v3.IMoveProjectRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + moveProject( + request?: protos.google.cloud.resourcemanager.v3.IMoveProjectRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.moveProject(request, options, callback); + } +/** + * Check the status of the long running operation returned by `moveProject()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/projects.move_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_MoveProject_async + */ + async checkMoveProjectProgress(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.moveProject, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Marks the project identified by the specified + * `name` (for example, `projects/415104041262`) for deletion. + * + * This method will only affect the project if it has a lifecycle state of + * {@link protos.google.cloud.resourcemanager.v3.Project.State.ACTIVE|ACTIVE}. + * + * This method changes the Project's lifecycle state from + * {@link protos.google.cloud.resourcemanager.v3.Project.State.ACTIVE|ACTIVE} + * to + * {@link protos.google.cloud.resourcemanager.v3.Project.State.DELETE_REQUESTED|DELETE_REQUESTED}. + * The deletion starts at an unspecified time, + * at which point the Project is no longer accessible. + * + * Until the deletion completes, you can check the lifecycle state + * checked by retrieving the project with [GetProject] + * [google.cloud.resourcemanager.v3.Projects.GetProject], + * and the project remains visible to [ListProjects] + * [google.cloud.resourcemanager.v3.Projects.ListProjects]. + * However, you cannot update the project. + * + * After the deletion completes, the project is not retrievable by + * the [GetProject] + * [google.cloud.resourcemanager.v3.Projects.GetProject], + * [ListProjects] + * [google.cloud.resourcemanager.v3.Projects.ListProjects], and + * {@link protos.google.cloud.resourcemanager.v3.Projects.SearchProjects|SearchProjects} + * methods. + * + * This method behaves idempotently, such that deleting a `DELETE_REQUESTED` + * project will not cause an error, but also won't do anything. + * + * The caller must have `resourcemanager.projects.delete` permissions for this + * project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Project (for example, `projects/415104041262`). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/projects.delete_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_DeleteProject_async + */ + deleteProject( + request?: protos.google.cloud.resourcemanager.v3.IDeleteProjectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteProject( + request: protos.google.cloud.resourcemanager.v3.IDeleteProjectRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteProject( + request: protos.google.cloud.resourcemanager.v3.IDeleteProjectRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteProject( + request?: protos.google.cloud.resourcemanager.v3.IDeleteProjectRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteProject(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteProject()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/projects.delete_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_DeleteProject_async + */ + async checkDeleteProjectProgress(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.deleteProject, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Restores the project identified by the specified + * `name` (for example, `projects/415104041262`). + * You can only use this method for a project that has a lifecycle state of + * [DELETE_REQUESTED] + * [Projects.State.DELETE_REQUESTED]. + * After deletion starts, the project cannot be restored. + * + * The caller must have `resourcemanager.projects.undelete` permission for + * this project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the project (for example, `projects/415104041262`). + * + * Required. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/projects.undelete_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_UndeleteProject_async + */ + undeleteProject( + request?: protos.google.cloud.resourcemanager.v3.IUndeleteProjectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + undeleteProject( + request: protos.google.cloud.resourcemanager.v3.IUndeleteProjectRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + undeleteProject( + request: protos.google.cloud.resourcemanager.v3.IUndeleteProjectRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + undeleteProject( + request?: protos.google.cloud.resourcemanager.v3.IUndeleteProjectRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.undeleteProject(request, options, callback); + } +/** + * Check the status of the long running operation returned by `undeleteProject()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/projects.undelete_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_UndeleteProject_async + */ + async checkUndeleteProjectProgress(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.undeleteProject, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists projects that are direct children of the specified folder or + * organization resource. `list()` provides a strongly consistent view of the + * projects underneath the specified parent resource. `list()` returns + * projects sorted based upon the (ascending) lexical ordering of their + * `display_name`. The caller must have `resourcemanager.projects.list` + * permission on the identified parent. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource whose projects are being listed. + * Only children of this parent resource are listed; descendants are not + * listed. + * + * If the parent is a folder, use the value `folders/{folder_id}`. If the + * parent is an organization, use the value `organizations/{org_id}`. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects] that + * indicates from where listing should continue. + * @param {number} [request.pageSize] + * Optional. The maximum number of projects to return in the response. + * The server can return fewer projects than requested. + * If unspecified, server picks an appropriate default. + * @param {boolean} [request.showDeleted] + * Optional. Indicate that projects in the `DELETE_REQUESTED` state should + * also be returned. Normally only `ACTIVE` projects are 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 protos.google.cloud.resourcemanager.v3.Project|Project}. + * 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 `listProjectsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listProjects( + request?: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.IProject[], + protos.google.cloud.resourcemanager.v3.IListProjectsRequest|null, + protos.google.cloud.resourcemanager.v3.IListProjectsResponse + ]>; + listProjects( + request: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListProjectsRequest, + protos.google.cloud.resourcemanager.v3.IListProjectsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IProject>): void; + listProjects( + request: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListProjectsRequest, + protos.google.cloud.resourcemanager.v3.IListProjectsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IProject>): void; + listProjects( + request?: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListProjectsRequest, + protos.google.cloud.resourcemanager.v3.IListProjectsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IProject>, + callback?: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListProjectsRequest, + protos.google.cloud.resourcemanager.v3.IListProjectsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IProject>): + Promise<[ + protos.google.cloud.resourcemanager.v3.IProject[], + protos.google.cloud.resourcemanager.v3.IListProjectsRequest|null, + protos.google.cloud.resourcemanager.v3.IListProjectsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.listProjects(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 name of the parent resource whose projects are being listed. + * Only children of this parent resource are listed; descendants are not + * listed. + * + * If the parent is a folder, use the value `folders/{folder_id}`. If the + * parent is an organization, use the value `organizations/{org_id}`. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects] that + * indicates from where listing should continue. + * @param {number} [request.pageSize] + * Optional. The maximum number of projects to return in the response. + * The server can return fewer projects than requested. + * If unspecified, server picks an appropriate default. + * @param {boolean} [request.showDeleted] + * Optional. Indicate that projects in the `DELETE_REQUESTED` state should + * also be returned. Normally only `ACTIVE` projects are 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 protos.google.cloud.resourcemanager.v3.Project|Project} 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 `listProjectsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listProjectsStream( + request?: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listProjects']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProjects.createStream( + this.innerApiCalls.listProjects as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProjects`, 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 name of the parent resource whose projects are being listed. + * Only children of this parent resource are listed; descendants are not + * listed. + * + * If the parent is a folder, use the value `folders/{folder_id}`. If the + * parent is an organization, use the value `organizations/{org_id}`. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects] that + * indicates from where listing should continue. + * @param {number} [request.pageSize] + * Optional. The maximum number of projects to return in the response. + * The server can return fewer projects than requested. + * If unspecified, server picks an appropriate default. + * @param {boolean} [request.showDeleted] + * Optional. Indicate that projects in the `DELETE_REQUESTED` state should + * also be returned. Normally only `ACTIVE` projects are 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.resourcemanager.v3.Project|Project}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v3/projects.list_projects.js + * region_tag:cloudresourcemanager_v3_generated_Projects_ListProjects_async + */ + listProjectsAsync( + request?: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listProjects']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProjects.asyncIterate( + this.innerApiCalls['listProjects'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Search for projects that the caller has both `resourcemanager.projects.get` + * permission on, and also satisfy the specified query. + * + * This method returns projects in an unspecified order. + * + * This method is eventually consistent with project mutations; this means + * that a newly created project may not appear in the results or recent + * updates to an existing project may not be reflected in the results. To + * retrieve the latest state of a project, use the + * {@link protos.google.cloud.resourcemanager.v3.Projects.GetProject|GetProject} method. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} [request.query] + * Optional. A query string for searching for projects that the caller has + * `resourcemanager.projects.get` permission to. If multiple fields are + * included in the query, then it will return results that match any of the + * fields. Some eligible fields are: + * + * - **`displayName`, `name`**: Filters by displayName. + * - **`parent`**: Project's parent (for example: `folders/123`, + * `organizations/*`). Prefer `parent` field over `parent.type` and + * `parent.id`. + * - **`parent.type`**: Parent's type: `folder` or `organization`. + * - **`parent.id`**: Parent's id number (for example: `123`). + * - **`id`, `projectId`**: Filters by projectId. + * - **`state`, `lifecycleState`**: Filters by state. + * - **`labels`**: Filters by label name or value. + * - **`labels.` (where `` is the name of a label)**: Filters by label + * name. + * + * Search expressions are case insensitive. + * + * Some examples queries: + * + * + * - **`name:how*`**: The project's name starts with "how". + * - **`name:Howl`**: The project's name is `Howl` or `howl`. + * - **`name:HOWL`**: Equivalent to above. + * - **`NAME:howl`**: Equivalent to above. + * - **`labels.color:*`**: The project has the label `color`. + * - **`labels.color:red`**: The project's label `color` has the value `red`. + * - **`labels.color:red labels.size:big`**: The project's label `color` has + * the value `red` or its label `size` has the value `big`. + * + * If no query is specified, the call will return projects for which the user + * has the `resourcemanager.projects.get` permission. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects] that + * indicates from where listing should continue. + * @param {number} [request.pageSize] + * Optional. The maximum number of projects to return in the response. + * The server can return fewer projects than requested. + * If unspecified, server picks an appropriate default. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.resourcemanager.v3.Project|Project}. + * 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 `searchProjectsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + searchProjects( + request?: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.IProject[], + protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest|null, + protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse + ]>; + searchProjects( + request: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, + protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IProject>): void; + searchProjects( + request: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, + protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IProject>): void; + searchProjects( + request?: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, + protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IProject>, + callback?: PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, + protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IProject>): + Promise<[ + protos.google.cloud.resourcemanager.v3.IProject[], + protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest|null, + protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.searchProjects(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.query] + * Optional. A query string for searching for projects that the caller has + * `resourcemanager.projects.get` permission to. If multiple fields are + * included in the query, then it will return results that match any of the + * fields. Some eligible fields are: + * + * - **`displayName`, `name`**: Filters by displayName. + * - **`parent`**: Project's parent (for example: `folders/123`, + * `organizations/*`). Prefer `parent` field over `parent.type` and + * `parent.id`. + * - **`parent.type`**: Parent's type: `folder` or `organization`. + * - **`parent.id`**: Parent's id number (for example: `123`). + * - **`id`, `projectId`**: Filters by projectId. + * - **`state`, `lifecycleState`**: Filters by state. + * - **`labels`**: Filters by label name or value. + * - **`labels.` (where `` is the name of a label)**: Filters by label + * name. + * + * Search expressions are case insensitive. + * + * Some examples queries: + * + * + * - **`name:how*`**: The project's name starts with "how". + * - **`name:Howl`**: The project's name is `Howl` or `howl`. + * - **`name:HOWL`**: Equivalent to above. + * - **`NAME:howl`**: Equivalent to above. + * - **`labels.color:*`**: The project has the label `color`. + * - **`labels.color:red`**: The project's label `color` has the value `red`. + * - **`labels.color:red labels.size:big`**: The project's label `color` has + * the value `red` or its label `size` has the value `big`. + * + * If no query is specified, the call will return projects for which the user + * has the `resourcemanager.projects.get` permission. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects] that + * indicates from where listing should continue. + * @param {number} [request.pageSize] + * Optional. The maximum number of projects to return in the response. + * The server can return fewer projects than requested. + * If unspecified, server picks an appropriate default. + * @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 protos.google.cloud.resourcemanager.v3.Project|Project} 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 `searchProjectsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + searchProjectsStream( + request?: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['searchProjects']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchProjects.createStream( + this.innerApiCalls.searchProjects as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `searchProjects`, 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.query] + * Optional. A query string for searching for projects that the caller has + * `resourcemanager.projects.get` permission to. If multiple fields are + * included in the query, then it will return results that match any of the + * fields. Some eligible fields are: + * + * - **`displayName`, `name`**: Filters by displayName. + * - **`parent`**: Project's parent (for example: `folders/123`, + * `organizations/*`). Prefer `parent` field over `parent.type` and + * `parent.id`. + * - **`parent.type`**: Parent's type: `folder` or `organization`. + * - **`parent.id`**: Parent's id number (for example: `123`). + * - **`id`, `projectId`**: Filters by projectId. + * - **`state`, `lifecycleState`**: Filters by state. + * - **`labels`**: Filters by label name or value. + * - **`labels.` (where `` is the name of a label)**: Filters by label + * name. + * + * Search expressions are case insensitive. + * + * Some examples queries: + * + * + * - **`name:how*`**: The project's name starts with "how". + * - **`name:Howl`**: The project's name is `Howl` or `howl`. + * - **`name:HOWL`**: Equivalent to above. + * - **`NAME:howl`**: Equivalent to above. + * - **`labels.color:*`**: The project has the label `color`. + * - **`labels.color:red`**: The project's label `color` has the value `red`. + * - **`labels.color:red labels.size:big`**: The project's label `color` has + * the value `red` or its label `size` has the value `big`. + * + * If no query is specified, the call will return projects for which the user + * has the `resourcemanager.projects.get` permission. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects] that + * indicates from where listing should continue. + * @param {number} [request.pageSize] + * Optional. The maximum number of projects to return in the response. + * The server can return fewer projects than requested. + * If unspecified, server picks an appropriate default. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.resourcemanager.v3.Project|Project}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v3/projects.search_projects.js + * region_tag:cloudresourcemanager_v3_generated_Projects_SearchProjects_async + */ + searchProjectsAsync( + request?: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['searchProjects']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchProjects.asyncIterate( + this.innerApiCalls['searchProjects'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * 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 folder resource name string. + * + * @param {string} folder + * @returns {string} Resource name string. + */ + folderPath(folder:string) { + return this.pathTemplates.folderPathTemplate.render({ + folder: folder, + }); + } + + /** + * Parse the folder from Folder resource. + * + * @param {string} folderName + * A fully-qualified path representing Folder resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderName(folderName: string) { + return this.pathTemplates.folderPathTemplate.match(folderName).folder; + } + + /** + * Return a fully-qualified organization resource name string. + * + * @param {string} organization + * @returns {string} Resource name string. + */ + organizationPath(organization:string) { + return this.pathTemplates.organizationPathTemplate.render({ + organization: organization, + }); + } + + /** + * Parse the organization from Organization resource. + * + * @param {string} organizationName + * A fully-qualified path representing Organization resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationName(organizationName: string) { + return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified tagBinding resource name string. + * + * @param {string} tag_binding + * @returns {string} Resource name string. + */ + tagBindingPath(tagBinding:string) { + return this.pathTemplates.tagBindingPathTemplate.render({ + tag_binding: tagBinding, + }); + } + + /** + * Parse the tag_binding from TagBinding resource. + * + * @param {string} tagBindingName + * A fully-qualified path representing TagBinding resource. + * @returns {string} A string representing the tag_binding. + */ + matchTagBindingFromTagBindingName(tagBindingName: string) { + return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; + } + + /** + * Return a fully-qualified tagHold resource name string. + * + * @param {string} tag_value + * @param {string} tag_hold + * @returns {string} Resource name string. + */ + tagHoldPath(tagValue:string,tagHold:string) { + return this.pathTemplates.tagHoldPathTemplate.render({ + tag_value: tagValue, + tag_hold: tagHold, + }); + } + + /** + * Parse the tag_value from TagHold resource. + * + * @param {string} tagHoldName + * A fully-qualified path representing TagHold resource. + * @returns {string} A string representing the tag_value. + */ + matchTagValueFromTagHoldName(tagHoldName: string) { + return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_value; + } + + /** + * Parse the tag_hold from TagHold resource. + * + * @param {string} tagHoldName + * A fully-qualified path representing TagHold resource. + * @returns {string} A string representing the tag_hold. + */ + matchTagHoldFromTagHoldName(tagHoldName: string) { + return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_hold; + } + + /** + * Return a fully-qualified tagKey resource name string. + * + * @param {string} tag_key + * @returns {string} Resource name string. + */ + tagKeyPath(tagKey:string) { + return this.pathTemplates.tagKeyPathTemplate.render({ + tag_key: tagKey, + }); + } + + /** + * Parse the tag_key from TagKey resource. + * + * @param {string} tagKeyName + * A fully-qualified path representing TagKey resource. + * @returns {string} A string representing the tag_key. + */ + matchTagKeyFromTagKeyName(tagKeyName: string) { + return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; + } + + /** + * Return a fully-qualified tagValue resource name string. + * + * @param {string} tag_value + * @returns {string} Resource name string. + */ + tagValuePath(tagValue:string) { + return this.pathTemplates.tagValuePathTemplate.render({ + tag_value: tagValue, + }); + } + + /** + * Parse the tag_value from TagValue resource. + * + * @param {string} tagValueName + * A fully-qualified path representing TagValue resource. + * @returns {string} A string representing the tag_value. + */ + matchTagValueFromTagValueName(tagValueName: string) { + return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; + } + + /** + * 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.projectsStub && !this._terminated) { + return this.projectsStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_client_config.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_client_config.json new file mode 100644 index 00000000000..f1308d45931 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_client_config.json @@ -0,0 +1,83 @@ +{ + "interfaces": { + "google.cloud.resourcemanager.v3.Projects": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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": { + "GetProject": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "ListProjects": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "SearchProjects": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateProject": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateProject": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "MoveProject": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteProject": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UndeleteProject": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_proto_list.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_proto_list.json new file mode 100644 index 00000000000..639794aadd4 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/cloud/resourcemanager/v3/folders.proto", + "../../protos/google/cloud/resourcemanager/v3/organizations.proto", + "../../protos/google/cloud/resourcemanager/v3/projects.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_holds.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" +] diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_client.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_client.ts new file mode 100644 index 00000000000..8ea49ac9dbd --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_client.ts @@ -0,0 +1,1258 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v3/tag_bindings_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './tag_bindings_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Allow users to create and manage TagBindings between TagValues and + * different Google Cloud resources throughout the GCP resource hierarchy. + * @class + * @memberof v3 + */ +export class TagBindingsClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + tagBindingsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of TagBindingsClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 TagBindingsClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof TagBindingsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + folderPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}' + ), + organizationPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + tagBindingPathTemplate: new this._gaxModule.PathTemplate( + 'tagBindings/{tag_binding}' + ), + tagHoldPathTemplate: new this._gaxModule.PathTemplate( + 'tagValues/{tag_value}/tagHolds/{tag_hold}' + ), + tagKeyPathTemplate: new this._gaxModule.PathTemplate( + 'tagKeys/{tag_key}' + ), + tagValuePathTemplate: new this._gaxModule.PathTemplate( + 'tagValues/{tag_value}' + ), + }; + + // 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 = { + listTagBindings: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tagBindings'), + listEffectiveTags: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'effectiveTags') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v3/{name=operations/**}',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createTagBindingResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.TagBinding') as gax.protobuf.Type; + const createTagBindingMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.CreateTagBindingMetadata') as gax.protobuf.Type; + const deleteTagBindingResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteTagBindingMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.DeleteTagBindingMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createTagBinding: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createTagBindingResponse.decode.bind(createTagBindingResponse), + createTagBindingMetadata.decode.bind(createTagBindingMetadata)), + deleteTagBinding: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteTagBindingResponse.decode.bind(deleteTagBindingResponse), + deleteTagBindingMetadata.decode.bind(deleteTagBindingMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.resourcemanager.v3.TagBindings', 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.tagBindingsStub) { + return this.tagBindingsStub; + } + + // Put together the "service stub" for + // google.cloud.resourcemanager.v3.TagBindings. + this.tagBindingsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.TagBindings') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.resourcemanager.v3.TagBindings, + 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 tagBindingsStubMethods = + ['listTagBindings', 'createTagBinding', 'deleteTagBinding', 'listEffectiveTags']; + for (const methodName of tagBindingsStubMethods) { + const callPromise = this.tagBindingsStub.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.tagBindingsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudresourcemanager.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 'cloudresourcemanager.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only' + ]; + } + + 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 TagBinding between a TagValue and a Google Cloud resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.resourcemanager.v3.TagBinding} request.tagBinding + * Required. The TagBinding to be created. + * @param {boolean} [request.validateOnly] + * Optional. Set to true to perform the validations necessary for creating the + * resource, but not actually perform the action. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_bindings.create_tag_binding.js + * region_tag:cloudresourcemanager_v3_generated_TagBindings_CreateTagBinding_async + */ + createTagBinding( + request?: protos.google.cloud.resourcemanager.v3.ICreateTagBindingRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createTagBinding( + request: protos.google.cloud.resourcemanager.v3.ICreateTagBindingRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createTagBinding( + request: protos.google.cloud.resourcemanager.v3.ICreateTagBindingRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createTagBinding( + request?: protos.google.cloud.resourcemanager.v3.ICreateTagBindingRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.createTagBinding(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createTagBinding()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_bindings.create_tag_binding.js + * region_tag:cloudresourcemanager_v3_generated_TagBindings_CreateTagBinding_async + */ + async checkCreateTagBindingProgress(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.createTagBinding, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a TagBinding. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the TagBinding. This is a String of the form: + * `tagBindings/{id}` (e.g. + * `tagBindings/%2F%2Fcloudresourcemanager.googleapis.com%2Fprojects%2F123/tagValues/456`). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_bindings.delete_tag_binding.js + * region_tag:cloudresourcemanager_v3_generated_TagBindings_DeleteTagBinding_async + */ + deleteTagBinding( + request?: protos.google.cloud.resourcemanager.v3.IDeleteTagBindingRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteTagBinding( + request: protos.google.cloud.resourcemanager.v3.IDeleteTagBindingRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteTagBinding( + request: protos.google.cloud.resourcemanager.v3.IDeleteTagBindingRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteTagBinding( + request?: protos.google.cloud.resourcemanager.v3.IDeleteTagBindingRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteTagBinding(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteTagBinding()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_bindings.delete_tag_binding.js + * region_tag:cloudresourcemanager_v3_generated_TagBindings_DeleteTagBinding_async + */ + async checkDeleteTagBindingProgress(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.deleteTagBinding, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists the TagBindings for the given Google Cloud resource, as specified + * with `parent`. + * + * NOTE: The `parent` field is expected to be a full resource name: + * https://cloud.google.com/apis/design/resource_names#full_resource_name + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The full resource name of a resource for which you want to list + * existing TagBindings. E.g. + * "//cloudresourcemanager.googleapis.com/projects/123" + * @param {number} [request.pageSize] + * Optional. The maximum number of TagBindings to return in the response. The + * server allows a maximum of 300 TagBindings to return. If unspecified, the + * server will use 100 as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * `ListTagBindings` that indicates where this listing should continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.resourcemanager.v3.TagBinding|TagBinding}. + * 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 `listTagBindingsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listTagBindings( + request?: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagBinding[], + protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest|null, + protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse + ]>; + listTagBindings( + request: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, + protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagBinding>): void; + listTagBindings( + request: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, + protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagBinding>): void; + listTagBindings( + request?: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, + protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagBinding>, + callback?: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, + protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagBinding>): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagBinding[], + protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest|null, + protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.listTagBindings(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 full resource name of a resource for which you want to list + * existing TagBindings. E.g. + * "//cloudresourcemanager.googleapis.com/projects/123" + * @param {number} [request.pageSize] + * Optional. The maximum number of TagBindings to return in the response. The + * server allows a maximum of 300 TagBindings to return. If unspecified, the + * server will use 100 as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * `ListTagBindings` that indicates where this listing should continue from. + * @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 protos.google.cloud.resourcemanager.v3.TagBinding|TagBinding} 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 `listTagBindingsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listTagBindingsStream( + request?: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listTagBindings']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTagBindings.createStream( + this.innerApiCalls.listTagBindings as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listTagBindings`, 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 full resource name of a resource for which you want to list + * existing TagBindings. E.g. + * "//cloudresourcemanager.googleapis.com/projects/123" + * @param {number} [request.pageSize] + * Optional. The maximum number of TagBindings to return in the response. The + * server allows a maximum of 300 TagBindings to return. If unspecified, the + * server will use 100 as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * `ListTagBindings` that indicates where this listing should continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.resourcemanager.v3.TagBinding|TagBinding}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_bindings.list_tag_bindings.js + * region_tag:cloudresourcemanager_v3_generated_TagBindings_ListTagBindings_async + */ + listTagBindingsAsync( + request?: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listTagBindings']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTagBindings.asyncIterate( + this.innerApiCalls['listTagBindings'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Return a list of effective tags for the given Google Cloud resource, as + * specified in `parent`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The full resource name of a resource for which you want to list + * the effective tags. E.g. + * "//cloudresourcemanager.googleapis.com/projects/123" + * @param {number} [request.pageSize] + * Optional. The maximum number of effective tags to return in the response. + * The server allows a maximum of 300 effective tags to return in a single + * page. If unspecified, the server will use 100 as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * `ListEffectiveTags` that indicates from where this listing should continue. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.resourcemanager.v3.EffectiveTag|EffectiveTag}. + * 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 `listEffectiveTagsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listEffectiveTags( + request?: protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.IEffectiveTag[], + protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest|null, + protos.google.cloud.resourcemanager.v3.IListEffectiveTagsResponse + ]>; + listEffectiveTags( + request: protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest, + protos.google.cloud.resourcemanager.v3.IListEffectiveTagsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IEffectiveTag>): void; + listEffectiveTags( + request: protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest, + protos.google.cloud.resourcemanager.v3.IListEffectiveTagsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IEffectiveTag>): void; + listEffectiveTags( + request?: protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest, + protos.google.cloud.resourcemanager.v3.IListEffectiveTagsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IEffectiveTag>, + callback?: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest, + protos.google.cloud.resourcemanager.v3.IListEffectiveTagsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IEffectiveTag>): + Promise<[ + protos.google.cloud.resourcemanager.v3.IEffectiveTag[], + protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest|null, + protos.google.cloud.resourcemanager.v3.IListEffectiveTagsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.listEffectiveTags(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 full resource name of a resource for which you want to list + * the effective tags. E.g. + * "//cloudresourcemanager.googleapis.com/projects/123" + * @param {number} [request.pageSize] + * Optional. The maximum number of effective tags to return in the response. + * The server allows a maximum of 300 effective tags to return in a single + * page. If unspecified, the server will use 100 as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * `ListEffectiveTags` that indicates from where this listing should continue. + * @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 protos.google.cloud.resourcemanager.v3.EffectiveTag|EffectiveTag} 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 `listEffectiveTagsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listEffectiveTagsStream( + request?: protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listEffectiveTags']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listEffectiveTags.createStream( + this.innerApiCalls.listEffectiveTags as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listEffectiveTags`, 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 full resource name of a resource for which you want to list + * the effective tags. E.g. + * "//cloudresourcemanager.googleapis.com/projects/123" + * @param {number} [request.pageSize] + * Optional. The maximum number of effective tags to return in the response. + * The server allows a maximum of 300 effective tags to return in a single + * page. If unspecified, the server will use 100 as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * `ListEffectiveTags` that indicates from where this listing should continue. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.resourcemanager.v3.EffectiveTag|EffectiveTag}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_bindings.list_effective_tags.js + * region_tag:cloudresourcemanager_v3_generated_TagBindings_ListEffectiveTags_async + */ + listEffectiveTagsAsync( + request?: protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listEffectiveTags']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listEffectiveTags.asyncIterate( + this.innerApiCalls['listEffectiveTags'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * 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 folder resource name string. + * + * @param {string} folder + * @returns {string} Resource name string. + */ + folderPath(folder:string) { + return this.pathTemplates.folderPathTemplate.render({ + folder: folder, + }); + } + + /** + * Parse the folder from Folder resource. + * + * @param {string} folderName + * A fully-qualified path representing Folder resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderName(folderName: string) { + return this.pathTemplates.folderPathTemplate.match(folderName).folder; + } + + /** + * Return a fully-qualified organization resource name string. + * + * @param {string} organization + * @returns {string} Resource name string. + */ + organizationPath(organization:string) { + return this.pathTemplates.organizationPathTemplate.render({ + organization: organization, + }); + } + + /** + * Parse the organization from Organization resource. + * + * @param {string} organizationName + * A fully-qualified path representing Organization resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationName(organizationName: string) { + return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified tagBinding resource name string. + * + * @param {string} tag_binding + * @returns {string} Resource name string. + */ + tagBindingPath(tagBinding:string) { + return this.pathTemplates.tagBindingPathTemplate.render({ + tag_binding: tagBinding, + }); + } + + /** + * Parse the tag_binding from TagBinding resource. + * + * @param {string} tagBindingName + * A fully-qualified path representing TagBinding resource. + * @returns {string} A string representing the tag_binding. + */ + matchTagBindingFromTagBindingName(tagBindingName: string) { + return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; + } + + /** + * Return a fully-qualified tagHold resource name string. + * + * @param {string} tag_value + * @param {string} tag_hold + * @returns {string} Resource name string. + */ + tagHoldPath(tagValue:string,tagHold:string) { + return this.pathTemplates.tagHoldPathTemplate.render({ + tag_value: tagValue, + tag_hold: tagHold, + }); + } + + /** + * Parse the tag_value from TagHold resource. + * + * @param {string} tagHoldName + * A fully-qualified path representing TagHold resource. + * @returns {string} A string representing the tag_value. + */ + matchTagValueFromTagHoldName(tagHoldName: string) { + return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_value; + } + + /** + * Parse the tag_hold from TagHold resource. + * + * @param {string} tagHoldName + * A fully-qualified path representing TagHold resource. + * @returns {string} A string representing the tag_hold. + */ + matchTagHoldFromTagHoldName(tagHoldName: string) { + return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_hold; + } + + /** + * Return a fully-qualified tagKey resource name string. + * + * @param {string} tag_key + * @returns {string} Resource name string. + */ + tagKeyPath(tagKey:string) { + return this.pathTemplates.tagKeyPathTemplate.render({ + tag_key: tagKey, + }); + } + + /** + * Parse the tag_key from TagKey resource. + * + * @param {string} tagKeyName + * A fully-qualified path representing TagKey resource. + * @returns {string} A string representing the tag_key. + */ + matchTagKeyFromTagKeyName(tagKeyName: string) { + return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; + } + + /** + * Return a fully-qualified tagValue resource name string. + * + * @param {string} tag_value + * @returns {string} Resource name string. + */ + tagValuePath(tagValue:string) { + return this.pathTemplates.tagValuePathTemplate.render({ + tag_value: tagValue, + }); + } + + /** + * Parse the tag_value from TagValue resource. + * + * @param {string} tagValueName + * A fully-qualified path representing TagValue resource. + * @returns {string} A string representing the tag_value. + */ + matchTagValueFromTagValueName(tagValueName: string) { + return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; + } + + /** + * 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.tagBindingsStub && !this._terminated) { + return this.tagBindingsStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_client_config.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_client_config.json new file mode 100644 index 00000000000..5a1182f0c9e --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_client_config.json @@ -0,0 +1,48 @@ +{ + "interfaces": { + "google.cloud.resourcemanager.v3.TagBindings": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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": { + "ListTagBindings": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "CreateTagBinding": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteTagBinding": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListEffectiveTags": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_proto_list.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_proto_list.json new file mode 100644 index 00000000000..639794aadd4 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/cloud/resourcemanager/v3/folders.proto", + "../../protos/google/cloud/resourcemanager/v3/organizations.proto", + "../../protos/google/cloud/resourcemanager/v3/projects.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_holds.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" +] diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_client.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_client.ts new file mode 100644 index 00000000000..02f1c57ffe3 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_client.ts @@ -0,0 +1,1143 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v3/tag_holds_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './tag_holds_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Allow users to create and manage TagHolds for TagValues. TagHolds represent + * the use of a Tag Value that is not captured by TagBindings but + * should still block TagValue deletion (such as a reference in a policy + * condition). This service provides isolated failure domains by cloud location + * so that TagHolds can be managed in the same location as their usage. + * @class + * @memberof v3 + */ +export class TagHoldsClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + tagHoldsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of TagHoldsClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 TagHoldsClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof TagHoldsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + folderPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}' + ), + organizationPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + tagBindingPathTemplate: new this._gaxModule.PathTemplate( + 'tagBindings/{tag_binding}' + ), + tagHoldPathTemplate: new this._gaxModule.PathTemplate( + 'tagValues/{tag_value}/tagHolds/{tag_hold}' + ), + tagKeyPathTemplate: new this._gaxModule.PathTemplate( + 'tagKeys/{tag_key}' + ), + tagValuePathTemplate: new this._gaxModule.PathTemplate( + 'tagValues/{tag_value}' + ), + }; + + // 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 = { + listTagHolds: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tagHolds') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v3/{name=operations/**}',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createTagHoldResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.TagHold') as gax.protobuf.Type; + const createTagHoldMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.CreateTagHoldMetadata') as gax.protobuf.Type; + const deleteTagHoldResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteTagHoldMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.DeleteTagHoldMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createTagHold: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createTagHoldResponse.decode.bind(createTagHoldResponse), + createTagHoldMetadata.decode.bind(createTagHoldMetadata)), + deleteTagHold: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteTagHoldResponse.decode.bind(deleteTagHoldResponse), + deleteTagHoldMetadata.decode.bind(deleteTagHoldMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.resourcemanager.v3.TagHolds', 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.tagHoldsStub) { + return this.tagHoldsStub; + } + + // Put together the "service stub" for + // google.cloud.resourcemanager.v3.TagHolds. + this.tagHoldsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.TagHolds') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.resourcemanager.v3.TagHolds, + 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 tagHoldsStubMethods = + ['createTagHold', 'deleteTagHold', 'listTagHolds']; + for (const methodName of tagHoldsStubMethods) { + const callPromise = this.tagHoldsStub.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.tagHoldsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudresourcemanager.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 'cloudresourcemanager.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only' + ]; + } + + 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 TagHold. Returns ALREADY_EXISTS if a TagHold with the same + * resource and origin exists under the same TagValue. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the TagHold's parent TagValue. Must be of + * the form: `tagValues/{tag-value-id}`. + * @param {google.cloud.resourcemanager.v3.TagHold} request.tagHold + * Required. The TagHold to be created. + * @param {boolean} [request.validateOnly] + * Optional. Set to true to perform the validations necessary for creating the + * resource, but not actually perform the action. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_holds.create_tag_hold.js + * region_tag:cloudresourcemanager_v3_generated_TagHolds_CreateTagHold_async + */ + createTagHold( + request?: protos.google.cloud.resourcemanager.v3.ICreateTagHoldRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createTagHold( + request: protos.google.cloud.resourcemanager.v3.ICreateTagHoldRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createTagHold( + request: protos.google.cloud.resourcemanager.v3.ICreateTagHoldRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createTagHold( + request?: protos.google.cloud.resourcemanager.v3.ICreateTagHoldRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createTagHold(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createTagHold()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_holds.create_tag_hold.js + * region_tag:cloudresourcemanager_v3_generated_TagHolds_CreateTagHold_async + */ + async checkCreateTagHoldProgress(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.createTagHold, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a TagHold. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the TagHold to delete. Must be of the form: + * `tagValues/{tag-value-id}/tagHolds/{tag-hold-id}`. + * @param {boolean} [request.validateOnly] + * Optional. Set to true to perform the validations necessary for deleting the + * resource, but not actually perform the action. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_holds.delete_tag_hold.js + * region_tag:cloudresourcemanager_v3_generated_TagHolds_DeleteTagHold_async + */ + deleteTagHold( + request?: protos.google.cloud.resourcemanager.v3.IDeleteTagHoldRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteTagHold( + request: protos.google.cloud.resourcemanager.v3.IDeleteTagHoldRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteTagHold( + request: protos.google.cloud.resourcemanager.v3.IDeleteTagHoldRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteTagHold( + request?: protos.google.cloud.resourcemanager.v3.IDeleteTagHoldRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteTagHold(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteTagHold()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_holds.delete_tag_hold.js + * region_tag:cloudresourcemanager_v3_generated_TagHolds_DeleteTagHold_async + */ + async checkDeleteTagHoldProgress(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.deleteTagHold, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists TagHolds under a TagValue. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the parent TagValue. Must be of the form: + * `tagValues/{tag-value-id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of TagHolds to return in the response. The + * server allows a maximum of 300 TagHolds to return. If unspecified, the + * server will use 100 as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * `ListTagHolds` that indicates where this listing should continue from. + * @param {string} [request.filter] + * Optional. Criteria used to select a subset of TagHolds parented by the + * TagValue to return. This field follows the syntax defined by aip.dev/160; + * the `holder` and `origin` fields are supported for filtering. Currently + * only `AND` syntax is supported. Some example queries are: + * + * * `holder = + * //compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group` + * * `origin = 35678234` + * * `holder = + * //compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group + * AND origin = 35678234` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.resourcemanager.v3.TagHold|TagHold}. + * 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 `listTagHoldsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listTagHolds( + request?: protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagHold[], + protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest|null, + protos.google.cloud.resourcemanager.v3.IListTagHoldsResponse + ]>; + listTagHolds( + request: protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest, + protos.google.cloud.resourcemanager.v3.IListTagHoldsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagHold>): void; + listTagHolds( + request: protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest, + protos.google.cloud.resourcemanager.v3.IListTagHoldsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagHold>): void; + listTagHolds( + request?: protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest, + protos.google.cloud.resourcemanager.v3.IListTagHoldsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagHold>, + callback?: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest, + protos.google.cloud.resourcemanager.v3.IListTagHoldsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagHold>): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagHold[], + protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest|null, + protos.google.cloud.resourcemanager.v3.IListTagHoldsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listTagHolds(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the parent TagValue. Must be of the form: + * `tagValues/{tag-value-id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of TagHolds to return in the response. The + * server allows a maximum of 300 TagHolds to return. If unspecified, the + * server will use 100 as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * `ListTagHolds` that indicates where this listing should continue from. + * @param {string} [request.filter] + * Optional. Criteria used to select a subset of TagHolds parented by the + * TagValue to return. This field follows the syntax defined by aip.dev/160; + * the `holder` and `origin` fields are supported for filtering. Currently + * only `AND` syntax is supported. Some example queries are: + * + * * `holder = + * //compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group` + * * `origin = 35678234` + * * `holder = + * //compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group + * AND origin = 35678234` + * @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 protos.google.cloud.resourcemanager.v3.TagHold|TagHold} 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 `listTagHoldsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listTagHoldsStream( + request?: protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest, + 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['listTagHolds']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTagHolds.createStream( + this.innerApiCalls.listTagHolds as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listTagHolds`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the parent TagValue. Must be of the form: + * `tagValues/{tag-value-id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of TagHolds to return in the response. The + * server allows a maximum of 300 TagHolds to return. If unspecified, the + * server will use 100 as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * `ListTagHolds` that indicates where this listing should continue from. + * @param {string} [request.filter] + * Optional. Criteria used to select a subset of TagHolds parented by the + * TagValue to return. This field follows the syntax defined by aip.dev/160; + * the `holder` and `origin` fields are supported for filtering. Currently + * only `AND` syntax is supported. Some example queries are: + * + * * `holder = + * //compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group` + * * `origin = 35678234` + * * `holder = + * //compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group + * AND origin = 35678234` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.resourcemanager.v3.TagHold|TagHold}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_holds.list_tag_holds.js + * region_tag:cloudresourcemanager_v3_generated_TagHolds_ListTagHolds_async + */ + listTagHoldsAsync( + request?: protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest, + 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['listTagHolds']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTagHolds.asyncIterate( + this.innerApiCalls['listTagHolds'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * 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 folder resource name string. + * + * @param {string} folder + * @returns {string} Resource name string. + */ + folderPath(folder:string) { + return this.pathTemplates.folderPathTemplate.render({ + folder: folder, + }); + } + + /** + * Parse the folder from Folder resource. + * + * @param {string} folderName + * A fully-qualified path representing Folder resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderName(folderName: string) { + return this.pathTemplates.folderPathTemplate.match(folderName).folder; + } + + /** + * Return a fully-qualified organization resource name string. + * + * @param {string} organization + * @returns {string} Resource name string. + */ + organizationPath(organization:string) { + return this.pathTemplates.organizationPathTemplate.render({ + organization: organization, + }); + } + + /** + * Parse the organization from Organization resource. + * + * @param {string} organizationName + * A fully-qualified path representing Organization resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationName(organizationName: string) { + return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified tagBinding resource name string. + * + * @param {string} tag_binding + * @returns {string} Resource name string. + */ + tagBindingPath(tagBinding:string) { + return this.pathTemplates.tagBindingPathTemplate.render({ + tag_binding: tagBinding, + }); + } + + /** + * Parse the tag_binding from TagBinding resource. + * + * @param {string} tagBindingName + * A fully-qualified path representing TagBinding resource. + * @returns {string} A string representing the tag_binding. + */ + matchTagBindingFromTagBindingName(tagBindingName: string) { + return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; + } + + /** + * Return a fully-qualified tagHold resource name string. + * + * @param {string} tag_value + * @param {string} tag_hold + * @returns {string} Resource name string. + */ + tagHoldPath(tagValue:string,tagHold:string) { + return this.pathTemplates.tagHoldPathTemplate.render({ + tag_value: tagValue, + tag_hold: tagHold, + }); + } + + /** + * Parse the tag_value from TagHold resource. + * + * @param {string} tagHoldName + * A fully-qualified path representing TagHold resource. + * @returns {string} A string representing the tag_value. + */ + matchTagValueFromTagHoldName(tagHoldName: string) { + return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_value; + } + + /** + * Parse the tag_hold from TagHold resource. + * + * @param {string} tagHoldName + * A fully-qualified path representing TagHold resource. + * @returns {string} A string representing the tag_hold. + */ + matchTagHoldFromTagHoldName(tagHoldName: string) { + return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_hold; + } + + /** + * Return a fully-qualified tagKey resource name string. + * + * @param {string} tag_key + * @returns {string} Resource name string. + */ + tagKeyPath(tagKey:string) { + return this.pathTemplates.tagKeyPathTemplate.render({ + tag_key: tagKey, + }); + } + + /** + * Parse the tag_key from TagKey resource. + * + * @param {string} tagKeyName + * A fully-qualified path representing TagKey resource. + * @returns {string} A string representing the tag_key. + */ + matchTagKeyFromTagKeyName(tagKeyName: string) { + return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; + } + + /** + * Return a fully-qualified tagValue resource name string. + * + * @param {string} tag_value + * @returns {string} Resource name string. + */ + tagValuePath(tagValue:string) { + return this.pathTemplates.tagValuePathTemplate.render({ + tag_value: tagValue, + }); + } + + /** + * Parse the tag_value from TagValue resource. + * + * @param {string} tagValueName + * A fully-qualified path representing TagValue resource. + * @returns {string} A string representing the tag_value. + */ + matchTagValueFromTagValueName(tagValueName: string) { + return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; + } + + /** + * 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.tagHoldsStub && !this._terminated) { + return this.tagHoldsStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_client_config.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_client_config.json new file mode 100644 index 00000000000..5b42806f40b --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_client_config.json @@ -0,0 +1,38 @@ +{ + "interfaces": { + "google.cloud.resourcemanager.v3.TagHolds": { + "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": { + "CreateTagHold": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteTagHold": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListTagHolds": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_proto_list.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_proto_list.json new file mode 100644 index 00000000000..639794aadd4 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/cloud/resourcemanager/v3/folders.proto", + "../../protos/google/cloud/resourcemanager/v3/organizations.proto", + "../../protos/google/cloud/resourcemanager/v3/projects.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_holds.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" +] diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_client.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_client.ts new file mode 100644 index 00000000000..608c4d49b76 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_client.ts @@ -0,0 +1,1585 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v3/tag_keys_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './tag_keys_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Allow users to create and manage tag keys. + * @class + * @memberof v3 + */ +export class TagKeysClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + tagKeysStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of TagKeysClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 TagKeysClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof TagKeysClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + folderPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}' + ), + organizationPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + tagBindingPathTemplate: new this._gaxModule.PathTemplate( + 'tagBindings/{tag_binding}' + ), + tagHoldPathTemplate: new this._gaxModule.PathTemplate( + 'tagValues/{tag_value}/tagHolds/{tag_hold}' + ), + tagKeyPathTemplate: new this._gaxModule.PathTemplate( + 'tagKeys/{tag_key}' + ), + tagValuePathTemplate: new this._gaxModule.PathTemplate( + 'tagValues/{tag_value}' + ), + }; + + // 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 = { + listTagKeys: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tagKeys') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v3/{name=operations/**}',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createTagKeyResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.TagKey') as gax.protobuf.Type; + const createTagKeyMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.CreateTagKeyMetadata') as gax.protobuf.Type; + const updateTagKeyResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.TagKey') as gax.protobuf.Type; + const updateTagKeyMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.UpdateTagKeyMetadata') as gax.protobuf.Type; + const deleteTagKeyResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.TagKey') as gax.protobuf.Type; + const deleteTagKeyMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.DeleteTagKeyMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createTagKey: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createTagKeyResponse.decode.bind(createTagKeyResponse), + createTagKeyMetadata.decode.bind(createTagKeyMetadata)), + updateTagKey: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateTagKeyResponse.decode.bind(updateTagKeyResponse), + updateTagKeyMetadata.decode.bind(updateTagKeyMetadata)), + deleteTagKey: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteTagKeyResponse.decode.bind(deleteTagKeyResponse), + deleteTagKeyMetadata.decode.bind(deleteTagKeyMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.resourcemanager.v3.TagKeys', 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.tagKeysStub) { + return this.tagKeysStub; + } + + // Put together the "service stub" for + // google.cloud.resourcemanager.v3.TagKeys. + this.tagKeysStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.TagKeys') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.resourcemanager.v3.TagKeys, + 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 tagKeysStubMethods = + ['listTagKeys', 'getTagKey', 'getNamespacedTagKey', 'createTagKey', 'updateTagKey', 'deleteTagKey', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of tagKeysStubMethods) { + const callPromise = this.tagKeysStub.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.tagKeysStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudresourcemanager.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 'cloudresourcemanager.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only' + ]; + } + + 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 -- + // ------------------- +/** + * Retrieves a TagKey. This method will return `PERMISSION_DENIED` if the + * key does not exist or the user does not have permission to view it. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A resource name in the format `tagKeys/{id}`, such as + * `tagKeys/123`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.resourcemanager.v3.TagKey|TagKey}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_keys.get_tag_key.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_GetTagKey_async + */ + getTagKey( + request?: protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagKey, + protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|undefined, {}|undefined + ]>; + getTagKey( + request: protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.resourcemanager.v3.ITagKey, + protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|null|undefined, + {}|null|undefined>): void; + getTagKey( + request: protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest, + callback: Callback< + protos.google.cloud.resourcemanager.v3.ITagKey, + protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|null|undefined, + {}|null|undefined>): void; + getTagKey( + request?: protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.resourcemanager.v3.ITagKey, + protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.resourcemanager.v3.ITagKey, + protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagKey, + protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getTagKey(request, options, callback); + } +/** + * Retrieves a TagKey by its namespaced name. + * This method will return `PERMISSION_DENIED` if the key does not exist + * or the user does not have permission to view it. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A namespaced tag key name in the format + * `{parentId}/{tagKeyShort}`, such as `42/foo` for a key with short name + * "foo" under the organization with ID 42 or `r2-d2/bar` for a key with short + * name "bar" under the project `r2-d2`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.resourcemanager.v3.TagKey|TagKey}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_keys.get_namespaced_tag_key.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_GetNamespacedTagKey_async + */ + getNamespacedTagKey( + request?: protos.google.cloud.resourcemanager.v3.IGetNamespacedTagKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagKey, + protos.google.cloud.resourcemanager.v3.IGetNamespacedTagKeyRequest|undefined, {}|undefined + ]>; + getNamespacedTagKey( + request: protos.google.cloud.resourcemanager.v3.IGetNamespacedTagKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.resourcemanager.v3.ITagKey, + protos.google.cloud.resourcemanager.v3.IGetNamespacedTagKeyRequest|null|undefined, + {}|null|undefined>): void; + getNamespacedTagKey( + request: protos.google.cloud.resourcemanager.v3.IGetNamespacedTagKeyRequest, + callback: Callback< + protos.google.cloud.resourcemanager.v3.ITagKey, + protos.google.cloud.resourcemanager.v3.IGetNamespacedTagKeyRequest|null|undefined, + {}|null|undefined>): void; + getNamespacedTagKey( + request?: protos.google.cloud.resourcemanager.v3.IGetNamespacedTagKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.resourcemanager.v3.ITagKey, + protos.google.cloud.resourcemanager.v3.IGetNamespacedTagKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.resourcemanager.v3.ITagKey, + protos.google.cloud.resourcemanager.v3.IGetNamespacedTagKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagKey, + protos.google.cloud.resourcemanager.v3.IGetNamespacedTagKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.getNamespacedTagKey(request, options, callback); + } +/** + * Gets the access control policy for a TagKey. The returned policy may be + * empty if no such policy or resource exists. The `resource` field should + * be the TagKey's resource name. For example, "tagKeys/1234". + * The caller must have + * `cloudresourcemanager.googleapis.com/tagKeys.getIamPolicy` permission on + * the specified TagKey. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_keys.get_iam_policy.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Sets the access control policy on a TagKey, replacing any existing + * policy. The `resource` field should be the TagKey's resource name. + * For example, "tagKeys/1234". + * The caller must have `resourcemanager.tagKeys.setIamPolicy` permission + * on the identified tagValue. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_keys.set_iam_policy.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified TagKey. + * The `resource` field should be the TagKey's resource name. + * For example, "tagKeys/1234". + * + * There are no permissions required for making this API call. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_keys.test_iam_permissions.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + +/** + * Creates a new TagKey. If another request with the same parameters is + * sent while the original request is in process, the second request + * will receive an error. A maximum of 1000 TagKeys can exist under a parent + * at any given time. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.resourcemanager.v3.TagKey} request.tagKey + * Required. The TagKey to be created. Only fields `short_name`, + * `description`, and `parent` are considered during the creation request. + * @param {boolean} [request.validateOnly] + * Optional. Set to true to perform validations necessary for creating the + * resource, but not actually perform the action. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_keys.create_tag_key.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_CreateTagKey_async + */ + createTagKey( + request?: protos.google.cloud.resourcemanager.v3.ICreateTagKeyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createTagKey( + request: protos.google.cloud.resourcemanager.v3.ICreateTagKeyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createTagKey( + request: protos.google.cloud.resourcemanager.v3.ICreateTagKeyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createTagKey( + request?: protos.google.cloud.resourcemanager.v3.ICreateTagKeyRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.createTagKey(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createTagKey()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_keys.create_tag_key.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_CreateTagKey_async + */ + async checkCreateTagKeyProgress(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.createTagKey, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the attributes of the TagKey resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.resourcemanager.v3.TagKey} request.tagKey + * Required. The new definition of the TagKey. Only the `description` and + * `etag` fields can be updated by this request. If the `etag` field is not + * empty, it must match the `etag` field of the existing tag key. Otherwise, + * `ABORTED` will be returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Fields to be updated. The mask may only contain `description` or + * `etag`. If omitted entirely, both `description` and `etag` are assumed to + * be significant. + * @param {boolean} request.validateOnly + * Set as true to perform validations necessary for updating the resource, but + * not actually perform the action. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_keys.update_tag_key.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_UpdateTagKey_async + */ + updateTagKey( + request?: protos.google.cloud.resourcemanager.v3.IUpdateTagKeyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateTagKey( + request: protos.google.cloud.resourcemanager.v3.IUpdateTagKeyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateTagKey( + request: protos.google.cloud.resourcemanager.v3.IUpdateTagKeyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateTagKey( + request?: protos.google.cloud.resourcemanager.v3.IUpdateTagKeyRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'tag_key.name': request.tagKey!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateTagKey(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateTagKey()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_keys.update_tag_key.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_UpdateTagKey_async + */ + async checkUpdateTagKeyProgress(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.updateTagKey, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a TagKey. The TagKey cannot be deleted if it has any child + * TagValues. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of a TagKey to be deleted in the format + * `tagKeys/123`. The TagKey cannot be a parent of any existing TagValues or + * it will not be deleted successfully. + * @param {boolean} [request.validateOnly] + * Optional. Set as true to perform validations necessary for deletion, but + * not actually perform the action. + * @param {string} [request.etag] + * Optional. The etag known to the client for the expected state of the + * TagKey. This is to be used for optimistic concurrency. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_keys.delete_tag_key.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_DeleteTagKey_async + */ + deleteTagKey( + request?: protos.google.cloud.resourcemanager.v3.IDeleteTagKeyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteTagKey( + request: protos.google.cloud.resourcemanager.v3.IDeleteTagKeyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteTagKey( + request: protos.google.cloud.resourcemanager.v3.IDeleteTagKeyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteTagKey( + request?: protos.google.cloud.resourcemanager.v3.IDeleteTagKeyRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteTagKey(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteTagKey()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_keys.delete_tag_key.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_DeleteTagKey_async + */ + async checkDeleteTagKeyProgress(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.deleteTagKey, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists all TagKeys for a parent resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the TagKey's parent. + * Must be of the form `organizations/{org_id}` or `projects/{project_id}` or + * `projects/{project_number}` + * @param {number} [request.pageSize] + * Optional. The maximum number of TagKeys to return in the response. The + * server allows a maximum of 300 TagKeys to return. If unspecified, the + * server will use 100 as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `ListTagKey` + * that indicates where this listing should continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.resourcemanager.v3.TagKey|TagKey}. + * 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 `listTagKeysAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listTagKeys( + request?: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagKey[], + protos.google.cloud.resourcemanager.v3.IListTagKeysRequest|null, + protos.google.cloud.resourcemanager.v3.IListTagKeysResponse + ]>; + listTagKeys( + request: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, + protos.google.cloud.resourcemanager.v3.IListTagKeysResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagKey>): void; + listTagKeys( + request: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, + protos.google.cloud.resourcemanager.v3.IListTagKeysResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagKey>): void; + listTagKeys( + request?: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, + protos.google.cloud.resourcemanager.v3.IListTagKeysResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagKey>, + callback?: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, + protos.google.cloud.resourcemanager.v3.IListTagKeysResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagKey>): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagKey[], + protos.google.cloud.resourcemanager.v3.IListTagKeysRequest|null, + protos.google.cloud.resourcemanager.v3.IListTagKeysResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.listTagKeys(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the TagKey's parent. + * Must be of the form `organizations/{org_id}` or `projects/{project_id}` or + * `projects/{project_number}` + * @param {number} [request.pageSize] + * Optional. The maximum number of TagKeys to return in the response. The + * server allows a maximum of 300 TagKeys to return. If unspecified, the + * server will use 100 as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `ListTagKey` + * that indicates where this listing should continue from. + * @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 protos.google.cloud.resourcemanager.v3.TagKey|TagKey} 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 `listTagKeysAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listTagKeysStream( + request?: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listTagKeys']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTagKeys.createStream( + this.innerApiCalls.listTagKeys as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listTagKeys`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the TagKey's parent. + * Must be of the form `organizations/{org_id}` or `projects/{project_id}` or + * `projects/{project_number}` + * @param {number} [request.pageSize] + * Optional. The maximum number of TagKeys to return in the response. The + * server allows a maximum of 300 TagKeys to return. If unspecified, the + * server will use 100 as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `ListTagKey` + * that indicates where this listing should continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.resourcemanager.v3.TagKey|TagKey}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_keys.list_tag_keys.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_ListTagKeys_async + */ + listTagKeysAsync( + request?: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listTagKeys']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTagKeys.asyncIterate( + this.innerApiCalls['listTagKeys'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * 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 folder resource name string. + * + * @param {string} folder + * @returns {string} Resource name string. + */ + folderPath(folder:string) { + return this.pathTemplates.folderPathTemplate.render({ + folder: folder, + }); + } + + /** + * Parse the folder from Folder resource. + * + * @param {string} folderName + * A fully-qualified path representing Folder resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderName(folderName: string) { + return this.pathTemplates.folderPathTemplate.match(folderName).folder; + } + + /** + * Return a fully-qualified organization resource name string. + * + * @param {string} organization + * @returns {string} Resource name string. + */ + organizationPath(organization:string) { + return this.pathTemplates.organizationPathTemplate.render({ + organization: organization, + }); + } + + /** + * Parse the organization from Organization resource. + * + * @param {string} organizationName + * A fully-qualified path representing Organization resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationName(organizationName: string) { + return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified tagBinding resource name string. + * + * @param {string} tag_binding + * @returns {string} Resource name string. + */ + tagBindingPath(tagBinding:string) { + return this.pathTemplates.tagBindingPathTemplate.render({ + tag_binding: tagBinding, + }); + } + + /** + * Parse the tag_binding from TagBinding resource. + * + * @param {string} tagBindingName + * A fully-qualified path representing TagBinding resource. + * @returns {string} A string representing the tag_binding. + */ + matchTagBindingFromTagBindingName(tagBindingName: string) { + return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; + } + + /** + * Return a fully-qualified tagHold resource name string. + * + * @param {string} tag_value + * @param {string} tag_hold + * @returns {string} Resource name string. + */ + tagHoldPath(tagValue:string,tagHold:string) { + return this.pathTemplates.tagHoldPathTemplate.render({ + tag_value: tagValue, + tag_hold: tagHold, + }); + } + + /** + * Parse the tag_value from TagHold resource. + * + * @param {string} tagHoldName + * A fully-qualified path representing TagHold resource. + * @returns {string} A string representing the tag_value. + */ + matchTagValueFromTagHoldName(tagHoldName: string) { + return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_value; + } + + /** + * Parse the tag_hold from TagHold resource. + * + * @param {string} tagHoldName + * A fully-qualified path representing TagHold resource. + * @returns {string} A string representing the tag_hold. + */ + matchTagHoldFromTagHoldName(tagHoldName: string) { + return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_hold; + } + + /** + * Return a fully-qualified tagKey resource name string. + * + * @param {string} tag_key + * @returns {string} Resource name string. + */ + tagKeyPath(tagKey:string) { + return this.pathTemplates.tagKeyPathTemplate.render({ + tag_key: tagKey, + }); + } + + /** + * Parse the tag_key from TagKey resource. + * + * @param {string} tagKeyName + * A fully-qualified path representing TagKey resource. + * @returns {string} A string representing the tag_key. + */ + matchTagKeyFromTagKeyName(tagKeyName: string) { + return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; + } + + /** + * Return a fully-qualified tagValue resource name string. + * + * @param {string} tag_value + * @returns {string} Resource name string. + */ + tagValuePath(tagValue:string) { + return this.pathTemplates.tagValuePathTemplate.render({ + tag_value: tagValue, + }); + } + + /** + * Parse the tag_value from TagValue resource. + * + * @param {string} tagValueName + * A fully-qualified path representing TagValue resource. + * @returns {string} A string representing the tag_value. + */ + matchTagValueFromTagValueName(tagValueName: string) { + return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; + } + + /** + * 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.tagKeysStub && !this._terminated) { + return this.tagKeysStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_client_config.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_client_config.json new file mode 100644 index 00000000000..f1e7c83955d --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_client_config.json @@ -0,0 +1,72 @@ +{ + "interfaces": { + "google.cloud.resourcemanager.v3.TagKeys": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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": { + "ListTagKeys": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "GetTagKey": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "GetNamespacedTagKey": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateTagKey": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateTagKey": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteTagKey": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_proto_list.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_proto_list.json new file mode 100644 index 00000000000..639794aadd4 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/cloud/resourcemanager/v3/folders.proto", + "../../protos/google/cloud/resourcemanager/v3/organizations.proto", + "../../protos/google/cloud/resourcemanager/v3/projects.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_holds.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" +] diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_client.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_client.ts new file mode 100644 index 00000000000..9a9220b0702 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_client.ts @@ -0,0 +1,1581 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v3/tag_values_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './tag_values_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Allow users to create and manage tag values. + * @class + * @memberof v3 + */ +export class TagValuesClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + tagValuesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of TagValuesClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 TagValuesClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof TagValuesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + folderPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}' + ), + organizationPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + tagBindingPathTemplate: new this._gaxModule.PathTemplate( + 'tagBindings/{tag_binding}' + ), + tagHoldPathTemplate: new this._gaxModule.PathTemplate( + 'tagValues/{tag_value}/tagHolds/{tag_hold}' + ), + tagKeyPathTemplate: new this._gaxModule.PathTemplate( + 'tagKeys/{tag_key}' + ), + tagValuePathTemplate: new this._gaxModule.PathTemplate( + 'tagValues/{tag_value}' + ), + }; + + // 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 = { + listTagValues: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tagValues') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v3/{name=operations/**}',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createTagValueResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.TagValue') as gax.protobuf.Type; + const createTagValueMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.CreateTagValueMetadata') as gax.protobuf.Type; + const updateTagValueResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.TagValue') as gax.protobuf.Type; + const updateTagValueMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.UpdateTagValueMetadata') as gax.protobuf.Type; + const deleteTagValueResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.TagValue') as gax.protobuf.Type; + const deleteTagValueMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.DeleteTagValueMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createTagValue: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createTagValueResponse.decode.bind(createTagValueResponse), + createTagValueMetadata.decode.bind(createTagValueMetadata)), + updateTagValue: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateTagValueResponse.decode.bind(updateTagValueResponse), + updateTagValueMetadata.decode.bind(updateTagValueMetadata)), + deleteTagValue: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteTagValueResponse.decode.bind(deleteTagValueResponse), + deleteTagValueMetadata.decode.bind(deleteTagValueMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.resourcemanager.v3.TagValues', 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.tagValuesStub) { + return this.tagValuesStub; + } + + // Put together the "service stub" for + // google.cloud.resourcemanager.v3.TagValues. + this.tagValuesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.TagValues') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.resourcemanager.v3.TagValues, + 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 tagValuesStubMethods = + ['listTagValues', 'getTagValue', 'getNamespacedTagValue', 'createTagValue', 'updateTagValue', 'deleteTagValue', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of tagValuesStubMethods) { + const callPromise = this.tagValuesStub.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.tagValuesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudresourcemanager.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 'cloudresourcemanager.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only' + ]; + } + + 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 -- + // ------------------- +/** + * Retrieves a TagValue. This method will return `PERMISSION_DENIED` if the + * value does not exist or the user does not have permission to view it. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name for TagValue to be fetched in the format + * `tagValues/456`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.resourcemanager.v3.TagValue|TagValue}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_values.get_tag_value.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_GetTagValue_async + */ + getTagValue( + request?: protos.google.cloud.resourcemanager.v3.IGetTagValueRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagValue, + protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|undefined, {}|undefined + ]>; + getTagValue( + request: protos.google.cloud.resourcemanager.v3.IGetTagValueRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.resourcemanager.v3.ITagValue, + protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|null|undefined, + {}|null|undefined>): void; + getTagValue( + request: protos.google.cloud.resourcemanager.v3.IGetTagValueRequest, + callback: Callback< + protos.google.cloud.resourcemanager.v3.ITagValue, + protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|null|undefined, + {}|null|undefined>): void; + getTagValue( + request?: protos.google.cloud.resourcemanager.v3.IGetTagValueRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.resourcemanager.v3.ITagValue, + protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.resourcemanager.v3.ITagValue, + protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagValue, + protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getTagValue(request, options, callback); + } +/** + * Retrieves a TagValue by its namespaced name. + * This method will return `PERMISSION_DENIED` if the value does not exist + * or the user does not have permission to view it. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A namespaced tag value name in the following format: + * + * `{parentId}/{tagKeyShort}/{tagValueShort}` + * + * Examples: + * - `42/foo/abc` for a value with short name "abc" under the key with short + * name "foo" under the organization with ID 42 + * - `r2-d2/bar/xyz` for a value with short name "xyz" under the key with + * short name "bar" under the project with ID "r2-d2" + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.resourcemanager.v3.TagValue|TagValue}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_values.get_namespaced_tag_value.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_GetNamespacedTagValue_async + */ + getNamespacedTagValue( + request?: protos.google.cloud.resourcemanager.v3.IGetNamespacedTagValueRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagValue, + protos.google.cloud.resourcemanager.v3.IGetNamespacedTagValueRequest|undefined, {}|undefined + ]>; + getNamespacedTagValue( + request: protos.google.cloud.resourcemanager.v3.IGetNamespacedTagValueRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.resourcemanager.v3.ITagValue, + protos.google.cloud.resourcemanager.v3.IGetNamespacedTagValueRequest|null|undefined, + {}|null|undefined>): void; + getNamespacedTagValue( + request: protos.google.cloud.resourcemanager.v3.IGetNamespacedTagValueRequest, + callback: Callback< + protos.google.cloud.resourcemanager.v3.ITagValue, + protos.google.cloud.resourcemanager.v3.IGetNamespacedTagValueRequest|null|undefined, + {}|null|undefined>): void; + getNamespacedTagValue( + request?: protos.google.cloud.resourcemanager.v3.IGetNamespacedTagValueRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.resourcemanager.v3.ITagValue, + protos.google.cloud.resourcemanager.v3.IGetNamespacedTagValueRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.resourcemanager.v3.ITagValue, + protos.google.cloud.resourcemanager.v3.IGetNamespacedTagValueRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagValue, + protos.google.cloud.resourcemanager.v3.IGetNamespacedTagValueRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.getNamespacedTagValue(request, options, callback); + } +/** + * Gets the access control policy for a TagValue. The returned policy may be + * empty if no such policy or resource exists. The `resource` field should + * be the TagValue's resource name. For example: `tagValues/1234`. + * The caller must have the + * `cloudresourcemanager.googleapis.com/tagValues.getIamPolicy` permission on + * the identified TagValue to get the access control policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_values.get_iam_policy.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Sets the access control policy on a TagValue, replacing any existing + * policy. The `resource` field should be the TagValue's resource name. + * For example: `tagValues/1234`. + * The caller must have `resourcemanager.tagValues.setIamPolicy` permission + * on the identified tagValue. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_values.set_iam_policy.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified TagValue. + * The `resource` field should be the TagValue's resource name. For example: + * `tagValues/1234`. + * + * There are no permissions required for making this API call. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_values.test_iam_permissions.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + +/** + * Creates a TagValue as a child of the specified TagKey. If a another + * request with the same parameters is sent while the original request is in + * process the second request will receive an error. A maximum of 1000 + * TagValues can exist under a TagKey at any given time. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.resourcemanager.v3.TagValue} request.tagValue + * Required. The TagValue to be created. Only fields `short_name`, + * `description`, and `parent` are considered during the creation request. + * @param {boolean} [request.validateOnly] + * Optional. Set as true to perform the validations necessary for creating the + * resource, but not actually perform the action. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_values.create_tag_value.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_CreateTagValue_async + */ + createTagValue( + request?: protos.google.cloud.resourcemanager.v3.ICreateTagValueRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createTagValue( + request: protos.google.cloud.resourcemanager.v3.ICreateTagValueRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createTagValue( + request: protos.google.cloud.resourcemanager.v3.ICreateTagValueRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createTagValue( + request?: protos.google.cloud.resourcemanager.v3.ICreateTagValueRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.createTagValue(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createTagValue()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_values.create_tag_value.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_CreateTagValue_async + */ + async checkCreateTagValueProgress(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.createTagValue, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the attributes of the TagValue resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.resourcemanager.v3.TagValue} request.tagValue + * Required. The new definition of the TagValue. Only fields `description` and + * `etag` fields can be updated by this request. If the `etag` field is + * nonempty, it must match the `etag` field of the existing ControlGroup. + * Otherwise, `ABORTED` will be returned. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Fields to be updated. + * @param {boolean} [request.validateOnly] + * Optional. True to perform validations necessary for updating the resource, + * but not actually perform the action. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_values.update_tag_value.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_UpdateTagValue_async + */ + updateTagValue( + request?: protos.google.cloud.resourcemanager.v3.IUpdateTagValueRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateTagValue( + request: protos.google.cloud.resourcemanager.v3.IUpdateTagValueRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateTagValue( + request: protos.google.cloud.resourcemanager.v3.IUpdateTagValueRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateTagValue( + request?: protos.google.cloud.resourcemanager.v3.IUpdateTagValueRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'tag_value.name': request.tagValue!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateTagValue(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateTagValue()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_values.update_tag_value.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_UpdateTagValue_async + */ + async checkUpdateTagValueProgress(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.updateTagValue, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a TagValue. The TagValue cannot have any bindings when it is + * deleted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name for TagValue to be deleted in the format + * tagValues/456. + * @param {boolean} [request.validateOnly] + * Optional. Set as true to perform the validations necessary for deletion, + * but not actually perform the action. + * @param {string} [request.etag] + * Optional. The etag known to the client for the expected state of the + * TagValue. This is to be used for optimistic concurrency. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_values.delete_tag_value.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_DeleteTagValue_async + */ + deleteTagValue( + request?: protos.google.cloud.resourcemanager.v3.IDeleteTagValueRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteTagValue( + request: protos.google.cloud.resourcemanager.v3.IDeleteTagValueRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteTagValue( + request: protos.google.cloud.resourcemanager.v3.IDeleteTagValueRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteTagValue( + request?: protos.google.cloud.resourcemanager.v3.IDeleteTagValueRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteTagValue(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteTagValue()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_values.delete_tag_value.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_DeleteTagValue_async + */ + async checkDeleteTagValueProgress(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.deleteTagValue, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists all TagValues for a specific TagKey. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. + * @param {number} [request.pageSize] + * Optional. The maximum number of TagValues to return in the response. The + * server allows a maximum of 300 TagValues to return. If unspecified, the + * server will use 100 as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * `ListTagValues` that indicates where this listing should continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.resourcemanager.v3.TagValue|TagValue}. + * 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 `listTagValuesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listTagValues( + request?: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagValue[], + protos.google.cloud.resourcemanager.v3.IListTagValuesRequest|null, + protos.google.cloud.resourcemanager.v3.IListTagValuesResponse + ]>; + listTagValues( + request: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, + protos.google.cloud.resourcemanager.v3.IListTagValuesResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagValue>): void; + listTagValues( + request: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, + protos.google.cloud.resourcemanager.v3.IListTagValuesResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagValue>): void; + listTagValues( + request?: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, + protos.google.cloud.resourcemanager.v3.IListTagValuesResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagValue>, + callback?: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, + protos.google.cloud.resourcemanager.v3.IListTagValuesResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagValue>): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagValue[], + protos.google.cloud.resourcemanager.v3.IListTagValuesRequest|null, + protos.google.cloud.resourcemanager.v3.IListTagValuesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.listTagValues(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. + * @param {number} [request.pageSize] + * Optional. The maximum number of TagValues to return in the response. The + * server allows a maximum of 300 TagValues to return. If unspecified, the + * server will use 100 as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * `ListTagValues` that indicates where this listing should continue from. + * @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 protos.google.cloud.resourcemanager.v3.TagValue|TagValue} 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 `listTagValuesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listTagValuesStream( + request?: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listTagValues']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTagValues.createStream( + this.innerApiCalls.listTagValues as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listTagValues`, 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. + * @param {number} [request.pageSize] + * Optional. The maximum number of TagValues to return in the response. The + * server allows a maximum of 300 TagValues to return. If unspecified, the + * server will use 100 as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to + * `ListTagValues` that indicates where this listing should continue from. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.resourcemanager.v3.TagValue|TagValue}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v3/tag_values.list_tag_values.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_ListTagValues_async + */ + listTagValuesAsync( + request?: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listTagValues']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTagValues.asyncIterate( + this.innerApiCalls['listTagValues'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * 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 folder resource name string. + * + * @param {string} folder + * @returns {string} Resource name string. + */ + folderPath(folder:string) { + return this.pathTemplates.folderPathTemplate.render({ + folder: folder, + }); + } + + /** + * Parse the folder from Folder resource. + * + * @param {string} folderName + * A fully-qualified path representing Folder resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderName(folderName: string) { + return this.pathTemplates.folderPathTemplate.match(folderName).folder; + } + + /** + * Return a fully-qualified organization resource name string. + * + * @param {string} organization + * @returns {string} Resource name string. + */ + organizationPath(organization:string) { + return this.pathTemplates.organizationPathTemplate.render({ + organization: organization, + }); + } + + /** + * Parse the organization from Organization resource. + * + * @param {string} organizationName + * A fully-qualified path representing Organization resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationName(organizationName: string) { + return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified tagBinding resource name string. + * + * @param {string} tag_binding + * @returns {string} Resource name string. + */ + tagBindingPath(tagBinding:string) { + return this.pathTemplates.tagBindingPathTemplate.render({ + tag_binding: tagBinding, + }); + } + + /** + * Parse the tag_binding from TagBinding resource. + * + * @param {string} tagBindingName + * A fully-qualified path representing TagBinding resource. + * @returns {string} A string representing the tag_binding. + */ + matchTagBindingFromTagBindingName(tagBindingName: string) { + return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; + } + + /** + * Return a fully-qualified tagHold resource name string. + * + * @param {string} tag_value + * @param {string} tag_hold + * @returns {string} Resource name string. + */ + tagHoldPath(tagValue:string,tagHold:string) { + return this.pathTemplates.tagHoldPathTemplate.render({ + tag_value: tagValue, + tag_hold: tagHold, + }); + } + + /** + * Parse the tag_value from TagHold resource. + * + * @param {string} tagHoldName + * A fully-qualified path representing TagHold resource. + * @returns {string} A string representing the tag_value. + */ + matchTagValueFromTagHoldName(tagHoldName: string) { + return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_value; + } + + /** + * Parse the tag_hold from TagHold resource. + * + * @param {string} tagHoldName + * A fully-qualified path representing TagHold resource. + * @returns {string} A string representing the tag_hold. + */ + matchTagHoldFromTagHoldName(tagHoldName: string) { + return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_hold; + } + + /** + * Return a fully-qualified tagKey resource name string. + * + * @param {string} tag_key + * @returns {string} Resource name string. + */ + tagKeyPath(tagKey:string) { + return this.pathTemplates.tagKeyPathTemplate.render({ + tag_key: tagKey, + }); + } + + /** + * Parse the tag_key from TagKey resource. + * + * @param {string} tagKeyName + * A fully-qualified path representing TagKey resource. + * @returns {string} A string representing the tag_key. + */ + matchTagKeyFromTagKeyName(tagKeyName: string) { + return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; + } + + /** + * Return a fully-qualified tagValue resource name string. + * + * @param {string} tag_value + * @returns {string} Resource name string. + */ + tagValuePath(tagValue:string) { + return this.pathTemplates.tagValuePathTemplate.render({ + tag_value: tagValue, + }); + } + + /** + * Parse the tag_value from TagValue resource. + * + * @param {string} tagValueName + * A fully-qualified path representing TagValue resource. + * @returns {string} A string representing the tag_value. + */ + matchTagValueFromTagValueName(tagValueName: string) { + return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; + } + + /** + * 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.tagValuesStub && !this._terminated) { + return this.tagValuesStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_client_config.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_client_config.json new file mode 100644 index 00000000000..6ddb1d9c83a --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_client_config.json @@ -0,0 +1,72 @@ +{ + "interfaces": { + "google.cloud.resourcemanager.v3.TagValues": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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": { + "ListTagValues": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "GetTagValue": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "GetNamespacedTagValue": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateTagValue": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateTagValue": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteTagValue": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_proto_list.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_proto_list.json new file mode 100644 index 00000000000..639794aadd4 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/cloud/resourcemanager/v3/folders.proto", + "../../protos/google/cloud/resourcemanager/v3/organizations.proto", + "../../protos/google/cloud/resourcemanager/v3/projects.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_holds.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" +] diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-resourcemanager/v3/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..8ef5ef34b96 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/system-test/fixtures/sample/src/index.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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const resourcemanager = require('@google-cloud/resource-manager'); + +function main() { + const foldersClient = new resourcemanager.FoldersClient(); + const organizationsClient = new resourcemanager.OrganizationsClient(); + const projectsClient = new resourcemanager.ProjectsClient(); + const tagBindingsClient = new resourcemanager.TagBindingsClient(); + const tagHoldsClient = new resourcemanager.TagHoldsClient(); + const tagKeysClient = new resourcemanager.TagKeysClient(); + const tagValuesClient = new resourcemanager.TagValuesClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..47d65a2016d --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/system-test/fixtures/sample/src/index.ts @@ -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. ** + +import {FoldersClient, OrganizationsClient, ProjectsClient, TagBindingsClient, TagHoldsClient, TagKeysClient, TagValuesClient} from '@google-cloud/resource-manager'; + +// check that the client class type name can be used +function doStuffWithFoldersClient(client: FoldersClient) { + client.close(); +} +function doStuffWithOrganizationsClient(client: OrganizationsClient) { + client.close(); +} +function doStuffWithProjectsClient(client: ProjectsClient) { + client.close(); +} +function doStuffWithTagBindingsClient(client: TagBindingsClient) { + client.close(); +} +function doStuffWithTagHoldsClient(client: TagHoldsClient) { + client.close(); +} +function doStuffWithTagKeysClient(client: TagKeysClient) { + client.close(); +} +function doStuffWithTagValuesClient(client: TagValuesClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const foldersClient = new FoldersClient(); + doStuffWithFoldersClient(foldersClient); + // check that the client instance can be created + const organizationsClient = new OrganizationsClient(); + doStuffWithOrganizationsClient(organizationsClient); + // check that the client instance can be created + const projectsClient = new ProjectsClient(); + doStuffWithProjectsClient(projectsClient); + // check that the client instance can be created + const tagBindingsClient = new TagBindingsClient(); + doStuffWithTagBindingsClient(tagBindingsClient); + // check that the client instance can be created + const tagHoldsClient = new TagHoldsClient(); + doStuffWithTagHoldsClient(tagHoldsClient); + // check that the client instance can be created + const tagKeysClient = new TagKeysClient(); + doStuffWithTagKeysClient(tagKeysClient); + // check that the client instance can be created + const tagValuesClient = new TagValuesClient(); + doStuffWithTagValuesClient(tagValuesClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/system-test/install.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/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-resourcemanager/v3/test/gapic_folders_v3.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_folders_v3.ts new file mode 100644 index 00000000000..93aefe82f9a --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_folders_v3.ts @@ -0,0 +1,2205 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 foldersModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v3.FoldersClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = foldersModule.v3.FoldersClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = foldersModule.v3.FoldersClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = foldersModule.v3.FoldersClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new foldersModule.v3.FoldersClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new foldersModule.v3.FoldersClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.foldersStub, undefined); + await client.initialize(); + assert(client.foldersStub); + }); + + it('has close method for the initialized client', done => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.foldersStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.foldersStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new foldersModule.v3.FoldersClient({ + 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 foldersModule.v3.FoldersClient({ + 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('getFolder', () => { + it('invokes getFolder without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetFolderRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetFolderRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.Folder() + ); + client.innerApiCalls.getFolder = stubSimpleCall(expectedResponse); + const [response] = await client.getFolder(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getFolder as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getFolder as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getFolder without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetFolderRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetFolderRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.Folder() + ); + client.innerApiCalls.getFolder = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getFolder( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IFolder|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getFolder as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getFolder as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getFolder with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetFolderRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetFolderRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getFolder = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getFolder(request), expectedError); + const actualRequest = (client.innerApiCalls.getFolder as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getFolder as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getFolder with closed client', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetFolderRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetFolderRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getFolder(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('createFolder', () => { + it('invokes createFolder without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateFolderRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createFolder = stubLongRunningCall(expectedResponse); + const [operation] = await client.createFolder(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes createFolder without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateFolderRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createFolder = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createFolder( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes createFolder with call error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateFolderRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.createFolder = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createFolder(request), expectedError); + }); + + it('invokes createFolder with LRO error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateFolderRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.createFolder = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createFolder(request); + await assert.rejects(operation.promise(), expectedError); + }); + + it('invokes checkCreateFolderProgress without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateFolderProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateFolderProgress with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateFolderProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateFolder', () => { + it('invokes updateFolder without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UpdateFolderRequest() + ); + request.folder ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateFolderRequest', ['folder', 'name']); + request.folder.name = defaultValue1; + const expectedHeaderRequestParams = `folder.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateFolder = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateFolder(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateFolder as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateFolder as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateFolder without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UpdateFolderRequest() + ); + request.folder ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateFolderRequest', ['folder', 'name']); + request.folder.name = defaultValue1; + const expectedHeaderRequestParams = `folder.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateFolder = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateFolder( + request, + (err?: Error|null, + result?: 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.updateFolder as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateFolder as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateFolder with call error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UpdateFolderRequest() + ); + request.folder ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateFolderRequest', ['folder', 'name']); + request.folder.name = defaultValue1; + const expectedHeaderRequestParams = `folder.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateFolder = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateFolder(request), expectedError); + const actualRequest = (client.innerApiCalls.updateFolder as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateFolder as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateFolder with LRO error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UpdateFolderRequest() + ); + request.folder ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateFolderRequest', ['folder', 'name']); + request.folder.name = defaultValue1; + const expectedHeaderRequestParams = `folder.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateFolder = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateFolder(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateFolder as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateFolder as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateFolderProgress without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateFolderProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateFolderProgress with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateFolderProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('moveFolder', () => { + it('invokes moveFolder without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.MoveFolderRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.MoveFolderRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.moveFolder = stubLongRunningCall(expectedResponse); + const [operation] = await client.moveFolder(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.moveFolder as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.moveFolder as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes moveFolder without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.MoveFolderRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.MoveFolderRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.moveFolder = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.moveFolder( + request, + (err?: Error|null, + result?: 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.moveFolder as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.moveFolder as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes moveFolder with call error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.MoveFolderRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.MoveFolderRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.moveFolder = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.moveFolder(request), expectedError); + const actualRequest = (client.innerApiCalls.moveFolder as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.moveFolder as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes moveFolder with LRO error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.MoveFolderRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.MoveFolderRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.moveFolder = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.moveFolder(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.moveFolder as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.moveFolder as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkMoveFolderProgress without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkMoveFolderProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkMoveFolderProgress with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkMoveFolderProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteFolder', () => { + it('invokes deleteFolder without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteFolderRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteFolderRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteFolder = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteFolder(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteFolder as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteFolder as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteFolder without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteFolderRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteFolderRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteFolder = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteFolder( + request, + (err?: Error|null, + result?: 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.deleteFolder as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteFolder as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteFolder with call error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteFolderRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteFolderRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteFolder = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteFolder(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteFolder as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteFolder as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteFolder with LRO error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteFolderRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteFolderRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteFolder = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteFolder(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteFolder as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteFolder as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteFolderProgress without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteFolderProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteFolderProgress with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteFolderProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('undeleteFolder', () => { + it('invokes undeleteFolder without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UndeleteFolderRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UndeleteFolderRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.undeleteFolder = stubLongRunningCall(expectedResponse); + const [operation] = await client.undeleteFolder(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.undeleteFolder as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.undeleteFolder as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes undeleteFolder without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UndeleteFolderRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UndeleteFolderRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.undeleteFolder = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.undeleteFolder( + request, + (err?: Error|null, + result?: 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.undeleteFolder as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.undeleteFolder as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes undeleteFolder with call error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UndeleteFolderRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UndeleteFolderRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.undeleteFolder = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.undeleteFolder(request), expectedError); + const actualRequest = (client.innerApiCalls.undeleteFolder as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.undeleteFolder as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes undeleteFolder with LRO error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UndeleteFolderRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UndeleteFolderRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.undeleteFolder = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.undeleteFolder(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.undeleteFolder as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.undeleteFolder as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUndeleteFolderProgress without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUndeleteFolderProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUndeleteFolderProgress with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUndeleteFolderProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listFolders', () => { + it('invokes listFolders without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListFoldersRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + ]; + client.innerApiCalls.listFolders = stubSimpleCall(expectedResponse); + const [response] = await client.listFolders(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listFolders without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListFoldersRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + ]; + client.innerApiCalls.listFolders = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listFolders( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IFolder[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listFolders with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListFoldersRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.listFolders = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listFolders(request), expectedError); + }); + + it('invokes listFoldersStream without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListFoldersRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + ]; + client.descriptors.page.listFolders.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listFoldersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.Folder[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Folder) => { + 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.listFolders.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listFolders, request)); + }); + + it('invokes listFoldersStream with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListFoldersRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listFolders.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listFoldersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.Folder[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Folder) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listFolders.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listFolders, request)); + }); + + it('uses async iteration with listFolders without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListFoldersRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + ]; + client.descriptors.page.listFolders.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.resourcemanager.v3.IFolder[] = []; + const iterable = client.listFoldersAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listFolders.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listFolders with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListFoldersRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listFolders.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listFoldersAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.resourcemanager.v3.IFolder[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listFolders.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('searchFolders', () => { + it('invokes searchFolders without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + ]; + client.innerApiCalls.searchFolders = stubSimpleCall(expectedResponse); + const [response] = await client.searchFolders(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes searchFolders without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + ]; + client.innerApiCalls.searchFolders = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchFolders( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IFolder[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes searchFolders with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.searchFolders = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.searchFolders(request), expectedError); + }); + + it('invokes searchFoldersStream without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + ]; + client.descriptors.page.searchFolders.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.searchFoldersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.Folder[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Folder) => { + 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.searchFolders.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchFolders, request)); + }); + + it('invokes searchFoldersStream with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.searchFolders.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.searchFoldersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.Folder[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Folder) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.searchFolders.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchFolders, request)); + }); + + it('uses async iteration with searchFolders without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + ]; + client.descriptors.page.searchFolders.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.resourcemanager.v3.IFolder[] = []; + const iterable = client.searchFoldersAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.searchFolders.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with searchFolders with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.searchFolders.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchFoldersAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.resourcemanager.v3.IFolder[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.searchFolders.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + 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 foldersModule.v3.FoldersClient({ + 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 foldersModule.v3.FoldersClient({ + 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 foldersModule.v3.FoldersClient({ + 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 foldersModule.v3.FoldersClient({ + 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 foldersModule.v3.FoldersClient({ + 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 foldersModule.v3.FoldersClient({ + 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 foldersModule.v3.FoldersClient({ + 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 foldersModule.v3.FoldersClient({ + 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 foldersModule.v3.FoldersClient({ + 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 foldersModule.v3.FoldersClient({ + 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('folder', () => { + const fakePath = "/rendered/path/folder"; + const expectedParameters = { + folder: "folderValue", + }; + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderPath', () => { + const result = client.folderPath("folderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderName', () => { + const result = client.matchFolderFromFolderName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organization', () => { + const fakePath = "/rendered/path/organization"; + const expectedParameters = { + organization: "organizationValue", + }; + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationPath', () => { + const result = client.organizationPath("organizationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationName', () => { + const result = client.matchOrganizationFromOrganizationName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagBinding', () => { + const fakePath = "/rendered/path/tagBinding"; + const expectedParameters = { + tag_binding: "tagBindingValue", + }; + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagBindingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagBindingPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagBindingPath', () => { + const result = client.tagBindingPath("tagBindingValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagBindingFromTagBindingName', () => { + const result = client.matchTagBindingFromTagBindingName(fakePath); + assert.strictEqual(result, "tagBindingValue"); + assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagHold', () => { + const fakePath = "/rendered/path/tagHold"; + const expectedParameters = { + tag_value: "tagValueValue", + tag_hold: "tagHoldValue", + }; + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagHoldPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagHoldPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagHoldPath', () => { + const result = client.tagHoldPath("tagValueValue", "tagHoldValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagHoldPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagValueFromTagHoldName', () => { + const result = client.matchTagValueFromTagHoldName(fakePath); + assert.strictEqual(result, "tagValueValue"); + assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchTagHoldFromTagHoldName', () => { + const result = client.matchTagHoldFromTagHoldName(fakePath); + assert.strictEqual(result, "tagHoldValue"); + assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagKey', () => { + const fakePath = "/rendered/path/tagKey"; + const expectedParameters = { + tag_key: "tagKeyValue", + }; + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagKeyPath', () => { + const result = client.tagKeyPath("tagKeyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagKeyFromTagKeyName', () => { + const result = client.matchTagKeyFromTagKeyName(fakePath); + assert.strictEqual(result, "tagKeyValue"); + assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagValue', () => { + const fakePath = "/rendered/path/tagValue"; + const expectedParameters = { + tag_value: "tagValueValue", + }; + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagValuePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagValuePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagValuePath', () => { + const result = client.tagValuePath("tagValueValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagValueFromTagValueName', () => { + const result = client.matchTagValueFromTagValueName(fakePath); + assert.strictEqual(result, "tagValueValue"); + assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_organizations_v3.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_organizations_v3.ts new file mode 100644 index 00000000000..1065ddafdbb --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_organizations_v3.ts @@ -0,0 +1,1025 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 organizationsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +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('v3.OrganizationsClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = organizationsModule.v3.OrganizationsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = organizationsModule.v3.OrganizationsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = organizationsModule.v3.OrganizationsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new organizationsModule.v3.OrganizationsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new organizationsModule.v3.OrganizationsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.organizationsStub, undefined); + await client.initialize(); + assert(client.organizationsStub); + }); + + it('has close method for the initialized client', done => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.organizationsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.organizationsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new organizationsModule.v3.OrganizationsClient({ + 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 organizationsModule.v3.OrganizationsClient({ + 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('getOrganization', () => { + it('invokes getOrganization without error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetOrganizationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetOrganizationRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.Organization() + ); + client.innerApiCalls.getOrganization = stubSimpleCall(expectedResponse); + const [response] = await client.getOrganization(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getOrganization as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getOrganization as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getOrganization without error using callback', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetOrganizationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetOrganizationRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.Organization() + ); + client.innerApiCalls.getOrganization = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getOrganization( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IOrganization|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getOrganization as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getOrganization as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getOrganization with error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetOrganizationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetOrganizationRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getOrganization = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getOrganization(request), expectedError); + const actualRequest = (client.innerApiCalls.getOrganization as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getOrganization as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getOrganization with closed client', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetOrganizationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetOrganizationRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getOrganization(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('searchOrganizations', () => { + it('invokes searchOrganizations without error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + ]; + client.innerApiCalls.searchOrganizations = stubSimpleCall(expectedResponse); + const [response] = await client.searchOrganizations(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes searchOrganizations without error using callback', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + ]; + client.innerApiCalls.searchOrganizations = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchOrganizations( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IOrganization[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes searchOrganizations with error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.searchOrganizations = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.searchOrganizations(request), expectedError); + }); + + it('invokes searchOrganizationsStream without error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + ]; + client.descriptors.page.searchOrganizations.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.searchOrganizationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.Organization[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Organization) => { + 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.searchOrganizations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchOrganizations, request)); + }); + + it('invokes searchOrganizationsStream with error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.searchOrganizations.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.searchOrganizationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.Organization[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Organization) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.searchOrganizations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchOrganizations, request)); + }); + + it('uses async iteration with searchOrganizations without error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + ]; + client.descriptors.page.searchOrganizations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.resourcemanager.v3.IOrganization[] = []; + const iterable = client.searchOrganizationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.searchOrganizations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with searchOrganizations with error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.searchOrganizations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchOrganizationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.resourcemanager.v3.IOrganization[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.searchOrganizations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('folder', () => { + const fakePath = "/rendered/path/folder"; + const expectedParameters = { + folder: "folderValue", + }; + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderPath', () => { + const result = client.folderPath("folderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderName', () => { + const result = client.matchFolderFromFolderName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organization', () => { + const fakePath = "/rendered/path/organization"; + const expectedParameters = { + organization: "organizationValue", + }; + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationPath', () => { + const result = client.organizationPath("organizationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationName', () => { + const result = client.matchOrganizationFromOrganizationName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagBinding', () => { + const fakePath = "/rendered/path/tagBinding"; + const expectedParameters = { + tag_binding: "tagBindingValue", + }; + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagBindingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagBindingPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagBindingPath', () => { + const result = client.tagBindingPath("tagBindingValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagBindingFromTagBindingName', () => { + const result = client.matchTagBindingFromTagBindingName(fakePath); + assert.strictEqual(result, "tagBindingValue"); + assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagHold', () => { + const fakePath = "/rendered/path/tagHold"; + const expectedParameters = { + tag_value: "tagValueValue", + tag_hold: "tagHoldValue", + }; + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagHoldPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagHoldPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagHoldPath', () => { + const result = client.tagHoldPath("tagValueValue", "tagHoldValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagHoldPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagValueFromTagHoldName', () => { + const result = client.matchTagValueFromTagHoldName(fakePath); + assert.strictEqual(result, "tagValueValue"); + assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchTagHoldFromTagHoldName', () => { + const result = client.matchTagHoldFromTagHoldName(fakePath); + assert.strictEqual(result, "tagHoldValue"); + assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagKey', () => { + const fakePath = "/rendered/path/tagKey"; + const expectedParameters = { + tag_key: "tagKeyValue", + }; + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagKeyPath', () => { + const result = client.tagKeyPath("tagKeyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagKeyFromTagKeyName', () => { + const result = client.matchTagKeyFromTagKeyName(fakePath); + assert.strictEqual(result, "tagKeyValue"); + assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagValue', () => { + const fakePath = "/rendered/path/tagValue"; + const expectedParameters = { + tag_value: "tagValueValue", + }; + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagValuePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagValuePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagValuePath', () => { + const result = client.tagValuePath("tagValueValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagValueFromTagValueName', () => { + const result = client.matchTagValueFromTagValueName(fakePath); + assert.strictEqual(result, "tagValueValue"); + assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_projects_v3.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_projects_v3.ts new file mode 100644 index 00000000000..80c78bed6a9 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_projects_v3.ts @@ -0,0 +1,2205 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 projectsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v3.ProjectsClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = projectsModule.v3.ProjectsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = projectsModule.v3.ProjectsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = projectsModule.v3.ProjectsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new projectsModule.v3.ProjectsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new projectsModule.v3.ProjectsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.projectsStub, undefined); + await client.initialize(); + assert(client.projectsStub); + }); + + it('has close method for the initialized client', done => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.projectsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.projectsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new projectsModule.v3.ProjectsClient({ + 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 projectsModule.v3.ProjectsClient({ + 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('getProject', () => { + it('invokes getProject without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetProjectRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.Project() + ); + client.innerApiCalls.getProject = stubSimpleCall(expectedResponse); + const [response] = await client.getProject(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProject as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProject as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProject without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetProjectRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.Project() + ); + client.innerApiCalls.getProject = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProject( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IProject|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProject as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProject as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProject with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetProjectRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProject = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProject(request), expectedError); + const actualRequest = (client.innerApiCalls.getProject as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProject as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProject with closed client', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetProjectRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProject(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('createProject', () => { + it('invokes createProject without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateProjectRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createProject = stubLongRunningCall(expectedResponse); + const [operation] = await client.createProject(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes createProject without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateProjectRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createProject = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProject( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes createProject with call error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateProjectRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.createProject = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createProject(request), expectedError); + }); + + it('invokes createProject with LRO error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateProjectRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.createProject = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createProject(request); + await assert.rejects(operation.promise(), expectedError); + }); + + it('invokes checkCreateProjectProgress without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateProjectProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateProjectProgress with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateProjectProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateProject', () => { + it('invokes updateProject without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UpdateProjectRequest() + ); + request.project ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateProjectRequest', ['project', 'name']); + request.project.name = defaultValue1; + const expectedHeaderRequestParams = `project.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateProject = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateProject(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProject as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProject as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProject without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UpdateProjectRequest() + ); + request.project ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateProjectRequest', ['project', 'name']); + request.project.name = defaultValue1; + const expectedHeaderRequestParams = `project.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateProject = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProject( + request, + (err?: Error|null, + result?: 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.updateProject as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProject as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProject with call error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UpdateProjectRequest() + ); + request.project ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateProjectRequest', ['project', 'name']); + request.project.name = defaultValue1; + const expectedHeaderRequestParams = `project.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProject = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateProject(request), expectedError); + const actualRequest = (client.innerApiCalls.updateProject as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProject as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProject with LRO error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UpdateProjectRequest() + ); + request.project ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateProjectRequest', ['project', 'name']); + request.project.name = defaultValue1; + const expectedHeaderRequestParams = `project.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProject = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateProject(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateProject as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProject as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateProjectProgress without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateProjectProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateProjectProgress with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateProjectProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('moveProject', () => { + it('invokes moveProject without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.MoveProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.MoveProjectRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.moveProject = stubLongRunningCall(expectedResponse); + const [operation] = await client.moveProject(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.moveProject as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.moveProject as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes moveProject without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.MoveProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.MoveProjectRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.moveProject = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.moveProject( + request, + (err?: Error|null, + result?: 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.moveProject as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.moveProject as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes moveProject with call error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.MoveProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.MoveProjectRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.moveProject = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.moveProject(request), expectedError); + const actualRequest = (client.innerApiCalls.moveProject as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.moveProject as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes moveProject with LRO error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.MoveProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.MoveProjectRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.moveProject = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.moveProject(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.moveProject as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.moveProject as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkMoveProjectProgress without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkMoveProjectProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkMoveProjectProgress with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkMoveProjectProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteProject', () => { + it('invokes deleteProject without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteProjectRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteProject = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteProject(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProject as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProject as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProject without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteProjectRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteProject = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProject( + request, + (err?: Error|null, + result?: 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.deleteProject as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProject as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProject with call error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteProjectRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProject = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteProject(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteProject as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProject as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProject with LRO error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteProjectRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProject = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteProject(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteProject as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProject as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteProjectProgress without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteProjectProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteProjectProgress with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteProjectProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('undeleteProject', () => { + it('invokes undeleteProject without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UndeleteProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UndeleteProjectRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.undeleteProject = stubLongRunningCall(expectedResponse); + const [operation] = await client.undeleteProject(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.undeleteProject as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.undeleteProject as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes undeleteProject without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UndeleteProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UndeleteProjectRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.undeleteProject = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.undeleteProject( + request, + (err?: Error|null, + result?: 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.undeleteProject as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.undeleteProject as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes undeleteProject with call error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UndeleteProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UndeleteProjectRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.undeleteProject = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.undeleteProject(request), expectedError); + const actualRequest = (client.innerApiCalls.undeleteProject as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.undeleteProject as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes undeleteProject with LRO error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UndeleteProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UndeleteProjectRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.undeleteProject = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.undeleteProject(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.undeleteProject as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.undeleteProject as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUndeleteProjectProgress without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUndeleteProjectProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUndeleteProjectProgress with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUndeleteProjectProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProjects', () => { + it('invokes listProjects without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListProjectsRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + ]; + client.innerApiCalls.listProjects = stubSimpleCall(expectedResponse); + const [response] = await client.listProjects(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listProjects without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListProjectsRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + ]; + client.innerApiCalls.listProjects = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProjects( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IProject[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listProjects with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListProjectsRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.listProjects = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProjects(request), expectedError); + }); + + it('invokes listProjectsStream without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListProjectsRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + ]; + client.descriptors.page.listProjects.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProjectsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.Project[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Project) => { + 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.listProjects.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProjects, request)); + }); + + it('invokes listProjectsStream with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListProjectsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listProjects.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProjectsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.Project[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Project) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProjects.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProjects, request)); + }); + + it('uses async iteration with listProjects without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListProjectsRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + ]; + client.descriptors.page.listProjects.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.resourcemanager.v3.IProject[] = []; + const iterable = client.listProjectsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProjects.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listProjects with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListProjectsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listProjects.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProjectsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.resourcemanager.v3.IProject[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProjects.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('searchProjects', () => { + it('invokes searchProjects without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + ]; + client.innerApiCalls.searchProjects = stubSimpleCall(expectedResponse); + const [response] = await client.searchProjects(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes searchProjects without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + ]; + client.innerApiCalls.searchProjects = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchProjects( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IProject[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes searchProjects with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.searchProjects = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.searchProjects(request), expectedError); + }); + + it('invokes searchProjectsStream without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + ]; + client.descriptors.page.searchProjects.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.searchProjectsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.Project[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Project) => { + 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.searchProjects.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchProjects, request)); + }); + + it('invokes searchProjectsStream with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.searchProjects.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.searchProjectsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.Project[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Project) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.searchProjects.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchProjects, request)); + }); + + it('uses async iteration with searchProjects without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + ]; + client.descriptors.page.searchProjects.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.resourcemanager.v3.IProject[] = []; + const iterable = client.searchProjectsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.searchProjects.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with searchProjects with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.searchProjects.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchProjectsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.resourcemanager.v3.IProject[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.searchProjects.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + 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 projectsModule.v3.ProjectsClient({ + 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 projectsModule.v3.ProjectsClient({ + 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 projectsModule.v3.ProjectsClient({ + 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 projectsModule.v3.ProjectsClient({ + 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 projectsModule.v3.ProjectsClient({ + 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 projectsModule.v3.ProjectsClient({ + 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 projectsModule.v3.ProjectsClient({ + 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 projectsModule.v3.ProjectsClient({ + 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 projectsModule.v3.ProjectsClient({ + 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 projectsModule.v3.ProjectsClient({ + 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('folder', () => { + const fakePath = "/rendered/path/folder"; + const expectedParameters = { + folder: "folderValue", + }; + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderPath', () => { + const result = client.folderPath("folderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderName', () => { + const result = client.matchFolderFromFolderName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organization', () => { + const fakePath = "/rendered/path/organization"; + const expectedParameters = { + organization: "organizationValue", + }; + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationPath', () => { + const result = client.organizationPath("organizationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationName', () => { + const result = client.matchOrganizationFromOrganizationName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagBinding', () => { + const fakePath = "/rendered/path/tagBinding"; + const expectedParameters = { + tag_binding: "tagBindingValue", + }; + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagBindingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagBindingPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagBindingPath', () => { + const result = client.tagBindingPath("tagBindingValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagBindingFromTagBindingName', () => { + const result = client.matchTagBindingFromTagBindingName(fakePath); + assert.strictEqual(result, "tagBindingValue"); + assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagHold', () => { + const fakePath = "/rendered/path/tagHold"; + const expectedParameters = { + tag_value: "tagValueValue", + tag_hold: "tagHoldValue", + }; + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagHoldPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagHoldPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagHoldPath', () => { + const result = client.tagHoldPath("tagValueValue", "tagHoldValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagHoldPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagValueFromTagHoldName', () => { + const result = client.matchTagValueFromTagHoldName(fakePath); + assert.strictEqual(result, "tagValueValue"); + assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchTagHoldFromTagHoldName', () => { + const result = client.matchTagHoldFromTagHoldName(fakePath); + assert.strictEqual(result, "tagHoldValue"); + assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagKey', () => { + const fakePath = "/rendered/path/tagKey"; + const expectedParameters = { + tag_key: "tagKeyValue", + }; + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagKeyPath', () => { + const result = client.tagKeyPath("tagKeyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagKeyFromTagKeyName', () => { + const result = client.matchTagKeyFromTagKeyName(fakePath); + assert.strictEqual(result, "tagKeyValue"); + assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagValue', () => { + const fakePath = "/rendered/path/tagValue"; + const expectedParameters = { + tag_value: "tagValueValue", + }; + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagValuePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagValuePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagValuePath', () => { + const result = client.tagValuePath("tagValueValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagValueFromTagValueName', () => { + const result = client.matchTagValueFromTagValueName(fakePath); + assert.strictEqual(result, "tagValueValue"); + assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_bindings_v3.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_bindings_v3.ts new file mode 100644 index 00000000000..84289dbd944 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_bindings_v3.ts @@ -0,0 +1,1307 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 tagbindingsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v3.TagBindingsClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = tagbindingsModule.v3.TagBindingsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = tagbindingsModule.v3.TagBindingsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = tagbindingsModule.v3.TagBindingsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new tagbindingsModule.v3.TagBindingsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.tagBindingsStub, undefined); + await client.initialize(); + assert(client.tagBindingsStub); + }); + + it('has close method for the initialized client', done => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.tagBindingsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.tagBindingsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new tagbindingsModule.v3.TagBindingsClient({ + 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 tagbindingsModule.v3.TagBindingsClient({ + 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('createTagBinding', () => { + it('invokes createTagBinding without error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateTagBindingRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createTagBinding = stubLongRunningCall(expectedResponse); + const [operation] = await client.createTagBinding(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes createTagBinding without error using callback', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateTagBindingRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createTagBinding = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createTagBinding( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes createTagBinding with call error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateTagBindingRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.createTagBinding = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createTagBinding(request), expectedError); + }); + + it('invokes createTagBinding with LRO error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateTagBindingRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.createTagBinding = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createTagBinding(request); + await assert.rejects(operation.promise(), expectedError); + }); + + it('invokes checkCreateTagBindingProgress without error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateTagBindingProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateTagBindingProgress with error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateTagBindingProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteTagBinding', () => { + it('invokes deleteTagBinding without error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteTagBindingRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagBindingRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteTagBinding = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteTagBinding(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteTagBinding as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteTagBinding as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteTagBinding without error using callback', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteTagBindingRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagBindingRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteTagBinding = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteTagBinding( + request, + (err?: Error|null, + result?: 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.deleteTagBinding as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteTagBinding as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteTagBinding with call error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteTagBindingRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagBindingRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTagBinding = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteTagBinding(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteTagBinding as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteTagBinding as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteTagBinding with LRO error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteTagBindingRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagBindingRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTagBinding = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteTagBinding(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteTagBinding as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteTagBinding as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteTagBindingProgress without error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteTagBindingProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteTagBindingProgress with error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteTagBindingProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listTagBindings', () => { + it('invokes listTagBindings without error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + ]; + client.innerApiCalls.listTagBindings = stubSimpleCall(expectedResponse); + const [response] = await client.listTagBindings(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listTagBindings without error using callback', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + ]; + client.innerApiCalls.listTagBindings = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTagBindings( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagBinding[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listTagBindings with error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.listTagBindings = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listTagBindings(request), expectedError); + }); + + it('invokes listTagBindingsStream without error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + ]; + client.descriptors.page.listTagBindings.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listTagBindingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.TagBinding[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagBinding) => { + 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.listTagBindings.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTagBindings, request)); + }); + + it('invokes listTagBindingsStream with error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listTagBindings.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listTagBindingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.TagBinding[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagBinding) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listTagBindings.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTagBindings, request)); + }); + + it('uses async iteration with listTagBindings without error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + ]; + client.descriptors.page.listTagBindings.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.resourcemanager.v3.ITagBinding[] = []; + const iterable = client.listTagBindingsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listTagBindings.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listTagBindings with error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listTagBindings.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listTagBindingsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.resourcemanager.v3.ITagBinding[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listTagBindings.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('listEffectiveTags', () => { + it('invokes listEffectiveTags without error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListEffectiveTagsRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), + ]; + client.innerApiCalls.listEffectiveTags = stubSimpleCall(expectedResponse); + const [response] = await client.listEffectiveTags(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listEffectiveTags without error using callback', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListEffectiveTagsRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), + ]; + client.innerApiCalls.listEffectiveTags = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listEffectiveTags( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IEffectiveTag[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listEffectiveTags with error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListEffectiveTagsRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.listEffectiveTags = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listEffectiveTags(request), expectedError); + }); + + it('invokes listEffectiveTagsStream without error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListEffectiveTagsRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), + ]; + client.descriptors.page.listEffectiveTags.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listEffectiveTagsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.EffectiveTag[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.EffectiveTag) => { + 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.listEffectiveTags.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listEffectiveTags, request)); + }); + + it('invokes listEffectiveTagsStream with error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListEffectiveTagsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listEffectiveTags.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listEffectiveTagsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.EffectiveTag[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.EffectiveTag) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listEffectiveTags.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listEffectiveTags, request)); + }); + + it('uses async iteration with listEffectiveTags without error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListEffectiveTagsRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), + ]; + client.descriptors.page.listEffectiveTags.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.resourcemanager.v3.IEffectiveTag[] = []; + const iterable = client.listEffectiveTagsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listEffectiveTags.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listEffectiveTags with error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListEffectiveTagsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listEffectiveTags.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listEffectiveTagsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.resourcemanager.v3.IEffectiveTag[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listEffectiveTags.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + 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 tagbindingsModule.v3.TagBindingsClient({ + 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 tagbindingsModule.v3.TagBindingsClient({ + 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 tagbindingsModule.v3.TagBindingsClient({ + 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 tagbindingsModule.v3.TagBindingsClient({ + 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 tagbindingsModule.v3.TagBindingsClient({ + 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 tagbindingsModule.v3.TagBindingsClient({ + 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 tagbindingsModule.v3.TagBindingsClient({ + 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 tagbindingsModule.v3.TagBindingsClient({ + 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 tagbindingsModule.v3.TagBindingsClient({ + 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 tagbindingsModule.v3.TagBindingsClient({ + 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('folder', () => { + const fakePath = "/rendered/path/folder"; + const expectedParameters = { + folder: "folderValue", + }; + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderPath', () => { + const result = client.folderPath("folderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderName', () => { + const result = client.matchFolderFromFolderName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organization', () => { + const fakePath = "/rendered/path/organization"; + const expectedParameters = { + organization: "organizationValue", + }; + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationPath', () => { + const result = client.organizationPath("organizationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationName', () => { + const result = client.matchOrganizationFromOrganizationName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagBinding', () => { + const fakePath = "/rendered/path/tagBinding"; + const expectedParameters = { + tag_binding: "tagBindingValue", + }; + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagBindingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagBindingPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagBindingPath', () => { + const result = client.tagBindingPath("tagBindingValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagBindingFromTagBindingName', () => { + const result = client.matchTagBindingFromTagBindingName(fakePath); + assert.strictEqual(result, "tagBindingValue"); + assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagHold', () => { + const fakePath = "/rendered/path/tagHold"; + const expectedParameters = { + tag_value: "tagValueValue", + tag_hold: "tagHoldValue", + }; + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagHoldPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagHoldPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagHoldPath', () => { + const result = client.tagHoldPath("tagValueValue", "tagHoldValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagHoldPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagValueFromTagHoldName', () => { + const result = client.matchTagValueFromTagHoldName(fakePath); + assert.strictEqual(result, "tagValueValue"); + assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchTagHoldFromTagHoldName', () => { + const result = client.matchTagHoldFromTagHoldName(fakePath); + assert.strictEqual(result, "tagHoldValue"); + assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagKey', () => { + const fakePath = "/rendered/path/tagKey"; + const expectedParameters = { + tag_key: "tagKeyValue", + }; + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagKeyPath', () => { + const result = client.tagKeyPath("tagKeyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagKeyFromTagKeyName', () => { + const result = client.matchTagKeyFromTagKeyName(fakePath); + assert.strictEqual(result, "tagKeyValue"); + assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagValue', () => { + const fakePath = "/rendered/path/tagValue"; + const expectedParameters = { + tag_value: "tagValueValue", + }; + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagValuePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagValuePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagValuePath', () => { + const result = client.tagValuePath("tagValueValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagValueFromTagValueName', () => { + const result = client.matchTagValueFromTagValueName(fakePath); + assert.strictEqual(result, "tagValueValue"); + assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_holds_v3.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_holds_v3.ts new file mode 100644 index 00000000000..17cf5fd6b5f --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_holds_v3.ts @@ -0,0 +1,1242 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 tagholdsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v3.TagHoldsClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = tagholdsModule.v3.TagHoldsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = tagholdsModule.v3.TagHoldsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = tagholdsModule.v3.TagHoldsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new tagholdsModule.v3.TagHoldsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new tagholdsModule.v3.TagHoldsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.tagHoldsStub, undefined); + await client.initialize(); + assert(client.tagHoldsStub); + }); + + it('has close method for the initialized client', done => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.tagHoldsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.tagHoldsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new tagholdsModule.v3.TagHoldsClient({ + 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 tagholdsModule.v3.TagHoldsClient({ + 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('createTagHold', () => { + it('invokes createTagHold without error', async () => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateTagHoldRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.CreateTagHoldRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createTagHold = stubLongRunningCall(expectedResponse); + const [operation] = await client.createTagHold(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createTagHold as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createTagHold as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createTagHold without error using callback', async () => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateTagHoldRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.CreateTagHoldRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createTagHold = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createTagHold( + request, + (err?: Error|null, + result?: 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.createTagHold as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createTagHold as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createTagHold with call error', async () => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateTagHoldRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.CreateTagHoldRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createTagHold = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createTagHold(request), expectedError); + const actualRequest = (client.innerApiCalls.createTagHold as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createTagHold as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createTagHold with LRO error', async () => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateTagHoldRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.CreateTagHoldRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createTagHold = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createTagHold(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createTagHold as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createTagHold as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateTagHoldProgress without error', async () => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateTagHoldProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateTagHoldProgress with error', async () => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateTagHoldProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteTagHold', () => { + it('invokes deleteTagHold without error', async () => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteTagHoldRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagHoldRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteTagHold = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteTagHold(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteTagHold as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteTagHold as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteTagHold without error using callback', async () => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteTagHoldRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagHoldRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteTagHold = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteTagHold( + request, + (err?: Error|null, + result?: 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.deleteTagHold as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteTagHold as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteTagHold with call error', async () => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteTagHoldRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagHoldRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTagHold = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteTagHold(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteTagHold as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteTagHold as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteTagHold with LRO error', async () => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteTagHoldRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagHoldRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTagHold = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteTagHold(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteTagHold as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteTagHold as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteTagHoldProgress without error', async () => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteTagHoldProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteTagHoldProgress with error', async () => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteTagHoldProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listTagHolds', () => { + it('invokes listTagHolds without error', async () => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagHoldsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.ListTagHoldsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), + ]; + client.innerApiCalls.listTagHolds = stubSimpleCall(expectedResponse); + const [response] = await client.listTagHolds(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listTagHolds as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listTagHolds as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listTagHolds without error using callback', async () => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagHoldsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.ListTagHoldsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), + ]; + client.innerApiCalls.listTagHolds = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTagHolds( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagHold[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listTagHolds as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listTagHolds as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listTagHolds with error', async () => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagHoldsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.ListTagHoldsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listTagHolds = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listTagHolds(request), expectedError); + const actualRequest = (client.innerApiCalls.listTagHolds as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listTagHolds as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listTagHoldsStream without error', async () => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagHoldsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.ListTagHoldsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), + ]; + client.descriptors.page.listTagHolds.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listTagHoldsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.TagHold[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagHold) => { + 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.listTagHolds.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTagHolds, request)); + assert( + (client.descriptors.page.listTagHolds.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listTagHoldsStream with error', async () => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagHoldsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.ListTagHoldsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTagHolds.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listTagHoldsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.TagHold[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagHold) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listTagHolds.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTagHolds, request)); + assert( + (client.descriptors.page.listTagHolds.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listTagHolds without error', async () => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagHoldsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.ListTagHoldsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), + ]; + client.descriptors.page.listTagHolds.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.resourcemanager.v3.ITagHold[] = []; + const iterable = client.listTagHoldsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listTagHolds.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listTagHolds.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listTagHolds with error', async () => { + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagHoldsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.ListTagHoldsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTagHolds.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listTagHoldsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.resourcemanager.v3.ITagHold[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listTagHolds.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listTagHolds.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 tagholdsModule.v3.TagHoldsClient({ + 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 tagholdsModule.v3.TagHoldsClient({ + 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 tagholdsModule.v3.TagHoldsClient({ + 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 tagholdsModule.v3.TagHoldsClient({ + 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 tagholdsModule.v3.TagHoldsClient({ + 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 tagholdsModule.v3.TagHoldsClient({ + 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 tagholdsModule.v3.TagHoldsClient({ + 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 tagholdsModule.v3.TagHoldsClient({ + 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 tagholdsModule.v3.TagHoldsClient({ + 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 tagholdsModule.v3.TagHoldsClient({ + 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 tagholdsModule.v3.TagHoldsClient({ + 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('folder', () => { + const fakePath = "/rendered/path/folder"; + const expectedParameters = { + folder: "folderValue", + }; + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderPath', () => { + const result = client.folderPath("folderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderName', () => { + const result = client.matchFolderFromFolderName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organization', () => { + const fakePath = "/rendered/path/organization"; + const expectedParameters = { + organization: "organizationValue", + }; + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationPath', () => { + const result = client.organizationPath("organizationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationName', () => { + const result = client.matchOrganizationFromOrganizationName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagBinding', () => { + const fakePath = "/rendered/path/tagBinding"; + const expectedParameters = { + tag_binding: "tagBindingValue", + }; + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagBindingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagBindingPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagBindingPath', () => { + const result = client.tagBindingPath("tagBindingValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagBindingFromTagBindingName', () => { + const result = client.matchTagBindingFromTagBindingName(fakePath); + assert.strictEqual(result, "tagBindingValue"); + assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagHold', () => { + const fakePath = "/rendered/path/tagHold"; + const expectedParameters = { + tag_value: "tagValueValue", + tag_hold: "tagHoldValue", + }; + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagHoldPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagHoldPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagHoldPath', () => { + const result = client.tagHoldPath("tagValueValue", "tagHoldValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagHoldPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagValueFromTagHoldName', () => { + const result = client.matchTagValueFromTagHoldName(fakePath); + assert.strictEqual(result, "tagValueValue"); + assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchTagHoldFromTagHoldName', () => { + const result = client.matchTagHoldFromTagHoldName(fakePath); + assert.strictEqual(result, "tagHoldValue"); + assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagKey', () => { + const fakePath = "/rendered/path/tagKey"; + const expectedParameters = { + tag_key: "tagKeyValue", + }; + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagKeyPath', () => { + const result = client.tagKeyPath("tagKeyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagKeyFromTagKeyName', () => { + const result = client.matchTagKeyFromTagKeyName(fakePath); + assert.strictEqual(result, "tagKeyValue"); + assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagValue', () => { + const fakePath = "/rendered/path/tagValue"; + const expectedParameters = { + tag_value: "tagValueValue", + }; + const client = new tagholdsModule.v3.TagHoldsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagValuePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagValuePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagValuePath', () => { + const result = client.tagValuePath("tagValueValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagValueFromTagValueName', () => { + const result = client.matchTagValueFromTagValueName(fakePath); + assert.strictEqual(result, "tagValueValue"); + assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_keys_v3.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_keys_v3.ts new file mode 100644 index 00000000000..24965247705 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_keys_v3.ts @@ -0,0 +1,1797 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 tagkeysModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v3.TagKeysClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = tagkeysModule.v3.TagKeysClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = tagkeysModule.v3.TagKeysClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = tagkeysModule.v3.TagKeysClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new tagkeysModule.v3.TagKeysClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new tagkeysModule.v3.TagKeysClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.tagKeysStub, undefined); + await client.initialize(); + assert(client.tagKeysStub); + }); + + it('has close method for the initialized client', done => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.tagKeysStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.tagKeysStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new tagkeysModule.v3.TagKeysClient({ + 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 tagkeysModule.v3.TagKeysClient({ + 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('getTagKey', () => { + it('invokes getTagKey without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetTagKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetTagKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.TagKey() + ); + client.innerApiCalls.getTagKey = stubSimpleCall(expectedResponse); + const [response] = await client.getTagKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getTagKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getTagKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getTagKey without error using callback', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetTagKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetTagKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.TagKey() + ); + client.innerApiCalls.getTagKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getTagKey( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getTagKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getTagKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getTagKey with error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetTagKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetTagKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getTagKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getTagKey(request), expectedError); + const actualRequest = (client.innerApiCalls.getTagKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getTagKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getTagKey with closed client', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetTagKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetTagKeyRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getTagKey(request), expectedError); + }); + }); + + describe('getNamespacedTagKey', () => { + it('invokes getNamespacedTagKey without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetNamespacedTagKeyRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.TagKey() + ); + client.innerApiCalls.getNamespacedTagKey = stubSimpleCall(expectedResponse); + const [response] = await client.getNamespacedTagKey(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes getNamespacedTagKey without error using callback', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetNamespacedTagKeyRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.TagKey() + ); + client.innerApiCalls.getNamespacedTagKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getNamespacedTagKey( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes getNamespacedTagKey with error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetNamespacedTagKeyRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.getNamespacedTagKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getNamespacedTagKey(request), expectedError); + }); + + it('invokes getNamespacedTagKey with closed client', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetNamespacedTagKeyRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getNamespacedTagKey(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('createTagKey', () => { + it('invokes createTagKey without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateTagKeyRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createTagKey = stubLongRunningCall(expectedResponse); + const [operation] = await client.createTagKey(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes createTagKey without error using callback', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateTagKeyRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createTagKey = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createTagKey( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes createTagKey with call error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateTagKeyRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.createTagKey = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createTagKey(request), expectedError); + }); + + it('invokes createTagKey with LRO error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateTagKeyRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.createTagKey = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createTagKey(request); + await assert.rejects(operation.promise(), expectedError); + }); + + it('invokes checkCreateTagKeyProgress without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateTagKeyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateTagKeyProgress with error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateTagKeyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateTagKey', () => { + it('invokes updateTagKey without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UpdateTagKeyRequest() + ); + request.tagKey ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateTagKeyRequest', ['tagKey', 'name']); + request.tagKey.name = defaultValue1; + const expectedHeaderRequestParams = `tag_key.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateTagKey = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateTagKey(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateTagKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateTagKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateTagKey without error using callback', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UpdateTagKeyRequest() + ); + request.tagKey ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateTagKeyRequest', ['tagKey', 'name']); + request.tagKey.name = defaultValue1; + const expectedHeaderRequestParams = `tag_key.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateTagKey = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateTagKey( + request, + (err?: Error|null, + result?: 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.updateTagKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateTagKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateTagKey with call error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UpdateTagKeyRequest() + ); + request.tagKey ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateTagKeyRequest', ['tagKey', 'name']); + request.tagKey.name = defaultValue1; + const expectedHeaderRequestParams = `tag_key.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateTagKey = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateTagKey(request), expectedError); + const actualRequest = (client.innerApiCalls.updateTagKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateTagKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateTagKey with LRO error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UpdateTagKeyRequest() + ); + request.tagKey ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateTagKeyRequest', ['tagKey', 'name']); + request.tagKey.name = defaultValue1; + const expectedHeaderRequestParams = `tag_key.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateTagKey = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateTagKey(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateTagKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateTagKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateTagKeyProgress without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateTagKeyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateTagKeyProgress with error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateTagKeyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteTagKey', () => { + it('invokes deleteTagKey without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteTagKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteTagKey = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteTagKey(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteTagKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteTagKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteTagKey without error using callback', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteTagKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteTagKey = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteTagKey( + request, + (err?: Error|null, + result?: 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.deleteTagKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteTagKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteTagKey with call error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteTagKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTagKey = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteTagKey(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteTagKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteTagKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteTagKey with LRO error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteTagKeyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagKeyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTagKey = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteTagKey(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteTagKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteTagKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteTagKeyProgress without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteTagKeyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteTagKeyProgress with error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteTagKeyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listTagKeys', () => { + it('invokes listTagKeys without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + ]; + client.innerApiCalls.listTagKeys = stubSimpleCall(expectedResponse); + const [response] = await client.listTagKeys(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listTagKeys without error using callback', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + ]; + client.innerApiCalls.listTagKeys = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTagKeys( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagKey[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listTagKeys with error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.listTagKeys = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listTagKeys(request), expectedError); + }); + + it('invokes listTagKeysStream without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + ]; + client.descriptors.page.listTagKeys.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listTagKeysStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.TagKey[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagKey) => { + 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.listTagKeys.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTagKeys, request)); + }); + + it('invokes listTagKeysStream with error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listTagKeys.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listTagKeysStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.TagKey[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagKey) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listTagKeys.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTagKeys, request)); + }); + + it('uses async iteration with listTagKeys without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + ]; + client.descriptors.page.listTagKeys.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.resourcemanager.v3.ITagKey[] = []; + const iterable = client.listTagKeysAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listTagKeys.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listTagKeys with error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listTagKeys.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listTagKeysAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.resourcemanager.v3.ITagKey[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listTagKeys.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + 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 tagkeysModule.v3.TagKeysClient({ + 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 tagkeysModule.v3.TagKeysClient({ + 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 tagkeysModule.v3.TagKeysClient({ + 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 tagkeysModule.v3.TagKeysClient({ + 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 tagkeysModule.v3.TagKeysClient({ + 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 tagkeysModule.v3.TagKeysClient({ + 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 tagkeysModule.v3.TagKeysClient({ + 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 tagkeysModule.v3.TagKeysClient({ + 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 tagkeysModule.v3.TagKeysClient({ + 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 tagkeysModule.v3.TagKeysClient({ + 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('folder', () => { + const fakePath = "/rendered/path/folder"; + const expectedParameters = { + folder: "folderValue", + }; + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderPath', () => { + const result = client.folderPath("folderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderName', () => { + const result = client.matchFolderFromFolderName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organization', () => { + const fakePath = "/rendered/path/organization"; + const expectedParameters = { + organization: "organizationValue", + }; + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationPath', () => { + const result = client.organizationPath("organizationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationName', () => { + const result = client.matchOrganizationFromOrganizationName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagBinding', () => { + const fakePath = "/rendered/path/tagBinding"; + const expectedParameters = { + tag_binding: "tagBindingValue", + }; + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagBindingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagBindingPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagBindingPath', () => { + const result = client.tagBindingPath("tagBindingValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagBindingFromTagBindingName', () => { + const result = client.matchTagBindingFromTagBindingName(fakePath); + assert.strictEqual(result, "tagBindingValue"); + assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagHold', () => { + const fakePath = "/rendered/path/tagHold"; + const expectedParameters = { + tag_value: "tagValueValue", + tag_hold: "tagHoldValue", + }; + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagHoldPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagHoldPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagHoldPath', () => { + const result = client.tagHoldPath("tagValueValue", "tagHoldValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagHoldPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagValueFromTagHoldName', () => { + const result = client.matchTagValueFromTagHoldName(fakePath); + assert.strictEqual(result, "tagValueValue"); + assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchTagHoldFromTagHoldName', () => { + const result = client.matchTagHoldFromTagHoldName(fakePath); + assert.strictEqual(result, "tagHoldValue"); + assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagKey', () => { + const fakePath = "/rendered/path/tagKey"; + const expectedParameters = { + tag_key: "tagKeyValue", + }; + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagKeyPath', () => { + const result = client.tagKeyPath("tagKeyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagKeyFromTagKeyName', () => { + const result = client.matchTagKeyFromTagKeyName(fakePath); + assert.strictEqual(result, "tagKeyValue"); + assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagValue', () => { + const fakePath = "/rendered/path/tagValue"; + const expectedParameters = { + tag_value: "tagValueValue", + }; + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagValuePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagValuePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagValuePath', () => { + const result = client.tagValuePath("tagValueValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagValueFromTagValueName', () => { + const result = client.matchTagValueFromTagValueName(fakePath); + assert.strictEqual(result, "tagValueValue"); + assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_values_v3.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_values_v3.ts new file mode 100644 index 00000000000..1a9b5fd1d77 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_values_v3.ts @@ -0,0 +1,1797 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 tagvaluesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v3.TagValuesClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = tagvaluesModule.v3.TagValuesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = tagvaluesModule.v3.TagValuesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = tagvaluesModule.v3.TagValuesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new tagvaluesModule.v3.TagValuesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.tagValuesStub, undefined); + await client.initialize(); + assert(client.tagValuesStub); + }); + + it('has close method for the initialized client', done => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.tagValuesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.tagValuesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new tagvaluesModule.v3.TagValuesClient({ + 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 tagvaluesModule.v3.TagValuesClient({ + 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('getTagValue', () => { + it('invokes getTagValue without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetTagValueRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetTagValueRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.TagValue() + ); + client.innerApiCalls.getTagValue = stubSimpleCall(expectedResponse); + const [response] = await client.getTagValue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getTagValue as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getTagValue as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getTagValue without error using callback', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetTagValueRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetTagValueRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.TagValue() + ); + client.innerApiCalls.getTagValue = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getTagValue( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagValue|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getTagValue as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getTagValue as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getTagValue with error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetTagValueRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetTagValueRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getTagValue = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getTagValue(request), expectedError); + const actualRequest = (client.innerApiCalls.getTagValue as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getTagValue as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getTagValue with closed client', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetTagValueRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetTagValueRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getTagValue(request), expectedError); + }); + }); + + describe('getNamespacedTagValue', () => { + it('invokes getNamespacedTagValue without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetNamespacedTagValueRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.TagValue() + ); + client.innerApiCalls.getNamespacedTagValue = stubSimpleCall(expectedResponse); + const [response] = await client.getNamespacedTagValue(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes getNamespacedTagValue without error using callback', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetNamespacedTagValueRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.TagValue() + ); + client.innerApiCalls.getNamespacedTagValue = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getNamespacedTagValue( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagValue|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes getNamespacedTagValue with error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetNamespacedTagValueRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.getNamespacedTagValue = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getNamespacedTagValue(request), expectedError); + }); + + it('invokes getNamespacedTagValue with closed client', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.GetNamespacedTagValueRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getNamespacedTagValue(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('createTagValue', () => { + it('invokes createTagValue without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateTagValueRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createTagValue = stubLongRunningCall(expectedResponse); + const [operation] = await client.createTagValue(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes createTagValue without error using callback', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateTagValueRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createTagValue = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createTagValue( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes createTagValue with call error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateTagValueRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.createTagValue = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createTagValue(request), expectedError); + }); + + it('invokes createTagValue with LRO error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.CreateTagValueRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.createTagValue = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createTagValue(request); + await assert.rejects(operation.promise(), expectedError); + }); + + it('invokes checkCreateTagValueProgress without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateTagValueProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateTagValueProgress with error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateTagValueProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateTagValue', () => { + it('invokes updateTagValue without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UpdateTagValueRequest() + ); + request.tagValue ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateTagValueRequest', ['tagValue', 'name']); + request.tagValue.name = defaultValue1; + const expectedHeaderRequestParams = `tag_value.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateTagValue = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateTagValue(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateTagValue as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateTagValue as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateTagValue without error using callback', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UpdateTagValueRequest() + ); + request.tagValue ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateTagValueRequest', ['tagValue', 'name']); + request.tagValue.name = defaultValue1; + const expectedHeaderRequestParams = `tag_value.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateTagValue = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateTagValue( + request, + (err?: Error|null, + result?: 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.updateTagValue as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateTagValue as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateTagValue with call error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UpdateTagValueRequest() + ); + request.tagValue ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateTagValueRequest', ['tagValue', 'name']); + request.tagValue.name = defaultValue1; + const expectedHeaderRequestParams = `tag_value.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateTagValue = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateTagValue(request), expectedError); + const actualRequest = (client.innerApiCalls.updateTagValue as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateTagValue as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateTagValue with LRO error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.UpdateTagValueRequest() + ); + request.tagValue ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateTagValueRequest', ['tagValue', 'name']); + request.tagValue.name = defaultValue1; + const expectedHeaderRequestParams = `tag_value.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateTagValue = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateTagValue(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateTagValue as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateTagValue as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateTagValueProgress without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateTagValueProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateTagValueProgress with error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateTagValueProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteTagValue', () => { + it('invokes deleteTagValue without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteTagValueRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagValueRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteTagValue = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteTagValue(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteTagValue as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteTagValue as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteTagValue without error using callback', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteTagValueRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagValueRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteTagValue = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteTagValue( + request, + (err?: Error|null, + result?: 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.deleteTagValue as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteTagValue as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteTagValue with call error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteTagValueRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagValueRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTagValue = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteTagValue(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteTagValue as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteTagValue as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteTagValue with LRO error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.DeleteTagValueRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagValueRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTagValue = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteTagValue(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteTagValue as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteTagValue as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteTagValueProgress without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteTagValueProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteTagValueProgress with error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteTagValueProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listTagValues', () => { + it('invokes listTagValues without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + ]; + client.innerApiCalls.listTagValues = stubSimpleCall(expectedResponse); + const [response] = await client.listTagValues(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listTagValues without error using callback', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + ]; + client.innerApiCalls.listTagValues = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTagValues( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagValue[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listTagValues with error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.listTagValues = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listTagValues(request), expectedError); + }); + + it('invokes listTagValuesStream without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + ]; + client.descriptors.page.listTagValues.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listTagValuesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.TagValue[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagValue) => { + 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.listTagValues.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTagValues, request)); + }); + + it('invokes listTagValuesStream with error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listTagValues.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listTagValuesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.TagValue[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagValue) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listTagValues.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTagValues, request)); + }); + + it('uses async iteration with listTagValues without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + ]; + client.descriptors.page.listTagValues.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.resourcemanager.v3.ITagValue[] = []; + const iterable = client.listTagValuesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listTagValues.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listTagValues with error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listTagValues.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listTagValuesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.resourcemanager.v3.ITagValue[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listTagValues.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + 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 tagvaluesModule.v3.TagValuesClient({ + 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 tagvaluesModule.v3.TagValuesClient({ + 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 tagvaluesModule.v3.TagValuesClient({ + 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 tagvaluesModule.v3.TagValuesClient({ + 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 tagvaluesModule.v3.TagValuesClient({ + 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 tagvaluesModule.v3.TagValuesClient({ + 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 tagvaluesModule.v3.TagValuesClient({ + 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 tagvaluesModule.v3.TagValuesClient({ + 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 tagvaluesModule.v3.TagValuesClient({ + 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 tagvaluesModule.v3.TagValuesClient({ + 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('folder', () => { + const fakePath = "/rendered/path/folder"; + const expectedParameters = { + folder: "folderValue", + }; + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderPath', () => { + const result = client.folderPath("folderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderName', () => { + const result = client.matchFolderFromFolderName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organization', () => { + const fakePath = "/rendered/path/organization"; + const expectedParameters = { + organization: "organizationValue", + }; + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationPath', () => { + const result = client.organizationPath("organizationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationName', () => { + const result = client.matchOrganizationFromOrganizationName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagBinding', () => { + const fakePath = "/rendered/path/tagBinding"; + const expectedParameters = { + tag_binding: "tagBindingValue", + }; + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagBindingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagBindingPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagBindingPath', () => { + const result = client.tagBindingPath("tagBindingValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagBindingFromTagBindingName', () => { + const result = client.matchTagBindingFromTagBindingName(fakePath); + assert.strictEqual(result, "tagBindingValue"); + assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagHold', () => { + const fakePath = "/rendered/path/tagHold"; + const expectedParameters = { + tag_value: "tagValueValue", + tag_hold: "tagHoldValue", + }; + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagHoldPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagHoldPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagHoldPath', () => { + const result = client.tagHoldPath("tagValueValue", "tagHoldValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagHoldPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagValueFromTagHoldName', () => { + const result = client.matchTagValueFromTagHoldName(fakePath); + assert.strictEqual(result, "tagValueValue"); + assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchTagHoldFromTagHoldName', () => { + const result = client.matchTagHoldFromTagHoldName(fakePath); + assert.strictEqual(result, "tagHoldValue"); + assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagKey', () => { + const fakePath = "/rendered/path/tagKey"; + const expectedParameters = { + tag_key: "tagKeyValue", + }; + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagKeyPath', () => { + const result = client.tagKeyPath("tagKeyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagKeyFromTagKeyName', () => { + const result = client.matchTagKeyFromTagKeyName(fakePath); + assert.strictEqual(result, "tagKeyValue"); + assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagValue', () => { + const fakePath = "/rendered/path/tagValue"; + const expectedParameters = { + tag_value: "tagValueValue", + }; + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagValuePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagValuePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagValuePath', () => { + const result = client.tagValuePath("tagValueValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagValueFromTagValueName', () => { + const result = client.matchTagValueFromTagValueName(fakePath); + assert.strictEqual(result, "tagValueValue"); + assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/tsconfig.json b/owl-bot-staging/google-cloud-resourcemanager/v3/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/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-resourcemanager/v3/webpack.config.js b/owl-bot-staging/google-cloud-resourcemanager/v3/webpack.config.js new file mode 100644 index 00000000000..92f3d14c0cc --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcemanager/v3/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: 'Folders', + filename: './folders.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-resourcesettings/v1/.eslintignore b/owl-bot-staging/google-cloud-resourcesettings/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/.eslintrc.json b/owl-bot-staging/google-cloud-resourcesettings/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/.gitignore b/owl-bot-staging/google-cloud-resourcesettings/v1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/.jsdoc.js b/owl-bot-staging/google-cloud-resourcesettings/v1/.jsdoc.js new file mode 100644 index 00000000000..df02879c503 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/.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/resource-settings', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/.mocharc.js b/owl-bot-staging/google-cloud-resourcesettings/v1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/.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-resourcesettings/v1/.prettierrc.js b/owl-bot-staging/google-cloud-resourcesettings/v1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/.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-resourcesettings/v1/README.md b/owl-bot-staging/google-cloud-resourcesettings/v1/README.md new file mode 100644 index 00000000000..83837ad6560 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/README.md @@ -0,0 +1 @@ +Resourcesettings: Nodejs Client diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/package.json b/owl-bot-staging/google-cloud-resourcesettings/v1/package.json new file mode 100644 index 00000000000..6a1a2c0d369 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/resource-settings", + "version": "0.1.0", + "description": "Resourcesettings client for Node.js", + "repository": "googleapis/nodejs-resourcesettings", + "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 resourcesettings", + "resourcesettings", + "resource settings service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/protos/google/cloud/resourcesettings/v1/resource_settings.proto b/owl-bot-staging/google-cloud-resourcesettings/v1/protos/google/cloud/resourcesettings/v1/resource_settings.proto new file mode 100644 index 00000000000..38479dcbd01 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/protos/google/cloud/resourcesettings/v1/resource_settings.proto @@ -0,0 +1,308 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.resourcesettings.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option cc_enable_arenas = true; +option go_package = "cloud.google.com/go/resourcesettings/apiv1/resourcesettingspb;resourcesettingspb"; +option java_multiple_files = true; +option java_outer_classname = "ResourceSettingsProto"; +option java_package = "com.google.cloud.resourcesettings.v1"; + +// Client library namespace +option csharp_namespace = "Google.Cloud.ResourceSettings.V1"; +option php_namespace = "Google\\Cloud\\ResourceSettings\\V1"; +option ruby_package = "Google::Cloud::ResourceSettings::V1"; + +// An interface to interact with resource settings and setting values throughout +// the resource hierarchy. +// +// Services may surface a number of settings for users to control how their +// resources behave. Values of settings applied on a given Cloud resource are +// evaluated hierarchically and inherited by all descendants of that resource. +// +// For all requests, returns a `google.rpc.Status` with +// `google.rpc.Code.PERMISSION_DENIED` if the IAM check fails or the `parent` +// resource is not in a Cloud Organization. +// For all requests, returns a `google.rpc.Status` with +// `google.rpc.Code.INVALID_ARGUMENT` if the request is malformed. +service ResourceSettingsService { + option (google.api.default_host) = "resourcesettings.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Lists all the settings that are available on the Cloud resource `parent`. + rpc ListSettings(ListSettingsRequest) returns (ListSettingsResponse) { + option (google.api.http) = { + get: "/v1/{parent=organizations/*}/settings" + additional_bindings { + get: "/v1/{parent=folders/*}/settings" + } + additional_bindings { + get: "/v1/{parent=projects/*}/settings" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a setting. + // + // Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the + // setting does not exist. + rpc GetSetting(GetSettingRequest) returns (Setting) { + option (google.api.http) = { + get: "/v1/{name=organizations/*/settings/*}" + additional_bindings { + get: "/v1/{name=folders/*/settings/*}" + } + additional_bindings { + get: "/v1/{name=projects/*/settings/*}" + } + }; + option (google.api.method_signature) = "name"; + } + + // Updates a setting. + // + // Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the + // setting does not exist. + // Returns a `google.rpc.Status` with `google.rpc.Code.FAILED_PRECONDITION` if + // the setting is flagged as read only. + // Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag + // supplied in the request does not match the persisted etag of the setting + // value. + // + // On success, the response will contain only `name`, `local_value` and + // `etag`. The `metadata` and `effective_value` cannot be updated through + // this API. + // + // Note: the supplied setting will perform a full overwrite of the + // `local_value` field. + rpc UpdateSetting(UpdateSettingRequest) returns (Setting) { + option (google.api.http) = { + patch: "/v1/{setting.name=organizations/*/settings/*}" + body: "setting" + additional_bindings { + patch: "/v1/{setting.name=folders/*/settings/*}" + body: "setting" + } + additional_bindings { + patch: "/v1/{setting.name=projects/*/settings/*}" + body: "setting" + } + }; + } +} + +// The schema for settings. +message Setting { + option (google.api.resource) = { + type: "resourcesettings.googleapis.com/Setting" + pattern: "projects/{project_number}/settings/{setting_name}" + pattern: "folders/{folder}/settings/{setting_name}" + pattern: "organizations/{organization}/settings/{setting_name}" + }; + + // The resource name of the setting. Must be in one of the following forms: + // + // * `projects/{project_number}/settings/{setting_name}` + // * `folders/{folder_id}/settings/{setting_name}` + // * `organizations/{organization_id}/settings/{setting_name}` + // + // For example, "/projects/123/settings/gcp-enableMyFeature" + string name = 1; + + // Output only. Metadata about a setting which is not editable by the end user. + SettingMetadata metadata = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The configured value of the setting at the given parent resource (ignoring + // the resource hierarchy). The data type of [Value][google.cloud.resourcesettings.v1.Value] must always be + // consistent with the data type defined in [Setting.metadata][google.cloud.resourcesettings.v1.Setting.metadata]. + Value local_value = 8; + + // Output only. The computed effective value of the setting at the given parent resource + // (based on the resource hierarchy). + // + // The effective value evaluates to one of the following options in the given + // order (the next option is used if the previous one does not exist): + // + // 1. the local setting value on the given resource: [Setting.local_value][google.cloud.resourcesettings.v1.Setting.local_value] + // 2. if one of the given resource's ancestors have a local setting value, + // the local value at the nearest such ancestor + // 3. the setting's default value: [SettingMetadata.default_value][google.cloud.resourcesettings.v1.SettingMetadata.default_value] + // 4. an empty value (defined as a `Value` with all fields unset) + // + // The data type of [Value][google.cloud.resourcesettings.v1.Value] must always be + // consistent with the data type defined in [Setting.metadata][google.cloud.resourcesettings.v1.Setting.metadata]. + Value effective_value = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // A fingerprint used for optimistic concurrency. See + // [UpdateSetting][google.cloud.resourcesettings.v1.ResourceSettingsService.UpdateSetting] for more + // details. + string etag = 10; +} + +// Metadata about a setting which is not editable by the end user. +message SettingMetadata { + // The data type for setting values of this setting. See [Value][google.cloud.resourcesettings.v1.Value] for more + // details on the available data types. + enum DataType { + // Unspecified data type. + DATA_TYPE_UNSPECIFIED = 0; + + // A boolean setting. + BOOLEAN = 1; + + // A string setting. + STRING = 2; + + // A string set setting. + STRING_SET = 3; + + // A Enum setting + ENUM_VALUE = 4; + } + + // The human readable name for this setting. + string display_name = 1; + + // A detailed description of what this setting does. + string description = 2; + + // A flag indicating that values of this setting cannot be modified (see + // documentation of the specific setting for updates and reasons). + bool read_only = 3; + + // The data type for this setting. + DataType data_type = 4; + + // The value provided by [Setting.effective_value][google.cloud.resourcesettings.v1.Setting.effective_value] if no setting value is + // explicitly set. + // + // Note: not all settings have a default value. + Value default_value = 5; +} + +// The data in a setting value. +message Value { + // A string set value that can hold a set of strings. The maximum length of + // each string is 200 characters and there can be a maximum of 50 strings in + // the string set. + message StringSet { + // The strings in the set + repeated string values = 1; + } + + // A enum value that can hold any enum type setting values. + // Each enum type is represented by a number, this representation + // is stored in the definitions. + message EnumValue { + // The value of this enum + string value = 1; + } + + // Selects the data type and associated value. + oneof value { + // Defines this value as being a boolean value. + bool boolean_value = 1; + + // Defines this value as being a string value. + string string_value = 2; + + // Defines this value as being a StringSet. + StringSet string_set_value = 3; + + // Defines this value as being a Enum. + EnumValue enum_value = 4; + } +} + +// The request for ListSettings. +message ListSettingsRequest { + // Required. The Cloud resource that parents the setting. Must be in one of the + // following forms: + // + // * `projects/{project_number}` + // * `projects/{project_id}` + // * `folders/{folder_id}` + // * `organizations/{organization_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "*" + } + ]; + + // Unused. The size of the page to be returned. + int32 page_size = 2; + + // Unused. A page token used to retrieve the next page. + string page_token = 3; + + // The SettingView for this request. + SettingView view = 4; +} + +// The response from ListSettings. +message ListSettingsResponse { + // A list of settings that are available at the specified Cloud resource. + repeated Setting settings = 1; + + // Unused. A page token used to retrieve the next page. + string next_page_token = 2; +} + +// The request for GetSetting. +message GetSettingRequest { + // Required. The name of the setting to get. See [Setting][google.cloud.resourcesettings.v1.Setting] for naming + // requirements. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "resourcesettings.googleapis.com/Setting" + } + ]; + + // The SettingView for this request. + SettingView view = 2; +} + +// The request for UpdateSetting. +message UpdateSettingRequest { + // Required. The setting to update. See [Setting][google.cloud.resourcesettings.v1.Setting] for field requirements. + Setting setting = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// View options for Settings. +enum SettingView { + // The default / unset value. + // The API will default to the SETTING_VIEW_BASIC view. + SETTING_VIEW_UNSPECIFIED = 0; + + // Include [Setting.metadata][google.cloud.resourcesettings.v1.Setting.metadata], but nothing else. + // This is the default value (for both ListSettings and GetSetting). + SETTING_VIEW_BASIC = 1; + + // Include [Setting.effective_value][google.cloud.resourcesettings.v1.Setting.effective_value], but nothing else. + SETTING_VIEW_EFFECTIVE_VALUE = 2; + + // Include [Setting.local_value][google.cloud.resourcesettings.v1.Setting.local_value], but nothing else. + SETTING_VIEW_LOCAL_VALUE = 3; +} diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.get_setting.js b/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.get_setting.js new file mode 100644 index 00000000000..cfb6e5b7d4b --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.get_setting.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(name) { + // [START resourcesettings_v1_generated_ResourceSettingsService_GetSetting_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 setting to get. See Setting google.cloud.resourcesettings.v1.Setting for naming + * requirements. + */ + // const name = 'abc123' + /** + * The SettingView for this request. + */ + // const view = {} + + // Imports the Resourcesettings library + const {ResourceSettingsServiceClient} = require('@google-cloud/resource-settings').v1; + + // Instantiates a client + const resourcesettingsClient = new ResourceSettingsServiceClient(); + + async function callGetSetting() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await resourcesettingsClient.getSetting(request); + console.log(response); + } + + callGetSetting(); + // [END resourcesettings_v1_generated_ResourceSettingsService_GetSetting_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.list_settings.js b/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.list_settings.js new file mode 100644 index 00000000000..ee3df4ce32d --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.list_settings.js @@ -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. ** + + + +'use strict'; + +function main(parent) { + // [START resourcesettings_v1_generated_ResourceSettingsService_ListSettings_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Cloud resource that parents the setting. Must be in one of the + * following forms: + * * `projects/{project_number}` + * * `projects/{project_id}` + * * `folders/{folder_id}` + * * `organizations/{organization_id}` + */ + // const parent = 'abc123' + /** + * Unused. The size of the page to be returned. + */ + // const pageSize = 1234 + /** + * Unused. A page token used to retrieve the next page. + */ + // const pageToken = 'abc123' + /** + * The SettingView for this request. + */ + // const view = {} + + // Imports the Resourcesettings library + const {ResourceSettingsServiceClient} = require('@google-cloud/resource-settings').v1; + + // Instantiates a client + const resourcesettingsClient = new ResourceSettingsServiceClient(); + + async function callListSettings() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await resourcesettingsClient.listSettingsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListSettings(); + // [END resourcesettings_v1_generated_ResourceSettingsService_ListSettings_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.update_setting.js b/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.update_setting.js new file mode 100644 index 00000000000..811ee6d9477 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.update_setting.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(setting) { + // [START resourcesettings_v1_generated_ResourceSettingsService_UpdateSetting_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The setting to update. See Setting google.cloud.resourcesettings.v1.Setting for field requirements. + */ + // const setting = {} + + // Imports the Resourcesettings library + const {ResourceSettingsServiceClient} = require('@google-cloud/resource-settings').v1; + + // Instantiates a client + const resourcesettingsClient = new ResourceSettingsServiceClient(); + + async function callUpdateSetting() { + // Construct request + const request = { + setting, + }; + + // Run request + const response = await resourcesettingsClient.updateSetting(request); + console.log(response); + } + + callUpdateSetting(); + // [END resourcesettings_v1_generated_ResourceSettingsService_UpdateSetting_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/snippet_metadata_google.cloud.resourcesettings.v1.json b/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/snippet_metadata_google.cloud.resourcesettings.v1.json new file mode 100644 index 00000000000..723ee3d0521 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/snippet_metadata_google.cloud.resourcesettings.v1.json @@ -0,0 +1,151 @@ +{ + "clientLibrary": { + "name": "nodejs-resourcesettings", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.resourcesettings.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "resourcesettings_v1_generated_ResourceSettingsService_ListSettings_async", + "title": "ResourceSettingsService listSettings Sample", + "origin": "API_DEFINITION", + "description": " Lists all the settings that are available on the Cloud resource `parent`.", + "canonical": true, + "file": "resource_settings_service.list_settings.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListSettings", + "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsService.ListSettings", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "view", + "type": ".google.cloud.resourcesettings.v1.SettingView" + } + ], + "resultType": ".google.cloud.resourcesettings.v1.ListSettingsResponse", + "client": { + "shortName": "ResourceSettingsServiceClient", + "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsServiceClient" + }, + "method": { + "shortName": "ListSettings", + "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsService.ListSettings", + "service": { + "shortName": "ResourceSettingsService", + "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsService" + } + } + } + }, + { + "regionTag": "resourcesettings_v1_generated_ResourceSettingsService_GetSetting_async", + "title": "ResourceSettingsService getSetting Sample", + "origin": "API_DEFINITION", + "description": " Gets a setting. Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the setting does not exist.", + "canonical": true, + "file": "resource_settings_service.get_setting.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetSetting", + "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsService.GetSetting", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "view", + "type": ".google.cloud.resourcesettings.v1.SettingView" + } + ], + "resultType": ".google.cloud.resourcesettings.v1.Setting", + "client": { + "shortName": "ResourceSettingsServiceClient", + "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsServiceClient" + }, + "method": { + "shortName": "GetSetting", + "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsService.GetSetting", + "service": { + "shortName": "ResourceSettingsService", + "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsService" + } + } + } + }, + { + "regionTag": "resourcesettings_v1_generated_ResourceSettingsService_UpdateSetting_async", + "title": "ResourceSettingsService updateSetting Sample", + "origin": "API_DEFINITION", + "description": " Updates a setting. Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the setting does not exist. Returns a `google.rpc.Status` with `google.rpc.Code.FAILED_PRECONDITION` if the setting is flagged as read only. Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag supplied in the request does not match the persisted etag of the setting value. On success, the response will contain only `name`, `local_value` and `etag`. The `metadata` and `effective_value` cannot be updated through this API. Note: the supplied setting will perform a full overwrite of the `local_value` field.", + "canonical": true, + "file": "resource_settings_service.update_setting.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateSetting", + "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsService.UpdateSetting", + "async": true, + "parameters": [ + { + "name": "setting", + "type": ".google.cloud.resourcesettings.v1.Setting" + } + ], + "resultType": ".google.cloud.resourcesettings.v1.Setting", + "client": { + "shortName": "ResourceSettingsServiceClient", + "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsServiceClient" + }, + "method": { + "shortName": "UpdateSetting", + "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsService.UpdateSetting", + "service": { + "shortName": "ResourceSettingsService", + "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/src/index.ts b/owl-bot-staging/google-cloud-resourcesettings/v1/src/index.ts new file mode 100644 index 00000000000..cc98aa85c64 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const ResourceSettingsServiceClient = v1.ResourceSettingsServiceClient; +type ResourceSettingsServiceClient = v1.ResourceSettingsServiceClient; +export {v1, ResourceSettingsServiceClient}; +export default {v1, ResourceSettingsServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..3b49a1ce240 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/gapic_metadata.json @@ -0,0 +1,57 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.resourcesettings.v1", + "libraryPackage": "@google-cloud/resource-settings", + "services": { + "ResourceSettingsService": { + "clients": { + "grpc": { + "libraryClient": "ResourceSettingsServiceClient", + "rpcs": { + "GetSetting": { + "methods": [ + "getSetting" + ] + }, + "UpdateSetting": { + "methods": [ + "updateSetting" + ] + }, + "ListSettings": { + "methods": [ + "listSettings", + "listSettingsStream", + "listSettingsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ResourceSettingsServiceClient", + "rpcs": { + "GetSetting": { + "methods": [ + "getSetting" + ] + }, + "UpdateSetting": { + "methods": [ + "updateSetting" + ] + }, + "ListSettings": { + "methods": [ + "listSettings", + "listSettingsStream", + "listSettingsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/index.ts new file mode 100644 index 00000000000..ea044328836 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ResourceSettingsServiceClient} from './resource_settings_service_client'; diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_client.ts b/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_client.ts new file mode 100644 index 00000000000..f36e0651c78 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_client.ts @@ -0,0 +1,808 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/resource_settings_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './resource_settings_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * An interface to interact with resource settings and setting values throughout + * the resource hierarchy. + * + * Services may surface a number of settings for users to control how their + * resources behave. Values of settings applied on a given Cloud resource are + * evaluated hierarchically and inherited by all descendants of that resource. + * + * For all requests, returns a `google.rpc.Status` with + * `google.rpc.Code.PERMISSION_DENIED` if the IAM check fails or the `parent` + * resource is not in a Cloud Organization. + * For all requests, returns a `google.rpc.Status` with + * `google.rpc.Code.INVALID_ARGUMENT` if the request is malformed. + * @class + * @memberof v1 + */ +export class ResourceSettingsServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + resourceSettingsServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ResourceSettingsServiceClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 ResourceSettingsServiceClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ResourceSettingsServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else { + 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 = { + folderSettingNamePathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/settings/{setting_name}' + ), + organizationSettingNamePathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/settings/{setting_name}' + ), + projectNumberSettingNamePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project_number}/settings/{setting_name}' + ), + }; + + // 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 = { + listSettings: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'settings') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.resourcesettings.v1.ResourceSettingsService', 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.resourceSettingsServiceStub) { + return this.resourceSettingsServiceStub; + } + + // Put together the "service stub" for + // google.cloud.resourcesettings.v1.ResourceSettingsService. + this.resourceSettingsServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.resourcesettings.v1.ResourceSettingsService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.resourcesettings.v1.ResourceSettingsService, + 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 resourceSettingsServiceStubMethods = + ['listSettings', 'getSetting', 'updateSetting']; + for (const methodName of resourceSettingsServiceStubMethods) { + const callPromise = this.resourceSettingsServiceStub.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.resourceSettingsServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'resourcesettings.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 'resourcesettings.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 setting. + * + * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the + * setting does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the setting to get. See {@link protos.google.cloud.resourcesettings.v1.Setting|Setting} for naming + * requirements. + * @param {google.cloud.resourcesettings.v1.SettingView} request.view + * The SettingView for this request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.resourcesettings.v1.Setting|Setting}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/resource_settings_service.get_setting.js + * region_tag:resourcesettings_v1_generated_ResourceSettingsService_GetSetting_async + */ + getSetting( + request?: protos.google.cloud.resourcesettings.v1.IGetSettingRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcesettings.v1.ISetting, + protos.google.cloud.resourcesettings.v1.IGetSettingRequest|undefined, {}|undefined + ]>; + getSetting( + request: protos.google.cloud.resourcesettings.v1.IGetSettingRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.resourcesettings.v1.ISetting, + protos.google.cloud.resourcesettings.v1.IGetSettingRequest|null|undefined, + {}|null|undefined>): void; + getSetting( + request: protos.google.cloud.resourcesettings.v1.IGetSettingRequest, + callback: Callback< + protos.google.cloud.resourcesettings.v1.ISetting, + protos.google.cloud.resourcesettings.v1.IGetSettingRequest|null|undefined, + {}|null|undefined>): void; + getSetting( + request?: protos.google.cloud.resourcesettings.v1.IGetSettingRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.resourcesettings.v1.ISetting, + protos.google.cloud.resourcesettings.v1.IGetSettingRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.resourcesettings.v1.ISetting, + protos.google.cloud.resourcesettings.v1.IGetSettingRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.resourcesettings.v1.ISetting, + protos.google.cloud.resourcesettings.v1.IGetSettingRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getSetting(request, options, callback); + } +/** + * Updates a setting. + * + * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the + * setting does not exist. + * Returns a `google.rpc.Status` with `google.rpc.Code.FAILED_PRECONDITION` if + * the setting is flagged as read only. + * Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag + * supplied in the request does not match the persisted etag of the setting + * value. + * + * On success, the response will contain only `name`, `local_value` and + * `etag`. The `metadata` and `effective_value` cannot be updated through + * this API. + * + * Note: the supplied setting will perform a full overwrite of the + * `local_value` field. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.resourcesettings.v1.Setting} request.setting + * Required. The setting to update. See {@link protos.google.cloud.resourcesettings.v1.Setting|Setting} for field requirements. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.resourcesettings.v1.Setting|Setting}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/resource_settings_service.update_setting.js + * region_tag:resourcesettings_v1_generated_ResourceSettingsService_UpdateSetting_async + */ + updateSetting( + request?: protos.google.cloud.resourcesettings.v1.IUpdateSettingRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcesettings.v1.ISetting, + protos.google.cloud.resourcesettings.v1.IUpdateSettingRequest|undefined, {}|undefined + ]>; + updateSetting( + request: protos.google.cloud.resourcesettings.v1.IUpdateSettingRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.resourcesettings.v1.ISetting, + protos.google.cloud.resourcesettings.v1.IUpdateSettingRequest|null|undefined, + {}|null|undefined>): void; + updateSetting( + request: protos.google.cloud.resourcesettings.v1.IUpdateSettingRequest, + callback: Callback< + protos.google.cloud.resourcesettings.v1.ISetting, + protos.google.cloud.resourcesettings.v1.IUpdateSettingRequest|null|undefined, + {}|null|undefined>): void; + updateSetting( + request?: protos.google.cloud.resourcesettings.v1.IUpdateSettingRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.resourcesettings.v1.ISetting, + protos.google.cloud.resourcesettings.v1.IUpdateSettingRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.resourcesettings.v1.ISetting, + protos.google.cloud.resourcesettings.v1.IUpdateSettingRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.resourcesettings.v1.ISetting, + protos.google.cloud.resourcesettings.v1.IUpdateSettingRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'setting.name': request.setting!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateSetting(request, options, callback); + } + + /** + * Lists all the settings that are available on the Cloud resource `parent`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The Cloud resource that parents the setting. Must be in one of the + * following forms: + * + * * `projects/{project_number}` + * * `projects/{project_id}` + * * `folders/{folder_id}` + * * `organizations/{organization_id}` + * @param {number} request.pageSize + * Unused. The size of the page to be returned. + * @param {string} request.pageToken + * Unused. A page token used to retrieve the next page. + * @param {google.cloud.resourcesettings.v1.SettingView} request.view + * The SettingView for this request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.resourcesettings.v1.Setting|Setting}. + * 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 `listSettingsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listSettings( + request?: protos.google.cloud.resourcesettings.v1.IListSettingsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcesettings.v1.ISetting[], + protos.google.cloud.resourcesettings.v1.IListSettingsRequest|null, + protos.google.cloud.resourcesettings.v1.IListSettingsResponse + ]>; + listSettings( + request: protos.google.cloud.resourcesettings.v1.IListSettingsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.resourcesettings.v1.IListSettingsRequest, + protos.google.cloud.resourcesettings.v1.IListSettingsResponse|null|undefined, + protos.google.cloud.resourcesettings.v1.ISetting>): void; + listSettings( + request: protos.google.cloud.resourcesettings.v1.IListSettingsRequest, + callback: PaginationCallback< + protos.google.cloud.resourcesettings.v1.IListSettingsRequest, + protos.google.cloud.resourcesettings.v1.IListSettingsResponse|null|undefined, + protos.google.cloud.resourcesettings.v1.ISetting>): void; + listSettings( + request?: protos.google.cloud.resourcesettings.v1.IListSettingsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.resourcesettings.v1.IListSettingsRequest, + protos.google.cloud.resourcesettings.v1.IListSettingsResponse|null|undefined, + protos.google.cloud.resourcesettings.v1.ISetting>, + callback?: PaginationCallback< + protos.google.cloud.resourcesettings.v1.IListSettingsRequest, + protos.google.cloud.resourcesettings.v1.IListSettingsResponse|null|undefined, + protos.google.cloud.resourcesettings.v1.ISetting>): + Promise<[ + protos.google.cloud.resourcesettings.v1.ISetting[], + protos.google.cloud.resourcesettings.v1.IListSettingsRequest|null, + protos.google.cloud.resourcesettings.v1.IListSettingsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listSettings(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 Cloud resource that parents the setting. Must be in one of the + * following forms: + * + * * `projects/{project_number}` + * * `projects/{project_id}` + * * `folders/{folder_id}` + * * `organizations/{organization_id}` + * @param {number} request.pageSize + * Unused. The size of the page to be returned. + * @param {string} request.pageToken + * Unused. A page token used to retrieve the next page. + * @param {google.cloud.resourcesettings.v1.SettingView} request.view + * The SettingView for this request. + * @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 protos.google.cloud.resourcesettings.v1.Setting|Setting} 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 `listSettingsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listSettingsStream( + request?: protos.google.cloud.resourcesettings.v1.IListSettingsRequest, + 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['listSettings']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listSettings.createStream( + this.innerApiCalls.listSettings as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listSettings`, 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 Cloud resource that parents the setting. Must be in one of the + * following forms: + * + * * `projects/{project_number}` + * * `projects/{project_id}` + * * `folders/{folder_id}` + * * `organizations/{organization_id}` + * @param {number} request.pageSize + * Unused. The size of the page to be returned. + * @param {string} request.pageToken + * Unused. A page token used to retrieve the next page. + * @param {google.cloud.resourcesettings.v1.SettingView} request.view + * The SettingView for this request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.resourcesettings.v1.Setting|Setting}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/resource_settings_service.list_settings.js + * region_tag:resourcesettings_v1_generated_ResourceSettingsService_ListSettings_async + */ + listSettingsAsync( + request?: protos.google.cloud.resourcesettings.v1.IListSettingsRequest, + 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['listSettings']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listSettings.asyncIterate( + this.innerApiCalls['listSettings'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified folderSettingName resource name string. + * + * @param {string} folder + * @param {string} setting_name + * @returns {string} Resource name string. + */ + folderSettingNamePath(folder:string,settingName:string) { + return this.pathTemplates.folderSettingNamePathTemplate.render({ + folder: folder, + setting_name: settingName, + }); + } + + /** + * Parse the folder from FolderSettingName resource. + * + * @param {string} folderSettingNameName + * A fully-qualified path representing folder_setting_name resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderSettingNameName(folderSettingNameName: string) { + return this.pathTemplates.folderSettingNamePathTemplate.match(folderSettingNameName).folder; + } + + /** + * Parse the setting_name from FolderSettingName resource. + * + * @param {string} folderSettingNameName + * A fully-qualified path representing folder_setting_name resource. + * @returns {string} A string representing the setting_name. + */ + matchSettingNameFromFolderSettingNameName(folderSettingNameName: string) { + return this.pathTemplates.folderSettingNamePathTemplate.match(folderSettingNameName).setting_name; + } + + /** + * Return a fully-qualified organizationSettingName resource name string. + * + * @param {string} organization + * @param {string} setting_name + * @returns {string} Resource name string. + */ + organizationSettingNamePath(organization:string,settingName:string) { + return this.pathTemplates.organizationSettingNamePathTemplate.render({ + organization: organization, + setting_name: settingName, + }); + } + + /** + * Parse the organization from OrganizationSettingName resource. + * + * @param {string} organizationSettingNameName + * A fully-qualified path representing organization_setting_name resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationSettingNameName(organizationSettingNameName: string) { + return this.pathTemplates.organizationSettingNamePathTemplate.match(organizationSettingNameName).organization; + } + + /** + * Parse the setting_name from OrganizationSettingName resource. + * + * @param {string} organizationSettingNameName + * A fully-qualified path representing organization_setting_name resource. + * @returns {string} A string representing the setting_name. + */ + matchSettingNameFromOrganizationSettingNameName(organizationSettingNameName: string) { + return this.pathTemplates.organizationSettingNamePathTemplate.match(organizationSettingNameName).setting_name; + } + + /** + * Return a fully-qualified projectNumberSettingName resource name string. + * + * @param {string} project_number + * @param {string} setting_name + * @returns {string} Resource name string. + */ + projectNumberSettingNamePath(projectNumber:string,settingName:string) { + return this.pathTemplates.projectNumberSettingNamePathTemplate.render({ + project_number: projectNumber, + setting_name: settingName, + }); + } + + /** + * Parse the project_number from ProjectNumberSettingName resource. + * + * @param {string} projectNumberSettingNameName + * A fully-qualified path representing project_number_setting_name resource. + * @returns {string} A string representing the project_number. + */ + matchProjectNumberFromProjectNumberSettingNameName(projectNumberSettingNameName: string) { + return this.pathTemplates.projectNumberSettingNamePathTemplate.match(projectNumberSettingNameName).project_number; + } + + /** + * Parse the setting_name from ProjectNumberSettingName resource. + * + * @param {string} projectNumberSettingNameName + * A fully-qualified path representing project_number_setting_name resource. + * @returns {string} A string representing the setting_name. + */ + matchSettingNameFromProjectNumberSettingNameName(projectNumberSettingNameName: string) { + return this.pathTemplates.projectNumberSettingNamePathTemplate.match(projectNumberSettingNameName).setting_name; + } + + /** + * 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.resourceSettingsServiceStub && !this._terminated) { + return this.resourceSettingsServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_client_config.json b/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_client_config.json new file mode 100644 index 00000000000..a1802c062bc --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_client_config.json @@ -0,0 +1,50 @@ +{ + "interfaces": { + "google.cloud.resourcesettings.v1.ResourceSettingsService": { + "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 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListSettings": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "GetSetting": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "UpdateSetting": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_proto_list.json b/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_proto_list.json new file mode 100644 index 00000000000..675fedf1ac6 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/resourcesettings/v1/resource_settings.proto" +] diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-resourcesettings/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..6766456c390 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const resourcesettings = require('@google-cloud/resource-settings'); + +function main() { + const resourceSettingsServiceClient = new resourcesettings.ResourceSettingsServiceClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-resourcesettings/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..acc97ba0fb5 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {ResourceSettingsServiceClient} from '@google-cloud/resource-settings'; + +// check that the client class type name can be used +function doStuffWithResourceSettingsServiceClient(client: ResourceSettingsServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const resourceSettingsServiceClient = new ResourceSettingsServiceClient(); + doStuffWithResourceSettingsServiceClient(resourceSettingsServiceClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/system-test/install.ts b/owl-bot-staging/google-cloud-resourcesettings/v1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/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-resourcesettings/v1/test/gapic_resource_settings_service_v1.ts b/owl-bot-staging/google-cloud-resourcesettings/v1/test/gapic_resource_settings_service_v1.ts new file mode 100644 index 00000000000..7c8ef02cc74 --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/test/gapic_resource_settings_service_v1.ts @@ -0,0 +1,779 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 resourcesettingsserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.ResourceSettingsServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = resourcesettingsserviceModule.v1.ResourceSettingsServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = resourcesettingsserviceModule.v1.ResourceSettingsServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = resourcesettingsserviceModule.v1.ResourceSettingsServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.resourceSettingsServiceStub, undefined); + await client.initialize(); + assert(client.resourceSettingsServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.resourceSettingsServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.resourceSettingsServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + 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 resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + 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('getSetting', () => { + it('invokes getSetting without error', async () => { + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcesettings.v1.GetSettingRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcesettings.v1.GetSettingRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.resourcesettings.v1.Setting() + ); + client.innerApiCalls.getSetting = stubSimpleCall(expectedResponse); + const [response] = await client.getSetting(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getSetting as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSetting as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSetting without error using callback', async () => { + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcesettings.v1.GetSettingRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcesettings.v1.GetSettingRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.resourcesettings.v1.Setting() + ); + client.innerApiCalls.getSetting = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSetting( + request, + (err?: Error|null, result?: protos.google.cloud.resourcesettings.v1.ISetting|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getSetting as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSetting as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSetting with error', async () => { + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcesettings.v1.GetSettingRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcesettings.v1.GetSettingRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getSetting = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getSetting(request), expectedError); + const actualRequest = (client.innerApiCalls.getSetting as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSetting as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSetting with closed client', async () => { + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcesettings.v1.GetSettingRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcesettings.v1.GetSettingRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getSetting(request), expectedError); + }); + }); + + describe('updateSetting', () => { + it('invokes updateSetting without error', async () => { + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcesettings.v1.UpdateSettingRequest() + ); + request.setting ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcesettings.v1.UpdateSettingRequest', ['setting', 'name']); + request.setting.name = defaultValue1; + const expectedHeaderRequestParams = `setting.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.resourcesettings.v1.Setting() + ); + client.innerApiCalls.updateSetting = stubSimpleCall(expectedResponse); + const [response] = await client.updateSetting(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateSetting as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateSetting as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateSetting without error using callback', async () => { + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcesettings.v1.UpdateSettingRequest() + ); + request.setting ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcesettings.v1.UpdateSettingRequest', ['setting', 'name']); + request.setting.name = defaultValue1; + const expectedHeaderRequestParams = `setting.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.resourcesettings.v1.Setting() + ); + client.innerApiCalls.updateSetting = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateSetting( + request, + (err?: Error|null, result?: protos.google.cloud.resourcesettings.v1.ISetting|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateSetting as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateSetting as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateSetting with error', async () => { + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcesettings.v1.UpdateSettingRequest() + ); + request.setting ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcesettings.v1.UpdateSettingRequest', ['setting', 'name']); + request.setting.name = defaultValue1; + const expectedHeaderRequestParams = `setting.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSetting = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateSetting(request), expectedError); + const actualRequest = (client.innerApiCalls.updateSetting as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateSetting as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateSetting with closed client', async () => { + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcesettings.v1.UpdateSettingRequest() + ); + request.setting ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcesettings.v1.UpdateSettingRequest', ['setting', 'name']); + request.setting.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateSetting(request), expectedError); + }); + }); + + describe('listSettings', () => { + it('invokes listSettings without error', async () => { + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcesettings.v1.ListSettingsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcesettings.v1.ListSettingsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), + generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), + generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), + ]; + client.innerApiCalls.listSettings = stubSimpleCall(expectedResponse); + const [response] = await client.listSettings(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listSettings as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSettings as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSettings without error using callback', async () => { + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcesettings.v1.ListSettingsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcesettings.v1.ListSettingsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), + generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), + generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), + ]; + client.innerApiCalls.listSettings = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listSettings( + request, + (err?: Error|null, result?: protos.google.cloud.resourcesettings.v1.ISetting[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listSettings as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSettings as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSettings with error', async () => { + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcesettings.v1.ListSettingsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcesettings.v1.ListSettingsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listSettings = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listSettings(request), expectedError); + const actualRequest = (client.innerApiCalls.listSettings as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSettings as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSettingsStream without error', async () => { + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcesettings.v1.ListSettingsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcesettings.v1.ListSettingsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), + generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), + generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), + ]; + client.descriptors.page.listSettings.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listSettingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcesettings.v1.Setting[] = []; + stream.on('data', (response: protos.google.cloud.resourcesettings.v1.Setting) => { + 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.listSettings.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listSettings, request)); + assert( + (client.descriptors.page.listSettings.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listSettingsStream with error', async () => { + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcesettings.v1.ListSettingsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcesettings.v1.ListSettingsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSettings.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listSettingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcesettings.v1.Setting[] = []; + stream.on('data', (response: protos.google.cloud.resourcesettings.v1.Setting) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listSettings.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listSettings, request)); + assert( + (client.descriptors.page.listSettings.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listSettings without error', async () => { + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcesettings.v1.ListSettingsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcesettings.v1.ListSettingsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), + generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), + generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), + ]; + client.descriptors.page.listSettings.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.resourcesettings.v1.ISetting[] = []; + const iterable = client.listSettingsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listSettings.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listSettings.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listSettings with error', async () => { + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.resourcesettings.v1.ListSettingsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.resourcesettings.v1.ListSettingsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSettings.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listSettingsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.resourcesettings.v1.ISetting[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listSettings.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listSettings.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('folderSettingName', () => { + const fakePath = "/rendered/path/folderSettingName"; + const expectedParameters = { + folder: "folderValue", + setting_name: "settingNameValue", + }; + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderSettingNamePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderSettingNamePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderSettingNamePath', () => { + const result = client.folderSettingNamePath("folderValue", "settingNameValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderSettingNamePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderSettingNameName', () => { + const result = client.matchFolderFromFolderSettingNameName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderSettingNamePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSettingNameFromFolderSettingNameName', () => { + const result = client.matchSettingNameFromFolderSettingNameName(fakePath); + assert.strictEqual(result, "settingNameValue"); + assert((client.pathTemplates.folderSettingNamePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organizationSettingName', () => { + const fakePath = "/rendered/path/organizationSettingName"; + const expectedParameters = { + organization: "organizationValue", + setting_name: "settingNameValue", + }; + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationSettingNamePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationSettingNamePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationSettingNamePath', () => { + const result = client.organizationSettingNamePath("organizationValue", "settingNameValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationSettingNamePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationSettingNameName', () => { + const result = client.matchOrganizationFromOrganizationSettingNameName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationSettingNamePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSettingNameFromOrganizationSettingNameName', () => { + const result = client.matchSettingNameFromOrganizationSettingNameName(fakePath); + assert.strictEqual(result, "settingNameValue"); + assert((client.pathTemplates.organizationSettingNamePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectNumberSettingName', () => { + const fakePath = "/rendered/path/projectNumberSettingName"; + const expectedParameters = { + project_number: "projectNumberValue", + setting_name: "settingNameValue", + }; + const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectNumberSettingNamePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectNumberSettingNamePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectNumberSettingNamePath', () => { + const result = client.projectNumberSettingNamePath("projectNumberValue", "settingNameValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectNumberSettingNamePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectNumberFromProjectNumberSettingNameName', () => { + const result = client.matchProjectNumberFromProjectNumberSettingNameName(fakePath); + assert.strictEqual(result, "projectNumberValue"); + assert((client.pathTemplates.projectNumberSettingNamePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSettingNameFromProjectNumberSettingNameName', () => { + const result = client.matchSettingNameFromProjectNumberSettingNameName(fakePath); + assert.strictEqual(result, "settingNameValue"); + assert((client.pathTemplates.projectNumberSettingNamePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/tsconfig.json b/owl-bot-staging/google-cloud-resourcesettings/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/webpack.config.js b/owl-bot-staging/google-cloud-resourcesettings/v1/webpack.config.js new file mode 100644 index 00000000000..af213ce887e --- /dev/null +++ b/owl-bot-staging/google-cloud-resourcesettings/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'ResourceSettingsService', + filename: './resource-settings-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/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/package.json b/owl-bot-staging/google-cloud-retail/v2/package.json new file mode 100644 index 00000000000..335f43fc78d --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/package.json @@ -0,0 +1,66 @@ +{ + "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", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} 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..f8df0337665 --- /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 = ['abc','def'] + /** + * 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..67f7afe6761 --- /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 = [1,2,3,4] + /** + * 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 = [1,2,3,4] + + // 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..37d00508561 --- /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 = ['abc','def'] + /** + * 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..1e766bf21ae --- /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 = [1,2,3,4] + /** + * 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..b949bfd3d29 --- /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 = ['abc','def'] + /** + * 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..eaf4e9abc2d --- /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 = ['abc','def'] + /** + * 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..c7524d4299c --- /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 = [1,2,3,4] + /** + * 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 = ['abc','def'] + /** + * 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 = ['abc','def'] + /** + * 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 = [1,2,3,4] + /** + * 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..dd09fa6d712 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_client.ts @@ -0,0 +1,2207 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.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 protos.google.cloud.retail.v2.Catalog|Catalog} to update. + * + * If the caller does not have permission to update the + * {@link protos.google.cloud.retail.v2.Catalog|Catalog}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * + * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2.Catalog|Catalog}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2.SearchService.Search|SearchService.Search}, + * {@link protos.google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct}, + * {@link protos.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 protos.google.cloud.retail.v2.SearchRequest.branch|SearchRequest.branch} to + * `projects/* /locations/* /catalogs/* /branches/default_branch` is equivalent + * to setting + * {@link protos.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 protos.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 protos.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 protos.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 protos.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 protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2.GetDefaultBranchResponse|GetDefaultBranchResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2.CompletionConfig|CompletionConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2.CompletionConfig|CompletionConfig} + * to update. + * + * If the caller does not have permission to update the + * {@link protos.google.cloud.retail.v2.CompletionConfig|CompletionConfig}, then a + * PERMISSION_DENIED error is returned. + * + * If the {@link protos.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 protos.google.cloud.retail.v2.CompletionConfig|CompletionConfig} to update. The + * following are the only supported fields: + * + * * {@link protos.google.cloud.retail.v2.CompletionConfig.matching_order|CompletionConfig.matching_order} + * * {@link protos.google.cloud.retail.v2.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions} + * * {@link protos.google.cloud.retail.v2.CompletionConfig.min_prefix_length|CompletionConfig.min_prefix_length} + * * {@link protos.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 protos.google.cloud.retail.v2.CompletionConfig|CompletionConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2.AttributesConfig|AttributesConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2.AttributesConfig|AttributesConfig} + * to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link protos.google.cloud.retail.v2.AttributesConfig|AttributesConfig} to update. The + * following is the only supported field: + * + * * {@link protos.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 protos.google.cloud.retail.v2.AttributesConfig|AttributesConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} to the + * {@link protos.google.cloud.retail.v2.AttributesConfig|AttributesConfig}. + * + * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2.AttributesConfig|AttributesConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} from the + * {@link protos.google.cloud.retail.v2.AttributesConfig|AttributesConfig}. + * + * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2.AttributesConfig|AttributesConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} in the + * {@link protos.google.cloud.retail.v2.AttributesConfig|AttributesConfig} by updating the + * catalog attribute with the same + * {@link protos.google.cloud.retail.v2.CatalogAttribute.key|CatalogAttribute.key}. + * + * If the {@link protos.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 protos.google.cloud.retail.v2.CatalogAttribute|CatalogAttribute}. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link protos.google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} to update. The + * following are NOT supported: + * + * * {@link protos.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 protos.google.cloud.retail.v2.AttributesConfig|AttributesConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..780b15b73b5 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/completion_service_client.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. ** + +/* 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.CompleteQueryResponse|CompleteQueryResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..307b1c502b0 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_client.ts @@ -0,0 +1,1546 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.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 protos.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 protos.google.cloud.retail.v2.Control|Control}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2.Control|Control} cannot be set to a different + * oneof field, if so an INVALID_ARGUMENT is returned. If the + * {@link protos.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 protos.google.cloud.retail.v2.Control|Control} to update. The following are NOT + * supported: + * + * * {@link protos.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 protos.google.cloud.retail.v2.Control|Control}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2.Control|Control}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..5fe8ba017bc --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_client.ts @@ -0,0 +1,1796 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.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 protos.google.cloud.retail.v2.Model|Model}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2.Model|Model}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2.Model|Model}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2.Model|Model}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..7e9fa1fd3f3 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/prediction_service_client.ts @@ -0,0 +1,1222 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id} or + * {@link protos.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 protos.google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id} to a + * random unique ID and leave + * {@link protos.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 protos.google.cloud.retail.v2.PredictResponse|PredictResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..fe3971c01f3 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/product_service_client.ts @@ -0,0 +1,2835 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 protos.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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.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 protos.google.cloud.retail.v2.Product|Product} to create. + * @param {string} request.productId + * Required. The ID to use for the {@link protos.google.cloud.retail.v2.Product|Product}, + * which will become the final component of the + * {@link protos.google.cloud.retail.v2.Product.name|Product.name}. + * + * If the caller does not have permission to create the + * {@link protos.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 protos.google.cloud.retail.v2.Product|Product}s with the same + * {@link protos.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 protos.google.cloud.retail.v2.Product|Product}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * + * If the requested {@link protos.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 protos.google.cloud.retail.v2.Product|Product}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * + * If the {@link protos.google.cloud.retail.v2.Product|Product} to update does not exist + * and + * {@link protos.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 protos.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 protos.google.cloud.retail.v2.Product|Product} is not + * found, a new {@link protos.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 protos.google.cloud.retail.v2.Product|Product}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * + * If the {@link protos.google.cloud.retail.v2.Product|Product} to delete does not exist, + * a NOT_FOUND error is returned. + * + * The {@link protos.google.cloud.retail.v2.Product|Product} to delete can neither be a + * {@link protos.google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link protos.google.cloud.retail.v2.Product|Product} member nor a + * {@link protos.google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link protos.google.cloud.retail.v2.Product|Product} with more than one + * {@link protos.google.cloud.retail.v2.Product.Type.VARIANT|variants}. Otherwise, an + * INVALID_ARGUMENT error is returned. + * + * All inventory information for the named + * {@link protos.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 protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.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 protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2.Product|Product} queried by + * {@link protos.google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link protos.google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. + * + * When inventory is updated with + * {@link protos.google.cloud.retail.v2.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link protos.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 protos.google.cloud.retail.v2.ProductService.CreateProduct|ProductService.CreateProduct} + * or + * {@link protos.google.cloud.retail.v2.ProductService.UpdateProduct|ProductService.UpdateProduct} + * request. + * + * If no inventory fields are set in + * {@link protos.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 protos.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 protos.google.cloud.retail.v2.ProductService.SetInventory|ProductService.SetInventory}, + * {@link protos.google.cloud.retail.v2.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}, + * and + * {@link protos.google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. + * + * The returned {@link protos.google.longrunning.Operation|Operation}s is obsolete after + * one day, and the {@link protos.google.longrunning.Operations.GetOperation|GetOperation} + * API returns `NOT_FOUND` afterwards. + * + * If conflicting updates are issued, the + * {@link protos.google.longrunning.Operation|Operation}s associated with the stale + * updates are not marked as {@link protos.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 protos.google.cloud.retail.v2.Product.price_info|Product.price_info} + * * {@link protos.google.cloud.retail.v2.Product.availability|Product.availability} + * * {@link protos.google.cloud.retail.v2.Product.available_quantity|Product.available_quantity} + * * {@link protos.google.cloud.retail.v2.Product.fulfillment_info|Product.fulfillment_info} + * The updated inventory fields must be specified in + * {@link protos.google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}. + * + * If + * {@link protos.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 protos.google.cloud.retail.v2.Product|Product} named in + * {@link protos.google.cloud.retail.v2.Product.name|Product.name}, regardless of whether + * or not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link protos.google.cloud.retail.v2.Product|Product} to update does not have + * existing inventory information, the provided inventory information will be + * inserted. + * + * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types and corresponding place IDs + * to update in + * {@link protos.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 protos.google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types to clear in + * {@link protos.google.cloud.retail.v2.Product.fulfillment_info|SetInventoryRequest.inventory.fulfillment_info} + * * Checks that only the desired fulfillment info types have empty + * {@link protos.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 protos.google.cloud.retail.v2.Product.price_info|Product.price_info} + * * {@link protos.google.cloud.retail.v2.Product.availability|Product.availability} + * * {@link protos.google.cloud.retail.v2.Product.available_quantity|Product.available_quantity} + * * {@link protos.google.cloud.retail.v2.Product.fulfillment_info|Product.fulfillment_info} + * + * If a full overwrite of inventory information while ignoring timestamps is + * needed, + * {@link protos.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 protos.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 protos.google.cloud.retail.v2.Product|Product} with name + * {@link protos.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 protos.google.cloud.retail.v2.Product|Product} is created. If set to + * false, a NOT_FOUND error is returned if the + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.google.cloud.retail.v2.ProductService.AddLocalInventories|ProductService.AddLocalInventories} + * method instead of + * {@link protos.google.cloud.retail.v2.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}. + * {@link protos.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 protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link protos.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 protos.google.cloud.retail.v2.Product|Product} queried by + * {@link protos.google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link protos.google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. + * + * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link protos.google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.FulfillmentInfo.type|Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.Product|Product} is created. If set to false, a + * NOT_FOUND error is returned if the + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.google.cloud.retail.v2.ProductService.RemoveLocalInventories|ProductService.RemoveLocalInventories} + * method instead of + * {@link protos.google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. + * {@link protos.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 protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link protos.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 protos.google.cloud.retail.v2.Product|Product} queried by + * {@link protos.google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link protos.google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. + * + * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link protos.google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.FulfillmentInfo.type|Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.Product|Product} is created. If set to false, a + * NOT_FOUND error is returned if the + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2.Product|Product} queried by + * {@link protos.google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link protos.google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. + * + * Local inventory information can only be modified using this method. + * {@link protos.google.cloud.retail.v2.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link protos.google.cloud.retail.v2.ProductService.UpdateProduct|ProductService.UpdateProduct} + * has no effect on local inventories. + * + * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link protos.google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.Product|Product} is + * created. If set to false, a NOT_FOUND error is returned if the + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.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 protos.google.cloud.retail.v2.Product|Product} queried by + * {@link protos.google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link protos.google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. + * + * Local inventory information can only be removed using this method. + * {@link protos.google.cloud.retail.v2.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link protos.google.cloud.retail.v2.ProductService.UpdateProduct|ProductService.UpdateProduct} + * has no effect on local inventories. + * + * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link protos.google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.Product|Product} is created. If set to false, a + * NOT_FOUND error is returned if the + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.google.cloud.retail.v2.ListProductsRequest.filter|filter} is unset. + * * List {@link protos.google.cloud.retail.v2.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link protos.google.cloud.retail.v2.Product|Product}s sharing the same + * {@link protos.google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link protos.google.cloud.retail.v2.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link protos.google.cloud.retail.v2.Product|Product}s bundled in a + * {@link protos.google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link protos.google.cloud.retail.v2.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link protos.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 protos.google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link protos.google.cloud.retail.v2.Product|Product} or + * {@link protos.google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link protos.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 protos.google.cloud.retail.v2.Product|Product} to return in the + * responses. If not set or empty, the following fields are returned: + * + * * {@link protos.google.cloud.retail.v2.Product.name|Product.name} + * * {@link protos.google.cloud.retail.v2.Product.id|Product.id} + * * {@link protos.google.cloud.retail.v2.Product.title|Product.title} + * * {@link protos.google.cloud.retail.v2.Product.uri|Product.uri} + * * {@link protos.google.cloud.retail.v2.Product.images|Product.images} + * * {@link protos.google.cloud.retail.v2.Product.price_info|Product.price_info} + * * {@link protos.google.cloud.retail.v2.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.google.cloud.retail.v2.ListProductsRequest.filter|filter} is unset. + * * List {@link protos.google.cloud.retail.v2.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link protos.google.cloud.retail.v2.Product|Product}s sharing the same + * {@link protos.google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link protos.google.cloud.retail.v2.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link protos.google.cloud.retail.v2.Product|Product}s bundled in a + * {@link protos.google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link protos.google.cloud.retail.v2.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link protos.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 protos.google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link protos.google.cloud.retail.v2.Product|Product} or + * {@link protos.google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link protos.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 protos.google.cloud.retail.v2.Product|Product} to return in the + * responses. If not set or empty, the following fields are returned: + * + * * {@link protos.google.cloud.retail.v2.Product.name|Product.name} + * * {@link protos.google.cloud.retail.v2.Product.id|Product.id} + * * {@link protos.google.cloud.retail.v2.Product.title|Product.title} + * * {@link protos.google.cloud.retail.v2.Product.uri|Product.uri} + * * {@link protos.google.cloud.retail.v2.Product.images|Product.images} + * * {@link protos.google.cloud.retail.v2.Product.price_info|Product.price_info} + * * {@link protos.google.cloud.retail.v2.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.google.cloud.retail.v2.ListProductsRequest.filter|filter} is unset. + * * List {@link protos.google.cloud.retail.v2.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link protos.google.cloud.retail.v2.Product|Product}s sharing the same + * {@link protos.google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link protos.google.cloud.retail.v2.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link protos.google.cloud.retail.v2.Product|Product}s bundled in a + * {@link protos.google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link protos.google.cloud.retail.v2.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link protos.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 protos.google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link protos.google.cloud.retail.v2.Product|Product} or + * {@link protos.google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link protos.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 protos.google.cloud.retail.v2.Product|Product} to return in the + * responses. If not set or empty, the following fields are returned: + * + * * {@link protos.google.cloud.retail.v2.Product.name|Product.name} + * * {@link protos.google.cloud.retail.v2.Product.id|Product.id} + * * {@link protos.google.cloud.retail.v2.Product.title|Product.title} + * * {@link protos.google.cloud.retail.v2.Product.uri|Product.uri} + * * {@link protos.google.cloud.retail.v2.Product.images|Product.images} + * * {@link protos.google.cloud.retail.v2.Product.price_info|Product.price_info} + * * {@link protos.google.cloud.retail.v2.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..8555ebfd641 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/search_service_client.ts @@ -0,0 +1,2037 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.google.cloud.retail.v2.SearchRequest.filter|filter} and + * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2.SearchService.Search|SearchService.Search} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.google.cloud.retail.v2.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and + * {@link protos.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 protos.google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link protos.google.cloud.retail.v2.Product|Product}s attributes, + * {@link protos.google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo} or + * {@link protos.google.cloud.retail.v2.LocalInventory|LocalInventory}s attributes. The + * attributes from all the matching + * {@link protos.google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link protos.google.cloud.retail.v2.Product|Product}s or + * {@link protos.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 protos.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 protos.google.cloud.retail.v2.LocalInventory.attributes|Product.local_inventories.attributes} + * map. + * * attributes.key, where key is any key in the + * {@link protos.google.cloud.retail.v2.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.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 protos.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 protos.google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link protos.google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link protos.google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.google.cloud.retail.v2.SearchRequest.filter|filter} and + * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2.SearchService.Search|SearchService.Search} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.google.cloud.retail.v2.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and + * {@link protos.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 protos.google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link protos.google.cloud.retail.v2.Product|Product}s attributes, + * {@link protos.google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo} or + * {@link protos.google.cloud.retail.v2.LocalInventory|LocalInventory}s attributes. The + * attributes from all the matching + * {@link protos.google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link protos.google.cloud.retail.v2.Product|Product}s or + * {@link protos.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 protos.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 protos.google.cloud.retail.v2.LocalInventory.attributes|Product.local_inventories.attributes} + * map. + * * attributes.key, where key is any key in the + * {@link protos.google.cloud.retail.v2.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.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 protos.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 protos.google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link protos.google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link protos.google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.google.cloud.retail.v2.SearchRequest.filter|filter} and + * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2.SearchService.Search|SearchService.Search} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.google.cloud.retail.v2.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and + * {@link protos.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 protos.google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link protos.google.cloud.retail.v2.Product|Product}s attributes, + * {@link protos.google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo} or + * {@link protos.google.cloud.retail.v2.LocalInventory|LocalInventory}s attributes. The + * attributes from all the matching + * {@link protos.google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link protos.google.cloud.retail.v2.Product|Product}s or + * {@link protos.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 protos.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 protos.google.cloud.retail.v2.LocalInventory.attributes|Product.local_inventories.attributes} + * map. + * * attributes.key, where key is any key in the + * {@link protos.google.cloud.retail.v2.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.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 protos.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 protos.google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link protos.google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link protos.google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link protos.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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..1a8cf6cd5b9 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_client.ts @@ -0,0 +1,1681 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.google.cloud.retail.v2.ServingConfig|ServingConfig}s are + * allowed in a {@link protos.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 protos.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 protos.google.cloud.retail.v2.ServingConfig|ServingConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2.ServingConfig|ServingConfig} to update. The + * following are NOT supported: + * + * * {@link protos.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 protos.google.cloud.retail.v2.ServingConfig|ServingConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2.ServingConfig|ServingConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2.ServingConfig|ServingConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2.ServingConfig|ServingConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..d59e333bbfd --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/user_event_service_client.ts @@ -0,0 +1,1548 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.google.cloud.retail.v2.UserEvent|UserEvent}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.api.HttpBody|HttpBody}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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/package.json b/owl-bot-staging/google-cloud-retail/v2alpha/package.json new file mode 100644 index 00000000000..60fb03c0056 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/package.json @@ -0,0 +1,67 @@ +{ + "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", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} 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..6d0ce2f5084 --- /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 = ['abc','def'] + + // 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..80b9515dc7c --- /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 = ['abc','def'] + /** + * 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..7ba158c314b --- /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 = [1,2,3,4] + /** + * 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 = [1,2,3,4] + + // 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..8bb159be5a5 --- /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 = ['abc','def'] + /** + * 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..e7bc30ee253 --- /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 = [1,2,3,4] + /** + * 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..7bfafee6dd3 --- /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 = ['abc','def'] + /** + * 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..88e315f9fad --- /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 = ['abc','def'] + /** + * 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..d3b029b917d --- /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 = [1,2,3,4] + /** + * 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 = ['abc','def'] + /** + * 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 = ['abc','def'] + /** + * 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 = [1,2,3,4] + /** + * 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..9e42d95478e --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_client.ts @@ -0,0 +1,2352 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.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 protos.google.cloud.retail.v2alpha.Catalog|Catalog} to update. + * + * If the caller does not have permission to update the + * {@link protos.google.cloud.retail.v2alpha.Catalog|Catalog}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.Catalog|Catalog}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search}, + * {@link protos.google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct}, + * {@link protos.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 protos.google.cloud.retail.v2alpha.SearchRequest.branch|SearchRequest.branch} to + * `projects/* /locations/* /catalogs/* /branches/default_branch` is equivalent + * to setting + * {@link protos.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 protos.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 protos.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 protos.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 protos.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 protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2alpha.GetDefaultBranchResponse|GetDefaultBranchResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig} to update. + * + * If the caller does not have permission to update the + * {@link protos.google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig}, then a + * PERMISSION_DENIED error is returned. + * + * If the {@link protos.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 protos.google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig} to update. + * The following are the only supported fields: + * + * * {@link protos.google.cloud.retail.v2alpha.CompletionConfig.matching_order|CompletionConfig.matching_order} + * * {@link protos.google.cloud.retail.v2alpha.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions} + * * {@link protos.google.cloud.retail.v2alpha.CompletionConfig.min_prefix_length|CompletionConfig.min_prefix_length} + * * {@link protos.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 protos.google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig} to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link protos.google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig} to update. + * The following is the only supported field: + * + * * {@link protos.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 protos.google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to the + * {@link protos.google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. + * + * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} from the + * {@link protos.google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. + * + * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute}s from the + * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.BatchRemoveCatalogAttributesResponse|BatchRemoveCatalogAttributesResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} in the + * {@link protos.google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig} by + * updating the catalog attribute with the same + * {@link protos.google.cloud.retail.v2alpha.CatalogAttribute.key|CatalogAttribute.key}. + * + * If the {@link protos.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 protos.google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute}. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link protos.google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to update. + * The following are NOT supported: + * + * * {@link protos.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 protos.google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..d6262741b81 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/completion_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/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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.CompleteQueryResponse|CompleteQueryResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..e242ee0aaab --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/control_service_client.ts @@ -0,0 +1,1611 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.Control|Control}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2alpha.Control|Control} cannot be set to a different + * oneof field, if so an INVALID_ARGUMENT is returned. If the + * {@link protos.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 protos.google.cloud.retail.v2alpha.Control|Control} to update. The following are + * NOT supported: + * + * * {@link protos.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 protos.google.cloud.retail.v2alpha.Control|Control}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2alpha.Control|Control}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..02b2f50fec3 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_client.ts @@ -0,0 +1,1350 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink}s + * under the specified parent {@link protos.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 protos.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksResponse|ListMerchantCenterAccountLinksResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink}. + * If the + * {@link protos.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 protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink} + * to create. + * + * If the caller does not have permission to create the + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..db6d53a4210 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_client.ts @@ -0,0 +1,1862 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.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 protos.google.cloud.retail.v2alpha.Model|Model}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2alpha.Model|Model}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2alpha.Model|Model}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2alpha.Model|Model}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..875ef80e1ee --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_client.ts @@ -0,0 +1,1287 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id} or + * {@link protos.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 protos.google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id} to + * a random unique ID and leave + * {@link protos.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 protos.google.cloud.retail.v2alpha.PredictResponse|PredictResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..e4560c639df --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/product_service_client.ts @@ -0,0 +1,3109 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 protos.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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product} to create. + * @param {string} request.productId + * Required. The ID to use for the + * {@link protos.google.cloud.retail.v2alpha.Product|Product}, which will become the final + * component of the {@link protos.google.cloud.retail.v2alpha.Product.name|Product.name}. + * + * If the caller does not have permission to create the + * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product}s with the same + * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * + * If the requested {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link protos.google.cloud.retail.v2alpha.Product|Product} to update does not + * exist and + * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product} is + * not found, a new {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link protos.google.cloud.retail.v2alpha.Product|Product} to delete does not + * exist, a NOT_FOUND error is returned. + * + * The {@link protos.google.cloud.retail.v2alpha.Product|Product} to delete can neither be + * a + * {@link protos.google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link protos.google.cloud.retail.v2alpha.Product|Product} member nor a + * {@link protos.google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link protos.google.cloud.retail.v2alpha.Product|Product} with more than one + * {@link protos.google.cloud.retail.v2alpha.Product.Type.VARIANT|variants}. Otherwise, an + * INVALID_ARGUMENT error is returned. + * + * All inventory information for the named + * {@link protos.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 protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product}s, this operation could take + * hours to complete. Before the operation completes, some + * {@link protos.google.cloud.retail.v2alpha.Product|Product}s may still be returned by + * {@link protos.google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link protos.google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. + * + * Depending on the number of {@link protos.google.cloud.retail.v2alpha.Product|Product}s, + * this operation could take hours to complete. To get a sample of + * {@link protos.google.cloud.retail.v2alpha.Product|Product}s that would be deleted, set + * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.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 protos.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 protos.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 protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product} queried by + * {@link protos.google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link protos.google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. + * + * When inventory is updated with + * {@link protos.google.cloud.retail.v2alpha.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link protos.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 protos.google.cloud.retail.v2alpha.ProductService.CreateProduct|ProductService.CreateProduct} + * or + * {@link protos.google.cloud.retail.v2alpha.ProductService.UpdateProduct|ProductService.UpdateProduct} + * request. + * + * If no inventory fields are set in + * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.ProductService.SetInventory|ProductService.SetInventory}, + * {@link protos.google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}, + * and + * {@link protos.google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. + * + * The returned {@link protos.google.longrunning.Operation|Operation}s is obsolete after + * one day, and the {@link protos.google.longrunning.Operations.GetOperation|GetOperation} + * API returns `NOT_FOUND` afterwards. + * + * If conflicting updates are issued, the + * {@link protos.google.longrunning.Operation|Operation}s associated with the stale + * updates are not marked as {@link protos.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 protos.google.cloud.retail.v2alpha.Product.price_info|Product.price_info} + * * {@link protos.google.cloud.retail.v2alpha.Product.availability|Product.availability} + * * {@link protos.google.cloud.retail.v2alpha.Product.available_quantity|Product.available_quantity} + * * {@link protos.google.cloud.retail.v2alpha.Product.fulfillment_info|Product.fulfillment_info} + * The updated inventory fields must be specified in + * {@link protos.google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}. + * + * If + * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product} named in + * {@link protos.google.cloud.retail.v2alpha.Product.name|Product.name}, regardless of + * whether or not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link protos.google.cloud.retail.v2alpha.Product|Product} to update does not + * have existing inventory information, the provided inventory information + * will be inserted. + * + * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types and corresponding place IDs + * to update in + * {@link protos.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 protos.google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types to clear in + * {@link protos.google.cloud.retail.v2alpha.Product.fulfillment_info|SetInventoryRequest.inventory.fulfillment_info} + * * Checks that only the desired fulfillment info types have empty + * {@link protos.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 protos.google.cloud.retail.v2alpha.Product.price_info|Product.price_info} + * * {@link protos.google.cloud.retail.v2alpha.Product.availability|Product.availability} + * * {@link protos.google.cloud.retail.v2alpha.Product.available_quantity|Product.available_quantity} + * * {@link protos.google.cloud.retail.v2alpha.Product.fulfillment_info|Product.fulfillment_info} + * + * If a full overwrite of inventory information while ignoring timestamps is + * needed, + * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product} with + * name {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product} is created. If set + * to false, a NOT_FOUND error is returned if the + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.google.cloud.retail.v2alpha.ProductService.AddLocalInventories|ProductService.AddLocalInventories} + * method instead of + * {@link protos.google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}. + * {@link protos.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 protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product} queried by + * {@link protos.google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link protos.google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. + * + * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link protos.google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories|ProductService.RemoveLocalInventories} + * method instead of + * {@link protos.google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. + * {@link protos.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 protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product} queried by + * {@link protos.google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link protos.google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. + * + * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link protos.google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product} queried by + * {@link protos.google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link protos.google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. + * + * Local inventory information can only be modified using this method. + * {@link protos.google.cloud.retail.v2alpha.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link protos.google.cloud.retail.v2alpha.ProductService.UpdateProduct|ProductService.UpdateProduct} + * has no effect on local inventories. + * + * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link protos.google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product} queried by + * {@link protos.google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link protos.google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. + * + * Local inventory information can only be removed using this method. + * {@link protos.google.cloud.retail.v2alpha.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link protos.google.cloud.retail.v2alpha.ProductService.UpdateProduct|ProductService.UpdateProduct} + * has no effect on local inventories. + * + * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link protos.google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.google.cloud.retail.v2alpha.ListProductsRequest.filter|filter} is unset. + * * List + * {@link protos.google.cloud.retail.v2alpha.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link protos.google.cloud.retail.v2alpha.Product|Product}s sharing the same + * {@link protos.google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link protos.google.cloud.retail.v2alpha.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link protos.google.cloud.retail.v2alpha.Product|Product}s bundled in a + * {@link protos.google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link protos.google.cloud.retail.v2alpha.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link protos.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 protos.google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link protos.google.cloud.retail.v2alpha.Product|Product} or + * {@link protos.google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link protos.google.cloud.retail.v2alpha.Product.name|Product.name} + * * {@link protos.google.cloud.retail.v2alpha.Product.id|Product.id} + * * {@link protos.google.cloud.retail.v2alpha.Product.title|Product.title} + * * {@link protos.google.cloud.retail.v2alpha.Product.uri|Product.uri} + * * {@link protos.google.cloud.retail.v2alpha.Product.images|Product.images} + * * {@link protos.google.cloud.retail.v2alpha.Product.price_info|Product.price_info} + * * {@link protos.google.cloud.retail.v2alpha.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link protos.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 protos.google.cloud.retail.v2alpha.ListProductsRequest.page_token|page_token} is + * empty, + * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.google.cloud.retail.v2alpha.ListProductsRequest.filter|filter} is unset. + * * List + * {@link protos.google.cloud.retail.v2alpha.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link protos.google.cloud.retail.v2alpha.Product|Product}s sharing the same + * {@link protos.google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link protos.google.cloud.retail.v2alpha.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link protos.google.cloud.retail.v2alpha.Product|Product}s bundled in a + * {@link protos.google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link protos.google.cloud.retail.v2alpha.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link protos.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 protos.google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link protos.google.cloud.retail.v2alpha.Product|Product} or + * {@link protos.google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link protos.google.cloud.retail.v2alpha.Product.name|Product.name} + * * {@link protos.google.cloud.retail.v2alpha.Product.id|Product.id} + * * {@link protos.google.cloud.retail.v2alpha.Product.title|Product.title} + * * {@link protos.google.cloud.retail.v2alpha.Product.uri|Product.uri} + * * {@link protos.google.cloud.retail.v2alpha.Product.images|Product.images} + * * {@link protos.google.cloud.retail.v2alpha.Product.price_info|Product.price_info} + * * {@link protos.google.cloud.retail.v2alpha.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link protos.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 protos.google.cloud.retail.v2alpha.ListProductsRequest.page_token|page_token} is + * empty, + * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.google.cloud.retail.v2alpha.ListProductsRequest.filter|filter} is unset. + * * List + * {@link protos.google.cloud.retail.v2alpha.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link protos.google.cloud.retail.v2alpha.Product|Product}s sharing the same + * {@link protos.google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link protos.google.cloud.retail.v2alpha.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link protos.google.cloud.retail.v2alpha.Product|Product}s bundled in a + * {@link protos.google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link protos.google.cloud.retail.v2alpha.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link protos.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 protos.google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link protos.google.cloud.retail.v2alpha.Product|Product} or + * {@link protos.google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link protos.google.cloud.retail.v2alpha.Product.name|Product.name} + * * {@link protos.google.cloud.retail.v2alpha.Product.id|Product.id} + * * {@link protos.google.cloud.retail.v2alpha.Product.title|Product.title} + * * {@link protos.google.cloud.retail.v2alpha.Product.uri|Product.uri} + * * {@link protos.google.cloud.retail.v2alpha.Product.images|Product.images} + * * {@link protos.google.cloud.retail.v2alpha.Product.price_info|Product.price_info} + * * {@link protos.google.cloud.retail.v2alpha.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link protos.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 protos.google.cloud.retail.v2alpha.ListProductsRequest.page_token|page_token} is + * empty, + * {@link protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..6f0eec9ff46 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/search_service_client.ts @@ -0,0 +1,2159 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.google.cloud.retail.v2alpha.SearchRequest.filter|filter} and + * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product}s deemed by the API as + * relevant) in search results. This field is only considered if + * {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and + * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link protos.google.cloud.retail.v2alpha.Product|Product}s attributes, + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo} or + * {@link protos.google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link protos.google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link protos.google.cloud.retail.v2alpha.Product|Product}s or + * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.LocalInventory.attributes|Product.local_inventories.attributes} + * map. + * * attributes.key, where key is any key in the + * {@link protos.google.cloud.retail.v2alpha.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link protos.google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link protos.google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.google.cloud.retail.v2alpha.SearchRequest.filter|filter} and + * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product}s deemed by the API as + * relevant) in search results. This field is only considered if + * {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and + * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link protos.google.cloud.retail.v2alpha.Product|Product}s attributes, + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo} or + * {@link protos.google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link protos.google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link protos.google.cloud.retail.v2alpha.Product|Product}s or + * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.LocalInventory.attributes|Product.local_inventories.attributes} + * map. + * * attributes.key, where key is any key in the + * {@link protos.google.cloud.retail.v2alpha.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link protos.google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link protos.google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.google.cloud.retail.v2alpha.SearchRequest.filter|filter} and + * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product}s deemed by the API as + * relevant) in search results. This field is only considered if + * {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and + * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link protos.google.cloud.retail.v2alpha.Product|Product}s attributes, + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo} or + * {@link protos.google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link protos.google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link protos.google.cloud.retail.v2alpha.Product|Product}s or + * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.LocalInventory.attributes|Product.local_inventories.attributes} + * map. + * * attributes.key, where key is any key in the + * {@link protos.google.cloud.retail.v2alpha.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link protos.google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link protos.google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link protos.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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..a0ce43a9353 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_client.ts @@ -0,0 +1,1747 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.google.cloud.retail.v2alpha.ServingConfig|ServingConfig}s are allowed in + * a {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.ServingConfig|ServingConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2alpha.ServingConfig|ServingConfig} to update. The + * following are NOT supported: + * + * * {@link protos.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 protos.google.cloud.retail.v2alpha.ServingConfig|ServingConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2alpha.ServingConfig|ServingConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2alpha.ServingConfig|ServingConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2alpha.ServingConfig|ServingConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..1eae60d1e83 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_client.ts @@ -0,0 +1,1614 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.google.cloud.retail.v2alpha.UserEvent|UserEvent}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.api.HttpBody|HttpBody}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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/package.json b/owl-bot-staging/google-cloud-retail/v2beta/package.json new file mode 100644 index 00000000000..335f43fc78d --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/package.json @@ -0,0 +1,66 @@ +{ + "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", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} 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..58aa90a124d --- /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 = ['abc','def'] + + // 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..9ba73ea0ac7 --- /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 = ['abc','def'] + /** + * 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..391aae2f11d --- /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 = [1,2,3,4] + /** + * 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 = [1,2,3,4] + + // 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..db6d3860c4f --- /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 = ['abc','def'] + /** + * 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..55407ab7f73 --- /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 = [1,2,3,4] + /** + * 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..e830998feff --- /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 = ['abc','def'] + /** + * 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..ecb44e4a246 --- /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 = ['abc','def'] + /** + * 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..bab66266868 --- /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 = [1,2,3,4] + /** + * 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 = ['abc','def'] + /** + * 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 = ['abc','def'] + /** + * 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 = [1,2,3,4] + /** + * 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..331b285dced --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_client.ts @@ -0,0 +1,2287 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.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 protos.google.cloud.retail.v2beta.Catalog|Catalog} to update. + * + * If the caller does not have permission to update the + * {@link protos.google.cloud.retail.v2beta.Catalog|Catalog}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.Catalog|Catalog}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2beta.SearchService.Search|SearchService.Search}, + * {@link protos.google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct}, + * {@link protos.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 protos.google.cloud.retail.v2beta.SearchRequest.branch|SearchRequest.branch} to + * `projects/* /locations/* /catalogs/* /branches/default_branch` is equivalent + * to setting + * {@link protos.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 protos.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 protos.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 protos.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 protos.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 protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2beta.GetDefaultBranchResponse|GetDefaultBranchResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2beta.CompletionConfig|CompletionConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2beta.CompletionConfig|CompletionConfig} to update. + * + * If the caller does not have permission to update the + * {@link protos.google.cloud.retail.v2beta.CompletionConfig|CompletionConfig}, then a + * PERMISSION_DENIED error is returned. + * + * If the {@link protos.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 protos.google.cloud.retail.v2beta.CompletionConfig|CompletionConfig} to update. + * The following are the only supported fields: + * + * * {@link protos.google.cloud.retail.v2beta.CompletionConfig.matching_order|CompletionConfig.matching_order} + * * {@link protos.google.cloud.retail.v2beta.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions} + * * {@link protos.google.cloud.retail.v2beta.CompletionConfig.min_prefix_length|CompletionConfig.min_prefix_length} + * * {@link protos.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 protos.google.cloud.retail.v2beta.CompletionConfig|CompletionConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2beta.AttributesConfig|AttributesConfig} to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link protos.google.cloud.retail.v2beta.AttributesConfig|AttributesConfig} to update. + * The following is the only supported field: + * + * * {@link protos.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 protos.google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to the + * {@link protos.google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. + * + * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} from the + * {@link protos.google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. + * + * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute}s from the + * {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse|BatchRemoveCatalogAttributesResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} in the + * {@link protos.google.cloud.retail.v2beta.AttributesConfig|AttributesConfig} by updating + * the catalog attribute with the same + * {@link protos.google.cloud.retail.v2beta.CatalogAttribute.key|CatalogAttribute.key}. + * + * If the {@link protos.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 protos.google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute}. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link protos.google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to update. + * The following are NOT supported: + * + * * {@link protos.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 protos.google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..063dc71473d --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/completion_service_client.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. ** + +/* 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.CompleteQueryResponse|CompleteQueryResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..2a269bb1548 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/control_service_client.ts @@ -0,0 +1,1546 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.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 protos.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 protos.google.cloud.retail.v2beta.Control|Control}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2beta.Control|Control} cannot be set to a different + * oneof field, if so an INVALID_ARGUMENT is returned. If the + * {@link protos.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 protos.google.cloud.retail.v2beta.Control|Control} to update. The following are + * NOT supported: + * + * * {@link protos.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 protos.google.cloud.retail.v2beta.Control|Control}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2beta.Control|Control}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..ce6c0b4b219 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_client.ts @@ -0,0 +1,1797 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.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 protos.google.cloud.retail.v2beta.Model|Model}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2beta.Model|Model}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2beta.Model|Model}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2beta.Model|Model}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..6ca97c6d694 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/prediction_service_client.ts @@ -0,0 +1,1222 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id} or + * {@link protos.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 protos.google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id} to + * a random unique ID and leave + * {@link protos.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 protos.google.cloud.retail.v2beta.PredictResponse|PredictResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..fa54c373837 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/product_service_client.ts @@ -0,0 +1,2843 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 protos.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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.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 protos.google.cloud.retail.v2beta.Product|Product} to create. + * @param {string} request.productId + * Required. The ID to use for the + * {@link protos.google.cloud.retail.v2beta.Product|Product}, which will become the final + * component of the {@link protos.google.cloud.retail.v2beta.Product.name|Product.name}. + * + * If the caller does not have permission to create the + * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product}s with the same + * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * + * If the requested {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link protos.google.cloud.retail.v2beta.Product|Product} to update does not + * exist and + * {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.Product|Product} is + * not found, a new {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link protos.google.cloud.retail.v2beta.Product|Product} to delete does not + * exist, a NOT_FOUND error is returned. + * + * The {@link protos.google.cloud.retail.v2beta.Product|Product} to delete can neither be + * a + * {@link protos.google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link protos.google.cloud.retail.v2beta.Product|Product} member nor a + * {@link protos.google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link protos.google.cloud.retail.v2beta.Product|Product} with more than one + * {@link protos.google.cloud.retail.v2beta.Product.Type.VARIANT|variants}. Otherwise, an + * INVALID_ARGUMENT error is returned. + * + * All inventory information for the named + * {@link protos.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 protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 protos.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 protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2beta.Product|Product} queried by + * {@link protos.google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link protos.google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. + * + * When inventory is updated with + * {@link protos.google.cloud.retail.v2beta.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link protos.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 protos.google.cloud.retail.v2beta.ProductService.CreateProduct|ProductService.CreateProduct} + * or + * {@link protos.google.cloud.retail.v2beta.ProductService.UpdateProduct|ProductService.UpdateProduct} + * request. + * + * If no inventory fields are set in + * {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.ProductService.SetInventory|ProductService.SetInventory}, + * {@link protos.google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}, + * and + * {@link protos.google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. + * + * The returned {@link protos.google.longrunning.Operation|Operation}s is obsolete after + * one day, and the {@link protos.google.longrunning.Operations.GetOperation|GetOperation} + * API returns `NOT_FOUND` afterwards. + * + * If conflicting updates are issued, the + * {@link protos.google.longrunning.Operation|Operation}s associated with the stale + * updates are not marked as {@link protos.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 protos.google.cloud.retail.v2beta.Product.price_info|Product.price_info} + * * {@link protos.google.cloud.retail.v2beta.Product.availability|Product.availability} + * * {@link protos.google.cloud.retail.v2beta.Product.available_quantity|Product.available_quantity} + * * {@link protos.google.cloud.retail.v2beta.Product.fulfillment_info|Product.fulfillment_info} + * The updated inventory fields must be specified in + * {@link protos.google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}. + * + * If + * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product} named in + * {@link protos.google.cloud.retail.v2beta.Product.name|Product.name}, regardless of + * whether or not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link protos.google.cloud.retail.v2beta.Product|Product} to update does not + * have existing inventory information, the provided inventory information + * will be inserted. + * + * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types and corresponding place IDs + * to update in + * {@link protos.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 protos.google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types to clear in + * {@link protos.google.cloud.retail.v2beta.Product.fulfillment_info|SetInventoryRequest.inventory.fulfillment_info} + * * Checks that only the desired fulfillment info types have empty + * {@link protos.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 protos.google.cloud.retail.v2beta.Product.price_info|Product.price_info} + * * {@link protos.google.cloud.retail.v2beta.Product.availability|Product.availability} + * * {@link protos.google.cloud.retail.v2beta.Product.available_quantity|Product.available_quantity} + * * {@link protos.google.cloud.retail.v2beta.Product.fulfillment_info|Product.fulfillment_info} + * + * If a full overwrite of inventory information while ignoring timestamps is + * needed, + * {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.Product|Product} with + * name {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product} is created. If set + * to false, a NOT_FOUND error is returned if the + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.google.cloud.retail.v2beta.ProductService.AddLocalInventories|ProductService.AddLocalInventories} + * method instead of + * {@link protos.google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}. + * {@link protos.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 protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product} queried by + * {@link protos.google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link protos.google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. + * + * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link protos.google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.FulfillmentInfo.type|Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.google.cloud.retail.v2beta.ProductService.RemoveLocalInventories|ProductService.RemoveLocalInventories} + * method instead of + * {@link protos.google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. + * {@link protos.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 protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product} queried by + * {@link protos.google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link protos.google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. + * + * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link protos.google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.FulfillmentInfo.type|Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2beta.Product|Product} queried by + * {@link protos.google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link protos.google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. + * + * Local inventory information can only be modified using this method. + * {@link protos.google.cloud.retail.v2beta.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link protos.google.cloud.retail.v2beta.ProductService.UpdateProduct|ProductService.UpdateProduct} + * has no effect on local inventories. + * + * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link protos.google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.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 protos.google.cloud.retail.v2beta.Product|Product} queried by + * {@link protos.google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link protos.google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. + * + * Local inventory information can only be removed using this method. + * {@link protos.google.cloud.retail.v2beta.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link protos.google.cloud.retail.v2beta.ProductService.UpdateProduct|ProductService.UpdateProduct} + * has no effect on local inventories. + * + * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link protos.google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.google.cloud.retail.v2beta.ListProductsRequest.filter|filter} is unset. + * * List + * {@link protos.google.cloud.retail.v2beta.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link protos.google.cloud.retail.v2beta.Product|Product}s sharing the same + * {@link protos.google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link protos.google.cloud.retail.v2beta.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link protos.google.cloud.retail.v2beta.Product|Product}s bundled in a + * {@link protos.google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link protos.google.cloud.retail.v2beta.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link protos.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 protos.google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link protos.google.cloud.retail.v2beta.Product|Product} or + * {@link protos.google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link protos.google.cloud.retail.v2beta.Product.name|Product.name} + * * {@link protos.google.cloud.retail.v2beta.Product.id|Product.id} + * * {@link protos.google.cloud.retail.v2beta.Product.title|Product.title} + * * {@link protos.google.cloud.retail.v2beta.Product.uri|Product.uri} + * * {@link protos.google.cloud.retail.v2beta.Product.images|Product.images} + * * {@link protos.google.cloud.retail.v2beta.Product.price_info|Product.price_info} + * * {@link protos.google.cloud.retail.v2beta.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2beta.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.google.cloud.retail.v2beta.ListProductsRequest.filter|filter} is unset. + * * List + * {@link protos.google.cloud.retail.v2beta.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link protos.google.cloud.retail.v2beta.Product|Product}s sharing the same + * {@link protos.google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link protos.google.cloud.retail.v2beta.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link protos.google.cloud.retail.v2beta.Product|Product}s bundled in a + * {@link protos.google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link protos.google.cloud.retail.v2beta.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link protos.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 protos.google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link protos.google.cloud.retail.v2beta.Product|Product} or + * {@link protos.google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link protos.google.cloud.retail.v2beta.Product.name|Product.name} + * * {@link protos.google.cloud.retail.v2beta.Product.id|Product.id} + * * {@link protos.google.cloud.retail.v2beta.Product.title|Product.title} + * * {@link protos.google.cloud.retail.v2beta.Product.uri|Product.uri} + * * {@link protos.google.cloud.retail.v2beta.Product.images|Product.images} + * * {@link protos.google.cloud.retail.v2beta.Product.price_info|Product.price_info} + * * {@link protos.google.cloud.retail.v2beta.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 protos.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 protos.google.cloud.retail.v2beta.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.google.cloud.retail.v2beta.ListProductsRequest.filter|filter} is unset. + * * List + * {@link protos.google.cloud.retail.v2beta.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link protos.google.cloud.retail.v2beta.Product|Product}s sharing the same + * {@link protos.google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link protos.google.cloud.retail.v2beta.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link protos.google.cloud.retail.v2beta.Product|Product}s bundled in a + * {@link protos.google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link protos.google.cloud.retail.v2beta.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link protos.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 protos.google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link protos.google.cloud.retail.v2beta.Product|Product} or + * {@link protos.google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link protos.google.cloud.retail.v2beta.Product.name|Product.name} + * * {@link protos.google.cloud.retail.v2beta.Product.id|Product.id} + * * {@link protos.google.cloud.retail.v2beta.Product.title|Product.title} + * * {@link protos.google.cloud.retail.v2beta.Product.uri|Product.uri} + * * {@link protos.google.cloud.retail.v2beta.Product.images|Product.images} + * * {@link protos.google.cloud.retail.v2beta.Product.price_info|Product.price_info} + * * {@link protos.google.cloud.retail.v2beta.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..9abe414e819 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/search_service_client.ts @@ -0,0 +1,2037 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.google.cloud.retail.v2beta.SearchRequest.filter|filter} and + * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if + * {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and + * {@link protos.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 protos.google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link protos.google.cloud.retail.v2beta.Product|Product}s attributes, + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo} or + * {@link protos.google.cloud.retail.v2beta.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link protos.google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link protos.google.cloud.retail.v2beta.Product|Product}s or + * {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.LocalInventory.attributes|Product.local_inventories.attributes} + * map. + * * attributes.key, where key is any key in the + * {@link protos.google.cloud.retail.v2beta.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link protos.google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link protos.google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.google.cloud.retail.v2beta.SearchRequest.filter|filter} and + * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if + * {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and + * {@link protos.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 protos.google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link protos.google.cloud.retail.v2beta.Product|Product}s attributes, + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo} or + * {@link protos.google.cloud.retail.v2beta.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link protos.google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link protos.google.cloud.retail.v2beta.Product|Product}s or + * {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.LocalInventory.attributes|Product.local_inventories.attributes} + * map. + * * attributes.key, where key is any key in the + * {@link protos.google.cloud.retail.v2beta.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link protos.google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link protos.google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.google.cloud.retail.v2beta.SearchRequest.filter|filter} and + * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link protos.google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if + * {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and + * {@link protos.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 protos.google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link protos.google.cloud.retail.v2beta.Product|Product}s attributes, + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo} or + * {@link protos.google.cloud.retail.v2beta.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link protos.google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link protos.google.cloud.retail.v2beta.Product|Product}s or + * {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.LocalInventory.attributes|Product.local_inventories.attributes} + * map. + * * attributes.key, where key is any key in the + * {@link protos.google.cloud.retail.v2beta.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link protos.google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link protos.google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link protos.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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..cec43f73cdd --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/serving_config_service_client.ts @@ -0,0 +1,1681 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.google.cloud.retail.v2beta.ServingConfig|ServingConfig}s + * are allowed in a {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.ServingConfig|ServingConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2beta.ServingConfig|ServingConfig} to update. The + * following are NOT supported: + * + * * {@link protos.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 protos.google.cloud.retail.v2beta.ServingConfig|ServingConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2beta.ServingConfig|ServingConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2beta.ServingConfig|ServingConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.cloud.retail.v2beta.ServingConfig|ServingConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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..03f11d11e7d --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/user_event_service_client.ts @@ -0,0 +1,1549 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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: true}, 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 { + 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) { + 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 protos.google.cloud.retail.v2beta.UserEvent|UserEvent}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.google.api.HttpBody|HttpBody}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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', +}; diff --git a/owl-bot-staging/google-cloud-run/v2/.eslintignore b/owl-bot-staging/google-cloud-run/v2/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-run/v2/.eslintrc.json b/owl-bot-staging/google-cloud-run/v2/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-run/v2/.gitignore b/owl-bot-staging/google-cloud-run/v2/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-run/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-run/v2/.jsdoc.js b/owl-bot-staging/google-cloud-run/v2/.jsdoc.js new file mode 100644 index 00000000000..fd5db45a599 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/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/run', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-run/v2/.mocharc.js b/owl-bot-staging/google-cloud-run/v2/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/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-run/v2/.prettierrc.js b/owl-bot-staging/google-cloud-run/v2/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-run/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-run/v2/README.md b/owl-bot-staging/google-cloud-run/v2/README.md new file mode 100644 index 00000000000..bc79325d121 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/README.md @@ -0,0 +1 @@ +Run: Nodejs Client diff --git a/owl-bot-staging/google-cloud-run/v2/package.json b/owl-bot-staging/google-cloud-run/v2/package.json new file mode 100644 index 00000000000..88d18b9fdcc --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/package.json @@ -0,0 +1,62 @@ +{ + "name": "@google-cloud/run", + "version": "0.1.0", + "description": "Run client for Node.js", + "repository": "googleapis/nodejs-run", + "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 run", + "run", + "executions", + "jobs", + "revisions", + "services", + "tasks" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/condition.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/condition.proto new file mode 100644 index 00000000000..cb6680a61b5 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/condition.proto @@ -0,0 +1,209 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.run.v2; + +import "google/protobuf/timestamp.proto"; + +option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; +option java_multiple_files = true; +option java_outer_classname = "ConditionProto"; +option java_package = "com.google.cloud.run.v2"; + +// Defines a status condition for a resource. +message Condition { + // Represents the possible Condition states. + enum State { + // The default value. This value is used if the state is omitted. + STATE_UNSPECIFIED = 0; + + // Transient state: Reconciliation has not started yet. + CONDITION_PENDING = 1; + + // Transient state: reconciliation is still in progress. + CONDITION_RECONCILING = 2; + + // Terminal state: Reconciliation did not succeed. + CONDITION_FAILED = 3; + + // Terminal state: Reconciliation completed successfully. + CONDITION_SUCCEEDED = 4; + } + + // Represents the severity of the condition failures. + enum Severity { + // Unspecified severity + SEVERITY_UNSPECIFIED = 0; + + // Error severity. + ERROR = 1; + + // Warning severity. + WARNING = 2; + + // Info severity. + INFO = 3; + } + + // Reasons common to all types of conditions. + enum CommonReason { + // Default value. + COMMON_REASON_UNDEFINED = 0; + + // Reason unknown. Further details will be in message. + UNKNOWN = 1; + + // Revision creation process failed. + REVISION_FAILED = 3; + + // Timed out waiting for completion. + PROGRESS_DEADLINE_EXCEEDED = 4; + + // The container image path is incorrect. + CONTAINER_MISSING = 6; + + // Insufficient permissions on the container image. + CONTAINER_PERMISSION_DENIED = 7; + + // Container image is not authorized by policy. + CONTAINER_IMAGE_UNAUTHORIZED = 8; + + // Container image policy authorization check failed. + CONTAINER_IMAGE_AUTHORIZATION_CHECK_FAILED = 9; + + // Insufficient permissions on encryption key. + ENCRYPTION_KEY_PERMISSION_DENIED = 10; + + // Permission check on encryption key failed. + ENCRYPTION_KEY_CHECK_FAILED = 11; + + // At least one Access check on secrets failed. + SECRETS_ACCESS_CHECK_FAILED = 12; + + // Waiting for operation to complete. + WAITING_FOR_OPERATION = 13; + + // System will retry immediately. + IMMEDIATE_RETRY = 14; + + // System will retry later; current attempt failed. + POSTPONED_RETRY = 15; + + // An internal error occurred. Further information may be in the message. + INTERNAL = 16; + } + + // Reasons specific to Revision resource. + enum RevisionReason { + // Default value. + REVISION_REASON_UNDEFINED = 0; + + // Revision in Pending state. + PENDING = 1; + + // Revision is in Reserve state. + RESERVE = 2; + + // Revision is Retired. + RETIRED = 3; + + // Revision is being retired. + RETIRING = 4; + + // Revision is being recreated. + RECREATING = 5; + + // There was a health check error. + HEALTH_CHECK_CONTAINER_ERROR = 6; + + // Health check failed due to user error from customized path of the + // container. System will retry. + CUSTOMIZED_PATH_RESPONSE_PENDING = 7; + + // A revision with min_instance_count > 0 was created and is reserved, but + // it was not configured to serve traffic, so it's not live. This can also + // happen momentarily during traffic migration. + MIN_INSTANCES_NOT_PROVISIONED = 8; + + // The maximum allowed number of active revisions has been reached. + ACTIVE_REVISION_LIMIT_REACHED = 9; + + // There was no deployment defined. + // This value is no longer used, but Services created in older versions of + // the API might contain this value. + NO_DEPLOYMENT = 10; + + // A revision's container has no port specified since the revision is of a + // manually scaled service with 0 instance count + HEALTH_CHECK_SKIPPED = 11; + + // A revision with min_instance_count > 0 was created and is waiting for + // enough instances to begin a traffic migration. + MIN_INSTANCES_WARMING = 12; + } + + // Reasons specific to Execution resource. + enum ExecutionReason { + // Default value. + EXECUTION_REASON_UNDEFINED = 0; + + // Internal system error getting execution status. System will retry. + JOB_STATUS_SERVICE_POLLING_ERROR = 1; + + // A task reached its retry limit and the last attempt failed due to the + // user container exiting with a non-zero exit code. + NON_ZERO_EXIT_CODE = 2; + + // The execution was cancelled by users. + CANCELLED = 3; + + // The execution is in the process of being cancelled. + CANCELLING = 4; + } + + // type is used to communicate the status of the reconciliation process. + // See also: + // https://github.com/knative/serving/blob/main/docs/spec/errors.md#error-conditions-and-reporting + // Types common to all resources include: + // * "Ready": True when the Resource is ready. + string type = 1; + + // State of the condition. + State state = 2; + + // Human readable message indicating details about the current status. + string message = 3; + + // Last time the condition transitioned from one status to another. + google.protobuf.Timestamp last_transition_time = 4; + + // How to interpret failures of this condition, one of Error, Warning, Info + Severity severity = 5; + + // The reason for this condition. Depending on the condition type, + // it will populate one of these fields. + // Successful conditions cannot have a reason. + oneof reasons { + // A common (service-level) reason for this condition. + CommonReason reason = 6; + + // A reason for the revision condition. + RevisionReason revision_reason = 9; + + // A reason for the execution condition. + ExecutionReason execution_reason = 11; + } +} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/execution.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/execution.proto new file mode 100644 index 00000000000..29b73a232fa --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/execution.proto @@ -0,0 +1,277 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.run.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/launch_stage.proto"; +import "google/api/resource.proto"; +import "google/cloud/run/v2/condition.proto"; +import "google/cloud/run/v2/task_template.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; +option java_multiple_files = true; +option java_outer_classname = "ExecutionProto"; +option java_package = "com.google.cloud.run.v2"; + +// Cloud Run Execution Control Plane API. +service Executions { + option (google.api.default_host) = "run.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Gets information about an Execution. + rpc GetExecution(GetExecutionRequest) returns (Execution) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/jobs/*/executions/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists Executions from a Job. + rpc ListExecutions(ListExecutionsRequest) returns (ListExecutionsResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*/jobs/*}/executions" + }; + option (google.api.method_signature) = "parent"; + } + + // Deletes an Execution. + rpc DeleteExecution(DeleteExecutionRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/jobs/*/executions/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Execution" + metadata_type: "Execution" + }; + } +} + +// Request message for obtaining a Execution by its full name. +message GetExecutionRequest { + // Required. The full name of the Execution. + // Format: + // projects/{project}/locations/{location}/jobs/{job}/executions/{execution}, + // where {project} can be project id or number. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "run.googleapis.com/Execution" } + ]; +} + +// Request message for retrieving a list of Executions. +message ListExecutionsRequest { + // Required. The Execution from which the Executions should be listed. + // To list all Executions across Jobs, use "-" instead of Job name. + // Format: projects/{project}/locations/{location}/jobs/{job}, where {project} + // can be project id or number. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "run.googleapis.com/Execution" + } + ]; + + // Maximum number of Executions to return in this call. + int32 page_size = 2; + + // A page token received from a previous call to ListExecutions. + // All other parameters must match. + string page_token = 3; + + // If true, returns deleted (but unexpired) resources along with active ones. + bool show_deleted = 4; +} + +// Response message containing a list of Executions. +message ListExecutionsResponse { + // The resulting list of Executions. + repeated Execution executions = 1; + + // A token indicating there are more items than page_size. Use it in the next + // ListExecutions request to continue. + string next_page_token = 2; +} + +// Request message for deleting an Execution. +message DeleteExecutionRequest { + // Required. The name of the Execution to delete. + // Format: + // projects/{project}/locations/{location}/jobs/{job}/executions/{execution}, + // where {project} can be project id or number. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "run.googleapis.com/Execution" } + ]; + + // Indicates that the request should be validated without actually + // deleting any resources. + bool validate_only = 2; + + // A system-generated fingerprint for this version of the resource. + // This may be used to detect modification conflict during updates. + string etag = 3; +} + +// Execution represents the configuration of a single execution. A execution an +// immutable resource that references a container image which is run to +// completion. +message Execution { + option (google.api.resource) = { + type: "run.googleapis.com/Execution" + pattern: "projects/{project}/locations/{location}/jobs/{job}/executions/{execution}" + style: DECLARATIVE_FRIENDLY + }; + + // Output only. The unique name of this Execution. + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Server assigned unique identifier for the Execution. The value + // is a UUID4 string and guaranteed to remain unchanged until the resource is + // deleted. + string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A number that monotonically increases every time the user + // modifies the desired state. + int64 generation = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Unstructured key value map that can be used to organize and + // categorize objects. User-provided labels are shared with Google's billing + // system, so they can be used to filter, or break down billing charges by + // team, component, environment, state, etc. For more information, visit + // https://cloud.google.com/resource-manager/docs/creating-managing-labels or + // https://cloud.google.com/run/docs/configuring/labels + map labels = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Unstructured key value map that may + // be set by external tools to store and arbitrary metadata. + // They are not queryable and should be preserved + // when modifying objects. + map annotations = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Represents time when the execution was acknowledged by the + // execution controller. It is not guaranteed to be set in happens-before + // order across separate operations. + google.protobuf.Timestamp create_time = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Represents time when the execution started to run. + // It is not guaranteed to be set in happens-before order across separate + // operations. + google.protobuf.Timestamp start_time = 22 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Represents time when the execution was completed. It is not + // guaranteed to be set in happens-before order across separate operations. + google.protobuf.Timestamp completion_time = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last-modified time. + google.protobuf.Timestamp update_time = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. For a deleted resource, the deletion time. It is only + // populated as a response to a Delete request. + google.protobuf.Timestamp delete_time = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. For a deleted resource, the time after which it will be + // permamently deleted. It is only populated as a response to a Delete + // request. + google.protobuf.Timestamp expire_time = 10 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The least stable launch stage needed to create this resource, as defined by + // [Google Cloud Platform Launch + // Stages](https://cloud.google.com/terms/launch-stages). Cloud Run supports + // `ALPHA`, `BETA`, and `GA`. + //

Note that this value might not be what was used + // as input. For example, if ALPHA was provided as input in the parent + // resource, but only BETA and GA-level features are were, this field will be + // BETA. + google.api.LaunchStage launch_stage = 11; + + // Output only. The name of the parent Job. + string job = 12 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { type: "run.googleapis.com/Job" } + ]; + + // Output only. Specifies the maximum desired number of tasks the execution + // should run at any given time. Must be <= task_count. The actual number of + // tasks running in steady state will be less than this number when + // ((.spec.task_count - .status.successful) < .spec.parallelism), i.e. when + // the work left to do is less than max parallelism. + int32 parallelism = 13 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Specifies the desired number of tasks the execution should + // run. Setting to 1 means that parallelism is limited to 1 and the success of + // that task signals the success of the execution. + int32 task_count = 14 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The template used to create tasks for this execution. + TaskTemplate template = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Indicates whether the resource's reconciliation is still in + // progress. See comments in `Job.reconciling` for additional information on + // reconciliation process in Cloud Run. + bool reconciling = 16 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Condition of this Execution, containing its readiness + // status, and detailed error information in case it did not reach the desired + // state. + repeated Condition conditions = 17 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The generation of this Execution. See comments in + // `reconciling` for additional information on reconciliation process in Cloud + // Run. + int64 observed_generation = 18 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The number of actively running tasks. + int32 running_count = 19 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The number of tasks which reached phase Succeeded. + int32 succeeded_count = 20 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The number of tasks which reached phase Failed. + int32 failed_count = 21 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The number of tasks which reached phase Cancelled. + int32 cancelled_count = 24 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The number of tasks which have retried at least once. + int32 retried_count = 25 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. URI where logs for this execution can be found in Cloud + // Console. + string log_uri = 26 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Reserved for future use. + bool satisfies_pzs = 27 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A system-generated fingerprint for this version of the + // resource. May be used to detect modification conflict during updates. + string etag = 99 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/execution_template.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/execution_template.proto new file mode 100644 index 00000000000..55f465a5f43 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/execution_template.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.run.v2; + +import "google/api/field_behavior.proto"; +import "google/cloud/run/v2/task_template.proto"; + +option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; +option java_multiple_files = true; +option java_outer_classname = "ExecutionTemplateProto"; +option java_package = "com.google.cloud.run.v2"; + +// ExecutionTemplate describes the data an execution should have when created +// from a template. +message ExecutionTemplate { + // Unstructured key value map that can be used to organize and categorize + // objects. + // User-provided labels are shared with Google's billing system, so they can + // be used to filter, or break down billing charges by team, component, + // environment, state, etc. For more information, visit + // https://cloud.google.com/resource-manager/docs/creating-managing-labels or + // https://cloud.google.com/run/docs/configuring/labels. + // + //

Cloud Run API v2 does not support labels with `run.googleapis.com`, + // `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` + // namespaces, and they will be rejected. All system labels in v1 now have a + // corresponding field in v2 ExecutionTemplate. + map labels = 1; + + // Unstructured key value map that may be set by external tools to store and + // arbitrary metadata. They are not queryable and should be preserved + // when modifying objects. + // + //

Cloud Run API v2 does not support annotations with `run.googleapis.com`, + // `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` + // namespaces, and they will be rejected. All system annotations in v1 now + // have a corresponding field in v2 ExecutionTemplate. + // + //

This field follows Kubernetes annotations' namespacing, limits, and + // rules. + map annotations = 2; + + // Specifies the maximum desired number of tasks the execution should run at + // given time. Must be <= task_count. + // When the job is run, if this field is 0 or unset, the maximum possible + // value will be used for that execution. + // The actual number of tasks running in steady state will be less than this + // number when there are fewer tasks waiting to be completed remaining, + // i.e. when the work left to do is less than max parallelism. + int32 parallelism = 3; + + // Specifies the desired number of tasks the execution should run. + // Setting to 1 means that parallelism is limited to 1 and the success of + // that task signals the success of the execution. Defaults to 1. + int32 task_count = 4; + + // Required. Describes the task(s) that will be created when executing an + // execution. + TaskTemplate template = 5 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/job.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/job.proto new file mode 100644 index 00000000000..b180eb50610 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/job.proto @@ -0,0 +1,424 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.run.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/launch_stage.proto"; +import "google/api/resource.proto"; +import "google/cloud/run/v2/condition.proto"; +import "google/cloud/run/v2/execution.proto"; +import "google/cloud/run/v2/execution_template.proto"; +import "google/cloud/run/v2/vendor_settings.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; +option java_multiple_files = true; +option java_outer_classname = "JobProto"; +option java_package = "com.google.cloud.run.v2"; + +// Cloud Run Job Control Plane API. +service Jobs { + option (google.api.default_host) = "run.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a Job. + rpc CreateJob(CreateJobRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*}/jobs" + body: "job" + }; + option (google.api.method_signature) = "parent,job,job_id"; + option (google.longrunning.operation_info) = { + response_type: "Job" + metadata_type: "Job" + }; + } + + // Gets information about a Job. + rpc GetJob(GetJobRequest) returns (Job) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/jobs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists Jobs. + rpc ListJobs(ListJobsRequest) returns (ListJobsResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*}/jobs" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates a Job. + rpc UpdateJob(UpdateJobRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v2/{job.name=projects/*/locations/*/jobs/*}" + body: "job" + }; + option (google.api.method_signature) = "job"; + option (google.longrunning.operation_info) = { + response_type: "Job" + metadata_type: "Job" + }; + } + + // Deletes a Job. + rpc DeleteJob(DeleteJobRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/jobs/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Job" + metadata_type: "Job" + }; + } + + // Triggers creation of a new Execution of this Job. + rpc RunJob(RunJobRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{name=projects/*/locations/*/jobs/*}:run" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Execution" + metadata_type: "Execution" + }; + } + + // Gets the IAM Access Control policy currently in effect for the given Job. + // This result does not include any inherited policies. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) + returns (google.iam.v1.Policy) { + option (google.api.http) = { + get: "/v2/{resource=projects/*/locations/*/jobs/*}:getIamPolicy" + }; + } + + // Sets the IAM Access control policy for the specified Job. Overwrites + // any existing policy. + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) + returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v2/{resource=projects/*/locations/*/jobs/*}:setIamPolicy" + body: "*" + }; + } + + // Returns permissions that a caller has on the specified Project. + // + // There are no permissions required for making this API call. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) + returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v2/{resource=projects/*/locations/*/jobs/*}:testIamPermissions" + body: "*" + }; + } +} + +// Request message for creating a Job. +message CreateJobRequest { + // Required. The location and project in which this Job should be created. + // Format: projects/{project}/locations/{location}, where {project} can be + // project id or number. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { child_type: "run.googleapis.com/Job" } + ]; + + // Required. The Job instance to create. + Job job = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The unique identifier for the Job. The name of the job becomes + // {parent}/jobs/{job_id}. + string job_id = 3 [(google.api.field_behavior) = REQUIRED]; + + // Indicates that the request should be validated and default values + // populated, without persisting the request or creating any resources. + bool validate_only = 4; +} + +// Request message for obtaining a Job by its full name. +message GetJobRequest { + // Required. The full name of the Job. + // Format: projects/{project}/locations/{location}/jobs/{job}, where {project} + // can be project id or number. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "run.googleapis.com/Job" } + ]; +} + +// Request message for updating a Job. +message UpdateJobRequest { + // Required. The Job to be updated. + Job job = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates that the request should be validated and default values + // populated, without persisting the request or updating any resources. + bool validate_only = 3; + + // If set to true, and if the Job does not exist, it will create a new + // one. Caller must have both create and update permissions for this call if + // this is set to true. + bool allow_missing = 4; +} + +// Request message for retrieving a list of Jobs. +message ListJobsRequest { + // Required. The location and project to list resources on. + // Format: projects/{project}/locations/{location}, where {project} can be + // project id or number. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { child_type: "run.googleapis.com/Job" } + ]; + + // Maximum number of Jobs to return in this call. + int32 page_size = 2; + + // A page token received from a previous call to ListJobs. + // All other parameters must match. + string page_token = 3; + + // If true, returns deleted (but unexpired) resources along with active ones. + bool show_deleted = 4; +} + +// Response message containing a list of Jobs. +message ListJobsResponse { + // The resulting list of Jobs. + repeated Job jobs = 1; + + // A token indicating there are more items than page_size. Use it in the next + // ListJobs request to continue. + string next_page_token = 2; +} + +// Request message to delete a Job by its full name. +message DeleteJobRequest { + // Required. The full name of the Job. + // Format: projects/{project}/locations/{location}/jobs/{job}, where {project} + // can be project id or number. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "run.googleapis.com/Job" } + ]; + + // Indicates that the request should be validated without actually + // deleting any resources. + bool validate_only = 3; + + // A system-generated fingerprint for this version of the + // resource. May be used to detect modification conflict during updates. + string etag = 4; +} + +// Request message to create a new Execution of a Job. +message RunJobRequest { + // Required. The full name of the Job. + // Format: projects/{project}/locations/{location}/jobs/{job}, where {project} + // can be project id or number. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "run.googleapis.com/Job" } + ]; + + // Indicates that the request should be validated without actually + // deleting any resources. + bool validate_only = 2; + + // A system-generated fingerprint for this version of the + // resource. May be used to detect modification conflict during updates. + string etag = 3; +} + +// Job represents the configuration of a single job, which references a +// container image that is run to completion. +message Job { + option (google.api.resource) = { + type: "run.googleapis.com/Job" + pattern: "projects/{project}/locations/{location}/jobs/{job}" + style: DECLARATIVE_FRIENDLY + }; + + // The fully qualified name of this Job. + // + // Format: + // projects/{project}/locations/{location}/jobs/{job} + string name = 1; + + // Output only. Server assigned unique identifier for the Execution. The value + // is a UUID4 string and guaranteed to remain unchanged until the resource is + // deleted. + string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A number that monotonically increases every time the user + // modifies the desired state. + int64 generation = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Unstructured key value map that can be used to organize and categorize + // objects. + // User-provided labels are shared with Google's billing system, so they can + // be used to filter, or break down billing charges by team, component, + // environment, state, etc. For more information, visit + // https://cloud.google.com/resource-manager/docs/creating-managing-labels or + // https://cloud.google.com/run/docs/configuring/labels. + // + //

Cloud Run API v2 does not support labels with `run.googleapis.com`, + // `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` + // namespaces, and they will be rejected. All system labels in v1 now have a + // corresponding field in v2 Job. + map labels = 4; + + // Unstructured key value map that may + // be set by external tools to store and arbitrary metadata. + // They are not queryable and should be preserved + // when modifying objects. + // + //

Cloud Run API v2 does not support annotations with `run.googleapis.com`, + // `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` + // namespaces, and they will be rejected on new resources. All system + // annotations in v1 now have a corresponding field in v2 Job. + // + //

This field follows Kubernetes annotations' namespacing, limits, and + // rules. + map annotations = 5; + + // Output only. The creation time. + google.protobuf.Timestamp create_time = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last-modified time. + google.protobuf.Timestamp update_time = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The deletion time. + google.protobuf.Timestamp delete_time = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. For a deleted resource, the time after which it will be + // permamently deleted. + google.protobuf.Timestamp expire_time = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Email address of the authenticated creator. + string creator = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Email address of the last authenticated modifier. + string last_modifier = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Arbitrary identifier for the API client. + string client = 12; + + // Arbitrary version identifier for the API client. + string client_version = 13; + + // The launch stage as defined by [Google Cloud Platform + // Launch Stages](https://cloud.google.com/terms/launch-stages). + // Cloud Run supports `ALPHA`, `BETA`, and `GA`. If no value is specified, GA + // is assumed. + // Set the launch stage to a preview stage on input to allow use of preview + // features in that stage. On read (or output), describes whether the resource + // uses preview features. + //

+ // For example, if ALPHA is provided as input, but only BETA and GA-level + // features are used, this field will be BETA on output. + google.api.LaunchStage launch_stage = 14; + + // Settings for the Binary Authorization feature. + BinaryAuthorization binary_authorization = 15; + + // Required. The template used to create executions for this Job. + ExecutionTemplate template = 16 [(google.api.field_behavior) = REQUIRED]; + + // Output only. The generation of this Job. See comments in `reconciling` for + // additional information on reconciliation process in Cloud Run. + int64 observed_generation = 17 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Condition of this Job, containing its readiness status, + // and detailed error information in case it did not reach the desired state. + Condition terminal_condition = 18 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Conditions of all other associated sub-resources. They + // contain additional diagnostics information in case the Job does not reach + // its desired state. See comments in `reconciling` for additional information + // on reconciliation process in Cloud Run. + repeated Condition conditions = 19 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Number of executions created for this job. + int32 execution_count = 20 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the last created execution. + ExecutionReference latest_created_execution = 22 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Returns true if the Job is currently being acted upon by the + // system to bring it into the desired state. + // + // When a new Job is created, or an existing one is updated, Cloud Run + // will asynchronously perform all necessary steps to bring the Job to the + // desired state. This process is called reconciliation. + // While reconciliation is in process, `observed_generation` and + // `latest_succeeded_execution`, will have transient values that might + // mismatch the intended state: Once reconciliation is over (and this field is + // false), there are two possible outcomes: reconciliation succeeded and the + // state matches the Job, or there was an error, and reconciliation failed. + // This state can be found in `terminal_condition.state`. + // + // If reconciliation succeeded, the following fields will match: + // `observed_generation` and `generation`, `latest_succeeded_execution` and + // `latest_created_execution`. + // + // If reconciliation failed, `observed_generation` and + // `latest_succeeded_execution` will have the state of the last succeeded + // execution or empty for newly created Job. Additional information on the + // failure can be found in `terminal_condition` and `conditions`. + bool reconciling = 23 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Reserved for future use. + bool satisfies_pzs = 25 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A system-generated fingerprint for this version of the + // resource. May be used to detect modification conflict during updates. + string etag = 99 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Reference to an Execution. Use /Executions.GetExecution with the given name +// to get full execution including the latest status. +message ExecutionReference { + // Name of the execution. + string name = 1 [ + (google.api.resource_reference) = { type: "run.googleapis.com/Execution" } + ]; + + // Creation timestamp of the execution. + google.protobuf.Timestamp create_time = 2; + + // Creation timestamp of the execution. + google.protobuf.Timestamp completion_time = 3; +} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/k8s.min.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/k8s.min.proto new file mode 100644 index 00000000000..1d66551ac39 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/k8s.min.proto @@ -0,0 +1,369 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.run.v2; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; +option java_multiple_files = true; +option java_outer_classname = "K8sMinProto"; +option java_package = "com.google.cloud.run.v2"; +option (google.api.resource_definition) = { + type: "cloudkms.googleapis.com/CryptoKey" + pattern: "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}" +}; +option (google.api.resource_definition) = { + type: "secretmanager.googleapis.com/Secret" + pattern: "projects/{project}/secrets/{secret}" +}; +option (google.api.resource_definition) = { + type: "secretmanager.googleapis.com/SecretVersion" + pattern: "projects/{project}/secrets/{secret}/versions/{version}" +}; +option (google.api.resource_definition) = { + type: "vpcaccess.googleapis.com/Connector" + pattern: "projects/{project}/locations/{location}/connectors/{connector}" +}; + +// A single application container. +// This specifies both the container to run, the command to run in the container +// and the arguments to supply to it. +// Note that additional arguments may be supplied by the system to the container +// at runtime. +message Container { + // Name of the container specified as a DNS_LABEL (RFC 1123). + string name = 1; + + // Required. Name of the container image in Dockerhub, Google Artifact + // Registry, or Google Container Registry. If the host is not provided, + // Dockerhub is assumed. + string image = 2 [(google.api.field_behavior) = REQUIRED]; + + // Entrypoint array. Not executed within a shell. + // The docker image's ENTRYPOINT is used if this is not provided. + repeated string command = 3; + + // Arguments to the entrypoint. + // The docker image's CMD is used if this is not provided. + repeated string args = 4; + + // List of environment variables to set in the container. + repeated EnvVar env = 5; + + // Compute Resource requirements by this container. + ResourceRequirements resources = 6; + + // List of ports to expose from the container. Only a single port can be + // specified. The specified ports must be listening on all interfaces + // (0.0.0.0) within the container to be accessible. + // + // If omitted, a port number will be chosen and passed to the container + // through the PORT environment variable for the container to listen on. + repeated ContainerPort ports = 7; + + // Volume to mount into the container's filesystem. + repeated VolumeMount volume_mounts = 8; + + // Container's working directory. + // If not specified, the container runtime's default will be used, which + // might be configured in the container image. + string working_dir = 9; + + // Periodic probe of container liveness. + // Container will be restarted if the probe fails. + Probe liveness_probe = 10; + + // Startup probe of application within the container. + // All other probes are disabled if a startup probe is provided, until it + // succeeds. Container will not be added to service endpoints if the probe + // fails. + Probe startup_probe = 11; +} + +// ResourceRequirements describes the compute resource requirements. +message ResourceRequirements { + // Only ´memory´ and 'cpu' are supported. + // + //

Notes: + // * The only supported values for CPU are '1', '2', '4', and '8'. Setting 4 + // CPU requires at least 2Gi of memory. For more information, go to + // https://cloud.google.com/run/docs/configuring/cpu. + // * For supported 'memory' values and syntax, go to + // https://cloud.google.com/run/docs/configuring/memory-limits + map limits = 1; + + // Determines whether CPU should be throttled or not outside of requests. + bool cpu_idle = 2; + + // Determines whether CPU should be boosted on startup of a new container + // instance above the requested CPU threshold, this can help reduce cold-start + // latency. + bool startup_cpu_boost = 3; +} + +// EnvVar represents an environment variable present in a Container. +message EnvVar { + // Required. Name of the environment variable. Must be a C_IDENTIFIER, and + // mnay not exceed 32768 characters. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + oneof values { + // Variable references $(VAR_NAME) are expanded + // using the previous defined environment variables in the container and + // any route environment variables. If a variable cannot be resolved, + // the reference in the input string will be unchanged. The $(VAR_NAME) + // syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped + // references will never be expanded, regardless of whether the variable + // exists or not. + // Defaults to "", and the maximum length is 32768 bytes. + string value = 2; + + // Source for the environment variable's value. + EnvVarSource value_source = 3; + } +} + +// EnvVarSource represents a source for the value of an EnvVar. +message EnvVarSource { + // Selects a secret and a specific version from Cloud Secret Manager. + SecretKeySelector secret_key_ref = 1; +} + +// SecretEnvVarSource represents a source for the value of an EnvVar. +message SecretKeySelector { + // Required. The name of the secret in Cloud Secret Manager. + // Format: {secret_name} if the secret is in the same project. + // projects/{project}/secrets/{secret_name} if the secret is + // in a different project. + string secret = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "secretmanager.googleapis.com/Secret" + } + ]; + + // The Cloud Secret Manager secret version. + // Can be 'latest' for the latest version, an integer for a specific version, + // or a version alias. + string version = 2 [(google.api.resource_reference) = { + type: "secretmanager.googleapis.com/SecretVersion" + }]; +} + +// ContainerPort represents a network port in a single container. +message ContainerPort { + // If specified, used to specify which protocol to use. + // Allowed values are "http1" and "h2c". + string name = 1; + + // Port number the container listens on. + // This must be a valid TCP port number, 0 < container_port < 65536. + int32 container_port = 3; +} + +// VolumeMount describes a mounting of a Volume within a container. +message VolumeMount { + // Required. This must match the Name of a Volume. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Path within the container at which the volume should be mounted. + // Must not contain ':'. For Cloud SQL volumes, it can be left empty, or must + // otherwise be `/cloudsql`. All instances defined in the Volume will be + // available as `/cloudsql/[instance]`. For more information on Cloud SQL + // volumes, visit https://cloud.google.com/sql/docs/mysql/connect-run + string mount_path = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Volume represents a named volume in a container. +message Volume { + // Required. Volume's name. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + oneof volume_type { + // Secret represents a secret that should populate this volume. + SecretVolumeSource secret = 2; + + // For Cloud SQL volumes, contains the specific instances that should be + // mounted. Visit https://cloud.google.com/sql/docs/mysql/connect-run for + // more information on how to connect Cloud SQL and Cloud Run. + CloudSqlInstance cloud_sql_instance = 3; + } +} + +// The secret's value will be presented as the content of a file whose +// name is defined in the item path. If no items are defined, the name of +// the file is the secret. +message SecretVolumeSource { + // Required. The name of the secret in Cloud Secret Manager. + // Format: {secret} if the secret is in the same project. + // projects/{project}/secrets/{secret} if the secret is + // in a different project. + string secret = 1 [(google.api.field_behavior) = REQUIRED]; + + // If unspecified, the volume will expose a file whose name is the + // secret, relative to VolumeMount.mount_path. + // If specified, the key will be used as the version to fetch from Cloud + // Secret Manager and the path will be the name of the file exposed in the + // volume. When items are defined, they must specify a path and a version. + repeated VersionToPath items = 2; + + // Integer representation of mode bits to use on created files by default. + // Must be a value between 0000 and 0777 (octal), defaulting to 0444. + // Directories within the path are not affected by this setting. + // + // Notes + // + // * Internally, a umask of 0222 will be applied to any non-zero value. + // * This is an integer representation of the mode bits. So, the octal + // integer value should look exactly as the chmod numeric notation with a + // leading zero. Some examples: for chmod 777 (a=rwx), set to 0777 (octal) or + // 511 (base-10). For chmod 640 (u=rw,g=r), set to 0640 (octal) or + // 416 (base-10). For chmod 755 (u=rwx,g=rx,o=rx), set to 0755 (octal) or 493 + // (base-10). + // * This might be in conflict with other options that affect the + // file mode, like fsGroup, and the result can be other mode bits set. + // + // This might be in conflict with other options that affect the + // file mode, like fsGroup, and as a result, other mode bits could be set. + int32 default_mode = 3; +} + +// VersionToPath maps a specific version of a secret to a relative file to mount +// to, relative to VolumeMount's mount_path. +message VersionToPath { + // Required. The relative path of the secret in the container. + string path = 1 [(google.api.field_behavior) = REQUIRED]; + + // The Cloud Secret Manager secret version. + // Can be 'latest' for the latest value, or an integer or a secret alias for a + // specific version. + string version = 2; + + // Integer octal mode bits to use on this file, must be a value between + // 01 and 0777 (octal). If 0 or not set, the Volume's default mode will be + // used. + // + // Notes + // + // * Internally, a umask of 0222 will be applied to any non-zero value. + // * This is an integer representation of the mode bits. So, the octal + // integer value should look exactly as the chmod numeric notation with a + // leading zero. Some examples: for chmod 777 (a=rwx), set to 0777 (octal) or + // 511 (base-10). For chmod 640 (u=rw,g=r), set to 0640 (octal) or + // 416 (base-10). For chmod 755 (u=rwx,g=rx,o=rx), set to 0755 (octal) or 493 + // (base-10). + // * This might be in conflict with other options that affect the + // file mode, like fsGroup, and the result can be other mode bits set. + int32 mode = 3; +} + +// Represents a set of Cloud SQL instances. Each one will be available under +// /cloudsql/[instance]. Visit +// https://cloud.google.com/sql/docs/mysql/connect-run for more information on +// how to connect Cloud SQL and Cloud Run. +message CloudSqlInstance { + // The Cloud SQL instance connection names, as can be found in + // https://console.cloud.google.com/sql/instances. Visit + // https://cloud.google.com/sql/docs/mysql/connect-run for more information on + // how to connect Cloud SQL and Cloud Run. Format: + // {project}:{location}:{instance} + repeated string instances = 1; +} + +// Probe describes a health check to be performed against a container to +// determine whether it is alive or ready to receive traffic. +message Probe { + // Number of seconds after the container has started before the probe is + // initiated. + // Defaults to 0 seconds. Minimum value is 0. Maximum value for liveness probe + // is 3600. Maximum value for startup probe is 240. + int32 initial_delay_seconds = 1; + + // Number of seconds after which the probe times out. + // Defaults to 1 second. Minimum value is 1. Maximum value is 3600. + // Must be smaller than period_seconds. + int32 timeout_seconds = 2; + + // How often (in seconds) to perform the probe. + // Default to 10 seconds. Minimum value is 1. Maximum value for liveness probe + // is 3600. Maximum value for startup probe is 240. + // Must be greater or equal than timeout_seconds. + int32 period_seconds = 3; + + // Minimum consecutive failures for the probe to be considered failed after + // having succeeded. Defaults to 3. Minimum value is 1. + int32 failure_threshold = 4; + + oneof probe_type { + // HTTPGet specifies the http request to perform. + // Exactly one of httpGet, tcpSocket, or grpc must be specified. + HTTPGetAction http_get = 5; + + // TCPSocket specifies an action involving a TCP port. + // Exactly one of httpGet, tcpSocket, or grpc must be specified. + TCPSocketAction tcp_socket = 6; + + // GRPC specifies an action involving a gRPC port. + // Exactly one of httpGet, tcpSocket, or grpc must be specified. + GRPCAction grpc = 7; + } +} + +// HTTPGetAction describes an action based on HTTP Get requests. +message HTTPGetAction { + // Path to access on the HTTP server. Defaults to '/'. + string path = 1; + + // Custom headers to set in the request. HTTP allows repeated headers. + repeated HTTPHeader http_headers = 4; + + // Port number to access on the container. Must be in the range 1 to 65535. + // If not specified, defaults to the exposed port of the container, which is + // the value of container.ports[0].containerPort. + int32 port = 5; +} + +// HTTPHeader describes a custom header to be used in HTTP probes +message HTTPHeader { + // Required. The header field name + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // The header field value + string value = 2; +} + +// TCPSocketAction describes an action based on opening a socket +message TCPSocketAction { + // Port number to access on the container. Must be in the range 1 to 65535. + // If not specified, defaults to the exposed port of the container, which is + // the value of container.ports[0].containerPort. + int32 port = 1; +} + +// GRPCAction describes an action involving a GRPC port. +message GRPCAction { + // Port number of the gRPC service. Number must be in the range 1 to 65535. + // If not specified, defaults to the exposed port of the container, which is + // the value of container.ports[0].containerPort. + int32 port = 1; + + // Service is the name of the service to place in the gRPC HealthCheckRequest + // (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). If + // this is not specified, the default behavior is defined by gRPC. + string service = 2; +} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/revision.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/revision.proto new file mode 100644 index 00000000000..bdaf9e73992 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/revision.proto @@ -0,0 +1,299 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.run.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/launch_stage.proto"; +import "google/api/resource.proto"; +import "google/api/routing.proto"; +import "google/cloud/run/v2/condition.proto"; +import "google/cloud/run/v2/k8s.min.proto"; +import "google/cloud/run/v2/vendor_settings.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; +option java_multiple_files = true; +option java_outer_classname = "RevisionProto"; +option java_package = "com.google.cloud.run.v2"; + +// Cloud Run Revision Control Plane API. +service Revisions { + option (google.api.default_host) = "run.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Gets information about a Revision. + rpc GetRevision(GetRevisionRequest) returns (Revision) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/services/*/revisions/*}" + }; + option (google.api.routing) = { + routing_parameters { + field: "name" + path_template: "projects/*/locations/{location=*}/**" + } + }; + option (google.api.method_signature) = "name"; + } + + // Lists Revisions from a given Service, or from a given location. + rpc ListRevisions(ListRevisionsRequest) returns (ListRevisionsResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*/services/*}/revisions" + }; + option (google.api.routing) = { + routing_parameters { + field: "parent" + path_template: "projects/*/locations/{location=*}/**" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Deletes a Revision. + rpc DeleteRevision(DeleteRevisionRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/services/*/revisions/*}" + }; + option (google.api.routing) = { + routing_parameters { + field: "name" + path_template: "projects/*/locations/{location=*}/**" + } + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Revision" + metadata_type: "Revision" + }; + } +} + +// Request message for obtaining a Revision by its full name. +message GetRevisionRequest { + // Required. The full name of the Revision. + // Format: + // projects/{project}/locations/{location}/services/{service}/revisions/{revision} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "run.googleapis.com/Revision" } + ]; +} + +// Request message for retrieving a list of Revisions. +message ListRevisionsRequest { + // Required. The Service from which the Revisions should be listed. + // To list all Revisions across Services, use "-" instead of Service name. + // Format: + // projects/{project}/locations/{location}/services/{service} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "run.googleapis.com/Revision" + } + ]; + + // Maximum number of revisions to return in this call. + int32 page_size = 2; + + // A page token received from a previous call to ListRevisions. + // All other parameters must match. + string page_token = 3; + + // If true, returns deleted (but unexpired) resources along with active ones. + bool show_deleted = 4; +} + +// Response message containing a list of Revisions. +message ListRevisionsResponse { + // The resulting list of Revisions. + repeated Revision revisions = 1; + + // A token indicating there are more items than page_size. Use it in the next + // ListRevisions request to continue. + string next_page_token = 2; +} + +// Request message for deleting a retired Revision. +// Revision lifecycle is usually managed by making changes to the parent +// Service. Only retired revisions can be deleted with this API. +message DeleteRevisionRequest { + // Required. The name of the Revision to delete. + // Format: + // projects/{project}/locations/{location}/services/{service}/revisions/{revision} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "run.googleapis.com/Revision" } + ]; + + // Indicates that the request should be validated without actually + // deleting any resources. + bool validate_only = 2; + + // A system-generated fingerprint for this version of the + // resource. This may be used to detect modification conflict during updates. + string etag = 3; +} + +// A Revision is an immutable snapshot of code and configuration. A Revision +// references a container image. Revisions are only created by updates to its +// parent Service. +message Revision { + option (google.api.resource) = { + type: "run.googleapis.com/Revision" + pattern: "projects/{project}/locations/{location}/services/{service}/revisions/{revision}" + style: DECLARATIVE_FRIENDLY + }; + + // Output only. The unique name of this Revision. + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Server assigned unique identifier for the Revision. The value + // is a UUID4 string and guaranteed to remain unchanged until the resource is + // deleted. + string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A number that monotonically increases every time the user + // modifies the desired state. + int64 generation = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Unstructured key value map that can be used to organize and + // categorize objects. User-provided labels are shared with Google's billing + // system, so they can be used to filter, or break down billing charges by + // team, component, environment, state, etc. For more information, visit + // https://cloud.google.com/resource-manager/docs/creating-managing-labels or + // https://cloud.google.com/run/docs/configuring/labels. + map labels = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Unstructured key value map that may + // be set by external tools to store and arbitrary metadata. + // They are not queryable and should be preserved + // when modifying objects. + map annotations = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The creation time. + google.protobuf.Timestamp create_time = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last-modified time. + google.protobuf.Timestamp update_time = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. For a deleted resource, the deletion time. It is only + // populated as a response to a Delete request. + google.protobuf.Timestamp delete_time = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. For a deleted resource, the time after which it will be + // permamently deleted. It is only populated as a response to a Delete + // request. + google.protobuf.Timestamp expire_time = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The least stable launch stage needed to create this resource, as defined by + // [Google Cloud Platform Launch + // Stages](https://cloud.google.com/terms/launch-stages). Cloud Run supports + // `ALPHA`, `BETA`, and `GA`. + //

Note that this value might not be what was used + // as input. For example, if ALPHA was provided as input in the parent + // resource, but only BETA and GA-level features are were, this field will be + // BETA. + google.api.LaunchStage launch_stage = 10; + + // Output only. The name of the parent service. + string service = 11 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { type: "run.googleapis.com/Service" } + ]; + + // Scaling settings for this revision. + RevisionScaling scaling = 12; + + // VPC Access configuration for this Revision. For more information, visit + // https://cloud.google.com/run/docs/configuring/connecting-vpc. + VpcAccess vpc_access = 13; + + // Sets the maximum number of requests that each serving instance can receive. + int32 max_instance_request_concurrency = 34; + + // Max allowed time for an instance to respond to a request. + google.protobuf.Duration timeout = 15; + + // Email address of the IAM service account associated with the revision of + // the service. The service account represents the identity of the running + // revision, and determines what permissions the revision has. + string service_account = 16; + + // Holds the single container that defines the unit of execution for this + // Revision. + repeated Container containers = 17; + + // A list of Volumes to make available to containers. + repeated Volume volumes = 18; + + // The execution environment being used to host this Revision. + ExecutionEnvironment execution_environment = 20; + + // A reference to a customer managed encryption key (CMEK) to use to encrypt + // this container image. For more information, go to + // https://cloud.google.com/run/docs/securing/using-cmek + string encryption_key = 21 [(google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKey" + }]; + + // The action to take if the encryption key is revoked. + EncryptionKeyRevocationAction encryption_key_revocation_action = 23; + + // If encryption_key_revocation_action is SHUTDOWN, the duration before + // shutting down all instances. The minimum increment is 1 hour. + google.protobuf.Duration encryption_key_shutdown_duration = 24; + + // Output only. Indicates whether the resource's reconciliation is still in + // progress. See comments in `Service.reconciling` for additional information + // on reconciliation process in Cloud Run. + bool reconciling = 30 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Condition of this Revision, containing its readiness + // status, and detailed error information in case it did not reach a serving + // state. + repeated Condition conditions = 31 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The generation of this Revision currently serving traffic. See + // comments in `reconciling` for additional information on reconciliation + // process in Cloud Run. + int64 observed_generation = 32 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Google Console URI to obtain logs for the Revision. + string log_uri = 33 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Reserved for future use. + bool satisfies_pzs = 37 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Enable session affinity. + bool session_affinity = 38; + + // Output only. A system-generated fingerprint for this version of the + // resource. May be used to detect modification conflict during updates. + string etag = 99 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/revision_template.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/revision_template.proto new file mode 100644 index 00000000000..cc13e2d8509 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/revision_template.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.run.v2; + +import "google/api/resource.proto"; +import "google/cloud/run/v2/k8s.min.proto"; +import "google/cloud/run/v2/vendor_settings.proto"; +import "google/protobuf/duration.proto"; + +option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; +option java_multiple_files = true; +option java_outer_classname = "RevisionTemplateProto"; +option java_package = "com.google.cloud.run.v2"; + +// RevisionTemplate describes the data a revision should have when created from +// a template. +message RevisionTemplate { + // The unique name for the revision. If this field is omitted, it will be + // automatically generated based on the Service name. + string revision = 1 [ + (google.api.resource_reference) = { type: "run.googleapis.com/Revision" } + ]; + + // Unstructured key value map that can be used to organize and categorize + // objects. + // User-provided labels are shared with Google's billing system, so they can + // be used to filter, or break down billing charges by team, component, + // environment, state, etc. For more information, visit + // https://cloud.google.com/resource-manager/docs/creating-managing-labels or + // https://cloud.google.com/run/docs/configuring/labels. + // + //

Cloud Run API v2 does not support labels with `run.googleapis.com`, + // `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` + // namespaces, and they will be rejected. All system labels in v1 now have a + // corresponding field in v2 RevisionTemplate. + map labels = 2; + + // Unstructured key value map that may be set by external tools to store and + // arbitrary metadata. They are not queryable and should be preserved + // when modifying objects. + // + //

Cloud Run API v2 does not support annotations with `run.googleapis.com`, + // `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` + // namespaces, and they will be rejected. All system annotations in v1 now + // have a corresponding field in v2 RevisionTemplate. + // + //

This field follows Kubernetes annotations' namespacing, limits, and + // rules. + map annotations = 3; + + // Scaling settings for this Revision. + RevisionScaling scaling = 4; + + // VPC Access configuration to use for this Revision. For more information, + // visit https://cloud.google.com/run/docs/configuring/connecting-vpc. + VpcAccess vpc_access = 6; + + // Max allowed time for an instance to respond to a request. + google.protobuf.Duration timeout = 8; + + // Email address of the IAM service account associated with the revision of + // the service. The service account represents the identity of the running + // revision, and determines what permissions the revision has. If not + // provided, the revision will use the project's default service account. + string service_account = 9; + + // Holds the single container that defines the unit of execution for this + // Revision. + repeated Container containers = 10; + + // A list of Volumes to make available to containers. + repeated Volume volumes = 11; + + // The sandbox environment to host this Revision. + ExecutionEnvironment execution_environment = 13; + + // A reference to a customer managed encryption key (CMEK) to use to encrypt + // this container image. For more information, go to + // https://cloud.google.com/run/docs/securing/using-cmek + string encryption_key = 14 [(google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKey" + }]; + + // Sets the maximum number of requests that each serving instance can receive. + int32 max_instance_request_concurrency = 15; + + // Enable session affinity. + bool session_affinity = 19; +} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/service.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/service.proto new file mode 100644 index 00000000000..8ce51cb2beb --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/service.proto @@ -0,0 +1,470 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.run.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/launch_stage.proto"; +import "google/api/resource.proto"; +import "google/api/routing.proto"; +import "google/cloud/run/v2/condition.proto"; +import "google/cloud/run/v2/revision_template.proto"; +import "google/cloud/run/v2/traffic_target.proto"; +import "google/cloud/run/v2/vendor_settings.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; +option java_multiple_files = true; +option java_outer_classname = "ServiceProto"; +option java_package = "com.google.cloud.run.v2"; + +// Cloud Run Service Control Plane API +service Services { + option (google.api.default_host) = "run.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a new Service in a given project and location. + rpc CreateService(CreateServiceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*}/services" + body: "service" + }; + option (google.api.routing) = { + routing_parameters { + field: "parent" + path_template: "projects/*/locations/{location=*}" + } + }; + option (google.api.method_signature) = "parent,service,service_id"; + option (google.longrunning.operation_info) = { + response_type: "Service" + metadata_type: "Service" + }; + } + + // Gets information about a Service. + rpc GetService(GetServiceRequest) returns (Service) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/services/*}" + }; + option (google.api.routing) = { + routing_parameters { + field: "name" + path_template: "projects/*/locations/{location=*}/**" + } + }; + option (google.api.method_signature) = "name"; + } + + // Lists Services. + rpc ListServices(ListServicesRequest) returns (ListServicesResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*}/services" + }; + option (google.api.routing) = { + routing_parameters { + field: "parent" + path_template: "projects/*/locations/{location=*}" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Updates a Service. + rpc UpdateService(UpdateServiceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v2/{service.name=projects/*/locations/*/services/*}" + body: "service" + }; + option (google.api.routing) = { + routing_parameters { + field: "service.name" + path_template: "projects/*/locations/{location=*}/**" + } + }; + option (google.api.method_signature) = "service"; + option (google.longrunning.operation_info) = { + response_type: "Service" + metadata_type: "Service" + }; + } + + // Deletes a Service. + // This will cause the Service to stop serving traffic and will delete all + // revisions. + rpc DeleteService(DeleteServiceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/services/*}" + }; + option (google.api.routing) = { + routing_parameters { + field: "name" + path_template: "projects/*/locations/{location=*}/**" + } + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Service" + metadata_type: "Service" + }; + } + + // Gets the IAM Access Control policy currently in effect for the given + // Cloud Run Service. This result does not include any inherited policies. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) + returns (google.iam.v1.Policy) { + option (google.api.http) = { + get: "/v2/{resource=projects/*/locations/*/services/*}:getIamPolicy" + }; + } + + // Sets the IAM Access control policy for the specified Service. Overwrites + // any existing policy. + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) + returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v2/{resource=projects/*/locations/*/services/*}:setIamPolicy" + body: "*" + }; + } + + // Returns permissions that a caller has on the specified Project. + // + // There are no permissions required for making this API call. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) + returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v2/{resource=projects/*/locations/*/services/*}:testIamPermissions" + body: "*" + }; + } +} + +// Request message for creating a Service. +message CreateServiceRequest { + // Required. The location and project in which this service should be created. + // Format: projects/{project}/locations/{location}, where {project} can be + // project id or number. Only lowercase characters, digits, and hyphens. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "run.googleapis.com/Service" + } + ]; + + // Required. The Service instance to create. + Service service = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The unique identifier for the Service. It must begin with letter, + // and cannot end with hyphen; must contain fewer than 50 characters. + // The name of the service becomes {parent}/services/{service_id}. + string service_id = 3 [(google.api.field_behavior) = REQUIRED]; + + // Indicates that the request should be validated and default values + // populated, without persisting the request or creating any resources. + bool validate_only = 4; +} + +// Request message for updating a service. +message UpdateServiceRequest { + // Required. The Service to be updated. + Service service = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates that the request should be validated and default values + // populated, without persisting the request or updating any resources. + bool validate_only = 3; + + // If set to true, and if the Service does not exist, it will create a new + // one. The caller must have 'run.services.create' permissions if this is set + // to true and the Service does not exist. + bool allow_missing = 4; +} + +// Request message for retrieving a list of Services. +message ListServicesRequest { + // Required. The location and project to list resources on. + // Location must be a valid Google Cloud region, and cannot be the "-" + // wildcard. Format: projects/{project}/locations/{location}, where {project} + // can be project id or number. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "run.googleapis.com/Service" + } + ]; + + // Maximum number of Services to return in this call. + int32 page_size = 2; + + // A page token received from a previous call to ListServices. + // All other parameters must match. + string page_token = 3; + + // If true, returns deleted (but unexpired) resources along with active ones. + bool show_deleted = 4; +} + +// Response message containing a list of Services. +message ListServicesResponse { + // The resulting list of Services. + repeated Service services = 1; + + // A token indicating there are more items than page_size. Use it in the next + // ListServices request to continue. + string next_page_token = 2; +} + +// Request message for obtaining a Service by its full name. +message GetServiceRequest { + // Required. The full name of the Service. + // Format: projects/{project}/locations/{location}/services/{service}, where + // {project} can be project id or number. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "run.googleapis.com/Service" } + ]; +} + +// Request message to delete a Service by its full name. +message DeleteServiceRequest { + // Required. The full name of the Service. + // Format: projects/{project}/locations/{location}/services/{service}, where + // {project} can be project id or number. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "run.googleapis.com/Service" } + ]; + + // Indicates that the request should be validated without actually + // deleting any resources. + bool validate_only = 2; + + // A system-generated fingerprint for this version of the + // resource. May be used to detect modification conflict during updates. + string etag = 3; +} + +// Service acts as a top-level container that manages a set of +// configurations and revision templates which implement a network service. +// Service exists to provide a singular abstraction which can be access +// controlled, reasoned about, and which encapsulates software lifecycle +// decisions such as rollout policy and team resource ownership. +message Service { + option (google.api.resource) = { + type: "run.googleapis.com/Service" + pattern: "projects/{project}/locations/{location}/services/{service}" + style: DECLARATIVE_FRIENDLY + }; + + // The fully qualified name of this Service. In CreateServiceRequest, this + // field is ignored, and instead composed from CreateServiceRequest.parent and + // CreateServiceRequest.service_id. + // + // Format: + // projects/{project}/locations/{location}/services/{service_id} + string name = 1; + + // User-provided description of the Service. This field currently has a + // 512-character limit. + string description = 2; + + // Output only. Server assigned unique identifier for the trigger. The value + // is a UUID4 string and guaranteed to remain unchanged until the resource is + // deleted. + string uid = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A number that monotonically increases every time the user + // modifies the desired state. + // Please note that unlike v1, this is an int64 value. As with most Google + // APIs, its JSON representation will be a `string` instead of an `integer`. + int64 generation = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Unstructured key value map that can be used to organize and categorize + // objects. + // User-provided labels are shared with Google's billing system, so they can + // be used to filter, or break down billing charges by team, component, + // environment, state, etc. For more information, visit + // https://cloud.google.com/resource-manager/docs/creating-managing-labels or + // https://cloud.google.com/run/docs/configuring/labels. + // + //

Cloud Run API v2 does not support labels with `run.googleapis.com`, + // `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` + // namespaces, and they will be rejected. All system labels in v1 now have a + // corresponding field in v2 Service. + map labels = 5; + + // Unstructured key value map that may be set by external tools to store and + // arbitrary metadata. They are not queryable and should be preserved + // when modifying objects. + // + //

Cloud Run API v2 does not support annotations with `run.googleapis.com`, + // `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` + // namespaces, and they will be rejected in new resources. All system + // annotations in v1 now have a corresponding field in v2 Service. + // + //

This field follows Kubernetes + // annotations' namespacing, limits, and rules. + map annotations = 6; + + // Output only. The creation time. + google.protobuf.Timestamp create_time = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last-modified time. + google.protobuf.Timestamp update_time = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The deletion time. + google.protobuf.Timestamp delete_time = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. For a deleted resource, the time after which it will be + // permamently deleted. + google.protobuf.Timestamp expire_time = 10 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Email address of the authenticated creator. + string creator = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Email address of the last authenticated modifier. + string last_modifier = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Arbitrary identifier for the API client. + string client = 13; + + // Arbitrary version identifier for the API client. + string client_version = 14; + + // Provides the ingress settings for this Service. On output, returns the + // currently observed ingress settings, or INGRESS_TRAFFIC_UNSPECIFIED if no + // revision is active. + IngressTraffic ingress = 15; + + // The launch stage as defined by [Google Cloud Platform + // Launch Stages](https://cloud.google.com/terms/launch-stages). + // Cloud Run supports `ALPHA`, `BETA`, and `GA`. If no value is specified, GA + // is assumed. + // Set the launch stage to a preview stage on input to allow use of preview + // features in that stage. On read (or output), describes whether the resource + // uses preview features. + //

+ // For example, if ALPHA is provided as input, but only BETA and GA-level + // features are used, this field will be BETA on output. + google.api.LaunchStage launch_stage = 16; + + // Settings for the Binary Authorization feature. + BinaryAuthorization binary_authorization = 17; + + // Required. The template used to create revisions for this Service. + RevisionTemplate template = 18 [(google.api.field_behavior) = REQUIRED]; + + // Specifies how to distribute traffic over a collection of Revisions + // belonging to the Service. If traffic is empty or not provided, defaults to + // 100% traffic to the latest `Ready` Revision. + repeated TrafficTarget traffic = 19; + + // Output only. The generation of this Service currently serving traffic. See + // comments in `reconciling` for additional information on reconciliation + // process in Cloud Run. Please note that unlike v1, this is an int64 value. + // As with most Google APIs, its JSON representation will be a `string` + // instead of an `integer`. + int64 observed_generation = 30 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Condition of this Service, containing its readiness + // status, and detailed error information in case it did not reach a serving + // state. See comments in `reconciling` for additional information on + // reconciliation process in Cloud Run. + Condition terminal_condition = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Conditions of all other associated sub-resources. They + // contain additional diagnostics information in case the Service does not + // reach its Serving state. See comments in `reconciling` for additional + // information on reconciliation process in Cloud Run. + repeated Condition conditions = 32 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the latest revision that is serving traffic. See + // comments in `reconciling` for additional information on reconciliation + // process in Cloud Run. + string latest_ready_revision = 33 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { type: "run.googleapis.com/Revision" } + ]; + + // Output only. Name of the last created revision. See comments in + // `reconciling` for additional information on reconciliation process in Cloud + // Run. + string latest_created_revision = 34 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { type: "run.googleapis.com/Revision" } + ]; + + // Output only. Detailed status information for corresponding traffic targets. + // See comments in `reconciling` for additional information on reconciliation + // process in Cloud Run. + repeated TrafficTargetStatus traffic_statuses = 35 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The main URI in which this Service is serving traffic. + string uri = 36 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // One or more custom audiences that you want this service to support. Specify + // each custom audience as the full URL in a string. The custom audiences are + // encoded in the token and used to authenticate requests. For more + // information, see + // https://cloud.google.com/run/docs/configuring/custom-audiences. + repeated string custom_audiences = 37; + + // Output only. Reserved for future use. + bool satisfies_pzs = 38 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Returns true if the Service is currently being acted upon by + // the system to bring it into the desired state. + // + // When a new Service is created, or an existing one is updated, Cloud Run + // will asynchronously perform all necessary steps to bring the Service to the + // desired serving state. This process is called reconciliation. + // While reconciliation is in process, `observed_generation`, + // `latest_ready_revison`, `traffic_statuses`, and `uri` will have transient + // values that might mismatch the intended state: Once reconciliation is over + // (and this field is false), there are two possible outcomes: reconciliation + // succeeded and the serving state matches the Service, or there was an error, + // and reconciliation failed. This state can be found in + // `terminal_condition.state`. + // + // If reconciliation succeeded, the following fields will match: `traffic` and + // `traffic_statuses`, `observed_generation` and `generation`, + // `latest_ready_revision` and `latest_created_revision`. + // + // If reconciliation failed, `traffic_statuses`, `observed_generation`, and + // `latest_ready_revision` will have the state of the last serving revision, + // or empty for newly created Services. Additional information on the failure + // can be found in `terminal_condition` and `conditions`. + bool reconciling = 98 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A system-generated fingerprint for this version of the + // resource. May be used to detect modification conflict during updates. + string etag = 99 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/task.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/task.proto new file mode 100644 index 00000000000..7741c301617 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/task.proto @@ -0,0 +1,267 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.run.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/run/v2/condition.proto"; +import "google/cloud/run/v2/k8s.min.proto"; +import "google/cloud/run/v2/vendor_settings.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; +option java_multiple_files = true; +option java_outer_classname = "TaskProto"; +option java_package = "com.google.cloud.run.v2"; + +// Cloud Run Task Control Plane API. +service Tasks { + option (google.api.default_host) = "run.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Gets information about a Task. + rpc GetTask(GetTaskRequest) returns (Task) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/jobs/*/executions/*/tasks/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists Tasks from an Execution of a Job. + rpc ListTasks(ListTasksRequest) returns (ListTasksResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*/jobs/*/executions/*}/tasks" + }; + option (google.api.method_signature) = "parent"; + } +} + +// Request message for obtaining a Task by its full name. +message GetTaskRequest { + // Required. The full name of the Task. + // Format: + // projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "run.googleapis.com/Task" } + ]; +} + +// Request message for retrieving a list of Tasks. +message ListTasksRequest { + // Required. The Execution from which the Tasks should be listed. + // To list all Tasks across Executions of a Job, use "-" instead of Execution + // name. To list all Tasks across Jobs, use "-" instead of Job name. Format: + // projects/{project}/locations/{location}/jobs/{job}/executions/{execution} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { child_type: "run.googleapis.com/Task" } + ]; + + // Maximum number of Tasks to return in this call. + int32 page_size = 2; + + // A page token received from a previous call to ListTasks. + // All other parameters must match. + string page_token = 3; + + // If true, returns deleted (but unexpired) resources along with active ones. + bool show_deleted = 4; +} + +// Response message containing a list of Tasks. +message ListTasksResponse { + // The resulting list of Tasks. + repeated Task tasks = 1; + + // A token indicating there are more items than page_size. Use it in the next + // ListTasks request to continue. + string next_page_token = 2; +} + +// Task represents a single run of a container to completion. +message Task { + option (google.api.resource) = { + type: "run.googleapis.com/Task" + pattern: "projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task}" + style: DECLARATIVE_FRIENDLY + }; + + // Output only. The unique name of this Task. + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Server assigned unique identifier for the Task. The value is a + // UUID4 string and guaranteed to remain unchanged until the resource is + // deleted. + string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A number that monotonically increases every time the user + // modifies the desired state. + int64 generation = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Unstructured key value map that can be used to organize and + // categorize objects. User-provided labels are shared with Google's billing + // system, so they can be used to filter, or break down billing charges by + // team, component, environment, state, etc. For more information, visit + // https://cloud.google.com/resource-manager/docs/creating-managing-labels or + // https://cloud.google.com/run/docs/configuring/labels + map labels = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Unstructured key value map that may + // be set by external tools to store and arbitrary metadata. + // They are not queryable and should be preserved + // when modifying objects. + map annotations = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Represents time when the task was created by the job + // controller. It is not guaranteed to be set in happens-before order across + // separate operations. + google.protobuf.Timestamp create_time = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Represents time when the task started to run. + // It is not guaranteed to be set in happens-before order across separate + // operations. + google.protobuf.Timestamp start_time = 27 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Represents time when the Task was completed. It is not + // guaranteed to be set in happens-before order across separate operations. + google.protobuf.Timestamp completion_time = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last-modified time. + google.protobuf.Timestamp update_time = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. For a deleted resource, the deletion time. It is only + // populated as a response to a Delete request. + google.protobuf.Timestamp delete_time = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. For a deleted resource, the time after which it will be + // permamently deleted. It is only populated as a response to a Delete + // request. + google.protobuf.Timestamp expire_time = 10 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The name of the parent Job. + string job = 12 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { type: "run.googleapis.com/Job" } + ]; + + // Output only. The name of the parent Execution. + string execution = 13 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { type: "run.googleapis.com/Execution" } + ]; + + // Holds the single container that defines the unit of execution for this + // task. + repeated Container containers = 14; + + // A list of Volumes to make available to containers. + repeated Volume volumes = 15; + + // Number of retries allowed per Task, before marking this Task failed. + int32 max_retries = 16; + + // Max allowed time duration the Task may be active before the system will + // actively try to mark it failed and kill associated containers. This applies + // per attempt of a task, meaning each retry can run for the full timeout. + google.protobuf.Duration timeout = 17; + + // Email address of the IAM service account associated with the Task of a + // Job. The service account represents the identity of the + // running task, and determines what permissions the task has. If + // not provided, the task will use the project's default service account. + string service_account = 18; + + // The execution environment being used to host this Task. + ExecutionEnvironment execution_environment = 20; + + // Output only. Indicates whether the resource's reconciliation is still in + // progress. See comments in `Job.reconciling` for additional information on + // reconciliation process in Cloud Run. + bool reconciling = 21 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Condition of this Task, containing its readiness status, + // and detailed error information in case it did not reach the desired state. + repeated Condition conditions = 22 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The generation of this Task. See comments in `Job.reconciling` + // for additional information on reconciliation process in Cloud Run. + int64 observed_generation = 23 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Index of the Task, unique per execution, and beginning at 0. + int32 index = 24 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The number of times this Task was retried. + // Tasks are retried when they fail up to the maxRetries limit. + int32 retried = 25 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Result of the last attempt of this Task. + TaskAttemptResult last_attempt_result = 26 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A reference to a customer managed encryption key (CMEK) to use + // to encrypt this container image. For more information, go to + // https://cloud.google.com/run/docs/securing/using-cmek + string encryption_key = 28 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKey" + } + ]; + + // Output only. VPC Access configuration to use for this Task. For more + // information, visit + // https://cloud.google.com/run/docs/configuring/connecting-vpc. + VpcAccess vpc_access = 29 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. URI where logs for this execution can be found in Cloud + // Console. + string log_uri = 32 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Reserved for future use. + bool satisfies_pzs = 33 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A system-generated fingerprint for this version of the + // resource. May be used to detect modification conflict during updates. + string etag = 99 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Result of a task attempt. +message TaskAttemptResult { + // Output only. The status of this attempt. + // If the status code is OK, then the attempt succeeded. + google.rpc.Status status = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The exit code of this attempt. + // This may be unset if the container was unable to exit cleanly with a code + // due to some other failure. + // See status field for possible failure details. + int32 exit_code = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/task_template.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/task_template.proto new file mode 100644 index 00000000000..586c4495627 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/task_template.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.run.v2; + +import "google/api/resource.proto"; +import "google/cloud/run/v2/k8s.min.proto"; +import "google/cloud/run/v2/vendor_settings.proto"; +import "google/protobuf/duration.proto"; + +option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; +option java_multiple_files = true; +option java_outer_classname = "TaskTemplateProto"; +option java_package = "com.google.cloud.run.v2"; + +// TaskTemplate describes the data a task should have when created +// from a template. +message TaskTemplate { + // Holds the single container that defines the unit of execution for this + // task. + repeated Container containers = 1; + + // A list of Volumes to make available to containers. + repeated Volume volumes = 2; + + oneof retries { + // Number of retries allowed per Task, before marking this Task failed. + // Defaults to 3. + int32 max_retries = 3; + } + + // Max allowed time duration the Task may be active before the system will + // actively try to mark it failed and kill associated containers. This applies + // per attempt of a task, meaning each retry can run for the full timeout. + // Defaults to 600 seconds. + google.protobuf.Duration timeout = 4; + + // Email address of the IAM service account associated with the Task of a + // Job. The service account represents the identity of the + // running task, and determines what permissions the task has. If + // not provided, the task will use the project's default service account. + string service_account = 5; + + // The execution environment being used to host this Task. + ExecutionEnvironment execution_environment = 6; + + // A reference to a customer managed encryption key (CMEK) to use to encrypt + // this container image. For more information, go to + // https://cloud.google.com/run/docs/securing/using-cmek + string encryption_key = 7 [(google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKey" + }]; + + // VPC Access configuration to use for this Task. For more information, + // visit https://cloud.google.com/run/docs/configuring/connecting-vpc. + VpcAccess vpc_access = 8; +} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/traffic_target.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/traffic_target.proto new file mode 100644 index 00000000000..adc7f05e2e8 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/traffic_target.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.run.v2; + +import "google/api/resource.proto"; + +option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; +option java_multiple_files = true; +option java_outer_classname = "TrafficTargetProto"; +option java_package = "com.google.cloud.run.v2"; + +// Holds a single traffic routing entry for the Service. Allocations can be done +// to a specific Revision name, or pointing to the latest Ready Revision. +message TrafficTarget { + // The allocation type for this traffic target. + TrafficTargetAllocationType type = 1; + + // Revision to which to send this portion of traffic, if traffic allocation is + // by revision. + string revision = 2 [ + (google.api.resource_reference) = { type: "run.googleapis.com/Revision" } + ]; + + // Specifies percent of the traffic to this Revision. + // This defaults to zero if unspecified. + int32 percent = 3; + + // Indicates a string to be part of the URI to exclusively reference this + // target. + string tag = 4; +} + +// Represents the observed state of a single `TrafficTarget` entry. +message TrafficTargetStatus { + // The allocation type for this traffic target. + TrafficTargetAllocationType type = 1; + + // Revision to which this traffic is sent. + string revision = 2 [ + (google.api.resource_reference) = { type: "run.googleapis.com/Revision" } + ]; + + // Specifies percent of the traffic to this Revision. + int32 percent = 3; + + // Indicates the string used in the URI to exclusively reference this target. + string tag = 4; + + // Displays the target URI. + string uri = 5; +} + +// The type of instance allocation. +enum TrafficTargetAllocationType { + // Unspecified instance allocation type. + TRAFFIC_TARGET_ALLOCATION_TYPE_UNSPECIFIED = 0; + + // Allocates instances to the Service's latest ready Revision. + TRAFFIC_TARGET_ALLOCATION_TYPE_LATEST = 1; + + // Allocates instances to a Revision by name. + TRAFFIC_TARGET_ALLOCATION_TYPE_REVISION = 2; +} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/vendor_settings.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/vendor_settings.proto new file mode 100644 index 00000000000..389b6153229 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/vendor_settings.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.run.v2; + +import "google/api/resource.proto"; + +option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; +option java_multiple_files = true; +option java_outer_classname = "VendorSettingsProto"; +option java_package = "com.google.cloud.run.v2"; + +// VPC Access settings. For more information on creating a VPC Connector, visit +// https://cloud.google.com/vpc/docs/configure-serverless-vpc-access For +// information on how to configure Cloud Run with an existing VPC Connector, +// visit https://cloud.google.com/run/docs/configuring/connecting-vpc +message VpcAccess { + // Egress options for VPC access. + enum VpcEgress { + // Unspecified + VPC_EGRESS_UNSPECIFIED = 0; + + // All outbound traffic is routed through the VPC connector. + ALL_TRAFFIC = 1; + + // Only private IP ranges are routed through the VPC connector. + PRIVATE_RANGES_ONLY = 2; + } + + // VPC Access connector name. + // Format: projects/{project}/locations/{location}/connectors/{connector}, + // where {project} can be project id or number. + string connector = 1 [(google.api.resource_reference) = { + type: "vpcaccess.googleapis.com/Connector" + }]; + + // Traffic VPC egress settings. + VpcEgress egress = 2; +} + +// Settings for Binary Authorization feature. +message BinaryAuthorization { + oneof binauthz_method { + // If True, indicates to use the default project's binary authorization + // policy. If False, binary authorization will be disabled. + bool use_default = 1; + } + + // If present, indicates to use Breakglass using this justification. + // If use_default is False, then it must be empty. + // For more information on breakglass, see + // https://cloud.google.com/binary-authorization/docs/using-breakglass + string breakglass_justification = 2; +} + +// Settings for revision-level scaling settings. +message RevisionScaling { + // Minimum number of serving instances that this resource should have. + int32 min_instance_count = 1; + + // Maximum number of serving instances that this resource should have. + int32 max_instance_count = 2; +} + +// Allowed ingress traffic for the Container. +enum IngressTraffic { + // Unspecified + INGRESS_TRAFFIC_UNSPECIFIED = 0; + + // All inbound traffic is allowed. + INGRESS_TRAFFIC_ALL = 1; + + // Only internal traffic is allowed. + INGRESS_TRAFFIC_INTERNAL_ONLY = 2; + + // Both internal and Google Cloud Load Balancer traffic is allowed. + INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER = 3; +} + +// Alternatives for execution environments. +enum ExecutionEnvironment { + // Unspecified + EXECUTION_ENVIRONMENT_UNSPECIFIED = 0; + + // Uses the First Generation environment. + EXECUTION_ENVIRONMENT_GEN1 = 1; + + // Uses Second Generation environment. + EXECUTION_ENVIRONMENT_GEN2 = 2; +} + +// Specifies behavior if an encryption key used by a resource is revoked. +enum EncryptionKeyRevocationAction { + // Unspecified + ENCRYPTION_KEY_REVOCATION_ACTION_UNSPECIFIED = 0; + + // Prevents the creation of new instances. + PREVENT_NEW = 1; + + // Shuts down existing instances, and prevents creation of new ones. + SHUTDOWN = 2; +} diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.delete_execution.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.delete_execution.js new file mode 100644 index 00000000000..bec84488fcb --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.delete_execution.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(name) { + // [START run_v2_generated_Executions_DeleteExecution_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 Execution to delete. + * Format: + * projects/{project}/locations/{location}/jobs/{job}/executions/{execution}, + * where {project} can be project id or number. + */ + // const name = 'abc123' + /** + * Indicates that the request should be validated without actually + * deleting any resources. + */ + // const validateOnly = true + /** + * A system-generated fingerprint for this version of the resource. + * This may be used to detect modification conflict during updates. + */ + // const etag = 'abc123' + + // Imports the Run library + const {ExecutionsClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ExecutionsClient(); + + async function callDeleteExecution() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await runClient.deleteExecution(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteExecution(); + // [END run_v2_generated_Executions_DeleteExecution_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.get_execution.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.get_execution.js new file mode 100644 index 00000000000..8233f4e8a19 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.get_execution.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 run_v2_generated_Executions_GetExecution_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The full name of the Execution. + * Format: + * projects/{project}/locations/{location}/jobs/{job}/executions/{execution}, + * where {project} can be project id or number. + */ + // const name = 'abc123' + + // Imports the Run library + const {ExecutionsClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ExecutionsClient(); + + async function callGetExecution() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await runClient.getExecution(request); + console.log(response); + } + + callGetExecution(); + // [END run_v2_generated_Executions_GetExecution_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.list_executions.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.list_executions.js new file mode 100644 index 00000000000..ebcc951cd10 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.list_executions.js @@ -0,0 +1,79 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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 run_v2_generated_Executions_ListExecutions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Execution from which the Executions should be listed. + * To list all Executions across Jobs, use "-" instead of Job name. + * Format: projects/{project}/locations/{location}/jobs/{job}, where {project} + * can be project id or number. + */ + // const parent = 'abc123' + /** + * Maximum number of Executions to return in this call. + */ + // const pageSize = 1234 + /** + * A page token received from a previous call to ListExecutions. + * All other parameters must match. + */ + // const pageToken = 'abc123' + /** + * If true, returns deleted (but unexpired) resources along with active ones. + */ + // const showDeleted = true + + // Imports the Run library + const {ExecutionsClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ExecutionsClient(); + + async function callListExecutions() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await runClient.listExecutionsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListExecutions(); + // [END run_v2_generated_Executions_ListExecutions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.create_job.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.create_job.js new file mode 100644 index 00000000000..4f2f2152f1d --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.create_job.js @@ -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. ** + + + +'use strict'; + +function main(parent, job, jobId) { + // [START run_v2_generated_Jobs_CreateJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The location and project in which this Job should be created. + * Format: projects/{project}/locations/{location}, where {project} can be + * project id or number. + */ + // const parent = 'abc123' + /** + * Required. The Job instance to create. + */ + // const job = {} + /** + * Required. The unique identifier for the Job. The name of the job becomes + * {parent}/jobs/{job_id}. + */ + // const jobId = 'abc123' + /** + * Indicates that the request should be validated and default values + * populated, without persisting the request or creating any resources. + */ + // const validateOnly = true + + // Imports the Run library + const {JobsClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new JobsClient(); + + async function callCreateJob() { + // Construct request + const request = { + parent, + job, + jobId, + }; + + // Run request + const [operation] = await runClient.createJob(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateJob(); + // [END run_v2_generated_Jobs_CreateJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.delete_job.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.delete_job.js new file mode 100644 index 00000000000..2ae230b7d92 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.delete_job.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(name) { + // [START run_v2_generated_Jobs_DeleteJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The full name of the Job. + * Format: projects/{project}/locations/{location}/jobs/{job}, where {project} + * can be project id or number. + */ + // const name = 'abc123' + /** + * Indicates that the request should be validated without actually + * deleting any resources. + */ + // const validateOnly = true + /** + * A system-generated fingerprint for this version of the + * resource. May be used to detect modification conflict during updates. + */ + // const etag = 'abc123' + + // Imports the Run library + const {JobsClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new JobsClient(); + + async function callDeleteJob() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await runClient.deleteJob(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteJob(); + // [END run_v2_generated_Jobs_DeleteJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.get_iam_policy.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.get_iam_policy.js new file mode 100644 index 00000000000..c7d7717d748 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.get_iam_policy.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(resource) { + // [START run_v2_generated_Jobs_GetIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + */ + // const options = {} + + // Imports the Run library + const {JobsClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new JobsClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await runClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END run_v2_generated_Jobs_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.get_job.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.get_job.js new file mode 100644 index 00000000000..5380023ba28 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.get_job.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 run_v2_generated_Jobs_GetJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The full name of the Job. + * Format: projects/{project}/locations/{location}/jobs/{job}, where {project} + * can be project id or number. + */ + // const name = 'abc123' + + // Imports the Run library + const {JobsClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new JobsClient(); + + async function callGetJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await runClient.getJob(request); + console.log(response); + } + + callGetJob(); + // [END run_v2_generated_Jobs_GetJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.list_jobs.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.list_jobs.js new file mode 100644 index 00000000000..35e4852d866 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.list_jobs.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(parent) { + // [START run_v2_generated_Jobs_ListJobs_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The location and project to list resources on. + * Format: projects/{project}/locations/{location}, where {project} can be + * project id or number. + */ + // const parent = 'abc123' + /** + * Maximum number of Jobs to return in this call. + */ + // const pageSize = 1234 + /** + * A page token received from a previous call to ListJobs. + * All other parameters must match. + */ + // const pageToken = 'abc123' + /** + * If true, returns deleted (but unexpired) resources along with active ones. + */ + // const showDeleted = true + + // Imports the Run library + const {JobsClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new JobsClient(); + + async function callListJobs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await runClient.listJobsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListJobs(); + // [END run_v2_generated_Jobs_ListJobs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.run_job.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.run_job.js new file mode 100644 index 00000000000..6bf942f7fe2 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.run_job.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(name) { + // [START run_v2_generated_Jobs_RunJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The full name of the Job. + * Format: projects/{project}/locations/{location}/jobs/{job}, where {project} + * can be project id or number. + */ + // const name = 'abc123' + /** + * Indicates that the request should be validated without actually + * deleting any resources. + */ + // const validateOnly = true + /** + * A system-generated fingerprint for this version of the + * resource. May be used to detect modification conflict during updates. + */ + // const etag = 'abc123' + + // Imports the Run library + const {JobsClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new JobsClient(); + + async function callRunJob() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await runClient.runJob(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRunJob(); + // [END run_v2_generated_Jobs_RunJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.set_iam_policy.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.set_iam_policy.js new file mode 100644 index 00000000000..d206bfa241e --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.set_iam_policy.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(resource, policy) { + // [START run_v2_generated_Jobs_SetIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + */ + // const policy = {} + /** + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * `paths: "bindings, etag"` + */ + // const updateMask = {} + + // Imports the Run library + const {JobsClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new JobsClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + resource, + policy, + }; + + // Run request + const response = await runClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END run_v2_generated_Jobs_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.test_iam_permissions.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.test_iam_permissions.js new file mode 100644 index 00000000000..2f53892e97f --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.test_iam_permissions.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(resource, permissions) { + // [START run_v2_generated_Jobs_TestIamPermissions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). + */ + // const permissions = ['abc','def'] + + // Imports the Run library + const {JobsClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new JobsClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + resource, + permissions, + }; + + // Run request + const response = await runClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END run_v2_generated_Jobs_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.update_job.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.update_job.js new file mode 100644 index 00000000000..15e4e80046a --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.update_job.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(job) { + // [START run_v2_generated_Jobs_UpdateJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Job to be updated. + */ + // const job = {} + /** + * Indicates that the request should be validated and default values + * populated, without persisting the request or updating any resources. + */ + // const validateOnly = true + /** + * If set to true, and if the Job does not exist, it will create a new + * one. Caller must have both create and update permissions for this call if + * this is set to true. + */ + // const allowMissing = true + + // Imports the Run library + const {JobsClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new JobsClient(); + + async function callUpdateJob() { + // Construct request + const request = { + job, + }; + + // Run request + const [operation] = await runClient.updateJob(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateJob(); + // [END run_v2_generated_Jobs_UpdateJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.delete_revision.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.delete_revision.js new file mode 100644 index 00000000000..412c47f9d83 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.delete_revision.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(name) { + // [START run_v2_generated_Revisions_DeleteRevision_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 Revision to delete. + * Format: + * projects/{project}/locations/{location}/services/{service}/revisions/{revision} + */ + // const name = 'abc123' + /** + * Indicates that the request should be validated without actually + * deleting any resources. + */ + // const validateOnly = true + /** + * A system-generated fingerprint for this version of the + * resource. This may be used to detect modification conflict during updates. + */ + // const etag = 'abc123' + + // Imports the Run library + const {RevisionsClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new RevisionsClient(); + + async function callDeleteRevision() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await runClient.deleteRevision(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteRevision(); + // [END run_v2_generated_Revisions_DeleteRevision_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.get_revision.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.get_revision.js new file mode 100644 index 00000000000..e2dbac26d79 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.get_revision.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 run_v2_generated_Revisions_GetRevision_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The full name of the Revision. + * Format: + * projects/{project}/locations/{location}/services/{service}/revisions/{revision} + */ + // const name = 'abc123' + + // Imports the Run library + const {RevisionsClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new RevisionsClient(); + + async function callGetRevision() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await runClient.getRevision(request); + console.log(response); + } + + callGetRevision(); + // [END run_v2_generated_Revisions_GetRevision_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.list_revisions.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.list_revisions.js new file mode 100644 index 00000000000..feeb3de4e24 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.list_revisions.js @@ -0,0 +1,79 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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 run_v2_generated_Revisions_ListRevisions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Service from which the Revisions should be listed. + * To list all Revisions across Services, use "-" instead of Service name. + * Format: + * projects/{project}/locations/{location}/services/{service} + */ + // const parent = 'abc123' + /** + * Maximum number of revisions to return in this call. + */ + // const pageSize = 1234 + /** + * A page token received from a previous call to ListRevisions. + * All other parameters must match. + */ + // const pageToken = 'abc123' + /** + * If true, returns deleted (but unexpired) resources along with active ones. + */ + // const showDeleted = true + + // Imports the Run library + const {RevisionsClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new RevisionsClient(); + + async function callListRevisions() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await runClient.listRevisionsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListRevisions(); + // [END run_v2_generated_Revisions_ListRevisions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.create_service.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.create_service.js new file mode 100644 index 00000000000..ac7f7db0fbd --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.create_service.js @@ -0,0 +1,81 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, service, serviceId) { + // [START run_v2_generated_Services_CreateService_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The location and project in which this service should be created. + * Format: projects/{project}/locations/{location}, where {project} can be + * project id or number. Only lowercase characters, digits, and hyphens. + */ + // const parent = 'abc123' + /** + * Required. The Service instance to create. + */ + // const service = {} + /** + * Required. The unique identifier for the Service. It must begin with letter, + * and cannot end with hyphen; must contain fewer than 50 characters. + * The name of the service becomes {parent}/services/{service_id}. + */ + // const serviceId = 'abc123' + /** + * Indicates that the request should be validated and default values + * populated, without persisting the request or creating any resources. + */ + // const validateOnly = true + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callCreateService() { + // Construct request + const request = { + parent, + service, + serviceId, + }; + + // Run request + const [operation] = await runClient.createService(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateService(); + // [END run_v2_generated_Services_CreateService_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.delete_service.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.delete_service.js new file mode 100644 index 00000000000..f3d8e315d2f --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.delete_service.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(name) { + // [START run_v2_generated_Services_DeleteService_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The full name of the Service. + * Format: projects/{project}/locations/{location}/services/{service}, where + * {project} can be project id or number. + */ + // const name = 'abc123' + /** + * Indicates that the request should be validated without actually + * deleting any resources. + */ + // const validateOnly = true + /** + * A system-generated fingerprint for this version of the + * resource. May be used to detect modification conflict during updates. + */ + // const etag = 'abc123' + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callDeleteService() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await runClient.deleteService(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteService(); + // [END run_v2_generated_Services_DeleteService_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.get_iam_policy.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.get_iam_policy.js new file mode 100644 index 00000000000..c1fda69132e --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.get_iam_policy.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(resource) { + // [START run_v2_generated_Services_GetIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + */ + // const options = {} + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await runClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END run_v2_generated_Services_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.get_service.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.get_service.js new file mode 100644 index 00000000000..4bca6947a81 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.get_service.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 run_v2_generated_Services_GetService_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The full name of the Service. + * Format: projects/{project}/locations/{location}/services/{service}, where + * {project} can be project id or number. + */ + // const name = 'abc123' + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callGetService() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await runClient.getService(request); + console.log(response); + } + + callGetService(); + // [END run_v2_generated_Services_GetService_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.list_services.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.list_services.js new file mode 100644 index 00000000000..5212a84dfe7 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.list_services.js @@ -0,0 +1,79 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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 run_v2_generated_Services_ListServices_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The location and project to list resources on. + * Location must be a valid Google Cloud region, and cannot be the "-" + * wildcard. Format: projects/{project}/locations/{location}, where {project} + * can be project id or number. + */ + // const parent = 'abc123' + /** + * Maximum number of Services to return in this call. + */ + // const pageSize = 1234 + /** + * A page token received from a previous call to ListServices. + * All other parameters must match. + */ + // const pageToken = 'abc123' + /** + * If true, returns deleted (but unexpired) resources along with active ones. + */ + // const showDeleted = true + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callListServices() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await runClient.listServicesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListServices(); + // [END run_v2_generated_Services_ListServices_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.set_iam_policy.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.set_iam_policy.js new file mode 100644 index 00000000000..c1c3105bd71 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.set_iam_policy.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(resource, policy) { + // [START run_v2_generated_Services_SetIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + */ + // const policy = {} + /** + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * `paths: "bindings, etag"` + */ + // const updateMask = {} + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + resource, + policy, + }; + + // Run request + const response = await runClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END run_v2_generated_Services_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.test_iam_permissions.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.test_iam_permissions.js new file mode 100644 index 00000000000..dd9186f09a1 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.test_iam_permissions.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(resource, permissions) { + // [START run_v2_generated_Services_TestIamPermissions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require 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 for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). + */ + // const permissions = ['abc','def'] + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + resource, + permissions, + }; + + // Run request + const response = await runClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END run_v2_generated_Services_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.update_service.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.update_service.js new file mode 100644 index 00000000000..e37f7604793 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.update_service.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(service) { + // [START run_v2_generated_Services_UpdateService_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Service to be updated. + */ + // const service = {} + /** + * Indicates that the request should be validated and default values + * populated, without persisting the request or updating any resources. + */ + // const validateOnly = true + /** + * If set to true, and if the Service does not exist, it will create a new + * one. The caller must have 'run.services.create' permissions if this is set + * to true and the Service does not exist. + */ + // const allowMissing = true + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callUpdateService() { + // Construct request + const request = { + service, + }; + + // Run request + const [operation] = await runClient.updateService(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateService(); + // [END run_v2_generated_Services_UpdateService_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/snippet_metadata_google.cloud.run.v2.json b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/snippet_metadata_google.cloud.run.v2.json new file mode 100644 index 00000000000..7050ec71d11 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/snippet_metadata_google.cloud.run.v2.json @@ -0,0 +1,1187 @@ +{ + "clientLibrary": { + "name": "nodejs-run", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.run.v2", + "version": "v2" + } + ] + }, + "snippets": [ + { + "regionTag": "run_v2_generated_Executions_GetExecution_async", + "title": "Executions getExecution Sample", + "origin": "API_DEFINITION", + "description": " Gets information about an Execution.", + "canonical": true, + "file": "executions.get_execution.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetExecution", + "fullName": "google.cloud.run.v2.Executions.GetExecution", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.run.v2.Execution", + "client": { + "shortName": "ExecutionsClient", + "fullName": "google.cloud.run.v2.ExecutionsClient" + }, + "method": { + "shortName": "GetExecution", + "fullName": "google.cloud.run.v2.Executions.GetExecution", + "service": { + "shortName": "Executions", + "fullName": "google.cloud.run.v2.Executions" + } + } + } + }, + { + "regionTag": "run_v2_generated_Executions_ListExecutions_async", + "title": "Executions listExecutions Sample", + "origin": "API_DEFINITION", + "description": " Lists Executions from a Job.", + "canonical": true, + "file": "executions.list_executions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListExecutions", + "fullName": "google.cloud.run.v2.Executions.ListExecutions", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "show_deleted", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.run.v2.ListExecutionsResponse", + "client": { + "shortName": "ExecutionsClient", + "fullName": "google.cloud.run.v2.ExecutionsClient" + }, + "method": { + "shortName": "ListExecutions", + "fullName": "google.cloud.run.v2.Executions.ListExecutions", + "service": { + "shortName": "Executions", + "fullName": "google.cloud.run.v2.Executions" + } + } + } + }, + { + "regionTag": "run_v2_generated_Executions_DeleteExecution_async", + "title": "Executions deleteExecution Sample", + "origin": "API_DEFINITION", + "description": " Deletes an Execution.", + "canonical": true, + "file": "executions.delete_execution.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteExecution", + "fullName": "google.cloud.run.v2.Executions.DeleteExecution", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ExecutionsClient", + "fullName": "google.cloud.run.v2.ExecutionsClient" + }, + "method": { + "shortName": "DeleteExecution", + "fullName": "google.cloud.run.v2.Executions.DeleteExecution", + "service": { + "shortName": "Executions", + "fullName": "google.cloud.run.v2.Executions" + } + } + } + }, + { + "regionTag": "run_v2_generated_Jobs_CreateJob_async", + "title": "Executions createJob Sample", + "origin": "API_DEFINITION", + "description": " Creates a Job.", + "canonical": true, + "file": "jobs.create_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateJob", + "fullName": "google.cloud.run.v2.Jobs.CreateJob", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "job", + "type": ".google.cloud.run.v2.Job" + }, + { + "name": "job_id", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "JobsClient", + "fullName": "google.cloud.run.v2.JobsClient" + }, + "method": { + "shortName": "CreateJob", + "fullName": "google.cloud.run.v2.Jobs.CreateJob", + "service": { + "shortName": "Jobs", + "fullName": "google.cloud.run.v2.Jobs" + } + } + } + }, + { + "regionTag": "run_v2_generated_Jobs_GetJob_async", + "title": "Executions getJob Sample", + "origin": "API_DEFINITION", + "description": " Gets information about a Job.", + "canonical": true, + "file": "jobs.get_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetJob", + "fullName": "google.cloud.run.v2.Jobs.GetJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.run.v2.Job", + "client": { + "shortName": "JobsClient", + "fullName": "google.cloud.run.v2.JobsClient" + }, + "method": { + "shortName": "GetJob", + "fullName": "google.cloud.run.v2.Jobs.GetJob", + "service": { + "shortName": "Jobs", + "fullName": "google.cloud.run.v2.Jobs" + } + } + } + }, + { + "regionTag": "run_v2_generated_Jobs_ListJobs_async", + "title": "Executions listJobs Sample", + "origin": "API_DEFINITION", + "description": " Lists Jobs.", + "canonical": true, + "file": "jobs.list_jobs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListJobs", + "fullName": "google.cloud.run.v2.Jobs.ListJobs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "show_deleted", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.run.v2.ListJobsResponse", + "client": { + "shortName": "JobsClient", + "fullName": "google.cloud.run.v2.JobsClient" + }, + "method": { + "shortName": "ListJobs", + "fullName": "google.cloud.run.v2.Jobs.ListJobs", + "service": { + "shortName": "Jobs", + "fullName": "google.cloud.run.v2.Jobs" + } + } + } + }, + { + "regionTag": "run_v2_generated_Jobs_UpdateJob_async", + "title": "Executions updateJob Sample", + "origin": "API_DEFINITION", + "description": " Updates a Job.", + "canonical": true, + "file": "jobs.update_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateJob", + "fullName": "google.cloud.run.v2.Jobs.UpdateJob", + "async": true, + "parameters": [ + { + "name": "job", + "type": ".google.cloud.run.v2.Job" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "JobsClient", + "fullName": "google.cloud.run.v2.JobsClient" + }, + "method": { + "shortName": "UpdateJob", + "fullName": "google.cloud.run.v2.Jobs.UpdateJob", + "service": { + "shortName": "Jobs", + "fullName": "google.cloud.run.v2.Jobs" + } + } + } + }, + { + "regionTag": "run_v2_generated_Jobs_DeleteJob_async", + "title": "Executions deleteJob Sample", + "origin": "API_DEFINITION", + "description": " Deletes a Job.", + "canonical": true, + "file": "jobs.delete_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteJob", + "fullName": "google.cloud.run.v2.Jobs.DeleteJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "JobsClient", + "fullName": "google.cloud.run.v2.JobsClient" + }, + "method": { + "shortName": "DeleteJob", + "fullName": "google.cloud.run.v2.Jobs.DeleteJob", + "service": { + "shortName": "Jobs", + "fullName": "google.cloud.run.v2.Jobs" + } + } + } + }, + { + "regionTag": "run_v2_generated_Jobs_RunJob_async", + "title": "Executions runJob Sample", + "origin": "API_DEFINITION", + "description": " Triggers creation of a new Execution of this Job.", + "canonical": true, + "file": "jobs.run_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RunJob", + "fullName": "google.cloud.run.v2.Jobs.RunJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "JobsClient", + "fullName": "google.cloud.run.v2.JobsClient" + }, + "method": { + "shortName": "RunJob", + "fullName": "google.cloud.run.v2.Jobs.RunJob", + "service": { + "shortName": "Jobs", + "fullName": "google.cloud.run.v2.Jobs" + } + } + } + }, + { + "regionTag": "run_v2_generated_Jobs_GetIamPolicy_async", + "title": "Executions getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the IAM Access Control policy currently in effect for the given Job. This result does not include any inherited policies.", + "canonical": true, + "file": "jobs.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.run.v2.Jobs.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.iam.v1.GetPolicyOptions" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "JobsClient", + "fullName": "google.cloud.run.v2.JobsClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.run.v2.Jobs.GetIamPolicy", + "service": { + "shortName": "Jobs", + "fullName": "google.cloud.run.v2.Jobs" + } + } + } + }, + { + "regionTag": "run_v2_generated_Jobs_SetIamPolicy_async", + "title": "Executions setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the IAM Access control policy for the specified Job. Overwrites any existing policy.", + "canonical": true, + "file": "jobs.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.run.v2.Jobs.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "policy", + "type": ".google.iam.v1.Policy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "JobsClient", + "fullName": "google.cloud.run.v2.JobsClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.run.v2.Jobs.SetIamPolicy", + "service": { + "shortName": "Jobs", + "fullName": "google.cloud.run.v2.Jobs" + } + } + } + }, + { + "regionTag": "run_v2_generated_Jobs_TestIamPermissions_async", + "title": "Executions testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified Project. There are no permissions required for making this API call.", + "canonical": true, + "file": "jobs.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.run.v2.Jobs.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "permissions", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.iam.v1.TestIamPermissionsResponse", + "client": { + "shortName": "JobsClient", + "fullName": "google.cloud.run.v2.JobsClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.run.v2.Jobs.TestIamPermissions", + "service": { + "shortName": "Jobs", + "fullName": "google.cloud.run.v2.Jobs" + } + } + } + }, + { + "regionTag": "run_v2_generated_Revisions_GetRevision_async", + "title": "Executions getRevision Sample", + "origin": "API_DEFINITION", + "description": " Gets information about a Revision.", + "canonical": true, + "file": "revisions.get_revision.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetRevision", + "fullName": "google.cloud.run.v2.Revisions.GetRevision", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.run.v2.Revision", + "client": { + "shortName": "RevisionsClient", + "fullName": "google.cloud.run.v2.RevisionsClient" + }, + "method": { + "shortName": "GetRevision", + "fullName": "google.cloud.run.v2.Revisions.GetRevision", + "service": { + "shortName": "Revisions", + "fullName": "google.cloud.run.v2.Revisions" + } + } + } + }, + { + "regionTag": "run_v2_generated_Revisions_ListRevisions_async", + "title": "Executions listRevisions Sample", + "origin": "API_DEFINITION", + "description": " Lists Revisions from a given Service, or from a given location.", + "canonical": true, + "file": "revisions.list_revisions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListRevisions", + "fullName": "google.cloud.run.v2.Revisions.ListRevisions", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "show_deleted", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.run.v2.ListRevisionsResponse", + "client": { + "shortName": "RevisionsClient", + "fullName": "google.cloud.run.v2.RevisionsClient" + }, + "method": { + "shortName": "ListRevisions", + "fullName": "google.cloud.run.v2.Revisions.ListRevisions", + "service": { + "shortName": "Revisions", + "fullName": "google.cloud.run.v2.Revisions" + } + } + } + }, + { + "regionTag": "run_v2_generated_Revisions_DeleteRevision_async", + "title": "Executions deleteRevision Sample", + "origin": "API_DEFINITION", + "description": " Deletes a Revision.", + "canonical": true, + "file": "revisions.delete_revision.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteRevision", + "fullName": "google.cloud.run.v2.Revisions.DeleteRevision", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "RevisionsClient", + "fullName": "google.cloud.run.v2.RevisionsClient" + }, + "method": { + "shortName": "DeleteRevision", + "fullName": "google.cloud.run.v2.Revisions.DeleteRevision", + "service": { + "shortName": "Revisions", + "fullName": "google.cloud.run.v2.Revisions" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_CreateService_async", + "title": "Executions createService Sample", + "origin": "API_DEFINITION", + "description": " Creates a new Service in a given project and location.", + "canonical": true, + "file": "services.create_service.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 73, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateService", + "fullName": "google.cloud.run.v2.Services.CreateService", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "service", + "type": ".google.cloud.run.v2.Service" + }, + { + "name": "service_id", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "CreateService", + "fullName": "google.cloud.run.v2.Services.CreateService", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_GetService_async", + "title": "Executions getService Sample", + "origin": "API_DEFINITION", + "description": " Gets information about a Service.", + "canonical": true, + "file": "services.get_service.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetService", + "fullName": "google.cloud.run.v2.Services.GetService", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.run.v2.Service", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "GetService", + "fullName": "google.cloud.run.v2.Services.GetService", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_ListServices_async", + "title": "Executions listServices Sample", + "origin": "API_DEFINITION", + "description": " Lists Services.", + "canonical": true, + "file": "services.list_services.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListServices", + "fullName": "google.cloud.run.v2.Services.ListServices", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "show_deleted", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.run.v2.ListServicesResponse", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "ListServices", + "fullName": "google.cloud.run.v2.Services.ListServices", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_UpdateService_async", + "title": "Executions updateService Sample", + "origin": "API_DEFINITION", + "description": " Updates a Service.", + "canonical": true, + "file": "services.update_service.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateService", + "fullName": "google.cloud.run.v2.Services.UpdateService", + "async": true, + "parameters": [ + { + "name": "service", + "type": ".google.cloud.run.v2.Service" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "UpdateService", + "fullName": "google.cloud.run.v2.Services.UpdateService", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_DeleteService_async", + "title": "Executions deleteService Sample", + "origin": "API_DEFINITION", + "description": " Deletes a Service. This will cause the Service to stop serving traffic and will delete all revisions.", + "canonical": true, + "file": "services.delete_service.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteService", + "fullName": "google.cloud.run.v2.Services.DeleteService", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "DeleteService", + "fullName": "google.cloud.run.v2.Services.DeleteService", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_GetIamPolicy_async", + "title": "Executions getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the IAM Access Control policy currently in effect for the given Cloud Run Service. This result does not include any inherited policies.", + "canonical": true, + "file": "services.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.run.v2.Services.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.iam.v1.GetPolicyOptions" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.run.v2.Services.GetIamPolicy", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_SetIamPolicy_async", + "title": "Executions setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the IAM Access control policy for the specified Service. Overwrites any existing policy.", + "canonical": true, + "file": "services.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.run.v2.Services.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "policy", + "type": ".google.iam.v1.Policy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.run.v2.Services.SetIamPolicy", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_TestIamPermissions_async", + "title": "Executions testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified Project. There are no permissions required for making this API call.", + "canonical": true, + "file": "services.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.run.v2.Services.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "permissions", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.iam.v1.TestIamPermissionsResponse", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.run.v2.Services.TestIamPermissions", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Tasks_GetTask_async", + "title": "Executions getTask Sample", + "origin": "API_DEFINITION", + "description": " Gets information about a Task.", + "canonical": true, + "file": "tasks.get_task.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetTask", + "fullName": "google.cloud.run.v2.Tasks.GetTask", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.run.v2.Task", + "client": { + "shortName": "TasksClient", + "fullName": "google.cloud.run.v2.TasksClient" + }, + "method": { + "shortName": "GetTask", + "fullName": "google.cloud.run.v2.Tasks.GetTask", + "service": { + "shortName": "Tasks", + "fullName": "google.cloud.run.v2.Tasks" + } + } + } + }, + { + "regionTag": "run_v2_generated_Tasks_ListTasks_async", + "title": "Executions listTasks Sample", + "origin": "API_DEFINITION", + "description": " Lists Tasks from an Execution of a Job.", + "canonical": true, + "file": "tasks.list_tasks.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListTasks", + "fullName": "google.cloud.run.v2.Tasks.ListTasks", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "show_deleted", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.run.v2.ListTasksResponse", + "client": { + "shortName": "TasksClient", + "fullName": "google.cloud.run.v2.TasksClient" + }, + "method": { + "shortName": "ListTasks", + "fullName": "google.cloud.run.v2.Tasks.ListTasks", + "service": { + "shortName": "Tasks", + "fullName": "google.cloud.run.v2.Tasks" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/tasks.get_task.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/tasks.get_task.js new file mode 100644 index 00000000000..211137155b1 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/tasks.get_task.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 run_v2_generated_Tasks_GetTask_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The full name of the Task. + * Format: + * projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task} + */ + // const name = 'abc123' + + // Imports the Run library + const {TasksClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new TasksClient(); + + async function callGetTask() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await runClient.getTask(request); + console.log(response); + } + + callGetTask(); + // [END run_v2_generated_Tasks_GetTask_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/tasks.list_tasks.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/tasks.list_tasks.js new file mode 100644 index 00000000000..6bb2c337ecb --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/tasks.list_tasks.js @@ -0,0 +1,79 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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 run_v2_generated_Tasks_ListTasks_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Execution from which the Tasks should be listed. + * To list all Tasks across Executions of a Job, use "-" instead of Execution + * name. To list all Tasks across Jobs, use "-" instead of Job name. Format: + * projects/{project}/locations/{location}/jobs/{job}/executions/{execution} + */ + // const parent = 'abc123' + /** + * Maximum number of Tasks to return in this call. + */ + // const pageSize = 1234 + /** + * A page token received from a previous call to ListTasks. + * All other parameters must match. + */ + // const pageToken = 'abc123' + /** + * If true, returns deleted (but unexpired) resources along with active ones. + */ + // const showDeleted = true + + // Imports the Run library + const {TasksClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new TasksClient(); + + async function callListTasks() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await runClient.listTasksAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListTasks(); + // [END run_v2_generated_Tasks_ListTasks_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/src/index.ts b/owl-bot-staging/google-cloud-run/v2/src/index.ts new file mode 100644 index 00000000000..5c10c55052f --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/src/index.ts @@ -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. ** + +import * as v2 from './v2'; +const ExecutionsClient = v2.ExecutionsClient; +type ExecutionsClient = v2.ExecutionsClient; +const JobsClient = v2.JobsClient; +type JobsClient = v2.JobsClient; +const RevisionsClient = v2.RevisionsClient; +type RevisionsClient = v2.RevisionsClient; +const ServicesClient = v2.ServicesClient; +type ServicesClient = v2.ServicesClient; +const TasksClient = v2.TasksClient; +type TasksClient = v2.TasksClient; +export {v2, ExecutionsClient, JobsClient, RevisionsClient, ServicesClient, TasksClient}; +export default {v2, ExecutionsClient, JobsClient, RevisionsClient, ServicesClient, TasksClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/executions_client.ts b/owl-bot-staging/google-cloud-run/v2/src/v2/executions_client.ts new file mode 100644 index 00000000000..191c4754a2f --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/src/v2/executions_client.ts @@ -0,0 +1,1349 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/executions_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './executions_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Cloud Run Execution Control Plane API. + * @class + * @memberof v2 + */ +export class ExecutionsClient { + 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; + executionsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ExecutionsClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 ExecutionsClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ExecutionsClient; + 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 { + 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 = { + executionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}' + ), + jobPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + revisionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/services/{service}/revisions/{revision}' + ), + servicePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/services/{service}' + ), + taskPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task}' + ), + }; + + // 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 = { + listExecutions: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'executions') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',},{selector: 'google.longrunning.Operations.WaitOperation',post: '/v2/{name=projects/*/locations/*/operations/*}:wait',body: '*',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const deleteExecutionResponse = protoFilesRoot.lookup( + '.google.cloud.run.v2.Execution') as gax.protobuf.Type; + const deleteExecutionMetadata = protoFilesRoot.lookup( + '.google.cloud.run.v2.Execution') as gax.protobuf.Type; + + this.descriptors.longrunning = { + deleteExecution: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteExecutionResponse.decode.bind(deleteExecutionResponse), + deleteExecutionMetadata.decode.bind(deleteExecutionMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.run.v2.Executions', 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.executionsStub) { + return this.executionsStub; + } + + // Put together the "service stub" for + // google.cloud.run.v2.Executions. + this.executionsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.run.v2.Executions') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.run.v2.Executions, + 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 executionsStubMethods = + ['getExecution', 'listExecutions', 'deleteExecution']; + for (const methodName of executionsStubMethods) { + const callPromise = this.executionsStub.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.executionsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'run.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 'run.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 information about an Execution. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full name of the Execution. + * Format: + * projects/{project}/locations/{location}/jobs/{job}/executions/{execution}, + * where {project} can be project id or number. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.run.v2.Execution|Execution}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/executions.get_execution.js + * region_tag:run_v2_generated_Executions_GetExecution_async + */ + getExecution( + request?: protos.google.cloud.run.v2.IGetExecutionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.run.v2.IExecution, + protos.google.cloud.run.v2.IGetExecutionRequest|undefined, {}|undefined + ]>; + getExecution( + request: protos.google.cloud.run.v2.IGetExecutionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.run.v2.IExecution, + protos.google.cloud.run.v2.IGetExecutionRequest|null|undefined, + {}|null|undefined>): void; + getExecution( + request: protos.google.cloud.run.v2.IGetExecutionRequest, + callback: Callback< + protos.google.cloud.run.v2.IExecution, + protos.google.cloud.run.v2.IGetExecutionRequest|null|undefined, + {}|null|undefined>): void; + getExecution( + request?: protos.google.cloud.run.v2.IGetExecutionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.run.v2.IExecution, + protos.google.cloud.run.v2.IGetExecutionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.run.v2.IExecution, + protos.google.cloud.run.v2.IGetExecutionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.run.v2.IExecution, + protos.google.cloud.run.v2.IGetExecutionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getExecution(request, options, callback); + } + +/** + * Deletes an Execution. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Execution to delete. + * Format: + * projects/{project}/locations/{location}/jobs/{job}/executions/{execution}, + * where {project} can be project id or number. + * @param {boolean} request.validateOnly + * Indicates that the request should be validated without actually + * deleting any resources. + * @param {string} request.etag + * A system-generated fingerprint for this version of the resource. + * This may be used to detect modification conflict during updates. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/executions.delete_execution.js + * region_tag:run_v2_generated_Executions_DeleteExecution_async + */ + deleteExecution( + request?: protos.google.cloud.run.v2.IDeleteExecutionRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteExecution( + request: protos.google.cloud.run.v2.IDeleteExecutionRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteExecution( + request: protos.google.cloud.run.v2.IDeleteExecutionRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteExecution( + request?: protos.google.cloud.run.v2.IDeleteExecutionRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteExecution(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteExecution()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/executions.delete_execution.js + * region_tag:run_v2_generated_Executions_DeleteExecution_async + */ + async checkDeleteExecutionProgress(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.deleteExecution, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists Executions from a Job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The Execution from which the Executions should be listed. + * To list all Executions across Jobs, use "-" instead of Job name. + * Format: projects/{project}/locations/{location}/jobs/{job}, where {project} + * can be project id or number. + * @param {number} request.pageSize + * Maximum number of Executions to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListExecutions. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.run.v2.Execution|Execution}. + * 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 `listExecutionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listExecutions( + request?: protos.google.cloud.run.v2.IListExecutionsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.run.v2.IExecution[], + protos.google.cloud.run.v2.IListExecutionsRequest|null, + protos.google.cloud.run.v2.IListExecutionsResponse + ]>; + listExecutions( + request: protos.google.cloud.run.v2.IListExecutionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.run.v2.IListExecutionsRequest, + protos.google.cloud.run.v2.IListExecutionsResponse|null|undefined, + protos.google.cloud.run.v2.IExecution>): void; + listExecutions( + request: protos.google.cloud.run.v2.IListExecutionsRequest, + callback: PaginationCallback< + protos.google.cloud.run.v2.IListExecutionsRequest, + protos.google.cloud.run.v2.IListExecutionsResponse|null|undefined, + protos.google.cloud.run.v2.IExecution>): void; + listExecutions( + request?: protos.google.cloud.run.v2.IListExecutionsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.run.v2.IListExecutionsRequest, + protos.google.cloud.run.v2.IListExecutionsResponse|null|undefined, + protos.google.cloud.run.v2.IExecution>, + callback?: PaginationCallback< + protos.google.cloud.run.v2.IListExecutionsRequest, + protos.google.cloud.run.v2.IListExecutionsResponse|null|undefined, + protos.google.cloud.run.v2.IExecution>): + Promise<[ + protos.google.cloud.run.v2.IExecution[], + protos.google.cloud.run.v2.IListExecutionsRequest|null, + protos.google.cloud.run.v2.IListExecutionsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listExecutions(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 Execution from which the Executions should be listed. + * To list all Executions across Jobs, use "-" instead of Job name. + * Format: projects/{project}/locations/{location}/jobs/{job}, where {project} + * can be project id or number. + * @param {number} request.pageSize + * Maximum number of Executions to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListExecutions. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @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 protos.google.cloud.run.v2.Execution|Execution} 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 `listExecutionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listExecutionsStream( + request?: protos.google.cloud.run.v2.IListExecutionsRequest, + 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['listExecutions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listExecutions.createStream( + this.innerApiCalls.listExecutions as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listExecutions`, 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 Execution from which the Executions should be listed. + * To list all Executions across Jobs, use "-" instead of Job name. + * Format: projects/{project}/locations/{location}/jobs/{job}, where {project} + * can be project id or number. + * @param {number} request.pageSize + * Maximum number of Executions to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListExecutions. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.run.v2.Execution|Execution}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v2/executions.list_executions.js + * region_tag:run_v2_generated_Executions_ListExecutions_async + */ + listExecutionsAsync( + request?: protos.google.cloud.run.v2.IListExecutionsRequest, + 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['listExecutions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listExecutions.asyncIterate( + this.innerApiCalls['listExecutions'] 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 execution resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @param {string} execution + * @returns {string} Resource name string. + */ + executionPath(project:string,location:string,job:string,execution:string) { + return this.pathTemplates.executionPathTemplate.render({ + project: project, + location: location, + job: job, + execution: execution, + }); + } + + /** + * Parse the project from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the project. + */ + matchProjectFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).project; + } + + /** + * Parse the location from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the location. + */ + matchLocationFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).location; + } + + /** + * Parse the job from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the job. + */ + matchJobFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).job; + } + + /** + * Parse the execution from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the execution. + */ + matchExecutionFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).execution; + } + + /** + * Return a fully-qualified job resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @returns {string} Resource name string. + */ + jobPath(project:string,location:string,job:string) { + return this.pathTemplates.jobPathTemplate.render({ + project: project, + location: location, + job: job, + }); + } + + /** + * Parse the project from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the project. + */ + matchProjectFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).project; + } + + /** + * Parse the location from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the location. + */ + matchLocationFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).location; + } + + /** + * Parse the job from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the job. + */ + matchJobFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).job; + } + + /** + * 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 project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified revision resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} service + * @param {string} revision + * @returns {string} Resource name string. + */ + revisionPath(project:string,location:string,service:string,revision:string) { + return this.pathTemplates.revisionPathTemplate.render({ + project: project, + location: location, + service: service, + revision: revision, + }); + } + + /** + * Parse the project from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).project; + } + + /** + * Parse the location from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the location. + */ + matchLocationFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).location; + } + + /** + * Parse the service from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the service. + */ + matchServiceFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).service; + } + + /** + * Parse the revision from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the revision. + */ + matchRevisionFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).revision; + } + + /** + * Return a fully-qualified service resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} service + * @returns {string} Resource name string. + */ + servicePath(project:string,location:string,service:string) { + return this.pathTemplates.servicePathTemplate.render({ + project: project, + location: location, + service: service, + }); + } + + /** + * Parse the project from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).project; + } + + /** + * Parse the location from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).location; + } + + /** + * Parse the service from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).service; + } + + /** + * Return a fully-qualified task resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @param {string} execution + * @param {string} task + * @returns {string} Resource name string. + */ + taskPath(project:string,location:string,job:string,execution:string,task:string) { + return this.pathTemplates.taskPathTemplate.render({ + project: project, + location: location, + job: job, + execution: execution, + task: task, + }); + } + + /** + * Parse the project from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the project. + */ + matchProjectFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).project; + } + + /** + * Parse the location from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the location. + */ + matchLocationFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).location; + } + + /** + * Parse the job from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the job. + */ + matchJobFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).job; + } + + /** + * Parse the execution from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the execution. + */ + matchExecutionFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).execution; + } + + /** + * Parse the task from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the task. + */ + matchTaskFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).task; + } + + /** + * 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.executionsStub && !this._terminated) { + return this.executionsStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/executions_client_config.json b/owl-bot-staging/google-cloud-run/v2/src/v2/executions_client_config.json new file mode 100644 index 00000000000..fadded8ee9a --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/src/v2/executions_client_config.json @@ -0,0 +1,38 @@ +{ + "interfaces": { + "google.cloud.run.v2.Executions": { + "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": { + "GetExecution": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListExecutions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteExecution": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/executions_proto_list.json b/owl-bot-staging/google-cloud-run/v2/src/v2/executions_proto_list.json new file mode 100644 index 00000000000..f6d18fdac6b --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/src/v2/executions_proto_list.json @@ -0,0 +1,14 @@ +[ + "../../protos/google/cloud/run/v2/condition.proto", + "../../protos/google/cloud/run/v2/execution.proto", + "../../protos/google/cloud/run/v2/execution_template.proto", + "../../protos/google/cloud/run/v2/job.proto", + "../../protos/google/cloud/run/v2/k8s.min.proto", + "../../protos/google/cloud/run/v2/revision.proto", + "../../protos/google/cloud/run/v2/revision_template.proto", + "../../protos/google/cloud/run/v2/service.proto", + "../../protos/google/cloud/run/v2/task.proto", + "../../protos/google/cloud/run/v2/task_template.proto", + "../../protos/google/cloud/run/v2/traffic_target.proto", + "../../protos/google/cloud/run/v2/vendor_settings.proto" +] diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/gapic_metadata.json b/owl-bot-staging/google-cloud-run/v2/src/v2/gapic_metadata.json new file mode 100644 index 00000000000..cfa5d3b6414 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/src/v2/gapic_metadata.json @@ -0,0 +1,349 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.run.v2", + "libraryPackage": "@google-cloud/run", + "services": { + "Executions": { + "clients": { + "grpc": { + "libraryClient": "ExecutionsClient", + "rpcs": { + "GetExecution": { + "methods": [ + "getExecution" + ] + }, + "DeleteExecution": { + "methods": [ + "deleteExecution" + ] + }, + "ListExecutions": { + "methods": [ + "listExecutions", + "listExecutionsStream", + "listExecutionsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ExecutionsClient", + "rpcs": { + "GetExecution": { + "methods": [ + "getExecution" + ] + }, + "DeleteExecution": { + "methods": [ + "deleteExecution" + ] + }, + "ListExecutions": { + "methods": [ + "listExecutions", + "listExecutionsStream", + "listExecutionsAsync" + ] + } + } + } + } + }, + "Jobs": { + "clients": { + "grpc": { + "libraryClient": "JobsClient", + "rpcs": { + "GetJob": { + "methods": [ + "getJob" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateJob": { + "methods": [ + "createJob" + ] + }, + "UpdateJob": { + "methods": [ + "updateJob" + ] + }, + "DeleteJob": { + "methods": [ + "deleteJob" + ] + }, + "RunJob": { + "methods": [ + "runJob" + ] + }, + "ListJobs": { + "methods": [ + "listJobs", + "listJobsStream", + "listJobsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "JobsClient", + "rpcs": { + "GetJob": { + "methods": [ + "getJob" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateJob": { + "methods": [ + "createJob" + ] + }, + "UpdateJob": { + "methods": [ + "updateJob" + ] + }, + "DeleteJob": { + "methods": [ + "deleteJob" + ] + }, + "RunJob": { + "methods": [ + "runJob" + ] + }, + "ListJobs": { + "methods": [ + "listJobs", + "listJobsStream", + "listJobsAsync" + ] + } + } + } + } + }, + "Revisions": { + "clients": { + "grpc": { + "libraryClient": "RevisionsClient", + "rpcs": { + "GetRevision": { + "methods": [ + "getRevision" + ] + }, + "DeleteRevision": { + "methods": [ + "deleteRevision" + ] + }, + "ListRevisions": { + "methods": [ + "listRevisions", + "listRevisionsStream", + "listRevisionsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RevisionsClient", + "rpcs": { + "GetRevision": { + "methods": [ + "getRevision" + ] + }, + "DeleteRevision": { + "methods": [ + "deleteRevision" + ] + }, + "ListRevisions": { + "methods": [ + "listRevisions", + "listRevisionsStream", + "listRevisionsAsync" + ] + } + } + } + } + }, + "Services": { + "clients": { + "grpc": { + "libraryClient": "ServicesClient", + "rpcs": { + "GetService": { + "methods": [ + "getService" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateService": { + "methods": [ + "createService" + ] + }, + "UpdateService": { + "methods": [ + "updateService" + ] + }, + "DeleteService": { + "methods": [ + "deleteService" + ] + }, + "ListServices": { + "methods": [ + "listServices", + "listServicesStream", + "listServicesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ServicesClient", + "rpcs": { + "GetService": { + "methods": [ + "getService" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateService": { + "methods": [ + "createService" + ] + }, + "UpdateService": { + "methods": [ + "updateService" + ] + }, + "DeleteService": { + "methods": [ + "deleteService" + ] + }, + "ListServices": { + "methods": [ + "listServices", + "listServicesStream", + "listServicesAsync" + ] + } + } + } + } + }, + "Tasks": { + "clients": { + "grpc": { + "libraryClient": "TasksClient", + "rpcs": { + "GetTask": { + "methods": [ + "getTask" + ] + }, + "ListTasks": { + "methods": [ + "listTasks", + "listTasksStream", + "listTasksAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "TasksClient", + "rpcs": { + "GetTask": { + "methods": [ + "getTask" + ] + }, + "ListTasks": { + "methods": [ + "listTasks", + "listTasksStream", + "listTasksAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/index.ts b/owl-bot-staging/google-cloud-run/v2/src/v2/index.ts new file mode 100644 index 00000000000..126c1e5f73f --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/src/v2/index.ts @@ -0,0 +1,23 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ExecutionsClient} from './executions_client'; +export {JobsClient} from './jobs_client'; +export {RevisionsClient} from './revisions_client'; +export {ServicesClient} from './services_client'; +export {TasksClient} from './tasks_client'; diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/jobs_client.ts b/owl-bot-staging/google-cloud-run/v2/src/v2/jobs_client.ts new file mode 100644 index 00000000000..6d9ef6a7a79 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/src/v2/jobs_client.ts @@ -0,0 +1,1896 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/jobs_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './jobs_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Cloud Run Job Control Plane API. + * @class + * @memberof v2 + */ +export class JobsClient { + 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; + jobsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of JobsClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 JobsClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof JobsClient; + 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 { + 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 = { + executionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}' + ), + jobPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + revisionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/services/{service}/revisions/{revision}' + ), + servicePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/services/{service}' + ), + taskPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task}' + ), + }; + + // 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 = { + listJobs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'jobs') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',},{selector: 'google.longrunning.Operations.WaitOperation',post: '/v2/{name=projects/*/locations/*/operations/*}:wait',body: '*',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createJobResponse = protoFilesRoot.lookup( + '.google.cloud.run.v2.Job') as gax.protobuf.Type; + const createJobMetadata = protoFilesRoot.lookup( + '.google.cloud.run.v2.Job') as gax.protobuf.Type; + const updateJobResponse = protoFilesRoot.lookup( + '.google.cloud.run.v2.Job') as gax.protobuf.Type; + const updateJobMetadata = protoFilesRoot.lookup( + '.google.cloud.run.v2.Job') as gax.protobuf.Type; + const deleteJobResponse = protoFilesRoot.lookup( + '.google.cloud.run.v2.Job') as gax.protobuf.Type; + const deleteJobMetadata = protoFilesRoot.lookup( + '.google.cloud.run.v2.Job') as gax.protobuf.Type; + const runJobResponse = protoFilesRoot.lookup( + '.google.cloud.run.v2.Execution') as gax.protobuf.Type; + const runJobMetadata = protoFilesRoot.lookup( + '.google.cloud.run.v2.Execution') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createJob: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createJobResponse.decode.bind(createJobResponse), + createJobMetadata.decode.bind(createJobMetadata)), + updateJob: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateJobResponse.decode.bind(updateJobResponse), + updateJobMetadata.decode.bind(updateJobMetadata)), + deleteJob: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteJobResponse.decode.bind(deleteJobResponse), + deleteJobMetadata.decode.bind(deleteJobMetadata)), + runJob: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + runJobResponse.decode.bind(runJobResponse), + runJobMetadata.decode.bind(runJobMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.run.v2.Jobs', 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.jobsStub) { + return this.jobsStub; + } + + // Put together the "service stub" for + // google.cloud.run.v2.Jobs. + this.jobsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.run.v2.Jobs') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.run.v2.Jobs, + 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 jobsStubMethods = + ['createJob', 'getJob', 'listJobs', 'updateJob', 'deleteJob', 'runJob', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of jobsStubMethods) { + const callPromise = this.jobsStub.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.jobsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'run.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 'run.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 information about a Job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full name of the Job. + * Format: projects/{project}/locations/{location}/jobs/{job}, where {project} + * can be project id or number. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.run.v2.Job|Job}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/jobs.get_job.js + * region_tag:run_v2_generated_Jobs_GetJob_async + */ + getJob( + request?: protos.google.cloud.run.v2.IGetJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.run.v2.IJob, + protos.google.cloud.run.v2.IGetJobRequest|undefined, {}|undefined + ]>; + getJob( + request: protos.google.cloud.run.v2.IGetJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.run.v2.IJob, + protos.google.cloud.run.v2.IGetJobRequest|null|undefined, + {}|null|undefined>): void; + getJob( + request: protos.google.cloud.run.v2.IGetJobRequest, + callback: Callback< + protos.google.cloud.run.v2.IJob, + protos.google.cloud.run.v2.IGetJobRequest|null|undefined, + {}|null|undefined>): void; + getJob( + request?: protos.google.cloud.run.v2.IGetJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.run.v2.IJob, + protos.google.cloud.run.v2.IGetJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.run.v2.IJob, + protos.google.cloud.run.v2.IGetJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.run.v2.IJob, + protos.google.cloud.run.v2.IGetJobRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getJob(request, options, callback); + } +/** + * Gets the IAM Access Control policy currently in effect for the given Job. + * This result does not include any inherited policies. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/jobs.get_iam_policy.js + * region_tag:run_v2_generated_Jobs_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Sets the IAM Access control policy for the specified Job. Overwrites + * any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/jobs.set_iam_policy.js + * region_tag:run_v2_generated_Jobs_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified Project. + * + * There are no permissions required for making this API call. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/jobs.test_iam_permissions.js + * region_tag:run_v2_generated_Jobs_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + +/** + * Creates a Job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location and project in which this Job should be created. + * Format: projects/{project}/locations/{location}, where {project} can be + * project id or number. + * @param {google.cloud.run.v2.Job} request.job + * Required. The Job instance to create. + * @param {string} request.jobId + * Required. The unique identifier for the Job. The name of the job becomes + * {parent}/jobs/{job_id}. + * @param {boolean} request.validateOnly + * Indicates that the request should be validated and default values + * populated, without persisting the request or creating any resources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/jobs.create_job.js + * region_tag:run_v2_generated_Jobs_CreateJob_async + */ + createJob( + request?: protos.google.cloud.run.v2.ICreateJobRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createJob( + request: protos.google.cloud.run.v2.ICreateJobRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createJob( + request: protos.google.cloud.run.v2.ICreateJobRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createJob( + request?: protos.google.cloud.run.v2.ICreateJobRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createJob(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createJob()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/jobs.create_job.js + * region_tag:run_v2_generated_Jobs_CreateJob_async + */ + async checkCreateJobProgress(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.createJob, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates a Job. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.run.v2.Job} request.job + * Required. The Job to be updated. + * @param {boolean} request.validateOnly + * Indicates that the request should be validated and default values + * populated, without persisting the request or updating any resources. + * @param {boolean} request.allowMissing + * If set to true, and if the Job does not exist, it will create a new + * one. Caller must have both create and update permissions for this call if + * this is set to true. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/jobs.update_job.js + * region_tag:run_v2_generated_Jobs_UpdateJob_async + */ + updateJob( + request?: protos.google.cloud.run.v2.IUpdateJobRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateJob( + request: protos.google.cloud.run.v2.IUpdateJobRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateJob( + request: protos.google.cloud.run.v2.IUpdateJobRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateJob( + request?: protos.google.cloud.run.v2.IUpdateJobRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'job.name': request.job!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateJob(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateJob()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/jobs.update_job.js + * region_tag:run_v2_generated_Jobs_UpdateJob_async + */ + async checkUpdateJobProgress(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.updateJob, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a Job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full name of the Job. + * Format: projects/{project}/locations/{location}/jobs/{job}, where {project} + * can be project id or number. + * @param {boolean} request.validateOnly + * Indicates that the request should be validated without actually + * deleting any resources. + * @param {string} request.etag + * A system-generated fingerprint for this version of the + * resource. May be used to detect modification conflict during updates. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/jobs.delete_job.js + * region_tag:run_v2_generated_Jobs_DeleteJob_async + */ + deleteJob( + request?: protos.google.cloud.run.v2.IDeleteJobRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteJob( + request: protos.google.cloud.run.v2.IDeleteJobRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteJob( + request: protos.google.cloud.run.v2.IDeleteJobRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteJob( + request?: protos.google.cloud.run.v2.IDeleteJobRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteJob(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteJob()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/jobs.delete_job.js + * region_tag:run_v2_generated_Jobs_DeleteJob_async + */ + async checkDeleteJobProgress(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.deleteJob, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Triggers creation of a new Execution of this Job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full name of the Job. + * Format: projects/{project}/locations/{location}/jobs/{job}, where {project} + * can be project id or number. + * @param {boolean} request.validateOnly + * Indicates that the request should be validated without actually + * deleting any resources. + * @param {string} request.etag + * A system-generated fingerprint for this version of the + * resource. May be used to detect modification conflict during updates. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/jobs.run_job.js + * region_tag:run_v2_generated_Jobs_RunJob_async + */ + runJob( + request?: protos.google.cloud.run.v2.IRunJobRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + runJob( + request: protos.google.cloud.run.v2.IRunJobRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + runJob( + request: protos.google.cloud.run.v2.IRunJobRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + runJob( + request?: protos.google.cloud.run.v2.IRunJobRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.runJob(request, options, callback); + } +/** + * Check the status of the long running operation returned by `runJob()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/jobs.run_job.js + * region_tag:run_v2_generated_Jobs_RunJob_async + */ + async checkRunJobProgress(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.runJob, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists Jobs. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location and project to list resources on. + * Format: projects/{project}/locations/{location}, where {project} can be + * project id or number. + * @param {number} request.pageSize + * Maximum number of Jobs to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListJobs. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.run.v2.Job|Job}. + * 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 `listJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listJobs( + request?: protos.google.cloud.run.v2.IListJobsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.run.v2.IJob[], + protos.google.cloud.run.v2.IListJobsRequest|null, + protos.google.cloud.run.v2.IListJobsResponse + ]>; + listJobs( + request: protos.google.cloud.run.v2.IListJobsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.run.v2.IListJobsRequest, + protos.google.cloud.run.v2.IListJobsResponse|null|undefined, + protos.google.cloud.run.v2.IJob>): void; + listJobs( + request: protos.google.cloud.run.v2.IListJobsRequest, + callback: PaginationCallback< + protos.google.cloud.run.v2.IListJobsRequest, + protos.google.cloud.run.v2.IListJobsResponse|null|undefined, + protos.google.cloud.run.v2.IJob>): void; + listJobs( + request?: protos.google.cloud.run.v2.IListJobsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.run.v2.IListJobsRequest, + protos.google.cloud.run.v2.IListJobsResponse|null|undefined, + protos.google.cloud.run.v2.IJob>, + callback?: PaginationCallback< + protos.google.cloud.run.v2.IListJobsRequest, + protos.google.cloud.run.v2.IListJobsResponse|null|undefined, + protos.google.cloud.run.v2.IJob>): + Promise<[ + protos.google.cloud.run.v2.IJob[], + protos.google.cloud.run.v2.IListJobsRequest|null, + protos.google.cloud.run.v2.IListJobsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listJobs(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location and project to list resources on. + * Format: projects/{project}/locations/{location}, where {project} can be + * project id or number. + * @param {number} request.pageSize + * Maximum number of Jobs to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListJobs. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @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 protos.google.cloud.run.v2.Job|Job} 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 `listJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listJobsStream( + request?: protos.google.cloud.run.v2.IListJobsRequest, + 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['listJobs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listJobs.createStream( + this.innerApiCalls.listJobs as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listJobs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location and project to list resources on. + * Format: projects/{project}/locations/{location}, where {project} can be + * project id or number. + * @param {number} request.pageSize + * Maximum number of Jobs to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListJobs. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.run.v2.Job|Job}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v2/jobs.list_jobs.js + * region_tag:run_v2_generated_Jobs_ListJobs_async + */ + listJobsAsync( + request?: protos.google.cloud.run.v2.IListJobsRequest, + 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['listJobs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listJobs.asyncIterate( + this.innerApiCalls['listJobs'] 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 execution resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @param {string} execution + * @returns {string} Resource name string. + */ + executionPath(project:string,location:string,job:string,execution:string) { + return this.pathTemplates.executionPathTemplate.render({ + project: project, + location: location, + job: job, + execution: execution, + }); + } + + /** + * Parse the project from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the project. + */ + matchProjectFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).project; + } + + /** + * Parse the location from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the location. + */ + matchLocationFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).location; + } + + /** + * Parse the job from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the job. + */ + matchJobFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).job; + } + + /** + * Parse the execution from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the execution. + */ + matchExecutionFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).execution; + } + + /** + * Return a fully-qualified job resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @returns {string} Resource name string. + */ + jobPath(project:string,location:string,job:string) { + return this.pathTemplates.jobPathTemplate.render({ + project: project, + location: location, + job: job, + }); + } + + /** + * Parse the project from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the project. + */ + matchProjectFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).project; + } + + /** + * Parse the location from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the location. + */ + matchLocationFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).location; + } + + /** + * Parse the job from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the job. + */ + matchJobFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).job; + } + + /** + * 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 project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified revision resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} service + * @param {string} revision + * @returns {string} Resource name string. + */ + revisionPath(project:string,location:string,service:string,revision:string) { + return this.pathTemplates.revisionPathTemplate.render({ + project: project, + location: location, + service: service, + revision: revision, + }); + } + + /** + * Parse the project from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).project; + } + + /** + * Parse the location from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the location. + */ + matchLocationFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).location; + } + + /** + * Parse the service from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the service. + */ + matchServiceFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).service; + } + + /** + * Parse the revision from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the revision. + */ + matchRevisionFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).revision; + } + + /** + * Return a fully-qualified service resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} service + * @returns {string} Resource name string. + */ + servicePath(project:string,location:string,service:string) { + return this.pathTemplates.servicePathTemplate.render({ + project: project, + location: location, + service: service, + }); + } + + /** + * Parse the project from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).project; + } + + /** + * Parse the location from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).location; + } + + /** + * Parse the service from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).service; + } + + /** + * Return a fully-qualified task resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @param {string} execution + * @param {string} task + * @returns {string} Resource name string. + */ + taskPath(project:string,location:string,job:string,execution:string,task:string) { + return this.pathTemplates.taskPathTemplate.render({ + project: project, + location: location, + job: job, + execution: execution, + task: task, + }); + } + + /** + * Parse the project from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the project. + */ + matchProjectFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).project; + } + + /** + * Parse the location from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the location. + */ + matchLocationFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).location; + } + + /** + * Parse the job from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the job. + */ + matchJobFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).job; + } + + /** + * Parse the execution from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the execution. + */ + matchExecutionFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).execution; + } + + /** + * Parse the task from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the task. + */ + matchTaskFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).task; + } + + /** + * 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.jobsStub && !this._terminated) { + return this.jobsStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/jobs_client_config.json b/owl-bot-staging/google-cloud-run/v2/src/v2/jobs_client_config.json new file mode 100644 index 00000000000..0751746db74 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/src/v2/jobs_client_config.json @@ -0,0 +1,62 @@ +{ + "interfaces": { + "google.cloud.run.v2.Jobs": { + "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": { + "CreateJob": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetJob": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListJobs": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateJob": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteJob": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RunJob": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/jobs_proto_list.json b/owl-bot-staging/google-cloud-run/v2/src/v2/jobs_proto_list.json new file mode 100644 index 00000000000..f6d18fdac6b --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/src/v2/jobs_proto_list.json @@ -0,0 +1,14 @@ +[ + "../../protos/google/cloud/run/v2/condition.proto", + "../../protos/google/cloud/run/v2/execution.proto", + "../../protos/google/cloud/run/v2/execution_template.proto", + "../../protos/google/cloud/run/v2/job.proto", + "../../protos/google/cloud/run/v2/k8s.min.proto", + "../../protos/google/cloud/run/v2/revision.proto", + "../../protos/google/cloud/run/v2/revision_template.proto", + "../../protos/google/cloud/run/v2/service.proto", + "../../protos/google/cloud/run/v2/task.proto", + "../../protos/google/cloud/run/v2/task_template.proto", + "../../protos/google/cloud/run/v2/traffic_target.proto", + "../../protos/google/cloud/run/v2/vendor_settings.proto" +] diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/revisions_client.ts b/owl-bot-staging/google-cloud-run/v2/src/v2/revisions_client.ts new file mode 100644 index 00000000000..2a059a40327 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/src/v2/revisions_client.ts @@ -0,0 +1,1467 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/revisions_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './revisions_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Cloud Run Revision Control Plane API. + * @class + * @memberof v2 + */ +export class RevisionsClient { + 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; + revisionsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RevisionsClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 RevisionsClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RevisionsClient; + 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 { + 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 = { + cryptoKeyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}' + ), + executionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}' + ), + jobPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + revisionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/services/{service}/revisions/{revision}' + ), + servicePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/services/{service}' + ), + taskPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task}' + ), + }; + + // 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 = { + listRevisions: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'revisions') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',},{selector: 'google.longrunning.Operations.WaitOperation',post: '/v2/{name=projects/*/locations/*/operations/*}:wait',body: '*',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const deleteRevisionResponse = protoFilesRoot.lookup( + '.google.cloud.run.v2.Revision') as gax.protobuf.Type; + const deleteRevisionMetadata = protoFilesRoot.lookup( + '.google.cloud.run.v2.Revision') as gax.protobuf.Type; + + this.descriptors.longrunning = { + deleteRevision: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteRevisionResponse.decode.bind(deleteRevisionResponse), + deleteRevisionMetadata.decode.bind(deleteRevisionMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.run.v2.Revisions', 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.revisionsStub) { + return this.revisionsStub; + } + + // Put together the "service stub" for + // google.cloud.run.v2.Revisions. + this.revisionsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.run.v2.Revisions') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.run.v2.Revisions, + 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 revisionsStubMethods = + ['getRevision', 'listRevisions', 'deleteRevision']; + for (const methodName of revisionsStubMethods) { + const callPromise = this.revisionsStub.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.revisionsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'run.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 'run.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 information about a Revision. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full name of the Revision. + * Format: + * projects/{project}/locations/{location}/services/{service}/revisions/{revision} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.run.v2.Revision|Revision}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/revisions.get_revision.js + * region_tag:run_v2_generated_Revisions_GetRevision_async + */ + getRevision( + request?: protos.google.cloud.run.v2.IGetRevisionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.run.v2.IRevision, + protos.google.cloud.run.v2.IGetRevisionRequest|undefined, {}|undefined + ]>; + getRevision( + request: protos.google.cloud.run.v2.IGetRevisionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.run.v2.IRevision, + protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, + {}|null|undefined>): void; + getRevision( + request: protos.google.cloud.run.v2.IGetRevisionRequest, + callback: Callback< + protos.google.cloud.run.v2.IRevision, + protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, + {}|null|undefined>): void; + getRevision( + request?: protos.google.cloud.run.v2.IGetRevisionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.run.v2.IRevision, + protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.run.v2.IRevision, + protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.run.v2.IRevision, + protos.google.cloud.run.v2.IGetRevisionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.name; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.getRevision(request, options, callback); + } + +/** + * Deletes a Revision. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Revision to delete. + * Format: + * projects/{project}/locations/{location}/services/{service}/revisions/{revision} + * @param {boolean} request.validateOnly + * Indicates that the request should be validated without actually + * deleting any resources. + * @param {string} request.etag + * A system-generated fingerprint for this version of the + * resource. This may be used to detect modification conflict during updates. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/revisions.delete_revision.js + * region_tag:run_v2_generated_Revisions_DeleteRevision_async + */ + deleteRevision( + request?: protos.google.cloud.run.v2.IDeleteRevisionRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteRevision( + request: protos.google.cloud.run.v2.IDeleteRevisionRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteRevision( + request: protos.google.cloud.run.v2.IDeleteRevisionRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteRevision( + request?: protos.google.cloud.run.v2.IDeleteRevisionRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.name; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.deleteRevision(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteRevision()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/revisions.delete_revision.js + * region_tag:run_v2_generated_Revisions_DeleteRevision_async + */ + async checkDeleteRevisionProgress(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.deleteRevision, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists Revisions from a given Service, or from a given location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The Service from which the Revisions should be listed. + * To list all Revisions across Services, use "-" instead of Service name. + * Format: + * projects/{project}/locations/{location}/services/{service} + * @param {number} request.pageSize + * Maximum number of revisions to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListRevisions. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.run.v2.Revision|Revision}. + * 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 `listRevisionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listRevisions( + request?: protos.google.cloud.run.v2.IListRevisionsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.run.v2.IRevision[], + protos.google.cloud.run.v2.IListRevisionsRequest|null, + protos.google.cloud.run.v2.IListRevisionsResponse + ]>; + listRevisions( + request: protos.google.cloud.run.v2.IListRevisionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.run.v2.IListRevisionsRequest, + protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, + protos.google.cloud.run.v2.IRevision>): void; + listRevisions( + request: protos.google.cloud.run.v2.IListRevisionsRequest, + callback: PaginationCallback< + protos.google.cloud.run.v2.IListRevisionsRequest, + protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, + protos.google.cloud.run.v2.IRevision>): void; + listRevisions( + request?: protos.google.cloud.run.v2.IListRevisionsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.run.v2.IListRevisionsRequest, + protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, + protos.google.cloud.run.v2.IRevision>, + callback?: PaginationCallback< + protos.google.cloud.run.v2.IListRevisionsRequest, + protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, + protos.google.cloud.run.v2.IRevision>): + Promise<[ + protos.google.cloud.run.v2.IRevision[], + protos.google.cloud.run.v2.IListRevisionsRequest|null, + protos.google.cloud.run.v2.IListRevisionsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.listRevisions(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 Service from which the Revisions should be listed. + * To list all Revisions across Services, use "-" instead of Service name. + * Format: + * projects/{project}/locations/{location}/services/{service} + * @param {number} request.pageSize + * Maximum number of revisions to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListRevisions. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @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 protos.google.cloud.run.v2.Revision|Revision} 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 `listRevisionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listRevisionsStream( + request?: protos.google.cloud.run.v2.IListRevisionsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + const defaultCallSettings = this._defaults['listRevisions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRevisions.createStream( + this.innerApiCalls.listRevisions as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listRevisions`, 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 Service from which the Revisions should be listed. + * To list all Revisions across Services, use "-" instead of Service name. + * Format: + * projects/{project}/locations/{location}/services/{service} + * @param {number} request.pageSize + * Maximum number of revisions to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListRevisions. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.run.v2.Revision|Revision}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v2/revisions.list_revisions.js + * region_tag:run_v2_generated_Revisions_ListRevisions_async + */ + listRevisionsAsync( + request?: protos.google.cloud.run.v2.IListRevisionsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + const defaultCallSettings = this._defaults['listRevisions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRevisions.asyncIterate( + this.innerApiCalls['listRevisions'] 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 cryptoKey resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} key_ring + * @param {string} crypto_key + * @returns {string} Resource name string. + */ + cryptoKeyPath(project:string,location:string,keyRing:string,cryptoKey:string) { + return this.pathTemplates.cryptoKeyPathTemplate.render({ + project: project, + location: location, + key_ring: keyRing, + crypto_key: cryptoKey, + }); + } + + /** + * Parse the project from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).project; + } + + /** + * Parse the location from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).location; + } + + /** + * Parse the key_ring from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the key_ring. + */ + matchKeyRingFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).key_ring; + } + + /** + * Parse the crypto_key from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the crypto_key. + */ + matchCryptoKeyFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).crypto_key; + } + + /** + * Return a fully-qualified execution resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @param {string} execution + * @returns {string} Resource name string. + */ + executionPath(project:string,location:string,job:string,execution:string) { + return this.pathTemplates.executionPathTemplate.render({ + project: project, + location: location, + job: job, + execution: execution, + }); + } + + /** + * Parse the project from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the project. + */ + matchProjectFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).project; + } + + /** + * Parse the location from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the location. + */ + matchLocationFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).location; + } + + /** + * Parse the job from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the job. + */ + matchJobFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).job; + } + + /** + * Parse the execution from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the execution. + */ + matchExecutionFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).execution; + } + + /** + * Return a fully-qualified job resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @returns {string} Resource name string. + */ + jobPath(project:string,location:string,job:string) { + return this.pathTemplates.jobPathTemplate.render({ + project: project, + location: location, + job: job, + }); + } + + /** + * Parse the project from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the project. + */ + matchProjectFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).project; + } + + /** + * Parse the location from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the location. + */ + matchLocationFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).location; + } + + /** + * Parse the job from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the job. + */ + matchJobFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).job; + } + + /** + * 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 project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified revision resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} service + * @param {string} revision + * @returns {string} Resource name string. + */ + revisionPath(project:string,location:string,service:string,revision:string) { + return this.pathTemplates.revisionPathTemplate.render({ + project: project, + location: location, + service: service, + revision: revision, + }); + } + + /** + * Parse the project from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).project; + } + + /** + * Parse the location from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the location. + */ + matchLocationFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).location; + } + + /** + * Parse the service from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the service. + */ + matchServiceFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).service; + } + + /** + * Parse the revision from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the revision. + */ + matchRevisionFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).revision; + } + + /** + * Return a fully-qualified service resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} service + * @returns {string} Resource name string. + */ + servicePath(project:string,location:string,service:string) { + return this.pathTemplates.servicePathTemplate.render({ + project: project, + location: location, + service: service, + }); + } + + /** + * Parse the project from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).project; + } + + /** + * Parse the location from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).location; + } + + /** + * Parse the service from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).service; + } + + /** + * Return a fully-qualified task resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @param {string} execution + * @param {string} task + * @returns {string} Resource name string. + */ + taskPath(project:string,location:string,job:string,execution:string,task:string) { + return this.pathTemplates.taskPathTemplate.render({ + project: project, + location: location, + job: job, + execution: execution, + task: task, + }); + } + + /** + * Parse the project from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the project. + */ + matchProjectFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).project; + } + + /** + * Parse the location from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the location. + */ + matchLocationFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).location; + } + + /** + * Parse the job from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the job. + */ + matchJobFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).job; + } + + /** + * Parse the execution from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the execution. + */ + matchExecutionFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).execution; + } + + /** + * Parse the task from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the task. + */ + matchTaskFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).task; + } + + /** + * 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.revisionsStub && !this._terminated) { + return this.revisionsStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/revisions_client_config.json b/owl-bot-staging/google-cloud-run/v2/src/v2/revisions_client_config.json new file mode 100644 index 00000000000..f5a18a2ed2b --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/src/v2/revisions_client_config.json @@ -0,0 +1,38 @@ +{ + "interfaces": { + "google.cloud.run.v2.Revisions": { + "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": { + "GetRevision": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListRevisions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteRevision": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/revisions_proto_list.json b/owl-bot-staging/google-cloud-run/v2/src/v2/revisions_proto_list.json new file mode 100644 index 00000000000..f6d18fdac6b --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/src/v2/revisions_proto_list.json @@ -0,0 +1,14 @@ +[ + "../../protos/google/cloud/run/v2/condition.proto", + "../../protos/google/cloud/run/v2/execution.proto", + "../../protos/google/cloud/run/v2/execution_template.proto", + "../../protos/google/cloud/run/v2/job.proto", + "../../protos/google/cloud/run/v2/k8s.min.proto", + "../../protos/google/cloud/run/v2/revision.proto", + "../../protos/google/cloud/run/v2/revision_template.proto", + "../../protos/google/cloud/run/v2/service.proto", + "../../protos/google/cloud/run/v2/task.proto", + "../../protos/google/cloud/run/v2/task_template.proto", + "../../protos/google/cloud/run/v2/traffic_target.proto", + "../../protos/google/cloud/run/v2/vendor_settings.proto" +] diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/services_client.ts b/owl-bot-staging/google-cloud-run/v2/src/v2/services_client.ts new file mode 100644 index 00000000000..7f30cc23110 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/src/v2/services_client.ts @@ -0,0 +1,1874 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/services_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './services_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Cloud Run Service Control Plane API + * @class + * @memberof v2 + */ +export class ServicesClient { + 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; + servicesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ServicesClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 ServicesClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ServicesClient; + 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 { + 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 = { + executionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}' + ), + jobPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + revisionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/services/{service}/revisions/{revision}' + ), + servicePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/services/{service}' + ), + taskPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task}' + ), + }; + + // 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 = { + listServices: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'services') + }; + + 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) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',},{selector: 'google.longrunning.Operations.WaitOperation',post: '/v2/{name=projects/*/locations/*/operations/*}:wait',body: '*',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createServiceResponse = protoFilesRoot.lookup( + '.google.cloud.run.v2.Service') as gax.protobuf.Type; + const createServiceMetadata = protoFilesRoot.lookup( + '.google.cloud.run.v2.Service') as gax.protobuf.Type; + const updateServiceResponse = protoFilesRoot.lookup( + '.google.cloud.run.v2.Service') as gax.protobuf.Type; + const updateServiceMetadata = protoFilesRoot.lookup( + '.google.cloud.run.v2.Service') as gax.protobuf.Type; + const deleteServiceResponse = protoFilesRoot.lookup( + '.google.cloud.run.v2.Service') as gax.protobuf.Type; + const deleteServiceMetadata = protoFilesRoot.lookup( + '.google.cloud.run.v2.Service') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createService: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createServiceResponse.decode.bind(createServiceResponse), + createServiceMetadata.decode.bind(createServiceMetadata)), + updateService: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateServiceResponse.decode.bind(updateServiceResponse), + updateServiceMetadata.decode.bind(updateServiceMetadata)), + deleteService: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteServiceResponse.decode.bind(deleteServiceResponse), + deleteServiceMetadata.decode.bind(deleteServiceMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.run.v2.Services', 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.servicesStub) { + return this.servicesStub; + } + + // Put together the "service stub" for + // google.cloud.run.v2.Services. + this.servicesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.run.v2.Services') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.run.v2.Services, + 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 servicesStubMethods = + ['createService', 'getService', 'listServices', 'updateService', 'deleteService', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of servicesStubMethods) { + const callPromise = this.servicesStub.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.servicesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'run.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 'run.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 information about a Service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full name of the Service. + * Format: projects/{project}/locations/{location}/services/{service}, where + * {project} can be project id or number. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.run.v2.Service|Service}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/services.get_service.js + * region_tag:run_v2_generated_Services_GetService_async + */ + getService( + request?: protos.google.cloud.run.v2.IGetServiceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.run.v2.IService, + protos.google.cloud.run.v2.IGetServiceRequest|undefined, {}|undefined + ]>; + getService( + request: protos.google.cloud.run.v2.IGetServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.run.v2.IService, + protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, + {}|null|undefined>): void; + getService( + request: protos.google.cloud.run.v2.IGetServiceRequest, + callback: Callback< + protos.google.cloud.run.v2.IService, + protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, + {}|null|undefined>): void; + getService( + request?: protos.google.cloud.run.v2.IGetServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.run.v2.IService, + protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.run.v2.IService, + protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.run.v2.IService, + protos.google.cloud.run.v2.IGetServiceRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.name; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.getService(request, options, callback); + } +/** + * Gets the IAM Access Control policy currently in effect for the given + * Cloud Run Service. This result does not include any inherited policies. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/services.get_iam_policy.js + * region_tag:run_v2_generated_Services_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Sets the IAM Access control policy for the specified Service. Overwrites + * any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/services.set_iam_policy.js + * region_tag:run_v2_generated_Services_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified Project. + * + * There are no permissions required for making this API call. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/services.test_iam_permissions.js + * region_tag:run_v2_generated_Services_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + +/** + * Creates a new Service in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location and project in which this service should be created. + * Format: projects/{project}/locations/{location}, where {project} can be + * project id or number. Only lowercase characters, digits, and hyphens. + * @param {google.cloud.run.v2.Service} request.service + * Required. The Service instance to create. + * @param {string} request.serviceId + * Required. The unique identifier for the Service. It must begin with letter, + * and cannot end with hyphen; must contain fewer than 50 characters. + * The name of the service becomes {parent}/services/{service_id}. + * @param {boolean} request.validateOnly + * Indicates that the request should be validated and default values + * populated, without persisting the request or creating any resources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/services.create_service.js + * region_tag:run_v2_generated_Services_CreateService_async + */ + createService( + request?: protos.google.cloud.run.v2.ICreateServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createService( + request: protos.google.cloud.run.v2.ICreateServiceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createService( + request: protos.google.cloud.run.v2.ICreateServiceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createService( + request?: protos.google.cloud.run.v2.ICreateServiceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.createService(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createService()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/services.create_service.js + * region_tag:run_v2_generated_Services_CreateService_async + */ + async checkCreateServiceProgress(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.createService, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates a Service. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.run.v2.Service} request.service + * Required. The Service to be updated. + * @param {boolean} request.validateOnly + * Indicates that the request should be validated and default values + * populated, without persisting the request or updating any resources. + * @param {boolean} request.allowMissing + * If set to true, and if the Service does not exist, it will create a new + * one. The caller must have 'run.services.create' permissions if this is set + * to true and the Service does not exist. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/services.update_service.js + * region_tag:run_v2_generated_Services_UpdateService_async + */ + updateService( + request?: protos.google.cloud.run.v2.IUpdateServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateService( + request: protos.google.cloud.run.v2.IUpdateServiceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateService( + request: protos.google.cloud.run.v2.IUpdateServiceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateService( + request?: protos.google.cloud.run.v2.IUpdateServiceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.service?.name; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.updateService(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateService()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/services.update_service.js + * region_tag:run_v2_generated_Services_UpdateService_async + */ + async checkUpdateServiceProgress(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.updateService, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a Service. + * This will cause the Service to stop serving traffic and will delete all + * revisions. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full name of the Service. + * Format: projects/{project}/locations/{location}/services/{service}, where + * {project} can be project id or number. + * @param {boolean} request.validateOnly + * Indicates that the request should be validated without actually + * deleting any resources. + * @param {string} request.etag + * A system-generated fingerprint for this version of the + * resource. May be used to detect modification conflict during updates. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/services.delete_service.js + * region_tag:run_v2_generated_Services_DeleteService_async + */ + deleteService( + request?: protos.google.cloud.run.v2.IDeleteServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteService( + request: protos.google.cloud.run.v2.IDeleteServiceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteService( + request: protos.google.cloud.run.v2.IDeleteServiceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteService( + request?: protos.google.cloud.run.v2.IDeleteServiceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.name; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.deleteService(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteService()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2/services.delete_service.js + * region_tag:run_v2_generated_Services_DeleteService_async + */ + async checkDeleteServiceProgress(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.deleteService, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists Services. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location and project to list resources on. + * Location must be a valid Google Cloud region, and cannot be the "-" + * wildcard. Format: projects/{project}/locations/{location}, where {project} + * can be project id or number. + * @param {number} request.pageSize + * Maximum number of Services to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListServices. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.run.v2.Service|Service}. + * 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 `listServicesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listServices( + request?: protos.google.cloud.run.v2.IListServicesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.run.v2.IService[], + protos.google.cloud.run.v2.IListServicesRequest|null, + protos.google.cloud.run.v2.IListServicesResponse + ]>; + listServices( + request: protos.google.cloud.run.v2.IListServicesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.run.v2.IListServicesRequest, + protos.google.cloud.run.v2.IListServicesResponse|null|undefined, + protos.google.cloud.run.v2.IService>): void; + listServices( + request: protos.google.cloud.run.v2.IListServicesRequest, + callback: PaginationCallback< + protos.google.cloud.run.v2.IListServicesRequest, + protos.google.cloud.run.v2.IListServicesResponse|null|undefined, + protos.google.cloud.run.v2.IService>): void; + listServices( + request?: protos.google.cloud.run.v2.IListServicesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.run.v2.IListServicesRequest, + protos.google.cloud.run.v2.IListServicesResponse|null|undefined, + protos.google.cloud.run.v2.IService>, + callback?: PaginationCallback< + protos.google.cloud.run.v2.IListServicesRequest, + protos.google.cloud.run.v2.IListServicesResponse|null|undefined, + protos.google.cloud.run.v2.IService>): + Promise<[ + protos.google.cloud.run.v2.IService[], + protos.google.cloud.run.v2.IListServicesRequest|null, + protos.google.cloud.run.v2.IListServicesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.listServices(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location and project to list resources on. + * Location must be a valid Google Cloud region, and cannot be the "-" + * wildcard. Format: projects/{project}/locations/{location}, where {project} + * can be project id or number. + * @param {number} request.pageSize + * Maximum number of Services to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListServices. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @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 protos.google.cloud.run.v2.Service|Service} 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 `listServicesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listServicesStream( + request?: protos.google.cloud.run.v2.IListServicesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + const defaultCallSettings = this._defaults['listServices']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServices.createStream( + this.innerApiCalls.listServices as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listServices`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location and project to list resources on. + * Location must be a valid Google Cloud region, and cannot be the "-" + * wildcard. Format: projects/{project}/locations/{location}, where {project} + * can be project id or number. + * @param {number} request.pageSize + * Maximum number of Services to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListServices. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.run.v2.Service|Service}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v2/services.list_services.js + * region_tag:run_v2_generated_Services_ListServices_async + */ + listServicesAsync( + request?: protos.google.cloud.run.v2.IListServicesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + const defaultCallSettings = this._defaults['listServices']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServices.asyncIterate( + this.innerApiCalls['listServices'] 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 execution resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @param {string} execution + * @returns {string} Resource name string. + */ + executionPath(project:string,location:string,job:string,execution:string) { + return this.pathTemplates.executionPathTemplate.render({ + project: project, + location: location, + job: job, + execution: execution, + }); + } + + /** + * Parse the project from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the project. + */ + matchProjectFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).project; + } + + /** + * Parse the location from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the location. + */ + matchLocationFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).location; + } + + /** + * Parse the job from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the job. + */ + matchJobFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).job; + } + + /** + * Parse the execution from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the execution. + */ + matchExecutionFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).execution; + } + + /** + * Return a fully-qualified job resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @returns {string} Resource name string. + */ + jobPath(project:string,location:string,job:string) { + return this.pathTemplates.jobPathTemplate.render({ + project: project, + location: location, + job: job, + }); + } + + /** + * Parse the project from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the project. + */ + matchProjectFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).project; + } + + /** + * Parse the location from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the location. + */ + matchLocationFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).location; + } + + /** + * Parse the job from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the job. + */ + matchJobFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).job; + } + + /** + * 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 project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified revision resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} service + * @param {string} revision + * @returns {string} Resource name string. + */ + revisionPath(project:string,location:string,service:string,revision:string) { + return this.pathTemplates.revisionPathTemplate.render({ + project: project, + location: location, + service: service, + revision: revision, + }); + } + + /** + * Parse the project from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).project; + } + + /** + * Parse the location from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the location. + */ + matchLocationFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).location; + } + + /** + * Parse the service from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the service. + */ + matchServiceFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).service; + } + + /** + * Parse the revision from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the revision. + */ + matchRevisionFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).revision; + } + + /** + * Return a fully-qualified service resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} service + * @returns {string} Resource name string. + */ + servicePath(project:string,location:string,service:string) { + return this.pathTemplates.servicePathTemplate.render({ + project: project, + location: location, + service: service, + }); + } + + /** + * Parse the project from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).project; + } + + /** + * Parse the location from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).location; + } + + /** + * Parse the service from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).service; + } + + /** + * Return a fully-qualified task resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @param {string} execution + * @param {string} task + * @returns {string} Resource name string. + */ + taskPath(project:string,location:string,job:string,execution:string,task:string) { + return this.pathTemplates.taskPathTemplate.render({ + project: project, + location: location, + job: job, + execution: execution, + task: task, + }); + } + + /** + * Parse the project from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the project. + */ + matchProjectFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).project; + } + + /** + * Parse the location from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the location. + */ + matchLocationFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).location; + } + + /** + * Parse the job from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the job. + */ + matchJobFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).job; + } + + /** + * Parse the execution from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the execution. + */ + matchExecutionFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).execution; + } + + /** + * Parse the task from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the task. + */ + matchTaskFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).task; + } + + /** + * 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.servicesStub && !this._terminated) { + return this.servicesStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/services_client_config.json b/owl-bot-staging/google-cloud-run/v2/src/v2/services_client_config.json new file mode 100644 index 00000000000..d9a33646b69 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/src/v2/services_client_config.json @@ -0,0 +1,75 @@ +{ + "interfaces": { + "google.cloud.run.v2.Services": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateService": { + "timeout_millis": 15000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetService": { + "timeout_millis": 10000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "ListServices": { + "timeout_millis": 10000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "UpdateService": { + "timeout_millis": 15000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteService": { + "timeout_millis": 10000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/services_proto_list.json b/owl-bot-staging/google-cloud-run/v2/src/v2/services_proto_list.json new file mode 100644 index 00000000000..f6d18fdac6b --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/src/v2/services_proto_list.json @@ -0,0 +1,14 @@ +[ + "../../protos/google/cloud/run/v2/condition.proto", + "../../protos/google/cloud/run/v2/execution.proto", + "../../protos/google/cloud/run/v2/execution_template.proto", + "../../protos/google/cloud/run/v2/job.proto", + "../../protos/google/cloud/run/v2/k8s.min.proto", + "../../protos/google/cloud/run/v2/revision.proto", + "../../protos/google/cloud/run/v2/revision_template.proto", + "../../protos/google/cloud/run/v2/service.proto", + "../../protos/google/cloud/run/v2/task.proto", + "../../protos/google/cloud/run/v2/task_template.proto", + "../../protos/google/cloud/run/v2/traffic_target.proto", + "../../protos/google/cloud/run/v2/vendor_settings.proto" +] diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/tasks_client.ts b/owl-bot-staging/google-cloud-run/v2/src/v2/tasks_client.ts new file mode 100644 index 00000000000..acee35d2327 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/src/v2/tasks_client.ts @@ -0,0 +1,1112 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, 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/tasks_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './tasks_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Cloud Run Task Control Plane API. + * @class + * @memberof v2 + */ +export class TasksClient { + 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}; + tasksStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of TasksClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 TasksClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof TasksClient; + 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 { + 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 = { + cryptoKeyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}' + ), + executionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}' + ), + jobPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + revisionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/services/{service}/revisions/{revision}' + ), + servicePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/services/{service}' + ), + taskPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task}' + ), + }; + + // 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 = { + listTasks: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tasks') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.run.v2.Tasks', 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.tasksStub) { + return this.tasksStub; + } + + // Put together the "service stub" for + // google.cloud.run.v2.Tasks. + this.tasksStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.run.v2.Tasks') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.run.v2.Tasks, + 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 tasksStubMethods = + ['getTask', 'listTasks']; + for (const methodName of tasksStubMethods) { + const callPromise = this.tasksStub.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.tasksStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'run.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 'run.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 information about a Task. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full name of the Task. + * Format: + * projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.run.v2.Task|Task}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/tasks.get_task.js + * region_tag:run_v2_generated_Tasks_GetTask_async + */ + getTask( + request?: protos.google.cloud.run.v2.IGetTaskRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.run.v2.ITask, + protos.google.cloud.run.v2.IGetTaskRequest|undefined, {}|undefined + ]>; + getTask( + request: protos.google.cloud.run.v2.IGetTaskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.run.v2.ITask, + protos.google.cloud.run.v2.IGetTaskRequest|null|undefined, + {}|null|undefined>): void; + getTask( + request: protos.google.cloud.run.v2.IGetTaskRequest, + callback: Callback< + protos.google.cloud.run.v2.ITask, + protos.google.cloud.run.v2.IGetTaskRequest|null|undefined, + {}|null|undefined>): void; + getTask( + request?: protos.google.cloud.run.v2.IGetTaskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.run.v2.ITask, + protos.google.cloud.run.v2.IGetTaskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.run.v2.ITask, + protos.google.cloud.run.v2.IGetTaskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.run.v2.ITask, + protos.google.cloud.run.v2.IGetTaskRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getTask(request, options, callback); + } + + /** + * Lists Tasks from an Execution of a Job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The Execution from which the Tasks should be listed. + * To list all Tasks across Executions of a Job, use "-" instead of Execution + * name. To list all Tasks across Jobs, use "-" instead of Job name. Format: + * projects/{project}/locations/{location}/jobs/{job}/executions/{execution} + * @param {number} request.pageSize + * Maximum number of Tasks to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListTasks. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.run.v2.Task|Task}. + * 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 `listTasksAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listTasks( + request?: protos.google.cloud.run.v2.IListTasksRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.run.v2.ITask[], + protos.google.cloud.run.v2.IListTasksRequest|null, + protos.google.cloud.run.v2.IListTasksResponse + ]>; + listTasks( + request: protos.google.cloud.run.v2.IListTasksRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.run.v2.IListTasksRequest, + protos.google.cloud.run.v2.IListTasksResponse|null|undefined, + protos.google.cloud.run.v2.ITask>): void; + listTasks( + request: protos.google.cloud.run.v2.IListTasksRequest, + callback: PaginationCallback< + protos.google.cloud.run.v2.IListTasksRequest, + protos.google.cloud.run.v2.IListTasksResponse|null|undefined, + protos.google.cloud.run.v2.ITask>): void; + listTasks( + request?: protos.google.cloud.run.v2.IListTasksRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.run.v2.IListTasksRequest, + protos.google.cloud.run.v2.IListTasksResponse|null|undefined, + protos.google.cloud.run.v2.ITask>, + callback?: PaginationCallback< + protos.google.cloud.run.v2.IListTasksRequest, + protos.google.cloud.run.v2.IListTasksResponse|null|undefined, + protos.google.cloud.run.v2.ITask>): + Promise<[ + protos.google.cloud.run.v2.ITask[], + protos.google.cloud.run.v2.IListTasksRequest|null, + protos.google.cloud.run.v2.IListTasksResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listTasks(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 Execution from which the Tasks should be listed. + * To list all Tasks across Executions of a Job, use "-" instead of Execution + * name. To list all Tasks across Jobs, use "-" instead of Job name. Format: + * projects/{project}/locations/{location}/jobs/{job}/executions/{execution} + * @param {number} request.pageSize + * Maximum number of Tasks to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListTasks. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @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 protos.google.cloud.run.v2.Task|Task} 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 `listTasksAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listTasksStream( + request?: protos.google.cloud.run.v2.IListTasksRequest, + 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['listTasks']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTasks.createStream( + this.innerApiCalls.listTasks as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listTasks`, 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 Execution from which the Tasks should be listed. + * To list all Tasks across Executions of a Job, use "-" instead of Execution + * name. To list all Tasks across Jobs, use "-" instead of Job name. Format: + * projects/{project}/locations/{location}/jobs/{job}/executions/{execution} + * @param {number} request.pageSize + * Maximum number of Tasks to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListTasks. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.run.v2.Task|Task}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v2/tasks.list_tasks.js + * region_tag:run_v2_generated_Tasks_ListTasks_async + */ + listTasksAsync( + request?: protos.google.cloud.run.v2.IListTasksRequest, + 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['listTasks']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTasks.asyncIterate( + this.innerApiCalls['listTasks'] 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified cryptoKey resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} key_ring + * @param {string} crypto_key + * @returns {string} Resource name string. + */ + cryptoKeyPath(project:string,location:string,keyRing:string,cryptoKey:string) { + return this.pathTemplates.cryptoKeyPathTemplate.render({ + project: project, + location: location, + key_ring: keyRing, + crypto_key: cryptoKey, + }); + } + + /** + * Parse the project from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).project; + } + + /** + * Parse the location from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).location; + } + + /** + * Parse the key_ring from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the key_ring. + */ + matchKeyRingFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).key_ring; + } + + /** + * Parse the crypto_key from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the crypto_key. + */ + matchCryptoKeyFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).crypto_key; + } + + /** + * Return a fully-qualified execution resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @param {string} execution + * @returns {string} Resource name string. + */ + executionPath(project:string,location:string,job:string,execution:string) { + return this.pathTemplates.executionPathTemplate.render({ + project: project, + location: location, + job: job, + execution: execution, + }); + } + + /** + * Parse the project from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the project. + */ + matchProjectFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).project; + } + + /** + * Parse the location from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the location. + */ + matchLocationFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).location; + } + + /** + * Parse the job from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the job. + */ + matchJobFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).job; + } + + /** + * Parse the execution from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the execution. + */ + matchExecutionFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).execution; + } + + /** + * Return a fully-qualified job resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @returns {string} Resource name string. + */ + jobPath(project:string,location:string,job:string) { + return this.pathTemplates.jobPathTemplate.render({ + project: project, + location: location, + job: job, + }); + } + + /** + * Parse the project from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the project. + */ + matchProjectFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).project; + } + + /** + * Parse the location from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the location. + */ + matchLocationFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).location; + } + + /** + * Parse the job from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the job. + */ + matchJobFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).job; + } + + /** + * 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 project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified revision resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} service + * @param {string} revision + * @returns {string} Resource name string. + */ + revisionPath(project:string,location:string,service:string,revision:string) { + return this.pathTemplates.revisionPathTemplate.render({ + project: project, + location: location, + service: service, + revision: revision, + }); + } + + /** + * Parse the project from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).project; + } + + /** + * Parse the location from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the location. + */ + matchLocationFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).location; + } + + /** + * Parse the service from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the service. + */ + matchServiceFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).service; + } + + /** + * Parse the revision from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the revision. + */ + matchRevisionFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).revision; + } + + /** + * Return a fully-qualified service resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} service + * @returns {string} Resource name string. + */ + servicePath(project:string,location:string,service:string) { + return this.pathTemplates.servicePathTemplate.render({ + project: project, + location: location, + service: service, + }); + } + + /** + * Parse the project from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).project; + } + + /** + * Parse the location from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).location; + } + + /** + * Parse the service from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).service; + } + + /** + * Return a fully-qualified task resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @param {string} execution + * @param {string} task + * @returns {string} Resource name string. + */ + taskPath(project:string,location:string,job:string,execution:string,task:string) { + return this.pathTemplates.taskPathTemplate.render({ + project: project, + location: location, + job: job, + execution: execution, + task: task, + }); + } + + /** + * Parse the project from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the project. + */ + matchProjectFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).project; + } + + /** + * Parse the location from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the location. + */ + matchLocationFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).location; + } + + /** + * Parse the job from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the job. + */ + matchJobFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).job; + } + + /** + * Parse the execution from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the execution. + */ + matchExecutionFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).execution; + } + + /** + * Parse the task from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the task. + */ + matchTaskFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).task; + } + + /** + * 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.tasksStub && !this._terminated) { + return this.tasksStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/tasks_client_config.json b/owl-bot-staging/google-cloud-run/v2/src/v2/tasks_client_config.json new file mode 100644 index 00000000000..c9fe28e061c --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/src/v2/tasks_client_config.json @@ -0,0 +1,34 @@ +{ + "interfaces": { + "google.cloud.run.v2.Tasks": { + "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": { + "GetTask": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListTasks": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/tasks_proto_list.json b/owl-bot-staging/google-cloud-run/v2/src/v2/tasks_proto_list.json new file mode 100644 index 00000000000..f6d18fdac6b --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/src/v2/tasks_proto_list.json @@ -0,0 +1,14 @@ +[ + "../../protos/google/cloud/run/v2/condition.proto", + "../../protos/google/cloud/run/v2/execution.proto", + "../../protos/google/cloud/run/v2/execution_template.proto", + "../../protos/google/cloud/run/v2/job.proto", + "../../protos/google/cloud/run/v2/k8s.min.proto", + "../../protos/google/cloud/run/v2/revision.proto", + "../../protos/google/cloud/run/v2/revision_template.proto", + "../../protos/google/cloud/run/v2/service.proto", + "../../protos/google/cloud/run/v2/task.proto", + "../../protos/google/cloud/run/v2/task_template.proto", + "../../protos/google/cloud/run/v2/traffic_target.proto", + "../../protos/google/cloud/run/v2/vendor_settings.proto" +] diff --git a/owl-bot-staging/google-cloud-run/v2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-run/v2/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..f91d0fdb85e --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/system-test/fixtures/sample/src/index.js @@ -0,0 +1,31 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 run = require('@google-cloud/run'); + +function main() { + const executionsClient = new run.ExecutionsClient(); + const jobsClient = new run.JobsClient(); + const revisionsClient = new run.RevisionsClient(); + const servicesClient = new run.ServicesClient(); + const tasksClient = new run.TasksClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-run/v2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-run/v2/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..d1dc2ca2135 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,56 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {ExecutionsClient, JobsClient, RevisionsClient, ServicesClient, TasksClient} from '@google-cloud/run'; + +// check that the client class type name can be used +function doStuffWithExecutionsClient(client: ExecutionsClient) { + client.close(); +} +function doStuffWithJobsClient(client: JobsClient) { + client.close(); +} +function doStuffWithRevisionsClient(client: RevisionsClient) { + client.close(); +} +function doStuffWithServicesClient(client: ServicesClient) { + client.close(); +} +function doStuffWithTasksClient(client: TasksClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const executionsClient = new ExecutionsClient(); + doStuffWithExecutionsClient(executionsClient); + // check that the client instance can be created + const jobsClient = new JobsClient(); + doStuffWithJobsClient(jobsClient); + // check that the client instance can be created + const revisionsClient = new RevisionsClient(); + doStuffWithRevisionsClient(revisionsClient); + // check that the client instance can be created + const servicesClient = new ServicesClient(); + doStuffWithServicesClient(servicesClient); + // check that the client instance can be created + const tasksClient = new TasksClient(); + doStuffWithTasksClient(tasksClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-run/v2/system-test/install.ts b/owl-bot-staging/google-cloud-run/v2/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/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-run/v2/test/gapic_executions_v2.ts b/owl-bot-staging/google-cloud-run/v2/test/gapic_executions_v2.ts new file mode 100644 index 00000000000..657aaf35b3f --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/test/gapic_executions_v2.ts @@ -0,0 +1,1474 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 executionsModule 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.ExecutionsClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = executionsModule.v2.ExecutionsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = executionsModule.v2.ExecutionsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = executionsModule.v2.ExecutionsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new executionsModule.v2.ExecutionsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new executionsModule.v2.ExecutionsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.executionsStub, undefined); + await client.initialize(); + assert(client.executionsStub); + }); + + it('has close method for the initialized client', done => { + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.executionsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.executionsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new executionsModule.v2.ExecutionsClient({ + 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 executionsModule.v2.ExecutionsClient({ + 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('getExecution', () => { + it('invokes getExecution without error', async () => { + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetExecutionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.GetExecutionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.run.v2.Execution() + ); + client.innerApiCalls.getExecution = stubSimpleCall(expectedResponse); + const [response] = await client.getExecution(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getExecution as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getExecution as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getExecution without error using callback', async () => { + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetExecutionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.GetExecutionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.run.v2.Execution() + ); + client.innerApiCalls.getExecution = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getExecution( + request, + (err?: Error|null, result?: protos.google.cloud.run.v2.IExecution|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getExecution as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getExecution as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getExecution with error', async () => { + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetExecutionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.GetExecutionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getExecution = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getExecution(request), expectedError); + const actualRequest = (client.innerApiCalls.getExecution as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getExecution as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getExecution with closed client', async () => { + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetExecutionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.GetExecutionRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getExecution(request), expectedError); + }); + }); + + describe('deleteExecution', () => { + it('invokes deleteExecution without error', async () => { + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.DeleteExecutionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.DeleteExecutionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteExecution = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteExecution(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteExecution as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteExecution as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteExecution without error using callback', async () => { + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.DeleteExecutionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.DeleteExecutionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteExecution = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteExecution( + request, + (err?: Error|null, + result?: 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.deleteExecution as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteExecution as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteExecution with call error', async () => { + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.DeleteExecutionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.DeleteExecutionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteExecution = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteExecution(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteExecution as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteExecution as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteExecution with LRO error', async () => { + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.DeleteExecutionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.DeleteExecutionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteExecution = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteExecution(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteExecution as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteExecution as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteExecutionProgress without error', async () => { + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteExecutionProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteExecutionProgress with error', async () => { + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteExecutionProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listExecutions', () => { + it('invokes listExecutions without error', async () => { + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListExecutionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.ListExecutionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Execution()), + generateSampleMessage(new protos.google.cloud.run.v2.Execution()), + generateSampleMessage(new protos.google.cloud.run.v2.Execution()), + ]; + client.innerApiCalls.listExecutions = stubSimpleCall(expectedResponse); + const [response] = await client.listExecutions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listExecutions without error using callback', async () => { + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListExecutionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.ListExecutionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Execution()), + generateSampleMessage(new protos.google.cloud.run.v2.Execution()), + generateSampleMessage(new protos.google.cloud.run.v2.Execution()), + ]; + client.innerApiCalls.listExecutions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listExecutions( + request, + (err?: Error|null, result?: protos.google.cloud.run.v2.IExecution[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listExecutions with error', async () => { + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListExecutionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.ListExecutionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listExecutions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listExecutions(request), expectedError); + const actualRequest = (client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listExecutionsStream without error', async () => { + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListExecutionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.ListExecutionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Execution()), + generateSampleMessage(new protos.google.cloud.run.v2.Execution()), + generateSampleMessage(new protos.google.cloud.run.v2.Execution()), + ]; + client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listExecutionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.run.v2.Execution[] = []; + stream.on('data', (response: protos.google.cloud.run.v2.Execution) => { + 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.listExecutions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); + assert( + (client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listExecutionsStream with error', async () => { + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListExecutionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.ListExecutionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listExecutionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.run.v2.Execution[] = []; + stream.on('data', (response: protos.google.cloud.run.v2.Execution) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); + assert( + (client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listExecutions without error', async () => { + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListExecutionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.ListExecutionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Execution()), + generateSampleMessage(new protos.google.cloud.run.v2.Execution()), + generateSampleMessage(new protos.google.cloud.run.v2.Execution()), + ]; + client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.run.v2.IExecution[] = []; + const iterable = client.listExecutionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listExecutions with error', async () => { + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListExecutionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.ListExecutionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listExecutionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.run.v2.IExecution[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listExecutions.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 executionsModule.v2.ExecutionsClient({ + 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 executionsModule.v2.ExecutionsClient({ + 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 executionsModule.v2.ExecutionsClient({ + 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 executionsModule.v2.ExecutionsClient({ + 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 executionsModule.v2.ExecutionsClient({ + 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 executionsModule.v2.ExecutionsClient({ + 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 executionsModule.v2.ExecutionsClient({ + 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 executionsModule.v2.ExecutionsClient({ + 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 executionsModule.v2.ExecutionsClient({ + 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 executionsModule.v2.ExecutionsClient({ + 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 executionsModule.v2.ExecutionsClient({ + 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 executionsModule.v2.ExecutionsClient({ + 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 executionsModule.v2.ExecutionsClient({ + 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 executionsModule.v2.ExecutionsClient({ + 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 executionsModule.v2.ExecutionsClient({ + 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 executionsModule.v2.ExecutionsClient({ + 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('execution', () => { + const fakePath = "/rendered/path/execution"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + execution: "executionValue", + }; + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.executionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.executionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('executionPath', () => { + const result = client.executionPath("projectValue", "locationValue", "jobValue", "executionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.executionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromExecutionName', () => { + const result = client.matchProjectFromExecutionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromExecutionName', () => { + const result = client.matchLocationFromExecutionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromExecutionName', () => { + const result = client.matchJobFromExecutionName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchExecutionFromExecutionName', () => { + const result = client.matchExecutionFromExecutionName(fakePath); + assert.strictEqual(result, "executionValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('job', () => { + const fakePath = "/rendered/path/job"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + }; + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.jobPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.jobPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('jobPath', () => { + const result = client.jobPath("projectValue", "locationValue", "jobValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.jobPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromJobName', () => { + const result = client.matchProjectFromJobName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromJobName', () => { + const result = client.matchLocationFromJobName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromJobName', () => { + const result = client.matchJobFromJobName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new executionsModule.v2.ExecutionsClient({ + 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('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('revision', () => { + const fakePath = "/rendered/path/revision"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + service: "serviceValue", + revision: "revisionValue", + }; + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.revisionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.revisionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('revisionPath', () => { + const result = client.revisionPath("projectValue", "locationValue", "serviceValue", "revisionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.revisionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRevisionName', () => { + const result = client.matchProjectFromRevisionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromRevisionName', () => { + const result = client.matchLocationFromRevisionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServiceFromRevisionName', () => { + const result = client.matchServiceFromRevisionName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRevisionFromRevisionName', () => { + const result = client.matchRevisionFromRevisionName(fakePath); + assert.strictEqual(result, "revisionValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('service', () => { + const fakePath = "/rendered/path/service"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + service: "serviceValue", + }; + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servicePath', () => { + const result = client.servicePath("projectValue", "locationValue", "serviceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servicePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServiceName', () => { + const result = client.matchProjectFromServiceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServiceName', () => { + const result = client.matchLocationFromServiceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServiceFromServiceName', () => { + const result = client.matchServiceFromServiceName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('task', () => { + const fakePath = "/rendered/path/task"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + execution: "executionValue", + task: "taskValue", + }; + const client = new executionsModule.v2.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.taskPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.taskPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('taskPath', () => { + const result = client.taskPath("projectValue", "locationValue", "jobValue", "executionValue", "taskValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.taskPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromTaskName', () => { + const result = client.matchProjectFromTaskName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromTaskName', () => { + const result = client.matchLocationFromTaskName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromTaskName', () => { + const result = client.matchJobFromTaskName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchExecutionFromTaskName', () => { + const result = client.matchExecutionFromTaskName(fakePath); + assert.strictEqual(result, "executionValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchTaskFromTaskName', () => { + const result = client.matchTaskFromTaskName(fakePath); + assert.strictEqual(result, "taskValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-run/v2/test/gapic_jobs_v2.ts b/owl-bot-staging/google-cloud-run/v2/test/gapic_jobs_v2.ts new file mode 100644 index 00000000000..69d0b0ae38f --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/test/gapic_jobs_v2.ts @@ -0,0 +1,2264 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 jobsModule 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.JobsClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = jobsModule.v2.JobsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = jobsModule.v2.JobsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = jobsModule.v2.JobsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new jobsModule.v2.JobsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new jobsModule.v2.JobsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.jobsStub, undefined); + await client.initialize(); + assert(client.jobsStub); + }); + + it('has close method for the initialized client', done => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.jobsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.jobsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new jobsModule.v2.JobsClient({ + 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 jobsModule.v2.JobsClient({ + 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('getJob', () => { + it('invokes getJob without error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.run.v2.Job() + ); + client.innerApiCalls.getJob = stubSimpleCall(expectedResponse); + const [response] = await client.getJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getJob without error using callback', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.run.v2.Job() + ); + client.innerApiCalls.getJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getJob( + request, + (err?: Error|null, result?: protos.google.cloud.run.v2.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getJob with error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getJob(request), expectedError); + const actualRequest = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getJob with closed client', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getJob(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('createJob', () => { + it('invokes createJob without error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createJob = stubLongRunningCall(expectedResponse); + const [operation] = await client.createJob(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createJob without error using callback', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createJob = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createJob( + request, + (err?: Error|null, + result?: 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.createJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createJob with call error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createJob = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createJob(request), expectedError); + const actualRequest = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createJob with LRO error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createJob = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createJob(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateJobProgress without error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateJobProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateJobProgress with error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateJobProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateJob', () => { + it('invokes updateJob without error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.UpdateJobRequest() + ); + request.job ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.UpdateJobRequest', ['job', 'name']); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateJob = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateJob(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateJob without error using callback', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.UpdateJobRequest() + ); + request.job ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.UpdateJobRequest', ['job', 'name']); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateJob = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateJob( + request, + (err?: Error|null, + result?: 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.updateJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateJob with call error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.UpdateJobRequest() + ); + request.job ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.UpdateJobRequest', ['job', 'name']); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateJob = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateJob(request), expectedError); + const actualRequest = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateJob with LRO error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.UpdateJobRequest() + ); + request.job ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.UpdateJobRequest', ['job', 'name']); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateJob = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateJob(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateJobProgress without error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateJobProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateJobProgress with error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateJobProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteJob', () => { + it('invokes deleteJob without error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteJob = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteJob(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteJob without error using callback', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteJob = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteJob( + request, + (err?: Error|null, + result?: 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.deleteJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteJob with call error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteJob = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteJob(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteJob with LRO error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteJob = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteJob(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteJobProgress without error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteJobProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteJobProgress with error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteJobProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('runJob', () => { + it('invokes runJob without error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.RunJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.RunJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.runJob = stubLongRunningCall(expectedResponse); + const [operation] = await client.runJob(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runJob without error using callback', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.RunJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.RunJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.runJob = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.runJob( + request, + (err?: Error|null, + result?: 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.runJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runJob with call error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.RunJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.RunJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.runJob = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.runJob(request), expectedError); + const actualRequest = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runJob with LRO error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.RunJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.RunJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.runJob = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.runJob(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkRunJobProgress without error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRunJobProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRunJobProgress with error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRunJobProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listJobs', () => { + it('invokes listJobs without error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Job()), + generateSampleMessage(new protos.google.cloud.run.v2.Job()), + generateSampleMessage(new protos.google.cloud.run.v2.Job()), + ]; + client.innerApiCalls.listJobs = stubSimpleCall(expectedResponse); + const [response] = await client.listJobs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listJobs without error using callback', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Job()), + generateSampleMessage(new protos.google.cloud.run.v2.Job()), + generateSampleMessage(new protos.google.cloud.run.v2.Job()), + ]; + client.innerApiCalls.listJobs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listJobs( + request, + (err?: Error|null, result?: protos.google.cloud.run.v2.IJob[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listJobs with error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listJobs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listJobs(request), expectedError); + const actualRequest = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listJobsStream without error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Job()), + generateSampleMessage(new protos.google.cloud.run.v2.Job()), + generateSampleMessage(new protos.google.cloud.run.v2.Job()), + ]; + client.descriptors.page.listJobs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.run.v2.Job[] = []; + stream.on('data', (response: protos.google.cloud.run.v2.Job) => { + 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.listJobs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listJobsStream with error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listJobs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.run.v2.Job[] = []; + stream.on('data', (response: protos.google.cloud.run.v2.Job) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listJobs without error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Job()), + generateSampleMessage(new protos.google.cloud.run.v2.Job()), + generateSampleMessage(new protos.google.cloud.run.v2.Job()), + ]; + client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.run.v2.IJob[] = []; + const iterable = client.listJobsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listJobs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listJobs with error', async () => { + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listJobsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.run.v2.IJob[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listJobs.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 jobsModule.v2.JobsClient({ + 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 jobsModule.v2.JobsClient({ + 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 jobsModule.v2.JobsClient({ + 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 jobsModule.v2.JobsClient({ + 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 jobsModule.v2.JobsClient({ + 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 jobsModule.v2.JobsClient({ + 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 jobsModule.v2.JobsClient({ + 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 jobsModule.v2.JobsClient({ + 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 jobsModule.v2.JobsClient({ + 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 jobsModule.v2.JobsClient({ + 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 jobsModule.v2.JobsClient({ + 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 jobsModule.v2.JobsClient({ + 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 jobsModule.v2.JobsClient({ + 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 jobsModule.v2.JobsClient({ + 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 jobsModule.v2.JobsClient({ + 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 jobsModule.v2.JobsClient({ + 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('execution', () => { + const fakePath = "/rendered/path/execution"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + execution: "executionValue", + }; + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.executionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.executionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('executionPath', () => { + const result = client.executionPath("projectValue", "locationValue", "jobValue", "executionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.executionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromExecutionName', () => { + const result = client.matchProjectFromExecutionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromExecutionName', () => { + const result = client.matchLocationFromExecutionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromExecutionName', () => { + const result = client.matchJobFromExecutionName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchExecutionFromExecutionName', () => { + const result = client.matchExecutionFromExecutionName(fakePath); + assert.strictEqual(result, "executionValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('job', () => { + const fakePath = "/rendered/path/job"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + }; + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.jobPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.jobPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('jobPath', () => { + const result = client.jobPath("projectValue", "locationValue", "jobValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.jobPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromJobName', () => { + const result = client.matchProjectFromJobName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromJobName', () => { + const result = client.matchLocationFromJobName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromJobName', () => { + const result = client.matchJobFromJobName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new jobsModule.v2.JobsClient({ + 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('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('revision', () => { + const fakePath = "/rendered/path/revision"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + service: "serviceValue", + revision: "revisionValue", + }; + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.revisionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.revisionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('revisionPath', () => { + const result = client.revisionPath("projectValue", "locationValue", "serviceValue", "revisionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.revisionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRevisionName', () => { + const result = client.matchProjectFromRevisionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromRevisionName', () => { + const result = client.matchLocationFromRevisionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServiceFromRevisionName', () => { + const result = client.matchServiceFromRevisionName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRevisionFromRevisionName', () => { + const result = client.matchRevisionFromRevisionName(fakePath); + assert.strictEqual(result, "revisionValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('service', () => { + const fakePath = "/rendered/path/service"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + service: "serviceValue", + }; + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servicePath', () => { + const result = client.servicePath("projectValue", "locationValue", "serviceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servicePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServiceName', () => { + const result = client.matchProjectFromServiceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServiceName', () => { + const result = client.matchLocationFromServiceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServiceFromServiceName', () => { + const result = client.matchServiceFromServiceName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('task', () => { + const fakePath = "/rendered/path/task"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + execution: "executionValue", + task: "taskValue", + }; + const client = new jobsModule.v2.JobsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.taskPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.taskPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('taskPath', () => { + const result = client.taskPath("projectValue", "locationValue", "jobValue", "executionValue", "taskValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.taskPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromTaskName', () => { + const result = client.matchProjectFromTaskName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromTaskName', () => { + const result = client.matchLocationFromTaskName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromTaskName', () => { + const result = client.matchJobFromTaskName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchExecutionFromTaskName', () => { + const result = client.matchExecutionFromTaskName(fakePath); + assert.strictEqual(result, "executionValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchTaskFromTaskName', () => { + const result = client.matchTaskFromTaskName(fakePath); + assert.strictEqual(result, "taskValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-run/v2/test/gapic_revisions_v2.ts b/owl-bot-staging/google-cloud-run/v2/test/gapic_revisions_v2.ts new file mode 100644 index 00000000000..2805a3f3661 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/test/gapic_revisions_v2.ts @@ -0,0 +1,1513 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 revisionsModule 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.RevisionsClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = revisionsModule.v2.RevisionsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = revisionsModule.v2.RevisionsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = revisionsModule.v2.RevisionsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new revisionsModule.v2.RevisionsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new revisionsModule.v2.RevisionsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.revisionsStub, undefined); + await client.initialize(); + assert(client.revisionsStub); + }); + + it('has close method for the initialized client', done => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.revisionsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.revisionsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new revisionsModule.v2.RevisionsClient({ + 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 revisionsModule.v2.RevisionsClient({ + 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('getRevision', () => { + it('invokes getRevision without error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetRevisionRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.run.v2.Revision() + ); + client.innerApiCalls.getRevision = stubSimpleCall(expectedResponse); + const [response] = await client.getRevision(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRevision as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRevision as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRevision without error using callback', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetRevisionRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.run.v2.Revision() + ); + client.innerApiCalls.getRevision = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRevision( + request, + (err?: Error|null, result?: protos.google.cloud.run.v2.IRevision|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRevision as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRevision as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRevision with error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetRevisionRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.innerApiCalls.getRevision = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getRevision(request), expectedError); + const actualRequest = (client.innerApiCalls.getRevision as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRevision as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRevision with closed client', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetRevisionRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getRevision(request), expectedError); + }); + }); + + describe('deleteRevision', () => { + it('invokes deleteRevision without error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.DeleteRevisionRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteRevision = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteRevision(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteRevision as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteRevision as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteRevision without error using callback', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.DeleteRevisionRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteRevision = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteRevision( + request, + (err?: Error|null, + result?: 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.deleteRevision as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteRevision as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteRevision with call error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.DeleteRevisionRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteRevision = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteRevision(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteRevision as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteRevision as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteRevision with LRO error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.DeleteRevisionRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteRevision = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteRevision(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteRevision as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteRevision as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteRevisionProgress without error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteRevisionProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteRevisionProgress with error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteRevisionProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listRevisions', () => { + it('invokes listRevisions without error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListRevisionsRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.parent = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value';const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + ]; + client.innerApiCalls.listRevisions = stubSimpleCall(expectedResponse); + const [response] = await client.listRevisions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listRevisions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRevisions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRevisions without error using callback', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListRevisionsRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.parent = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value';const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + ]; + client.innerApiCalls.listRevisions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listRevisions( + request, + (err?: Error|null, result?: protos.google.cloud.run.v2.IRevision[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listRevisions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRevisions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRevisions with error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListRevisionsRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.parent = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.innerApiCalls.listRevisions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listRevisions(request), expectedError); + const actualRequest = (client.innerApiCalls.listRevisions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRevisions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRevisionsStream without error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListRevisionsRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.parent = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + ]; + client.descriptors.page.listRevisions.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listRevisionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.run.v2.Revision[] = []; + stream.on('data', (response: protos.google.cloud.run.v2.Revision) => { + 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.listRevisions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRevisions, request)); + assert( + (client.descriptors.page.listRevisions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listRevisionsStream with error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListRevisionsRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.parent = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.descriptors.page.listRevisions.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listRevisionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.run.v2.Revision[] = []; + stream.on('data', (response: protos.google.cloud.run.v2.Revision) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listRevisions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRevisions, request)); + assert( + (client.descriptors.page.listRevisions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listRevisions without error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListRevisionsRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.parent = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + ]; + client.descriptors.page.listRevisions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.run.v2.IRevision[] = []; + const iterable = client.listRevisionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listRevisions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listRevisions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listRevisions with error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListRevisionsRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.parent = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.descriptors.page.listRevisions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listRevisionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.run.v2.IRevision[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listRevisions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listRevisions.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 revisionsModule.v2.RevisionsClient({ + 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 revisionsModule.v2.RevisionsClient({ + 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 revisionsModule.v2.RevisionsClient({ + 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 revisionsModule.v2.RevisionsClient({ + 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 revisionsModule.v2.RevisionsClient({ + 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 revisionsModule.v2.RevisionsClient({ + 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 revisionsModule.v2.RevisionsClient({ + 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 revisionsModule.v2.RevisionsClient({ + 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 revisionsModule.v2.RevisionsClient({ + 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 revisionsModule.v2.RevisionsClient({ + 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 revisionsModule.v2.RevisionsClient({ + 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 revisionsModule.v2.RevisionsClient({ + 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 revisionsModule.v2.RevisionsClient({ + 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 revisionsModule.v2.RevisionsClient({ + 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 revisionsModule.v2.RevisionsClient({ + 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 revisionsModule.v2.RevisionsClient({ + 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('cryptoKey', () => { + const fakePath = "/rendered/path/cryptoKey"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + key_ring: "keyRingValue", + crypto_key: "cryptoKeyValue", + }; + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.cryptoKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.cryptoKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('cryptoKeyPath', () => { + const result = client.cryptoKeyPath("projectValue", "locationValue", "keyRingValue", "cryptoKeyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.cryptoKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCryptoKeyName', () => { + const result = client.matchProjectFromCryptoKeyName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCryptoKeyName', () => { + const result = client.matchLocationFromCryptoKeyName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchKeyRingFromCryptoKeyName', () => { + const result = client.matchKeyRingFromCryptoKeyName(fakePath); + assert.strictEqual(result, "keyRingValue"); + assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCryptoKeyFromCryptoKeyName', () => { + const result = client.matchCryptoKeyFromCryptoKeyName(fakePath); + assert.strictEqual(result, "cryptoKeyValue"); + assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('execution', () => { + const fakePath = "/rendered/path/execution"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + execution: "executionValue", + }; + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.executionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.executionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('executionPath', () => { + const result = client.executionPath("projectValue", "locationValue", "jobValue", "executionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.executionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromExecutionName', () => { + const result = client.matchProjectFromExecutionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromExecutionName', () => { + const result = client.matchLocationFromExecutionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromExecutionName', () => { + const result = client.matchJobFromExecutionName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchExecutionFromExecutionName', () => { + const result = client.matchExecutionFromExecutionName(fakePath); + assert.strictEqual(result, "executionValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('job', () => { + const fakePath = "/rendered/path/job"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + }; + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.jobPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.jobPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('jobPath', () => { + const result = client.jobPath("projectValue", "locationValue", "jobValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.jobPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromJobName', () => { + const result = client.matchProjectFromJobName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromJobName', () => { + const result = client.matchLocationFromJobName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromJobName', () => { + const result = client.matchJobFromJobName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new revisionsModule.v2.RevisionsClient({ + 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('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('revision', () => { + const fakePath = "/rendered/path/revision"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + service: "serviceValue", + revision: "revisionValue", + }; + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.revisionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.revisionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('revisionPath', () => { + const result = client.revisionPath("projectValue", "locationValue", "serviceValue", "revisionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.revisionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRevisionName', () => { + const result = client.matchProjectFromRevisionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromRevisionName', () => { + const result = client.matchLocationFromRevisionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServiceFromRevisionName', () => { + const result = client.matchServiceFromRevisionName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRevisionFromRevisionName', () => { + const result = client.matchRevisionFromRevisionName(fakePath); + assert.strictEqual(result, "revisionValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('service', () => { + const fakePath = "/rendered/path/service"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + service: "serviceValue", + }; + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servicePath', () => { + const result = client.servicePath("projectValue", "locationValue", "serviceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servicePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServiceName', () => { + const result = client.matchProjectFromServiceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServiceName', () => { + const result = client.matchLocationFromServiceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServiceFromServiceName', () => { + const result = client.matchServiceFromServiceName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('task', () => { + const fakePath = "/rendered/path/task"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + execution: "executionValue", + task: "taskValue", + }; + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.taskPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.taskPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('taskPath', () => { + const result = client.taskPath("projectValue", "locationValue", "jobValue", "executionValue", "taskValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.taskPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromTaskName', () => { + const result = client.matchProjectFromTaskName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromTaskName', () => { + const result = client.matchLocationFromTaskName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromTaskName', () => { + const result = client.matchJobFromTaskName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchExecutionFromTaskName', () => { + const result = client.matchExecutionFromTaskName(fakePath); + assert.strictEqual(result, "executionValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchTaskFromTaskName', () => { + const result = client.matchTaskFromTaskName(fakePath); + assert.strictEqual(result, "taskValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-run/v2/test/gapic_services_v2.ts b/owl-bot-staging/google-cloud-run/v2/test/gapic_services_v2.ts new file mode 100644 index 00000000000..6d61b3188a1 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/test/gapic_services_v2.ts @@ -0,0 +1,2087 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 servicesModule 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.ServicesClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = servicesModule.v2.ServicesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = servicesModule.v2.ServicesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = servicesModule.v2.ServicesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new servicesModule.v2.ServicesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new servicesModule.v2.ServicesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.servicesStub, undefined); + await client.initialize(); + assert(client.servicesStub); + }); + + it('has close method for the initialized client', done => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.servicesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.servicesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new servicesModule.v2.ServicesClient({ + 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 servicesModule.v2.ServicesClient({ + 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('getService', () => { + it('invokes getService without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetServiceRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.run.v2.Service() + ); + client.innerApiCalls.getService = stubSimpleCall(expectedResponse); + const [response] = await client.getService(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getService as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getService as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getService without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetServiceRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.run.v2.Service() + ); + client.innerApiCalls.getService = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getService( + request, + (err?: Error|null, result?: protos.google.cloud.run.v2.IService|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getService as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getService as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getService with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetServiceRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.innerApiCalls.getService = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getService(request), expectedError); + const actualRequest = (client.innerApiCalls.getService as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getService as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getService with closed client', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetServiceRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getService(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('createService', () => { + it('invokes createService without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.CreateServiceRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createService = stubLongRunningCall(expectedResponse); + const [operation] = await client.createService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createService as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createService as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createService without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.CreateServiceRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createService = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createService( + request, + (err?: Error|null, + result?: 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.createService as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createService as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createService with call error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.CreateServiceRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.innerApiCalls.createService = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createService(request), expectedError); + const actualRequest = (client.innerApiCalls.createService as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createService as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createService with LRO error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.CreateServiceRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.innerApiCalls.createService = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createService(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createService as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createService as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateServiceProgress without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateServiceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateServiceProgress with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateServiceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateService', () => { + it('invokes updateService without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.UpdateServiceRequest() + ); + request.service = {}; + // path template: projects/*/locations/{location=*}/** + request.service.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateService = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateService as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateService as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateService without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.UpdateServiceRequest() + ); + request.service = {}; + // path template: projects/*/locations/{location=*}/** + request.service.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateService = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateService( + request, + (err?: Error|null, + result?: 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.updateService as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateService as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateService with call error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.UpdateServiceRequest() + ); + request.service = {}; + // path template: projects/*/locations/{location=*}/** + request.service.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.innerApiCalls.updateService = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateService(request), expectedError); + const actualRequest = (client.innerApiCalls.updateService as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateService as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateService with LRO error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.UpdateServiceRequest() + ); + request.service = {}; + // path template: projects/*/locations/{location=*}/** + request.service.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.innerApiCalls.updateService = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateService(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateService as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateService as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateServiceProgress without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateServiceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateServiceProgress with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateServiceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteService', () => { + it('invokes deleteService without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.DeleteServiceRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteService = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteService as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteService as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteService without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.DeleteServiceRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteService = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteService( + request, + (err?: Error|null, + result?: 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.deleteService as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteService as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteService with call error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.DeleteServiceRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteService = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteService(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteService as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteService as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteService with LRO error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.DeleteServiceRequest() + ); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteService = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteService(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteService as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteService as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteServiceProgress without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteServiceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteServiceProgress with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteServiceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listServices', () => { + it('invokes listServices without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListServicesRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value';const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + ]; + client.innerApiCalls.listServices = stubSimpleCall(expectedResponse); + const [response] = await client.listServices(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listServices as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listServices as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServices without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListServicesRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value';const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + ]; + client.innerApiCalls.listServices = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServices( + request, + (err?: Error|null, result?: protos.google.cloud.run.v2.IService[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listServices as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listServices as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServices with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListServicesRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.innerApiCalls.listServices = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listServices(request), expectedError); + const actualRequest = (client.innerApiCalls.listServices as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listServices as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServicesStream without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListServicesRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + ]; + client.descriptors.page.listServices.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.run.v2.Service[] = []; + stream.on('data', (response: protos.google.cloud.run.v2.Service) => { + 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.listServices.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServices, request)); + assert( + (client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listServicesStream with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListServicesRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.descriptors.page.listServices.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.run.v2.Service[] = []; + stream.on('data', (response: protos.google.cloud.run.v2.Service) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServices, request)); + assert( + (client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listServices without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListServicesRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + ]; + client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.run.v2.IService[] = []; + const iterable = client.listServicesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listServices with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListServicesRequest() + ); + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + const expectedHeaderRequestParams = 'location=value'; + const expectedError = new Error('expected'); + client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServicesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.run.v2.IService[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listServices.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 servicesModule.v2.ServicesClient({ + 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 servicesModule.v2.ServicesClient({ + 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 servicesModule.v2.ServicesClient({ + 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 servicesModule.v2.ServicesClient({ + 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 servicesModule.v2.ServicesClient({ + 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 servicesModule.v2.ServicesClient({ + 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 servicesModule.v2.ServicesClient({ + 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 servicesModule.v2.ServicesClient({ + 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 servicesModule.v2.ServicesClient({ + 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 servicesModule.v2.ServicesClient({ + 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 servicesModule.v2.ServicesClient({ + 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 servicesModule.v2.ServicesClient({ + 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 servicesModule.v2.ServicesClient({ + 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 servicesModule.v2.ServicesClient({ + 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 servicesModule.v2.ServicesClient({ + 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 servicesModule.v2.ServicesClient({ + 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('execution', () => { + const fakePath = "/rendered/path/execution"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + execution: "executionValue", + }; + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.executionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.executionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('executionPath', () => { + const result = client.executionPath("projectValue", "locationValue", "jobValue", "executionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.executionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromExecutionName', () => { + const result = client.matchProjectFromExecutionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromExecutionName', () => { + const result = client.matchLocationFromExecutionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromExecutionName', () => { + const result = client.matchJobFromExecutionName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchExecutionFromExecutionName', () => { + const result = client.matchExecutionFromExecutionName(fakePath); + assert.strictEqual(result, "executionValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('job', () => { + const fakePath = "/rendered/path/job"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + }; + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.jobPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.jobPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('jobPath', () => { + const result = client.jobPath("projectValue", "locationValue", "jobValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.jobPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromJobName', () => { + const result = client.matchProjectFromJobName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromJobName', () => { + const result = client.matchLocationFromJobName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromJobName', () => { + const result = client.matchJobFromJobName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new servicesModule.v2.ServicesClient({ + 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('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('revision', () => { + const fakePath = "/rendered/path/revision"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + service: "serviceValue", + revision: "revisionValue", + }; + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.revisionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.revisionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('revisionPath', () => { + const result = client.revisionPath("projectValue", "locationValue", "serviceValue", "revisionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.revisionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRevisionName', () => { + const result = client.matchProjectFromRevisionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromRevisionName', () => { + const result = client.matchLocationFromRevisionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServiceFromRevisionName', () => { + const result = client.matchServiceFromRevisionName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRevisionFromRevisionName', () => { + const result = client.matchRevisionFromRevisionName(fakePath); + assert.strictEqual(result, "revisionValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('service', () => { + const fakePath = "/rendered/path/service"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + service: "serviceValue", + }; + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servicePath', () => { + const result = client.servicePath("projectValue", "locationValue", "serviceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servicePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServiceName', () => { + const result = client.matchProjectFromServiceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServiceName', () => { + const result = client.matchLocationFromServiceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServiceFromServiceName', () => { + const result = client.matchServiceFromServiceName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('task', () => { + const fakePath = "/rendered/path/task"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + execution: "executionValue", + task: "taskValue", + }; + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.taskPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.taskPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('taskPath', () => { + const result = client.taskPath("projectValue", "locationValue", "jobValue", "executionValue", "taskValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.taskPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromTaskName', () => { + const result = client.matchProjectFromTaskName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromTaskName', () => { + const result = client.matchLocationFromTaskName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromTaskName', () => { + const result = client.matchJobFromTaskName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchExecutionFromTaskName', () => { + const result = client.matchExecutionFromTaskName(fakePath); + assert.strictEqual(result, "executionValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchTaskFromTaskName', () => { + const result = client.matchTaskFromTaskName(fakePath); + assert.strictEqual(result, "taskValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-run/v2/test/gapic_tasks_v2.ts b/owl-bot-staging/google-cloud-run/v2/test/gapic_tasks_v2.ts new file mode 100644 index 00000000000..4488b5b1bf8 --- /dev/null +++ b/owl-bot-staging/google-cloud-run/v2/test/gapic_tasks_v2.ts @@ -0,0 +1,1103 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 tasksModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, 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.TasksClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = tasksModule.v2.TasksClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = tasksModule.v2.TasksClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = tasksModule.v2.TasksClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new tasksModule.v2.TasksClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new tasksModule.v2.TasksClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.tasksStub, undefined); + await client.initialize(); + assert(client.tasksStub); + }); + + it('has close method for the initialized client', done => { + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.tasksStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.tasksStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new tasksModule.v2.TasksClient({ + 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 tasksModule.v2.TasksClient({ + 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('getTask', () => { + it('invokes getTask without error', async () => { + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetTaskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.GetTaskRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.run.v2.Task() + ); + client.innerApiCalls.getTask = stubSimpleCall(expectedResponse); + const [response] = await client.getTask(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getTask as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getTask without error using callback', async () => { + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetTaskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.GetTaskRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.run.v2.Task() + ); + client.innerApiCalls.getTask = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getTask( + request, + (err?: Error|null, result?: protos.google.cloud.run.v2.ITask|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getTask as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getTask with error', async () => { + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetTaskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.GetTaskRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getTask = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getTask(request), expectedError); + const actualRequest = (client.innerApiCalls.getTask as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getTask with closed client', async () => { + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.GetTaskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.GetTaskRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getTask(request), expectedError); + }); + }); + + describe('listTasks', () => { + it('invokes listTasks without error', async () => { + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListTasksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.ListTasksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Task()), + generateSampleMessage(new protos.google.cloud.run.v2.Task()), + generateSampleMessage(new protos.google.cloud.run.v2.Task()), + ]; + client.innerApiCalls.listTasks = stubSimpleCall(expectedResponse); + const [response] = await client.listTasks(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listTasks as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listTasks without error using callback', async () => { + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListTasksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.ListTasksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Task()), + generateSampleMessage(new protos.google.cloud.run.v2.Task()), + generateSampleMessage(new protos.google.cloud.run.v2.Task()), + ]; + client.innerApiCalls.listTasks = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTasks( + request, + (err?: Error|null, result?: protos.google.cloud.run.v2.ITask[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listTasks as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listTasks with error', async () => { + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListTasksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.ListTasksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listTasks = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listTasks(request), expectedError); + const actualRequest = (client.innerApiCalls.listTasks as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listTasksStream without error', async () => { + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListTasksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.ListTasksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Task()), + generateSampleMessage(new protos.google.cloud.run.v2.Task()), + generateSampleMessage(new protos.google.cloud.run.v2.Task()), + ]; + client.descriptors.page.listTasks.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listTasksStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.run.v2.Task[] = []; + stream.on('data', (response: protos.google.cloud.run.v2.Task) => { + 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.listTasks.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTasks, request)); + assert( + (client.descriptors.page.listTasks.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listTasksStream with error', async () => { + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListTasksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.ListTasksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTasks.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listTasksStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.run.v2.Task[] = []; + stream.on('data', (response: protos.google.cloud.run.v2.Task) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listTasks.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTasks, request)); + assert( + (client.descriptors.page.listTasks.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listTasks without error', async () => { + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListTasksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.ListTasksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Task()), + generateSampleMessage(new protos.google.cloud.run.v2.Task()), + generateSampleMessage(new protos.google.cloud.run.v2.Task()), + ]; + client.descriptors.page.listTasks.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.run.v2.ITask[] = []; + const iterable = client.listTasksAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listTasks.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listTasks.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listTasks with error', async () => { + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.run.v2.ListTasksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.run.v2.ListTasksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTasks.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listTasksAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.run.v2.ITask[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listTasks.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listTasks.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 tasksModule.v2.TasksClient({ + 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 tasksModule.v2.TasksClient({ + 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 tasksModule.v2.TasksClient({ + 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 tasksModule.v2.TasksClient({ + 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 tasksModule.v2.TasksClient({ + 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('Path templates', () => { + + describe('cryptoKey', () => { + const fakePath = "/rendered/path/cryptoKey"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + key_ring: "keyRingValue", + crypto_key: "cryptoKeyValue", + }; + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.cryptoKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.cryptoKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('cryptoKeyPath', () => { + const result = client.cryptoKeyPath("projectValue", "locationValue", "keyRingValue", "cryptoKeyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.cryptoKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCryptoKeyName', () => { + const result = client.matchProjectFromCryptoKeyName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCryptoKeyName', () => { + const result = client.matchLocationFromCryptoKeyName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchKeyRingFromCryptoKeyName', () => { + const result = client.matchKeyRingFromCryptoKeyName(fakePath); + assert.strictEqual(result, "keyRingValue"); + assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCryptoKeyFromCryptoKeyName', () => { + const result = client.matchCryptoKeyFromCryptoKeyName(fakePath); + assert.strictEqual(result, "cryptoKeyValue"); + assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('execution', () => { + const fakePath = "/rendered/path/execution"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + execution: "executionValue", + }; + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.executionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.executionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('executionPath', () => { + const result = client.executionPath("projectValue", "locationValue", "jobValue", "executionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.executionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromExecutionName', () => { + const result = client.matchProjectFromExecutionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromExecutionName', () => { + const result = client.matchLocationFromExecutionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromExecutionName', () => { + const result = client.matchJobFromExecutionName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchExecutionFromExecutionName', () => { + const result = client.matchExecutionFromExecutionName(fakePath); + assert.strictEqual(result, "executionValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('job', () => { + const fakePath = "/rendered/path/job"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + }; + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.jobPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.jobPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('jobPath', () => { + const result = client.jobPath("projectValue", "locationValue", "jobValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.jobPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromJobName', () => { + const result = client.matchProjectFromJobName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromJobName', () => { + const result = client.matchLocationFromJobName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromJobName', () => { + const result = client.matchJobFromJobName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new tasksModule.v2.TasksClient({ + 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('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('revision', () => { + const fakePath = "/rendered/path/revision"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + service: "serviceValue", + revision: "revisionValue", + }; + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.revisionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.revisionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('revisionPath', () => { + const result = client.revisionPath("projectValue", "locationValue", "serviceValue", "revisionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.revisionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRevisionName', () => { + const result = client.matchProjectFromRevisionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromRevisionName', () => { + const result = client.matchLocationFromRevisionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServiceFromRevisionName', () => { + const result = client.matchServiceFromRevisionName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRevisionFromRevisionName', () => { + const result = client.matchRevisionFromRevisionName(fakePath); + assert.strictEqual(result, "revisionValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('service', () => { + const fakePath = "/rendered/path/service"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + service: "serviceValue", + }; + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servicePath', () => { + const result = client.servicePath("projectValue", "locationValue", "serviceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servicePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServiceName', () => { + const result = client.matchProjectFromServiceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServiceName', () => { + const result = client.matchLocationFromServiceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServiceFromServiceName', () => { + const result = client.matchServiceFromServiceName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('task', () => { + const fakePath = "/rendered/path/task"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + execution: "executionValue", + task: "taskValue", + }; + const client = new tasksModule.v2.TasksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.taskPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.taskPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('taskPath', () => { + const result = client.taskPath("projectValue", "locationValue", "jobValue", "executionValue", "taskValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.taskPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromTaskName', () => { + const result = client.matchProjectFromTaskName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromTaskName', () => { + const result = client.matchLocationFromTaskName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromTaskName', () => { + const result = client.matchJobFromTaskName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchExecutionFromTaskName', () => { + const result = client.matchExecutionFromTaskName(fakePath); + assert.strictEqual(result, "executionValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchTaskFromTaskName', () => { + const result = client.matchTaskFromTaskName(fakePath); + assert.strictEqual(result, "taskValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-run/v2/tsconfig.json b/owl-bot-staging/google-cloud-run/v2/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-run/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-run/v2/webpack.config.js b/owl-bot-staging/google-cloud-run/v2/webpack.config.js new file mode 100644 index 00000000000..7de187a074a --- /dev/null +++ b/owl-bot-staging/google-cloud-run/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: 'Executions', + filename: './executions.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-scheduler/v1/.eslintignore b/owl-bot-staging/google-cloud-scheduler/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-scheduler/v1/.eslintrc.json b/owl-bot-staging/google-cloud-scheduler/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/.gitignore b/owl-bot-staging/google-cloud-scheduler/v1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-scheduler/v1/.jsdoc.js b/owl-bot-staging/google-cloud-scheduler/v1/.jsdoc.js new file mode 100644 index 00000000000..da319aef859 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/.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/scheduler', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-scheduler/v1/.mocharc.js b/owl-bot-staging/google-cloud-scheduler/v1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/.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-scheduler/v1/.prettierrc.js b/owl-bot-staging/google-cloud-scheduler/v1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/.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-scheduler/v1/README.md b/owl-bot-staging/google-cloud-scheduler/v1/README.md new file mode 100644 index 00000000000..90fa2a2d162 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/README.md @@ -0,0 +1 @@ +Scheduler: Nodejs Client diff --git a/owl-bot-staging/google-cloud-scheduler/v1/package.json b/owl-bot-staging/google-cloud-scheduler/v1/package.json new file mode 100644 index 00000000000..c3738ba2d1a --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/scheduler", + "version": "0.1.0", + "description": "Scheduler client for Node.js", + "repository": "googleapis/nodejs-scheduler", + "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 scheduler", + "scheduler", + "cloud scheduler" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/cloudscheduler.proto b/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/cloudscheduler.proto new file mode 100644 index 00000000000..b6b594b2b62 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/cloudscheduler.proto @@ -0,0 +1,287 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.scheduler.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/scheduler/v1/job.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option go_package = "cloud.google.com/go/scheduler/apiv1/schedulerpb;schedulerpb"; +option java_multiple_files = true; +option java_outer_classname = "SchedulerProto"; +option java_package = "com.google.cloud.scheduler.v1"; +option objc_class_prefix = "SCHEDULER"; + +// The Cloud Scheduler API allows external entities to reliably +// schedule asynchronous jobs. +service CloudScheduler { + option (google.api.default_host) = "cloudscheduler.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Lists jobs. + rpc ListJobs(ListJobsRequest) returns (ListJobsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/jobs" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a job. + rpc GetJob(GetJobRequest) returns (Job) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/jobs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a job. + rpc CreateJob(CreateJobRequest) returns (Job) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/jobs" + body: "job" + }; + option (google.api.method_signature) = "parent,job"; + } + + // Updates a job. + // + // If successful, the updated [Job][google.cloud.scheduler.v1.Job] is + // returned. If the job does not exist, `NOT_FOUND` is returned. + // + // If UpdateJob does not successfully return, it is possible for the + // job to be in an + // [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1.Job.State.UPDATE_FAILED] + // state. A job in this state may not be executed. If this happens, retry the + // UpdateJob request until a successful response is received. + rpc UpdateJob(UpdateJobRequest) returns (Job) { + option (google.api.http) = { + patch: "/v1/{job.name=projects/*/locations/*/jobs/*}" + body: "job" + }; + option (google.api.method_signature) = "job,update_mask"; + } + + // Deletes a job. + rpc DeleteJob(DeleteJobRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/jobs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Pauses a job. + // + // If a job is paused then the system will stop executing the job + // until it is re-enabled via + // [ResumeJob][google.cloud.scheduler.v1.CloudScheduler.ResumeJob]. The state + // of the job is stored in [state][google.cloud.scheduler.v1.Job.state]; if + // paused it will be set to + // [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. A job must + // be in [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED] to + // be paused. + rpc PauseJob(PauseJobRequest) returns (Job) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/jobs/*}:pause" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Resume a job. + // + // This method reenables a job after it has been + // [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. The state + // of a job is stored in [Job.state][google.cloud.scheduler.v1.Job.state]; + // after calling this method it will be set to + // [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED]. A job + // must be in [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED] + // to be resumed. + rpc ResumeJob(ResumeJobRequest) returns (Job) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/jobs/*}:resume" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Forces a job to run now. + // + // When this method is called, Cloud Scheduler will dispatch the job, even + // if the job is already running. + rpc RunJob(RunJobRequest) returns (Job) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/jobs/*}:run" + body: "*" + }; + option (google.api.method_signature) = "name"; + } +} + +// Request message for listing jobs using +// [ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs]. +message ListJobsRequest { + // Required. The location name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "cloudscheduler.googleapis.com/Job" + } + ]; + + // Requested page size. + // + // The maximum page size is 500. If unspecified, the page size will + // be the maximum. Fewer jobs than requested might be returned, + // even if more jobs exist; use next_page_token to determine if more + // jobs exist. + int32 page_size = 5; + + // A token identifying a page of results the server will return. To + // request the first page results, page_token must be empty. To + // request the next page of results, page_token must be the value of + // [next_page_token][google.cloud.scheduler.v1.ListJobsResponse.next_page_token] + // returned from the previous call to + // [ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs]. It is an + // error to switch the value of + // [filter][google.cloud.scheduler.v1.ListJobsRequest.filter] or + // [order_by][google.cloud.scheduler.v1.ListJobsRequest.order_by] while + // iterating through pages. + string page_token = 6; +} + +// Response message for listing jobs using +// [ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs]. +message ListJobsResponse { + // The list of jobs. + repeated Job jobs = 1; + + // A token to retrieve next page of results. Pass this value in the + // [page_token][google.cloud.scheduler.v1.ListJobsRequest.page_token] field in + // the subsequent call to + // [ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs] to retrieve + // the next page of results. If this is empty it indicates that there are no + // more results through which to paginate. + // + // The page token is valid for only 2 hours. + string next_page_token = 2; +} + +// Request message for +// [GetJob][google.cloud.scheduler.v1.CloudScheduler.GetJob]. +message GetJobRequest { + // Required. The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudscheduler.googleapis.com/Job" + } + ]; +} + +// Request message for +// [CreateJob][google.cloud.scheduler.v1.CloudScheduler.CreateJob]. +message CreateJobRequest { + // Required. The location name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "cloudscheduler.googleapis.com/Job" + } + ]; + + // Required. The job to add. The user can optionally specify a name for the + // job in [name][google.cloud.scheduler.v1.Job.name]. + // [name][google.cloud.scheduler.v1.Job.name] cannot be the same as an + // existing job. If a name is not specified then the system will + // generate a random unique name that will be returned + // ([name][google.cloud.scheduler.v1.Job.name]) in the response. + Job job = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for +// [UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob]. +message UpdateJobRequest { + // Required. The new job properties. + // [name][google.cloud.scheduler.v1.Job.name] must be specified. + // + // Output only fields cannot be modified using UpdateJob. + // Any value specified for an output only field will be ignored. + Job job = 1 [(google.api.field_behavior) = REQUIRED]; + + // A mask used to specify which fields of the job are being updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for deleting a job using +// [DeleteJob][google.cloud.scheduler.v1.CloudScheduler.DeleteJob]. +message DeleteJobRequest { + // Required. The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudscheduler.googleapis.com/Job" + } + ]; +} + +// Request message for +// [PauseJob][google.cloud.scheduler.v1.CloudScheduler.PauseJob]. +message PauseJobRequest { + // Required. The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudscheduler.googleapis.com/Job" + } + ]; +} + +// Request message for +// [ResumeJob][google.cloud.scheduler.v1.CloudScheduler.ResumeJob]. +message ResumeJobRequest { + // Required. The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudscheduler.googleapis.com/Job" + } + ]; +} + +// Request message for forcing a job to run now using +// [RunJob][google.cloud.scheduler.v1.CloudScheduler.RunJob]. +message RunJobRequest { + // Required. The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudscheduler.googleapis.com/Job" + } + ]; +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/job.proto b/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/job.proto new file mode 100644 index 00000000000..e12e589efe9 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/job.proto @@ -0,0 +1,259 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.scheduler.v1; + +import "google/api/resource.proto"; +import "google/cloud/scheduler/v1/target.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option go_package = "cloud.google.com/go/scheduler/apiv1/schedulerpb;schedulerpb"; +option java_multiple_files = true; +option java_outer_classname = "JobProto"; +option java_package = "com.google.cloud.scheduler.v1"; + +// Configuration for a job. +// The maximum allowed size for a job is 1MB. +message Job { + option (google.api.resource) = { + type: "cloudscheduler.googleapis.com/Job" + pattern: "projects/{project}/locations/{location}/jobs/{job}" + }; + + // State of the job. + enum State { + // Unspecified state. + STATE_UNSPECIFIED = 0; + + // The job is executing normally. + ENABLED = 1; + + // The job is paused by the user. It will not execute. A user can + // intentionally pause the job using + // [PauseJobRequest][google.cloud.scheduler.v1.PauseJobRequest]. + PAUSED = 2; + + // The job is disabled by the system due to error. The user + // cannot directly set a job to be disabled. + DISABLED = 3; + + // The job state resulting from a failed + // [CloudScheduler.UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob] + // operation. To recover a job from this state, retry + // [CloudScheduler.UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob] + // until a successful response is received. + UPDATE_FAILED = 4; + } + + // Optionally caller-specified in + // [CreateJob][google.cloud.scheduler.v1.CloudScheduler.CreateJob], after + // which it becomes output only. + // + // The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + // + // * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]), + // hyphens (-), colons (:), or periods (.). + // For more information, see + // [Identifying + // projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects) + // * `LOCATION_ID` is the canonical ID for the job's location. + // The list of available locations can be obtained by calling + // [ListLocations][google.cloud.location.Locations.ListLocations]. + // For more information, see https://cloud.google.com/about/locations/. + // * `JOB_ID` can contain only letters ([A-Za-z]), numbers ([0-9]), + // hyphens (-), or underscores (_). The maximum length is 500 characters. + string name = 1; + + // Optionally caller-specified in + // [CreateJob][google.cloud.scheduler.v1.CloudScheduler.CreateJob] or + // [UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob]. + // + // A human-readable description for the job. This string must not contain + // more than 500 characters. + string description = 2; + + // Required. + // + // Delivery settings containing destination and parameters. + oneof target { + // Pub/Sub target. + PubsubTarget pubsub_target = 4; + + // App Engine HTTP target. + AppEngineHttpTarget app_engine_http_target = 5; + + // HTTP target. + HttpTarget http_target = 6; + } + + // Required, except when used with + // [UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob]. + // + // Describes the schedule on which the job will be executed. + // + // The schedule can be either of the following types: + // + // * [Crontab](https://en.wikipedia.org/wiki/Cron#Overview) + // * English-like + // [schedule](https://cloud.google.com/scheduler/docs/configuring/cron-job-schedules) + // + // As a general rule, execution `n + 1` of a job will not begin + // until execution `n` has finished. Cloud Scheduler will never + // allow two simultaneously outstanding executions. For example, + // this implies that if the `n+1`th execution is scheduled to run at + // 16:00 but the `n`th execution takes until 16:15, the `n+1`th + // execution will not start until `16:15`. + // A scheduled start time will be delayed if the previous + // execution has not ended when its scheduled time occurs. + // + // If [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count] > 0 and + // a job attempt fails, the job will be tried a total of + // [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count] times, + // with exponential backoff, until the next scheduled start time. + string schedule = 20; + + // Specifies the time zone to be used in interpreting + // [schedule][google.cloud.scheduler.v1.Job.schedule]. The value of this field + // must be a time zone name from the [tz + // database](http://en.wikipedia.org/wiki/Tz_database). + // + // Note that some time zones include a provision for + // daylight savings time. The rules for daylight saving time are + // determined by the chosen tz. For UTC use the string "utc". If a + // time zone is not specified, the default will be in UTC (also known + // as GMT). + string time_zone = 21; + + // Output only. The creation time of the job. + google.protobuf.Timestamp user_update_time = 9; + + // Output only. State of the job. + State state = 10; + + // Output only. The response from the target for the last attempted execution. + google.rpc.Status status = 11; + + // Output only. The next time the job is scheduled. Note that this may be a + // retry of a previously failed attempt or the next execution time + // according to the schedule. + google.protobuf.Timestamp schedule_time = 17; + + // Output only. The time the last job attempt started. + google.protobuf.Timestamp last_attempt_time = 18; + + // Settings that determine the retry behavior. + RetryConfig retry_config = 19; + + // The deadline for job attempts. If the request handler does not respond by + // this deadline then the request is cancelled and the attempt is marked as a + // `DEADLINE_EXCEEDED` failure. The failed attempt can be viewed in + // execution logs. Cloud Scheduler will retry the job according + // to the [RetryConfig][google.cloud.scheduler.v1.RetryConfig]. + // + // The default and the allowed values depend on the type of target: + // + // * For [HTTP targets][google.cloud.scheduler.v1.Job.http_target], the + // default is 3 minutes. The deadline must be in the interval [15 seconds, 30 + // minutes]. + // + // * For [App Engine HTTP + // targets][google.cloud.scheduler.v1.Job.app_engine_http_target], 0 indicates + // that the request has the default deadline. The default deadline depends on + // the scaling type of the service: 10 minutes for standard apps with + // automatic scaling, 24 hours for standard apps with manual and basic + // scaling, and 60 minutes for flex apps. If the request deadline is set, it + // must be in the interval [15 seconds, 24 hours 15 seconds]. + // + // * For [Pub/Sub targets][google.cloud.scheduler.v1.Job.pubsub_target], this + // field is ignored. + google.protobuf.Duration attempt_deadline = 22; +} + +// Settings that determine the retry behavior. +// +// By default, if a job does not complete successfully (meaning that +// an acknowledgement is not received from the handler, then it will be retried +// with exponential backoff according to the settings in +// [RetryConfig][google.cloud.scheduler.v1.RetryConfig]. +message RetryConfig { + // The number of attempts that the system will make to run a job using the + // exponential backoff procedure described by + // [max_doublings][google.cloud.scheduler.v1.RetryConfig.max_doublings]. + // + // The default value of retry_count is zero. + // + // If retry_count is zero, a job attempt will *not* be retried if + // it fails. Instead the Cloud Scheduler system will wait for the + // next scheduled execution time. + // + // If retry_count is set to a non-zero number then Cloud Scheduler + // will retry failed attempts, using exponential backoff, + // retry_count times, or until the next scheduled execution time, + // whichever comes first. + // + // Values greater than 5 and negative values are not allowed. + int32 retry_count = 1; + + // The time limit for retrying a failed job, measured from time when an + // execution was first attempted. If specified with + // [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count], the job + // will be retried until both limits are reached. + // + // The default value for max_retry_duration is zero, which means retry + // duration is unlimited. + google.protobuf.Duration max_retry_duration = 2; + + // The minimum amount of time to wait before retrying a job after + // it fails. + // + // The default value of this field is 5 seconds. + google.protobuf.Duration min_backoff_duration = 3; + + // The maximum amount of time to wait before retrying a job after + // it fails. + // + // The default value of this field is 1 hour. + google.protobuf.Duration max_backoff_duration = 4; + + // The time between retries will double `max_doublings` times. + // + // A job's retry interval starts at + // [min_backoff_duration][google.cloud.scheduler.v1.RetryConfig.min_backoff_duration], + // then doubles `max_doublings` times, then increases linearly, and finally + // retries at intervals of + // [max_backoff_duration][google.cloud.scheduler.v1.RetryConfig.max_backoff_duration] + // up to [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count] + // times. + // + // For example, if + // [min_backoff_duration][google.cloud.scheduler.v1.RetryConfig.min_backoff_duration] + // is 10s, + // [max_backoff_duration][google.cloud.scheduler.v1.RetryConfig.max_backoff_duration] + // is 300s, and `max_doublings` is 3, then the a job will first be retried in + // 10s. The retry interval will double three times, and then increase linearly + // by 2^3 * 10s. Finally, the job will retry at intervals of + // [max_backoff_duration][google.cloud.scheduler.v1.RetryConfig.max_backoff_duration] + // until the job has been attempted + // [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count] times. + // Thus, the requests will retry at 10s, 20s, 40s, 80s, 160s, 240s, 300s, + // 300s, .... + // + // The default value of this field is 5. + int32 max_doublings = 5; +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/target.proto b/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/target.proto new file mode 100644 index 00000000000..12a797b06bc --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/target.proto @@ -0,0 +1,369 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.scheduler.v1; + +import "google/api/resource.proto"; + +option go_package = "cloud.google.com/go/scheduler/apiv1/schedulerpb;schedulerpb"; +option java_multiple_files = true; +option java_outer_classname = "TargetProto"; +option java_package = "com.google.cloud.scheduler.v1"; +option (google.api.resource_definition) = { + type: "pubsub.googleapis.com/Topic" + pattern: "projects/{project}/topics/{topic}" +}; + +// Http target. The job will be pushed to the job handler by means of +// an HTTP request via an +// [http_method][google.cloud.scheduler.v1.HttpTarget.http_method] such as HTTP +// POST, HTTP GET, etc. The job is acknowledged by means of an HTTP +// response code in the range [200 - 299]. A failure to receive a response +// constitutes a failed execution. For a redirected request, the response +// returned by the redirected request is considered. +message HttpTarget { + // Required. The full URI path that the request will be sent to. This string + // must begin with either "http://" or "https://". Some examples of + // valid values for [uri][google.cloud.scheduler.v1.HttpTarget.uri] are: + // `http://acme.com` and `https://acme.com/sales:8080`. Cloud Scheduler will + // encode some characters for safety and compatibility. The maximum allowed + // URL length is 2083 characters after encoding. + string uri = 1; + + // Which HTTP method to use for the request. + HttpMethod http_method = 2; + + // The user can specify HTTP request headers to send with the job's + // HTTP request. This map contains the header field names and + // values. Repeated headers are not supported, but a header value can + // contain commas. These headers represent a subset of the headers + // that will accompany the job's HTTP request. Some HTTP request + // headers will be ignored or replaced. A partial list of headers that + // will be ignored or replaced is below: + // - Host: This will be computed by Cloud Scheduler and derived from + // [uri][google.cloud.scheduler.v1.HttpTarget.uri]. + // * `Content-Length`: This will be computed by Cloud Scheduler. + // * `User-Agent`: This will be set to `"Google-Cloud-Scheduler"`. + // * `X-Google-*`: Google internal use only. + // * `X-AppEngine-*`: Google internal use only. + // * `X-CloudScheduler`: This header will be set to true. + // * `X-CloudScheduler-JobName`: This header will contain the job name. + // * `X-CloudScheduler-ScheduleTime`: For Cloud Scheduler jobs specified in + // the unix-cron format, this header will contain the job schedule time in + // RFC3339 UTC "Zulu" format. + // + // The total size of headers must be less than 80KB. + map headers = 3; + + // HTTP request body. A request body is allowed only if the HTTP + // method is POST, PUT, or PATCH. It is an error to set body on a job with an + // incompatible [HttpMethod][google.cloud.scheduler.v1.HttpMethod]. + bytes body = 4; + + // The mode for generating an `Authorization` header for HTTP requests. + // + // If specified, all `Authorization` headers in the + // [HttpTarget.headers][google.cloud.scheduler.v1.HttpTarget.headers] field + // will be overridden. + oneof authorization_header { + // If specified, an + // [OAuth token](https://developers.google.com/identity/protocols/OAuth2) + // will be generated and attached as an `Authorization` header in the HTTP + // request. + // + // This type of authorization should generally only be used when calling + // Google APIs hosted on *.googleapis.com. + OAuthToken oauth_token = 5; + + // If specified, an + // [OIDC](https://developers.google.com/identity/protocols/OpenIDConnect) + // token will be generated and attached as an `Authorization` header in the + // HTTP request. + // + // This type of authorization can be used for many scenarios, including + // calling Cloud Run, or endpoints where you intend to validate the token + // yourself. + OidcToken oidc_token = 6; + } +} + +// App Engine target. The job will be pushed to a job handler by means +// of an HTTP request via an +// [http_method][google.cloud.scheduler.v1.AppEngineHttpTarget.http_method] such +// as HTTP POST, HTTP GET, etc. The job is acknowledged by means of an +// HTTP response code in the range [200 - 299]. Error 503 is +// considered an App Engine system error instead of an application +// error. Requests returning error 503 will be retried regardless of +// retry configuration and not counted against retry counts. Any other +// response code, or a failure to receive a response before the +// deadline, constitutes a failed attempt. +message AppEngineHttpTarget { + // The HTTP method to use for the request. PATCH and OPTIONS are not + // permitted. + HttpMethod http_method = 1; + + // App Engine Routing setting for the job. + AppEngineRouting app_engine_routing = 2; + + // The relative URI. + // + // The relative URL must begin with "/" and must be a valid HTTP relative URL. + // It can contain a path, query string arguments, and `#` fragments. + // If the relative URL is empty, then the root path "/" will be used. + // No spaces are allowed, and the maximum length allowed is 2083 characters. + string relative_uri = 3; + + // HTTP request headers. + // + // This map contains the header field names and values. Headers can be set + // when the job is created. + // + // Cloud Scheduler sets some headers to default values: + // + // * `User-Agent`: By default, this header is + // `"AppEngine-Google; (+http://code.google.com/appengine)"`. + // This header can be modified, but Cloud Scheduler will append + // `"AppEngine-Google; (+http://code.google.com/appengine)"` to the + // modified `User-Agent`. + // * `X-CloudScheduler`: This header will be set to true. + // * `X-CloudScheduler-JobName`: This header will contain the job name. + // * `X-CloudScheduler-ScheduleTime`: For Cloud Scheduler jobs specified in + // the unix-cron format, this header will contain the job schedule time in + // RFC3339 UTC "Zulu" format. + // + // If the job has an + // [body][google.cloud.scheduler.v1.AppEngineHttpTarget.body], Cloud Scheduler + // sets the following headers: + // + // * `Content-Type`: By default, the `Content-Type` header is set to + // `"application/octet-stream"`. The default can be overridden by explictly + // setting `Content-Type` to a particular media type when the job is + // created. + // For example, `Content-Type` can be set to `"application/json"`. + // * `Content-Length`: This is computed by Cloud Scheduler. This value is + // output only. It cannot be changed. + // + // The headers below are output only. They cannot be set or overridden: + // + // * `X-Google-*`: For Google internal use only. + // * `X-AppEngine-*`: For Google internal use only. + // + // In addition, some App Engine headers, which contain + // job-specific information, are also be sent to the job handler. + map headers = 4; + + // Body. + // + // HTTP request body. A request body is allowed only if the HTTP method is + // POST or PUT. It will result in invalid argument error to set a body on a + // job with an incompatible + // [HttpMethod][google.cloud.scheduler.v1.HttpMethod]. + bytes body = 5; +} + +// Pub/Sub target. The job will be delivered by publishing a message to +// the given Pub/Sub topic. +message PubsubTarget { + // Required. The name of the Cloud Pub/Sub topic to which messages will + // be published when a job is delivered. The topic name must be in the + // same format as required by Pub/Sub's + // [PublishRequest.name](https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#publishrequest), + // for example `projects/PROJECT_ID/topics/TOPIC_ID`. + // + // The topic must be in the same project as the Cloud Scheduler job. + string topic_name = 1 [ + (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" } + ]; + + // The message payload for PubsubMessage. + // + // Pubsub message must contain either non-empty data, or at least one + // attribute. + bytes data = 3; + + // Attributes for PubsubMessage. + // + // Pubsub message must contain either non-empty data, or at least one + // attribute. + map attributes = 4; +} + +// App Engine Routing. +// +// For more information about services, versions, and instances see +// [An Overview of App +// Engine](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine), +// [Microservices Architecture on Google App +// Engine](https://cloud.google.com/appengine/docs/python/microservices-on-app-engine), +// [App Engine Standard request +// routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed), +// and [App Engine Flex request +// routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed). +message AppEngineRouting { + // App service. + // + // By default, the job is sent to the service which is the default + // service when the job is attempted. + string service = 1; + + // App version. + // + // By default, the job is sent to the version which is the default + // version when the job is attempted. + string version = 2; + + // App instance. + // + // By default, the job is sent to an instance which is available when + // the job is attempted. + // + // Requests can only be sent to a specific instance if + // [manual scaling is used in App Engine + // Standard](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine?#scaling_types_and_instance_classes). + // App Engine Flex does not support instances. For more information, see + // [App Engine Standard request + // routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed) + // and [App Engine Flex request + // routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed). + string instance = 3; + + // Output only. The host that the job is sent to. + // + // For more information about how App Engine requests are routed, see + // [here](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed). + // + // The host is constructed as: + // + // + // * `host = [application_domain_name]`
+ // `| [service] + '.' + [application_domain_name]`
+ // `| [version] + '.' + [application_domain_name]`
+ // `| [version_dot_service]+ '.' + [application_domain_name]`
+ // `| [instance] + '.' + [application_domain_name]`
+ // `| [instance_dot_service] + '.' + [application_domain_name]`
+ // `| [instance_dot_version] + '.' + [application_domain_name]`
+ // `| [instance_dot_version_dot_service] + '.' + [application_domain_name]` + // + // * `application_domain_name` = The domain name of the app, for + // example .appspot.com, which is associated with the + // job's project ID. + // + // * `service =` [service][google.cloud.scheduler.v1.AppEngineRouting.service] + // + // * `version =` [version][google.cloud.scheduler.v1.AppEngineRouting.version] + // + // * `version_dot_service =` + // [version][google.cloud.scheduler.v1.AppEngineRouting.version] `+ '.' +` + // [service][google.cloud.scheduler.v1.AppEngineRouting.service] + // + // * `instance =` + // [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] + // + // * `instance_dot_service =` + // [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] `+ '.' +` + // [service][google.cloud.scheduler.v1.AppEngineRouting.service] + // + // * `instance_dot_version =` + // [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] `+ '.' +` + // [version][google.cloud.scheduler.v1.AppEngineRouting.version] + // + // * `instance_dot_version_dot_service =` + // [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] `+ '.' +` + // [version][google.cloud.scheduler.v1.AppEngineRouting.version] `+ '.' +` + // [service][google.cloud.scheduler.v1.AppEngineRouting.service] + // + // + // If [service][google.cloud.scheduler.v1.AppEngineRouting.service] is empty, + // then the job will be sent to the service which is the default service when + // the job is attempted. + // + // If [version][google.cloud.scheduler.v1.AppEngineRouting.version] is empty, + // then the job will be sent to the version which is the default version when + // the job is attempted. + // + // If [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] is + // empty, then the job will be sent to an instance which is available when the + // job is attempted. + // + // If [service][google.cloud.scheduler.v1.AppEngineRouting.service], + // [version][google.cloud.scheduler.v1.AppEngineRouting.version], or + // [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] is invalid, + // then the job will be sent to the default version of the default service + // when the job is attempted. + string host = 4; +} + +// The HTTP method used to execute the job. +enum HttpMethod { + // HTTP method unspecified. Defaults to POST. + HTTP_METHOD_UNSPECIFIED = 0; + + // HTTP POST + POST = 1; + + // HTTP GET + GET = 2; + + // HTTP HEAD + HEAD = 3; + + // HTTP PUT + PUT = 4; + + // HTTP DELETE + DELETE = 5; + + // HTTP PATCH + PATCH = 6; + + // HTTP OPTIONS + OPTIONS = 7; +} + +// Contains information needed for generating an +// [OAuth token](https://developers.google.com/identity/protocols/OAuth2). +// This type of authorization should generally only be used when calling Google +// APIs hosted on *.googleapis.com. +message OAuthToken { + // [Service account email](https://cloud.google.com/iam/docs/service-accounts) + // to be used for generating OAuth token. + // The service account must be within the same project as the job. The caller + // must have iam.serviceAccounts.actAs permission for the service account. + string service_account_email = 1; + + // OAuth scope to be used for generating OAuth access token. + // If not specified, "https://www.googleapis.com/auth/cloud-platform" + // will be used. + string scope = 2; +} + +// Contains information needed for generating an +// [OpenID Connect +// token](https://developers.google.com/identity/protocols/OpenIDConnect). +// This type of authorization can be used for many scenarios, including +// calling Cloud Run, or endpoints where you intend to validate the token +// yourself. +message OidcToken { + // [Service account email](https://cloud.google.com/iam/docs/service-accounts) + // to be used for generating OIDC token. + // The service account must be within the same project as the job. The caller + // must have iam.serviceAccounts.actAs permission for the service account. + string service_account_email = 1; + + // Audience to be used when generating OIDC token. If not specified, the URI + // specified in target will be used. + string audience = 2; +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.create_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.create_job.js new file mode 100644 index 00000000000..988e2d72be2 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.create_job.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, job) { + // [START cloudscheduler_v1_generated_CloudScheduler_CreateJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + */ + // const parent = 'abc123' + /** + * Required. The job to add. The user can optionally specify a name for the + * job in name google.cloud.scheduler.v1.Job.name. + * name google.cloud.scheduler.v1.Job.name cannot be the same as an + * existing job. If a name is not specified then the system will + * generate a random unique name that will be returned + * (name google.cloud.scheduler.v1.Job.name) in the response. + */ + // const job = {} + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callCreateJob() { + // Construct request + const request = { + parent, + job, + }; + + // Run request + const response = await schedulerClient.createJob(request); + console.log(response); + } + + callCreateJob(); + // [END cloudscheduler_v1_generated_CloudScheduler_CreateJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.delete_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.delete_job.js new file mode 100644 index 00000000000..cdb25bf704f --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.delete_job.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 cloudscheduler_v1_generated_CloudScheduler_DeleteJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + */ + // const name = 'abc123' + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callDeleteJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await schedulerClient.deleteJob(request); + console.log(response); + } + + callDeleteJob(); + // [END cloudscheduler_v1_generated_CloudScheduler_DeleteJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.get_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.get_job.js new file mode 100644 index 00000000000..ab4396baf0e --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.get_job.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 cloudscheduler_v1_generated_CloudScheduler_GetJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + */ + // const name = 'abc123' + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callGetJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await schedulerClient.getJob(request); + console.log(response); + } + + callGetJob(); + // [END cloudscheduler_v1_generated_CloudScheduler_GetJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.list_jobs.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.list_jobs.js new file mode 100644 index 00000000000..bca6c481609 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.list_jobs.js @@ -0,0 +1,85 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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 cloudscheduler_v1_generated_CloudScheduler_ListJobs_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + */ + // const parent = 'abc123' + /** + * Requested page size. + * The maximum page size is 500. If unspecified, the page size will + * be the maximum. Fewer jobs than requested might be returned, + * even if more jobs exist; use next_page_token to determine if more + * jobs exist. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results the server will return. To + * request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * next_page_token google.cloud.scheduler.v1.ListJobsResponse.next_page_token + * returned from the previous call to + * ListJobs google.cloud.scheduler.v1.CloudScheduler.ListJobs. It is an + * error to switch the value of + * filter google.cloud.scheduler.v1.ListJobsRequest.filter or + * order_by google.cloud.scheduler.v1.ListJobsRequest.order_by while + * iterating through pages. + */ + // const pageToken = 'abc123' + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callListJobs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await schedulerClient.listJobsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListJobs(); + // [END cloudscheduler_v1_generated_CloudScheduler_ListJobs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.pause_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.pause_job.js new file mode 100644 index 00000000000..becc78f8bc3 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.pause_job.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 cloudscheduler_v1_generated_CloudScheduler_PauseJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + */ + // const name = 'abc123' + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callPauseJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await schedulerClient.pauseJob(request); + console.log(response); + } + + callPauseJob(); + // [END cloudscheduler_v1_generated_CloudScheduler_PauseJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.resume_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.resume_job.js new file mode 100644 index 00000000000..fbf390f598c --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.resume_job.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 cloudscheduler_v1_generated_CloudScheduler_ResumeJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + */ + // const name = 'abc123' + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callResumeJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await schedulerClient.resumeJob(request); + console.log(response); + } + + callResumeJob(); + // [END cloudscheduler_v1_generated_CloudScheduler_ResumeJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.run_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.run_job.js new file mode 100644 index 00000000000..ab91a903b8b --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.run_job.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 cloudscheduler_v1_generated_CloudScheduler_RunJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + */ + // const name = 'abc123' + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callRunJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await schedulerClient.runJob(request); + console.log(response); + } + + callRunJob(); + // [END cloudscheduler_v1_generated_CloudScheduler_RunJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.update_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.update_job.js new file mode 100644 index 00000000000..fc859a2c552 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.update_job.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(job) { + // [START cloudscheduler_v1_generated_CloudScheduler_UpdateJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The new job properties. + * name google.cloud.scheduler.v1.Job.name must be specified. + * Output only fields cannot be modified using UpdateJob. + * Any value specified for an output only field will be ignored. + */ + // const job = {} + /** + * A mask used to specify which fields of the job are being updated. + */ + // const updateMask = {} + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callUpdateJob() { + // Construct request + const request = { + job, + }; + + // Run request + const response = await schedulerClient.updateJob(request); + console.log(response); + } + + callUpdateJob(); + // [END cloudscheduler_v1_generated_CloudScheduler_UpdateJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/snippet_metadata_google.cloud.scheduler.v1.json b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/snippet_metadata_google.cloud.scheduler.v1.json new file mode 100644 index 00000000000..002b7a4b866 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/snippet_metadata_google.cloud.scheduler.v1.json @@ -0,0 +1,351 @@ +{ + "clientLibrary": { + "name": "nodejs-scheduler", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.scheduler.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "cloudscheduler_v1_generated_CloudScheduler_ListJobs_async", + "title": "scheduler listJobs Sample", + "origin": "API_DEFINITION", + "description": " Lists jobs.", + "canonical": true, + "file": "cloud_scheduler.list_jobs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 77, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListJobs", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.ListJobs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.scheduler.v1.ListJobsResponse", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" + }, + "method": { + "shortName": "ListJobs", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.ListJobs", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1_generated_CloudScheduler_GetJob_async", + "title": "scheduler getJob Sample", + "origin": "API_DEFINITION", + "description": " Gets a job.", + "canonical": true, + "file": "cloud_scheduler.get_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.GetJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.scheduler.v1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" + }, + "method": { + "shortName": "GetJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.GetJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1_generated_CloudScheduler_CreateJob_async", + "title": "scheduler createJob Sample", + "origin": "API_DEFINITION", + "description": " Creates a job.", + "canonical": true, + "file": "cloud_scheduler.create_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.CreateJob", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "job", + "type": ".google.cloud.scheduler.v1.Job" + } + ], + "resultType": ".google.cloud.scheduler.v1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" + }, + "method": { + "shortName": "CreateJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.CreateJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1_generated_CloudScheduler_UpdateJob_async", + "title": "scheduler updateJob Sample", + "origin": "API_DEFINITION", + "description": " Updates a job. If successful, the updated [Job][google.cloud.scheduler.v1.Job] is returned. If the job does not exist, `NOT_FOUND` is returned. If UpdateJob does not successfully return, it is possible for the job to be in an [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1.Job.State.UPDATE_FAILED] state. A job in this state may not be executed. If this happens, retry the UpdateJob request until a successful response is received.", + "canonical": true, + "file": "cloud_scheduler.update_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.UpdateJob", + "async": true, + "parameters": [ + { + "name": "job", + "type": ".google.cloud.scheduler.v1.Job" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.scheduler.v1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" + }, + "method": { + "shortName": "UpdateJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.UpdateJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1_generated_CloudScheduler_DeleteJob_async", + "title": "scheduler deleteJob Sample", + "origin": "API_DEFINITION", + "description": " Deletes a job.", + "canonical": true, + "file": "cloud_scheduler.delete_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.DeleteJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" + }, + "method": { + "shortName": "DeleteJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.DeleteJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1_generated_CloudScheduler_PauseJob_async", + "title": "scheduler pauseJob Sample", + "origin": "API_DEFINITION", + "description": " Pauses a job. If a job is paused then the system will stop executing the job until it is re-enabled via [ResumeJob][google.cloud.scheduler.v1.CloudScheduler.ResumeJob]. The state of the job is stored in [state][google.cloud.scheduler.v1.Job.state]; if paused it will be set to [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. A job must be in [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED] to be paused.", + "canonical": true, + "file": "cloud_scheduler.pause_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PauseJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.PauseJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.scheduler.v1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" + }, + "method": { + "shortName": "PauseJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.PauseJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1_generated_CloudScheduler_ResumeJob_async", + "title": "scheduler resumeJob Sample", + "origin": "API_DEFINITION", + "description": " Resume a job. This method reenables a job after it has been [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. The state of a job is stored in [Job.state][google.cloud.scheduler.v1.Job.state]; after calling this method it will be set to [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED]. A job must be in [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED] to be resumed.", + "canonical": true, + "file": "cloud_scheduler.resume_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ResumeJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.ResumeJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.scheduler.v1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" + }, + "method": { + "shortName": "ResumeJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.ResumeJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1_generated_CloudScheduler_RunJob_async", + "title": "scheduler runJob Sample", + "origin": "API_DEFINITION", + "description": " Forces a job to run now. When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running.", + "canonical": true, + "file": "cloud_scheduler.run_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RunJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.RunJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.scheduler.v1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" + }, + "method": { + "shortName": "RunJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.RunJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1.CloudScheduler" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/index.ts b/owl-bot-staging/google-cloud-scheduler/v1/src/index.ts new file mode 100644 index 00000000000..b5209cd98c9 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const CloudSchedulerClient = v1.CloudSchedulerClient; +type CloudSchedulerClient = v1.CloudSchedulerClient; +export {v1, CloudSchedulerClient}; +export default {v1, CloudSchedulerClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client.ts b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client.ts new file mode 100644 index 00000000000..eda3ad0dfa8 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client.ts @@ -0,0 +1,1281 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/cloud_scheduler_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './cloud_scheduler_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The Cloud Scheduler API allows external entities to reliably + * schedule asynchronous jobs. + * @class + * @memberof v1 + */ +export class CloudSchedulerClient { + 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}; + cloudSchedulerStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CloudSchedulerClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 CloudSchedulerClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CloudSchedulerClient; + 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 { + 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 = { + jobPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listJobs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'jobs') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.scheduler.v1.CloudScheduler', 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.cloudSchedulerStub) { + return this.cloudSchedulerStub; + } + + // Put together the "service stub" for + // google.cloud.scheduler.v1.CloudScheduler. + this.cloudSchedulerStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.scheduler.v1.CloudScheduler') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.scheduler.v1.CloudScheduler, + 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 cloudSchedulerStubMethods = + ['listJobs', 'getJob', 'createJob', 'updateJob', 'deleteJob', 'pauseJob', 'resumeJob', 'runJob']; + for (const methodName of cloudSchedulerStubMethods) { + const callPromise = this.cloudSchedulerStub.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.cloudSchedulerStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudscheduler.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 'cloudscheduler.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 job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.scheduler.v1.Job|Job}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_scheduler.get_job.js + * region_tag:cloudscheduler_v1_generated_CloudScheduler_GetJob_async + */ + getJob( + request?: protos.google.cloud.scheduler.v1.IGetJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IGetJobRequest|undefined, {}|undefined + ]>; + getJob( + request: protos.google.cloud.scheduler.v1.IGetJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IGetJobRequest|null|undefined, + {}|null|undefined>): void; + getJob( + request: protos.google.cloud.scheduler.v1.IGetJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IGetJobRequest|null|undefined, + {}|null|undefined>): void; + getJob( + request?: protos.google.cloud.scheduler.v1.IGetJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IGetJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IGetJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IGetJobRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getJob(request, options, callback); + } +/** + * Creates a job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {google.cloud.scheduler.v1.Job} request.job + * Required. The job to add. The user can optionally specify a name for the + * job in {@link protos.google.cloud.scheduler.v1.Job.name|name}. + * {@link protos.google.cloud.scheduler.v1.Job.name|name} cannot be the same as an + * existing job. If a name is not specified then the system will + * generate a random unique name that will be returned + * ({@link protos.google.cloud.scheduler.v1.Job.name|name}) in the response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.scheduler.v1.Job|Job}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_scheduler.create_job.js + * region_tag:cloudscheduler_v1_generated_CloudScheduler_CreateJob_async + */ + createJob( + request?: protos.google.cloud.scheduler.v1.ICreateJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.ICreateJobRequest|undefined, {}|undefined + ]>; + createJob( + request: protos.google.cloud.scheduler.v1.ICreateJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.ICreateJobRequest|null|undefined, + {}|null|undefined>): void; + createJob( + request: protos.google.cloud.scheduler.v1.ICreateJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.ICreateJobRequest|null|undefined, + {}|null|undefined>): void; + createJob( + request?: protos.google.cloud.scheduler.v1.ICreateJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.ICreateJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.ICreateJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.ICreateJobRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createJob(request, options, callback); + } +/** + * Updates a job. + * + * If successful, the updated {@link protos.google.cloud.scheduler.v1.Job|Job} is + * returned. If the job does not exist, `NOT_FOUND` is returned. + * + * If UpdateJob does not successfully return, it is possible for the + * job to be in an + * {@link protos.google.cloud.scheduler.v1.Job.State.UPDATE_FAILED|Job.State.UPDATE_FAILED} + * state. A job in this state may not be executed. If this happens, retry the + * UpdateJob request until a successful response is received. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.scheduler.v1.Job} request.job + * Required. The new job properties. + * {@link protos.google.cloud.scheduler.v1.Job.name|name} must be specified. + * + * Output only fields cannot be modified using UpdateJob. + * Any value specified for an output only field will be ignored. + * @param {google.protobuf.FieldMask} request.updateMask + * A mask used to specify which fields of the job are being 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 protos.google.cloud.scheduler.v1.Job|Job}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_scheduler.update_job.js + * region_tag:cloudscheduler_v1_generated_CloudScheduler_UpdateJob_async + */ + updateJob( + request?: protos.google.cloud.scheduler.v1.IUpdateJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IUpdateJobRequest|undefined, {}|undefined + ]>; + updateJob( + request: protos.google.cloud.scheduler.v1.IUpdateJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IUpdateJobRequest|null|undefined, + {}|null|undefined>): void; + updateJob( + request: protos.google.cloud.scheduler.v1.IUpdateJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IUpdateJobRequest|null|undefined, + {}|null|undefined>): void; + updateJob( + request?: protos.google.cloud.scheduler.v1.IUpdateJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IUpdateJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IUpdateJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IUpdateJobRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'job.name': request.job!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateJob(request, options, callback); + } +/** + * Deletes a job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_scheduler.delete_job.js + * region_tag:cloudscheduler_v1_generated_CloudScheduler_DeleteJob_async + */ + deleteJob( + request?: protos.google.cloud.scheduler.v1.IDeleteJobRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1.IDeleteJobRequest|undefined, {}|undefined + ]>; + deleteJob( + request: protos.google.cloud.scheduler.v1.IDeleteJobRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1.IDeleteJobRequest|null|undefined, + {}|null|undefined>): void; + deleteJob( + request: protos.google.cloud.scheduler.v1.IDeleteJobRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1.IDeleteJobRequest|null|undefined, + {}|null|undefined>): void; + deleteJob( + request?: protos.google.cloud.scheduler.v1.IDeleteJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1.IDeleteJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1.IDeleteJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1.IDeleteJobRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteJob(request, options, callback); + } +/** + * Pauses a job. + * + * If a job is paused then the system will stop executing the job + * until it is re-enabled via + * {@link protos.google.cloud.scheduler.v1.CloudScheduler.ResumeJob|ResumeJob}. The state + * of the job is stored in {@link protos.google.cloud.scheduler.v1.Job.state|state}; if + * paused it will be set to + * {@link protos.google.cloud.scheduler.v1.Job.State.PAUSED|Job.State.PAUSED}. A job must + * be in {@link protos.google.cloud.scheduler.v1.Job.State.ENABLED|Job.State.ENABLED} to + * be paused. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.scheduler.v1.Job|Job}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_scheduler.pause_job.js + * region_tag:cloudscheduler_v1_generated_CloudScheduler_PauseJob_async + */ + pauseJob( + request?: protos.google.cloud.scheduler.v1.IPauseJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IPauseJobRequest|undefined, {}|undefined + ]>; + pauseJob( + request: protos.google.cloud.scheduler.v1.IPauseJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IPauseJobRequest|null|undefined, + {}|null|undefined>): void; + pauseJob( + request: protos.google.cloud.scheduler.v1.IPauseJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IPauseJobRequest|null|undefined, + {}|null|undefined>): void; + pauseJob( + request?: protos.google.cloud.scheduler.v1.IPauseJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IPauseJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IPauseJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IPauseJobRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.pauseJob(request, options, callback); + } +/** + * Resume a job. + * + * This method reenables a job after it has been + * {@link protos.google.cloud.scheduler.v1.Job.State.PAUSED|Job.State.PAUSED}. The state + * of a job is stored in {@link protos.google.cloud.scheduler.v1.Job.state|Job.state}; + * after calling this method it will be set to + * {@link protos.google.cloud.scheduler.v1.Job.State.ENABLED|Job.State.ENABLED}. A job + * must be in {@link protos.google.cloud.scheduler.v1.Job.State.PAUSED|Job.State.PAUSED} + * to be resumed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.scheduler.v1.Job|Job}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_scheduler.resume_job.js + * region_tag:cloudscheduler_v1_generated_CloudScheduler_ResumeJob_async + */ + resumeJob( + request?: protos.google.cloud.scheduler.v1.IResumeJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IResumeJobRequest|undefined, {}|undefined + ]>; + resumeJob( + request: protos.google.cloud.scheduler.v1.IResumeJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IResumeJobRequest|null|undefined, + {}|null|undefined>): void; + resumeJob( + request: protos.google.cloud.scheduler.v1.IResumeJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IResumeJobRequest|null|undefined, + {}|null|undefined>): void; + resumeJob( + request?: protos.google.cloud.scheduler.v1.IResumeJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IResumeJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IResumeJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IResumeJobRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.resumeJob(request, options, callback); + } +/** + * Forces a job to run now. + * + * When this method is called, Cloud Scheduler will dispatch the job, even + * if the job is already running. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.scheduler.v1.Job|Job}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_scheduler.run_job.js + * region_tag:cloudscheduler_v1_generated_CloudScheduler_RunJob_async + */ + runJob( + request?: protos.google.cloud.scheduler.v1.IRunJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IRunJobRequest|undefined, {}|undefined + ]>; + runJob( + request: protos.google.cloud.scheduler.v1.IRunJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IRunJobRequest|null|undefined, + {}|null|undefined>): void; + runJob( + request: protos.google.cloud.scheduler.v1.IRunJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IRunJobRequest|null|undefined, + {}|null|undefined>): void; + runJob( + request?: protos.google.cloud.scheduler.v1.IRunJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IRunJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IRunJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IRunJobRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.runJob(request, options, callback); + } + + /** + * Lists jobs. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {number} request.pageSize + * Requested page size. + * + * The maximum page size is 500. If unspecified, the page size will + * be the maximum. Fewer jobs than requested might be returned, + * even if more jobs exist; use next_page_token to determine if more + * jobs exist. + * @param {string} request.pageToken + * A token identifying a page of results the server will return. To + * request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.scheduler.v1.ListJobsResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.scheduler.v1.CloudScheduler.ListJobs|ListJobs}. It is an + * error to switch the value of + * {@link protos.google.cloud.scheduler.v1.ListJobsRequest.filter|filter} or + * {@link protos.google.cloud.scheduler.v1.ListJobsRequest.order_by|order_by} while + * iterating through pages. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.scheduler.v1.Job|Job}. + * 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 `listJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listJobs( + request?: protos.google.cloud.scheduler.v1.IListJobsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1.IJob[], + protos.google.cloud.scheduler.v1.IListJobsRequest|null, + protos.google.cloud.scheduler.v1.IListJobsResponse + ]>; + listJobs( + request: protos.google.cloud.scheduler.v1.IListJobsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.scheduler.v1.IListJobsRequest, + protos.google.cloud.scheduler.v1.IListJobsResponse|null|undefined, + protos.google.cloud.scheduler.v1.IJob>): void; + listJobs( + request: protos.google.cloud.scheduler.v1.IListJobsRequest, + callback: PaginationCallback< + protos.google.cloud.scheduler.v1.IListJobsRequest, + protos.google.cloud.scheduler.v1.IListJobsResponse|null|undefined, + protos.google.cloud.scheduler.v1.IJob>): void; + listJobs( + request?: protos.google.cloud.scheduler.v1.IListJobsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.scheduler.v1.IListJobsRequest, + protos.google.cloud.scheduler.v1.IListJobsResponse|null|undefined, + protos.google.cloud.scheduler.v1.IJob>, + callback?: PaginationCallback< + protos.google.cloud.scheduler.v1.IListJobsRequest, + protos.google.cloud.scheduler.v1.IListJobsResponse|null|undefined, + protos.google.cloud.scheduler.v1.IJob>): + Promise<[ + protos.google.cloud.scheduler.v1.IJob[], + protos.google.cloud.scheduler.v1.IListJobsRequest|null, + protos.google.cloud.scheduler.v1.IListJobsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listJobs(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {number} request.pageSize + * Requested page size. + * + * The maximum page size is 500. If unspecified, the page size will + * be the maximum. Fewer jobs than requested might be returned, + * even if more jobs exist; use next_page_token to determine if more + * jobs exist. + * @param {string} request.pageToken + * A token identifying a page of results the server will return. To + * request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.scheduler.v1.ListJobsResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.scheduler.v1.CloudScheduler.ListJobs|ListJobs}. It is an + * error to switch the value of + * {@link protos.google.cloud.scheduler.v1.ListJobsRequest.filter|filter} or + * {@link protos.google.cloud.scheduler.v1.ListJobsRequest.order_by|order_by} while + * iterating through pages. + * @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 protos.google.cloud.scheduler.v1.Job|Job} 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 `listJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listJobsStream( + request?: protos.google.cloud.scheduler.v1.IListJobsRequest, + 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['listJobs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listJobs.createStream( + this.innerApiCalls.listJobs as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listJobs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {number} request.pageSize + * Requested page size. + * + * The maximum page size is 500. If unspecified, the page size will + * be the maximum. Fewer jobs than requested might be returned, + * even if more jobs exist; use next_page_token to determine if more + * jobs exist. + * @param {string} request.pageToken + * A token identifying a page of results the server will return. To + * request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.scheduler.v1.ListJobsResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.scheduler.v1.CloudScheduler.ListJobs|ListJobs}. It is an + * error to switch the value of + * {@link protos.google.cloud.scheduler.v1.ListJobsRequest.filter|filter} or + * {@link protos.google.cloud.scheduler.v1.ListJobsRequest.order_by|order_by} while + * iterating through pages. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.scheduler.v1.Job|Job}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_scheduler.list_jobs.js + * region_tag:cloudscheduler_v1_generated_CloudScheduler_ListJobs_async + */ + listJobsAsync( + request?: protos.google.cloud.scheduler.v1.IListJobsRequest, + 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['listJobs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listJobs.asyncIterate( + this.innerApiCalls['listJobs'] 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified job resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @returns {string} Resource name string. + */ + jobPath(project:string,location:string,job:string) { + return this.pathTemplates.jobPathTemplate.render({ + project: project, + location: location, + job: job, + }); + } + + /** + * Parse the project from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the project. + */ + matchProjectFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).project; + } + + /** + * Parse the location from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the location. + */ + matchLocationFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).location; + } + + /** + * Parse the job from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the job. + */ + matchJobFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).job; + } + + /** + * 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 project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.cloudSchedulerStub && !this._terminated) { + return this.cloudSchedulerStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client_config.json b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client_config.json new file mode 100644 index 00000000000..edb34789cd4 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client_config.json @@ -0,0 +1,66 @@ +{ + "interfaces": { + "google.cloud.scheduler.v1.CloudScheduler": { + "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": { + "ListJobs": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetJob": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateJob": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateJob": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteJob": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "PauseJob": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ResumeJob": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RunJob": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_proto_list.json b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_proto_list.json new file mode 100644 index 00000000000..2762a0163a0 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_proto_list.json @@ -0,0 +1,5 @@ +[ + "../../protos/google/cloud/scheduler/v1/cloudscheduler.proto", + "../../protos/google/cloud/scheduler/v1/job.proto", + "../../protos/google/cloud/scheduler/v1/target.proto" +] diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..122c43fbb24 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/gapic_metadata.json @@ -0,0 +1,107 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.scheduler.v1", + "libraryPackage": "@google-cloud/scheduler", + "services": { + "CloudScheduler": { + "clients": { + "grpc": { + "libraryClient": "CloudSchedulerClient", + "rpcs": { + "GetJob": { + "methods": [ + "getJob" + ] + }, + "CreateJob": { + "methods": [ + "createJob" + ] + }, + "UpdateJob": { + "methods": [ + "updateJob" + ] + }, + "DeleteJob": { + "methods": [ + "deleteJob" + ] + }, + "PauseJob": { + "methods": [ + "pauseJob" + ] + }, + "ResumeJob": { + "methods": [ + "resumeJob" + ] + }, + "RunJob": { + "methods": [ + "runJob" + ] + }, + "ListJobs": { + "methods": [ + "listJobs", + "listJobsStream", + "listJobsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CloudSchedulerClient", + "rpcs": { + "GetJob": { + "methods": [ + "getJob" + ] + }, + "CreateJob": { + "methods": [ + "createJob" + ] + }, + "UpdateJob": { + "methods": [ + "updateJob" + ] + }, + "DeleteJob": { + "methods": [ + "deleteJob" + ] + }, + "PauseJob": { + "methods": [ + "pauseJob" + ] + }, + "ResumeJob": { + "methods": [ + "resumeJob" + ] + }, + "RunJob": { + "methods": [ + "runJob" + ] + }, + "ListJobs": { + "methods": [ + "listJobs", + "listJobsStream", + "listJobsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/index.ts new file mode 100644 index 00000000000..782589c88a7 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {CloudSchedulerClient} from './cloud_scheduler_client'; diff --git a/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..26229572638 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const scheduler = require('@google-cloud/scheduler'); + +function main() { + const cloudSchedulerClient = new scheduler.CloudSchedulerClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..99f6bacd17a --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {CloudSchedulerClient} from '@google-cloud/scheduler'; + +// check that the client class type name can be used +function doStuffWithCloudSchedulerClient(client: CloudSchedulerClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const cloudSchedulerClient = new CloudSchedulerClient(); + doStuffWithCloudSchedulerClient(cloudSchedulerClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/system-test/install.ts b/owl-bot-staging/google-cloud-scheduler/v1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/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-scheduler/v1/test/gapic_cloud_scheduler_v1.ts b/owl-bot-staging/google-cloud-scheduler/v1/test/gapic_cloud_scheduler_v1.ts new file mode 100644 index 00000000000..fb8169ed4a1 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/test/gapic_cloud_scheduler_v1.ts @@ -0,0 +1,1485 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 cloudschedulerModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, 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('v1.CloudSchedulerClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = cloudschedulerModule.v1.CloudSchedulerClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = cloudschedulerModule.v1.CloudSchedulerClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = cloudschedulerModule.v1.CloudSchedulerClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudSchedulerStub, undefined); + await client.initialize(); + assert(client.cloudSchedulerStub); + }); + + it('has close method for the initialized client', done => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.cloudSchedulerStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudSchedulerStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1.CloudSchedulerClient({ + 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('getJob', () => { + it('invokes getJob without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.getJob = stubSimpleCall(expectedResponse); + const [response] = await client.getJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getJob without error using callback', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.getJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getJob with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getJob(request), expectedError); + const actualRequest = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getJob with closed client', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getJob(request), expectedError); + }); + }); + + describe('createJob', () => { + it('invokes createJob without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.createJob = stubSimpleCall(expectedResponse); + const [response] = await client.createJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createJob without error using callback', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.createJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createJob with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createJob(request), expectedError); + const actualRequest = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createJob with closed client', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createJob(request), expectedError); + }); + }); + + describe('updateJob', () => { + it('invokes updateJob without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.UpdateJobRequest() + ); + request.job ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.UpdateJobRequest', ['job', 'name']); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.updateJob = stubSimpleCall(expectedResponse); + const [response] = await client.updateJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateJob without error using callback', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.UpdateJobRequest() + ); + request.job ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.UpdateJobRequest', ['job', 'name']); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.updateJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateJob with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.UpdateJobRequest() + ); + request.job ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.UpdateJobRequest', ['job', 'name']); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateJob(request), expectedError); + const actualRequest = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateJob with closed client', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.UpdateJobRequest() + ); + request.job ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.UpdateJobRequest', ['job', 'name']); + request.job.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateJob(request), expectedError); + }); + }); + + describe('deleteJob', () => { + it('invokes deleteJob without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteJob = stubSimpleCall(expectedResponse); + const [response] = await client.deleteJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteJob without error using callback', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteJob( + 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.deleteJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteJob with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteJob(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteJob with closed client', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteJob(request), expectedError); + }); + }); + + describe('pauseJob', () => { + it('invokes pauseJob without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.PauseJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.PauseJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.pauseJob = stubSimpleCall(expectedResponse); + const [response] = await client.pauseJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseJob without error using callback', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.PauseJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.PauseJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.pauseJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.pauseJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseJob with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.PauseJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.PauseJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.pauseJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.pauseJob(request), expectedError); + const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseJob with closed client', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.PauseJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.PauseJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.pauseJob(request), expectedError); + }); + }); + + describe('resumeJob', () => { + it('invokes resumeJob without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ResumeJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.ResumeJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.resumeJob = stubSimpleCall(expectedResponse); + const [response] = await client.resumeJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeJob without error using callback', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ResumeJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.ResumeJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.resumeJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resumeJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeJob with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ResumeJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.ResumeJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resumeJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.resumeJob(request), expectedError); + const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeJob with closed client', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ResumeJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.ResumeJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.resumeJob(request), expectedError); + }); + }); + + describe('runJob', () => { + it('invokes runJob without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.RunJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.RunJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.runJob = stubSimpleCall(expectedResponse); + const [response] = await client.runJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runJob without error using callback', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.RunJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.RunJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.runJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.runJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runJob with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.RunJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.RunJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.runJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.runJob(request), expectedError); + const actualRequest = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runJob with closed client', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.RunJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.RunJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.runJob(request), expectedError); + }); + }); + + describe('listJobs', () => { + it('invokes listJobs without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + ]; + client.innerApiCalls.listJobs = stubSimpleCall(expectedResponse); + const [response] = await client.listJobs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listJobs without error using callback', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + ]; + client.innerApiCalls.listJobs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listJobs( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listJobs with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listJobs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listJobs(request), expectedError); + const actualRequest = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listJobsStream without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + ]; + client.descriptors.page.listJobs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.scheduler.v1.Job[] = []; + stream.on('data', (response: protos.google.cloud.scheduler.v1.Job) => { + 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.listJobs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listJobsStream with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listJobs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.scheduler.v1.Job[] = []; + stream.on('data', (response: protos.google.cloud.scheduler.v1.Job) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listJobs without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + ]; + client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.scheduler.v1.IJob[] = []; + const iterable = client.listJobsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listJobs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listJobs with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listJobsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.scheduler.v1.IJob[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listJobs.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 cloudschedulerModule.v1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1.CloudSchedulerClient({ + 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('Path templates', () => { + + describe('job', () => { + const fakePath = "/rendered/path/job"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + }; + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.jobPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.jobPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('jobPath', () => { + const result = client.jobPath("projectValue", "locationValue", "jobValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.jobPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromJobName', () => { + const result = client.matchProjectFromJobName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromJobName', () => { + const result = client.matchLocationFromJobName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromJobName', () => { + const result = client.matchJobFromJobName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + 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('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/tsconfig.json b/owl-bot-staging/google-cloud-scheduler/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/webpack.config.js b/owl-bot-staging/google-cloud-scheduler/v1/webpack.config.js new file mode 100644 index 00000000000..d4565464f20 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'scheduler', + filename: './scheduler.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-scheduler/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/.gitignore b/owl-bot-staging/google-cloud-scheduler/v1beta1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/.jsdoc.js new file mode 100644 index 00000000000..da319aef859 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/.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/scheduler', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/.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-scheduler/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/.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-scheduler/v1beta1/README.md b/owl-bot-staging/google-cloud-scheduler/v1beta1/README.md new file mode 100644 index 00000000000..90fa2a2d162 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/README.md @@ -0,0 +1 @@ +Scheduler: Nodejs Client diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/package.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/package.json new file mode 100644 index 00000000000..c3738ba2d1a --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/package.json @@ -0,0 +1,58 @@ +{ + "name": "@google-cloud/scheduler", + "version": "0.1.0", + "description": "Scheduler client for Node.js", + "repository": "googleapis/nodejs-scheduler", + "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 scheduler", + "scheduler", + "cloud scheduler" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto b/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto new file mode 100644 index 00000000000..210e0f29412 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto @@ -0,0 +1,315 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.scheduler.v1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/scheduler/v1beta1/job.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option go_package = "cloud.google.com/go/scheduler/apiv1beta1/schedulerpb;schedulerpb"; +option java_multiple_files = true; +option java_outer_classname = "SchedulerProto"; +option java_package = "com.google.cloud.scheduler.v1beta1"; +option objc_class_prefix = "SCHEDULER"; + +// The Cloud Scheduler API allows external entities to reliably +// schedule asynchronous jobs. +service CloudScheduler { + option (google.api.default_host) = "cloudscheduler.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Lists jobs. + rpc ListJobs(ListJobsRequest) returns (ListJobsResponse) { + option (google.api.http) = { + get: "/v1beta1/{parent=projects/*/locations/*}/jobs" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a job. + rpc GetJob(GetJobRequest) returns (Job) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/locations/*/jobs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a job. + rpc CreateJob(CreateJobRequest) returns (Job) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*/locations/*}/jobs" + body: "job" + }; + option (google.api.method_signature) = "parent,job"; + } + + // Updates a job. + // + // If successful, the updated [Job][google.cloud.scheduler.v1beta1.Job] is + // returned. If the job does not exist, `NOT_FOUND` is returned. + // + // If UpdateJob does not successfully return, it is possible for the + // job to be in an + // [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1beta1.Job.State.UPDATE_FAILED] + // state. A job in this state may not be executed. If this happens, retry the + // UpdateJob request until a successful response is received. + rpc UpdateJob(UpdateJobRequest) returns (Job) { + option (google.api.http) = { + patch: "/v1beta1/{job.name=projects/*/locations/*/jobs/*}" + body: "job" + }; + option (google.api.method_signature) = "job,update_mask"; + } + + // Deletes a job. + rpc DeleteJob(DeleteJobRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1beta1/{name=projects/*/locations/*/jobs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Pauses a job. + // + // If a job is paused then the system will stop executing the job + // until it is re-enabled via + // [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. The + // state of the job is stored in + // [state][google.cloud.scheduler.v1beta1.Job.state]; if paused it will be set + // to [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. A + // job must be in + // [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED] to be + // paused. + rpc PauseJob(PauseJobRequest) returns (Job) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/jobs/*}:pause" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Resume a job. + // + // This method reenables a job after it has been + // [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. The + // state of a job is stored in + // [Job.state][google.cloud.scheduler.v1beta1.Job.state]; after calling this + // method it will be set to + // [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED]. A + // job must be in + // [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED] to be + // resumed. + rpc ResumeJob(ResumeJobRequest) returns (Job) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/jobs/*}:resume" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Forces a job to run now. + // + // When this method is called, Cloud Scheduler will dispatch the job, even + // if the job is already running. + rpc RunJob(RunJobRequest) returns (Job) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/jobs/*}:run" + body: "*" + }; + option (google.api.method_signature) = "name"; + } +} + +// Request message for listing jobs using +// [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs]. +message ListJobsRequest { + // Required. The location name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "cloudscheduler.googleapis.com/Job" + } + ]; + + // `filter` can be used to specify a subset of jobs. + // + // If `filter` equals `target_config="HttpConfig"`, then the http + // target jobs are retrieved. If `filter` equals + // `target_config="PubSubConfig"`, then the Pub/Sub target jobs are + // retrieved. If `filter` equals `labels.foo=value1 + // labels.foo=value2` then only jobs which are labeled with + // foo=value1 AND foo=value2 will be returned. + string filter = 4; + + // Requested page size. + // + // The maximum page size is 500. If unspecified, the page size will + // be the maximum. Fewer jobs than requested might be returned, + // even if more jobs exist; use next_page_token to determine if more + // jobs exist. + int32 page_size = 5; + + // A token identifying a page of results the server will return. To + // request the first page results, page_token must be empty. To + // request the next page of results, page_token must be the value of + // [next_page_token][google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token] + // returned from the previous call to + // [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs]. It is + // an error to switch the value of + // [filter][google.cloud.scheduler.v1beta1.ListJobsRequest.filter] or + // [order_by][google.cloud.scheduler.v1beta1.ListJobsRequest.order_by] while + // iterating through pages. + string page_token = 6; + + // This field is used to manage the legacy App Engine Cron jobs using the + // Cloud Scheduler API. If the field is set to true, the jobs in the __cron + // queue will be listed instead. + bool legacy_app_engine_cron = 7; +} + +// Response message for listing jobs using +// [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs]. +message ListJobsResponse { + // The list of jobs. + repeated Job jobs = 1; + + // A token to retrieve next page of results. Pass this value in the + // [page_token][google.cloud.scheduler.v1beta1.ListJobsRequest.page_token] + // field in the subsequent call to + // [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs] to + // retrieve the next page of results. If this is empty it indicates that there + // are no more results through which to paginate. + // + // The page token is valid for only 2 hours. + string next_page_token = 2; +} + +// Request message for +// [GetJob][google.cloud.scheduler.v1beta1.CloudScheduler.GetJob]. +message GetJobRequest { + // Required. The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudscheduler.googleapis.com/Job" + } + ]; +} + +// Request message for +// [CreateJob][google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob]. +message CreateJobRequest { + // Required. The location name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "cloudscheduler.googleapis.com/Job" + } + ]; + + // Required. The job to add. The user can optionally specify a name for the + // job in [name][google.cloud.scheduler.v1beta1.Job.name]. + // [name][google.cloud.scheduler.v1beta1.Job.name] cannot be the same as an + // existing job. If a name is not specified then the system will + // generate a random unique name that will be returned + // ([name][google.cloud.scheduler.v1beta1.Job.name]) in the response. + Job job = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for +// [UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob]. +message UpdateJobRequest { + // Required. The new job properties. + // [name][google.cloud.scheduler.v1beta1.Job.name] must be specified. + // + // Output only fields cannot be modified using UpdateJob. + // Any value specified for an output only field will be ignored. + Job job = 1 [(google.api.field_behavior) = REQUIRED]; + + // A mask used to specify which fields of the job are being updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for deleting a job using +// [DeleteJob][google.cloud.scheduler.v1beta1.CloudScheduler.DeleteJob]. +message DeleteJobRequest { + // Required. The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudscheduler.googleapis.com/Job" + } + ]; + + // This field is used to manage the legacy App Engine Cron jobs using the + // Cloud Scheduler API. If the field is set to true, the job in the __cron + // queue with the corresponding name will be deleted instead. + bool legacy_app_engine_cron = 2; +} + +// Request message for +// [PauseJob][google.cloud.scheduler.v1beta1.CloudScheduler.PauseJob]. +message PauseJobRequest { + // Required. The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudscheduler.googleapis.com/Job" + } + ]; +} + +// Request message for +// [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. +message ResumeJobRequest { + // Required. The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudscheduler.googleapis.com/Job" + } + ]; +} + +// Request message for forcing a job to run now using +// [RunJob][google.cloud.scheduler.v1beta1.CloudScheduler.RunJob]. +message RunJobRequest { + // Required. The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudscheduler.googleapis.com/Job" + } + ]; + + // This field is used to manage the legacy App Engine Cron jobs using the + // Cloud Scheduler API. If the field is set to true, the job in the __cron + // queue with the corresponding name will be forced to run instead. + bool legacy_app_engine_cron = 2; +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/job.proto b/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/job.proto new file mode 100644 index 00000000000..2674217d97e --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/job.proto @@ -0,0 +1,268 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.scheduler.v1beta1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/scheduler/v1beta1/target.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option go_package = "cloud.google.com/go/scheduler/apiv1beta1/schedulerpb;schedulerpb"; +option java_multiple_files = true; +option java_outer_classname = "JobProto"; +option java_package = "com.google.cloud.scheduler.v1beta1"; + +// Configuration for a job. +// The maximum allowed size for a job is 1MB. +message Job { + option (google.api.resource) = { + type: "cloudscheduler.googleapis.com/Job" + pattern: "projects/{project}/locations/{location}/jobs/{job}" + }; + + // State of the job. + enum State { + // Unspecified state. + STATE_UNSPECIFIED = 0; + + // The job is executing normally. + ENABLED = 1; + + // The job is paused by the user. It will not execute. A user can + // intentionally pause the job using + // [PauseJobRequest][google.cloud.scheduler.v1beta1.PauseJobRequest]. + PAUSED = 2; + + // The job is disabled by the system due to error. The user + // cannot directly set a job to be disabled. + DISABLED = 3; + + // The job state resulting from a failed + // [CloudScheduler.UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob] + // operation. To recover a job from this state, retry + // [CloudScheduler.UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob] + // until a successful response is received. + UPDATE_FAILED = 4; + } + + // Optionally caller-specified in + // [CreateJob][google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob], after + // which it becomes output only. + // + // The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + // + // * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]), + // hyphens (-), colons (:), or periods (.). + // For more information, see + // [Identifying + // projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects) + // * `LOCATION_ID` is the canonical ID for the job's location. + // The list of available locations can be obtained by calling + // [ListLocations][google.cloud.location.Locations.ListLocations]. + // For more information, see https://cloud.google.com/about/locations/. + // * `JOB_ID` can contain only letters ([A-Za-z]), numbers ([0-9]), + // hyphens (-), or underscores (_). The maximum length is 500 characters. + string name = 1; + + // Optionally caller-specified in + // [CreateJob][google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob] or + // [UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob]. + // + // A human-readable description for the job. This string must not contain + // more than 500 characters. + string description = 2; + + // Required. + // + // Delivery settings containing destination and parameters. + oneof target { + // Pub/Sub target. + PubsubTarget pubsub_target = 4; + + // App Engine HTTP target. + AppEngineHttpTarget app_engine_http_target = 5; + + // HTTP target. + HttpTarget http_target = 6; + } + + // Required, except when used with + // [UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob]. + // + // Describes the schedule on which the job will be executed. + // + // The schedule can be either of the following types: + // + // * [Crontab](https://en.wikipedia.org/wiki/Cron#Overview) + // * English-like + // [schedule](https://cloud.google.com/scheduler/docs/configuring/cron-job-schedules) + // + // As a general rule, execution `n + 1` of a job will not begin + // until execution `n` has finished. Cloud Scheduler will never + // allow two simultaneously outstanding executions. For example, + // this implies that if the `n+1`th execution is scheduled to run at + // 16:00 but the `n`th execution takes until 16:15, the `n+1`th + // execution will not start until `16:15`. + // A scheduled start time will be delayed if the previous + // execution has not ended when its scheduled time occurs. + // + // If [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] > + // 0 and a job attempt fails, the job will be tried a total of + // [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] + // times, with exponential backoff, until the next scheduled start + // time. + string schedule = 20; + + // Specifies the time zone to be used in interpreting + // [schedule][google.cloud.scheduler.v1beta1.Job.schedule]. The value of this + // field must be a time zone name from the [tz + // database](http://en.wikipedia.org/wiki/Tz_database). + // + // Note that some time zones include a provision for + // daylight savings time. The rules for daylight saving time are + // determined by the chosen tz. For UTC use the string "utc". If a + // time zone is not specified, the default will be in UTC (also known + // as GMT). + string time_zone = 21; + + // Output only. The creation time of the job. + google.protobuf.Timestamp user_update_time = 9; + + // Output only. State of the job. + State state = 10; + + // Output only. The response from the target for the last attempted execution. + google.rpc.Status status = 11; + + // Output only. The next time the job is scheduled. Note that this may be a + // retry of a previously failed attempt or the next execution time + // according to the schedule. + google.protobuf.Timestamp schedule_time = 17; + + // Output only. The time the last job attempt started. + google.protobuf.Timestamp last_attempt_time = 18; + + // Settings that determine the retry behavior. + RetryConfig retry_config = 19; + + // The deadline for job attempts. If the request handler does not respond by + // this deadline then the request is cancelled and the attempt is marked as a + // `DEADLINE_EXCEEDED` failure. The failed attempt can be viewed in + // execution logs. Cloud Scheduler will retry the job according + // to the [RetryConfig][google.cloud.scheduler.v1beta1.RetryConfig]. + // + // The default and the allowed values depend on the type of target: + // + // * For [HTTP targets][google.cloud.scheduler.v1beta1.Job.http_target], the + // default is 3 minutes. The deadline must be in the interval [15 seconds, 30 + // minutes]. + // + // * For [App Engine HTTP + // targets][google.cloud.scheduler.v1beta1.Job.app_engine_http_target], 0 + // indicates that the request has the default deadline. The default deadline + // depends on the scaling type of the service: 10 minutes for standard apps + // with automatic scaling, 24 hours for standard apps with manual and basic + // scaling, and 60 minutes for flex apps. If the request deadline is set, it + // must be in the interval [15 seconds, 24 hours 15 seconds]. + // + // * For [Pub/Sub targets][google.cloud.scheduler.v1beta1.Job.pubsub_target], + // this field is ignored. + google.protobuf.Duration attempt_deadline = 22; + + // Immutable. This field is used to manage the legacy App Engine Cron jobs + // using the Cloud Scheduler API. If the field is set to true, the job will be + // considered a legacy job. Note that App Engine Cron jobs have fewer + // features than Cloud Scheduler jobs, e.g., are only limited to App Engine + // targets. + bool legacy_app_engine_cron = 23 [(google.api.field_behavior) = IMMUTABLE]; +} + +// Settings that determine the retry behavior. +// +// By default, if a job does not complete successfully (meaning that +// an acknowledgement is not received from the handler, then it will be retried +// with exponential backoff according to the settings in +// [RetryConfig][google.cloud.scheduler.v1beta1.RetryConfig]. +message RetryConfig { + // The number of attempts that the system will make to run a job using the + // exponential backoff procedure described by + // [max_doublings][google.cloud.scheduler.v1beta1.RetryConfig.max_doublings]. + // + // The default value of retry_count is zero. + // + // If retry_count is zero, a job attempt will *not* be retried if + // it fails. Instead the Cloud Scheduler system will wait for the + // next scheduled execution time. + // + // If retry_count is set to a non-zero number then Cloud Scheduler + // will retry failed attempts, using exponential backoff, + // retry_count times, or until the next scheduled execution time, + // whichever comes first. + // + // Values greater than 5 and negative values are not allowed. + int32 retry_count = 1; + + // The time limit for retrying a failed job, measured from time when an + // execution was first attempted. If specified with + // [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count], the + // job will be retried until both limits are reached. + // + // The default value for max_retry_duration is zero, which means retry + // duration is unlimited. + google.protobuf.Duration max_retry_duration = 2; + + // The minimum amount of time to wait before retrying a job after + // it fails. + // + // The default value of this field is 5 seconds. + google.protobuf.Duration min_backoff_duration = 3; + + // The maximum amount of time to wait before retrying a job after + // it fails. + // + // The default value of this field is 1 hour. + google.protobuf.Duration max_backoff_duration = 4; + + // The time between retries will double `max_doublings` times. + // + // A job's retry interval starts at + // [min_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.min_backoff_duration], + // then doubles `max_doublings` times, then increases linearly, and finally + // retries at intervals of + // [max_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.max_backoff_duration] + // up to [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] + // times. + // + // For example, if + // [min_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.min_backoff_duration] + // is 10s, + // [max_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.max_backoff_duration] + // is 300s, and `max_doublings` is 3, then the a job will first be retried in + // 10s. The retry interval will double three times, and then increase linearly + // by 2^3 * 10s. Finally, the job will retry at intervals of + // [max_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.max_backoff_duration] + // until the job has been attempted + // [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] + // times. Thus, the requests will retry at 10s, 20s, 40s, 80s, 160s, 240s, + // 300s, 300s, .... + // + // The default value of this field is 5. + int32 max_doublings = 5; +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/target.proto b/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/target.proto new file mode 100644 index 00000000000..af1c3484e50 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/target.proto @@ -0,0 +1,371 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.scheduler.v1beta1; + +import "google/api/resource.proto"; + +option go_package = "cloud.google.com/go/scheduler/apiv1beta1/schedulerpb;schedulerpb"; +option java_multiple_files = true; +option java_outer_classname = "TargetProto"; +option java_package = "com.google.cloud.scheduler.v1beta1"; +option (google.api.resource_definition) = { + type: "pubsub.googleapis.com/Topic" + pattern: "projects/{project}/topics/{topic}" +}; + +// Http target. The job will be pushed to the job handler by means of +// an HTTP request via an +// [http_method][google.cloud.scheduler.v1beta1.HttpTarget.http_method] such as +// HTTP POST, HTTP GET, etc. The job is acknowledged by means of an HTTP +// response code in the range [200 - 299]. A failure to receive a response +// constitutes a failed execution. For a redirected request, the response +// returned by the redirected request is considered. +message HttpTarget { + // Required. The full URI path that the request will be sent to. This string + // must begin with either "http://" or "https://". Some examples of + // valid values for [uri][google.cloud.scheduler.v1beta1.HttpTarget.uri] are: + // `http://acme.com` and `https://acme.com/sales:8080`. Cloud Scheduler will + // encode some characters for safety and compatibility. The maximum allowed + // URL length is 2083 characters after encoding. + string uri = 1; + + // Which HTTP method to use for the request. + HttpMethod http_method = 2; + + // The user can specify HTTP request headers to send with the job's + // HTTP request. This map contains the header field names and + // values. Repeated headers are not supported, but a header value can + // contain commas. These headers represent a subset of the headers + // that will accompany the job's HTTP request. Some HTTP request + // headers will be ignored or replaced. A partial list of headers that + // will be ignored or replaced is below: + // - Host: This will be computed by Cloud Scheduler and derived from + // [uri][google.cloud.scheduler.v1beta1.HttpTarget.uri]. + // * `Content-Length`: This will be computed by Cloud Scheduler. + // * `User-Agent`: This will be set to `"Google-Cloud-Scheduler"`. + // * `X-Google-*`: Google internal use only. + // * `X-AppEngine-*`: Google internal use only. + // * `X-CloudScheduler`: This header will be set to true. + // * `X-CloudScheduler-JobName`: This header will contain the job name. + // * `X-CloudScheduler-ScheduleTime`: For Cloud Scheduler jobs specified in + // the unix-cron format, this header will contain the job schedule time in + // RFC3339 UTC "Zulu" format. + // + // The total size of headers must be less than 80KB. + map headers = 3; + + // HTTP request body. A request body is allowed only if the HTTP + // method is POST, PUT, or PATCH. It is an error to set body on a job with an + // incompatible [HttpMethod][google.cloud.scheduler.v1beta1.HttpMethod]. + bytes body = 4; + + // The mode for generating an `Authorization` header for HTTP requests. + // + // If specified, all `Authorization` headers in the + // [HttpTarget.headers][google.cloud.scheduler.v1beta1.HttpTarget.headers] + // field will be overridden. + oneof authorization_header { + // If specified, an + // [OAuth token](https://developers.google.com/identity/protocols/OAuth2) + // will be generated and attached as an `Authorization` header in the HTTP + // request. + // + // This type of authorization should generally only be used when calling + // Google APIs hosted on *.googleapis.com. + OAuthToken oauth_token = 5; + + // If specified, an + // [OIDC](https://developers.google.com/identity/protocols/OpenIDConnect) + // token will be generated and attached as an `Authorization` header in the + // HTTP request. + // + // This type of authorization can be used for many scenarios, including + // calling Cloud Run, or endpoints where you intend to validate the token + // yourself. + OidcToken oidc_token = 6; + } +} + +// App Engine target. The job will be pushed to a job handler by means +// of an HTTP request via an +// [http_method][google.cloud.scheduler.v1beta1.AppEngineHttpTarget.http_method] +// such as HTTP POST, HTTP GET, etc. The job is acknowledged by means of an HTTP +// response code in the range [200 - 299]. Error 503 is considered an App Engine +// system error instead of an application error. Requests returning error 503 +// will be retried regardless of retry configuration and not counted against +// retry counts. Any other response code, or a failure to receive a response +// before the deadline, constitutes a failed attempt. +message AppEngineHttpTarget { + // The HTTP method to use for the request. PATCH and OPTIONS are not + // permitted. + HttpMethod http_method = 1; + + // App Engine Routing setting for the job. + AppEngineRouting app_engine_routing = 2; + + // The relative URI. + // + // The relative URL must begin with "/" and must be a valid HTTP relative URL. + // It can contain a path, query string arguments, and `#` fragments. + // If the relative URL is empty, then the root path "/" will be used. + // No spaces are allowed, and the maximum length allowed is 2083 characters. + string relative_uri = 3; + + // HTTP request headers. + // + // This map contains the header field names and values. Headers can be set + // when the job is created. + // + // Cloud Scheduler sets some headers to default values: + // + // * `User-Agent`: By default, this header is + // `"AppEngine-Google; (+http://code.google.com/appengine)"`. + // This header can be modified, but Cloud Scheduler will append + // `"AppEngine-Google; (+http://code.google.com/appengine)"` to the + // modified `User-Agent`. + // * `X-CloudScheduler`: This header will be set to true. + // * `X-CloudScheduler-JobName`: This header will contain the job name. + // * `X-CloudScheduler-ScheduleTime`: For Cloud Scheduler jobs specified in + // the unix-cron format, this header will contain the job schedule time in + // RFC3339 UTC "Zulu" format. + // + // If the job has an + // [body][google.cloud.scheduler.v1beta1.AppEngineHttpTarget.body], Cloud + // Scheduler sets the following headers: + // + // * `Content-Type`: By default, the `Content-Type` header is set to + // `"application/octet-stream"`. The default can be overridden by explictly + // setting `Content-Type` to a particular media type when the job is + // created. + // For example, `Content-Type` can be set to `"application/json"`. + // * `Content-Length`: This is computed by Cloud Scheduler. This value is + // output only. It cannot be changed. + // + // The headers below are output only. They cannot be set or overridden: + // + // * `X-Google-*`: For Google internal use only. + // * `X-AppEngine-*`: For Google internal use only. + // + // In addition, some App Engine headers, which contain + // job-specific information, are also be sent to the job handler. + map headers = 4; + + // Body. + // + // HTTP request body. A request body is allowed only if the HTTP method is + // POST or PUT. It will result in invalid argument error to set a body on a + // job with an incompatible + // [HttpMethod][google.cloud.scheduler.v1beta1.HttpMethod]. + bytes body = 5; +} + +// Pub/Sub target. The job will be delivered by publishing a message to +// the given Pub/Sub topic. +message PubsubTarget { + // Required. The name of the Cloud Pub/Sub topic to which messages will + // be published when a job is delivered. The topic name must be in the + // same format as required by Pub/Sub's + // [PublishRequest.name](https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#publishrequest), + // for example `projects/PROJECT_ID/topics/TOPIC_ID`. + // + // The topic must be in the same project as the Cloud Scheduler job. + string topic_name = 1 [ + (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" } + ]; + + // The message payload for PubsubMessage. + // + // Pubsub message must contain either non-empty data, or at least one + // attribute. + bytes data = 3; + + // Attributes for PubsubMessage. + // + // Pubsub message must contain either non-empty data, or at least one + // attribute. + map attributes = 4; +} + +// App Engine Routing. +// +// For more information about services, versions, and instances see +// [An Overview of App +// Engine](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine), +// [Microservices Architecture on Google App +// Engine](https://cloud.google.com/appengine/docs/python/microservices-on-app-engine), +// [App Engine Standard request +// routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed), +// and [App Engine Flex request +// routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed). +message AppEngineRouting { + // App service. + // + // By default, the job is sent to the service which is the default + // service when the job is attempted. + string service = 1; + + // App version. + // + // By default, the job is sent to the version which is the default + // version when the job is attempted. + string version = 2; + + // App instance. + // + // By default, the job is sent to an instance which is available when + // the job is attempted. + // + // Requests can only be sent to a specific instance if + // [manual scaling is used in App Engine + // Standard](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine?#scaling_types_and_instance_classes). + // App Engine Flex does not support instances. For more information, see + // [App Engine Standard request + // routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed) + // and [App Engine Flex request + // routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed). + string instance = 3; + + // Output only. The host that the job is sent to. + // + // For more information about how App Engine requests are routed, see + // [here](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed). + // + // The host is constructed as: + // + // + // * `host = [application_domain_name]`
+ // `| [service] + '.' + [application_domain_name]`
+ // `| [version] + '.' + [application_domain_name]`
+ // `| [version_dot_service]+ '.' + [application_domain_name]`
+ // `| [instance] + '.' + [application_domain_name]`
+ // `| [instance_dot_service] + '.' + [application_domain_name]`
+ // `| [instance_dot_version] + '.' + [application_domain_name]`
+ // `| [instance_dot_version_dot_service] + '.' + [application_domain_name]` + // + // * `application_domain_name` = The domain name of the app, for + // example .appspot.com, which is associated with the + // job's project ID. + // + // * `service =` + // [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] + // + // * `version =` + // [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] + // + // * `version_dot_service =` + // [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] `+ '.' + // +` [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] + // + // * `instance =` + // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] + // + // * `instance_dot_service =` + // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] `+ + // '.' +` [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] + // + // * `instance_dot_version =` + // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] `+ + // '.' +` [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] + // + // * `instance_dot_version_dot_service =` + // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] `+ + // '.' +` [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] + // `+ '.' +` + // [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] + // + // + // If [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] is + // empty, then the job will be sent to the service which is the default + // service when the job is attempted. + // + // If [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] is + // empty, then the job will be sent to the version which is the default + // version when the job is attempted. + // + // If [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] is + // empty, then the job will be sent to an instance which is available when the + // job is attempted. + // + // If [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service], + // [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version], or + // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] is + // invalid, then the job will be sent to the default version of the default + // service when the job is attempted. + string host = 4; +} + +// The HTTP method used to execute the job. +enum HttpMethod { + // HTTP method unspecified. Defaults to POST. + HTTP_METHOD_UNSPECIFIED = 0; + + // HTTP POST + POST = 1; + + // HTTP GET + GET = 2; + + // HTTP HEAD + HEAD = 3; + + // HTTP PUT + PUT = 4; + + // HTTP DELETE + DELETE = 5; + + // HTTP PATCH + PATCH = 6; + + // HTTP OPTIONS + OPTIONS = 7; +} + +// Contains information needed for generating an +// [OAuth token](https://developers.google.com/identity/protocols/OAuth2). +// This type of authorization should generally only be used when calling Google +// APIs hosted on *.googleapis.com. +message OAuthToken { + // [Service account email](https://cloud.google.com/iam/docs/service-accounts) + // to be used for generating OAuth token. + // The service account must be within the same project as the job. The caller + // must have iam.serviceAccounts.actAs permission for the service account. + string service_account_email = 1; + + // OAuth scope to be used for generating OAuth access token. + // If not specified, "https://www.googleapis.com/auth/cloud-platform" + // will be used. + string scope = 2; +} + +// Contains information needed for generating an +// [OpenID Connect +// token](https://developers.google.com/identity/protocols/OpenIDConnect). +// This type of authorization can be used for many scenarios, including +// calling Cloud Run, or endpoints where you intend to validate the token +// yourself. +message OidcToken { + // [Service account email](https://cloud.google.com/iam/docs/service-accounts) + // to be used for generating OIDC token. + // The service account must be within the same project as the job. The caller + // must have iam.serviceAccounts.actAs permission for the service account. + string service_account_email = 1; + + // Audience to be used when generating OIDC token. If not specified, the URI + // specified in target will be used. + string audience = 2; +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.create_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.create_job.js new file mode 100644 index 00000000000..762d2f72efb --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.create_job.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, job) { + // [START cloudscheduler_v1beta1_generated_CloudScheduler_CreateJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + */ + // const parent = 'abc123' + /** + * Required. The job to add. The user can optionally specify a name for the + * job in name google.cloud.scheduler.v1beta1.Job.name. + * name google.cloud.scheduler.v1beta1.Job.name cannot be the same as an + * existing job. If a name is not specified then the system will + * generate a random unique name that will be returned + * (name google.cloud.scheduler.v1beta1.Job.name) in the response. + */ + // const job = {} + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callCreateJob() { + // Construct request + const request = { + parent, + job, + }; + + // Run request + const response = await schedulerClient.createJob(request); + console.log(response); + } + + callCreateJob(); + // [END cloudscheduler_v1beta1_generated_CloudScheduler_CreateJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.delete_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.delete_job.js new file mode 100644 index 00000000000..e7158b66478 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.delete_job.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 cloudscheduler_v1beta1_generated_CloudScheduler_DeleteJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + */ + // const name = 'abc123' + /** + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the job in the __cron + * queue with the corresponding name will be deleted instead. + */ + // const legacyAppEngineCron = true + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callDeleteJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await schedulerClient.deleteJob(request); + console.log(response); + } + + callDeleteJob(); + // [END cloudscheduler_v1beta1_generated_CloudScheduler_DeleteJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.get_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.get_job.js new file mode 100644 index 00000000000..4dd97392582 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.get_job.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 cloudscheduler_v1beta1_generated_CloudScheduler_GetJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + */ + // const name = 'abc123' + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callGetJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await schedulerClient.getJob(request); + console.log(response); + } + + callGetJob(); + // [END cloudscheduler_v1beta1_generated_CloudScheduler_GetJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.list_jobs.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.list_jobs.js new file mode 100644 index 00000000000..9a13ffc200a --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.list_jobs.js @@ -0,0 +1,101 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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 cloudscheduler_v1beta1_generated_CloudScheduler_ListJobs_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + */ + // const parent = 'abc123' + /** + * `filter` can be used to specify a subset of jobs. + * If `filter` equals `target_config="HttpConfig"`, then the http + * target jobs are retrieved. If `filter` equals + * `target_config="PubSubConfig"`, then the Pub/Sub target jobs are + * retrieved. If `filter` equals `labels.foo=value1 + * labels.foo=value2` then only jobs which are labeled with + * foo=value1 AND foo=value2 will be returned. + */ + // const filter = 'abc123' + /** + * Requested page size. + * The maximum page size is 500. If unspecified, the page size will + * be the maximum. Fewer jobs than requested might be returned, + * even if more jobs exist; use next_page_token to determine if more + * jobs exist. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results the server will return. To + * request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * next_page_token google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token + * returned from the previous call to + * ListJobs google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs. It is + * an error to switch the value of + * filter google.cloud.scheduler.v1beta1.ListJobsRequest.filter or + * order_by google.cloud.scheduler.v1beta1.ListJobsRequest.order_by while + * iterating through pages. + */ + // const pageToken = 'abc123' + /** + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the jobs in the __cron + * queue will be listed instead. + */ + // const legacyAppEngineCron = true + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callListJobs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await schedulerClient.listJobsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListJobs(); + // [END cloudscheduler_v1beta1_generated_CloudScheduler_ListJobs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.pause_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.pause_job.js new file mode 100644 index 00000000000..abf403eeb43 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.pause_job.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 cloudscheduler_v1beta1_generated_CloudScheduler_PauseJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + */ + // const name = 'abc123' + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callPauseJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await schedulerClient.pauseJob(request); + console.log(response); + } + + callPauseJob(); + // [END cloudscheduler_v1beta1_generated_CloudScheduler_PauseJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.resume_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.resume_job.js new file mode 100644 index 00000000000..efc9e23b1ec --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.resume_job.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 cloudscheduler_v1beta1_generated_CloudScheduler_ResumeJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + */ + // const name = 'abc123' + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callResumeJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await schedulerClient.resumeJob(request); + console.log(response); + } + + callResumeJob(); + // [END cloudscheduler_v1beta1_generated_CloudScheduler_ResumeJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.run_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.run_job.js new file mode 100644 index 00000000000..ae29c9451da --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.run_job.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 cloudscheduler_v1beta1_generated_CloudScheduler_RunJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + */ + // const name = 'abc123' + /** + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the job in the __cron + * queue with the corresponding name will be forced to run instead. + */ + // const legacyAppEngineCron = true + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callRunJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await schedulerClient.runJob(request); + console.log(response); + } + + callRunJob(); + // [END cloudscheduler_v1beta1_generated_CloudScheduler_RunJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.update_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.update_job.js new file mode 100644 index 00000000000..c00b440ac7a --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.update_job.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(job) { + // [START cloudscheduler_v1beta1_generated_CloudScheduler_UpdateJob_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The new job properties. + * name google.cloud.scheduler.v1beta1.Job.name must be specified. + * Output only fields cannot be modified using UpdateJob. + * Any value specified for an output only field will be ignored. + */ + // const job = {} + /** + * A mask used to specify which fields of the job are being updated. + */ + // const updateMask = {} + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callUpdateJob() { + // Construct request + const request = { + job, + }; + + // Run request + const response = await schedulerClient.updateJob(request); + console.log(response); + } + + callUpdateJob(); + // [END cloudscheduler_v1beta1_generated_CloudScheduler_UpdateJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.scheduler.v1beta1.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.scheduler.v1beta1.json new file mode 100644 index 00000000000..19c756a7cd0 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.scheduler.v1beta1.json @@ -0,0 +1,367 @@ +{ + "clientLibrary": { + "name": "nodejs-scheduler", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.scheduler.v1beta1", + "version": "v1beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_ListJobs_async", + "title": "scheduler listJobs Sample", + "origin": "API_DEFINITION", + "description": " Lists jobs.", + "canonical": true, + "file": "cloud_scheduler.list_jobs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 93, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListJobs", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "legacy_app_engine_cron", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.scheduler.v1beta1.ListJobsResponse", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" + }, + "method": { + "shortName": "ListJobs", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_GetJob_async", + "title": "scheduler getJob Sample", + "origin": "API_DEFINITION", + "description": " Gets a job.", + "canonical": true, + "file": "cloud_scheduler.get_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.GetJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.scheduler.v1beta1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" + }, + "method": { + "shortName": "GetJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.GetJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_CreateJob_async", + "title": "scheduler createJob Sample", + "origin": "API_DEFINITION", + "description": " Creates a job.", + "canonical": true, + "file": "cloud_scheduler.create_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "job", + "type": ".google.cloud.scheduler.v1beta1.Job" + } + ], + "resultType": ".google.cloud.scheduler.v1beta1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" + }, + "method": { + "shortName": "CreateJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_UpdateJob_async", + "title": "scheduler updateJob Sample", + "origin": "API_DEFINITION", + "description": " Updates a job. If successful, the updated [Job][google.cloud.scheduler.v1beta1.Job] is returned. If the job does not exist, `NOT_FOUND` is returned. If UpdateJob does not successfully return, it is possible for the job to be in an [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1beta1.Job.State.UPDATE_FAILED] state. A job in this state may not be executed. If this happens, retry the UpdateJob request until a successful response is received.", + "canonical": true, + "file": "cloud_scheduler.update_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob", + "async": true, + "parameters": [ + { + "name": "job", + "type": ".google.cloud.scheduler.v1beta1.Job" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.scheduler.v1beta1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" + }, + "method": { + "shortName": "UpdateJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_DeleteJob_async", + "title": "scheduler deleteJob Sample", + "origin": "API_DEFINITION", + "description": " Deletes a job.", + "canonical": true, + "file": "cloud_scheduler.delete_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.DeleteJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "legacy_app_engine_cron", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" + }, + "method": { + "shortName": "DeleteJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.DeleteJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_PauseJob_async", + "title": "scheduler pauseJob Sample", + "origin": "API_DEFINITION", + "description": " Pauses a job. If a job is paused then the system will stop executing the job until it is re-enabled via [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. The state of the job is stored in [state][google.cloud.scheduler.v1beta1.Job.state]; if paused it will be set to [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. A job must be in [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED] to be paused.", + "canonical": true, + "file": "cloud_scheduler.pause_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PauseJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.PauseJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.scheduler.v1beta1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" + }, + "method": { + "shortName": "PauseJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.PauseJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_ResumeJob_async", + "title": "scheduler resumeJob Sample", + "origin": "API_DEFINITION", + "description": " Resume a job. This method reenables a job after it has been [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. The state of a job is stored in [Job.state][google.cloud.scheduler.v1beta1.Job.state]; after calling this method it will be set to [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED]. A job must be in [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED] to be resumed.", + "canonical": true, + "file": "cloud_scheduler.resume_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ResumeJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.scheduler.v1beta1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" + }, + "method": { + "shortName": "ResumeJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_RunJob_async", + "title": "scheduler runJob Sample", + "origin": "API_DEFINITION", + "description": " Forces a job to run now. When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running.", + "canonical": true, + "file": "cloud_scheduler.run_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RunJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.RunJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "legacy_app_engine_cron", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.scheduler.v1beta1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" + }, + "method": { + "shortName": "RunJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.RunJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/index.ts new file mode 100644 index 00000000000..a6d6606681c --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1beta1 from './v1beta1'; +const CloudSchedulerClient = v1beta1.CloudSchedulerClient; +type CloudSchedulerClient = v1beta1.CloudSchedulerClient; +export {v1beta1, CloudSchedulerClient}; +export default {v1beta1, CloudSchedulerClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client.ts new file mode 100644 index 00000000000..5edbca778e4 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client.ts @@ -0,0 +1,1331 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, 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/v1beta1/cloud_scheduler_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './cloud_scheduler_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The Cloud Scheduler API allows external entities to reliably + * schedule asynchronous jobs. + * @class + * @memberof v1beta1 + */ +export class CloudSchedulerClient { + 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}; + cloudSchedulerStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CloudSchedulerClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 CloudSchedulerClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CloudSchedulerClient; + 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 { + 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 = { + jobPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listJobs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'jobs') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.scheduler.v1beta1.CloudScheduler', 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.cloudSchedulerStub) { + return this.cloudSchedulerStub; + } + + // Put together the "service stub" for + // google.cloud.scheduler.v1beta1.CloudScheduler. + this.cloudSchedulerStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.scheduler.v1beta1.CloudScheduler') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.scheduler.v1beta1.CloudScheduler, + 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 cloudSchedulerStubMethods = + ['listJobs', 'getJob', 'createJob', 'updateJob', 'deleteJob', 'pauseJob', 'resumeJob', 'runJob']; + for (const methodName of cloudSchedulerStubMethods) { + const callPromise = this.cloudSchedulerStub.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.cloudSchedulerStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudscheduler.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 'cloudscheduler.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 job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.scheduler.v1beta1.Job|Job}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_scheduler.get_job.js + * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_GetJob_async + */ + getJob( + request?: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IGetJobRequest|undefined, {}|undefined + ]>; + getJob( + request: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IGetJobRequest|null|undefined, + {}|null|undefined>): void; + getJob( + request: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IGetJobRequest|null|undefined, + {}|null|undefined>): void; + getJob( + request?: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IGetJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IGetJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IGetJobRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getJob(request, options, callback); + } +/** + * Creates a job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {google.cloud.scheduler.v1beta1.Job} request.job + * Required. The job to add. The user can optionally specify a name for the + * job in {@link protos.google.cloud.scheduler.v1beta1.Job.name|name}. + * {@link protos.google.cloud.scheduler.v1beta1.Job.name|name} cannot be the same as an + * existing job. If a name is not specified then the system will + * generate a random unique name that will be returned + * ({@link protos.google.cloud.scheduler.v1beta1.Job.name|name}) in the response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.scheduler.v1beta1.Job|Job}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_scheduler.create_job.js + * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_CreateJob_async + */ + createJob( + request?: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|undefined, {}|undefined + ]>; + createJob( + request: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|null|undefined, + {}|null|undefined>): void; + createJob( + request: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|null|undefined, + {}|null|undefined>): void; + createJob( + request?: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createJob(request, options, callback); + } +/** + * Updates a job. + * + * If successful, the updated {@link protos.google.cloud.scheduler.v1beta1.Job|Job} is + * returned. If the job does not exist, `NOT_FOUND` is returned. + * + * If UpdateJob does not successfully return, it is possible for the + * job to be in an + * {@link protos.google.cloud.scheduler.v1beta1.Job.State.UPDATE_FAILED|Job.State.UPDATE_FAILED} + * state. A job in this state may not be executed. If this happens, retry the + * UpdateJob request until a successful response is received. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.scheduler.v1beta1.Job} request.job + * Required. The new job properties. + * {@link protos.google.cloud.scheduler.v1beta1.Job.name|name} must be specified. + * + * Output only fields cannot be modified using UpdateJob. + * Any value specified for an output only field will be ignored. + * @param {google.protobuf.FieldMask} request.updateMask + * A mask used to specify which fields of the job are being 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 protos.google.cloud.scheduler.v1beta1.Job|Job}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_scheduler.update_job.js + * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_UpdateJob_async + */ + updateJob( + request?: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|undefined, {}|undefined + ]>; + updateJob( + request: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|null|undefined, + {}|null|undefined>): void; + updateJob( + request: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|null|undefined, + {}|null|undefined>): void; + updateJob( + request?: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'job.name': request.job!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateJob(request, options, callback); + } +/** + * Deletes a job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {boolean} request.legacyAppEngineCron + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the job in the __cron + * queue with the corresponding name will be deleted instead. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_scheduler.delete_job.js + * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_DeleteJob_async + */ + deleteJob( + request?: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|undefined, {}|undefined + ]>; + deleteJob( + request: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|null|undefined, + {}|null|undefined>): void; + deleteJob( + request: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|null|undefined, + {}|null|undefined>): void; + deleteJob( + request?: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteJob(request, options, callback); + } +/** + * Pauses a job. + * + * If a job is paused then the system will stop executing the job + * until it is re-enabled via + * {@link protos.google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob|ResumeJob}. The + * state of the job is stored in + * {@link protos.google.cloud.scheduler.v1beta1.Job.state|state}; if paused it will be set + * to {@link protos.google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED}. A + * job must be in + * {@link protos.google.cloud.scheduler.v1beta1.Job.State.ENABLED|Job.State.ENABLED} to be + * paused. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.scheduler.v1beta1.Job|Job}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_scheduler.pause_job.js + * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_PauseJob_async + */ + pauseJob( + request?: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|undefined, {}|undefined + ]>; + pauseJob( + request: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|null|undefined, + {}|null|undefined>): void; + pauseJob( + request: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|null|undefined, + {}|null|undefined>): void; + pauseJob( + request?: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.pauseJob(request, options, callback); + } +/** + * Resume a job. + * + * This method reenables a job after it has been + * {@link protos.google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED}. The + * state of a job is stored in + * {@link protos.google.cloud.scheduler.v1beta1.Job.state|Job.state}; after calling this + * method it will be set to + * {@link protos.google.cloud.scheduler.v1beta1.Job.State.ENABLED|Job.State.ENABLED}. A + * job must be in + * {@link protos.google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED} to be + * resumed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.scheduler.v1beta1.Job|Job}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_scheduler.resume_job.js + * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_ResumeJob_async + */ + resumeJob( + request?: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|undefined, {}|undefined + ]>; + resumeJob( + request: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|null|undefined, + {}|null|undefined>): void; + resumeJob( + request: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|null|undefined, + {}|null|undefined>): void; + resumeJob( + request?: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.resumeJob(request, options, callback); + } +/** + * Forces a job to run now. + * + * When this method is called, Cloud Scheduler will dispatch the job, even + * if the job is already running. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {boolean} request.legacyAppEngineCron + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the job in the __cron + * queue with the corresponding name will be forced to run instead. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.scheduler.v1beta1.Job|Job}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_scheduler.run_job.js + * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_RunJob_async + */ + runJob( + request?: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IRunJobRequest|undefined, {}|undefined + ]>; + runJob( + request: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IRunJobRequest|null|undefined, + {}|null|undefined>): void; + runJob( + request: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IRunJobRequest|null|undefined, + {}|null|undefined>): void; + runJob( + request?: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IRunJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IRunJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IRunJobRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.runJob(request, options, callback); + } + + /** + * Lists jobs. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {string} request.filter + * `filter` can be used to specify a subset of jobs. + * + * If `filter` equals `target_config="HttpConfig"`, then the http + * target jobs are retrieved. If `filter` equals + * `target_config="PubSubConfig"`, then the Pub/Sub target jobs are + * retrieved. If `filter` equals `labels.foo=value1 + * labels.foo=value2` then only jobs which are labeled with + * foo=value1 AND foo=value2 will be returned. + * @param {number} request.pageSize + * Requested page size. + * + * The maximum page size is 500. If unspecified, the page size will + * be the maximum. Fewer jobs than requested might be returned, + * even if more jobs exist; use next_page_token to determine if more + * jobs exist. + * @param {string} request.pageToken + * A token identifying a page of results the server will return. To + * request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is + * an error to switch the value of + * {@link protos.google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or + * {@link protos.google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while + * iterating through pages. + * @param {boolean} request.legacyAppEngineCron + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the jobs in the __cron + * queue will be listed instead. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.scheduler.v1beta1.Job|Job}. + * 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 `listJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listJobs( + request?: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob[], + protos.google.cloud.scheduler.v1beta1.IListJobsRequest|null, + protos.google.cloud.scheduler.v1beta1.IListJobsResponse + ]>; + listJobs( + request: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + protos.google.cloud.scheduler.v1beta1.IListJobsResponse|null|undefined, + protos.google.cloud.scheduler.v1beta1.IJob>): void; + listJobs( + request: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + callback: PaginationCallback< + protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + protos.google.cloud.scheduler.v1beta1.IListJobsResponse|null|undefined, + protos.google.cloud.scheduler.v1beta1.IJob>): void; + listJobs( + request?: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + protos.google.cloud.scheduler.v1beta1.IListJobsResponse|null|undefined, + protos.google.cloud.scheduler.v1beta1.IJob>, + callback?: PaginationCallback< + protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + protos.google.cloud.scheduler.v1beta1.IListJobsResponse|null|undefined, + protos.google.cloud.scheduler.v1beta1.IJob>): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob[], + protos.google.cloud.scheduler.v1beta1.IListJobsRequest|null, + protos.google.cloud.scheduler.v1beta1.IListJobsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listJobs(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {string} request.filter + * `filter` can be used to specify a subset of jobs. + * + * If `filter` equals `target_config="HttpConfig"`, then the http + * target jobs are retrieved. If `filter` equals + * `target_config="PubSubConfig"`, then the Pub/Sub target jobs are + * retrieved. If `filter` equals `labels.foo=value1 + * labels.foo=value2` then only jobs which are labeled with + * foo=value1 AND foo=value2 will be returned. + * @param {number} request.pageSize + * Requested page size. + * + * The maximum page size is 500. If unspecified, the page size will + * be the maximum. Fewer jobs than requested might be returned, + * even if more jobs exist; use next_page_token to determine if more + * jobs exist. + * @param {string} request.pageToken + * A token identifying a page of results the server will return. To + * request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is + * an error to switch the value of + * {@link protos.google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or + * {@link protos.google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while + * iterating through pages. + * @param {boolean} request.legacyAppEngineCron + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the jobs in the __cron + * queue will be listed instead. + * @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 protos.google.cloud.scheduler.v1beta1.Job|Job} 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 `listJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listJobsStream( + request?: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + 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['listJobs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listJobs.createStream( + this.innerApiCalls.listJobs as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listJobs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {string} request.filter + * `filter` can be used to specify a subset of jobs. + * + * If `filter` equals `target_config="HttpConfig"`, then the http + * target jobs are retrieved. If `filter` equals + * `target_config="PubSubConfig"`, then the Pub/Sub target jobs are + * retrieved. If `filter` equals `labels.foo=value1 + * labels.foo=value2` then only jobs which are labeled with + * foo=value1 AND foo=value2 will be returned. + * @param {number} request.pageSize + * Requested page size. + * + * The maximum page size is 500. If unspecified, the page size will + * be the maximum. Fewer jobs than requested might be returned, + * even if more jobs exist; use next_page_token to determine if more + * jobs exist. + * @param {string} request.pageToken + * A token identifying a page of results the server will return. To + * request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is + * an error to switch the value of + * {@link protos.google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or + * {@link protos.google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while + * iterating through pages. + * @param {boolean} request.legacyAppEngineCron + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the jobs in the __cron + * queue will be listed instead. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.scheduler.v1beta1.Job|Job}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/cloud_scheduler.list_jobs.js + * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_ListJobs_async + */ + listJobsAsync( + request?: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + 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['listJobs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listJobs.asyncIterate( + this.innerApiCalls['listJobs'] 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified job resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @returns {string} Resource name string. + */ + jobPath(project:string,location:string,job:string) { + return this.pathTemplates.jobPathTemplate.render({ + project: project, + location: location, + job: job, + }); + } + + /** + * Parse the project from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the project. + */ + matchProjectFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).project; + } + + /** + * Parse the location from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the location. + */ + matchLocationFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).location; + } + + /** + * Parse the job from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the job. + */ + matchJobFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).job; + } + + /** + * 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 project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.cloudSchedulerStub && !this._terminated) { + return this.cloudSchedulerStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client_config.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client_config.json new file mode 100644 index 00000000000..6ded8ffff11 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client_config.json @@ -0,0 +1,66 @@ +{ + "interfaces": { + "google.cloud.scheduler.v1beta1.CloudScheduler": { + "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": { + "ListJobs": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetJob": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateJob": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateJob": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteJob": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "PauseJob": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ResumeJob": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "RunJob": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_proto_list.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_proto_list.json new file mode 100644 index 00000000000..a911aaeb80f --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_proto_list.json @@ -0,0 +1,5 @@ +[ + "../../protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto", + "../../protos/google/cloud/scheduler/v1beta1/job.proto", + "../../protos/google/cloud/scheduler/v1beta1/target.proto" +] diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/gapic_metadata.json new file mode 100644 index 00000000000..c097889cd1f --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/gapic_metadata.json @@ -0,0 +1,107 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.scheduler.v1beta1", + "libraryPackage": "@google-cloud/scheduler", + "services": { + "CloudScheduler": { + "clients": { + "grpc": { + "libraryClient": "CloudSchedulerClient", + "rpcs": { + "GetJob": { + "methods": [ + "getJob" + ] + }, + "CreateJob": { + "methods": [ + "createJob" + ] + }, + "UpdateJob": { + "methods": [ + "updateJob" + ] + }, + "DeleteJob": { + "methods": [ + "deleteJob" + ] + }, + "PauseJob": { + "methods": [ + "pauseJob" + ] + }, + "ResumeJob": { + "methods": [ + "resumeJob" + ] + }, + "RunJob": { + "methods": [ + "runJob" + ] + }, + "ListJobs": { + "methods": [ + "listJobs", + "listJobsStream", + "listJobsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CloudSchedulerClient", + "rpcs": { + "GetJob": { + "methods": [ + "getJob" + ] + }, + "CreateJob": { + "methods": [ + "createJob" + ] + }, + "UpdateJob": { + "methods": [ + "updateJob" + ] + }, + "DeleteJob": { + "methods": [ + "deleteJob" + ] + }, + "PauseJob": { + "methods": [ + "pauseJob" + ] + }, + "ResumeJob": { + "methods": [ + "resumeJob" + ] + }, + "RunJob": { + "methods": [ + "runJob" + ] + }, + "ListJobs": { + "methods": [ + "listJobs", + "listJobsStream", + "listJobsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/index.ts new file mode 100644 index 00000000000..782589c88a7 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {CloudSchedulerClient} from './cloud_scheduler_client'; diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..26229572638 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const scheduler = require('@google-cloud/scheduler'); + +function main() { + const cloudSchedulerClient = new scheduler.CloudSchedulerClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..99f6bacd17a --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {CloudSchedulerClient} from '@google-cloud/scheduler'; + +// check that the client class type name can be used +function doStuffWithCloudSchedulerClient(client: CloudSchedulerClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const cloudSchedulerClient = new CloudSchedulerClient(); + doStuffWithCloudSchedulerClient(cloudSchedulerClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/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-scheduler/v1beta1/test/gapic_cloud_scheduler_v1beta1.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/test/gapic_cloud_scheduler_v1beta1.ts new file mode 100644 index 00000000000..634bfba4d18 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/test/gapic_cloud_scheduler_v1beta1.ts @@ -0,0 +1,1485 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 cloudschedulerModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, 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('v1beta1.CloudSchedulerClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = cloudschedulerModule.v1beta1.CloudSchedulerClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = cloudschedulerModule.v1beta1.CloudSchedulerClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = cloudschedulerModule.v1beta1.CloudSchedulerClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudSchedulerStub, undefined); + await client.initialize(); + assert(client.cloudSchedulerStub); + }); + + it('has close method for the initialized client', done => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.cloudSchedulerStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudSchedulerStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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('getJob', () => { + it('invokes getJob without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.getJob = stubSimpleCall(expectedResponse); + const [response] = await client.getJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getJob without error using callback', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.getJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getJob with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getJob(request), expectedError); + const actualRequest = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getJob with closed client', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getJob(request), expectedError); + }); + }); + + describe('createJob', () => { + it('invokes createJob without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.createJob = stubSimpleCall(expectedResponse); + const [response] = await client.createJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createJob without error using callback', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.createJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createJob with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createJob(request), expectedError); + const actualRequest = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createJob with closed client', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createJob(request), expectedError); + }); + }); + + describe('updateJob', () => { + it('invokes updateJob without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest() + ); + request.job ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.UpdateJobRequest', ['job', 'name']); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.updateJob = stubSimpleCall(expectedResponse); + const [response] = await client.updateJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateJob without error using callback', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest() + ); + request.job ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.UpdateJobRequest', ['job', 'name']); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.updateJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateJob with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest() + ); + request.job ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.UpdateJobRequest', ['job', 'name']); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateJob(request), expectedError); + const actualRequest = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateJob with closed client', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest() + ); + request.job ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.UpdateJobRequest', ['job', 'name']); + request.job.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateJob(request), expectedError); + }); + }); + + describe('deleteJob', () => { + it('invokes deleteJob without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteJob = stubSimpleCall(expectedResponse); + const [response] = await client.deleteJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteJob without error using callback', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteJob( + 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.deleteJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteJob with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteJob(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteJob with closed client', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteJob(request), expectedError); + }); + }); + + describe('pauseJob', () => { + it('invokes pauseJob without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.PauseJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.PauseJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.pauseJob = stubSimpleCall(expectedResponse); + const [response] = await client.pauseJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseJob without error using callback', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.PauseJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.PauseJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.pauseJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.pauseJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseJob with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.PauseJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.PauseJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.pauseJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.pauseJob(request), expectedError); + const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseJob with closed client', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.PauseJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.PauseJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.pauseJob(request), expectedError); + }); + }); + + describe('resumeJob', () => { + it('invokes resumeJob without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ResumeJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.resumeJob = stubSimpleCall(expectedResponse); + const [response] = await client.resumeJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeJob without error using callback', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ResumeJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.resumeJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resumeJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeJob with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ResumeJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resumeJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.resumeJob(request), expectedError); + const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeJob with closed client', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ResumeJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.resumeJob(request), expectedError); + }); + }); + + describe('runJob', () => { + it('invokes runJob without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.RunJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.RunJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.runJob = stubSimpleCall(expectedResponse); + const [response] = await client.runJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runJob without error using callback', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.RunJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.RunJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.runJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.runJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runJob with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.RunJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.RunJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.runJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.runJob(request), expectedError); + const actualRequest = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runJob with closed client', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.RunJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.RunJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.runJob(request), expectedError); + }); + }); + + describe('listJobs', () => { + it('invokes listJobs without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + ]; + client.innerApiCalls.listJobs = stubSimpleCall(expectedResponse); + const [response] = await client.listJobs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listJobs without error using callback', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + ]; + client.innerApiCalls.listJobs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listJobs( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listJobs with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listJobs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listJobs(request), expectedError); + const actualRequest = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listJobsStream without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + ]; + client.descriptors.page.listJobs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.scheduler.v1beta1.Job[] = []; + stream.on('data', (response: protos.google.cloud.scheduler.v1beta1.Job) => { + 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.listJobs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listJobsStream with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listJobs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.scheduler.v1beta1.Job[] = []; + stream.on('data', (response: protos.google.cloud.scheduler.v1beta1.Job) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listJobs without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + ]; + client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.scheduler.v1beta1.IJob[] = []; + const iterable = client.listJobsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listJobs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listJobs with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listJobsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.scheduler.v1beta1.IJob[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listJobs.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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('Path templates', () => { + + describe('job', () => { + const fakePath = "/rendered/path/job"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + }; + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.jobPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.jobPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('jobPath', () => { + const result = client.jobPath("projectValue", "locationValue", "jobValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.jobPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromJobName', () => { + const result = client.matchProjectFromJobName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromJobName', () => { + const result = client.matchLocationFromJobName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromJobName', () => { + const result = client.matchJobFromJobName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/webpack.config.js new file mode 100644 index 00000000000..d4565464f20 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'scheduler', + filename: './scheduler.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 1a17f60681972ab8e2a5a029798f2109f3d298d3 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Thu, 24 Aug 2023 21:18:23 +0000 Subject: [PATCH 2/3] =?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 --- .../v1/.eslintignore | 7 - .../v1/.eslintrc.json | 3 - .../v1/.gitignore | 14 - .../google-cloud-networksecurity/v1/.jsdoc.js | 55 - .../v1/.mocharc.js | 33 - .../v1/.prettierrc.js | 22 - .../google-cloud-networksecurity/v1/README.md | 1 - .../v1/package.json | 58 - .../v1/authorization_policy.proto | 249 - .../v1/client_tls_policy.proto | 160 - .../cloud/networksecurity/v1/common.proto | 55 - .../networksecurity/v1/network_security.proto | 201 - .../v1/server_tls_policy.proto | 181 - .../google/cloud/networksecurity/v1/tls.proto | 78 - ...rk_security.create_authorization_policy.js | 76 - ...twork_security.create_client_tls_policy.js | 75 - ...twork_security.create_server_tls_policy.js | 75 - ...rk_security.delete_authorization_policy.js | 63 - ...twork_security.delete_client_tls_policy.js | 63 - ...twork_security.delete_server_tls_policy.js | 63 - ...twork_security.get_authorization_policy.js | 62 - .../network_security.get_client_tls_policy.js | 62 - .../network_security.get_server_tls_policy.js | 62 - ...rk_security.list_authorization_policies.js | 76 - ...twork_security.list_client_tls_policies.js | 75 - ...twork_security.list_server_tls_policies.js | 75 - ...rk_security.update_authorization_policy.js | 70 - ...twork_security.update_client_tls_policy.js | 71 - ...twork_security.update_server_tls_policy.js | 71 - ...adata_google.cloud.networksecurity.v1.json | 675 -- .../v1/src/index.ts | 25 - .../v1/src/v1/gapic_metadata.json | 185 - .../v1/src/v1/index.ts | 19 - .../v1/src/v1/network_security_client.ts | 2592 ------- .../v1/network_security_client_config.json | 101 - .../src/v1/network_security_proto_list.json | 8 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1/system-test/install.ts | 49 - .../v1/test/gapic_network_security_v1.ts | 3508 --------- .../v1/tsconfig.json | 19 - .../v1/webpack.config.js | 64 - .../v1beta1/.eslintignore | 7 - .../v1beta1/.eslintrc.json | 3 - .../v1beta1/.gitignore | 14 - .../v1beta1/.jsdoc.js | 55 - .../v1beta1/.mocharc.js | 33 - .../v1beta1/.prettierrc.js | 22 - .../v1beta1/README.md | 1 - .../v1beta1/package.json | 58 - .../v1beta1/authorization_policy.proto | 259 - .../v1beta1/client_tls_policy.proto | 169 - .../networksecurity/v1beta1/common.proto | 58 - .../v1beta1/network_security.proto | 201 - .../v1beta1/server_tls_policy.proto | 187 - .../cloud/networksecurity/v1beta1/tls.proto | 78 - ...rk_security.create_authorization_policy.js | 76 - ...twork_security.create_client_tls_policy.js | 76 - ...twork_security.create_server_tls_policy.js | 76 - ...rk_security.delete_authorization_policy.js | 63 - ...twork_security.delete_client_tls_policy.js | 63 - ...twork_security.delete_server_tls_policy.js | 63 - ...twork_security.get_authorization_policy.js | 62 - .../network_security.get_client_tls_policy.js | 62 - .../network_security.get_server_tls_policy.js | 62 - ...rk_security.list_authorization_policies.js | 76 - ...twork_security.list_client_tls_policies.js | 75 - ...twork_security.list_server_tls_policies.js | 75 - ...rk_security.update_authorization_policy.js | 70 - ...twork_security.update_client_tls_policy.js | 71 - ...twork_security.update_server_tls_policy.js | 71 - ..._google.cloud.networksecurity.v1beta1.json | 675 -- .../v1beta1/src/index.ts | 25 - .../v1beta1/src/v1beta1/gapic_metadata.json | 185 - .../v1beta1/src/v1beta1/index.ts | 19 - .../src/v1beta1/network_security_client.ts | 2594 ------- .../network_security_client_config.json | 101 - .../v1beta1/network_security_proto_list.json | 8 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1beta1/system-test/install.ts | 49 - .../test/gapic_network_security_v1beta1.ts | 3508 --------- .../v1beta1/tsconfig.json | 19 - .../v1beta1/webpack.config.js | 64 - .../google-cloud-notebooks/v1/.eslintignore | 7 - .../google-cloud-notebooks/v1/.eslintrc.json | 3 - .../google-cloud-notebooks/v1/.gitignore | 14 - .../google-cloud-notebooks/v1/.jsdoc.js | 55 - .../google-cloud-notebooks/v1/.mocharc.js | 33 - .../google-cloud-notebooks/v1/.prettierrc.js | 22 - .../google-cloud-notebooks/v1/README.md | 1 - .../google-cloud-notebooks/v1/package.json | 59 - .../notebooks/v1/diagnostic_config.proto | 60 - .../cloud/notebooks/v1/environment.proto | 96 - .../google/cloud/notebooks/v1/event.proto | 61 - .../google/cloud/notebooks/v1/execution.proto | 350 - .../google/cloud/notebooks/v1/instance.proto | 541 -- .../cloud/notebooks/v1/instance_config.proto | 35 - .../cloud/notebooks/v1/managed_service.proto | 439 -- .../google/cloud/notebooks/v1/runtime.proto | 611 -- .../google/cloud/notebooks/v1/schedule.proto | 107 - .../google/cloud/notebooks/v1/service.proto | 1017 --- ...managed_notebook_service.create_runtime.js | 77 - ...managed_notebook_service.delete_runtime.js | 67 - ...naged_notebook_service.diagnose_runtime.js | 68 - .../managed_notebook_service.get_runtime.js | 62 - .../managed_notebook_service.list_runtimes.js | 73 - ..._service.refresh_runtime_token_internal.js | 68 - ...d_notebook_service.report_runtime_event.js | 74 - .../managed_notebook_service.reset_runtime.js | 67 - .../managed_notebook_service.start_runtime.js | 67 - .../managed_notebook_service.stop_runtime.js | 67 - ...managed_notebook_service.switch_runtime.js | 75 - ...managed_notebook_service.update_runtime.js | 90 - ...anaged_notebook_service.upgrade_runtime.js | 67 - .../v1/notebook_service.create_environment.js | 75 - .../v1/notebook_service.create_execution.js | 73 - .../v1/notebook_service.create_instance.js | 73 - .../v1/notebook_service.create_schedule.js | 73 - .../v1/notebook_service.delete_environment.js | 63 - .../v1/notebook_service.delete_execution.js | 63 - .../v1/notebook_service.delete_instance.js | 63 - .../v1/notebook_service.delete_schedule.js | 63 - .../v1/notebook_service.diagnose_instance.js | 68 - .../v1/notebook_service.get_environment.js | 62 - .../v1/notebook_service.get_execution.js | 62 - .../v1/notebook_service.get_instance.js | 62 - .../notebook_service.get_instance_health.js | 62 - .../v1/notebook_service.get_schedule.js | 62 - ...otebook_service.is_instance_upgradeable.js | 67 - .../v1/notebook_service.list_environments.js | 72 - .../v1/notebook_service.list_executions.js | 83 - .../v1/notebook_service.list_instances.js | 73 - .../v1/notebook_service.list_schedules.js | 81 - .../v1/notebook_service.register_instance.js | 71 - .../notebook_service.report_instance_info.js | 74 - .../v1/notebook_service.reset_instance.js | 63 - .../v1/notebook_service.rollback_instance.js | 69 - ...tebook_service.set_instance_accelerator.js | 76 - .../notebook_service.set_instance_labels.js | 68 - ...ebook_service.set_instance_machine_type.js | 69 - .../v1/notebook_service.start_instance.js | 63 - .../v1/notebook_service.stop_instance.js | 63 - .../v1/notebook_service.trigger_schedule.js | 63 - ...notebook_service.update_instance_config.js | 67 - ..._service.update_instance_metadata_items.js | 66 - ...service.update_shielded_instance_config.js | 67 - .../v1/notebook_service.upgrade_instance.js | 68 - ...ebook_service.upgrade_instance_internal.js | 74 - ...et_metadata_google.cloud.notebooks.v1.json | 2115 ------ .../google-cloud-notebooks/v1/src/index.ts | 27 - .../v1/src/v1/gapic_metadata.json | 527 -- .../google-cloud-notebooks/v1/src/v1/index.ts | 20 - .../src/v1/managed_notebook_service_client.ts | 2414 ------- ...anaged_notebook_service_client_config.json | 94 - .../managed_notebook_service_proto_list.json | 12 - .../v1/src/v1/notebook_service_client.ts | 4544 ------------ .../v1/notebook_service_client_config.json | 199 - .../src/v1/notebook_service_proto_list.json | 12 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - .../v1/system-test/install.ts | 49 - .../test/gapic_managed_notebook_service_v1.ts | 3200 -------- .../v1/test/gapic_notebook_service_v1.ts | 6405 ----------------- .../google-cloud-notebooks/v1/tsconfig.json | 19 - .../v1/webpack.config.js | 64 - .../v1beta1/.eslintignore | 7 - .../v1beta1/.eslintrc.json | 3 - .../google-cloud-notebooks/v1beta1/.gitignore | 14 - .../google-cloud-notebooks/v1beta1/.jsdoc.js | 55 - .../v1beta1/.mocharc.js | 33 - .../v1beta1/.prettierrc.js | 22 - .../google-cloud-notebooks/v1beta1/README.md | 1 - .../v1beta1/package.json | 58 - .../cloud/notebooks/v1beta1/environment.proto | 96 - .../cloud/notebooks/v1beta1/instance.proto | 333 - .../cloud/notebooks/v1beta1/service.proto | 524 -- .../notebook_service.create_environment.js | 75 - .../notebook_service.create_instance.js | 73 - .../notebook_service.delete_environment.js | 63 - .../notebook_service.delete_instance.js | 63 - .../notebook_service.get_environment.js | 62 - .../v1beta1/notebook_service.get_instance.js | 62 - ...otebook_service.is_instance_upgradeable.js | 62 - .../notebook_service.list_environments.js | 72 - .../notebook_service.list_instances.js | 73 - .../notebook_service.register_instance.js | 71 - .../notebook_service.report_instance_info.js | 74 - .../notebook_service.reset_instance.js | 63 - ...tebook_service.set_instance_accelerator.js | 76 - .../notebook_service.set_instance_labels.js | 68 - ...ebook_service.set_instance_machine_type.js | 69 - .../notebook_service.start_instance.js | 63 - .../v1beta1/notebook_service.stop_instance.js | 63 - .../notebook_service.upgrade_instance.js | 63 - ...ebook_service.upgrade_instance_internal.js | 69 - ...tadata_google.cloud.notebooks.v1beta1.json | 839 --- .../v1beta1/src/index.ts | 25 - .../v1beta1/src/v1beta1/gapic_metadata.json | 221 - .../v1beta1/src/v1beta1/index.ts | 19 - .../src/v1beta1/notebook_service_client.ts | 2818 -------- .../notebook_service_client_config.json | 121 - .../v1beta1/notebook_service_proto_list.json | 5 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1beta1/system-test/install.ts | 49 - .../test/gapic_notebook_service_v1beta1.ts | 3991 ---------- .../v1beta1/tsconfig.json | 19 - .../v1beta1/webpack.config.js | 64 - .../google-cloud-notebooks/v2/.eslintignore | 7 - .../google-cloud-notebooks/v2/.eslintrc.json | 3 - .../google-cloud-notebooks/v2/.gitignore | 14 - .../google-cloud-notebooks/v2/.jsdoc.js | 55 - .../google-cloud-notebooks/v2/.mocharc.js | 33 - .../google-cloud-notebooks/v2/.prettierrc.js | 22 - .../google-cloud-notebooks/v2/README.md | 1 - .../google-cloud-notebooks/v2/package.json | 58 - .../notebooks/v2/diagnostic_config.proto | 61 - .../google/cloud/notebooks/v2/event.proto | 70 - .../google/cloud/notebooks/v2/gce_setup.proto | 340 - .../google/cloud/notebooks/v2/instance.proto | 231 - .../google/cloud/notebooks/v2/service.proto | 413 -- ...ok_service.check_instance_upgradability.js | 62 - .../v2/notebook_service.create_instance.js | 77 - .../v2/notebook_service.delete_instance.js | 67 - .../v2/notebook_service.diagnose_instance.js | 72 - .../v2/notebook_service.get_instance.js | 62 - .../v2/notebook_service.list_instances.js | 82 - .../v2/notebook_service.reset_instance.js | 63 - .../v2/notebook_service.rollback_instance.js | 74 - .../v2/notebook_service.start_instance.js | 63 - .../v2/notebook_service.stop_instance.js | 63 - .../v2/notebook_service.update_instance.js | 71 - .../v2/notebook_service.upgrade_instance.js | 63 - ...et_metadata_google.cloud.notebooks.v2.json | 551 -- .../google-cloud-notebooks/v2/src/index.ts | 25 - .../v2/src/v2/gapic_metadata.json | 147 - .../google-cloud-notebooks/v2/src/v2/index.ts | 19 - .../v2/src/v2/notebook_service_client.ts | 2099 ------ .../v2/notebook_service_client_config.json | 89 - .../src/v2/notebook_service_proto_list.json | 7 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v2/system-test/install.ts | 49 - .../v2/test/gapic_notebook_service_v2.ts | 2878 -------- .../google-cloud-notebooks/v2/tsconfig.json | 19 - .../v2/webpack.config.js | 64 - .../v1/.eslintignore | 7 - .../v1/.eslintrc.json | 3 - .../google-cloud-optimization/v1/.gitignore | 14 - .../google-cloud-optimization/v1/.jsdoc.js | 55 - .../google-cloud-optimization/v1/.mocharc.js | 33 - .../v1/.prettierrc.js | 22 - .../google-cloud-optimization/v1/README.md | 1 - .../google-cloud-optimization/v1/package.json | 58 - .../cloud/optimization/v1/async_model.proto | 110 - .../cloud/optimization/v1/fleet_routing.proto | 2750 ------- .../v1/fleet_routing.batch_optimize_tours.js | 70 - .../v1/fleet_routing.optimize_tours.js | 254 - ...metadata_google.cloud.optimization.v1.json | 167 - .../google-cloud-optimization/v1/src/index.ts | 25 - .../v1/src/v1/fleet_routing_client.ts | 901 --- .../src/v1/fleet_routing_client_config.json | 48 - .../v1/src/v1/fleet_routing_proto_list.json | 4 - .../v1/src/v1/gapic_metadata.json | 43 - .../v1/src/v1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1/system-test/install.ts | 49 - .../v1/test/gapic_fleet_routing_v1.ts | 703 -- .../v1/tsconfig.json | 19 - .../v1/webpack.config.js | 64 - .../v1/.eslintignore | 7 - .../v1/.eslintrc.json | 3 - .../v1/.gitignore | 14 - .../v1/.jsdoc.js | 55 - .../v1/.mocharc.js | 33 - .../v1/.prettierrc.js | 22 - .../v1/README.md | 1 - .../v1/package.json | 59 - .../airflow/service/v1/environments.proto | 1392 ---- .../airflow/service/v1/image_versions.proto | 90 - .../airflow/service/v1/operations.proto | 97 - .../v1/environments.create_environment.js | 66 - .../v1/environments.database_failover.js | 62 - .../v1/environments.delete_environment.js | 62 - .../environments.execute_airflow_command.js | 76 - .../environments.fetch_database_properties.js | 62 - .../v1/environments.get_environment.js | 61 - .../v1/environments.list_environments.js | 71 - .../v1/environments.load_snapshot.js | 87 - .../v1/environments.poll_airflow_command.js | 77 - .../v1/environments.save_snapshot.js | 67 - .../v1/environments.stop_airflow_command.js | 78 - .../v1/environments.update_environment.js | 184 - .../v1/image_versions.list_image_versions.js | 75 - ...loud.orchestration.airflow.service.v1.json | 635 -- .../v1/src/index.ts | 27 - .../v1/src/v1/environments_client.ts | 1867 ----- .../v1/src/v1/environments_client_config.json | 74 - .../v1/src/v1/environments_proto_list.json | 5 - .../v1/src/v1/gapic_metadata.json | 175 - .../v1/src/v1/image_versions_client.ts | 556 -- .../src/v1/image_versions_client_config.json | 30 - .../v1/src/v1/image_versions_proto_list.json | 5 - .../v1/src/v1/index.ts | 20 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - .../v1/system-test/install.ts | 49 - .../v1/test/gapic_environments_v1.ts | 2226 ------ .../v1/test/gapic_image_versions_v1.ts | 491 -- .../v1/tsconfig.json | 19 - .../v1/webpack.config.js | 64 - .../v1beta1/.eslintignore | 7 - .../v1beta1/.eslintrc.json | 3 - .../v1beta1/.gitignore | 14 - .../v1beta1/.jsdoc.js | 55 - .../v1beta1/.mocharc.js | 33 - .../v1beta1/.prettierrc.js | 22 - .../v1beta1/README.md | 1 - .../v1beta1/package.json | 59 - .../service/v1beta1/environments.proto | 1530 ---- .../service/v1beta1/image_versions.proto | 90 - .../airflow/service/v1beta1/operations.proto | 93 - .../v1beta1/environments.check_upgrade.js | 86 - .../environments.create_environment.js | 66 - .../v1beta1/environments.database_failover.js | 62 - .../environments.delete_environment.js | 62 - .../environments.execute_airflow_command.js | 76 - .../environments.fetch_database_properties.js | 62 - .../v1beta1/environments.get_environment.js | 61 - .../v1beta1/environments.list_environments.js | 71 - .../v1beta1/environments.load_snapshot.js | 87 - .../environments.poll_airflow_command.js | 77 - .../environments.restart_web_server.js | 63 - .../v1beta1/environments.save_snapshot.js | 67 - .../environments.stop_airflow_command.js | 78 - .../environments.update_environment.js | 206 - .../image_versions.list_image_versions.js | 75 - ...orchestration.airflow.service.v1beta1.json | 719 -- .../v1beta1/src/index.ts | 27 - .../src/v1beta1/environments_client.ts | 2113 ------ .../v1beta1/environments_client_config.json | 82 - .../src/v1beta1/environments_proto_list.json | 5 - .../v1beta1/src/v1beta1/gapic_metadata.json | 195 - .../src/v1beta1/image_versions_client.ts | 556 -- .../v1beta1/image_versions_client_config.json | 30 - .../v1beta1/image_versions_proto_list.json | 5 - .../v1beta1/src/v1beta1/index.ts | 20 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - .../v1beta1/system-test/install.ts | 49 - .../test/gapic_environments_v1beta1.ts | 2534 ------- .../test/gapic_image_versions_v1beta1.ts | 491 -- .../v1beta1/tsconfig.json | 19 - .../v1beta1/webpack.config.js | 64 - .../google-cloud-orgpolicy/v2/.eslintignore | 7 - .../google-cloud-orgpolicy/v2/.eslintrc.json | 3 - .../google-cloud-orgpolicy/v2/.gitignore | 14 - .../google-cloud-orgpolicy/v2/.jsdoc.js | 55 - .../google-cloud-orgpolicy/v2/.mocharc.js | 33 - .../google-cloud-orgpolicy/v2/.prettierrc.js | 22 - .../google-cloud-orgpolicy/v2/README.md | 1 - .../google-cloud-orgpolicy/v2/package.json | 58 - .../cloud/orgpolicy/v2/constraint.proto | 126 - .../google/cloud/orgpolicy/v2/orgpolicy.proto | 478 -- .../generated/v2/org_policy.create_policy.js | 71 - .../generated/v2/org_policy.delete_policy.js | 62 - .../v2/org_policy.get_effective_policy.js | 61 - .../generated/v2/org_policy.get_policy.js | 62 - .../v2/org_policy.list_constraints.js | 79 - .../generated/v2/org_policy.list_policies.js | 80 - .../generated/v2/org_policy.update_policy.js | 67 - ...et_metadata_google.cloud.orgpolicy.v2.json | 319 - .../google-cloud-orgpolicy/v2/src/index.ts | 25 - .../v2/src/v2/gapic_metadata.json | 101 - .../google-cloud-orgpolicy/v2/src/v2/index.ts | 19 - .../v2/src/v2/org_policy_client.ts | 1385 ---- .../v2/src/v2/org_policy_client_config.json | 70 - .../v2/src/v2/org_policy_proto_list.json | 4 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v2/system-test/install.ts | 49 - .../v2/test/gapic_org_policy_v2.ts | 1492 ---- .../google-cloud-orgpolicy/v2/tsconfig.json | 19 - .../v2/webpack.config.js | 64 - .../google-cloud-osconfig/v1/.eslintignore | 7 - .../google-cloud-osconfig/v1/.eslintrc.json | 3 - .../google-cloud-osconfig/v1/.gitignore | 14 - .../google-cloud-osconfig/v1/.jsdoc.js | 55 - .../google-cloud-osconfig/v1/.mocharc.js | 33 - .../google-cloud-osconfig/v1/.prettierrc.js | 22 - .../google-cloud-osconfig/v1/README.md | 1 - .../google-cloud-osconfig/v1/package.json | 59 - .../google/cloud/osconfig/v1/inventory.proto | 384 - .../google/cloud/osconfig/v1/os_policy.proto | 548 -- .../v1/os_policy_assignment_reports.proto | 296 - .../osconfig/v1/os_policy_assignments.proto | 386 - .../cloud/osconfig/v1/osconfig_common.proto | 38 - .../cloud/osconfig/v1/osconfig_service.proto | 158 - .../osconfig/v1/osconfig_zonal_service.proto | 202 - .../cloud/osconfig/v1/patch_deployments.proto | 339 - .../google/cloud/osconfig/v1/patch_jobs.proto | 742 -- .../cloud/osconfig/v1/vulnerability.proto | 365 - .../v1/os_config_service.cancel_patch_job.js | 61 - ..._config_service.create_patch_deployment.js | 78 - ..._config_service.delete_patch_deployment.js | 62 - .../v1/os_config_service.execute_patch_job.js | 95 - .../os_config_service.get_patch_deployment.js | 62 - .../v1/os_config_service.get_patch_job.js | 61 - ...s_config_service.list_patch_deployments.js | 74 - ...service.list_patch_job_instance_details.js | 79 - .../v1/os_config_service.list_patch_jobs.js | 78 - ...s_config_service.pause_patch_deployment.js | 62 - ..._config_service.resume_patch_deployment.js | 62 - ..._config_service.update_patch_deployment.js | 66 - ...al_service.create_o_s_policy_assignment.js | 79 - ...al_service.delete_o_s_policy_assignment.js | 62 - .../os_config_zonal_service.get_inventory.js | 71 - ...zonal_service.get_o_s_policy_assignment.js | 63 - ...ervice.get_o_s_policy_assignment_report.js | 67 - ..._zonal_service.get_vulnerability_report.js | 66 - ...s_config_zonal_service.list_inventories.js | 85 - ...vice.list_o_s_policy_assignment_reports.js | 95 - ...ce.list_o_s_policy_assignment_revisions.js | 73 - ...nal_service.list_o_s_policy_assignments.js | 73 - ...onal_service.list_vulnerability_reports.js | 80 - ...al_service.update_o_s_policy_assignment.js | 67 - ...pet_metadata_google.cloud.osconfig.v1.json | 1119 --- .../google-cloud-osconfig/v1/src/index.ts | 27 - .../v1/src/v1/gapic_metadata.json | 309 - .../google-cloud-osconfig/v1/src/v1/index.ts | 20 - .../v1/src/v1/os_config_service_client.ts | 1854 ----- .../v1/os_config_service_client_config.json | 98 - .../src/v1/os_config_service_proto_list.json | 12 - .../src/v1/os_config_zonal_service_client.ts | 2306 ------ ...os_config_zonal_service_client_config.json | 98 - .../os_config_zonal_service_proto_list.json | 12 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - .../v1/system-test/install.ts | 49 - .../v1/test/gapic_os_config_service_v1.ts | 2179 ------ .../test/gapic_os_config_zonal_service_v1.ts | 2607 ------- .../google-cloud-osconfig/v1/tsconfig.json | 19 - .../v1/webpack.config.js | 64 - .../v1alpha/.eslintignore | 7 - .../v1alpha/.eslintrc.json | 3 - .../google-cloud-osconfig/v1alpha/.gitignore | 14 - .../google-cloud-osconfig/v1alpha/.jsdoc.js | 55 - .../google-cloud-osconfig/v1alpha/.mocharc.js | 33 - .../v1alpha/.prettierrc.js | 22 - .../google-cloud-osconfig/v1alpha/README.md | 1 - .../v1alpha/package.json | 58 - .../osconfig/v1alpha/config_common.proto | 133 - .../instance_os_policies_compliance.proto | 182 - .../cloud/osconfig/v1alpha/inventory.proto | 383 - .../cloud/osconfig/v1alpha/os_policy.proto | 565 -- .../os_policy_assignment_reports.proto | 296 - .../v1alpha/os_policy_assignments.proto | 383 - .../osconfig/v1alpha/osconfig_common.proto | 40 - .../v1alpha/osconfig_zonal_service.proto | 215 - .../osconfig/v1alpha/vulnerability.proto | 365 - ...al_service.create_o_s_policy_assignment.js | 79 - ...al_service.delete_o_s_policy_assignment.js | 62 - ...ce.get_instance_o_s_policies_compliance.js | 67 - .../os_config_zonal_service.get_inventory.js | 71 - ...zonal_service.get_o_s_policy_assignment.js | 63 - ...ervice.get_o_s_policy_assignment_report.js | 67 - ..._zonal_service.get_vulnerability_report.js | 66 - ....list_instance_o_s_policies_compliances.js | 81 - ...s_config_zonal_service.list_inventories.js | 85 - ...vice.list_o_s_policy_assignment_reports.js | 95 - ...ce.list_o_s_policy_assignment_revisions.js | 73 - ...nal_service.list_o_s_policy_assignments.js | 73 - ...onal_service.list_vulnerability_reports.js | 80 - ...al_service.update_o_s_policy_assignment.js | 66 - ...etadata_google.cloud.osconfig.v1alpha.json | 659 -- .../v1alpha/src/index.ts | 25 - .../v1alpha/src/v1alpha/gapic_metadata.json | 187 - .../v1alpha/src/v1alpha/index.ts | 19 - .../v1alpha/os_config_zonal_service_client.ts | 2569 ------- ...os_config_zonal_service_client_config.json | 108 - .../os_config_zonal_service_proto_list.json | 11 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1alpha/system-test/install.ts | 49 - .../gapic_os_config_zonal_service_v1alpha.ts | 2952 -------- .../v1alpha/tsconfig.json | 19 - .../v1alpha/webpack.config.js | 64 - .../v1beta/.eslintignore | 7 - .../v1beta/.eslintrc.json | 3 - .../google-cloud-osconfig/v1beta/.gitignore | 14 - .../google-cloud-osconfig/v1beta/.jsdoc.js | 55 - .../google-cloud-osconfig/v1beta/.mocharc.js | 33 - .../v1beta/.prettierrc.js | 22 - .../google-cloud-osconfig/v1beta/README.md | 1 - .../google-cloud-osconfig/v1beta/package.json | 58 - .../osconfig/v1beta/guest_policies.proto | 772 -- .../osconfig/v1beta/osconfig_common.proto | 36 - .../osconfig/v1beta/osconfig_service.proto | 186 - .../osconfig/v1beta/patch_deployments.proto | 295 - .../cloud/osconfig/v1beta/patch_jobs.proto | 702 -- .../os_config_service.cancel_patch_job.js | 61 - .../os_config_service.create_guest_policy.js | 78 - ..._config_service.create_patch_deployment.js | 77 - .../os_config_service.delete_guest_policy.js | 62 - ..._config_service.delete_patch_deployment.js | 62 - .../os_config_service.execute_patch_job.js | 95 - .../os_config_service.get_guest_policy.js | 62 - .../os_config_service.get_patch_deployment.js | 62 - .../v1beta/os_config_service.get_patch_job.js | 61 - .../os_config_service.list_guest_policies.js | 73 - ...s_config_service.list_patch_deployments.js | 72 - ...service.list_patch_job_instance_details.js | 78 - .../os_config_service.list_patch_jobs.js | 78 - ...g_service.lookup_effective_guest_policy.js | 79 - ...s_config_service.pause_patch_deployment.js | 62 - ..._config_service.resume_patch_deployment.js | 62 - .../os_config_service.update_guest_policy.js | 66 - ..._config_service.update_patch_deployment.js | 66 - ...metadata_google.cloud.osconfig.v1beta.json | 839 --- .../google-cloud-osconfig/v1beta/src/index.ts | 25 - .../v1beta/src/v1beta/gapic_metadata.json | 219 - .../v1beta/src/v1beta/index.ts | 19 - .../src/v1beta/os_config_service_client.ts | 2220 ------ .../os_config_service_client_config.json | 128 - .../v1beta/os_config_service_proto_list.json | 7 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1beta/system-test/install.ts | 49 - .../test/gapic_os_config_service_v1beta.ts | 2814 -------- .../v1beta/tsconfig.json | 19 - .../v1beta/webpack.config.js | 64 - .../google-cloud-oslogin/v1/.eslintignore | 7 - .../google-cloud-oslogin/v1/.eslintrc.json | 3 - .../google-cloud-oslogin/v1/.gitignore | 14 - .../google-cloud-oslogin/v1/.jsdoc.js | 55 - .../google-cloud-oslogin/v1/.mocharc.js | 33 - .../google-cloud-oslogin/v1/.prettierrc.js | 22 - .../google-cloud-oslogin/v1/README.md | 1 - .../google-cloud-oslogin/v1/package.json | 58 - .../google/cloud/oslogin/common/common.proto | 108 - .../google/cloud/oslogin/v1/oslogin.proto | 248 - .../os_login_service.create_ssh_public_key.js | 66 - .../os_login_service.delete_posix_account.js | 63 - .../os_login_service.delete_ssh_public_key.js | 63 - .../v1/os_login_service.get_login_profile.js | 69 - .../v1/os_login_service.get_ssh_public_key.js | 63 - .../os_login_service.import_ssh_public_key.js | 69 - .../os_login_service.update_ssh_public_key.js | 72 - ...ppet_metadata_google.cloud.oslogin.v1.json | 323 - .../google-cloud-oslogin/v1/src/index.ts | 25 - .../v1/src/v1/gapic_metadata.json | 93 - .../google-cloud-oslogin/v1/src/v1/index.ts | 19 - .../v1/src/v1/os_login_service_client.ts | 942 --- .../v1/os_login_service_client_config.json | 60 - .../src/v1/os_login_service_proto_list.json | 4 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1/system-test/install.ts | 49 - .../v1/test/gapic_os_login_service_v1.ts | 1015 --- .../google-cloud-oslogin/v1/tsconfig.json | 19 - .../google-cloud-oslogin/v1/webpack.config.js | 64 - .../google-cloud-oslogin/v1beta/.eslintignore | 7 - .../v1beta/.eslintrc.json | 3 - .../google-cloud-oslogin/v1beta/.gitignore | 14 - .../google-cloud-oslogin/v1beta/.jsdoc.js | 55 - .../google-cloud-oslogin/v1beta/.mocharc.js | 33 - .../v1beta/.prettierrc.js | 22 - .../google-cloud-oslogin/v1beta/README.md | 1 - .../google-cloud-oslogin/v1beta/package.json | 58 - .../google/cloud/oslogin/common/common.proto | 108 - .../google/cloud/oslogin/v1beta/oslogin.proto | 321 - .../os_login_service.create_ssh_public_key.js | 66 - .../os_login_service.delete_posix_account.js | 63 - .../os_login_service.delete_ssh_public_key.js | 63 - .../os_login_service.get_login_profile.js | 73 - .../os_login_service.get_ssh_public_key.js | 63 - .../os_login_service.import_ssh_public_key.js | 73 - .../os_login_service.sign_ssh_public_key.js | 67 - .../os_login_service.update_ssh_public_key.js | 72 - ..._metadata_google.cloud.oslogin.v1beta.json | 375 - .../google-cloud-oslogin/v1beta/src/index.ts | 25 - .../v1beta/src/v1beta/gapic_metadata.json | 103 - .../v1beta/src/v1beta/index.ts | 19 - .../src/v1beta/os_login_service_client.ts | 1021 --- .../os_login_service_client_config.json | 64 - .../v1beta/os_login_service_proto_list.json | 4 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1beta/system-test/install.ts | 49 - .../test/gapic_os_login_service_v1beta.ts | 1123 --- .../google-cloud-oslogin/v1beta/tsconfig.json | 19 - .../v1beta/webpack.config.js | 64 - .../v1beta1/.eslintignore | 7 - .../v1beta1/.eslintrc.json | 3 - .../v1beta1/.gitignore | 14 - .../v1beta1/.jsdoc.js | 55 - .../v1beta1/.mocharc.js | 33 - .../v1beta1/.prettierrc.js | 22 - .../v1beta1/README.md | 1 - .../v1beta1/package.json | 58 - .../v1beta1/phishingprotection.proto | 73 - ...ection_service_v1_beta1.report_phishing.js | 67 - ...ogle.cloud.phishingprotection.v1beta1.json | 59 - .../v1beta1/src/index.ts | 25 - .../v1beta1/src/v1beta1/gapic_metadata.json | 33 - .../v1beta1/src/v1beta1/index.ts | 19 - ...hing_protection_service_v1_beta1_client.ts | 421 -- ...ection_service_v1_beta1_client_config.json | 31 - ...rotection_service_v1_beta1_proto_list.json | 3 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1beta1/system-test/install.ts | 49 - ...ing_protection_service_v1_beta1_v1beta1.ts | 291 - .../v1beta1/tsconfig.json | 19 - .../v1beta1/webpack.config.js | 64 - .../v3/.eslintignore | 7 - .../v3/.eslintrc.json | 3 - .../v3/.gitignore | 14 - .../v3/.jsdoc.js | 55 - .../v3/.mocharc.js | 33 - .../v3/.prettierrc.js | 22 - .../v3/README.md | 1 - .../v3/package.json | 59 - .../iam/v3/troubleshooter.proto | 757 -- ..._troubleshooter.troubleshoot_iam_policy.js | 61 - ...gle.cloud.policytroubleshooter.iam.v3.json | 55 - .../v3/src/index.ts | 25 - .../v3/src/v3/gapic_metadata.json | 33 - .../v3/src/v3/index.ts | 19 - .../v3/src/v3/policy_troubleshooter_client.ts | 376 - .../policy_troubleshooter_client_config.json | 43 - .../v3/policy_troubleshooter_proto_list.json | 4 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v3/system-test/install.ts | 49 - .../v3/test/gapic_policy_troubleshooter_v3.ts | 225 - .../v3/tsconfig.json | 19 - .../v3/webpack.config.js | 64 - .../v3beta/.eslintignore | 7 - .../v3beta/.eslintrc.json | 3 - .../v3beta/.gitignore | 14 - .../v3beta/.jsdoc.js | 55 - .../v3beta/.mocharc.js | 33 - .../v3beta/.prettierrc.js | 22 - .../v3beta/README.md | 1 - .../v3beta/package.json | 59 - .../iam/v3beta/troubleshooter.proto | 754 -- .../v3beta/protos/google/iam/v1/policy.proto | 410 -- .../v3beta/protos/google/iam/v2/deny.proto | 109 - .../v3beta/protos/google/iam/v2/policy.proto | 287 - .../v3beta/protos/google/rpc/status.proto | 49 - .../v3beta/protos/google/type/expr.proto | 73 - ..._troubleshooter.troubleshoot_iam_policy.js | 61 - ...cloud.policytroubleshooter.iam.v3beta.json | 55 - .../v3beta/src/index.ts | 25 - .../v3beta/src/v3beta/gapic_metadata.json | 33 - .../v3beta/src/v3beta/index.ts | 19 - .../v3beta/policy_troubleshooter_client.ts | 376 - .../policy_troubleshooter_client_config.json | 43 - .../policy_troubleshooter_proto_list.json | 4 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v3beta/system-test/install.ts | 49 - .../gapic_policy_troubleshooter_v3beta.ts | 225 - .../v3beta/tsconfig.json | 19 - .../v3beta/webpack.config.js | 64 - .../v1/.eslintignore | 7 - .../v1/.eslintrc.json | 3 - .../v1/.gitignore | 14 - .../v1/.jsdoc.js | 55 - .../v1/.mocharc.js | 33 - .../v1/.prettierrc.js | 22 - .../v1/README.md | 1 - .../v1/package.json | 58 - .../policytroubleshooter/v1/checker.proto | 83 - .../v1/explanations.proto | 247 - .../v1/iam_checker.troubleshoot_iam_policy.js | 61 - ..._google.cloud.policytroubleshooter.v1.json | 55 - .../v1/src/index.ts | 25 - .../v1/src/v1/gapic_metadata.json | 33 - .../v1/src/v1/iam_checker_client.ts | 376 - .../v1/src/v1/iam_checker_client_config.json | 31 - .../v1/src/v1/iam_checker_proto_list.json | 4 - .../v1/src/v1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1/system-test/install.ts | 49 - .../v1/test/gapic_iam_checker_v1.ts | 225 - .../v1/tsconfig.json | 19 - .../v1/webpack.config.js | 64 - .../v1beta1/.eslintignore | 7 - .../v1beta1/.eslintrc.json | 3 - .../v1beta1/.gitignore | 14 - .../v1beta1/.jsdoc.js | 55 - .../v1beta1/.mocharc.js | 33 - .../v1beta1/.prettierrc.js | 22 - .../v1beta1/README.md | 1 - .../v1beta1/package.json | 58 - .../v1beta1/private_catalog.proto | 556 -- .../private_catalog.search_catalogs.js | 80 - .../private_catalog.search_products.js | 82 - .../private_catalog.search_versions.js | 83 - ...a_google.cloud.privatecatalog.v1beta1.json | 171 - .../v1beta1/src/index.ts | 25 - .../v1beta1/src/v1beta1/gapic_metadata.json | 65 - .../v1beta1/src/v1beta1/index.ts | 19 - .../src/v1beta1/private_catalog_client.ts | 1053 --- .../private_catalog_client_config.json | 38 - .../v1beta1/private_catalog_proto_list.json | 3 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1beta1/system-test/install.ts | 49 - .../test/gapic_private_catalog_v1beta1.ts | 1041 --- .../v1beta1/tsconfig.json | 19 - .../v1beta1/webpack.config.js | 64 - .../v1/.eslintignore | 7 - .../v1/.eslintrc.json | 3 - .../v1/.gitignore | 14 - .../v1/.jsdoc.js | 55 - .../v1/.mocharc.js | 33 - .../v1/.prettierrc.js | 22 - .../v1/README.md | 1 - .../v1/package.json | 58 - .../v1/api_entities.proto | 171 - .../v1/rapidmigrationassessment.proto | 421 -- ..._migration_assessment.create_annotation.js | 71 - ...d_migration_assessment.create_collector.js | 76 - ...d_migration_assessment.delete_collector.js | 76 - ...pid_migration_assessment.get_annotation.js | 61 - ...apid_migration_assessment.get_collector.js | 61 - ...id_migration_assessment.list_collectors.js | 80 - ...id_migration_assessment.pause_collector.js | 76 - ...migration_assessment.register_collector.js | 76 - ...d_migration_assessment.resume_collector.js | 76 - ...d_migration_assessment.update_collector.js | 85 - ...gle.cloud.rapidmigrationassessment.v1.json | 475 -- .../v1/src/index.ts | 25 - .../v1/src/v1/gapic_metadata.json | 127 - .../v1/src/v1/index.ts | 19 - .../v1/rapid_migration_assessment_client.ts | 1839 ----- ...id_migration_assessment_client_config.json | 85 - ...rapid_migration_assessment_proto_list.json | 4 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1/system-test/install.ts | 49 - .../gapic_rapid_migration_assessment_v1.ts | 2310 ------ .../v1/tsconfig.json | 19 - .../v1/webpack.config.js | 64 - .../v1/.eslintignore | 7 - .../v1/.eslintrc.json | 3 - .../v1/.gitignore | 14 - .../v1/.jsdoc.js | 55 - .../v1/.mocharc.js | 33 - .../v1/.prettierrc.js | 22 - .../v1/README.md | 1 - .../v1/package.json | 58 - .../v1/recaptchaenterprise.proto | 1427 ---- ..._enterprise_service.annotate_assessment.js | 86 - ...ha_enterprise_service.create_assessment.js | 67 - ...recaptcha_enterprise_service.create_key.js | 67 - ...recaptcha_enterprise_service.delete_key.js | 62 - .../recaptcha_enterprise_service.get_key.js | 62 - ...ecaptcha_enterprise_service.get_metrics.js | 62 - .../recaptcha_enterprise_service.list_keys.js | 74 - ....list_related_account_group_memberships.js | 78 - ...ise_service.list_related_account_groups.js | 78 - ...ecaptcha_enterprise_service.migrate_key.js | 73 - ...rise_service.retrieve_legacy_secret_key.js | 62 - ...earch_related_account_group_memberships.js | 86 - ...recaptcha_enterprise_service.update_key.js | 66 - ...a_google.cloud.recaptchaenterprise.v1.json | 603 -- .../v1/src/index.ts | 25 - .../v1/src/v1/gapic_metadata.json | 169 - .../v1/src/v1/index.ts | 19 - .../v1/recaptcha_enterprise_service_client.ts | 2023 ------ ...tcha_enterprise_service_client_config.json | 85 - ...captcha_enterprise_service_proto_list.json | 3 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1/system-test/install.ts | 49 - .../gapic_recaptcha_enterprise_service_v1.ts | 2384 ------ .../v1/tsconfig.json | 19 - .../v1/webpack.config.js | 64 - .../v1beta1/.eslintignore | 7 - .../v1beta1/.eslintrc.json | 3 - .../v1beta1/.gitignore | 14 - .../v1beta1/.jsdoc.js | 55 - .../v1beta1/.mocharc.js | 33 - .../v1beta1/.prettierrc.js | 22 - .../v1beta1/README.md | 1 - .../v1beta1/package.json | 58 - .../v1beta1/recaptchaenterprise.proto | 682 -- ...se_service_v1_beta1.annotate_assessment.js | 86 - ...rise_service_v1_beta1.create_assessment.js | 67 - ...gle.cloud.recaptchaenterprise.v1beta1.json | 115 - .../v1beta1/src/index.ts | 25 - .../v1beta1/src/v1beta1/gapic_metadata.json | 43 - .../v1beta1/src/v1beta1/index.ts | 19 - ...tcha_enterprise_service_v1_beta1_client.ts | 542 -- ...rprise_service_v1_beta1_client_config.json | 36 - ...nterprise_service_v1_beta1_proto_list.json | 3 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1beta1/system-test/install.ts | 49 - ...cha_enterprise_service_v1_beta1_v1beta1.ts | 437 -- .../v1beta1/tsconfig.json | 19 - .../v1beta1/webpack.config.js | 64 - .../google-cloud-recommender/v1/.eslintignore | 7 - .../v1/.eslintrc.json | 3 - .../google-cloud-recommender/v1/.gitignore | 14 - .../google-cloud-recommender/v1/.jsdoc.js | 55 - .../google-cloud-recommender/v1/.mocharc.js | 33 - .../v1/.prettierrc.js | 22 - .../google-cloud-recommender/v1/README.md | 1 - .../google-cloud-recommender/v1/package.json | 58 - .../google/cloud/recommender/v1/insight.proto | 162 - .../recommender/v1/insight_type_config.proto | 85 - .../cloud/recommender/v1/recommendation.proto | 343 - .../recommender/v1/recommender_config.proto | 85 - .../recommender/v1/recommender_service.proto | 604 -- .../generated/v1/recommender.get_insight.js | 61 - .../v1/recommender.get_insight_type_config.js | 65 - .../v1/recommender.get_recommendation.js | 61 - .../v1/recommender.get_recommender_config.js | 65 - .../generated/v1/recommender.list_insights.js | 101 - .../v1/recommender.list_recommendations.js | 101 - .../v1/recommender.mark_insight_accepted.js | 71 - ...recommender.mark_recommendation_claimed.js | 73 - .../recommender.mark_recommendation_failed.js | 73 - ...commender.mark_recommendation_succeeded.js | 73 - .../recommender.update_insight_type_config.js | 70 - .../recommender.update_recommender_config.js | 70 - ..._metadata_google.cloud.recommender.v1.json | 567 -- .../google-cloud-recommender/v1/src/index.ts | 25 - .../v1/src/v1/gapic_metadata.json | 151 - .../v1/src/v1/index.ts | 19 - .../v1/src/v1/recommender_client.ts | 2866 -------- .../v1/src/v1/recommender_client_config.json | 82 - .../v1/src/v1/recommender_proto_list.json | 7 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1/system-test/install.ts | 49 - .../v1/test/gapic_recommender_v1.ts | 2762 ------- .../google-cloud-recommender/v1/tsconfig.json | 19 - .../v1/webpack.config.js | 64 - .../v1beta1/.eslintignore | 7 - .../v1beta1/.eslintrc.json | 3 - .../v1beta1/.gitignore | 14 - .../v1beta1/.jsdoc.js | 55 - .../v1beta1/.mocharc.js | 33 - .../v1beta1/.prettierrc.js | 22 - .../v1beta1/README.md | 1 - .../v1beta1/package.json | 58 - .../cloud/recommender/v1beta1/insight.proto | 161 - .../v1beta1/insight_type_config.proto | 85 - .../recommender/v1beta1/recommendation.proto | 361 - .../v1beta1/recommender_config.proto | 85 - .../v1beta1/recommender_service.proto | 591 -- .../v1beta1/recommender.get_insight.js | 61 - .../recommender.get_insight_type_config.js | 65 - .../v1beta1/recommender.get_recommendation.js | 61 - .../recommender.get_recommender_config.js | 65 - .../v1beta1/recommender.list_insights.js | 101 - .../recommender.list_recommendations.js | 101 - .../recommender.mark_insight_accepted.js | 71 - ...recommender.mark_recommendation_claimed.js | 73 - .../recommender.mark_recommendation_failed.js | 73 - ...commender.mark_recommendation_succeeded.js | 73 - .../recommender.update_insight_type_config.js | 70 - .../recommender.update_recommender_config.js | 70 - ...data_google.cloud.recommender.v1beta1.json | 567 -- .../v1beta1/src/index.ts | 25 - .../v1beta1/src/v1beta1/gapic_metadata.json | 151 - .../v1beta1/src/v1beta1/index.ts | 19 - .../v1beta1/src/v1beta1/recommender_client.ts | 2866 -------- .../v1beta1/recommender_client_config.json | 82 - .../src/v1beta1/recommender_proto_list.json | 7 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1beta1/system-test/install.ts | 49 - .../v1beta1/test/gapic_recommender_v1beta1.ts | 2762 ------- .../v1beta1/tsconfig.json | 19 - .../v1beta1/webpack.config.js | 64 - .../google-cloud-redis/v1/.eslintignore | 7 - .../google-cloud-redis/v1/.eslintrc.json | 3 - .../google-cloud-redis/v1/.gitignore | 14 - .../google-cloud-redis/v1/.jsdoc.js | 55 - .../google-cloud-redis/v1/.mocharc.js | 33 - .../google-cloud-redis/v1/.prettierrc.js | 22 - .../google-cloud-redis/v1/README.md | 1 - .../google-cloud-redis/v1/package.json | 58 - .../google/cloud/redis/v1/cloud_redis.proto | 1000 --- .../v1/cloud_redis.create_instance.js | 80 - .../v1/cloud_redis.delete_instance.js | 64 - .../v1/cloud_redis.export_instance.js | 69 - .../v1/cloud_redis.failover_instance.js | 69 - .../generated/v1/cloud_redis.get_instance.js | 63 - .../cloud_redis.get_instance_auth_string.js | 63 - .../v1/cloud_redis.import_instance.js | 69 - .../v1/cloud_redis.list_instances.js | 80 - .../v1/cloud_redis.reschedule_maintenance.js | 76 - .../v1/cloud_redis.update_instance.js | 75 - .../v1/cloud_redis.upgrade_instance.js | 69 - ...nippet_metadata_google.cloud.redis.v1.json | 499 -- .../google-cloud-redis/v1/src/index.ts | 25 - .../v1/src/v1/cloud_redis_client.ts | 1923 ----- .../v1/src/v1/cloud_redis_client_config.json | 81 - .../v1/src/v1/cloud_redis_proto_list.json | 3 - .../v1/src/v1/gapic_metadata.json | 137 - .../google-cloud-redis/v1/src/v1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1/system-test/install.ts | 49 - .../v1/test/gapic_cloud_redis_v1.ts | 2418 ------- .../google-cloud-redis/v1/tsconfig.json | 19 - .../google-cloud-redis/v1/webpack.config.js | 64 - .../google-cloud-redis/v1beta1/.eslintignore | 7 - .../google-cloud-redis/v1beta1/.eslintrc.json | 3 - .../google-cloud-redis/v1beta1/.gitignore | 14 - .../google-cloud-redis/v1beta1/.jsdoc.js | 55 - .../google-cloud-redis/v1beta1/.mocharc.js | 33 - .../google-cloud-redis/v1beta1/.prettierrc.js | 22 - .../google-cloud-redis/v1beta1/README.md | 1 - .../google-cloud-redis/v1beta1/package.json | 58 - .../cloud/redis/v1beta1/cloud_redis.proto | 913 --- .../v1beta1/cloud_redis.create_instance.js | 80 - .../v1beta1/cloud_redis.delete_instance.js | 64 - .../v1beta1/cloud_redis.export_instance.js | 69 - .../v1beta1/cloud_redis.failover_instance.js | 69 - .../v1beta1/cloud_redis.get_instance.js | 63 - .../cloud_redis.get_instance_auth_string.js | 63 - .../v1beta1/cloud_redis.import_instance.js | 69 - .../v1beta1/cloud_redis.list_instances.js | 79 - .../cloud_redis.reschedule_maintenance.js | 75 - .../v1beta1/cloud_redis.update_instance.js | 75 - .../v1beta1/cloud_redis.upgrade_instance.js | 69 - ...t_metadata_google.cloud.redis.v1beta1.json | 499 -- .../google-cloud-redis/v1beta1/src/index.ts | 25 - .../v1beta1/src/v1beta1/cloud_redis_client.ts | 1659 ----- .../v1beta1/cloud_redis_client_config.json | 80 - .../src/v1beta1/cloud_redis_proto_list.json | 3 - .../v1beta1/src/v1beta1/gapic_metadata.json | 137 - .../v1beta1/src/v1beta1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1beta1/system-test/install.ts | 49 - .../v1beta1/test/gapic_cloud_redis_v1beta1.ts | 1997 ----- .../google-cloud-redis/v1beta1/tsconfig.json | 19 - .../v1beta1/webpack.config.js | 64 - .../v3/.eslintignore | 7 - .../v3/.eslintrc.json | 3 - .../v3/.gitignore | 14 - .../google-cloud-resourcemanager/v3/.jsdoc.js | 55 - .../v3/.mocharc.js | 33 - .../v3/.prettierrc.js | 22 - .../google-cloud-resourcemanager/v3/README.md | 1 - .../v3/package.json | 64 - .../cloud/resourcemanager/v3/folders.proto | 546 -- .../resourcemanager/v3/organizations.proto | 241 - .../cloud/resourcemanager/v3/projects.proto | 638 -- .../resourcemanager/v3/tag_bindings.proto | 268 - .../cloud/resourcemanager/v3/tag_holds.proto | 216 - .../cloud/resourcemanager/v3/tag_keys.proto | 367 - .../cloud/resourcemanager/v3/tag_values.proto | 331 - .../generated/v3/folders.create_folder.js | 63 - .../generated/v3/folders.delete_folder.js | 63 - .../generated/v3/folders.get_folder.js | 62 - .../generated/v3/folders.get_iam_policy.js | 67 - .../generated/v3/folders.list_folders.js | 86 - .../generated/v3/folders.move_folder.js | 70 - .../generated/v3/folders.search_folders.js | 98 - .../generated/v3/folders.set_iam_policy.js | 77 - .../v3/folders.test_iam_permissions.js | 70 - .../generated/v3/folders.undelete_folder.js | 63 - .../generated/v3/folders.update_folder.js | 69 - .../v3/organizations.get_iam_policy.js | 67 - .../v3/organizations.get_organization.js | 63 - .../v3/organizations.search_organizations.js | 87 - .../v3/organizations.set_iam_policy.js | 77 - .../v3/organizations.test_iam_permissions.js | 70 - .../generated/v3/projects.create_project.js | 68 - .../generated/v3/projects.delete_project.js | 62 - .../generated/v3/projects.get_iam_policy.js | 67 - .../generated/v3/projects.get_project.js | 61 - .../generated/v3/projects.list_projects.js | 84 - .../generated/v3/projects.move_project.js | 67 - .../generated/v3/projects.search_projects.js | 100 - .../generated/v3/projects.set_iam_policy.js | 77 - .../v3/projects.test_iam_permissions.js | 70 - .../generated/v3/projects.undelete_project.js | 63 - .../generated/v3/projects.update_project.js | 66 - ...adata_google.cloud.resourcemanager.v3.json | 2339 ------ .../v3/tag_bindings.create_tag_binding.js | 67 - .../v3/tag_bindings.delete_tag_binding.js | 64 - .../v3/tag_bindings.list_effective_tags.js | 76 - .../v3/tag_bindings.list_tag_bindings.js | 76 - .../generated/v3/tag_holds.create_tag_hold.js | 73 - .../generated/v3/tag_holds.delete_tag_hold.js | 68 - .../generated/v3/tag_holds.list_tag_holds.js | 88 - .../generated/v3/tag_keys.create_tag_key.js | 68 - .../generated/v3/tag_keys.delete_tag_key.js | 74 - .../generated/v3/tag_keys.get_iam_policy.js | 67 - .../v3/tag_keys.get_namespaced_tag_key.js | 64 - .../generated/v3/tag_keys.get_tag_key.js | 62 - .../generated/v3/tag_keys.list_tag_keys.js | 76 - .../generated/v3/tag_keys.set_iam_policy.js | 77 - .../v3/tag_keys.test_iam_permissions.js | 70 - .../generated/v3/tag_keys.update_tag_key.js | 76 - .../v3/tag_values.create_tag_value.js | 68 - .../v3/tag_values.delete_tag_value.js | 73 - .../generated/v3/tag_values.get_iam_policy.js | 67 - .../v3/tag_values.get_namespaced_tag_value.js | 67 - .../generated/v3/tag_values.get_tag_value.js | 62 - .../v3/tag_values.list_tag_values.js | 74 - .../generated/v3/tag_values.set_iam_policy.js | 77 - .../v3/tag_values.test_iam_permissions.js | 70 - .../v3/tag_values.update_tag_value.js | 74 - .../v3/src/index.ts | 37 - .../v3/src/v3/folders_client.ts | 2074 ------ .../v3/src/v3/folders_client_config.json | 83 - .../v3/src/v3/folders_proto_list.json | 9 - .../v3/src/v3/gapic_metadata.json | 667 -- .../v3/src/v3/index.ts | 25 - .../v3/src/v3/organizations_client.ts | 1063 --- .../src/v3/organizations_client_config.json | 53 - .../v3/src/v3/organizations_proto_list.json | 9 - .../v3/src/v3/projects_client.ts | 2093 ------ .../v3/src/v3/projects_client_config.json | 83 - .../v3/src/v3/projects_proto_list.json | 9 - .../v3/src/v3/tag_bindings_client.ts | 1258 ---- .../v3/src/v3/tag_bindings_client_config.json | 48 - .../v3/src/v3/tag_bindings_proto_list.json | 9 - .../v3/src/v3/tag_holds_client.ts | 1143 --- .../v3/src/v3/tag_holds_client_config.json | 38 - .../v3/src/v3/tag_holds_proto_list.json | 9 - .../v3/src/v3/tag_keys_client.ts | 1585 ---- .../v3/src/v3/tag_keys_client_config.json | 72 - .../v3/src/v3/tag_keys_proto_list.json | 9 - .../v3/src/v3/tag_values_client.ts | 1581 ---- .../v3/src/v3/tag_values_client_config.json | 72 - .../v3/src/v3/tag_values_proto_list.json | 9 - .../system-test/fixtures/sample/src/index.js | 33 - .../system-test/fixtures/sample/src/index.ts | 68 - .../v3/system-test/install.ts | 49 - .../v3/test/gapic_folders_v3.ts | 2205 ------ .../v3/test/gapic_organizations_v3.ts | 1025 --- .../v3/test/gapic_projects_v3.ts | 2205 ------ .../v3/test/gapic_tag_bindings_v3.ts | 1307 ---- .../v3/test/gapic_tag_holds_v3.ts | 1242 ---- .../v3/test/gapic_tag_keys_v3.ts | 1797 ----- .../v3/test/gapic_tag_values_v3.ts | 1797 ----- .../v3/tsconfig.json | 19 - .../v3/webpack.config.js | 64 - .../v1/.eslintignore | 7 - .../v1/.eslintrc.json | 3 - .../v1/.gitignore | 14 - .../v1/.jsdoc.js | 55 - .../v1/.mocharc.js | 33 - .../v1/.prettierrc.js | 22 - .../v1/README.md | 1 - .../v1/package.json | 58 - .../v1/resource_settings.proto | 308 - .../resource_settings_service.get_setting.js | 66 - ...resource_settings_service.list_settings.js | 80 - ...esource_settings_service.update_setting.js | 61 - ...data_google.cloud.resourcesettings.v1.json | 151 - .../v1/src/index.ts | 25 - .../v1/src/v1/gapic_metadata.json | 57 - .../v1/src/v1/index.ts | 19 - .../v1/resource_settings_service_client.ts | 808 --- ...source_settings_service_client_config.json | 50 - .../resource_settings_service_proto_list.json | 3 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1/system-test/install.ts | 49 - .../gapic_resource_settings_service_v1.ts | 779 -- .../v1/tsconfig.json | 19 - .../v1/webpack.config.js | 64 - .../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 - .../google-cloud-retail/v2/package.json | 66 - .../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 | 2207 ------ .../src/v2/catalog_service_client_config.json | 90 - .../v2/src/v2/catalog_service_proto_list.json | 21 - .../v2/src/v2/completion_service_client.ts | 1288 ---- .../v2/completion_service_client_config.json | 45 - .../src/v2/completion_service_proto_list.json | 21 - .../v2/src/v2/control_service_client.ts | 1546 ---- .../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 | 1796 ----- .../src/v2/model_service_client_config.json | 66 - .../v2/src/v2/model_service_proto_list.json | 21 - .../v2/src/v2/prediction_service_client.ts | 1222 ---- .../v2/prediction_service_client_config.json | 40 - .../src/v2/prediction_service_proto_list.json | 21 - .../v2/src/v2/product_service_client.ts | 2835 -------- .../src/v2/product_service_client_config.json | 99 - .../v2/src/v2/product_service_proto_list.json | 21 - .../v2/src/v2/search_service_client.ts | 2037 ------ .../src/v2/search_service_client_config.json | 40 - .../v2/src/v2/search_service_proto_list.json | 21 - .../src/v2/serving_config_service_client.ts | 1681 ----- .../serving_config_service_client_config.json | 54 - .../v2/serving_config_service_proto_list.json | 21 - .../v2/src/v2/user_event_service_client.ts | 1548 ---- .../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 - .../google-cloud-retail/v2alpha/package.json | 67 - .../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 | 2352 ------ .../catalog_service_client_config.json | 95 - .../v2alpha/catalog_service_proto_list.json | 24 - .../src/v2alpha/completion_service_client.ts | 1357 ---- .../completion_service_client_config.json | 45 - .../completion_service_proto_list.json | 24 - .../src/v2alpha/control_service_client.ts | 1611 ----- .../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 | 1350 ---- ...er_account_link_service_client_config.json | 38 - ...enter_account_link_service_proto_list.json | 24 - .../src/v2alpha/model_service_client.ts | 1862 ----- .../v2alpha/model_service_client_config.json | 66 - .../src/v2alpha/model_service_proto_list.json | 24 - .../src/v2alpha/prediction_service_client.ts | 1287 ---- .../prediction_service_client_config.json | 40 - .../prediction_service_proto_list.json | 24 - .../src/v2alpha/product_service_client.ts | 3109 -------- .../product_service_client_config.json | 104 - .../v2alpha/product_service_proto_list.json | 24 - .../src/v2alpha/search_service_client.ts | 2159 ------ .../v2alpha/search_service_client_config.json | 40 - .../v2alpha/search_service_proto_list.json | 24 - .../v2alpha/serving_config_service_client.ts | 1747 ----- .../serving_config_service_client_config.json | 54 - .../serving_config_service_proto_list.json | 24 - .../src/v2alpha/user_event_service_client.ts | 1614 ----- .../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 - .../google-cloud-retail/v2beta/package.json | 66 - .../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 | 2287 ------ .../v2beta/catalog_service_client_config.json | 95 - .../v2beta/catalog_service_proto_list.json | 22 - .../src/v2beta/completion_service_client.ts | 1288 ---- .../completion_service_client_config.json | 45 - .../v2beta/completion_service_proto_list.json | 22 - .../src/v2beta/control_service_client.ts | 1546 ---- .../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 | 1797 ----- .../v2beta/model_service_client_config.json | 58 - .../src/v2beta/model_service_proto_list.json | 22 - .../src/v2beta/prediction_service_client.ts | 1222 ---- .../prediction_service_client_config.json | 40 - .../v2beta/prediction_service_proto_list.json | 22 - .../src/v2beta/product_service_client.ts | 2843 -------- .../v2beta/product_service_client_config.json | 99 - .../v2beta/product_service_proto_list.json | 22 - .../src/v2beta/search_service_client.ts | 2037 ------ .../v2beta/search_service_client_config.json | 40 - .../src/v2beta/search_service_proto_list.json | 22 - .../v2beta/serving_config_service_client.ts | 1681 ----- .../serving_config_service_client_config.json | 54 - .../serving_config_service_proto_list.json | 22 - .../src/v2beta/user_event_service_client.ts | 1549 ---- .../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 - .../google-cloud-run/v2/.eslintignore | 7 - .../google-cloud-run/v2/.eslintrc.json | 3 - .../google-cloud-run/v2/.gitignore | 14 - owl-bot-staging/google-cloud-run/v2/.jsdoc.js | 55 - .../google-cloud-run/v2/.mocharc.js | 33 - .../google-cloud-run/v2/.prettierrc.js | 22 - owl-bot-staging/google-cloud-run/v2/README.md | 1 - .../google-cloud-run/v2/package.json | 62 - .../google/cloud/run/v2/condition.proto | 209 - .../google/cloud/run/v2/execution.proto | 277 - .../cloud/run/v2/execution_template.proto | 74 - .../v2/protos/google/cloud/run/v2/job.proto | 424 -- .../protos/google/cloud/run/v2/k8s.min.proto | 369 - .../protos/google/cloud/run/v2/revision.proto | 299 - .../cloud/run/v2/revision_template.proto | 103 - .../protos/google/cloud/run/v2/service.proto | 470 -- .../v2/protos/google/cloud/run/v2/task.proto | 267 - .../google/cloud/run/v2/task_template.proto | 70 - .../google/cloud/run/v2/traffic_target.proto | 77 - .../google/cloud/run/v2/vendor_settings.proto | 115 - .../v2/executions.delete_execution.js | 75 - .../generated/v2/executions.get_execution.js | 64 - .../v2/executions.list_executions.js | 79 - .../samples/generated/v2/jobs.create_job.js | 80 - .../samples/generated/v2/jobs.delete_job.js | 74 - .../generated/v2/jobs.get_iam_policy.js | 67 - .../v2/samples/generated/v2/jobs.get_job.js | 63 - .../v2/samples/generated/v2/jobs.list_jobs.js | 78 - .../v2/samples/generated/v2/jobs.run_job.js | 74 - .../generated/v2/jobs.set_iam_policy.js | 77 - .../generated/v2/jobs.test_iam_permissions.js | 70 - .../samples/generated/v2/jobs.update_job.js | 73 - .../generated/v2/revisions.delete_revision.js | 74 - .../generated/v2/revisions.get_revision.js | 63 - .../generated/v2/revisions.list_revisions.js | 79 - .../generated/v2/services.create_service.js | 81 - .../generated/v2/services.delete_service.js | 74 - .../generated/v2/services.get_iam_policy.js | 67 - .../generated/v2/services.get_service.js | 63 - .../generated/v2/services.list_services.js | 79 - .../generated/v2/services.set_iam_policy.js | 77 - .../v2/services.test_iam_permissions.js | 70 - .../generated/v2/services.update_service.js | 73 - .../snippet_metadata_google.cloud.run.v2.json | 1187 --- .../v2/samples/generated/v2/tasks.get_task.js | 63 - .../samples/generated/v2/tasks.list_tasks.js | 79 - .../google-cloud-run/v2/src/index.ts | 33 - .../v2/src/v2/executions_client.ts | 1349 ---- .../v2/src/v2/executions_client_config.json | 38 - .../v2/src/v2/executions_proto_list.json | 14 - .../v2/src/v2/gapic_metadata.json | 349 - .../google-cloud-run/v2/src/v2/index.ts | 23 - .../google-cloud-run/v2/src/v2/jobs_client.ts | 1896 ----- .../v2/src/v2/jobs_client_config.json | 62 - .../v2/src/v2/jobs_proto_list.json | 14 - .../v2/src/v2/revisions_client.ts | 1467 ---- .../v2/src/v2/revisions_client_config.json | 38 - .../v2/src/v2/revisions_proto_list.json | 14 - .../v2/src/v2/services_client.ts | 1874 ----- .../v2/src/v2/services_client_config.json | 75 - .../v2/src/v2/services_proto_list.json | 14 - .../v2/src/v2/tasks_client.ts | 1112 --- .../v2/src/v2/tasks_client_config.json | 34 - .../v2/src/v2/tasks_proto_list.json | 14 - .../system-test/fixtures/sample/src/index.js | 31 - .../system-test/fixtures/sample/src/index.ts | 56 - .../v2/system-test/install.ts | 49 - .../v2/test/gapic_executions_v2.ts | 1474 ---- .../google-cloud-run/v2/test/gapic_jobs_v2.ts | 2264 ------ .../v2/test/gapic_revisions_v2.ts | 1513 ---- .../v2/test/gapic_services_v2.ts | 2087 ------ .../v2/test/gapic_tasks_v2.ts | 1103 --- .../google-cloud-run/v2/tsconfig.json | 19 - .../google-cloud-run/v2/webpack.config.js | 64 - .../google-cloud-scheduler/v1/.eslintignore | 7 - .../google-cloud-scheduler/v1/.eslintrc.json | 3 - .../google-cloud-scheduler/v1/.gitignore | 14 - .../google-cloud-scheduler/v1/.jsdoc.js | 55 - .../google-cloud-scheduler/v1/.mocharc.js | 33 - .../google-cloud-scheduler/v1/.prettierrc.js | 22 - .../google-cloud-scheduler/v1/README.md | 1 - .../google-cloud-scheduler/v1/package.json | 58 - .../cloud/scheduler/v1/cloudscheduler.proto | 287 - .../google/cloud/scheduler/v1/job.proto | 259 - .../google/cloud/scheduler/v1/target.proto | 369 - .../v1/cloud_scheduler.create_job.js | 72 - .../v1/cloud_scheduler.delete_job.js | 62 - .../generated/v1/cloud_scheduler.get_job.js | 62 - .../generated/v1/cloud_scheduler.list_jobs.js | 85 - .../generated/v1/cloud_scheduler.pause_job.js | 62 - .../v1/cloud_scheduler.resume_job.js | 62 - .../generated/v1/cloud_scheduler.run_job.js | 62 - .../v1/cloud_scheduler.update_job.js | 68 - ...et_metadata_google.cloud.scheduler.v1.json | 351 - .../google-cloud-scheduler/v1/src/index.ts | 25 - .../v1/src/v1/cloud_scheduler_client.ts | 1281 ---- .../src/v1/cloud_scheduler_client_config.json | 66 - .../v1/src/v1/cloud_scheduler_proto_list.json | 5 - .../v1/src/v1/gapic_metadata.json | 107 - .../google-cloud-scheduler/v1/src/v1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1/system-test/install.ts | 49 - .../v1/test/gapic_cloud_scheduler_v1.ts | 1485 ---- .../google-cloud-scheduler/v1/tsconfig.json | 19 - .../v1/webpack.config.js | 64 - .../v1beta1/.eslintignore | 7 - .../v1beta1/.eslintrc.json | 3 - .../google-cloud-scheduler/v1beta1/.gitignore | 14 - .../google-cloud-scheduler/v1beta1/.jsdoc.js | 55 - .../v1beta1/.mocharc.js | 33 - .../v1beta1/.prettierrc.js | 22 - .../google-cloud-scheduler/v1beta1/README.md | 1 - .../v1beta1/package.json | 58 - .../scheduler/v1beta1/cloudscheduler.proto | 315 - .../google/cloud/scheduler/v1beta1/job.proto | 268 - .../cloud/scheduler/v1beta1/target.proto | 371 - .../v1beta1/cloud_scheduler.create_job.js | 72 - .../v1beta1/cloud_scheduler.delete_job.js | 68 - .../v1beta1/cloud_scheduler.get_job.js | 62 - .../v1beta1/cloud_scheduler.list_jobs.js | 101 - .../v1beta1/cloud_scheduler.pause_job.js | 62 - .../v1beta1/cloud_scheduler.resume_job.js | 62 - .../v1beta1/cloud_scheduler.run_job.js | 68 - .../v1beta1/cloud_scheduler.update_job.js | 68 - ...tadata_google.cloud.scheduler.v1beta1.json | 367 - .../v1beta1/src/index.ts | 25 - .../src/v1beta1/cloud_scheduler_client.ts | 1331 ---- .../cloud_scheduler_client_config.json | 66 - .../v1beta1/cloud_scheduler_proto_list.json | 5 - .../v1beta1/src/v1beta1/gapic_metadata.json | 107 - .../v1beta1/src/v1beta1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1beta1/system-test/install.ts | 49 - .../test/gapic_cloud_scheduler_v1beta1.ts | 1485 ---- .../v1beta1/tsconfig.json | 19 - .../v1beta1/webpack.config.js | 64 - .../samples/quickstart.js | 5 +- .../src/v1/network_security_client.ts | 9 +- .../src/v1beta1/network_security_client.ts | 9 +- .../src/v1/managed_notebook_service_client.ts | 9 +- .../src/v1/notebook_service_client.ts | 9 +- .../src/v1beta1/notebook_service_client.ts | 9 +- .../src/v2/notebook_service_client.ts | 9 +- .../src/v1/fleet_routing_client.ts | 9 +- .../src/v1/environments_client.ts | 9 +- .../src/v1/image_versions_client.ts | 7 +- .../src/v1beta1/environments_client.ts | 9 +- .../src/v1beta1/image_versions_client.ts | 7 +- .../src/v2/org_policy_client.ts | 7 +- .../src/v1/os_config_service_client.ts | 7 +- .../src/v1/os_config_zonal_service_client.ts | 9 +- .../v1alpha/os_config_zonal_service_client.ts | 9 +- .../src/v1beta/os_config_service_client.ts | 7 +- .../gapic_os_config_zonal_service_v1alpha.ts | 5 +- .../src/v1/os_login_service_client.ts | 7 +- .../src/v1beta/os_login_service_client.ts | 7 +- ...hing_protection_service_v1_beta1_client.ts | 7 +- .../src/v3/policy_troubleshooter_client.ts | 7 +- .../v3beta/policy_troubleshooter_client.ts | 7 +- .../src/v1/iam_checker_client.ts | 7 +- .../src/v1beta1/private_catalog_client.ts | 7 +- .../README.md | 5 +- .../samples/quickstart.js | 5 +- .../v1/rapid_migration_assessment_client.ts | 9 +- .../v1/recaptcha_enterprise_service_client.ts | 7 +- ...tcha_enterprise_service_v1_beta1_client.ts | 7 +- .../gapic_recaptcha_enterprise_service_v1.ts | 10 +- .../src/v1/recommender_client.ts | 7 +- .../src/v1beta1/recommender_client.ts | 7 +- .../src/v1/cloud_redis_client.ts | 9 +- .../src/v1beta1/cloud_redis_client.ts | 9 +- .../src/v3/folders_client.ts | 9 +- .../src/v3/organizations_client.ts | 7 +- .../src/v3/projects_client.ts | 9 +- .../src/v3/tag_bindings_client.ts | 9 +- .../src/v3/tag_holds_client.ts | 9 +- .../src/v3/tag_keys_client.ts | 9 +- .../src/v3/tag_values_client.ts | 9 +- .../v1/resource_settings_service_client.ts | 7 +- .../src/v2/catalog_service_client.ts | 9 +- .../src/v2/completion_service_client.ts | 9 +- .../src/v2/control_service_client.ts | 9 +- .../src/v2/model_service_client.ts | 9 +- .../src/v2/prediction_service_client.ts | 9 +- .../src/v2/product_service_client.ts | 9 +- .../src/v2/search_service_client.ts | 9 +- .../src/v2/serving_config_service_client.ts | 9 +- .../src/v2/user_event_service_client.ts | 9 +- .../src/v2alpha/catalog_service_client.ts | 9 +- .../src/v2alpha/completion_service_client.ts | 9 +- .../src/v2alpha/control_service_client.ts | 9 +- ...hant_center_account_link_service_client.ts | 9 +- .../src/v2alpha/model_service_client.ts | 9 +- .../src/v2alpha/prediction_service_client.ts | 9 +- .../src/v2alpha/product_service_client.ts | 9 +- .../src/v2alpha/search_service_client.ts | 9 +- .../v2alpha/serving_config_service_client.ts | 9 +- .../src/v2alpha/user_event_service_client.ts | 9 +- .../src/v2beta/catalog_service_client.ts | 9 +- .../src/v2beta/completion_service_client.ts | 9 +- .../src/v2beta/control_service_client.ts | 9 +- .../src/v2beta/model_service_client.ts | 9 +- .../src/v2beta/prediction_service_client.ts | 9 +- .../src/v2beta/product_service_client.ts | 9 +- .../src/v2beta/search_service_client.ts | 9 +- .../v2beta/serving_config_service_client.ts | 9 +- .../src/v2beta/user_event_service_client.ts | 9 +- .../src/v2/executions_client.ts | 9 +- .../google-cloud-run/src/v2/jobs_client.ts | 9 +- .../src/v2/revisions_client.ts | 9 +- .../src/v2/services_client.ts | 9 +- .../google-cloud-run/src/v2/tasks_client.ts | 7 +- .../src/v1/cloud_scheduler_client.ts | 7 +- .../src/v1beta1/cloud_scheduler_client.ts | 7 +- 1679 files changed, 288 insertions(+), 418535 deletions(-) delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/README.md delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/package.json delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/authorization_policy.proto delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/client_tls_policy.proto delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/common.proto delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/network_security.proto delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/server_tls_policy.proto delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/tls.proto delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_authorization_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_client_tls_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_server_tls_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_authorization_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_client_tls_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_server_tls_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_authorization_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_client_tls_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_server_tls_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_authorization_policies.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_client_tls_policies.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_server_tls_policies.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_authorization_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_client_tls_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_server_tls_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/snippet_metadata_google.cloud.networksecurity.v1.json delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_client.ts delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_client_config.json delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/test/gapic_network_security_v1.ts delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/README.md delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/package.json delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/authorization_policy.proto delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/client_tls_policy.proto delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/common.proto delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/network_security.proto delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/server_tls_policy.proto delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/tls.proto delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_authorization_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_client_tls_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_server_tls_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_authorization_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_client_tls_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_server_tls_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_authorization_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_client_tls_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_server_tls_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_authorization_policies.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_client_tls_policies.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_server_tls_policies.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_authorization_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_client_tls_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_server_tls_policy.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.networksecurity.v1beta1.json delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/index.ts delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_client.ts delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_client_config.json delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/test/gapic_network_security_v1beta1.ts delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-networksecurity/v1beta1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/README.md delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/package.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/diagnostic_config.proto delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/environment.proto delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/event.proto delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/execution.proto delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/instance.proto delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/instance_config.proto delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/managed_service.proto delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/runtime.proto delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/schedule.proto delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/service.proto delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.create_runtime.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.delete_runtime.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.diagnose_runtime.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.get_runtime.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.list_runtimes.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.refresh_runtime_token_internal.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.report_runtime_event.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.reset_runtime.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.start_runtime.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.stop_runtime.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.switch_runtime.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.update_runtime.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.upgrade_runtime.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_environment.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_execution.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_schedule.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_environment.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_execution.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_schedule.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.diagnose_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_environment.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_execution.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_instance_health.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_schedule.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.is_instance_upgradeable.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_environments.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_executions.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_instances.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_schedules.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.register_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.report_instance_info.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.reset_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.rollback_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_accelerator.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_labels.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_machine_type.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.start_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.stop_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.trigger_schedule.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_instance_config.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_instance_metadata_items.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_shielded_instance_config.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.upgrade_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.upgrade_instance_internal.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/snippet_metadata_google.cloud.notebooks.v1.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/test/gapic_managed_notebook_service_v1.ts delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/test/gapic_notebook_service_v1.ts delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/README.md delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/package.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/environment.proto delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/instance.proto delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/service.proto delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.create_environment.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.create_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.delete_environment.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.delete_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.get_environment.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.get_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.is_instance_upgradeable.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.list_environments.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.list_instances.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.register_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.report_instance_info.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.reset_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_accelerator.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_labels.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_machine_type.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.start_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.stop_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.upgrade_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.upgrade_instance_internal.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.notebooks.v1beta1.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/index.ts delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/test/gapic_notebook_service_v1beta1.ts delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v1beta1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/.gitignore delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/README.md delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/package.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/diagnostic_config.proto delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/event.proto delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/gce_setup.proto delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/instance.proto delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/service.proto delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.check_instance_upgradability.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.create_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.delete_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.diagnose_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.get_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.list_instances.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.reset_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.rollback_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.start_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.stop_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.update_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.upgrade_instance.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/snippet_metadata_google.cloud.notebooks.v2.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/src/v2/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/src/v2/index.ts delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/test/gapic_notebook_service_v2.ts delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-notebooks/v2/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/README.md delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/package.json delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/protos/google/cloud/optimization/v1/async_model.proto delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/protos/google/cloud/optimization/v1/fleet_routing.proto delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/fleet_routing.batch_optimize_tours.js delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/fleet_routing.optimize_tours.js delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/snippet_metadata_google.cloud.optimization.v1.json delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_client.ts delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_client_config.json delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/test/gapic_fleet_routing_v1.ts delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-optimization/v1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/README.md delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/package.json delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/environments.proto delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/image_versions.proto delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/operations.proto delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.create_environment.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.database_failover.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.delete_environment.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.execute_airflow_command.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.fetch_database_properties.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.get_environment.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.list_environments.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.load_snapshot.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.poll_airflow_command.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.save_snapshot.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.stop_airflow_command.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.update_environment.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/image_versions.list_image_versions.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/snippet_metadata_google.cloud.orchestration.airflow.service.v1.json delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_client.ts delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_client_config.json delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_client.ts delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_client_config.json delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/test/gapic_environments_v1.ts delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/test/gapic_image_versions_v1.ts delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/README.md delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/package.json delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/environments.proto delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/image_versions.proto delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/operations.proto delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.check_upgrade.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.create_environment.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.database_failover.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.delete_environment.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.execute_airflow_command.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.fetch_database_properties.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.get_environment.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.list_environments.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.load_snapshot.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.poll_airflow_command.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.restart_web_server.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.save_snapshot.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.stop_airflow_command.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.update_environment.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/image_versions.list_image_versions.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.orchestration.airflow.service.v1beta1.json delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_client.ts delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_client_config.json delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_client.ts delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_client_config.json delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/index.ts delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/test/gapic_environments_v1beta1.ts delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/test/gapic_image_versions_v1beta1.ts delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/.gitignore delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/README.md delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/package.json delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/protos/google/cloud/orgpolicy/v2/constraint.proto delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/protos/google/cloud/orgpolicy/v2/orgpolicy.proto delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.create_policy.js delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.delete_policy.js delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.get_effective_policy.js delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.get_policy.js delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.list_constraints.js delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.list_policies.js delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.update_policy.js delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/snippet_metadata_google.cloud.orgpolicy.v2.json delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/index.ts delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_client.ts delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_client_config.json delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/test/gapic_org_policy_v2.ts delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-orgpolicy/v2/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/README.md delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/package.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/inventory.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy_assignment_reports.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy_assignments.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_common.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_service.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_zonal_service.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/patch_deployments.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/patch_jobs.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/vulnerability.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.cancel_patch_job.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.create_patch_deployment.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.delete_patch_deployment.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.execute_patch_job.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.get_patch_deployment.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.get_patch_job.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_deployments.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_job_instance_details.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_jobs.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.pause_patch_deployment.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.resume_patch_deployment.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.update_patch_deployment.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.create_o_s_policy_assignment.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.delete_o_s_policy_assignment.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_inventory.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_o_s_policy_assignment.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_o_s_policy_assignment_report.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_vulnerability_report.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_inventories.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignment_reports.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignment_revisions.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignments.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_vulnerability_reports.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.update_o_s_policy_assignment.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/snippet_metadata_google.cloud.osconfig.v1.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/test/gapic_os_config_service_v1.ts delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/test/gapic_os_config_zonal_service_v1.ts delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/.gitignore delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/README.md delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/package.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/config_common.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/instance_os_policies_compliance.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/inventory.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy_assignment_reports.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy_assignments.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/osconfig_common.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/osconfig_zonal_service.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/vulnerability.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.create_o_s_policy_assignment.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.delete_o_s_policy_assignment.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_instance_o_s_policies_compliance.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_inventory.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_o_s_policy_assignment.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_o_s_policy_assignment_report.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_vulnerability_report.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_instance_o_s_policies_compliances.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_inventories.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignment_reports.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignment_revisions.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignments.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_vulnerability_reports.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.update_o_s_policy_assignment.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/snippet_metadata_google.cloud.osconfig.v1alpha.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/index.ts delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/test/gapic_os_config_zonal_service_v1alpha.ts delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1alpha/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/.gitignore delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/README.md delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/package.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/guest_policies.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/osconfig_common.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/osconfig_service.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/patch_deployments.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/patch_jobs.proto delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.cancel_patch_job.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.create_guest_policy.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.create_patch_deployment.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.delete_guest_policy.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.delete_patch_deployment.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.execute_patch_job.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_guest_policy.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_patch_deployment.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_patch_job.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_guest_policies.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_deployments.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_job_instance_details.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_jobs.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.lookup_effective_guest_policy.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.pause_patch_deployment.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.resume_patch_deployment.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.update_guest_policy.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.update_patch_deployment.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/snippet_metadata_google.cloud.osconfig.v1beta.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/index.ts delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/test/gapic_os_config_service_v1beta.ts delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-osconfig/v1beta/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/README.md delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/package.json delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/protos/google/cloud/oslogin/common/common.proto delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/protos/google/cloud/oslogin/v1/oslogin.proto delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.create_ssh_public_key.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.delete_posix_account.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.delete_ssh_public_key.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.get_login_profile.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.get_ssh_public_key.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.import_ssh_public_key.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.update_ssh_public_key.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/snippet_metadata_google.cloud.oslogin.v1.json delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/test/gapic_os_login_service_v1.ts delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/.gitignore delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/README.md delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/package.json delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/protos/google/cloud/oslogin/common/common.proto delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/protos/google/cloud/oslogin/v1beta/oslogin.proto delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.create_ssh_public_key.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.delete_posix_account.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.delete_ssh_public_key.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.get_login_profile.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.get_ssh_public_key.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.import_ssh_public_key.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.sign_ssh_public_key.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.update_ssh_public_key.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/snippet_metadata_google.cloud.oslogin.v1beta.json delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/index.ts delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/test/gapic_os_login_service_v1beta.ts delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-oslogin/v1beta/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/README.md delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/package.json delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/protos/google/cloud/phishingprotection/v1beta1/phishingprotection.proto delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/samples/generated/v1beta1/phishing_protection_service_v1_beta1.report_phishing.js delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.phishingprotection.v1beta1.json delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/index.ts delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_client.ts delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_client_config.json delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/test/gapic_phishing_protection_service_v1_beta1_v1beta1.ts delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-phishingprotection/v1beta1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.gitignore delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/README.md delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/package.json delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/protos/google/cloud/policytroubleshooter/iam/v3/troubleshooter.proto delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/samples/generated/v3/policy_troubleshooter.troubleshoot_iam_policy.js delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/samples/generated/v3/snippet_metadata_google.cloud.policytroubleshooter.iam.v3.json delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/index.ts delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_client.ts delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_client_config.json delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/test/gapic_policy_troubleshooter_v3.ts delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.gitignore delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/README.md delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/package.json delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/cloud/policytroubleshooter/iam/v3beta/troubleshooter.proto delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v1/policy.proto delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v2/deny.proto delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v2/policy.proto delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/rpc/status.proto delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/type/expr.proto delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/samples/generated/v3beta/policy_troubleshooter.troubleshoot_iam_policy.js delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/samples/generated/v3beta/snippet_metadata_google.cloud.policytroubleshooter.iam.v3beta.json delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/index.ts delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_client.ts delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_client_config.json delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/test/gapic_policy_troubleshooter_v3beta.ts delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/README.md delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/package.json delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/protos/google/cloud/policytroubleshooter/v1/checker.proto delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/protos/google/cloud/policytroubleshooter/v1/explanations.proto delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/samples/generated/v1/iam_checker.troubleshoot_iam_policy.js delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/samples/generated/v1/snippet_metadata_google.cloud.policytroubleshooter.v1.json delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_client.ts delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_client_config.json delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/test/gapic_iam_checker_v1.ts delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-policytroubleshooter/v1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/README.md delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/package.json delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/protos/google/cloud/privatecatalog/v1beta1/private_catalog.proto delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_catalogs.js delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_products.js delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_versions.js delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.privatecatalog.v1beta1.json delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/index.ts delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_client.ts delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_client_config.json delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/test/gapic_private_catalog_v1beta1.ts delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-privatecatalog/v1beta1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/README.md delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/package.json delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/protos/google/cloud/rapidmigrationassessment/v1/api_entities.proto delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/protos/google/cloud/rapidmigrationassessment/v1/rapidmigrationassessment.proto delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.create_annotation.js delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.create_collector.js delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.delete_collector.js delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.get_annotation.js delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.get_collector.js delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.list_collectors.js delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.pause_collector.js delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.register_collector.js delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.resume_collector.js delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.update_collector.js delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/snippet_metadata_google.cloud.rapidmigrationassessment.v1.json delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_client.ts delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_client_config.json delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/test/gapic_rapid_migration_assessment_v1.ts delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-rapidmigrationassessment/v1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/README.md delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/package.json delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.annotate_assessment.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.create_assessment.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.create_key.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.delete_key.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.get_key.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.get_metrics.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_keys.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_group_memberships.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_groups.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.migrate_key.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.retrieve_legacy_secret_key.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.search_related_account_group_memberships.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.update_key.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/snippet_metadata_google.cloud.recaptchaenterprise.v1.json delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/test/gapic_recaptcha_enterprise_service_v1.ts delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/README.md delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/package.json delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.annotate_assessment.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_assessment.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.recaptchaenterprise.v1beta1.json delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/index.ts delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/test/gapic_recaptcha_enterprise_service_v1_beta1_v1beta1.ts delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/README.md delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/package.json delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/insight.proto delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/insight_type_config.proto delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommendation.proto delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommender_config.proto delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommender_service.proto delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_insight.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_insight_type_config.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_recommendation.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_recommender_config.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.list_insights.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.list_recommendations.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_insight_accepted.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_claimed.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_failed.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_succeeded.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.update_insight_type_config.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.update_recommender_config.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/snippet_metadata_google.cloud.recommender.v1.json delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_client.ts delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_client_config.json delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/test/gapic_recommender_v1.ts delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-recommender/v1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/README.md delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/package.json delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/insight.proto delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/insight_type_config.proto delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommendation.proto delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommender_config.proto delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommender_service.proto delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_insight.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_insight_type_config.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_recommendation.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_recommender_config.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.list_insights.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.list_recommendations.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_insight_accepted.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_claimed.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_failed.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_succeeded.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.update_insight_type_config.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.update_recommender_config.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.recommender.v1beta1.json delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/index.ts delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_client.ts delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_client_config.json delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/test/gapic_recommender_v1beta1.ts delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-recommender/v1beta1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-redis/v1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-redis/v1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-redis/v1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1/README.md delete mode 100644 owl-bot-staging/google-cloud-redis/v1/package.json delete mode 100644 owl-bot-staging/google-cloud-redis/v1/protos/google/cloud/redis/v1/cloud_redis.proto delete mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.create_instance.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.delete_instance.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.export_instance.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.failover_instance.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.get_instance.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.get_instance_auth_string.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.import_instance.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.list_instances.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.reschedule_maintenance.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.update_instance.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.upgrade_instance.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/snippet_metadata_google.cloud.redis.v1.json delete mode 100644 owl-bot-staging/google-cloud-redis/v1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_client.ts delete mode 100644 owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_client_config.json delete mode 100644 owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-redis/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-redis/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/google-cloud-redis/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-redis/v1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-redis/v1/test/gapic_cloud_redis_v1.ts delete mode 100644 owl-bot-staging/google-cloud-redis/v1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-redis/v1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/README.md delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/package.json delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/protos/google/cloud/redis/v1beta1/cloud_redis.proto delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.create_instance.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.delete_instance.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.export_instance.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.failover_instance.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.get_instance.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.get_instance_auth_string.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.import_instance.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.list_instances.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.reschedule_maintenance.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.update_instance.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.upgrade_instance.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.redis.v1beta1.json delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_client.ts delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_client_config.json delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/index.ts delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/test/gapic_cloud_redis_v1beta1.ts delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-redis/v1beta1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/.gitignore delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/README.md delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/package.json delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/folders.proto delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/organizations.proto delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/projects.proto delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_bindings.proto delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_holds.proto delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_keys.proto delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_values.proto delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.create_folder.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.delete_folder.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.get_folder.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.get_iam_policy.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.list_folders.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.move_folder.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.search_folders.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.set_iam_policy.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.test_iam_permissions.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.undelete_folder.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.update_folder.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.get_iam_policy.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.get_organization.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.search_organizations.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.set_iam_policy.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.test_iam_permissions.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.create_project.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.delete_project.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.get_iam_policy.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.get_project.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.list_projects.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.move_project.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.search_projects.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.set_iam_policy.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.test_iam_permissions.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.undelete_project.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.update_project.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/snippet_metadata_google.cloud.resourcemanager.v3.json delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.create_tag_binding.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.delete_tag_binding.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.list_effective_tags.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.list_tag_bindings.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.create_tag_hold.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.delete_tag_hold.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.list_tag_holds.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.create_tag_key.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.delete_tag_key.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_iam_policy.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_namespaced_tag_key.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_tag_key.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.list_tag_keys.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.set_iam_policy.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.test_iam_permissions.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.update_tag_key.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.create_tag_value.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.delete_tag_value.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_iam_policy.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_namespaced_tag_value.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_tag_value.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.list_tag_values.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.set_iam_policy.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.test_iam_permissions.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.update_tag_value.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_client.ts delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_client_config.json delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/index.ts delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_client.ts delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_client_config.json delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_client.ts delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_client_config.json delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_client.ts delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_client_config.json delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_client.ts delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_client_config.json delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_client.ts delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_client_config.json delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_client.ts delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_client_config.json delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_folders_v3.ts delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_organizations_v3.ts delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_projects_v3.ts delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_bindings_v3.ts delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_holds_v3.ts delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_keys_v3.ts delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_values_v3.ts delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-resourcemanager/v3/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/README.md delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/package.json delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/protos/google/cloud/resourcesettings/v1/resource_settings.proto delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.get_setting.js delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.list_settings.js delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.update_setting.js delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/snippet_metadata_google.cloud.resourcesettings.v1.json delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/test/gapic_resource_settings_service_v1.ts delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-resourcesettings/v1/webpack.config.js 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/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/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/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 delete mode 100644 owl-bot-staging/google-cloud-run/v2/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-run/v2/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-run/v2/.gitignore delete mode 100644 owl-bot-staging/google-cloud-run/v2/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/README.md delete mode 100644 owl-bot-staging/google-cloud-run/v2/package.json delete mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/condition.proto delete mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/execution.proto delete mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/execution_template.proto delete mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/job.proto delete mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/k8s.min.proto delete mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/revision.proto delete mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/revision_template.proto delete mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/service.proto delete mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/task.proto delete mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/task_template.proto delete mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/traffic_target.proto delete mode 100644 owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/vendor_settings.proto delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.delete_execution.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.get_execution.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.list_executions.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.create_job.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.delete_job.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.get_iam_policy.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.get_job.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.list_jobs.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.run_job.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.set_iam_policy.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.test_iam_permissions.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.update_job.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.delete_revision.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.get_revision.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.list_revisions.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.create_service.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.delete_service.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.get_iam_policy.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.get_service.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.list_services.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.set_iam_policy.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.test_iam_permissions.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.update_service.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/snippet_metadata_google.cloud.run.v2.json delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/tasks.get_task.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/samples/generated/v2/tasks.list_tasks.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/executions_client.ts delete mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/executions_client_config.json delete mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/executions_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/index.ts delete mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/jobs_client.ts delete mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/jobs_client_config.json delete mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/jobs_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/revisions_client.ts delete mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/revisions_client_config.json delete mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/revisions_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/services_client.ts delete mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/services_client_config.json delete mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/services_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/tasks_client.ts delete mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/tasks_client_config.json delete mode 100644 owl-bot-staging/google-cloud-run/v2/src/v2/tasks_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-run/v2/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-run/v2/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-run/v2/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-run/v2/test/gapic_executions_v2.ts delete mode 100644 owl-bot-staging/google-cloud-run/v2/test/gapic_jobs_v2.ts delete mode 100644 owl-bot-staging/google-cloud-run/v2/test/gapic_revisions_v2.ts delete mode 100644 owl-bot-staging/google-cloud-run/v2/test/gapic_services_v2.ts delete mode 100644 owl-bot-staging/google-cloud-run/v2/test/gapic_tasks_v2.ts delete mode 100644 owl-bot-staging/google-cloud-run/v2/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-run/v2/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/README.md delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/package.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/cloudscheduler.proto delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/job.proto delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/target.proto delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.create_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.delete_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.get_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.list_jobs.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.pause_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.resume_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.run_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.update_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/snippet_metadata_google.cloud.scheduler.v1.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client_config.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/test/gapic_cloud_scheduler_v1.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/README.md delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/package.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/job.proto delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/target.proto delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.create_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.delete_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.get_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.list_jobs.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.pause_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.resume_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.run_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.update_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.scheduler.v1beta1.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client_config.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/index.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/test/gapic_cloud_scheduler_v1beta1.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/webpack.config.js diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/.eslintignore b/owl-bot-staging/google-cloud-networksecurity/v1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/.eslintrc.json b/owl-bot-staging/google-cloud-networksecurity/v1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/.gitignore b/owl-bot-staging/google-cloud-networksecurity/v1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/.jsdoc.js b/owl-bot-staging/google-cloud-networksecurity/v1/.jsdoc.js deleted file mode 100644 index 4caec343c54..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/.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/networksecurity', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/.mocharc.js b/owl-bot-staging/google-cloud-networksecurity/v1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/.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-networksecurity/v1/.prettierrc.js b/owl-bot-staging/google-cloud-networksecurity/v1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/.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-networksecurity/v1/README.md b/owl-bot-staging/google-cloud-networksecurity/v1/README.md deleted file mode 100644 index aa251b5b5c0..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Networksecurity: Nodejs Client diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/package.json b/owl-bot-staging/google-cloud-networksecurity/v1/package.json deleted file mode 100644 index 4035fdcca29..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/networksecurity", - "version": "0.1.0", - "description": "Networksecurity client for Node.js", - "repository": "googleapis/nodejs-networksecurity", - "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 networksecurity", - "networksecurity", - "network security" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/authorization_policy.proto b/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/authorization_policy.proto deleted file mode 100644 index 7d720d4e9c4..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/authorization_policy.proto +++ /dev/null @@ -1,249 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.networksecurity.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.NetworkSecurity.V1"; -option go_package = "cloud.google.com/go/networksecurity/apiv1/networksecuritypb;networksecuritypb"; -option java_multiple_files = true; -option java_outer_classname = "AuthorizationPolicyProto"; -option java_package = "com.google.cloud.networksecurity.v1"; -option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1"; -option ruby_package = "Google::Cloud::NetworkSecurity::V1"; - -// AuthorizationPolicy is a resource that specifies how a server -// should authorize incoming connections. This resource in itself does -// not change the configuration unless it's attached to a target https -// proxy or endpoint config selector resource. -message AuthorizationPolicy { - option (google.api.resource) = { - type: "networksecurity.googleapis.com/AuthorizationPolicy" - pattern: "projects/{project}/locations/{location}/authorizationPolicies/{authorization_policy}" - }; - - // Specification of rules. - message Rule { - // Specification of traffic source attributes. - message Source { - // Optional. List of peer identities to match for authorization. At least one - // principal should match. Each peer can be an exact match, or a prefix - // match (example, "namespace/*") or a suffix match (example, - // "*/service-account") or a presence match "*". Authorization based on - // the principal name without certificate validation (configured by - // ServerTlsPolicy resource) is considered insecure. - repeated string principals = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. List of CIDR ranges to match based on source IP address. At least one - // IP block should match. Single IP (e.g., "1.2.3.4") and CIDR (e.g., - // "1.2.3.0/24") are supported. Authorization based on source IP alone - // should be avoided. The IP addresses of any load balancers or proxies - // should be considered untrusted. - repeated string ip_blocks = 2 [(google.api.field_behavior) = OPTIONAL]; - } - - // Specification of traffic destination attributes. - message Destination { - // Specification of HTTP header match attributes. - message HttpHeaderMatch { - oneof type { - // Required. The value of the header must match the regular expression - // specified in regexMatch. For regular expression grammar, - // please see: en.cppreference.com/w/cpp/regex/ecmascript - // For matching against a port specified in the HTTP - // request, use a headerMatch with headerName set to Host - // and a regular expression that satisfies the RFC2616 Host - // header's port specifier. - string regex_match = 2 [(google.api.field_behavior) = REQUIRED]; - } - - // Required. The name of the HTTP header to match. For matching - // against the HTTP request's authority, use a headerMatch - // with the header name ":authority". For matching a - // request's method, use the headerName ":method". - string header_name = 1 [(google.api.field_behavior) = REQUIRED]; - } - - // Required. List of host names to match. Matched against the ":authority" header in - // http requests. At least one host should match. Each host can be an - // exact match, or a prefix match (example "mydomain.*") or a suffix - // match (example "*.myorg.com") or a presence (any) match "*". - repeated string hosts = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. List of destination ports to match. At least one port should match. - repeated uint32 ports = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. A list of HTTP methods to match. At least one method should - // match. Should not be set for gRPC services. - repeated string methods = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Match against key:value pair in http header. Provides a flexible match - // based on HTTP headers, for potentially advanced use cases. At least one - // header should match. Avoid using header matches to make authorization - // decisions unless there is a strong guarantee that requests arrive - // through a trusted client or proxy. - HttpHeaderMatch http_header_match = 5 [(google.api.field_behavior) = OPTIONAL]; - } - - // Optional. List of attributes for the traffic source. All of the sources must match. - // A source is a match if both principals and ip_blocks match. If not set, - // the action specified in the 'action' field will be applied without any - // rule checks for the source. - repeated Source sources = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. List of attributes for the traffic destination. All of the destinations - // must match. A destination is a match if a request matches all the - // specified hosts, ports, methods and headers. If not set, the - // action specified in the 'action' field will be applied without any rule - // checks for the destination. - repeated Destination destinations = 2 [(google.api.field_behavior) = OPTIONAL]; - } - - // Possible values that define what action to take. - enum Action { - // Default value. - ACTION_UNSPECIFIED = 0; - - // Grant access. - ALLOW = 1; - - // Deny access. - // Deny rules should be avoided unless they are used to provide a default - // "deny all" fallback. - DENY = 2; - } - - // Required. Name of the AuthorizationPolicy resource. It matches pattern - // `projects/{project}/locations/{location}/authorizationPolicies/`. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Free-text description of the resource. - string description = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The timestamp when the resource was created. - google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The timestamp when the resource was updated. - google.protobuf.Timestamp update_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Set of label tags associated with the AuthorizationPolicy resource. - map labels = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Required. The action to take when a rule match is found. Possible values - // are "ALLOW" or "DENY". - Action action = 6 [(google.api.field_behavior) = REQUIRED]; - - // Optional. List of rules to match. Note that at least one of the rules must match in - // order for the action specified in the 'action' field to be taken. A rule is - // a match if there is a matching source and destination. If left blank, the - // action specified in the `action` field will be applied on every request. - repeated Rule rules = 7 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request used with the ListAuthorizationPolicies method. -message ListAuthorizationPoliciesRequest { - // Required. The project and location from which the AuthorizationPolicies - // should be listed, specified in the format - // `projects/{project}/locations/{location}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Maximum number of AuthorizationPolicies to return per call. - int32 page_size = 2; - - // The value returned by the last - // `ListAuthorizationPoliciesResponse` Indicates that this is a - // continuation of a prior `ListAuthorizationPolicies` call, and - // that the system should return the next page of data. - string page_token = 3; -} - -// Response returned by the ListAuthorizationPolicies method. -message ListAuthorizationPoliciesResponse { - // List of AuthorizationPolicies resources. - repeated AuthorizationPolicy authorization_policies = 1; - - // If there might be more results than those appearing in this response, then - // `next_page_token` is included. To get the next set of results, call this - // method again using the value of `next_page_token` as `page_token`. - string next_page_token = 2; -} - -// Request used by the GetAuthorizationPolicy method. -message GetAuthorizationPolicyRequest { - // Required. A name of the AuthorizationPolicy to get. Must be in the format - // `projects/{project}/locations/{location}/authorizationPolicies/*`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "networksecurity.googleapis.com/AuthorizationPolicy" - } - ]; -} - -// Request used by the CreateAuthorizationPolicy method. -message CreateAuthorizationPolicyRequest { - // Required. The parent resource of the AuthorizationPolicy. Must be in the - // format `projects/{project}/locations/{location}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "networksecurity.googleapis.com/AuthorizationPolicy" - } - ]; - - // Required. Short name of the AuthorizationPolicy resource to be created. - // This value should be 1-63 characters long, containing only - // letters, numbers, hyphens, and underscores, and should not start - // with a number. E.g. "authz_policy". - string authorization_policy_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. AuthorizationPolicy resource to be created. - AuthorizationPolicy authorization_policy = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request used by the UpdateAuthorizationPolicy method. -message UpdateAuthorizationPolicyRequest { - // Optional. Field mask is used to specify the fields to be overwritten in the - // AuthorizationPolicy resource by the update. - // The fields specified in the update_mask are relative to the resource, not - // the full request. A field will be overwritten if it is in the mask. If the - // user does not provide a mask then all fields will be overwritten. - google.protobuf.FieldMask update_mask = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Required. Updated AuthorizationPolicy resource. - AuthorizationPolicy authorization_policy = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request used by the DeleteAuthorizationPolicy method. -message DeleteAuthorizationPolicyRequest { - // Required. A name of the AuthorizationPolicy to delete. Must be in the format - // `projects/{project}/locations/{location}/authorizationPolicies/*`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "networksecurity.googleapis.com/AuthorizationPolicy" - } - ]; -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/client_tls_policy.proto b/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/client_tls_policy.proto deleted file mode 100644 index e201dd82c1c..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/client_tls_policy.proto +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.networksecurity.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/networksecurity/v1/tls.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.NetworkSecurity.V1"; -option go_package = "cloud.google.com/go/networksecurity/apiv1/networksecuritypb;networksecuritypb"; -option java_multiple_files = true; -option java_outer_classname = "ClientTlsPolicyProto"; -option java_package = "com.google.cloud.networksecurity.v1"; -option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1"; -option ruby_package = "Google::Cloud::NetworkSecurity::V1"; - -// ClientTlsPolicy is a resource that specifies how a client should authenticate -// connections to backends of a service. This resource itself does not affect -// configuration unless it is attached to a backend service resource. -message ClientTlsPolicy { - option (google.api.resource) = { - type: "networksecurity.googleapis.com/ClientTlsPolicy" - pattern: "projects/{project}/locations/{location}/clientTlsPolicies/{client_tls_policy}" - }; - - // Required. Name of the ClientTlsPolicy resource. It matches the pattern - // `projects/*/locations/{location}/clientTlsPolicies/{client_tls_policy}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Free-text description of the resource. - string description = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The timestamp when the resource was created. - google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The timestamp when the resource was updated. - google.protobuf.Timestamp update_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Set of label tags associated with the resource. - map labels = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Server Name Indication string to present to the server during TLS - // handshake. E.g: "secure.example.com". - string sni = 6 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Defines a mechanism to provision client identity (public and private keys) - // for peer to peer authentication. The presence of this dictates mTLS. - CertificateProvider client_certificate = 7 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Defines the mechanism to obtain the Certificate Authority certificate to - // validate the server certificate. If empty, client does not validate the - // server certificate. - repeated ValidationCA server_validation_ca = 8 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request used by the ListClientTlsPolicies method. -message ListClientTlsPoliciesRequest { - // Required. The project and location from which the ClientTlsPolicies should - // be listed, specified in the format `projects/*/locations/{location}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Maximum number of ClientTlsPolicies to return per call. - int32 page_size = 2; - - // The value returned by the last `ListClientTlsPoliciesResponse` - // Indicates that this is a continuation of a prior - // `ListClientTlsPolicies` call, and that the system - // should return the next page of data. - string page_token = 3; -} - -// Response returned by the ListClientTlsPolicies method. -message ListClientTlsPoliciesResponse { - // List of ClientTlsPolicy resources. - repeated ClientTlsPolicy client_tls_policies = 1; - - // If there might be more results than those appearing in this response, then - // `next_page_token` is included. To get the next set of results, call this - // method again using the value of `next_page_token` as `page_token`. - string next_page_token = 2; -} - -// Request used by the GetClientTlsPolicy method. -message GetClientTlsPolicyRequest { - // Required. A name of the ClientTlsPolicy to get. Must be in the format - // `projects/*/locations/{location}/clientTlsPolicies/*`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "networksecurity.googleapis.com/ClientTlsPolicy" - } - ]; -} - -// Request used by the CreateClientTlsPolicy method. -message CreateClientTlsPolicyRequest { - // Required. The parent resource of the ClientTlsPolicy. Must be in - // the format `projects/*/locations/{location}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "networksecurity.googleapis.com/ClientTlsPolicy" - } - ]; - - // Required. Short name of the ClientTlsPolicy resource to be created. This value should - // be 1-63 characters long, containing only letters, numbers, hyphens, and - // underscores, and should not start with a number. E.g. "client_mtls_policy". - string client_tls_policy_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. ClientTlsPolicy resource to be created. - ClientTlsPolicy client_tls_policy = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request used by UpdateClientTlsPolicy method. -message UpdateClientTlsPolicyRequest { - // Optional. Field mask is used to specify the fields to be overwritten in the - // ClientTlsPolicy resource by the update. The fields - // specified in the update_mask are relative to the resource, not - // the full request. A field will be overwritten if it is in the - // mask. If the user does not provide a mask then all fields will be - // overwritten. - google.protobuf.FieldMask update_mask = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Required. Updated ClientTlsPolicy resource. - ClientTlsPolicy client_tls_policy = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request used by the DeleteClientTlsPolicy method. -message DeleteClientTlsPolicyRequest { - // Required. A name of the ClientTlsPolicy to delete. Must be in - // the format `projects/*/locations/{location}/clientTlsPolicies/*`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "networksecurity.googleapis.com/ClientTlsPolicy" - } - ]; -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/common.proto b/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/common.proto deleted file mode 100644 index 728b9b08945..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/common.proto +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.networksecurity.v1; - -import "google/api/field_behavior.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.NetworkSecurity.V1"; -option go_package = "cloud.google.com/go/networksecurity/apiv1/networksecuritypb;networksecuritypb"; -option java_multiple_files = true; -option java_outer_classname = "CommonProto"; -option java_package = "com.google.cloud.networksecurity.v1"; -option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1"; -option ruby_package = "Google::Cloud::NetworkSecurity::V1"; - -// Represents the metadata of the long-running operation. -message OperationMetadata { - // Output only. The time the operation was created. - google.protobuf.Timestamp create_time = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time the operation finished running. - google.protobuf.Timestamp end_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Server-defined resource path for the target of the operation. - string target = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Name of the verb executed by the operation. - string verb = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Human-readable status of the operation, if any. - string status_message = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Identifies whether the user has requested cancellation - // of the operation. Operations that have successfully been cancelled - // have [Operation.error][] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, - // corresponding to `Code.CANCELLED`. - bool requested_cancellation = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. API version used to start the operation. - string api_version = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/network_security.proto b/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/network_security.proto deleted file mode 100644 index a77d11f6b25..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/network_security.proto +++ /dev/null @@ -1,201 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.networksecurity.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/cloud/networksecurity/v1/authorization_policy.proto"; -import "google/cloud/networksecurity/v1/client_tls_policy.proto"; -import "google/cloud/networksecurity/v1/server_tls_policy.proto"; -import "google/longrunning/operations.proto"; - -option csharp_namespace = "Google.Cloud.NetworkSecurity.V1"; -option go_package = "cloud.google.com/go/networksecurity/apiv1/networksecuritypb;networksecuritypb"; -option java_multiple_files = true; -option java_package = "com.google.cloud.networksecurity.v1"; -option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1"; -option ruby_package = "Google::Cloud::NetworkSecurity::V1"; - -// Network Security API provides resources to configure authentication and -// authorization policies. Refer to per API resource documentation for more -// information. -service NetworkSecurity { - option (google.api.default_host) = "networksecurity.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Lists AuthorizationPolicies in a given project and location. - rpc ListAuthorizationPolicies(ListAuthorizationPoliciesRequest) returns (ListAuthorizationPoliciesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/authorizationPolicies" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets details of a single AuthorizationPolicy. - rpc GetAuthorizationPolicy(GetAuthorizationPolicyRequest) returns (AuthorizationPolicy) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/authorizationPolicies/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a new AuthorizationPolicy in a given project and location. - rpc CreateAuthorizationPolicy(CreateAuthorizationPolicyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/authorizationPolicies" - body: "authorization_policy" - }; - option (google.api.method_signature) = "parent,authorization_policy,authorization_policy_id"; - option (google.longrunning.operation_info) = { - response_type: "AuthorizationPolicy" - metadata_type: "google.cloud.networksecurity.v1.OperationMetadata" - }; - } - - // Updates the parameters of a single AuthorizationPolicy. - rpc UpdateAuthorizationPolicy(UpdateAuthorizationPolicyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1/{authorization_policy.name=projects/*/locations/*/authorizationPolicies/*}" - body: "authorization_policy" - }; - option (google.api.method_signature) = "authorization_policy,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "AuthorizationPolicy" - metadata_type: "google.cloud.networksecurity.v1.OperationMetadata" - }; - } - - // Deletes a single AuthorizationPolicy. - rpc DeleteAuthorizationPolicy(DeleteAuthorizationPolicyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/authorizationPolicies/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "google.cloud.networksecurity.v1.OperationMetadata" - }; - } - - // Lists ServerTlsPolicies in a given project and location. - rpc ListServerTlsPolicies(ListServerTlsPoliciesRequest) returns (ListServerTlsPoliciesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/serverTlsPolicies" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets details of a single ServerTlsPolicy. - rpc GetServerTlsPolicy(GetServerTlsPolicyRequest) returns (ServerTlsPolicy) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/serverTlsPolicies/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a new ServerTlsPolicy in a given project and location. - rpc CreateServerTlsPolicy(CreateServerTlsPolicyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/serverTlsPolicies" - body: "server_tls_policy" - }; - option (google.api.method_signature) = "parent,server_tls_policy,server_tls_policy_id"; - option (google.longrunning.operation_info) = { - response_type: "ServerTlsPolicy" - metadata_type: "google.cloud.networksecurity.v1.OperationMetadata" - }; - } - - // Updates the parameters of a single ServerTlsPolicy. - rpc UpdateServerTlsPolicy(UpdateServerTlsPolicyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1/{server_tls_policy.name=projects/*/locations/*/serverTlsPolicies/*}" - body: "server_tls_policy" - }; - option (google.api.method_signature) = "server_tls_policy,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "ServerTlsPolicy" - metadata_type: "google.cloud.networksecurity.v1.OperationMetadata" - }; - } - - // Deletes a single ServerTlsPolicy. - rpc DeleteServerTlsPolicy(DeleteServerTlsPolicyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/serverTlsPolicies/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "google.cloud.networksecurity.v1.OperationMetadata" - }; - } - - // Lists ClientTlsPolicies in a given project and location. - rpc ListClientTlsPolicies(ListClientTlsPoliciesRequest) returns (ListClientTlsPoliciesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/clientTlsPolicies" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets details of a single ClientTlsPolicy. - rpc GetClientTlsPolicy(GetClientTlsPolicyRequest) returns (ClientTlsPolicy) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/clientTlsPolicies/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a new ClientTlsPolicy in a given project and location. - rpc CreateClientTlsPolicy(CreateClientTlsPolicyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/clientTlsPolicies" - body: "client_tls_policy" - }; - option (google.api.method_signature) = "parent,client_tls_policy,client_tls_policy_id"; - option (google.longrunning.operation_info) = { - response_type: "ClientTlsPolicy" - metadata_type: "google.cloud.networksecurity.v1.OperationMetadata" - }; - } - - // Updates the parameters of a single ClientTlsPolicy. - rpc UpdateClientTlsPolicy(UpdateClientTlsPolicyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1/{client_tls_policy.name=projects/*/locations/*/clientTlsPolicies/*}" - body: "client_tls_policy" - }; - option (google.api.method_signature) = "client_tls_policy,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "ClientTlsPolicy" - metadata_type: "google.cloud.networksecurity.v1.OperationMetadata" - }; - } - - // Deletes a single ClientTlsPolicy. - rpc DeleteClientTlsPolicy(DeleteClientTlsPolicyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/clientTlsPolicies/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "google.cloud.networksecurity.v1.OperationMetadata" - }; - } -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/server_tls_policy.proto b/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/server_tls_policy.proto deleted file mode 100644 index c837d4a61f4..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/server_tls_policy.proto +++ /dev/null @@ -1,181 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.networksecurity.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/networksecurity/v1/tls.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.NetworkSecurity.V1"; -option go_package = "cloud.google.com/go/networksecurity/apiv1/networksecuritypb;networksecuritypb"; -option java_multiple_files = true; -option java_outer_classname = "ServerTlsPolicyProto"; -option java_package = "com.google.cloud.networksecurity.v1"; -option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1"; -option ruby_package = "Google::Cloud::NetworkSecurity::V1"; - -// ServerTlsPolicy is a resource that specifies how a server should authenticate -// incoming requests. This resource itself does not affect configuration unless -// it is attached to a target https proxy or endpoint config selector resource. -message ServerTlsPolicy { - option (google.api.resource) = { - type: "networksecurity.googleapis.com/ServerTlsPolicy" - pattern: "projects/{project}/locations/{location}/serverTlsPolicies/{server_tls_policy}" - }; - - // Specification of the MTLSPolicy. - message MTLSPolicy { - // - // Defines the mechanism to obtain the Certificate Authority certificate to - // validate the client certificate. - repeated ValidationCA client_validation_ca = 1; - } - - // Required. Name of the ServerTlsPolicy resource. It matches the pattern - // `projects/*/locations/{location}/serverTlsPolicies/{server_tls_policy}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Free-text description of the resource. - string description = 2; - - // Output only. The timestamp when the resource was created. - google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The timestamp when the resource was updated. - google.protobuf.Timestamp update_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Set of label tags associated with the resource. - map labels = 5; - - // - // Determines if server allows plaintext connections. If set to true, server - // allows plain text connections. By default, it is set to false. This setting - // is not exclusive of other encryption modes. For example, if `allow_open` - // and `mtls_policy` are set, server allows both plain text and mTLS - // connections. See documentation of other encryption modes to confirm - // compatibility. - // - // Consider using it if you wish to upgrade in place your deployment to TLS - // while having mixed TLS and non-TLS traffic reaching port :80. - bool allow_open = 6; - - // - // Defines a mechanism to provision server identity (public and private keys). - // Cannot be combined with `allow_open` as a permissive mode that allows both - // plain text and TLS is not supported. - CertificateProvider server_certificate = 7; - - // - // Defines a mechanism to provision peer validation certificates for peer to - // peer authentication (Mutual TLS - mTLS). If not specified, client - // certificate will not be requested. The connection is treated as TLS and not - // mTLS. If `allow_open` and `mtls_policy` are set, server allows both plain - // text and mTLS connections. - MTLSPolicy mtls_policy = 8; -} - -// Request used by the ListServerTlsPolicies method. -message ListServerTlsPoliciesRequest { - // Required. The project and location from which the ServerTlsPolicies should - // be listed, specified in the format `projects/*/locations/{location}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Maximum number of ServerTlsPolicies to return per call. - int32 page_size = 2; - - // The value returned by the last `ListServerTlsPoliciesResponse` - // Indicates that this is a continuation of a prior - // `ListServerTlsPolicies` call, and that the system - // should return the next page of data. - string page_token = 3; -} - -// Response returned by the ListServerTlsPolicies method. -message ListServerTlsPoliciesResponse { - // List of ServerTlsPolicy resources. - repeated ServerTlsPolicy server_tls_policies = 1; - - // If there might be more results than those appearing in this response, then - // `next_page_token` is included. To get the next set of results, call this - // method again using the value of `next_page_token` as `page_token`. - string next_page_token = 2; -} - -// Request used by the GetServerTlsPolicy method. -message GetServerTlsPolicyRequest { - // Required. A name of the ServerTlsPolicy to get. Must be in the format - // `projects/*/locations/{location}/serverTlsPolicies/*`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "networksecurity.googleapis.com/ServerTlsPolicy" - } - ]; -} - -// Request used by the CreateServerTlsPolicy method. -message CreateServerTlsPolicyRequest { - // Required. The parent resource of the ServerTlsPolicy. Must be in - // the format `projects/*/locations/{location}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "networksecurity.googleapis.com/ServerTlsPolicy" - } - ]; - - // Required. Short name of the ServerTlsPolicy resource to be created. This value should - // be 1-63 characters long, containing only letters, numbers, hyphens, and - // underscores, and should not start with a number. E.g. "server_mtls_policy". - string server_tls_policy_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. ServerTlsPolicy resource to be created. - ServerTlsPolicy server_tls_policy = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request used by UpdateServerTlsPolicy method. -message UpdateServerTlsPolicyRequest { - // Optional. Field mask is used to specify the fields to be overwritten in the - // ServerTlsPolicy resource by the update. The fields - // specified in the update_mask are relative to the resource, not - // the full request. A field will be overwritten if it is in the - // mask. If the user does not provide a mask then all fields will be - // overwritten. - google.protobuf.FieldMask update_mask = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Required. Updated ServerTlsPolicy resource. - ServerTlsPolicy server_tls_policy = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request used by the DeleteServerTlsPolicy method. -message DeleteServerTlsPolicyRequest { - // Required. A name of the ServerTlsPolicy to delete. Must be in - // the format `projects/*/locations/{location}/serverTlsPolicies/*`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "networksecurity.googleapis.com/ServerTlsPolicy" - } - ]; -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/tls.proto b/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/tls.proto deleted file mode 100644 index 2a82818593e..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/protos/google/cloud/networksecurity/v1/tls.proto +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.networksecurity.v1; - -import "google/api/field_behavior.proto"; - -option csharp_namespace = "Google.Cloud.NetworkSecurity.V1"; -option go_package = "cloud.google.com/go/networksecurity/apiv1/networksecuritypb;networksecuritypb"; -option java_multiple_files = true; -option java_outer_classname = "TlsProto"; -option java_package = "com.google.cloud.networksecurity.v1"; -option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1"; -option ruby_package = "Google::Cloud::NetworkSecurity::V1"; - -// Specification of the GRPC Endpoint. -message GrpcEndpoint { - // Required. The target URI of the gRPC endpoint. Only UDS path is supported, and - // should start with "unix:". - string target_uri = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Specification of ValidationCA. Defines the mechanism to obtain the -// Certificate Authority certificate to validate the peer certificate. -message ValidationCA { - // The type of certificate provider which provides the CA certificate. - oneof type { - // gRPC specific configuration to access the gRPC server to - // obtain the CA certificate. - GrpcEndpoint grpc_endpoint = 2; - - // The certificate provider instance specification that will be passed to - // the data plane, which will be used to load necessary credential - // information. - CertificateProviderInstance certificate_provider_instance = 3; - } -} - -// Specification of a TLS certificate provider instance. Workloads may have one -// or more CertificateProvider instances (plugins) and one of them is enabled -// and configured by specifying this message. Workloads use the values from this -// message to locate and load the CertificateProvider instance configuration. -message CertificateProviderInstance { - // Required. Plugin instance name, used to locate and load CertificateProvider instance - // configuration. Set to "google_cloud_private_spiffe" to use Certificate - // Authority Service certificate provider instance. - string plugin_instance = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Specification of certificate provider. Defines the mechanism to obtain the -// certificate and private key for peer to peer authentication. -message CertificateProvider { - // The type of certificate provider which provides the certificates and - // private keys. - oneof type { - // gRPC specific configuration to access the gRPC server to - // obtain the cert and private key. - GrpcEndpoint grpc_endpoint = 2; - - // The certificate provider instance specification that will be passed to - // the data plane, which will be used to load necessary credential - // information. - CertificateProviderInstance certificate_provider_instance = 3; - } -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_authorization_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_authorization_policy.js deleted file mode 100644 index e76bce8bd60..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_authorization_policy.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, authorizationPolicyId, authorizationPolicy) { - // [START networksecurity_v1_generated_NetworkSecurity_CreateAuthorizationPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 of the AuthorizationPolicy. Must be in the - * format `projects/{project}/locations/{location}`. - */ - // const parent = 'abc123' - /** - * Required. Short name of the AuthorizationPolicy resource to be created. - * This value should be 1-63 characters long, containing only - * letters, numbers, hyphens, and underscores, and should not start - * with a number. E.g. "authz_policy". - */ - // const authorizationPolicyId = 'abc123' - /** - * Required. AuthorizationPolicy resource to be created. - */ - // const authorizationPolicy = {} - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callCreateAuthorizationPolicy() { - // Construct request - const request = { - parent, - authorizationPolicyId, - authorizationPolicy, - }; - - // Run request - const [operation] = await networksecurityClient.createAuthorizationPolicy(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateAuthorizationPolicy(); - // [END networksecurity_v1_generated_NetworkSecurity_CreateAuthorizationPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_client_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_client_tls_policy.js deleted file mode 100644 index 900a9007bdc..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_client_tls_policy.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, clientTlsPolicyId, clientTlsPolicy) { - // [START networksecurity_v1_generated_NetworkSecurity_CreateClientTlsPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 of the ClientTlsPolicy. Must be in - * the format `projects/* /locations/{location}`. - */ - // const parent = 'abc123' - /** - * Required. Short name of the ClientTlsPolicy resource to be created. This value should - * be 1-63 characters long, containing only letters, numbers, hyphens, and - * underscores, and should not start with a number. E.g. "client_mtls_policy". - */ - // const clientTlsPolicyId = 'abc123' - /** - * Required. ClientTlsPolicy resource to be created. - */ - // const clientTlsPolicy = {} - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callCreateClientTlsPolicy() { - // Construct request - const request = { - parent, - clientTlsPolicyId, - clientTlsPolicy, - }; - - // Run request - const [operation] = await networksecurityClient.createClientTlsPolicy(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateClientTlsPolicy(); - // [END networksecurity_v1_generated_NetworkSecurity_CreateClientTlsPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_server_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_server_tls_policy.js deleted file mode 100644 index ba11efbdcfc..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.create_server_tls_policy.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, serverTlsPolicyId, serverTlsPolicy) { - // [START networksecurity_v1_generated_NetworkSecurity_CreateServerTlsPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 of the ServerTlsPolicy. Must be in - * the format `projects/* /locations/{location}`. - */ - // const parent = 'abc123' - /** - * Required. Short name of the ServerTlsPolicy resource to be created. This value should - * be 1-63 characters long, containing only letters, numbers, hyphens, and - * underscores, and should not start with a number. E.g. "server_mtls_policy". - */ - // const serverTlsPolicyId = 'abc123' - /** - * Required. ServerTlsPolicy resource to be created. - */ - // const serverTlsPolicy = {} - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callCreateServerTlsPolicy() { - // Construct request - const request = { - parent, - serverTlsPolicyId, - serverTlsPolicy, - }; - - // Run request - const [operation] = await networksecurityClient.createServerTlsPolicy(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateServerTlsPolicy(); - // [END networksecurity_v1_generated_NetworkSecurity_CreateServerTlsPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_authorization_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_authorization_policy.js deleted file mode 100644 index 3dcd0431ac9..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_authorization_policy.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 networksecurity_v1_generated_NetworkSecurity_DeleteAuthorizationPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A name of the AuthorizationPolicy to delete. Must be in the format - * `projects/{project}/locations/{location}/authorizationPolicies/*`. - */ - // const name = 'abc123' - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callDeleteAuthorizationPolicy() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await networksecurityClient.deleteAuthorizationPolicy(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteAuthorizationPolicy(); - // [END networksecurity_v1_generated_NetworkSecurity_DeleteAuthorizationPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_client_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_client_tls_policy.js deleted file mode 100644 index 9ece970e232..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_client_tls_policy.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 networksecurity_v1_generated_NetworkSecurity_DeleteClientTlsPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A name of the ClientTlsPolicy to delete. Must be in - * the format `projects/* /locations/{location}/clientTlsPolicies/*`. - */ - // const name = 'abc123' - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callDeleteClientTlsPolicy() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await networksecurityClient.deleteClientTlsPolicy(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteClientTlsPolicy(); - // [END networksecurity_v1_generated_NetworkSecurity_DeleteClientTlsPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_server_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_server_tls_policy.js deleted file mode 100644 index 2e2be0db04a..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.delete_server_tls_policy.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 networksecurity_v1_generated_NetworkSecurity_DeleteServerTlsPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A name of the ServerTlsPolicy to delete. Must be in - * the format `projects/* /locations/{location}/serverTlsPolicies/*`. - */ - // const name = 'abc123' - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callDeleteServerTlsPolicy() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await networksecurityClient.deleteServerTlsPolicy(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteServerTlsPolicy(); - // [END networksecurity_v1_generated_NetworkSecurity_DeleteServerTlsPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_authorization_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_authorization_policy.js deleted file mode 100644 index 991d4b08055..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_authorization_policy.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 networksecurity_v1_generated_NetworkSecurity_GetAuthorizationPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A name of the AuthorizationPolicy to get. Must be in the format - * `projects/{project}/locations/{location}/authorizationPolicies/*`. - */ - // const name = 'abc123' - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callGetAuthorizationPolicy() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await networksecurityClient.getAuthorizationPolicy(request); - console.log(response); - } - - callGetAuthorizationPolicy(); - // [END networksecurity_v1_generated_NetworkSecurity_GetAuthorizationPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_client_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_client_tls_policy.js deleted file mode 100644 index 7c73d75f68f..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_client_tls_policy.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 networksecurity_v1_generated_NetworkSecurity_GetClientTlsPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A name of the ClientTlsPolicy to get. Must be in the format - * `projects/* /locations/{location}/clientTlsPolicies/*`. - */ - // const name = 'abc123' - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callGetClientTlsPolicy() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await networksecurityClient.getClientTlsPolicy(request); - console.log(response); - } - - callGetClientTlsPolicy(); - // [END networksecurity_v1_generated_NetworkSecurity_GetClientTlsPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_server_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_server_tls_policy.js deleted file mode 100644 index 33054403c72..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.get_server_tls_policy.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 networksecurity_v1_generated_NetworkSecurity_GetServerTlsPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A name of the ServerTlsPolicy to get. Must be in the format - * `projects/* /locations/{location}/serverTlsPolicies/*`. - */ - // const name = 'abc123' - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callGetServerTlsPolicy() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await networksecurityClient.getServerTlsPolicy(request); - console.log(response); - } - - callGetServerTlsPolicy(); - // [END networksecurity_v1_generated_NetworkSecurity_GetServerTlsPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_authorization_policies.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_authorization_policies.js deleted file mode 100644 index e8f0b461843..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_authorization_policies.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) { - // [START networksecurity_v1_generated_NetworkSecurity_ListAuthorizationPolicies_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project and location from which the AuthorizationPolicies - * should be listed, specified in the format - * `projects/{project}/locations/{location}`. - */ - // const parent = 'abc123' - /** - * Maximum number of AuthorizationPolicies to return per call. - */ - // const pageSize = 1234 - /** - * The value returned by the last - * `ListAuthorizationPoliciesResponse` Indicates that this is a - * continuation of a prior `ListAuthorizationPolicies` call, and - * that the system should return the next page of data. - */ - // const pageToken = 'abc123' - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callListAuthorizationPolicies() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await networksecurityClient.listAuthorizationPoliciesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListAuthorizationPolicies(); - // [END networksecurity_v1_generated_NetworkSecurity_ListAuthorizationPolicies_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_client_tls_policies.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_client_tls_policies.js deleted file mode 100644 index fbc5b008e6b..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_client_tls_policies.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 networksecurity_v1_generated_NetworkSecurity_ListClientTlsPolicies_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project and location from which the ClientTlsPolicies should - * be listed, specified in the format `projects/* /locations/{location}`. - */ - // const parent = 'abc123' - /** - * Maximum number of ClientTlsPolicies to return per call. - */ - // const pageSize = 1234 - /** - * The value returned by the last `ListClientTlsPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListClientTlsPolicies` call, and that the system - * should return the next page of data. - */ - // const pageToken = 'abc123' - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callListClientTlsPolicies() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await networksecurityClient.listClientTlsPoliciesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListClientTlsPolicies(); - // [END networksecurity_v1_generated_NetworkSecurity_ListClientTlsPolicies_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_server_tls_policies.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_server_tls_policies.js deleted file mode 100644 index ca346255795..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.list_server_tls_policies.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 networksecurity_v1_generated_NetworkSecurity_ListServerTlsPolicies_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project and location from which the ServerTlsPolicies should - * be listed, specified in the format `projects/* /locations/{location}`. - */ - // const parent = 'abc123' - /** - * Maximum number of ServerTlsPolicies to return per call. - */ - // const pageSize = 1234 - /** - * The value returned by the last `ListServerTlsPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListServerTlsPolicies` call, and that the system - * should return the next page of data. - */ - // const pageToken = 'abc123' - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callListServerTlsPolicies() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await networksecurityClient.listServerTlsPoliciesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListServerTlsPolicies(); - // [END networksecurity_v1_generated_NetworkSecurity_ListServerTlsPolicies_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_authorization_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_authorization_policy.js deleted file mode 100644 index 218edc063d0..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_authorization_policy.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(authorizationPolicy) { - // [START networksecurity_v1_generated_NetworkSecurity_UpdateAuthorizationPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Optional. Field mask is used to specify the fields to be overwritten in the - * AuthorizationPolicy resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - */ - // const updateMask = {} - /** - * Required. Updated AuthorizationPolicy resource. - */ - // const authorizationPolicy = {} - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callUpdateAuthorizationPolicy() { - // Construct request - const request = { - authorizationPolicy, - }; - - // Run request - const [operation] = await networksecurityClient.updateAuthorizationPolicy(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateAuthorizationPolicy(); - // [END networksecurity_v1_generated_NetworkSecurity_UpdateAuthorizationPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_client_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_client_tls_policy.js deleted file mode 100644 index 9a75111060d..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_client_tls_policy.js +++ /dev/null @@ -1,71 +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(clientTlsPolicy) { - // [START networksecurity_v1_generated_NetworkSecurity_UpdateClientTlsPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Optional. Field mask is used to specify the fields to be overwritten in the - * ClientTlsPolicy resource by the update. The fields - * specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the - * mask. If the user does not provide a mask then all fields will be - * overwritten. - */ - // const updateMask = {} - /** - * Required. Updated ClientTlsPolicy resource. - */ - // const clientTlsPolicy = {} - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callUpdateClientTlsPolicy() { - // Construct request - const request = { - clientTlsPolicy, - }; - - // Run request - const [operation] = await networksecurityClient.updateClientTlsPolicy(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateClientTlsPolicy(); - // [END networksecurity_v1_generated_NetworkSecurity_UpdateClientTlsPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_server_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_server_tls_policy.js deleted file mode 100644 index 713f138f1af..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/network_security.update_server_tls_policy.js +++ /dev/null @@ -1,71 +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(serverTlsPolicy) { - // [START networksecurity_v1_generated_NetworkSecurity_UpdateServerTlsPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Optional. Field mask is used to specify the fields to be overwritten in the - * ServerTlsPolicy resource by the update. The fields - * specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the - * mask. If the user does not provide a mask then all fields will be - * overwritten. - */ - // const updateMask = {} - /** - * Required. Updated ServerTlsPolicy resource. - */ - // const serverTlsPolicy = {} - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/networksecurity').v1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callUpdateServerTlsPolicy() { - // Construct request - const request = { - serverTlsPolicy, - }; - - // Run request - const [operation] = await networksecurityClient.updateServerTlsPolicy(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateServerTlsPolicy(); - // [END networksecurity_v1_generated_NetworkSecurity_UpdateServerTlsPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/snippet_metadata_google.cloud.networksecurity.v1.json b/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/snippet_metadata_google.cloud.networksecurity.v1.json deleted file mode 100644 index ee181262eaa..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/samples/generated/v1/snippet_metadata_google.cloud.networksecurity.v1.json +++ /dev/null @@ -1,675 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-networksecurity", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.networksecurity.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "networksecurity_v1_generated_NetworkSecurity_ListAuthorizationPolicies_async", - "title": "NetworkSecurity listAuthorizationPolicies Sample", - "origin": "API_DEFINITION", - "description": " Lists AuthorizationPolicies in a given project and location.", - "canonical": true, - "file": "network_security.list_authorization_policies.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListAuthorizationPolicies", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.ListAuthorizationPolicies", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.networksecurity.v1.ListAuthorizationPoliciesResponse", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" - }, - "method": { - "shortName": "ListAuthorizationPolicies", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.ListAuthorizationPolicies", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1_generated_NetworkSecurity_GetAuthorizationPolicy_async", - "title": "NetworkSecurity getAuthorizationPolicy Sample", - "origin": "API_DEFINITION", - "description": " Gets details of a single AuthorizationPolicy.", - "canonical": true, - "file": "network_security.get_authorization_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetAuthorizationPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.GetAuthorizationPolicy", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.networksecurity.v1.AuthorizationPolicy", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" - }, - "method": { - "shortName": "GetAuthorizationPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.GetAuthorizationPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1_generated_NetworkSecurity_CreateAuthorizationPolicy_async", - "title": "NetworkSecurity createAuthorizationPolicy Sample", - "origin": "API_DEFINITION", - "description": " Creates a new AuthorizationPolicy in a given project and location.", - "canonical": true, - "file": "network_security.create_authorization_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateAuthorizationPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.CreateAuthorizationPolicy", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "authorization_policy_id", - "type": "TYPE_STRING" - }, - { - "name": "authorization_policy", - "type": ".google.cloud.networksecurity.v1.AuthorizationPolicy" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" - }, - "method": { - "shortName": "CreateAuthorizationPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.CreateAuthorizationPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1_generated_NetworkSecurity_UpdateAuthorizationPolicy_async", - "title": "NetworkSecurity updateAuthorizationPolicy Sample", - "origin": "API_DEFINITION", - "description": " Updates the parameters of a single AuthorizationPolicy.", - "canonical": true, - "file": "network_security.update_authorization_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateAuthorizationPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.UpdateAuthorizationPolicy", - "async": true, - "parameters": [ - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "authorization_policy", - "type": ".google.cloud.networksecurity.v1.AuthorizationPolicy" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" - }, - "method": { - "shortName": "UpdateAuthorizationPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.UpdateAuthorizationPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1_generated_NetworkSecurity_DeleteAuthorizationPolicy_async", - "title": "NetworkSecurity deleteAuthorizationPolicy Sample", - "origin": "API_DEFINITION", - "description": " Deletes a single AuthorizationPolicy.", - "canonical": true, - "file": "network_security.delete_authorization_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteAuthorizationPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.DeleteAuthorizationPolicy", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" - }, - "method": { - "shortName": "DeleteAuthorizationPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.DeleteAuthorizationPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1_generated_NetworkSecurity_ListServerTlsPolicies_async", - "title": "NetworkSecurity listServerTlsPolicies Sample", - "origin": "API_DEFINITION", - "description": " Lists ServerTlsPolicies in a given project and location.", - "canonical": true, - "file": "network_security.list_server_tls_policies.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListServerTlsPolicies", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.ListServerTlsPolicies", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.networksecurity.v1.ListServerTlsPoliciesResponse", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" - }, - "method": { - "shortName": "ListServerTlsPolicies", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.ListServerTlsPolicies", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1_generated_NetworkSecurity_GetServerTlsPolicy_async", - "title": "NetworkSecurity getServerTlsPolicy Sample", - "origin": "API_DEFINITION", - "description": " Gets details of a single ServerTlsPolicy.", - "canonical": true, - "file": "network_security.get_server_tls_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetServerTlsPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.GetServerTlsPolicy", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.networksecurity.v1.ServerTlsPolicy", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" - }, - "method": { - "shortName": "GetServerTlsPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.GetServerTlsPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1_generated_NetworkSecurity_CreateServerTlsPolicy_async", - "title": "NetworkSecurity createServerTlsPolicy Sample", - "origin": "API_DEFINITION", - "description": " Creates a new ServerTlsPolicy in a given project and location.", - "canonical": true, - "file": "network_security.create_server_tls_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateServerTlsPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.CreateServerTlsPolicy", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "server_tls_policy_id", - "type": "TYPE_STRING" - }, - { - "name": "server_tls_policy", - "type": ".google.cloud.networksecurity.v1.ServerTlsPolicy" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" - }, - "method": { - "shortName": "CreateServerTlsPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.CreateServerTlsPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1_generated_NetworkSecurity_UpdateServerTlsPolicy_async", - "title": "NetworkSecurity updateServerTlsPolicy Sample", - "origin": "API_DEFINITION", - "description": " Updates the parameters of a single ServerTlsPolicy.", - "canonical": true, - "file": "network_security.update_server_tls_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateServerTlsPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.UpdateServerTlsPolicy", - "async": true, - "parameters": [ - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "server_tls_policy", - "type": ".google.cloud.networksecurity.v1.ServerTlsPolicy" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" - }, - "method": { - "shortName": "UpdateServerTlsPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.UpdateServerTlsPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1_generated_NetworkSecurity_DeleteServerTlsPolicy_async", - "title": "NetworkSecurity deleteServerTlsPolicy Sample", - "origin": "API_DEFINITION", - "description": " Deletes a single ServerTlsPolicy.", - "canonical": true, - "file": "network_security.delete_server_tls_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteServerTlsPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.DeleteServerTlsPolicy", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" - }, - "method": { - "shortName": "DeleteServerTlsPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.DeleteServerTlsPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1_generated_NetworkSecurity_ListClientTlsPolicies_async", - "title": "NetworkSecurity listClientTlsPolicies Sample", - "origin": "API_DEFINITION", - "description": " Lists ClientTlsPolicies in a given project and location.", - "canonical": true, - "file": "network_security.list_client_tls_policies.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListClientTlsPolicies", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.ListClientTlsPolicies", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.networksecurity.v1.ListClientTlsPoliciesResponse", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" - }, - "method": { - "shortName": "ListClientTlsPolicies", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.ListClientTlsPolicies", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1_generated_NetworkSecurity_GetClientTlsPolicy_async", - "title": "NetworkSecurity getClientTlsPolicy Sample", - "origin": "API_DEFINITION", - "description": " Gets details of a single ClientTlsPolicy.", - "canonical": true, - "file": "network_security.get_client_tls_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetClientTlsPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.GetClientTlsPolicy", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.networksecurity.v1.ClientTlsPolicy", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" - }, - "method": { - "shortName": "GetClientTlsPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.GetClientTlsPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1_generated_NetworkSecurity_CreateClientTlsPolicy_async", - "title": "NetworkSecurity createClientTlsPolicy Sample", - "origin": "API_DEFINITION", - "description": " Creates a new ClientTlsPolicy in a given project and location.", - "canonical": true, - "file": "network_security.create_client_tls_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateClientTlsPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.CreateClientTlsPolicy", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "client_tls_policy_id", - "type": "TYPE_STRING" - }, - { - "name": "client_tls_policy", - "type": ".google.cloud.networksecurity.v1.ClientTlsPolicy" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" - }, - "method": { - "shortName": "CreateClientTlsPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.CreateClientTlsPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1_generated_NetworkSecurity_UpdateClientTlsPolicy_async", - "title": "NetworkSecurity updateClientTlsPolicy Sample", - "origin": "API_DEFINITION", - "description": " Updates the parameters of a single ClientTlsPolicy.", - "canonical": true, - "file": "network_security.update_client_tls_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateClientTlsPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.UpdateClientTlsPolicy", - "async": true, - "parameters": [ - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "client_tls_policy", - "type": ".google.cloud.networksecurity.v1.ClientTlsPolicy" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" - }, - "method": { - "shortName": "UpdateClientTlsPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.UpdateClientTlsPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1_generated_NetworkSecurity_DeleteClientTlsPolicy_async", - "title": "NetworkSecurity deleteClientTlsPolicy Sample", - "origin": "API_DEFINITION", - "description": " Deletes a single ClientTlsPolicy.", - "canonical": true, - "file": "network_security.delete_client_tls_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteClientTlsPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.DeleteClientTlsPolicy", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurityClient" - }, - "method": { - "shortName": "DeleteClientTlsPolicy", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity.DeleteClientTlsPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1.NetworkSecurity" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/src/index.ts b/owl-bot-staging/google-cloud-networksecurity/v1/src/index.ts deleted file mode 100644 index 67aad02cedc..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/src/index.ts +++ /dev/null @@ -1,25 +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 v1 from './v1'; -const NetworkSecurityClient = v1.NetworkSecurityClient; -type NetworkSecurityClient = v1.NetworkSecurityClient; -export {v1, NetworkSecurityClient}; -export default {v1, NetworkSecurityClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/gapic_metadata.json deleted file mode 100644 index af9154fe63b..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,185 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.networksecurity.v1", - "libraryPackage": "@google-cloud/networksecurity", - "services": { - "NetworkSecurity": { - "clients": { - "grpc": { - "libraryClient": "NetworkSecurityClient", - "rpcs": { - "GetAuthorizationPolicy": { - "methods": [ - "getAuthorizationPolicy" - ] - }, - "GetServerTlsPolicy": { - "methods": [ - "getServerTlsPolicy" - ] - }, - "GetClientTlsPolicy": { - "methods": [ - "getClientTlsPolicy" - ] - }, - "CreateAuthorizationPolicy": { - "methods": [ - "createAuthorizationPolicy" - ] - }, - "UpdateAuthorizationPolicy": { - "methods": [ - "updateAuthorizationPolicy" - ] - }, - "DeleteAuthorizationPolicy": { - "methods": [ - "deleteAuthorizationPolicy" - ] - }, - "CreateServerTlsPolicy": { - "methods": [ - "createServerTlsPolicy" - ] - }, - "UpdateServerTlsPolicy": { - "methods": [ - "updateServerTlsPolicy" - ] - }, - "DeleteServerTlsPolicy": { - "methods": [ - "deleteServerTlsPolicy" - ] - }, - "CreateClientTlsPolicy": { - "methods": [ - "createClientTlsPolicy" - ] - }, - "UpdateClientTlsPolicy": { - "methods": [ - "updateClientTlsPolicy" - ] - }, - "DeleteClientTlsPolicy": { - "methods": [ - "deleteClientTlsPolicy" - ] - }, - "ListAuthorizationPolicies": { - "methods": [ - "listAuthorizationPolicies", - "listAuthorizationPoliciesStream", - "listAuthorizationPoliciesAsync" - ] - }, - "ListServerTlsPolicies": { - "methods": [ - "listServerTlsPolicies", - "listServerTlsPoliciesStream", - "listServerTlsPoliciesAsync" - ] - }, - "ListClientTlsPolicies": { - "methods": [ - "listClientTlsPolicies", - "listClientTlsPoliciesStream", - "listClientTlsPoliciesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "NetworkSecurityClient", - "rpcs": { - "GetAuthorizationPolicy": { - "methods": [ - "getAuthorizationPolicy" - ] - }, - "GetServerTlsPolicy": { - "methods": [ - "getServerTlsPolicy" - ] - }, - "GetClientTlsPolicy": { - "methods": [ - "getClientTlsPolicy" - ] - }, - "CreateAuthorizationPolicy": { - "methods": [ - "createAuthorizationPolicy" - ] - }, - "UpdateAuthorizationPolicy": { - "methods": [ - "updateAuthorizationPolicy" - ] - }, - "DeleteAuthorizationPolicy": { - "methods": [ - "deleteAuthorizationPolicy" - ] - }, - "CreateServerTlsPolicy": { - "methods": [ - "createServerTlsPolicy" - ] - }, - "UpdateServerTlsPolicy": { - "methods": [ - "updateServerTlsPolicy" - ] - }, - "DeleteServerTlsPolicy": { - "methods": [ - "deleteServerTlsPolicy" - ] - }, - "CreateClientTlsPolicy": { - "methods": [ - "createClientTlsPolicy" - ] - }, - "UpdateClientTlsPolicy": { - "methods": [ - "updateClientTlsPolicy" - ] - }, - "DeleteClientTlsPolicy": { - "methods": [ - "deleteClientTlsPolicy" - ] - }, - "ListAuthorizationPolicies": { - "methods": [ - "listAuthorizationPolicies", - "listAuthorizationPoliciesStream", - "listAuthorizationPoliciesAsync" - ] - }, - "ListServerTlsPolicies": { - "methods": [ - "listServerTlsPolicies", - "listServerTlsPoliciesStream", - "listServerTlsPoliciesAsync" - ] - }, - "ListClientTlsPolicies": { - "methods": [ - "listClientTlsPolicies", - "listClientTlsPoliciesStream", - "listClientTlsPoliciesAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/index.ts deleted file mode 100644 index e2b4efdd9b3..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +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 {NetworkSecurityClient} from './network_security_client'; diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_client.ts b/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_client.ts deleted file mode 100644 index d4576d88671..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_client.ts +++ /dev/null @@ -1,2592 +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, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/network_security_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './network_security_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Network Security API provides resources to configure authentication and - * authorization policies. Refer to per API resource documentation for more - * information. - * @class - * @memberof v1 - */ -export class NetworkSecurityClient { - 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}; - iamClient: IamClient; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - networkSecurityStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of NetworkSecurityClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 NetworkSecurityClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof NetworkSecurityClient; - 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.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - - 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 { - 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 = { - authorizationPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/authorizationPolicies/{authorization_policy}' - ), - clientTlsPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/clientTlsPolicies/{client_tls_policy}' - ), - serverTlsPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serverTlsPolicies/{server_tls_policy}' - ), - }; - - // 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 = { - listAuthorizationPolicies: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'authorizationPolicies'), - listServerTlsPolicies: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'serverTlsPolicies'), - listClientTlsPolicies: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'clientTlsPolicies') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/*/authorizationPolicies/*}:getIamPolicy',additional_bindings: [{get: '/v1/{resource=projects/*/locations/*/serverTlsPolicies/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/clientTlsPolicies/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/*/authorizationPolicies/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/serverTlsPolicies/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/clientTlsPolicies/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/*/authorizationPolicies/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/serverTlsPolicies/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/clientTlsPolicies/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createAuthorizationPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1.AuthorizationPolicy') as gax.protobuf.Type; - const createAuthorizationPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1.OperationMetadata') as gax.protobuf.Type; - const updateAuthorizationPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1.AuthorizationPolicy') as gax.protobuf.Type; - const updateAuthorizationPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1.OperationMetadata') as gax.protobuf.Type; - const deleteAuthorizationPolicyResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteAuthorizationPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1.OperationMetadata') as gax.protobuf.Type; - const createServerTlsPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1.ServerTlsPolicy') as gax.protobuf.Type; - const createServerTlsPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1.OperationMetadata') as gax.protobuf.Type; - const updateServerTlsPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1.ServerTlsPolicy') as gax.protobuf.Type; - const updateServerTlsPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1.OperationMetadata') as gax.protobuf.Type; - const deleteServerTlsPolicyResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteServerTlsPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1.OperationMetadata') as gax.protobuf.Type; - const createClientTlsPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1.ClientTlsPolicy') as gax.protobuf.Type; - const createClientTlsPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1.OperationMetadata') as gax.protobuf.Type; - const updateClientTlsPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1.ClientTlsPolicy') as gax.protobuf.Type; - const updateClientTlsPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1.OperationMetadata') as gax.protobuf.Type; - const deleteClientTlsPolicyResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteClientTlsPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createAuthorizationPolicy: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createAuthorizationPolicyResponse.decode.bind(createAuthorizationPolicyResponse), - createAuthorizationPolicyMetadata.decode.bind(createAuthorizationPolicyMetadata)), - updateAuthorizationPolicy: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateAuthorizationPolicyResponse.decode.bind(updateAuthorizationPolicyResponse), - updateAuthorizationPolicyMetadata.decode.bind(updateAuthorizationPolicyMetadata)), - deleteAuthorizationPolicy: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteAuthorizationPolicyResponse.decode.bind(deleteAuthorizationPolicyResponse), - deleteAuthorizationPolicyMetadata.decode.bind(deleteAuthorizationPolicyMetadata)), - createServerTlsPolicy: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createServerTlsPolicyResponse.decode.bind(createServerTlsPolicyResponse), - createServerTlsPolicyMetadata.decode.bind(createServerTlsPolicyMetadata)), - updateServerTlsPolicy: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateServerTlsPolicyResponse.decode.bind(updateServerTlsPolicyResponse), - updateServerTlsPolicyMetadata.decode.bind(updateServerTlsPolicyMetadata)), - deleteServerTlsPolicy: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteServerTlsPolicyResponse.decode.bind(deleteServerTlsPolicyResponse), - deleteServerTlsPolicyMetadata.decode.bind(deleteServerTlsPolicyMetadata)), - createClientTlsPolicy: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createClientTlsPolicyResponse.decode.bind(createClientTlsPolicyResponse), - createClientTlsPolicyMetadata.decode.bind(createClientTlsPolicyMetadata)), - updateClientTlsPolicy: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateClientTlsPolicyResponse.decode.bind(updateClientTlsPolicyResponse), - updateClientTlsPolicyMetadata.decode.bind(updateClientTlsPolicyMetadata)), - deleteClientTlsPolicy: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteClientTlsPolicyResponse.decode.bind(deleteClientTlsPolicyResponse), - deleteClientTlsPolicyMetadata.decode.bind(deleteClientTlsPolicyMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networksecurity.v1.NetworkSecurity', 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.networkSecurityStub) { - return this.networkSecurityStub; - } - - // Put together the "service stub" for - // google.cloud.networksecurity.v1.NetworkSecurity. - this.networkSecurityStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networksecurity.v1.NetworkSecurity') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.networksecurity.v1.NetworkSecurity, - 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 networkSecurityStubMethods = - ['listAuthorizationPolicies', 'getAuthorizationPolicy', 'createAuthorizationPolicy', 'updateAuthorizationPolicy', 'deleteAuthorizationPolicy', 'listServerTlsPolicies', 'getServerTlsPolicy', 'createServerTlsPolicy', 'updateServerTlsPolicy', 'deleteServerTlsPolicy', 'listClientTlsPolicies', 'getClientTlsPolicy', 'createClientTlsPolicy', 'updateClientTlsPolicy', 'deleteClientTlsPolicy']; - for (const methodName of networkSecurityStubMethods) { - const callPromise = this.networkSecurityStub.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.networkSecurityStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'networksecurity.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 'networksecurity.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 details of a single AuthorizationPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the AuthorizationPolicy to get. Must be in the format - * `projects/{project}/locations/{location}/authorizationPolicies/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.networksecurity.v1.AuthorizationPolicy|AuthorizationPolicy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.get_authorization_policy.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_GetAuthorizationPolicy_async - */ - getAuthorizationPolicy( - request?: protos.google.cloud.networksecurity.v1.IGetAuthorizationPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networksecurity.v1.IAuthorizationPolicy, - protos.google.cloud.networksecurity.v1.IGetAuthorizationPolicyRequest|undefined, {}|undefined - ]>; - getAuthorizationPolicy( - request: protos.google.cloud.networksecurity.v1.IGetAuthorizationPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networksecurity.v1.IAuthorizationPolicy, - protos.google.cloud.networksecurity.v1.IGetAuthorizationPolicyRequest|null|undefined, - {}|null|undefined>): void; - getAuthorizationPolicy( - request: protos.google.cloud.networksecurity.v1.IGetAuthorizationPolicyRequest, - callback: Callback< - protos.google.cloud.networksecurity.v1.IAuthorizationPolicy, - protos.google.cloud.networksecurity.v1.IGetAuthorizationPolicyRequest|null|undefined, - {}|null|undefined>): void; - getAuthorizationPolicy( - request?: protos.google.cloud.networksecurity.v1.IGetAuthorizationPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networksecurity.v1.IAuthorizationPolicy, - protos.google.cloud.networksecurity.v1.IGetAuthorizationPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.networksecurity.v1.IAuthorizationPolicy, - protos.google.cloud.networksecurity.v1.IGetAuthorizationPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networksecurity.v1.IAuthorizationPolicy, - protos.google.cloud.networksecurity.v1.IGetAuthorizationPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getAuthorizationPolicy(request, options, callback); - } -/** - * Gets details of a single ServerTlsPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the ServerTlsPolicy to get. Must be in the format - * `projects/* /locations/{location}/serverTlsPolicies/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.networksecurity.v1.ServerTlsPolicy|ServerTlsPolicy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.get_server_tls_policy.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_GetServerTlsPolicy_async - */ - getServerTlsPolicy( - request?: protos.google.cloud.networksecurity.v1.IGetServerTlsPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networksecurity.v1.IServerTlsPolicy, - protos.google.cloud.networksecurity.v1.IGetServerTlsPolicyRequest|undefined, {}|undefined - ]>; - getServerTlsPolicy( - request: protos.google.cloud.networksecurity.v1.IGetServerTlsPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networksecurity.v1.IServerTlsPolicy, - protos.google.cloud.networksecurity.v1.IGetServerTlsPolicyRequest|null|undefined, - {}|null|undefined>): void; - getServerTlsPolicy( - request: protos.google.cloud.networksecurity.v1.IGetServerTlsPolicyRequest, - callback: Callback< - protos.google.cloud.networksecurity.v1.IServerTlsPolicy, - protos.google.cloud.networksecurity.v1.IGetServerTlsPolicyRequest|null|undefined, - {}|null|undefined>): void; - getServerTlsPolicy( - request?: protos.google.cloud.networksecurity.v1.IGetServerTlsPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networksecurity.v1.IServerTlsPolicy, - protos.google.cloud.networksecurity.v1.IGetServerTlsPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.networksecurity.v1.IServerTlsPolicy, - protos.google.cloud.networksecurity.v1.IGetServerTlsPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networksecurity.v1.IServerTlsPolicy, - protos.google.cloud.networksecurity.v1.IGetServerTlsPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getServerTlsPolicy(request, options, callback); - } -/** - * Gets details of a single ClientTlsPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the ClientTlsPolicy to get. Must be in the format - * `projects/* /locations/{location}/clientTlsPolicies/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.networksecurity.v1.ClientTlsPolicy|ClientTlsPolicy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.get_client_tls_policy.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_GetClientTlsPolicy_async - */ - getClientTlsPolicy( - request?: protos.google.cloud.networksecurity.v1.IGetClientTlsPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networksecurity.v1.IClientTlsPolicy, - protos.google.cloud.networksecurity.v1.IGetClientTlsPolicyRequest|undefined, {}|undefined - ]>; - getClientTlsPolicy( - request: protos.google.cloud.networksecurity.v1.IGetClientTlsPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networksecurity.v1.IClientTlsPolicy, - protos.google.cloud.networksecurity.v1.IGetClientTlsPolicyRequest|null|undefined, - {}|null|undefined>): void; - getClientTlsPolicy( - request: protos.google.cloud.networksecurity.v1.IGetClientTlsPolicyRequest, - callback: Callback< - protos.google.cloud.networksecurity.v1.IClientTlsPolicy, - protos.google.cloud.networksecurity.v1.IGetClientTlsPolicyRequest|null|undefined, - {}|null|undefined>): void; - getClientTlsPolicy( - request?: protos.google.cloud.networksecurity.v1.IGetClientTlsPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networksecurity.v1.IClientTlsPolicy, - protos.google.cloud.networksecurity.v1.IGetClientTlsPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.networksecurity.v1.IClientTlsPolicy, - protos.google.cloud.networksecurity.v1.IGetClientTlsPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networksecurity.v1.IClientTlsPolicy, - protos.google.cloud.networksecurity.v1.IGetClientTlsPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getClientTlsPolicy(request, options, callback); - } - -/** - * Creates a new AuthorizationPolicy in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the AuthorizationPolicy. Must be in the - * format `projects/{project}/locations/{location}`. - * @param {string} request.authorizationPolicyId - * Required. Short name of the AuthorizationPolicy resource to be created. - * This value should be 1-63 characters long, containing only - * letters, numbers, hyphens, and underscores, and should not start - * with a number. E.g. "authz_policy". - * @param {google.cloud.networksecurity.v1.AuthorizationPolicy} request.authorizationPolicy - * Required. AuthorizationPolicy resource to be created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.create_authorization_policy.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_CreateAuthorizationPolicy_async - */ - createAuthorizationPolicy( - request?: protos.google.cloud.networksecurity.v1.ICreateAuthorizationPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createAuthorizationPolicy( - request: protos.google.cloud.networksecurity.v1.ICreateAuthorizationPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createAuthorizationPolicy( - request: protos.google.cloud.networksecurity.v1.ICreateAuthorizationPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createAuthorizationPolicy( - request?: protos.google.cloud.networksecurity.v1.ICreateAuthorizationPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createAuthorizationPolicy(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createAuthorizationPolicy()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.create_authorization_policy.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_CreateAuthorizationPolicy_async - */ - async checkCreateAuthorizationPolicyProgress(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.createAuthorizationPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the parameters of a single AuthorizationPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * AuthorizationPolicy resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.networksecurity.v1.AuthorizationPolicy} request.authorizationPolicy - * Required. Updated AuthorizationPolicy resource. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.update_authorization_policy.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_UpdateAuthorizationPolicy_async - */ - updateAuthorizationPolicy( - request?: protos.google.cloud.networksecurity.v1.IUpdateAuthorizationPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateAuthorizationPolicy( - request: protos.google.cloud.networksecurity.v1.IUpdateAuthorizationPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateAuthorizationPolicy( - request: protos.google.cloud.networksecurity.v1.IUpdateAuthorizationPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateAuthorizationPolicy( - request?: protos.google.cloud.networksecurity.v1.IUpdateAuthorizationPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'authorization_policy.name': request.authorizationPolicy!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateAuthorizationPolicy(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateAuthorizationPolicy()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.update_authorization_policy.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_UpdateAuthorizationPolicy_async - */ - async checkUpdateAuthorizationPolicyProgress(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.updateAuthorizationPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a single AuthorizationPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the AuthorizationPolicy to delete. Must be in the format - * `projects/{project}/locations/{location}/authorizationPolicies/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.delete_authorization_policy.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_DeleteAuthorizationPolicy_async - */ - deleteAuthorizationPolicy( - request?: protos.google.cloud.networksecurity.v1.IDeleteAuthorizationPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteAuthorizationPolicy( - request: protos.google.cloud.networksecurity.v1.IDeleteAuthorizationPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteAuthorizationPolicy( - request: protos.google.cloud.networksecurity.v1.IDeleteAuthorizationPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteAuthorizationPolicy( - request?: protos.google.cloud.networksecurity.v1.IDeleteAuthorizationPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteAuthorizationPolicy(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteAuthorizationPolicy()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.delete_authorization_policy.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_DeleteAuthorizationPolicy_async - */ - async checkDeleteAuthorizationPolicyProgress(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.deleteAuthorizationPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Creates a new ServerTlsPolicy in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the ServerTlsPolicy. Must be in - * the format `projects/* /locations/{location}`. - * @param {string} request.serverTlsPolicyId - * Required. Short name of the ServerTlsPolicy resource to be created. This value should - * be 1-63 characters long, containing only letters, numbers, hyphens, and - * underscores, and should not start with a number. E.g. "server_mtls_policy". - * @param {google.cloud.networksecurity.v1.ServerTlsPolicy} request.serverTlsPolicy - * Required. ServerTlsPolicy resource to be created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.create_server_tls_policy.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_CreateServerTlsPolicy_async - */ - createServerTlsPolicy( - request?: protos.google.cloud.networksecurity.v1.ICreateServerTlsPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createServerTlsPolicy( - request: protos.google.cloud.networksecurity.v1.ICreateServerTlsPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createServerTlsPolicy( - request: protos.google.cloud.networksecurity.v1.ICreateServerTlsPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createServerTlsPolicy( - request?: protos.google.cloud.networksecurity.v1.ICreateServerTlsPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createServerTlsPolicy(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createServerTlsPolicy()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.create_server_tls_policy.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_CreateServerTlsPolicy_async - */ - async checkCreateServerTlsPolicyProgress(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.createServerTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the parameters of a single ServerTlsPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * ServerTlsPolicy resource by the update. The fields - * specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the - * mask. If the user does not provide a mask then all fields will be - * overwritten. - * @param {google.cloud.networksecurity.v1.ServerTlsPolicy} request.serverTlsPolicy - * Required. Updated ServerTlsPolicy resource. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.update_server_tls_policy.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_UpdateServerTlsPolicy_async - */ - updateServerTlsPolicy( - request?: protos.google.cloud.networksecurity.v1.IUpdateServerTlsPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateServerTlsPolicy( - request: protos.google.cloud.networksecurity.v1.IUpdateServerTlsPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateServerTlsPolicy( - request: protos.google.cloud.networksecurity.v1.IUpdateServerTlsPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateServerTlsPolicy( - request?: protos.google.cloud.networksecurity.v1.IUpdateServerTlsPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'server_tls_policy.name': request.serverTlsPolicy!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateServerTlsPolicy(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateServerTlsPolicy()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.update_server_tls_policy.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_UpdateServerTlsPolicy_async - */ - async checkUpdateServerTlsPolicyProgress(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.updateServerTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a single ServerTlsPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the ServerTlsPolicy to delete. Must be in - * the format `projects/* /locations/{location}/serverTlsPolicies/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.delete_server_tls_policy.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_DeleteServerTlsPolicy_async - */ - deleteServerTlsPolicy( - request?: protos.google.cloud.networksecurity.v1.IDeleteServerTlsPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteServerTlsPolicy( - request: protos.google.cloud.networksecurity.v1.IDeleteServerTlsPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteServerTlsPolicy( - request: protos.google.cloud.networksecurity.v1.IDeleteServerTlsPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteServerTlsPolicy( - request?: protos.google.cloud.networksecurity.v1.IDeleteServerTlsPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteServerTlsPolicy(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteServerTlsPolicy()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.delete_server_tls_policy.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_DeleteServerTlsPolicy_async - */ - async checkDeleteServerTlsPolicyProgress(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.deleteServerTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Creates a new ClientTlsPolicy in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the ClientTlsPolicy. Must be in - * the format `projects/* /locations/{location}`. - * @param {string} request.clientTlsPolicyId - * Required. Short name of the ClientTlsPolicy resource to be created. This value should - * be 1-63 characters long, containing only letters, numbers, hyphens, and - * underscores, and should not start with a number. E.g. "client_mtls_policy". - * @param {google.cloud.networksecurity.v1.ClientTlsPolicy} request.clientTlsPolicy - * Required. ClientTlsPolicy resource to be created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.create_client_tls_policy.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_CreateClientTlsPolicy_async - */ - createClientTlsPolicy( - request?: protos.google.cloud.networksecurity.v1.ICreateClientTlsPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createClientTlsPolicy( - request: protos.google.cloud.networksecurity.v1.ICreateClientTlsPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createClientTlsPolicy( - request: protos.google.cloud.networksecurity.v1.ICreateClientTlsPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createClientTlsPolicy( - request?: protos.google.cloud.networksecurity.v1.ICreateClientTlsPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createClientTlsPolicy(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createClientTlsPolicy()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.create_client_tls_policy.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_CreateClientTlsPolicy_async - */ - async checkCreateClientTlsPolicyProgress(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.createClientTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the parameters of a single ClientTlsPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * ClientTlsPolicy resource by the update. The fields - * specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the - * mask. If the user does not provide a mask then all fields will be - * overwritten. - * @param {google.cloud.networksecurity.v1.ClientTlsPolicy} request.clientTlsPolicy - * Required. Updated ClientTlsPolicy resource. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.update_client_tls_policy.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_UpdateClientTlsPolicy_async - */ - updateClientTlsPolicy( - request?: protos.google.cloud.networksecurity.v1.IUpdateClientTlsPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateClientTlsPolicy( - request: protos.google.cloud.networksecurity.v1.IUpdateClientTlsPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateClientTlsPolicy( - request: protos.google.cloud.networksecurity.v1.IUpdateClientTlsPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateClientTlsPolicy( - request?: protos.google.cloud.networksecurity.v1.IUpdateClientTlsPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'client_tls_policy.name': request.clientTlsPolicy!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateClientTlsPolicy(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateClientTlsPolicy()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.update_client_tls_policy.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_UpdateClientTlsPolicy_async - */ - async checkUpdateClientTlsPolicyProgress(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.updateClientTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a single ClientTlsPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the ClientTlsPolicy to delete. Must be in - * the format `projects/* /locations/{location}/clientTlsPolicies/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.delete_client_tls_policy.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_DeleteClientTlsPolicy_async - */ - deleteClientTlsPolicy( - request?: protos.google.cloud.networksecurity.v1.IDeleteClientTlsPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteClientTlsPolicy( - request: protos.google.cloud.networksecurity.v1.IDeleteClientTlsPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteClientTlsPolicy( - request: protos.google.cloud.networksecurity.v1.IDeleteClientTlsPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteClientTlsPolicy( - request?: protos.google.cloud.networksecurity.v1.IDeleteClientTlsPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteClientTlsPolicy(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteClientTlsPolicy()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.delete_client_tls_policy.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_DeleteClientTlsPolicy_async - */ - async checkDeleteClientTlsPolicyProgress(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.deleteClientTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists AuthorizationPolicies in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the AuthorizationPolicies - * should be listed, specified in the format - * `projects/{project}/locations/{location}`. - * @param {number} request.pageSize - * Maximum number of AuthorizationPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last - * `ListAuthorizationPoliciesResponse` Indicates that this is a - * continuation of a prior `ListAuthorizationPolicies` call, and - * that the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.networksecurity.v1.AuthorizationPolicy|AuthorizationPolicy}. - * 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 `listAuthorizationPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listAuthorizationPolicies( - request?: protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networksecurity.v1.IAuthorizationPolicy[], - protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest|null, - protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesResponse - ]>; - listAuthorizationPolicies( - request: protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest, - protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1.IAuthorizationPolicy>): void; - listAuthorizationPolicies( - request: protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest, - callback: PaginationCallback< - protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest, - protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1.IAuthorizationPolicy>): void; - listAuthorizationPolicies( - request?: protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest, - protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1.IAuthorizationPolicy>, - callback?: PaginationCallback< - protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest, - protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1.IAuthorizationPolicy>): - Promise<[ - protos.google.cloud.networksecurity.v1.IAuthorizationPolicy[], - protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest|null, - protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listAuthorizationPolicies(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the AuthorizationPolicies - * should be listed, specified in the format - * `projects/{project}/locations/{location}`. - * @param {number} request.pageSize - * Maximum number of AuthorizationPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last - * `ListAuthorizationPoliciesResponse` Indicates that this is a - * continuation of a prior `ListAuthorizationPolicies` call, and - * that the system should return the next page of data. - * @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 protos.google.cloud.networksecurity.v1.AuthorizationPolicy|AuthorizationPolicy} 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 `listAuthorizationPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listAuthorizationPoliciesStream( - request?: protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest, - 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['listAuthorizationPolicies']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listAuthorizationPolicies.createStream( - this.innerApiCalls.listAuthorizationPolicies as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listAuthorizationPolicies`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the AuthorizationPolicies - * should be listed, specified in the format - * `projects/{project}/locations/{location}`. - * @param {number} request.pageSize - * Maximum number of AuthorizationPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last - * `ListAuthorizationPoliciesResponse` Indicates that this is a - * continuation of a prior `ListAuthorizationPolicies` call, and - * that the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networksecurity.v1.AuthorizationPolicy|AuthorizationPolicy}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.list_authorization_policies.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_ListAuthorizationPolicies_async - */ - listAuthorizationPoliciesAsync( - request?: protos.google.cloud.networksecurity.v1.IListAuthorizationPoliciesRequest, - 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['listAuthorizationPolicies']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listAuthorizationPolicies.asyncIterate( - this.innerApiCalls['listAuthorizationPolicies'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists ServerTlsPolicies in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the ServerTlsPolicies should - * be listed, specified in the format `projects/* /locations/{location}`. - * @param {number} request.pageSize - * Maximum number of ServerTlsPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListServerTlsPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListServerTlsPolicies` call, and that the system - * should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.networksecurity.v1.ServerTlsPolicy|ServerTlsPolicy}. - * 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 `listServerTlsPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listServerTlsPolicies( - request?: protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networksecurity.v1.IServerTlsPolicy[], - protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest|null, - protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesResponse - ]>; - listServerTlsPolicies( - request: protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest, - protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1.IServerTlsPolicy>): void; - listServerTlsPolicies( - request: protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest, - callback: PaginationCallback< - protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest, - protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1.IServerTlsPolicy>): void; - listServerTlsPolicies( - request?: protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest, - protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1.IServerTlsPolicy>, - callback?: PaginationCallback< - protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest, - protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1.IServerTlsPolicy>): - Promise<[ - protos.google.cloud.networksecurity.v1.IServerTlsPolicy[], - protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest|null, - protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listServerTlsPolicies(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the ServerTlsPolicies should - * be listed, specified in the format `projects/* /locations/{location}`. - * @param {number} request.pageSize - * Maximum number of ServerTlsPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListServerTlsPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListServerTlsPolicies` call, and that the system - * should return the next page of data. - * @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 protos.google.cloud.networksecurity.v1.ServerTlsPolicy|ServerTlsPolicy} 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 `listServerTlsPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listServerTlsPoliciesStream( - request?: protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest, - 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['listServerTlsPolicies']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServerTlsPolicies.createStream( - this.innerApiCalls.listServerTlsPolicies as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listServerTlsPolicies`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the ServerTlsPolicies should - * be listed, specified in the format `projects/* /locations/{location}`. - * @param {number} request.pageSize - * Maximum number of ServerTlsPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListServerTlsPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListServerTlsPolicies` call, and that the system - * should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networksecurity.v1.ServerTlsPolicy|ServerTlsPolicy}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.list_server_tls_policies.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_ListServerTlsPolicies_async - */ - listServerTlsPoliciesAsync( - request?: protos.google.cloud.networksecurity.v1.IListServerTlsPoliciesRequest, - 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['listServerTlsPolicies']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServerTlsPolicies.asyncIterate( - this.innerApiCalls['listServerTlsPolicies'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists ClientTlsPolicies in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the ClientTlsPolicies should - * be listed, specified in the format `projects/* /locations/{location}`. - * @param {number} request.pageSize - * Maximum number of ClientTlsPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListClientTlsPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListClientTlsPolicies` call, and that the system - * should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.networksecurity.v1.ClientTlsPolicy|ClientTlsPolicy}. - * 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 `listClientTlsPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listClientTlsPolicies( - request?: protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networksecurity.v1.IClientTlsPolicy[], - protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest|null, - protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesResponse - ]>; - listClientTlsPolicies( - request: protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest, - protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1.IClientTlsPolicy>): void; - listClientTlsPolicies( - request: protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest, - callback: PaginationCallback< - protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest, - protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1.IClientTlsPolicy>): void; - listClientTlsPolicies( - request?: protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest, - protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1.IClientTlsPolicy>, - callback?: PaginationCallback< - protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest, - protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1.IClientTlsPolicy>): - Promise<[ - protos.google.cloud.networksecurity.v1.IClientTlsPolicy[], - protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest|null, - protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listClientTlsPolicies(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the ClientTlsPolicies should - * be listed, specified in the format `projects/* /locations/{location}`. - * @param {number} request.pageSize - * Maximum number of ClientTlsPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListClientTlsPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListClientTlsPolicies` call, and that the system - * should return the next page of data. - * @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 protos.google.cloud.networksecurity.v1.ClientTlsPolicy|ClientTlsPolicy} 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 `listClientTlsPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listClientTlsPoliciesStream( - request?: protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest, - 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['listClientTlsPolicies']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listClientTlsPolicies.createStream( - this.innerApiCalls.listClientTlsPolicies as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listClientTlsPolicies`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the ClientTlsPolicies should - * be listed, specified in the format `projects/* /locations/{location}`. - * @param {number} request.pageSize - * Maximum number of ClientTlsPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListClientTlsPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListClientTlsPolicies` call, and that the system - * should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networksecurity.v1.ClientTlsPolicy|ClientTlsPolicy}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_security.list_client_tls_policies.js - * region_tag:networksecurity_v1_generated_NetworkSecurity_ListClientTlsPolicies_async - */ - listClientTlsPoliciesAsync( - request?: protos.google.cloud.networksecurity.v1.IListClientTlsPoliciesRequest, - 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['listClientTlsPolicies']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listClientTlsPolicies.asyncIterate( - this.innerApiCalls['listClientTlsPolicies'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @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/interfaces/CallOptions.html | 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.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - getIamPolicy( - request: IamProtos.google.iam.v1.GetIamPolicyRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, - {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { - return this.iamClient.getIamPolicy(request, options, callback); - } - -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - setIamPolicy( - request: IamProtos.google.iam.v1.SetIamPolicyRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, - {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { - return this.iamClient.setIamPolicy(request, options, callback); - } - -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ - testIamPermissions( - request: IamProtos.google.iam.v1.TestIamPermissionsRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.TestIamPermissionsResponse, - IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.TestIamPermissionsResponse, - IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, - {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { - return this.iamClient.testIamPermissions(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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 authorizationPolicy resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} authorization_policy - * @returns {string} Resource name string. - */ - authorizationPolicyPath(project:string,location:string,authorizationPolicy:string) { - return this.pathTemplates.authorizationPolicyPathTemplate.render({ - project: project, - location: location, - authorization_policy: authorizationPolicy, - }); - } - - /** - * Parse the project from AuthorizationPolicy resource. - * - * @param {string} authorizationPolicyName - * A fully-qualified path representing AuthorizationPolicy resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAuthorizationPolicyName(authorizationPolicyName: string) { - return this.pathTemplates.authorizationPolicyPathTemplate.match(authorizationPolicyName).project; - } - - /** - * Parse the location from AuthorizationPolicy resource. - * - * @param {string} authorizationPolicyName - * A fully-qualified path representing AuthorizationPolicy resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAuthorizationPolicyName(authorizationPolicyName: string) { - return this.pathTemplates.authorizationPolicyPathTemplate.match(authorizationPolicyName).location; - } - - /** - * Parse the authorization_policy from AuthorizationPolicy resource. - * - * @param {string} authorizationPolicyName - * A fully-qualified path representing AuthorizationPolicy resource. - * @returns {string} A string representing the authorization_policy. - */ - matchAuthorizationPolicyFromAuthorizationPolicyName(authorizationPolicyName: string) { - return this.pathTemplates.authorizationPolicyPathTemplate.match(authorizationPolicyName).authorization_policy; - } - - /** - * Return a fully-qualified clientTlsPolicy resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} client_tls_policy - * @returns {string} Resource name string. - */ - clientTlsPolicyPath(project:string,location:string,clientTlsPolicy:string) { - return this.pathTemplates.clientTlsPolicyPathTemplate.render({ - project: project, - location: location, - client_tls_policy: clientTlsPolicy, - }); - } - - /** - * Parse the project from ClientTlsPolicy resource. - * - * @param {string} clientTlsPolicyName - * A fully-qualified path representing ClientTlsPolicy resource. - * @returns {string} A string representing the project. - */ - matchProjectFromClientTlsPolicyName(clientTlsPolicyName: string) { - return this.pathTemplates.clientTlsPolicyPathTemplate.match(clientTlsPolicyName).project; - } - - /** - * Parse the location from ClientTlsPolicy resource. - * - * @param {string} clientTlsPolicyName - * A fully-qualified path representing ClientTlsPolicy resource. - * @returns {string} A string representing the location. - */ - matchLocationFromClientTlsPolicyName(clientTlsPolicyName: string) { - return this.pathTemplates.clientTlsPolicyPathTemplate.match(clientTlsPolicyName).location; - } - - /** - * Parse the client_tls_policy from ClientTlsPolicy resource. - * - * @param {string} clientTlsPolicyName - * A fully-qualified path representing ClientTlsPolicy resource. - * @returns {string} A string representing the client_tls_policy. - */ - matchClientTlsPolicyFromClientTlsPolicyName(clientTlsPolicyName: string) { - return this.pathTemplates.clientTlsPolicyPathTemplate.match(clientTlsPolicyName).client_tls_policy; - } - - /** - * Return a fully-qualified serverTlsPolicy resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} server_tls_policy - * @returns {string} Resource name string. - */ - serverTlsPolicyPath(project:string,location:string,serverTlsPolicy:string) { - return this.pathTemplates.serverTlsPolicyPathTemplate.render({ - project: project, - location: location, - server_tls_policy: serverTlsPolicy, - }); - } - - /** - * Parse the project from ServerTlsPolicy resource. - * - * @param {string} serverTlsPolicyName - * A fully-qualified path representing ServerTlsPolicy resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServerTlsPolicyName(serverTlsPolicyName: string) { - return this.pathTemplates.serverTlsPolicyPathTemplate.match(serverTlsPolicyName).project; - } - - /** - * Parse the location from ServerTlsPolicy resource. - * - * @param {string} serverTlsPolicyName - * A fully-qualified path representing ServerTlsPolicy resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServerTlsPolicyName(serverTlsPolicyName: string) { - return this.pathTemplates.serverTlsPolicyPathTemplate.match(serverTlsPolicyName).location; - } - - /** - * Parse the server_tls_policy from ServerTlsPolicy resource. - * - * @param {string} serverTlsPolicyName - * A fully-qualified path representing ServerTlsPolicy resource. - * @returns {string} A string representing the server_tls_policy. - */ - matchServerTlsPolicyFromServerTlsPolicyName(serverTlsPolicyName: string) { - return this.pathTemplates.serverTlsPolicyPathTemplate.match(serverTlsPolicyName).server_tls_policy; - } - - /** - * 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.networkSecurityStub && !this._terminated) { - return this.networkSecurityStub.then(stub => { - this._terminated = true; - stub.close(); - this.iamClient.close(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_client_config.json b/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_client_config.json deleted file mode 100644 index eb0689a8517..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_client_config.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "interfaces": { - "google.cloud.networksecurity.v1.NetworkSecurity": { - "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": { - "ListAuthorizationPolicies": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetAuthorizationPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateAuthorizationPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateAuthorizationPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteAuthorizationPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListServerTlsPolicies": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetServerTlsPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateServerTlsPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateServerTlsPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteServerTlsPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListClientTlsPolicies": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetClientTlsPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateClientTlsPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateClientTlsPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteClientTlsPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_proto_list.json b/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_proto_list.json deleted file mode 100644 index 4dea8c095ea..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/src/v1/network_security_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/networksecurity/v1/authorization_policy.proto", - "../../protos/google/cloud/networksecurity/v1/client_tls_policy.proto", - "../../protos/google/cloud/networksecurity/v1/common.proto", - "../../protos/google/cloud/networksecurity/v1/network_security.proto", - "../../protos/google/cloud/networksecurity/v1/server_tls_policy.proto", - "../../protos/google/cloud/networksecurity/v1/tls.proto" -] diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-networksecurity/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 276817cefad..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const networksecurity = require('@google-cloud/networksecurity'); - -function main() { - const networkSecurityClient = new networksecurity.NetworkSecurityClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-networksecurity/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 4d3fbe66ebb..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {NetworkSecurityClient} from '@google-cloud/networksecurity'; - -// check that the client class type name can be used -function doStuffWithNetworkSecurityClient(client: NetworkSecurityClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const networkSecurityClient = new NetworkSecurityClient(); - doStuffWithNetworkSecurityClient(networkSecurityClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/system-test/install.ts b/owl-bot-staging/google-cloud-networksecurity/v1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/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-networksecurity/v1/test/gapic_network_security_v1.ts b/owl-bot-staging/google-cloud-networksecurity/v1/test/gapic_network_security_v1.ts deleted file mode 100644 index c7026aa1d19..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/test/gapic_network_security_v1.ts +++ /dev/null @@ -1,3508 +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 networksecurityModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.NetworkSecurityClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = networksecurityModule.v1.NetworkSecurityClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = networksecurityModule.v1.NetworkSecurityClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = networksecurityModule.v1.NetworkSecurityClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new networksecurityModule.v1.NetworkSecurityClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.networkSecurityStub, undefined); - await client.initialize(); - assert(client.networkSecurityStub); - }); - - it('has close method for the initialized client', done => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.networkSecurityStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.networkSecurityStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new networksecurityModule.v1.NetworkSecurityClient({ - 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 networksecurityModule.v1.NetworkSecurityClient({ - 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('getAuthorizationPolicy', () => { - it('invokes getAuthorizationPolicy without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.GetAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.GetAuthorizationPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.AuthorizationPolicy() - ); - client.innerApiCalls.getAuthorizationPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getAuthorizationPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAuthorizationPolicy without error using callback', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.GetAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.GetAuthorizationPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.AuthorizationPolicy() - ); - client.innerApiCalls.getAuthorizationPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getAuthorizationPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.networksecurity.v1.IAuthorizationPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAuthorizationPolicy with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.GetAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.GetAuthorizationPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getAuthorizationPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAuthorizationPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAuthorizationPolicy with closed client', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.GetAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.GetAuthorizationPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getAuthorizationPolicy(request), expectedError); - }); - }); - - describe('getServerTlsPolicy', () => { - it('invokes getServerTlsPolicy without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.GetServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.GetServerTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ServerTlsPolicy() - ); - client.innerApiCalls.getServerTlsPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getServerTlsPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getServerTlsPolicy without error using callback', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.GetServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.GetServerTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ServerTlsPolicy() - ); - client.innerApiCalls.getServerTlsPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getServerTlsPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.networksecurity.v1.IServerTlsPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getServerTlsPolicy with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.GetServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.GetServerTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getServerTlsPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getServerTlsPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getServerTlsPolicy with closed client', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.GetServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.GetServerTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getServerTlsPolicy(request), expectedError); - }); - }); - - describe('getClientTlsPolicy', () => { - it('invokes getClientTlsPolicy without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.GetClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.GetClientTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ClientTlsPolicy() - ); - client.innerApiCalls.getClientTlsPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getClientTlsPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getClientTlsPolicy without error using callback', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.GetClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.GetClientTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ClientTlsPolicy() - ); - client.innerApiCalls.getClientTlsPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getClientTlsPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.networksecurity.v1.IClientTlsPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getClientTlsPolicy with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.GetClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.GetClientTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getClientTlsPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getClientTlsPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getClientTlsPolicy with closed client', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.GetClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.GetClientTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getClientTlsPolicy(request), expectedError); - }); - }); - - describe('createAuthorizationPolicy', () => { - it('invokes createAuthorizationPolicy without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.CreateAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateAuthorizationPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createAuthorizationPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.createAuthorizationPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createAuthorizationPolicy without error using callback', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.CreateAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateAuthorizationPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createAuthorizationPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createAuthorizationPolicy( - request, - (err?: Error|null, - result?: 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.createAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createAuthorizationPolicy with call error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.CreateAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateAuthorizationPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createAuthorizationPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createAuthorizationPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createAuthorizationPolicy with LRO error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.CreateAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateAuthorizationPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createAuthorizationPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createAuthorizationPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateAuthorizationPolicyProgress without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateAuthorizationPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateAuthorizationPolicyProgress with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateAuthorizationPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateAuthorizationPolicy', () => { - it('invokes updateAuthorizationPolicy without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.UpdateAuthorizationPolicyRequest() - ); - request.authorizationPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateAuthorizationPolicyRequest', ['authorizationPolicy', 'name']); - request.authorizationPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `authorization_policy.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateAuthorizationPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateAuthorizationPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateAuthorizationPolicy without error using callback', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.UpdateAuthorizationPolicyRequest() - ); - request.authorizationPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateAuthorizationPolicyRequest', ['authorizationPolicy', 'name']); - request.authorizationPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `authorization_policy.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateAuthorizationPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateAuthorizationPolicy( - request, - (err?: Error|null, - result?: 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.updateAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateAuthorizationPolicy with call error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.UpdateAuthorizationPolicyRequest() - ); - request.authorizationPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateAuthorizationPolicyRequest', ['authorizationPolicy', 'name']); - request.authorizationPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `authorization_policy.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAuthorizationPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateAuthorizationPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateAuthorizationPolicy with LRO error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.UpdateAuthorizationPolicyRequest() - ); - request.authorizationPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateAuthorizationPolicyRequest', ['authorizationPolicy', 'name']); - request.authorizationPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `authorization_policy.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAuthorizationPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateAuthorizationPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateAuthorizationPolicyProgress without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateAuthorizationPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateAuthorizationPolicyProgress with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateAuthorizationPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteAuthorizationPolicy', () => { - it('invokes deleteAuthorizationPolicy without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.DeleteAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteAuthorizationPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteAuthorizationPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteAuthorizationPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteAuthorizationPolicy without error using callback', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.DeleteAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteAuthorizationPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteAuthorizationPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteAuthorizationPolicy( - request, - (err?: Error|null, - result?: 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.deleteAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteAuthorizationPolicy with call error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.DeleteAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteAuthorizationPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteAuthorizationPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteAuthorizationPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteAuthorizationPolicy with LRO error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.DeleteAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteAuthorizationPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteAuthorizationPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteAuthorizationPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteAuthorizationPolicyProgress without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteAuthorizationPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteAuthorizationPolicyProgress with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteAuthorizationPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('createServerTlsPolicy', () => { - it('invokes createServerTlsPolicy without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.CreateServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateServerTlsPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createServerTlsPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.createServerTlsPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createServerTlsPolicy without error using callback', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.CreateServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateServerTlsPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createServerTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createServerTlsPolicy( - request, - (err?: Error|null, - result?: 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.createServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createServerTlsPolicy with call error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.CreateServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateServerTlsPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createServerTlsPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createServerTlsPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.createServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createServerTlsPolicy with LRO error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.CreateServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateServerTlsPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createServerTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createServerTlsPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateServerTlsPolicyProgress without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateServerTlsPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateServerTlsPolicyProgress with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateServerTlsPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateServerTlsPolicy', () => { - it('invokes updateServerTlsPolicy without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.UpdateServerTlsPolicyRequest() - ); - request.serverTlsPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateServerTlsPolicyRequest', ['serverTlsPolicy', 'name']); - request.serverTlsPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `server_tls_policy.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateServerTlsPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateServerTlsPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateServerTlsPolicy without error using callback', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.UpdateServerTlsPolicyRequest() - ); - request.serverTlsPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateServerTlsPolicyRequest', ['serverTlsPolicy', 'name']); - request.serverTlsPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `server_tls_policy.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateServerTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateServerTlsPolicy( - request, - (err?: Error|null, - result?: 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.updateServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateServerTlsPolicy with call error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.UpdateServerTlsPolicyRequest() - ); - request.serverTlsPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateServerTlsPolicyRequest', ['serverTlsPolicy', 'name']); - request.serverTlsPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `server_tls_policy.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateServerTlsPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateServerTlsPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateServerTlsPolicy with LRO error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.UpdateServerTlsPolicyRequest() - ); - request.serverTlsPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateServerTlsPolicyRequest', ['serverTlsPolicy', 'name']); - request.serverTlsPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `server_tls_policy.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateServerTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateServerTlsPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateServerTlsPolicyProgress without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateServerTlsPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateServerTlsPolicyProgress with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateServerTlsPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteServerTlsPolicy', () => { - it('invokes deleteServerTlsPolicy without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.DeleteServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteServerTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteServerTlsPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteServerTlsPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteServerTlsPolicy without error using callback', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.DeleteServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteServerTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteServerTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteServerTlsPolicy( - request, - (err?: Error|null, - result?: 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.deleteServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteServerTlsPolicy with call error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.DeleteServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteServerTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServerTlsPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteServerTlsPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteServerTlsPolicy with LRO error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.DeleteServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteServerTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServerTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteServerTlsPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteServerTlsPolicyProgress without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteServerTlsPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteServerTlsPolicyProgress with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteServerTlsPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('createClientTlsPolicy', () => { - it('invokes createClientTlsPolicy without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.CreateClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateClientTlsPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createClientTlsPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.createClientTlsPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createClientTlsPolicy without error using callback', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.CreateClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateClientTlsPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createClientTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createClientTlsPolicy( - request, - (err?: Error|null, - result?: 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.createClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createClientTlsPolicy with call error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.CreateClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateClientTlsPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createClientTlsPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createClientTlsPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.createClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createClientTlsPolicy with LRO error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.CreateClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.CreateClientTlsPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createClientTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createClientTlsPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateClientTlsPolicyProgress without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateClientTlsPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateClientTlsPolicyProgress with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateClientTlsPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateClientTlsPolicy', () => { - it('invokes updateClientTlsPolicy without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.UpdateClientTlsPolicyRequest() - ); - request.clientTlsPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateClientTlsPolicyRequest', ['clientTlsPolicy', 'name']); - request.clientTlsPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `client_tls_policy.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateClientTlsPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateClientTlsPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateClientTlsPolicy without error using callback', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.UpdateClientTlsPolicyRequest() - ); - request.clientTlsPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateClientTlsPolicyRequest', ['clientTlsPolicy', 'name']); - request.clientTlsPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `client_tls_policy.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateClientTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateClientTlsPolicy( - request, - (err?: Error|null, - result?: 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.updateClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateClientTlsPolicy with call error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.UpdateClientTlsPolicyRequest() - ); - request.clientTlsPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateClientTlsPolicyRequest', ['clientTlsPolicy', 'name']); - request.clientTlsPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `client_tls_policy.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateClientTlsPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateClientTlsPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateClientTlsPolicy with LRO error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.UpdateClientTlsPolicyRequest() - ); - request.clientTlsPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.UpdateClientTlsPolicyRequest', ['clientTlsPolicy', 'name']); - request.clientTlsPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `client_tls_policy.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateClientTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateClientTlsPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateClientTlsPolicyProgress without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateClientTlsPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateClientTlsPolicyProgress with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateClientTlsPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteClientTlsPolicy', () => { - it('invokes deleteClientTlsPolicy without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.DeleteClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteClientTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteClientTlsPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteClientTlsPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteClientTlsPolicy without error using callback', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.DeleteClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteClientTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteClientTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteClientTlsPolicy( - request, - (err?: Error|null, - result?: 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.deleteClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteClientTlsPolicy with call error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.DeleteClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteClientTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteClientTlsPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteClientTlsPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteClientTlsPolicy with LRO error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.DeleteClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.DeleteClientTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteClientTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteClientTlsPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteClientTlsPolicyProgress without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteClientTlsPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteClientTlsPolicyProgress with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteClientTlsPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listAuthorizationPolicies', () => { - it('invokes listAuthorizationPolicies without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), - ]; - client.innerApiCalls.listAuthorizationPolicies = stubSimpleCall(expectedResponse); - const [response] = await client.listAuthorizationPolicies(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAuthorizationPolicies without error using callback', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), - ]; - client.innerApiCalls.listAuthorizationPolicies = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listAuthorizationPolicies( - request, - (err?: Error|null, result?: protos.google.cloud.networksecurity.v1.IAuthorizationPolicy[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAuthorizationPolicies with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listAuthorizationPolicies = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listAuthorizationPolicies(request), expectedError); - const actualRequest = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAuthorizationPoliciesStream without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), - ]; - client.descriptors.page.listAuthorizationPolicies.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listAuthorizationPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networksecurity.v1.AuthorizationPolicy[] = []; - stream.on('data', (response: protos.google.cloud.networksecurity.v1.AuthorizationPolicy) => { - 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.listAuthorizationPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAuthorizationPolicies, request)); - assert( - (client.descriptors.page.listAuthorizationPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listAuthorizationPoliciesStream with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listAuthorizationPolicies.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listAuthorizationPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networksecurity.v1.AuthorizationPolicy[] = []; - stream.on('data', (response: protos.google.cloud.networksecurity.v1.AuthorizationPolicy) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listAuthorizationPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAuthorizationPolicies, request)); - assert( - (client.descriptors.page.listAuthorizationPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listAuthorizationPolicies without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.AuthorizationPolicy()), - ]; - client.descriptors.page.listAuthorizationPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networksecurity.v1.IAuthorizationPolicy[] = []; - const iterable = client.listAuthorizationPoliciesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listAuthorizationPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAuthorizationPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listAuthorizationPolicies with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.ListAuthorizationPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listAuthorizationPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listAuthorizationPoliciesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networksecurity.v1.IAuthorizationPolicy[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listAuthorizationPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAuthorizationPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listServerTlsPolicies', () => { - it('invokes listServerTlsPolicies without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), - ]; - client.innerApiCalls.listServerTlsPolicies = stubSimpleCall(expectedResponse); - const [response] = await client.listServerTlsPolicies(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServerTlsPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServerTlsPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServerTlsPolicies without error using callback', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), - ]; - client.innerApiCalls.listServerTlsPolicies = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServerTlsPolicies( - request, - (err?: Error|null, result?: protos.google.cloud.networksecurity.v1.IServerTlsPolicy[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServerTlsPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServerTlsPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServerTlsPolicies with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listServerTlsPolicies = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServerTlsPolicies(request), expectedError); - const actualRequest = (client.innerApiCalls.listServerTlsPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServerTlsPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServerTlsPoliciesStream without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), - ]; - client.descriptors.page.listServerTlsPolicies.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listServerTlsPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networksecurity.v1.ServerTlsPolicy[] = []; - stream.on('data', (response: protos.google.cloud.networksecurity.v1.ServerTlsPolicy) => { - 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.listServerTlsPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServerTlsPolicies, request)); - assert( - (client.descriptors.page.listServerTlsPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listServerTlsPoliciesStream with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listServerTlsPolicies.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listServerTlsPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networksecurity.v1.ServerTlsPolicy[] = []; - stream.on('data', (response: protos.google.cloud.networksecurity.v1.ServerTlsPolicy) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listServerTlsPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServerTlsPolicies, request)); - assert( - (client.descriptors.page.listServerTlsPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listServerTlsPolicies without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ServerTlsPolicy()), - ]; - client.descriptors.page.listServerTlsPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networksecurity.v1.IServerTlsPolicy[] = []; - const iterable = client.listServerTlsPoliciesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listServerTlsPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServerTlsPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listServerTlsPolicies with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.ListServerTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listServerTlsPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listServerTlsPoliciesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networksecurity.v1.IServerTlsPolicy[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listServerTlsPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServerTlsPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listClientTlsPolicies', () => { - it('invokes listClientTlsPolicies without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), - ]; - client.innerApiCalls.listClientTlsPolicies = stubSimpleCall(expectedResponse); - const [response] = await client.listClientTlsPolicies(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listClientTlsPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listClientTlsPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listClientTlsPolicies without error using callback', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), - ]; - client.innerApiCalls.listClientTlsPolicies = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listClientTlsPolicies( - request, - (err?: Error|null, result?: protos.google.cloud.networksecurity.v1.IClientTlsPolicy[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listClientTlsPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listClientTlsPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listClientTlsPolicies with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listClientTlsPolicies = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listClientTlsPolicies(request), expectedError); - const actualRequest = (client.innerApiCalls.listClientTlsPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listClientTlsPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listClientTlsPoliciesStream without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), - ]; - client.descriptors.page.listClientTlsPolicies.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listClientTlsPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networksecurity.v1.ClientTlsPolicy[] = []; - stream.on('data', (response: protos.google.cloud.networksecurity.v1.ClientTlsPolicy) => { - 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.listClientTlsPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listClientTlsPolicies, request)); - assert( - (client.descriptors.page.listClientTlsPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listClientTlsPoliciesStream with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listClientTlsPolicies.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listClientTlsPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networksecurity.v1.ClientTlsPolicy[] = []; - stream.on('data', (response: protos.google.cloud.networksecurity.v1.ClientTlsPolicy) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listClientTlsPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listClientTlsPolicies, request)); - assert( - (client.descriptors.page.listClientTlsPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listClientTlsPolicies without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1.ClientTlsPolicy()), - ]; - client.descriptors.page.listClientTlsPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networksecurity.v1.IClientTlsPolicy[] = []; - const iterable = client.listClientTlsPoliciesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listClientTlsPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listClientTlsPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listClientTlsPolicies with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1.ListClientTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listClientTlsPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listClientTlsPoliciesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networksecurity.v1.IClientTlsPolicy[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listClientTlsPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listClientTlsPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new networksecurityModule.v1.NetworkSecurityClient({ - 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 networksecurityModule.v1.NetworkSecurityClient({ - 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 networksecurityModule.v1.NetworkSecurityClient({ - 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 networksecurityModule.v1.NetworkSecurityClient({ - 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 networksecurityModule.v1.NetworkSecurityClient({ - 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 networksecurityModule.v1.NetworkSecurityClient({ - 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 networksecurityModule.v1.NetworkSecurityClient({ - 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 networksecurityModule.v1.NetworkSecurityClient({ - 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 networksecurityModule.v1.NetworkSecurityClient({ - 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 networksecurityModule.v1.NetworkSecurityClient({ - 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 networksecurityModule.v1.NetworkSecurityClient({ - 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 networksecurityModule.v1.NetworkSecurityClient({ - 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 networksecurityModule.v1.NetworkSecurityClient({ - 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 networksecurityModule.v1.NetworkSecurityClient({ - 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 networksecurityModule.v1.NetworkSecurityClient({ - 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 networksecurityModule.v1.NetworkSecurityClient({ - 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('authorizationPolicy', () => { - const fakePath = "/rendered/path/authorizationPolicy"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - authorization_policy: "authorizationPolicyValue", - }; - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.authorizationPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.authorizationPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('authorizationPolicyPath', () => { - const result = client.authorizationPolicyPath("projectValue", "locationValue", "authorizationPolicyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.authorizationPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAuthorizationPolicyName', () => { - const result = client.matchProjectFromAuthorizationPolicyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.authorizationPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAuthorizationPolicyName', () => { - const result = client.matchLocationFromAuthorizationPolicyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.authorizationPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAuthorizationPolicyFromAuthorizationPolicyName', () => { - const result = client.matchAuthorizationPolicyFromAuthorizationPolicyName(fakePath); - assert.strictEqual(result, "authorizationPolicyValue"); - assert((client.pathTemplates.authorizationPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('clientTlsPolicy', () => { - const fakePath = "/rendered/path/clientTlsPolicy"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - client_tls_policy: "clientTlsPolicyValue", - }; - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.clientTlsPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.clientTlsPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('clientTlsPolicyPath', () => { - const result = client.clientTlsPolicyPath("projectValue", "locationValue", "clientTlsPolicyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.clientTlsPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromClientTlsPolicyName', () => { - const result = client.matchProjectFromClientTlsPolicyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.clientTlsPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromClientTlsPolicyName', () => { - const result = client.matchLocationFromClientTlsPolicyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.clientTlsPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchClientTlsPolicyFromClientTlsPolicyName', () => { - const result = client.matchClientTlsPolicyFromClientTlsPolicyName(fakePath); - assert.strictEqual(result, "clientTlsPolicyValue"); - assert((client.pathTemplates.clientTlsPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('serverTlsPolicy', () => { - const fakePath = "/rendered/path/serverTlsPolicy"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - server_tls_policy: "serverTlsPolicyValue", - }; - const client = new networksecurityModule.v1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.serverTlsPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serverTlsPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serverTlsPolicyPath', () => { - const result = client.serverTlsPolicyPath("projectValue", "locationValue", "serverTlsPolicyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serverTlsPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServerTlsPolicyName', () => { - const result = client.matchProjectFromServerTlsPolicyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serverTlsPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServerTlsPolicyName', () => { - const result = client.matchLocationFromServerTlsPolicyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serverTlsPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServerTlsPolicyFromServerTlsPolicyName', () => { - const result = client.matchServerTlsPolicyFromServerTlsPolicyName(fakePath); - assert.strictEqual(result, "serverTlsPolicyValue"); - assert((client.pathTemplates.serverTlsPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/tsconfig.json b/owl-bot-staging/google-cloud-networksecurity/v1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1/webpack.config.js b/owl-bot-staging/google-cloud-networksecurity/v1/webpack.config.js deleted file mode 100644 index d5abc33e904..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'NetworkSecurity', - filename: './network-security.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-networksecurity/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-networksecurity/v1beta1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-networksecurity/v1beta1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/.gitignore b/owl-bot-staging/google-cloud-networksecurity/v1beta1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/.jsdoc.js deleted file mode 100644 index 1a78e759476..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/.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/network-security', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/.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-networksecurity/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/.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-networksecurity/v1beta1/README.md b/owl-bot-staging/google-cloud-networksecurity/v1beta1/README.md deleted file mode 100644 index aa251b5b5c0..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Networksecurity: Nodejs Client diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/package.json b/owl-bot-staging/google-cloud-networksecurity/v1beta1/package.json deleted file mode 100644 index b8a5aa0ce92..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/network-security", - "version": "0.1.0", - "description": "Networksecurity client for Node.js", - "repository": "googleapis/nodejs-networksecurity", - "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 networksecurity", - "networksecurity", - "network security" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/authorization_policy.proto b/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/authorization_policy.proto deleted file mode 100644 index e52f06d6a89..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/authorization_policy.proto +++ /dev/null @@ -1,259 +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.networksecurity.v1beta1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.NetworkSecurity.V1Beta1"; -option go_package = "cloud.google.com/go/networksecurity/apiv1beta1/networksecuritypb;networksecuritypb"; -option java_multiple_files = true; -option java_outer_classname = "AuthorizationPolicyProto"; -option java_package = "com.google.cloud.networksecurity.v1beta1"; -option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1beta1"; -option ruby_package = "Google::Cloud::NetworkSecurity::V1beta1"; - -// AuthorizationPolicy is a resource that specifies how a server -// should authorize incoming connections. This resource in itself does -// not change the configuration unless it's attached to a target https -// proxy or endpoint config selector resource. -message AuthorizationPolicy { - option (google.api.resource) = { - type: "networksecurity.googleapis.com/AuthorizationPolicy" - pattern: "projects/{project}/locations/{location}/authorizationPolicies/{authorization_policy}" - }; - - // Specification of rules. - message Rule { - // Specification of traffic source attributes. - message Source { - // Optional. List of peer identities to match for authorization. At least - // one principal should match. Each peer can be an exact match, or a - // prefix match (example, "namespace/*") or a suffix match (example, - // "*/service-account") or a presence match "*". Authorization based on - // the principal name without certificate validation (configured by - // ServerTlsPolicy resource) is considered insecure. - repeated string principals = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. List of CIDR ranges to match based on source IP address. At - // least one IP block should match. Single IP (e.g., "1.2.3.4") and CIDR - // (e.g., "1.2.3.0/24") are supported. Authorization based on source IP - // alone should be avoided. The IP addresses of any load balancers or - // proxies should be considered untrusted. - repeated string ip_blocks = 2 [(google.api.field_behavior) = OPTIONAL]; - } - - // Specification of traffic destination attributes. - message Destination { - // Specification of HTTP header match attributes. - message HttpHeaderMatch { - oneof type { - // Required. The value of the header must match the regular expression - // specified in regexMatch. For regular expression grammar, - // please see: en.cppreference.com/w/cpp/regex/ecmascript - // For matching against a port specified in the HTTP - // request, use a headerMatch with headerName set to Host - // and a regular expression that satisfies the RFC2616 Host - // header's port specifier. - string regex_match = 2 [(google.api.field_behavior) = REQUIRED]; - } - - // Required. The name of the HTTP header to match. For matching - // against the HTTP request's authority, use a headerMatch - // with the header name ":authority". For matching a - // request's method, use the headerName ":method". - string header_name = 1 [(google.api.field_behavior) = REQUIRED]; - } - - // Required. List of host names to match. Matched against the ":authority" - // header in http requests. At least one host should match. Each host can - // be an exact match, or a prefix match (example "mydomain.*") or a suffix - // match (example "*.myorg.com") or a presence (any) match "*". - repeated string hosts = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. List of destination ports to match. At least one port should - // match. - repeated uint32 ports = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. A list of HTTP methods to match. At least one method should - // match. Should not be set for gRPC services. - repeated string methods = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Match against key:value pair in http header. Provides a - // flexible match based on HTTP headers, for potentially advanced use - // cases. At least one header should match. Avoid using header matches to - // make authorization decisions unless there is a strong guarantee that - // requests arrive through a trusted client or proxy. - HttpHeaderMatch http_header_match = 5 - [(google.api.field_behavior) = OPTIONAL]; - } - - // Optional. List of attributes for the traffic source. All of the sources - // must match. A source is a match if both principals and ip_blocks match. - // If not set, the action specified in the 'action' field will be applied - // without any rule checks for the source. - repeated Source sources = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. List of attributes for the traffic destination. All of the - // destinations must match. A destination is a match if a request matches - // all the specified hosts, ports, methods and headers. If not set, the - // action specified in the 'action' field will be applied without any rule - // checks for the destination. - repeated Destination destinations = 2 - [(google.api.field_behavior) = OPTIONAL]; - } - - // Possible values that define what action to take. - enum Action { - // Default value. - ACTION_UNSPECIFIED = 0; - - // Grant access. - ALLOW = 1; - - // Deny access. - // Deny rules should be avoided unless they are used to provide a default - // "deny all" fallback. - DENY = 2; - } - - // Required. Name of the AuthorizationPolicy resource. It matches pattern - // `projects/{project}/locations/{location}/authorizationPolicies/`. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Free-text description of the resource. - string description = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The timestamp when the resource was created. - google.protobuf.Timestamp create_time = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The timestamp when the resource was updated. - google.protobuf.Timestamp update_time = 4 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Set of label tags associated with the AuthorizationPolicy - // resource. - map labels = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Required. The action to take when a rule match is found. Possible values - // are "ALLOW" or "DENY". - Action action = 6 [(google.api.field_behavior) = REQUIRED]; - - // Optional. List of rules to match. Note that at least one of the rules must - // match in order for the action specified in the 'action' field to be taken. - // A rule is a match if there is a matching source and destination. If left - // blank, the action specified in the `action` field will be applied on every - // request. - repeated Rule rules = 7 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request used with the ListAuthorizationPolicies method. -message ListAuthorizationPoliciesRequest { - // Required. The project and location from which the AuthorizationPolicies - // should be listed, specified in the format - // `projects/{project}/locations/{location}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Maximum number of AuthorizationPolicies to return per call. - int32 page_size = 2; - - // The value returned by the last - // `ListAuthorizationPoliciesResponse` Indicates that this is a - // continuation of a prior `ListAuthorizationPolicies` call, and - // that the system should return the next page of data. - string page_token = 3; -} - -// Response returned by the ListAuthorizationPolicies method. -message ListAuthorizationPoliciesResponse { - // List of AuthorizationPolicies resources. - repeated AuthorizationPolicy authorization_policies = 1; - - // If there might be more results than those appearing in this response, then - // `next_page_token` is included. To get the next set of results, call this - // method again using the value of `next_page_token` as `page_token`. - string next_page_token = 2; -} - -// Request used by the GetAuthorizationPolicy method. -message GetAuthorizationPolicyRequest { - // Required. A name of the AuthorizationPolicy to get. Must be in the format - // `projects/{project}/locations/{location}/authorizationPolicies/*`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "networksecurity.googleapis.com/AuthorizationPolicy" - } - ]; -} - -// Request used by the CreateAuthorizationPolicy method. -message CreateAuthorizationPolicyRequest { - // Required. The parent resource of the AuthorizationPolicy. Must be in the - // format `projects/{project}/locations/{location}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "networksecurity.googleapis.com/AuthorizationPolicy" - } - ]; - - // Required. Short name of the AuthorizationPolicy resource to be created. - // This value should be 1-63 characters long, containing only - // letters, numbers, hyphens, and underscores, and should not start - // with a number. E.g. "authz_policy". - string authorization_policy_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. AuthorizationPolicy resource to be created. - AuthorizationPolicy authorization_policy = 3 - [(google.api.field_behavior) = REQUIRED]; -} - -// Request used by the UpdateAuthorizationPolicy method. -message UpdateAuthorizationPolicyRequest { - // Optional. Field mask is used to specify the fields to be overwritten in the - // AuthorizationPolicy resource by the update. - // The fields specified in the update_mask are relative to the resource, not - // the full request. A field will be overwritten if it is in the mask. If the - // user does not provide a mask then all fields will be overwritten. - google.protobuf.FieldMask update_mask = 1 - [(google.api.field_behavior) = OPTIONAL]; - - // Required. Updated AuthorizationPolicy resource. - AuthorizationPolicy authorization_policy = 2 - [(google.api.field_behavior) = REQUIRED]; -} - -// Request used by the DeleteAuthorizationPolicy method. -message DeleteAuthorizationPolicyRequest { - // Required. A name of the AuthorizationPolicy to delete. Must be in the - // format `projects/{project}/locations/{location}/authorizationPolicies/*`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "networksecurity.googleapis.com/AuthorizationPolicy" - } - ]; -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/client_tls_policy.proto b/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/client_tls_policy.proto deleted file mode 100644 index 23b51077410..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/client_tls_policy.proto +++ /dev/null @@ -1,169 +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.networksecurity.v1beta1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/networksecurity/v1beta1/tls.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.NetworkSecurity.V1Beta1"; -option go_package = "cloud.google.com/go/networksecurity/apiv1beta1/networksecuritypb;networksecuritypb"; -option java_multiple_files = true; -option java_outer_classname = "ClientTlsPolicyProto"; -option java_package = "com.google.cloud.networksecurity.v1beta1"; -option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1beta1"; -option ruby_package = "Google::Cloud::NetworkSecurity::V1beta1"; - -// ClientTlsPolicy is a resource that specifies how a client should authenticate -// connections to backends of a service. This resource itself does not affect -// configuration unless it is attached to a backend service resource. -message ClientTlsPolicy { - option (google.api.resource) = { - type: "networksecurity.googleapis.com/ClientTlsPolicy" - pattern: "projects/{project}/locations/{location}/clientTlsPolicies/{client_tls_policy}" - }; - - // Required. Name of the ClientTlsPolicy resource. It matches the pattern - // `projects/*/locations/{location}/clientTlsPolicies/{client_tls_policy}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Free-text description of the resource. - string description = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The timestamp when the resource was created. - google.protobuf.Timestamp create_time = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The timestamp when the resource was updated. - google.protobuf.Timestamp update_time = 4 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Set of label tags associated with the resource. - map labels = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Server Name Indication string to present to the server during TLS - // handshake. E.g: "secure.example.com". - string sni = 6 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Defines a mechanism to provision client identity (public and - // private keys) for peer to peer authentication. The presence of this - // dictates mTLS. - CertificateProvider client_certificate = 7 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Defines the mechanism to obtain the Certificate Authority - // certificate to validate the server certificate. If empty, client does not - // validate the server certificate. - repeated ValidationCA server_validation_ca = 8 - [(google.api.field_behavior) = OPTIONAL]; -} - -// Request used by the ListClientTlsPolicies method. -message ListClientTlsPoliciesRequest { - // Required. The project and location from which the ClientTlsPolicies should - // be listed, specified in the format `projects/*/locations/{location}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Maximum number of ClientTlsPolicies to return per call. - int32 page_size = 2; - - // The value returned by the last `ListClientTlsPoliciesResponse` - // Indicates that this is a continuation of a prior - // `ListClientTlsPolicies` call, and that the system - // should return the next page of data. - string page_token = 3; -} - -// Response returned by the ListClientTlsPolicies method. -message ListClientTlsPoliciesResponse { - // List of ClientTlsPolicy resources. - repeated ClientTlsPolicy client_tls_policies = 1; - - // If there might be more results than those appearing in this response, then - // `next_page_token` is included. To get the next set of results, call this - // method again using the value of `next_page_token` as `page_token`. - string next_page_token = 2; -} - -// Request used by the GetClientTlsPolicy method. -message GetClientTlsPolicyRequest { - // Required. A name of the ClientTlsPolicy to get. Must be in the format - // `projects/*/locations/{location}/clientTlsPolicies/*`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "networksecurity.googleapis.com/ClientTlsPolicy" - } - ]; -} - -// Request used by the CreateClientTlsPolicy method. -message CreateClientTlsPolicyRequest { - // Required. The parent resource of the ClientTlsPolicy. Must be in - // the format `projects/*/locations/{location}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "networksecurity.googleapis.com/ClientTlsPolicy" - } - ]; - - // Required. Short name of the ClientTlsPolicy resource to be created. This - // value should be 1-63 characters long, containing only letters, numbers, - // hyphens, and underscores, and should not start with a number. E.g. - // "client_mtls_policy". - string client_tls_policy_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. ClientTlsPolicy resource to be created. - ClientTlsPolicy client_tls_policy = 3 - [(google.api.field_behavior) = REQUIRED]; -} - -// Request used by UpdateClientTlsPolicy method. -message UpdateClientTlsPolicyRequest { - // Optional. Field mask is used to specify the fields to be overwritten in the - // ClientTlsPolicy resource by the update. The fields - // specified in the update_mask are relative to the resource, not - // the full request. A field will be overwritten if it is in the - // mask. If the user does not provide a mask then all fields will be - // overwritten. - google.protobuf.FieldMask update_mask = 1 - [(google.api.field_behavior) = OPTIONAL]; - - // Required. Updated ClientTlsPolicy resource. - ClientTlsPolicy client_tls_policy = 2 - [(google.api.field_behavior) = REQUIRED]; -} - -// Request used by the DeleteClientTlsPolicy method. -message DeleteClientTlsPolicyRequest { - // Required. A name of the ClientTlsPolicy to delete. Must be in - // the format `projects/*/locations/{location}/clientTlsPolicies/*`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "networksecurity.googleapis.com/ClientTlsPolicy" - } - ]; -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/common.proto b/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/common.proto deleted file mode 100644 index 04f37a45ec9..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/common.proto +++ /dev/null @@ -1,58 +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.networksecurity.v1beta1; - -import "google/api/field_behavior.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.NetworkSecurity.V1Beta1"; -option go_package = "cloud.google.com/go/networksecurity/apiv1beta1/networksecuritypb;networksecuritypb"; -option java_multiple_files = true; -option java_outer_classname = "CommonProto"; -option java_package = "com.google.cloud.networksecurity.v1beta1"; -option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1beta1"; -option ruby_package = "Google::Cloud::NetworkSecurity::V1beta1"; - -// Represents the metadata of the long-running operation. -message OperationMetadata { - // Output only. The time the operation was created. - google.protobuf.Timestamp create_time = 1 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time the operation finished running. - google.protobuf.Timestamp end_time = 2 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Server-defined resource path for the target of the operation. - string target = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Name of the verb executed by the operation. - string verb = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Human-readable status of the operation, if any. - string status_message = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Identifies whether the user has requested cancellation - // of the operation. Operations that have successfully been cancelled - // have [Operation.error][] value with a - // [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to - // `Code.CANCELLED`. - bool requested_cancellation = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. API version used to start the operation. - string api_version = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/network_security.proto b/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/network_security.proto deleted file mode 100644 index 157948f65c5..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/network_security.proto +++ /dev/null @@ -1,201 +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.networksecurity.v1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/cloud/networksecurity/v1beta1/authorization_policy.proto"; -import "google/cloud/networksecurity/v1beta1/client_tls_policy.proto"; -import "google/cloud/networksecurity/v1beta1/server_tls_policy.proto"; -import "google/longrunning/operations.proto"; - -option csharp_namespace = "Google.Cloud.NetworkSecurity.V1Beta1"; -option go_package = "cloud.google.com/go/networksecurity/apiv1beta1/networksecuritypb;networksecuritypb"; -option java_multiple_files = true; -option java_package = "com.google.cloud.networksecurity.v1beta1"; -option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1beta1"; -option ruby_package = "Google::Cloud::NetworkSecurity::V1beta1"; - -// Network Security API provides resources to configure authentication and -// authorization policies. Refer to per API resource documentation for more -// information. -service NetworkSecurity { - option (google.api.default_host) = "networksecurity.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Lists AuthorizationPolicies in a given project and location. - rpc ListAuthorizationPolicies(ListAuthorizationPoliciesRequest) returns (ListAuthorizationPoliciesResponse) { - option (google.api.http) = { - get: "/v1beta1/{parent=projects/*/locations/*}/authorizationPolicies" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets details of a single AuthorizationPolicy. - rpc GetAuthorizationPolicy(GetAuthorizationPolicyRequest) returns (AuthorizationPolicy) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/locations/*/authorizationPolicies/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a new AuthorizationPolicy in a given project and location. - rpc CreateAuthorizationPolicy(CreateAuthorizationPolicyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*/locations/*}/authorizationPolicies" - body: "authorization_policy" - }; - option (google.api.method_signature) = "parent,authorization_policy,authorization_policy_id"; - option (google.longrunning.operation_info) = { - response_type: "AuthorizationPolicy" - metadata_type: "google.cloud.networksecurity.v1beta1.OperationMetadata" - }; - } - - // Updates the parameters of a single AuthorizationPolicy. - rpc UpdateAuthorizationPolicy(UpdateAuthorizationPolicyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1beta1/{authorization_policy.name=projects/*/locations/*/authorizationPolicies/*}" - body: "authorization_policy" - }; - option (google.api.method_signature) = "authorization_policy,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "AuthorizationPolicy" - metadata_type: "google.cloud.networksecurity.v1beta1.OperationMetadata" - }; - } - - // Deletes a single AuthorizationPolicy. - rpc DeleteAuthorizationPolicy(DeleteAuthorizationPolicyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1beta1/{name=projects/*/locations/*/authorizationPolicies/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "google.cloud.networksecurity.v1beta1.OperationMetadata" - }; - } - - // Lists ServerTlsPolicies in a given project and location. - rpc ListServerTlsPolicies(ListServerTlsPoliciesRequest) returns (ListServerTlsPoliciesResponse) { - option (google.api.http) = { - get: "/v1beta1/{parent=projects/*/locations/*}/serverTlsPolicies" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets details of a single ServerTlsPolicy. - rpc GetServerTlsPolicy(GetServerTlsPolicyRequest) returns (ServerTlsPolicy) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/locations/*/serverTlsPolicies/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a new ServerTlsPolicy in a given project and location. - rpc CreateServerTlsPolicy(CreateServerTlsPolicyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*/locations/*}/serverTlsPolicies" - body: "server_tls_policy" - }; - option (google.api.method_signature) = "parent,server_tls_policy,server_tls_policy_id"; - option (google.longrunning.operation_info) = { - response_type: "ServerTlsPolicy" - metadata_type: "google.cloud.networksecurity.v1beta1.OperationMetadata" - }; - } - - // Updates the parameters of a single ServerTlsPolicy. - rpc UpdateServerTlsPolicy(UpdateServerTlsPolicyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1beta1/{server_tls_policy.name=projects/*/locations/*/serverTlsPolicies/*}" - body: "server_tls_policy" - }; - option (google.api.method_signature) = "server_tls_policy,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "ServerTlsPolicy" - metadata_type: "google.cloud.networksecurity.v1beta1.OperationMetadata" - }; - } - - // Deletes a single ServerTlsPolicy. - rpc DeleteServerTlsPolicy(DeleteServerTlsPolicyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1beta1/{name=projects/*/locations/*/serverTlsPolicies/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "google.cloud.networksecurity.v1beta1.OperationMetadata" - }; - } - - // Lists ClientTlsPolicies in a given project and location. - rpc ListClientTlsPolicies(ListClientTlsPoliciesRequest) returns (ListClientTlsPoliciesResponse) { - option (google.api.http) = { - get: "/v1beta1/{parent=projects/*/locations/*}/clientTlsPolicies" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets details of a single ClientTlsPolicy. - rpc GetClientTlsPolicy(GetClientTlsPolicyRequest) returns (ClientTlsPolicy) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/locations/*/clientTlsPolicies/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a new ClientTlsPolicy in a given project and location. - rpc CreateClientTlsPolicy(CreateClientTlsPolicyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*/locations/*}/clientTlsPolicies" - body: "client_tls_policy" - }; - option (google.api.method_signature) = "parent,client_tls_policy,client_tls_policy_id"; - option (google.longrunning.operation_info) = { - response_type: "ClientTlsPolicy" - metadata_type: "google.cloud.networksecurity.v1beta1.OperationMetadata" - }; - } - - // Updates the parameters of a single ClientTlsPolicy. - rpc UpdateClientTlsPolicy(UpdateClientTlsPolicyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1beta1/{client_tls_policy.name=projects/*/locations/*/clientTlsPolicies/*}" - body: "client_tls_policy" - }; - option (google.api.method_signature) = "client_tls_policy,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "ClientTlsPolicy" - metadata_type: "google.cloud.networksecurity.v1beta1.OperationMetadata" - }; - } - - // Deletes a single ClientTlsPolicy. - rpc DeleteClientTlsPolicy(DeleteClientTlsPolicyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1beta1/{name=projects/*/locations/*/clientTlsPolicies/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "google.cloud.networksecurity.v1beta1.OperationMetadata" - }; - } -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/server_tls_policy.proto b/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/server_tls_policy.proto deleted file mode 100644 index 02b5a7443bc..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/server_tls_policy.proto +++ /dev/null @@ -1,187 +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.networksecurity.v1beta1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/networksecurity/v1beta1/tls.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.NetworkSecurity.V1Beta1"; -option go_package = "cloud.google.com/go/networksecurity/apiv1beta1/networksecuritypb;networksecuritypb"; -option java_multiple_files = true; -option java_outer_classname = "ServerTlsPolicyProto"; -option java_package = "com.google.cloud.networksecurity.v1beta1"; -option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1beta1"; -option ruby_package = "Google::Cloud::NetworkSecurity::V1beta1"; - -// ServerTlsPolicy is a resource that specifies how a server should authenticate -// incoming requests. This resource itself does not affect configuration unless -// it is attached to a target https proxy or endpoint config selector resource. -message ServerTlsPolicy { - option (google.api.resource) = { - type: "networksecurity.googleapis.com/ServerTlsPolicy" - pattern: "projects/{project}/locations/{location}/serverTlsPolicies/{server_tls_policy}" - }; - - // Specification of the MTLSPolicy. - message MTLSPolicy { - // - // Defines the mechanism to obtain the Certificate Authority certificate to - // validate the client certificate. - repeated ValidationCA client_validation_ca = 1; - } - - // Required. Name of the ServerTlsPolicy resource. It matches the pattern - // `projects/*/locations/{location}/serverTlsPolicies/{server_tls_policy}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Free-text description of the resource. - string description = 2; - - // Output only. The timestamp when the resource was created. - google.protobuf.Timestamp create_time = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The timestamp when the resource was updated. - google.protobuf.Timestamp update_time = 4 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Set of label tags associated with the resource. - map labels = 5; - - // - // Determines if server allows plaintext connections. If set to true, server - // allows plain text connections. By default, it is set to false. This setting - // is not exclusive of other encryption modes. For example, if `allow_open` - // and `mtls_policy` are set, server allows both plain text and mTLS - // connections. See documentation of other encryption modes to confirm - // compatibility. - // - // Consider using it if you wish to upgrade in place your deployment to TLS - // while having mixed TLS and non-TLS traffic reaching port :80. - bool allow_open = 6; - - // - // Defines a mechanism to provision server identity (public and private keys). - // Cannot be combined with `allow_open` as a permissive mode that allows both - // plain text and TLS is not supported. - CertificateProvider server_certificate = 7; - - // - // Defines a mechanism to provision peer validation certificates for peer to - // peer authentication (Mutual TLS - mTLS). If not specified, client - // certificate will not be requested. The connection is treated as TLS and not - // mTLS. If `allow_open` and `mtls_policy` are set, server allows both plain - // text and mTLS connections. - MTLSPolicy mtls_policy = 8; -} - -// Request used by the ListServerTlsPolicies method. -message ListServerTlsPoliciesRequest { - // Required. The project and location from which the ServerTlsPolicies should - // be listed, specified in the format `projects/*/locations/{location}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Maximum number of ServerTlsPolicies to return per call. - int32 page_size = 2; - - // The value returned by the last `ListServerTlsPoliciesResponse` - // Indicates that this is a continuation of a prior - // `ListServerTlsPolicies` call, and that the system - // should return the next page of data. - string page_token = 3; -} - -// Response returned by the ListServerTlsPolicies method. -message ListServerTlsPoliciesResponse { - // List of ServerTlsPolicy resources. - repeated ServerTlsPolicy server_tls_policies = 1; - - // If there might be more results than those appearing in this response, then - // `next_page_token` is included. To get the next set of results, call this - // method again using the value of `next_page_token` as `page_token`. - string next_page_token = 2; -} - -// Request used by the GetServerTlsPolicy method. -message GetServerTlsPolicyRequest { - // Required. A name of the ServerTlsPolicy to get. Must be in the format - // `projects/*/locations/{location}/serverTlsPolicies/*`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "networksecurity.googleapis.com/ServerTlsPolicy" - } - ]; -} - -// Request used by the CreateServerTlsPolicy method. -message CreateServerTlsPolicyRequest { - // Required. The parent resource of the ServerTlsPolicy. Must be in - // the format `projects/*/locations/{location}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "networksecurity.googleapis.com/ServerTlsPolicy" - } - ]; - - // Required. Short name of the ServerTlsPolicy resource to be created. This - // value should be 1-63 characters long, containing only letters, numbers, - // hyphens, and underscores, and should not start with a number. E.g. - // "server_mtls_policy". - string server_tls_policy_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. ServerTlsPolicy resource to be created. - ServerTlsPolicy server_tls_policy = 3 - [(google.api.field_behavior) = REQUIRED]; -} - -// Request used by UpdateServerTlsPolicy method. -message UpdateServerTlsPolicyRequest { - // Optional. Field mask is used to specify the fields to be overwritten in the - // ServerTlsPolicy resource by the update. The fields - // specified in the update_mask are relative to the resource, not - // the full request. A field will be overwritten if it is in the - // mask. If the user does not provide a mask then all fields will be - // overwritten. - google.protobuf.FieldMask update_mask = 1 - [(google.api.field_behavior) = OPTIONAL]; - - // Required. Updated ServerTlsPolicy resource. - ServerTlsPolicy server_tls_policy = 2 - [(google.api.field_behavior) = REQUIRED]; -} - -// Request used by the DeleteServerTlsPolicy method. -message DeleteServerTlsPolicyRequest { - // Required. A name of the ServerTlsPolicy to delete. Must be in - // the format `projects/*/locations/{location}/serverTlsPolicies/*`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "networksecurity.googleapis.com/ServerTlsPolicy" - } - ]; -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/tls.proto b/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/tls.proto deleted file mode 100644 index f160146c186..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/protos/google/cloud/networksecurity/v1beta1/tls.proto +++ /dev/null @@ -1,78 +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.networksecurity.v1beta1; - -import "google/api/field_behavior.proto"; - -option csharp_namespace = "Google.Cloud.NetworkSecurity.V1Beta1"; -option go_package = "cloud.google.com/go/networksecurity/apiv1beta1/networksecuritypb;networksecuritypb"; -option java_multiple_files = true; -option java_outer_classname = "TlsProto"; -option java_package = "com.google.cloud.networksecurity.v1beta1"; -option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1beta1"; -option ruby_package = "Google::Cloud::NetworkSecurity::V1beta1"; - -// Specification of the GRPC Endpoint. -message GrpcEndpoint { - // Required. The target URI of the gRPC endpoint. Only UDS path is supported, - // and should start with "unix:". - string target_uri = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Specification of ValidationCA. Defines the mechanism to obtain the -// Certificate Authority certificate to validate the peer certificate. -message ValidationCA { - // The type of certificate provider which provides the CA certificate. - oneof type { - // gRPC specific configuration to access the gRPC server to - // obtain the CA certificate. - GrpcEndpoint grpc_endpoint = 2; - - // The certificate provider instance specification that will be passed to - // the data plane, which will be used to load necessary credential - // information. - CertificateProviderInstance certificate_provider_instance = 3; - } -} - -// Specification of a TLS certificate provider instance. Workloads may have one -// or more CertificateProvider instances (plugins) and one of them is enabled -// and configured by specifying this message. Workloads use the values from this -// message to locate and load the CertificateProvider instance configuration. -message CertificateProviderInstance { - // Required. Plugin instance name, used to locate and load CertificateProvider - // instance configuration. Set to "google_cloud_private_spiffe" to use - // Certificate Authority Service certificate provider instance. - string plugin_instance = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Specification of certificate provider. Defines the mechanism to obtain the -// certificate and private key for peer to peer authentication. -message CertificateProvider { - // The type of certificate provider which provides the certificates and - // private keys. - oneof type { - // gRPC specific configuration to access the gRPC server to - // obtain the cert and private key. - GrpcEndpoint grpc_endpoint = 2; - - // The certificate provider instance specification that will be passed to - // the data plane, which will be used to load necessary credential - // information. - CertificateProviderInstance certificate_provider_instance = 3; - } -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_authorization_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_authorization_policy.js deleted file mode 100644 index 09b602c953d..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_authorization_policy.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, authorizationPolicyId, authorizationPolicy) { - // [START networksecurity_v1beta1_generated_NetworkSecurity_CreateAuthorizationPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 of the AuthorizationPolicy. Must be in the - * format `projects/{project}/locations/{location}`. - */ - // const parent = 'abc123' - /** - * Required. Short name of the AuthorizationPolicy resource to be created. - * This value should be 1-63 characters long, containing only - * letters, numbers, hyphens, and underscores, and should not start - * with a number. E.g. "authz_policy". - */ - // const authorizationPolicyId = 'abc123' - /** - * Required. AuthorizationPolicy resource to be created. - */ - // const authorizationPolicy = {} - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callCreateAuthorizationPolicy() { - // Construct request - const request = { - parent, - authorizationPolicyId, - authorizationPolicy, - }; - - // Run request - const [operation] = await networksecurityClient.createAuthorizationPolicy(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateAuthorizationPolicy(); - // [END networksecurity_v1beta1_generated_NetworkSecurity_CreateAuthorizationPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_client_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_client_tls_policy.js deleted file mode 100644 index 73511aa2b59..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_client_tls_policy.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, clientTlsPolicyId, clientTlsPolicy) { - // [START networksecurity_v1beta1_generated_NetworkSecurity_CreateClientTlsPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 of the ClientTlsPolicy. Must be in - * the format `projects/* /locations/{location}`. - */ - // const parent = 'abc123' - /** - * Required. Short name of the ClientTlsPolicy resource to be created. This - * value should be 1-63 characters long, containing only letters, numbers, - * hyphens, and underscores, and should not start with a number. E.g. - * "client_mtls_policy". - */ - // const clientTlsPolicyId = 'abc123' - /** - * Required. ClientTlsPolicy resource to be created. - */ - // const clientTlsPolicy = {} - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callCreateClientTlsPolicy() { - // Construct request - const request = { - parent, - clientTlsPolicyId, - clientTlsPolicy, - }; - - // Run request - const [operation] = await networksecurityClient.createClientTlsPolicy(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateClientTlsPolicy(); - // [END networksecurity_v1beta1_generated_NetworkSecurity_CreateClientTlsPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_server_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_server_tls_policy.js deleted file mode 100644 index 2e9fa72315a..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.create_server_tls_policy.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, serverTlsPolicyId, serverTlsPolicy) { - // [START networksecurity_v1beta1_generated_NetworkSecurity_CreateServerTlsPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 of the ServerTlsPolicy. Must be in - * the format `projects/* /locations/{location}`. - */ - // const parent = 'abc123' - /** - * Required. Short name of the ServerTlsPolicy resource to be created. This - * value should be 1-63 characters long, containing only letters, numbers, - * hyphens, and underscores, and should not start with a number. E.g. - * "server_mtls_policy". - */ - // const serverTlsPolicyId = 'abc123' - /** - * Required. ServerTlsPolicy resource to be created. - */ - // const serverTlsPolicy = {} - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callCreateServerTlsPolicy() { - // Construct request - const request = { - parent, - serverTlsPolicyId, - serverTlsPolicy, - }; - - // Run request - const [operation] = await networksecurityClient.createServerTlsPolicy(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateServerTlsPolicy(); - // [END networksecurity_v1beta1_generated_NetworkSecurity_CreateServerTlsPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_authorization_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_authorization_policy.js deleted file mode 100644 index 13551ea50ae..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_authorization_policy.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 networksecurity_v1beta1_generated_NetworkSecurity_DeleteAuthorizationPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A name of the AuthorizationPolicy to delete. Must be in the - * format `projects/{project}/locations/{location}/authorizationPolicies/*`. - */ - // const name = 'abc123' - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callDeleteAuthorizationPolicy() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await networksecurityClient.deleteAuthorizationPolicy(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteAuthorizationPolicy(); - // [END networksecurity_v1beta1_generated_NetworkSecurity_DeleteAuthorizationPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_client_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_client_tls_policy.js deleted file mode 100644 index 7b9f981d457..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_client_tls_policy.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 networksecurity_v1beta1_generated_NetworkSecurity_DeleteClientTlsPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A name of the ClientTlsPolicy to delete. Must be in - * the format `projects/* /locations/{location}/clientTlsPolicies/*`. - */ - // const name = 'abc123' - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callDeleteClientTlsPolicy() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await networksecurityClient.deleteClientTlsPolicy(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteClientTlsPolicy(); - // [END networksecurity_v1beta1_generated_NetworkSecurity_DeleteClientTlsPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_server_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_server_tls_policy.js deleted file mode 100644 index 6fd1a0a27d7..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.delete_server_tls_policy.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 networksecurity_v1beta1_generated_NetworkSecurity_DeleteServerTlsPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A name of the ServerTlsPolicy to delete. Must be in - * the format `projects/* /locations/{location}/serverTlsPolicies/*`. - */ - // const name = 'abc123' - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callDeleteServerTlsPolicy() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await networksecurityClient.deleteServerTlsPolicy(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteServerTlsPolicy(); - // [END networksecurity_v1beta1_generated_NetworkSecurity_DeleteServerTlsPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_authorization_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_authorization_policy.js deleted file mode 100644 index c3d6417d0fd..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_authorization_policy.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 networksecurity_v1beta1_generated_NetworkSecurity_GetAuthorizationPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A name of the AuthorizationPolicy to get. Must be in the format - * `projects/{project}/locations/{location}/authorizationPolicies/*`. - */ - // const name = 'abc123' - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callGetAuthorizationPolicy() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await networksecurityClient.getAuthorizationPolicy(request); - console.log(response); - } - - callGetAuthorizationPolicy(); - // [END networksecurity_v1beta1_generated_NetworkSecurity_GetAuthorizationPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_client_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_client_tls_policy.js deleted file mode 100644 index 1004b7ad7bd..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_client_tls_policy.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 networksecurity_v1beta1_generated_NetworkSecurity_GetClientTlsPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A name of the ClientTlsPolicy to get. Must be in the format - * `projects/* /locations/{location}/clientTlsPolicies/*`. - */ - // const name = 'abc123' - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callGetClientTlsPolicy() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await networksecurityClient.getClientTlsPolicy(request); - console.log(response); - } - - callGetClientTlsPolicy(); - // [END networksecurity_v1beta1_generated_NetworkSecurity_GetClientTlsPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_server_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_server_tls_policy.js deleted file mode 100644 index 939edabe360..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.get_server_tls_policy.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 networksecurity_v1beta1_generated_NetworkSecurity_GetServerTlsPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A name of the ServerTlsPolicy to get. Must be in the format - * `projects/* /locations/{location}/serverTlsPolicies/*`. - */ - // const name = 'abc123' - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callGetServerTlsPolicy() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await networksecurityClient.getServerTlsPolicy(request); - console.log(response); - } - - callGetServerTlsPolicy(); - // [END networksecurity_v1beta1_generated_NetworkSecurity_GetServerTlsPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_authorization_policies.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_authorization_policies.js deleted file mode 100644 index 1e87e193215..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_authorization_policies.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) { - // [START networksecurity_v1beta1_generated_NetworkSecurity_ListAuthorizationPolicies_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project and location from which the AuthorizationPolicies - * should be listed, specified in the format - * `projects/{project}/locations/{location}`. - */ - // const parent = 'abc123' - /** - * Maximum number of AuthorizationPolicies to return per call. - */ - // const pageSize = 1234 - /** - * The value returned by the last - * `ListAuthorizationPoliciesResponse` Indicates that this is a - * continuation of a prior `ListAuthorizationPolicies` call, and - * that the system should return the next page of data. - */ - // const pageToken = 'abc123' - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callListAuthorizationPolicies() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await networksecurityClient.listAuthorizationPoliciesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListAuthorizationPolicies(); - // [END networksecurity_v1beta1_generated_NetworkSecurity_ListAuthorizationPolicies_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_client_tls_policies.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_client_tls_policies.js deleted file mode 100644 index 2b9b7aa9706..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_client_tls_policies.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 networksecurity_v1beta1_generated_NetworkSecurity_ListClientTlsPolicies_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project and location from which the ClientTlsPolicies should - * be listed, specified in the format `projects/* /locations/{location}`. - */ - // const parent = 'abc123' - /** - * Maximum number of ClientTlsPolicies to return per call. - */ - // const pageSize = 1234 - /** - * The value returned by the last `ListClientTlsPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListClientTlsPolicies` call, and that the system - * should return the next page of data. - */ - // const pageToken = 'abc123' - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callListClientTlsPolicies() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await networksecurityClient.listClientTlsPoliciesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListClientTlsPolicies(); - // [END networksecurity_v1beta1_generated_NetworkSecurity_ListClientTlsPolicies_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_server_tls_policies.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_server_tls_policies.js deleted file mode 100644 index 5be89c04144..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.list_server_tls_policies.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 networksecurity_v1beta1_generated_NetworkSecurity_ListServerTlsPolicies_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project and location from which the ServerTlsPolicies should - * be listed, specified in the format `projects/* /locations/{location}`. - */ - // const parent = 'abc123' - /** - * Maximum number of ServerTlsPolicies to return per call. - */ - // const pageSize = 1234 - /** - * The value returned by the last `ListServerTlsPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListServerTlsPolicies` call, and that the system - * should return the next page of data. - */ - // const pageToken = 'abc123' - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callListServerTlsPolicies() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await networksecurityClient.listServerTlsPoliciesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListServerTlsPolicies(); - // [END networksecurity_v1beta1_generated_NetworkSecurity_ListServerTlsPolicies_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_authorization_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_authorization_policy.js deleted file mode 100644 index 3b5db121a7c..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_authorization_policy.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(authorizationPolicy) { - // [START networksecurity_v1beta1_generated_NetworkSecurity_UpdateAuthorizationPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Optional. Field mask is used to specify the fields to be overwritten in the - * AuthorizationPolicy resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - */ - // const updateMask = {} - /** - * Required. Updated AuthorizationPolicy resource. - */ - // const authorizationPolicy = {} - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callUpdateAuthorizationPolicy() { - // Construct request - const request = { - authorizationPolicy, - }; - - // Run request - const [operation] = await networksecurityClient.updateAuthorizationPolicy(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateAuthorizationPolicy(); - // [END networksecurity_v1beta1_generated_NetworkSecurity_UpdateAuthorizationPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_client_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_client_tls_policy.js deleted file mode 100644 index c18ee51a0b5..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_client_tls_policy.js +++ /dev/null @@ -1,71 +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(clientTlsPolicy) { - // [START networksecurity_v1beta1_generated_NetworkSecurity_UpdateClientTlsPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Optional. Field mask is used to specify the fields to be overwritten in the - * ClientTlsPolicy resource by the update. The fields - * specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the - * mask. If the user does not provide a mask then all fields will be - * overwritten. - */ - // const updateMask = {} - /** - * Required. Updated ClientTlsPolicy resource. - */ - // const clientTlsPolicy = {} - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callUpdateClientTlsPolicy() { - // Construct request - const request = { - clientTlsPolicy, - }; - - // Run request - const [operation] = await networksecurityClient.updateClientTlsPolicy(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateClientTlsPolicy(); - // [END networksecurity_v1beta1_generated_NetworkSecurity_UpdateClientTlsPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_server_tls_policy.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_server_tls_policy.js deleted file mode 100644 index b6c9a2252d0..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/network_security.update_server_tls_policy.js +++ /dev/null @@ -1,71 +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(serverTlsPolicy) { - // [START networksecurity_v1beta1_generated_NetworkSecurity_UpdateServerTlsPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Optional. Field mask is used to specify the fields to be overwritten in the - * ServerTlsPolicy resource by the update. The fields - * specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the - * mask. If the user does not provide a mask then all fields will be - * overwritten. - */ - // const updateMask = {} - /** - * Required. Updated ServerTlsPolicy resource. - */ - // const serverTlsPolicy = {} - - // Imports the Networksecurity library - const {NetworkSecurityClient} = require('@google-cloud/network-security').v1beta1; - - // Instantiates a client - const networksecurityClient = new NetworkSecurityClient(); - - async function callUpdateServerTlsPolicy() { - // Construct request - const request = { - serverTlsPolicy, - }; - - // Run request - const [operation] = await networksecurityClient.updateServerTlsPolicy(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateServerTlsPolicy(); - // [END networksecurity_v1beta1_generated_NetworkSecurity_UpdateServerTlsPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.networksecurity.v1beta1.json b/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.networksecurity.v1beta1.json deleted file mode 100644 index e6aa109a35f..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.networksecurity.v1beta1.json +++ /dev/null @@ -1,675 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-networksecurity", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.networksecurity.v1beta1", - "version": "v1beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_ListAuthorizationPolicies_async", - "title": "NetworkSecurity listAuthorizationPolicies Sample", - "origin": "API_DEFINITION", - "description": " Lists AuthorizationPolicies in a given project and location.", - "canonical": true, - "file": "network_security.list_authorization_policies.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListAuthorizationPolicies", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.ListAuthorizationPolicies", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesResponse", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" - }, - "method": { - "shortName": "ListAuthorizationPolicies", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.ListAuthorizationPolicies", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_GetAuthorizationPolicy_async", - "title": "NetworkSecurity getAuthorizationPolicy Sample", - "origin": "API_DEFINITION", - "description": " Gets details of a single AuthorizationPolicy.", - "canonical": true, - "file": "network_security.get_authorization_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetAuthorizationPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.GetAuthorizationPolicy", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.networksecurity.v1beta1.AuthorizationPolicy", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" - }, - "method": { - "shortName": "GetAuthorizationPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.GetAuthorizationPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_CreateAuthorizationPolicy_async", - "title": "NetworkSecurity createAuthorizationPolicy Sample", - "origin": "API_DEFINITION", - "description": " Creates a new AuthorizationPolicy in a given project and location.", - "canonical": true, - "file": "network_security.create_authorization_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateAuthorizationPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.CreateAuthorizationPolicy", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "authorization_policy_id", - "type": "TYPE_STRING" - }, - { - "name": "authorization_policy", - "type": ".google.cloud.networksecurity.v1beta1.AuthorizationPolicy" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" - }, - "method": { - "shortName": "CreateAuthorizationPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.CreateAuthorizationPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_UpdateAuthorizationPolicy_async", - "title": "NetworkSecurity updateAuthorizationPolicy Sample", - "origin": "API_DEFINITION", - "description": " Updates the parameters of a single AuthorizationPolicy.", - "canonical": true, - "file": "network_security.update_authorization_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateAuthorizationPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.UpdateAuthorizationPolicy", - "async": true, - "parameters": [ - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "authorization_policy", - "type": ".google.cloud.networksecurity.v1beta1.AuthorizationPolicy" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" - }, - "method": { - "shortName": "UpdateAuthorizationPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.UpdateAuthorizationPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_DeleteAuthorizationPolicy_async", - "title": "NetworkSecurity deleteAuthorizationPolicy Sample", - "origin": "API_DEFINITION", - "description": " Deletes a single AuthorizationPolicy.", - "canonical": true, - "file": "network_security.delete_authorization_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteAuthorizationPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.DeleteAuthorizationPolicy", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" - }, - "method": { - "shortName": "DeleteAuthorizationPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.DeleteAuthorizationPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_ListServerTlsPolicies_async", - "title": "NetworkSecurity listServerTlsPolicies Sample", - "origin": "API_DEFINITION", - "description": " Lists ServerTlsPolicies in a given project and location.", - "canonical": true, - "file": "network_security.list_server_tls_policies.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListServerTlsPolicies", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.ListServerTlsPolicies", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesResponse", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" - }, - "method": { - "shortName": "ListServerTlsPolicies", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.ListServerTlsPolicies", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_GetServerTlsPolicy_async", - "title": "NetworkSecurity getServerTlsPolicy Sample", - "origin": "API_DEFINITION", - "description": " Gets details of a single ServerTlsPolicy.", - "canonical": true, - "file": "network_security.get_server_tls_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetServerTlsPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.GetServerTlsPolicy", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.networksecurity.v1beta1.ServerTlsPolicy", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" - }, - "method": { - "shortName": "GetServerTlsPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.GetServerTlsPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_CreateServerTlsPolicy_async", - "title": "NetworkSecurity createServerTlsPolicy Sample", - "origin": "API_DEFINITION", - "description": " Creates a new ServerTlsPolicy in a given project and location.", - "canonical": true, - "file": "network_security.create_server_tls_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateServerTlsPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.CreateServerTlsPolicy", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "server_tls_policy_id", - "type": "TYPE_STRING" - }, - { - "name": "server_tls_policy", - "type": ".google.cloud.networksecurity.v1beta1.ServerTlsPolicy" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" - }, - "method": { - "shortName": "CreateServerTlsPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.CreateServerTlsPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_UpdateServerTlsPolicy_async", - "title": "NetworkSecurity updateServerTlsPolicy Sample", - "origin": "API_DEFINITION", - "description": " Updates the parameters of a single ServerTlsPolicy.", - "canonical": true, - "file": "network_security.update_server_tls_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateServerTlsPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.UpdateServerTlsPolicy", - "async": true, - "parameters": [ - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "server_tls_policy", - "type": ".google.cloud.networksecurity.v1beta1.ServerTlsPolicy" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" - }, - "method": { - "shortName": "UpdateServerTlsPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.UpdateServerTlsPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_DeleteServerTlsPolicy_async", - "title": "NetworkSecurity deleteServerTlsPolicy Sample", - "origin": "API_DEFINITION", - "description": " Deletes a single ServerTlsPolicy.", - "canonical": true, - "file": "network_security.delete_server_tls_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteServerTlsPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.DeleteServerTlsPolicy", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" - }, - "method": { - "shortName": "DeleteServerTlsPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.DeleteServerTlsPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_ListClientTlsPolicies_async", - "title": "NetworkSecurity listClientTlsPolicies Sample", - "origin": "API_DEFINITION", - "description": " Lists ClientTlsPolicies in a given project and location.", - "canonical": true, - "file": "network_security.list_client_tls_policies.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListClientTlsPolicies", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.ListClientTlsPolicies", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesResponse", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" - }, - "method": { - "shortName": "ListClientTlsPolicies", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.ListClientTlsPolicies", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_GetClientTlsPolicy_async", - "title": "NetworkSecurity getClientTlsPolicy Sample", - "origin": "API_DEFINITION", - "description": " Gets details of a single ClientTlsPolicy.", - "canonical": true, - "file": "network_security.get_client_tls_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetClientTlsPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.GetClientTlsPolicy", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.networksecurity.v1beta1.ClientTlsPolicy", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" - }, - "method": { - "shortName": "GetClientTlsPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.GetClientTlsPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_CreateClientTlsPolicy_async", - "title": "NetworkSecurity createClientTlsPolicy Sample", - "origin": "API_DEFINITION", - "description": " Creates a new ClientTlsPolicy in a given project and location.", - "canonical": true, - "file": "network_security.create_client_tls_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateClientTlsPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.CreateClientTlsPolicy", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "client_tls_policy_id", - "type": "TYPE_STRING" - }, - { - "name": "client_tls_policy", - "type": ".google.cloud.networksecurity.v1beta1.ClientTlsPolicy" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" - }, - "method": { - "shortName": "CreateClientTlsPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.CreateClientTlsPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_UpdateClientTlsPolicy_async", - "title": "NetworkSecurity updateClientTlsPolicy Sample", - "origin": "API_DEFINITION", - "description": " Updates the parameters of a single ClientTlsPolicy.", - "canonical": true, - "file": "network_security.update_client_tls_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateClientTlsPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.UpdateClientTlsPolicy", - "async": true, - "parameters": [ - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "client_tls_policy", - "type": ".google.cloud.networksecurity.v1beta1.ClientTlsPolicy" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" - }, - "method": { - "shortName": "UpdateClientTlsPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.UpdateClientTlsPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" - } - } - } - }, - { - "regionTag": "networksecurity_v1beta1_generated_NetworkSecurity_DeleteClientTlsPolicy_async", - "title": "NetworkSecurity deleteClientTlsPolicy Sample", - "origin": "API_DEFINITION", - "description": " Deletes a single ClientTlsPolicy.", - "canonical": true, - "file": "network_security.delete_client_tls_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteClientTlsPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.DeleteClientTlsPolicy", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NetworkSecurityClient", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurityClient" - }, - "method": { - "shortName": "DeleteClientTlsPolicy", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity.DeleteClientTlsPolicy", - "service": { - "shortName": "NetworkSecurity", - "fullName": "google.cloud.networksecurity.v1beta1.NetworkSecurity" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/index.ts deleted file mode 100644 index 550885bb0e9..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/index.ts +++ /dev/null @@ -1,25 +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 v1beta1 from './v1beta1'; -const NetworkSecurityClient = v1beta1.NetworkSecurityClient; -type NetworkSecurityClient = v1beta1.NetworkSecurityClient; -export {v1beta1, NetworkSecurityClient}; -export default {v1beta1, NetworkSecurityClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/gapic_metadata.json deleted file mode 100644 index 4378e4f3a6b..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/gapic_metadata.json +++ /dev/null @@ -1,185 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.networksecurity.v1beta1", - "libraryPackage": "@google-cloud/network-security", - "services": { - "NetworkSecurity": { - "clients": { - "grpc": { - "libraryClient": "NetworkSecurityClient", - "rpcs": { - "GetAuthorizationPolicy": { - "methods": [ - "getAuthorizationPolicy" - ] - }, - "GetServerTlsPolicy": { - "methods": [ - "getServerTlsPolicy" - ] - }, - "GetClientTlsPolicy": { - "methods": [ - "getClientTlsPolicy" - ] - }, - "CreateAuthorizationPolicy": { - "methods": [ - "createAuthorizationPolicy" - ] - }, - "UpdateAuthorizationPolicy": { - "methods": [ - "updateAuthorizationPolicy" - ] - }, - "DeleteAuthorizationPolicy": { - "methods": [ - "deleteAuthorizationPolicy" - ] - }, - "CreateServerTlsPolicy": { - "methods": [ - "createServerTlsPolicy" - ] - }, - "UpdateServerTlsPolicy": { - "methods": [ - "updateServerTlsPolicy" - ] - }, - "DeleteServerTlsPolicy": { - "methods": [ - "deleteServerTlsPolicy" - ] - }, - "CreateClientTlsPolicy": { - "methods": [ - "createClientTlsPolicy" - ] - }, - "UpdateClientTlsPolicy": { - "methods": [ - "updateClientTlsPolicy" - ] - }, - "DeleteClientTlsPolicy": { - "methods": [ - "deleteClientTlsPolicy" - ] - }, - "ListAuthorizationPolicies": { - "methods": [ - "listAuthorizationPolicies", - "listAuthorizationPoliciesStream", - "listAuthorizationPoliciesAsync" - ] - }, - "ListServerTlsPolicies": { - "methods": [ - "listServerTlsPolicies", - "listServerTlsPoliciesStream", - "listServerTlsPoliciesAsync" - ] - }, - "ListClientTlsPolicies": { - "methods": [ - "listClientTlsPolicies", - "listClientTlsPoliciesStream", - "listClientTlsPoliciesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "NetworkSecurityClient", - "rpcs": { - "GetAuthorizationPolicy": { - "methods": [ - "getAuthorizationPolicy" - ] - }, - "GetServerTlsPolicy": { - "methods": [ - "getServerTlsPolicy" - ] - }, - "GetClientTlsPolicy": { - "methods": [ - "getClientTlsPolicy" - ] - }, - "CreateAuthorizationPolicy": { - "methods": [ - "createAuthorizationPolicy" - ] - }, - "UpdateAuthorizationPolicy": { - "methods": [ - "updateAuthorizationPolicy" - ] - }, - "DeleteAuthorizationPolicy": { - "methods": [ - "deleteAuthorizationPolicy" - ] - }, - "CreateServerTlsPolicy": { - "methods": [ - "createServerTlsPolicy" - ] - }, - "UpdateServerTlsPolicy": { - "methods": [ - "updateServerTlsPolicy" - ] - }, - "DeleteServerTlsPolicy": { - "methods": [ - "deleteServerTlsPolicy" - ] - }, - "CreateClientTlsPolicy": { - "methods": [ - "createClientTlsPolicy" - ] - }, - "UpdateClientTlsPolicy": { - "methods": [ - "updateClientTlsPolicy" - ] - }, - "DeleteClientTlsPolicy": { - "methods": [ - "deleteClientTlsPolicy" - ] - }, - "ListAuthorizationPolicies": { - "methods": [ - "listAuthorizationPolicies", - "listAuthorizationPoliciesStream", - "listAuthorizationPoliciesAsync" - ] - }, - "ListServerTlsPolicies": { - "methods": [ - "listServerTlsPolicies", - "listServerTlsPoliciesStream", - "listServerTlsPoliciesAsync" - ] - }, - "ListClientTlsPolicies": { - "methods": [ - "listClientTlsPolicies", - "listClientTlsPoliciesStream", - "listClientTlsPoliciesAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/index.ts deleted file mode 100644 index e2b4efdd9b3..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/index.ts +++ /dev/null @@ -1,19 +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 {NetworkSecurityClient} from './network_security_client'; diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_client.ts b/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_client.ts deleted file mode 100644 index 30faca4b9a8..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_client.ts +++ /dev/null @@ -1,2594 +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, IamClient, IamProtos, 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/v1beta1/network_security_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './network_security_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Network Security API provides resources to configure authentication and - * authorization policies. Refer to per API resource documentation for more - * information. - * @class - * @memberof v1beta1 - */ -export class NetworkSecurityClient { - 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}; - iamClient: IamClient; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - networkSecurityStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of NetworkSecurityClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 NetworkSecurityClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof NetworkSecurityClient; - 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.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - - 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 { - 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 = { - authorizationPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/authorizationPolicies/{authorization_policy}' - ), - clientTlsPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/clientTlsPolicies/{client_tls_policy}' - ), - serverTlsPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serverTlsPolicies/{server_tls_policy}' - ), - }; - - // 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 = { - listAuthorizationPolicies: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'authorizationPolicies'), - listServerTlsPolicies: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'serverTlsPolicies'), - listClientTlsPolicies: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'clientTlsPolicies') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1beta1/{resource=projects/*/locations/*/authorizationPolicies/*}:getIamPolicy',additional_bindings: [{get: '/v1beta1/{resource=projects/*/locations/*/serverTlsPolicies/*}:getIamPolicy',},{get: '/v1beta1/{resource=projects/*/locations/*/clientTlsPolicies/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1beta1/{resource=projects/*/locations/*/authorizationPolicies/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1beta1/{resource=projects/*/locations/*/serverTlsPolicies/*}:setIamPolicy',body: '*',},{post: '/v1beta1/{resource=projects/*/locations/*/clientTlsPolicies/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1beta1/{resource=projects/*/locations/*/authorizationPolicies/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1beta1/{resource=projects/*/locations/*/serverTlsPolicies/*}:testIamPermissions',body: '*',},{post: '/v1beta1/{resource=projects/*/locations/*/clientTlsPolicies/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta1/{name=projects/*/locations/*}/operations',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createAuthorizationPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1beta1.AuthorizationPolicy') as gax.protobuf.Type; - const createAuthorizationPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1beta1.OperationMetadata') as gax.protobuf.Type; - const updateAuthorizationPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1beta1.AuthorizationPolicy') as gax.protobuf.Type; - const updateAuthorizationPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1beta1.OperationMetadata') as gax.protobuf.Type; - const deleteAuthorizationPolicyResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteAuthorizationPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1beta1.OperationMetadata') as gax.protobuf.Type; - const createServerTlsPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1beta1.ServerTlsPolicy') as gax.protobuf.Type; - const createServerTlsPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1beta1.OperationMetadata') as gax.protobuf.Type; - const updateServerTlsPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1beta1.ServerTlsPolicy') as gax.protobuf.Type; - const updateServerTlsPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1beta1.OperationMetadata') as gax.protobuf.Type; - const deleteServerTlsPolicyResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteServerTlsPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1beta1.OperationMetadata') as gax.protobuf.Type; - const createClientTlsPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1beta1.ClientTlsPolicy') as gax.protobuf.Type; - const createClientTlsPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1beta1.OperationMetadata') as gax.protobuf.Type; - const updateClientTlsPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1beta1.ClientTlsPolicy') as gax.protobuf.Type; - const updateClientTlsPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1beta1.OperationMetadata') as gax.protobuf.Type; - const deleteClientTlsPolicyResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteClientTlsPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networksecurity.v1beta1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createAuthorizationPolicy: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createAuthorizationPolicyResponse.decode.bind(createAuthorizationPolicyResponse), - createAuthorizationPolicyMetadata.decode.bind(createAuthorizationPolicyMetadata)), - updateAuthorizationPolicy: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateAuthorizationPolicyResponse.decode.bind(updateAuthorizationPolicyResponse), - updateAuthorizationPolicyMetadata.decode.bind(updateAuthorizationPolicyMetadata)), - deleteAuthorizationPolicy: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteAuthorizationPolicyResponse.decode.bind(deleteAuthorizationPolicyResponse), - deleteAuthorizationPolicyMetadata.decode.bind(deleteAuthorizationPolicyMetadata)), - createServerTlsPolicy: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createServerTlsPolicyResponse.decode.bind(createServerTlsPolicyResponse), - createServerTlsPolicyMetadata.decode.bind(createServerTlsPolicyMetadata)), - updateServerTlsPolicy: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateServerTlsPolicyResponse.decode.bind(updateServerTlsPolicyResponse), - updateServerTlsPolicyMetadata.decode.bind(updateServerTlsPolicyMetadata)), - deleteServerTlsPolicy: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteServerTlsPolicyResponse.decode.bind(deleteServerTlsPolicyResponse), - deleteServerTlsPolicyMetadata.decode.bind(deleteServerTlsPolicyMetadata)), - createClientTlsPolicy: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createClientTlsPolicyResponse.decode.bind(createClientTlsPolicyResponse), - createClientTlsPolicyMetadata.decode.bind(createClientTlsPolicyMetadata)), - updateClientTlsPolicy: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateClientTlsPolicyResponse.decode.bind(updateClientTlsPolicyResponse), - updateClientTlsPolicyMetadata.decode.bind(updateClientTlsPolicyMetadata)), - deleteClientTlsPolicy: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteClientTlsPolicyResponse.decode.bind(deleteClientTlsPolicyResponse), - deleteClientTlsPolicyMetadata.decode.bind(deleteClientTlsPolicyMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networksecurity.v1beta1.NetworkSecurity', 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.networkSecurityStub) { - return this.networkSecurityStub; - } - - // Put together the "service stub" for - // google.cloud.networksecurity.v1beta1.NetworkSecurity. - this.networkSecurityStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networksecurity.v1beta1.NetworkSecurity') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.networksecurity.v1beta1.NetworkSecurity, - 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 networkSecurityStubMethods = - ['listAuthorizationPolicies', 'getAuthorizationPolicy', 'createAuthorizationPolicy', 'updateAuthorizationPolicy', 'deleteAuthorizationPolicy', 'listServerTlsPolicies', 'getServerTlsPolicy', 'createServerTlsPolicy', 'updateServerTlsPolicy', 'deleteServerTlsPolicy', 'listClientTlsPolicies', 'getClientTlsPolicy', 'createClientTlsPolicy', 'updateClientTlsPolicy', 'deleteClientTlsPolicy']; - for (const methodName of networkSecurityStubMethods) { - const callPromise = this.networkSecurityStub.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.networkSecurityStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'networksecurity.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 'networksecurity.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 details of a single AuthorizationPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the AuthorizationPolicy to get. Must be in the format - * `projects/{project}/locations/{location}/authorizationPolicies/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy|AuthorizationPolicy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.get_authorization_policy.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_GetAuthorizationPolicy_async - */ - getAuthorizationPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.IGetAuthorizationPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy, - protos.google.cloud.networksecurity.v1beta1.IGetAuthorizationPolicyRequest|undefined, {}|undefined - ]>; - getAuthorizationPolicy( - request: protos.google.cloud.networksecurity.v1beta1.IGetAuthorizationPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy, - protos.google.cloud.networksecurity.v1beta1.IGetAuthorizationPolicyRequest|null|undefined, - {}|null|undefined>): void; - getAuthorizationPolicy( - request: protos.google.cloud.networksecurity.v1beta1.IGetAuthorizationPolicyRequest, - callback: Callback< - protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy, - protos.google.cloud.networksecurity.v1beta1.IGetAuthorizationPolicyRequest|null|undefined, - {}|null|undefined>): void; - getAuthorizationPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.IGetAuthorizationPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy, - protos.google.cloud.networksecurity.v1beta1.IGetAuthorizationPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy, - protos.google.cloud.networksecurity.v1beta1.IGetAuthorizationPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy, - protos.google.cloud.networksecurity.v1beta1.IGetAuthorizationPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getAuthorizationPolicy(request, options, callback); - } -/** - * Gets details of a single ServerTlsPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the ServerTlsPolicy to get. Must be in the format - * `projects/* /locations/{location}/serverTlsPolicies/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy|ServerTlsPolicy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.get_server_tls_policy.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_GetServerTlsPolicy_async - */ - getServerTlsPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.IGetServerTlsPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy, - protos.google.cloud.networksecurity.v1beta1.IGetServerTlsPolicyRequest|undefined, {}|undefined - ]>; - getServerTlsPolicy( - request: protos.google.cloud.networksecurity.v1beta1.IGetServerTlsPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy, - protos.google.cloud.networksecurity.v1beta1.IGetServerTlsPolicyRequest|null|undefined, - {}|null|undefined>): void; - getServerTlsPolicy( - request: protos.google.cloud.networksecurity.v1beta1.IGetServerTlsPolicyRequest, - callback: Callback< - protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy, - protos.google.cloud.networksecurity.v1beta1.IGetServerTlsPolicyRequest|null|undefined, - {}|null|undefined>): void; - getServerTlsPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.IGetServerTlsPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy, - protos.google.cloud.networksecurity.v1beta1.IGetServerTlsPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy, - protos.google.cloud.networksecurity.v1beta1.IGetServerTlsPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy, - protos.google.cloud.networksecurity.v1beta1.IGetServerTlsPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getServerTlsPolicy(request, options, callback); - } -/** - * Gets details of a single ClientTlsPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the ClientTlsPolicy to get. Must be in the format - * `projects/* /locations/{location}/clientTlsPolicies/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy|ClientTlsPolicy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.get_client_tls_policy.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_GetClientTlsPolicy_async - */ - getClientTlsPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.IGetClientTlsPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy, - protos.google.cloud.networksecurity.v1beta1.IGetClientTlsPolicyRequest|undefined, {}|undefined - ]>; - getClientTlsPolicy( - request: protos.google.cloud.networksecurity.v1beta1.IGetClientTlsPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy, - protos.google.cloud.networksecurity.v1beta1.IGetClientTlsPolicyRequest|null|undefined, - {}|null|undefined>): void; - getClientTlsPolicy( - request: protos.google.cloud.networksecurity.v1beta1.IGetClientTlsPolicyRequest, - callback: Callback< - protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy, - protos.google.cloud.networksecurity.v1beta1.IGetClientTlsPolicyRequest|null|undefined, - {}|null|undefined>): void; - getClientTlsPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.IGetClientTlsPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy, - protos.google.cloud.networksecurity.v1beta1.IGetClientTlsPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy, - protos.google.cloud.networksecurity.v1beta1.IGetClientTlsPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy, - protos.google.cloud.networksecurity.v1beta1.IGetClientTlsPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getClientTlsPolicy(request, options, callback); - } - -/** - * Creates a new AuthorizationPolicy in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the AuthorizationPolicy. Must be in the - * format `projects/{project}/locations/{location}`. - * @param {string} request.authorizationPolicyId - * Required. Short name of the AuthorizationPolicy resource to be created. - * This value should be 1-63 characters long, containing only - * letters, numbers, hyphens, and underscores, and should not start - * with a number. E.g. "authz_policy". - * @param {google.cloud.networksecurity.v1beta1.AuthorizationPolicy} request.authorizationPolicy - * Required. AuthorizationPolicy resource to be created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.create_authorization_policy.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_CreateAuthorizationPolicy_async - */ - createAuthorizationPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.ICreateAuthorizationPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createAuthorizationPolicy( - request: protos.google.cloud.networksecurity.v1beta1.ICreateAuthorizationPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createAuthorizationPolicy( - request: protos.google.cloud.networksecurity.v1beta1.ICreateAuthorizationPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createAuthorizationPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.ICreateAuthorizationPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createAuthorizationPolicy(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createAuthorizationPolicy()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.create_authorization_policy.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_CreateAuthorizationPolicy_async - */ - async checkCreateAuthorizationPolicyProgress(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.createAuthorizationPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the parameters of a single AuthorizationPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * AuthorizationPolicy resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.networksecurity.v1beta1.AuthorizationPolicy} request.authorizationPolicy - * Required. Updated AuthorizationPolicy resource. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.update_authorization_policy.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_UpdateAuthorizationPolicy_async - */ - updateAuthorizationPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.IUpdateAuthorizationPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateAuthorizationPolicy( - request: protos.google.cloud.networksecurity.v1beta1.IUpdateAuthorizationPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateAuthorizationPolicy( - request: protos.google.cloud.networksecurity.v1beta1.IUpdateAuthorizationPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateAuthorizationPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.IUpdateAuthorizationPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'authorization_policy.name': request.authorizationPolicy!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateAuthorizationPolicy(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateAuthorizationPolicy()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.update_authorization_policy.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_UpdateAuthorizationPolicy_async - */ - async checkUpdateAuthorizationPolicyProgress(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.updateAuthorizationPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a single AuthorizationPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the AuthorizationPolicy to delete. Must be in the - * format `projects/{project}/locations/{location}/authorizationPolicies/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.delete_authorization_policy.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_DeleteAuthorizationPolicy_async - */ - deleteAuthorizationPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.IDeleteAuthorizationPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteAuthorizationPolicy( - request: protos.google.cloud.networksecurity.v1beta1.IDeleteAuthorizationPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteAuthorizationPolicy( - request: protos.google.cloud.networksecurity.v1beta1.IDeleteAuthorizationPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteAuthorizationPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.IDeleteAuthorizationPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteAuthorizationPolicy(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteAuthorizationPolicy()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.delete_authorization_policy.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_DeleteAuthorizationPolicy_async - */ - async checkDeleteAuthorizationPolicyProgress(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.deleteAuthorizationPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Creates a new ServerTlsPolicy in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the ServerTlsPolicy. Must be in - * the format `projects/* /locations/{location}`. - * @param {string} request.serverTlsPolicyId - * Required. Short name of the ServerTlsPolicy resource to be created. This - * value should be 1-63 characters long, containing only letters, numbers, - * hyphens, and underscores, and should not start with a number. E.g. - * "server_mtls_policy". - * @param {google.cloud.networksecurity.v1beta1.ServerTlsPolicy} request.serverTlsPolicy - * Required. ServerTlsPolicy resource to be created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.create_server_tls_policy.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_CreateServerTlsPolicy_async - */ - createServerTlsPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.ICreateServerTlsPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createServerTlsPolicy( - request: protos.google.cloud.networksecurity.v1beta1.ICreateServerTlsPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createServerTlsPolicy( - request: protos.google.cloud.networksecurity.v1beta1.ICreateServerTlsPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createServerTlsPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.ICreateServerTlsPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createServerTlsPolicy(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createServerTlsPolicy()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.create_server_tls_policy.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_CreateServerTlsPolicy_async - */ - async checkCreateServerTlsPolicyProgress(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.createServerTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the parameters of a single ServerTlsPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * ServerTlsPolicy resource by the update. The fields - * specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the - * mask. If the user does not provide a mask then all fields will be - * overwritten. - * @param {google.cloud.networksecurity.v1beta1.ServerTlsPolicy} request.serverTlsPolicy - * Required. Updated ServerTlsPolicy resource. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.update_server_tls_policy.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_UpdateServerTlsPolicy_async - */ - updateServerTlsPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.IUpdateServerTlsPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateServerTlsPolicy( - request: protos.google.cloud.networksecurity.v1beta1.IUpdateServerTlsPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateServerTlsPolicy( - request: protos.google.cloud.networksecurity.v1beta1.IUpdateServerTlsPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateServerTlsPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.IUpdateServerTlsPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'server_tls_policy.name': request.serverTlsPolicy!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateServerTlsPolicy(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateServerTlsPolicy()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.update_server_tls_policy.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_UpdateServerTlsPolicy_async - */ - async checkUpdateServerTlsPolicyProgress(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.updateServerTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a single ServerTlsPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the ServerTlsPolicy to delete. Must be in - * the format `projects/* /locations/{location}/serverTlsPolicies/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.delete_server_tls_policy.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_DeleteServerTlsPolicy_async - */ - deleteServerTlsPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.IDeleteServerTlsPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteServerTlsPolicy( - request: protos.google.cloud.networksecurity.v1beta1.IDeleteServerTlsPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteServerTlsPolicy( - request: protos.google.cloud.networksecurity.v1beta1.IDeleteServerTlsPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteServerTlsPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.IDeleteServerTlsPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteServerTlsPolicy(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteServerTlsPolicy()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.delete_server_tls_policy.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_DeleteServerTlsPolicy_async - */ - async checkDeleteServerTlsPolicyProgress(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.deleteServerTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Creates a new ClientTlsPolicy in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the ClientTlsPolicy. Must be in - * the format `projects/* /locations/{location}`. - * @param {string} request.clientTlsPolicyId - * Required. Short name of the ClientTlsPolicy resource to be created. This - * value should be 1-63 characters long, containing only letters, numbers, - * hyphens, and underscores, and should not start with a number. E.g. - * "client_mtls_policy". - * @param {google.cloud.networksecurity.v1beta1.ClientTlsPolicy} request.clientTlsPolicy - * Required. ClientTlsPolicy resource to be created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.create_client_tls_policy.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_CreateClientTlsPolicy_async - */ - createClientTlsPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.ICreateClientTlsPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createClientTlsPolicy( - request: protos.google.cloud.networksecurity.v1beta1.ICreateClientTlsPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createClientTlsPolicy( - request: protos.google.cloud.networksecurity.v1beta1.ICreateClientTlsPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createClientTlsPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.ICreateClientTlsPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createClientTlsPolicy(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createClientTlsPolicy()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.create_client_tls_policy.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_CreateClientTlsPolicy_async - */ - async checkCreateClientTlsPolicyProgress(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.createClientTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the parameters of a single ClientTlsPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * ClientTlsPolicy resource by the update. The fields - * specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the - * mask. If the user does not provide a mask then all fields will be - * overwritten. - * @param {google.cloud.networksecurity.v1beta1.ClientTlsPolicy} request.clientTlsPolicy - * Required. Updated ClientTlsPolicy resource. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.update_client_tls_policy.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_UpdateClientTlsPolicy_async - */ - updateClientTlsPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.IUpdateClientTlsPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateClientTlsPolicy( - request: protos.google.cloud.networksecurity.v1beta1.IUpdateClientTlsPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateClientTlsPolicy( - request: protos.google.cloud.networksecurity.v1beta1.IUpdateClientTlsPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateClientTlsPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.IUpdateClientTlsPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'client_tls_policy.name': request.clientTlsPolicy!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateClientTlsPolicy(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateClientTlsPolicy()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.update_client_tls_policy.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_UpdateClientTlsPolicy_async - */ - async checkUpdateClientTlsPolicyProgress(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.updateClientTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a single ClientTlsPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the ClientTlsPolicy to delete. Must be in - * the format `projects/* /locations/{location}/clientTlsPolicies/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.delete_client_tls_policy.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_DeleteClientTlsPolicy_async - */ - deleteClientTlsPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.IDeleteClientTlsPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteClientTlsPolicy( - request: protos.google.cloud.networksecurity.v1beta1.IDeleteClientTlsPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteClientTlsPolicy( - request: protos.google.cloud.networksecurity.v1beta1.IDeleteClientTlsPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteClientTlsPolicy( - request?: protos.google.cloud.networksecurity.v1beta1.IDeleteClientTlsPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteClientTlsPolicy(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteClientTlsPolicy()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.delete_client_tls_policy.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_DeleteClientTlsPolicy_async - */ - async checkDeleteClientTlsPolicyProgress(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.deleteClientTlsPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists AuthorizationPolicies in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the AuthorizationPolicies - * should be listed, specified in the format - * `projects/{project}/locations/{location}`. - * @param {number} request.pageSize - * Maximum number of AuthorizationPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last - * `ListAuthorizationPoliciesResponse` Indicates that this is a - * continuation of a prior `ListAuthorizationPolicies` call, and - * that the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy|AuthorizationPolicy}. - * 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 `listAuthorizationPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listAuthorizationPolicies( - request?: protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy[], - protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest|null, - protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesResponse - ]>; - listAuthorizationPolicies( - request: protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest, - protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy>): void; - listAuthorizationPolicies( - request: protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest, - callback: PaginationCallback< - protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest, - protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy>): void; - listAuthorizationPolicies( - request?: protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest, - protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy>, - callback?: PaginationCallback< - protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest, - protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy>): - Promise<[ - protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy[], - protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest|null, - protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listAuthorizationPolicies(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the AuthorizationPolicies - * should be listed, specified in the format - * `projects/{project}/locations/{location}`. - * @param {number} request.pageSize - * Maximum number of AuthorizationPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last - * `ListAuthorizationPoliciesResponse` Indicates that this is a - * continuation of a prior `ListAuthorizationPolicies` call, and - * that the system should return the next page of data. - * @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 protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy|AuthorizationPolicy} 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 `listAuthorizationPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listAuthorizationPoliciesStream( - request?: protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest, - 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['listAuthorizationPolicies']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listAuthorizationPolicies.createStream( - this.innerApiCalls.listAuthorizationPolicies as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listAuthorizationPolicies`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the AuthorizationPolicies - * should be listed, specified in the format - * `projects/{project}/locations/{location}`. - * @param {number} request.pageSize - * Maximum number of AuthorizationPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last - * `ListAuthorizationPoliciesResponse` Indicates that this is a - * continuation of a prior `ListAuthorizationPolicies` call, and - * that the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy|AuthorizationPolicy}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.list_authorization_policies.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_ListAuthorizationPolicies_async - */ - listAuthorizationPoliciesAsync( - request?: protos.google.cloud.networksecurity.v1beta1.IListAuthorizationPoliciesRequest, - 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['listAuthorizationPolicies']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listAuthorizationPolicies.asyncIterate( - this.innerApiCalls['listAuthorizationPolicies'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists ServerTlsPolicies in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the ServerTlsPolicies should - * be listed, specified in the format `projects/* /locations/{location}`. - * @param {number} request.pageSize - * Maximum number of ServerTlsPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListServerTlsPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListServerTlsPolicies` call, and that the system - * should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy|ServerTlsPolicy}. - * 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 `listServerTlsPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listServerTlsPolicies( - request?: protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy[], - protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest|null, - protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesResponse - ]>; - listServerTlsPolicies( - request: protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest, - protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy>): void; - listServerTlsPolicies( - request: protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest, - callback: PaginationCallback< - protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest, - protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy>): void; - listServerTlsPolicies( - request?: protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest, - protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy>, - callback?: PaginationCallback< - protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest, - protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy>): - Promise<[ - protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy[], - protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest|null, - protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listServerTlsPolicies(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the ServerTlsPolicies should - * be listed, specified in the format `projects/* /locations/{location}`. - * @param {number} request.pageSize - * Maximum number of ServerTlsPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListServerTlsPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListServerTlsPolicies` call, and that the system - * should return the next page of data. - * @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 protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy|ServerTlsPolicy} 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 `listServerTlsPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listServerTlsPoliciesStream( - request?: protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest, - 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['listServerTlsPolicies']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServerTlsPolicies.createStream( - this.innerApiCalls.listServerTlsPolicies as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listServerTlsPolicies`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the ServerTlsPolicies should - * be listed, specified in the format `projects/* /locations/{location}`. - * @param {number} request.pageSize - * Maximum number of ServerTlsPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListServerTlsPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListServerTlsPolicies` call, and that the system - * should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy|ServerTlsPolicy}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.list_server_tls_policies.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_ListServerTlsPolicies_async - */ - listServerTlsPoliciesAsync( - request?: protos.google.cloud.networksecurity.v1beta1.IListServerTlsPoliciesRequest, - 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['listServerTlsPolicies']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServerTlsPolicies.asyncIterate( - this.innerApiCalls['listServerTlsPolicies'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists ClientTlsPolicies in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the ClientTlsPolicies should - * be listed, specified in the format `projects/* /locations/{location}`. - * @param {number} request.pageSize - * Maximum number of ClientTlsPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListClientTlsPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListClientTlsPolicies` call, and that the system - * should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy|ClientTlsPolicy}. - * 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 `listClientTlsPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listClientTlsPolicies( - request?: protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy[], - protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest|null, - protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesResponse - ]>; - listClientTlsPolicies( - request: protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest, - protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy>): void; - listClientTlsPolicies( - request: protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest, - callback: PaginationCallback< - protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest, - protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy>): void; - listClientTlsPolicies( - request?: protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest, - protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy>, - callback?: PaginationCallback< - protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest, - protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesResponse|null|undefined, - protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy>): - Promise<[ - protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy[], - protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest|null, - protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listClientTlsPolicies(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the ClientTlsPolicies should - * be listed, specified in the format `projects/* /locations/{location}`. - * @param {number} request.pageSize - * Maximum number of ClientTlsPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListClientTlsPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListClientTlsPolicies` call, and that the system - * should return the next page of data. - * @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 protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy|ClientTlsPolicy} 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 `listClientTlsPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listClientTlsPoliciesStream( - request?: protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest, - 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['listClientTlsPolicies']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listClientTlsPolicies.createStream( - this.innerApiCalls.listClientTlsPolicies as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listClientTlsPolicies`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the ClientTlsPolicies should - * be listed, specified in the format `projects/* /locations/{location}`. - * @param {number} request.pageSize - * Maximum number of ClientTlsPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListClientTlsPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListClientTlsPolicies` call, and that the system - * should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy|ClientTlsPolicy}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_security.list_client_tls_policies.js - * region_tag:networksecurity_v1beta1_generated_NetworkSecurity_ListClientTlsPolicies_async - */ - listClientTlsPoliciesAsync( - request?: protos.google.cloud.networksecurity.v1beta1.IListClientTlsPoliciesRequest, - 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['listClientTlsPolicies']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listClientTlsPolicies.asyncIterate( - this.innerApiCalls['listClientTlsPolicies'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @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/interfaces/CallOptions.html | 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.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - getIamPolicy( - request: IamProtos.google.iam.v1.GetIamPolicyRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, - {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { - return this.iamClient.getIamPolicy(request, options, callback); - } - -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - setIamPolicy( - request: IamProtos.google.iam.v1.SetIamPolicyRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, - {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { - return this.iamClient.setIamPolicy(request, options, callback); - } - -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ - testIamPermissions( - request: IamProtos.google.iam.v1.TestIamPermissionsRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.TestIamPermissionsResponse, - IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.TestIamPermissionsResponse, - IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, - {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { - return this.iamClient.testIamPermissions(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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 authorizationPolicy resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} authorization_policy - * @returns {string} Resource name string. - */ - authorizationPolicyPath(project:string,location:string,authorizationPolicy:string) { - return this.pathTemplates.authorizationPolicyPathTemplate.render({ - project: project, - location: location, - authorization_policy: authorizationPolicy, - }); - } - - /** - * Parse the project from AuthorizationPolicy resource. - * - * @param {string} authorizationPolicyName - * A fully-qualified path representing AuthorizationPolicy resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAuthorizationPolicyName(authorizationPolicyName: string) { - return this.pathTemplates.authorizationPolicyPathTemplate.match(authorizationPolicyName).project; - } - - /** - * Parse the location from AuthorizationPolicy resource. - * - * @param {string} authorizationPolicyName - * A fully-qualified path representing AuthorizationPolicy resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAuthorizationPolicyName(authorizationPolicyName: string) { - return this.pathTemplates.authorizationPolicyPathTemplate.match(authorizationPolicyName).location; - } - - /** - * Parse the authorization_policy from AuthorizationPolicy resource. - * - * @param {string} authorizationPolicyName - * A fully-qualified path representing AuthorizationPolicy resource. - * @returns {string} A string representing the authorization_policy. - */ - matchAuthorizationPolicyFromAuthorizationPolicyName(authorizationPolicyName: string) { - return this.pathTemplates.authorizationPolicyPathTemplate.match(authorizationPolicyName).authorization_policy; - } - - /** - * Return a fully-qualified clientTlsPolicy resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} client_tls_policy - * @returns {string} Resource name string. - */ - clientTlsPolicyPath(project:string,location:string,clientTlsPolicy:string) { - return this.pathTemplates.clientTlsPolicyPathTemplate.render({ - project: project, - location: location, - client_tls_policy: clientTlsPolicy, - }); - } - - /** - * Parse the project from ClientTlsPolicy resource. - * - * @param {string} clientTlsPolicyName - * A fully-qualified path representing ClientTlsPolicy resource. - * @returns {string} A string representing the project. - */ - matchProjectFromClientTlsPolicyName(clientTlsPolicyName: string) { - return this.pathTemplates.clientTlsPolicyPathTemplate.match(clientTlsPolicyName).project; - } - - /** - * Parse the location from ClientTlsPolicy resource. - * - * @param {string} clientTlsPolicyName - * A fully-qualified path representing ClientTlsPolicy resource. - * @returns {string} A string representing the location. - */ - matchLocationFromClientTlsPolicyName(clientTlsPolicyName: string) { - return this.pathTemplates.clientTlsPolicyPathTemplate.match(clientTlsPolicyName).location; - } - - /** - * Parse the client_tls_policy from ClientTlsPolicy resource. - * - * @param {string} clientTlsPolicyName - * A fully-qualified path representing ClientTlsPolicy resource. - * @returns {string} A string representing the client_tls_policy. - */ - matchClientTlsPolicyFromClientTlsPolicyName(clientTlsPolicyName: string) { - return this.pathTemplates.clientTlsPolicyPathTemplate.match(clientTlsPolicyName).client_tls_policy; - } - - /** - * Return a fully-qualified serverTlsPolicy resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} server_tls_policy - * @returns {string} Resource name string. - */ - serverTlsPolicyPath(project:string,location:string,serverTlsPolicy:string) { - return this.pathTemplates.serverTlsPolicyPathTemplate.render({ - project: project, - location: location, - server_tls_policy: serverTlsPolicy, - }); - } - - /** - * Parse the project from ServerTlsPolicy resource. - * - * @param {string} serverTlsPolicyName - * A fully-qualified path representing ServerTlsPolicy resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServerTlsPolicyName(serverTlsPolicyName: string) { - return this.pathTemplates.serverTlsPolicyPathTemplate.match(serverTlsPolicyName).project; - } - - /** - * Parse the location from ServerTlsPolicy resource. - * - * @param {string} serverTlsPolicyName - * A fully-qualified path representing ServerTlsPolicy resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServerTlsPolicyName(serverTlsPolicyName: string) { - return this.pathTemplates.serverTlsPolicyPathTemplate.match(serverTlsPolicyName).location; - } - - /** - * Parse the server_tls_policy from ServerTlsPolicy resource. - * - * @param {string} serverTlsPolicyName - * A fully-qualified path representing ServerTlsPolicy resource. - * @returns {string} A string representing the server_tls_policy. - */ - matchServerTlsPolicyFromServerTlsPolicyName(serverTlsPolicyName: string) { - return this.pathTemplates.serverTlsPolicyPathTemplate.match(serverTlsPolicyName).server_tls_policy; - } - - /** - * 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.networkSecurityStub && !this._terminated) { - return this.networkSecurityStub.then(stub => { - this._terminated = true; - stub.close(); - this.iamClient.close(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_client_config.json b/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_client_config.json deleted file mode 100644 index a8a5697e043..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_client_config.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "interfaces": { - "google.cloud.networksecurity.v1beta1.NetworkSecurity": { - "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": { - "ListAuthorizationPolicies": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetAuthorizationPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateAuthorizationPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateAuthorizationPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteAuthorizationPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListServerTlsPolicies": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetServerTlsPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateServerTlsPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateServerTlsPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteServerTlsPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListClientTlsPolicies": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetClientTlsPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateClientTlsPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateClientTlsPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteClientTlsPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_proto_list.json b/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_proto_list.json deleted file mode 100644 index dd0ef0b24df..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/src/v1beta1/network_security_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/networksecurity/v1beta1/authorization_policy.proto", - "../../protos/google/cloud/networksecurity/v1beta1/client_tls_policy.proto", - "../../protos/google/cloud/networksecurity/v1beta1/common.proto", - "../../protos/google/cloud/networksecurity/v1beta1/network_security.proto", - "../../protos/google/cloud/networksecurity/v1beta1/server_tls_policy.proto", - "../../protos/google/cloud/networksecurity/v1beta1/tls.proto" -] diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index ffbf8b4ca50..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const networksecurity = require('@google-cloud/network-security'); - -function main() { - const networkSecurityClient = new networksecurity.NetworkSecurityClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 496dee08836..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {NetworkSecurityClient} from '@google-cloud/network-security'; - -// check that the client class type name can be used -function doStuffWithNetworkSecurityClient(client: NetworkSecurityClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const networkSecurityClient = new NetworkSecurityClient(); - doStuffWithNetworkSecurityClient(networkSecurityClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-networksecurity/v1beta1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/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-networksecurity/v1beta1/test/gapic_network_security_v1beta1.ts b/owl-bot-staging/google-cloud-networksecurity/v1beta1/test/gapic_network_security_v1beta1.ts deleted file mode 100644 index f0a23c69f11..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/test/gapic_network_security_v1beta1.ts +++ /dev/null @@ -1,3508 +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 networksecurityModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos, IamProtos, 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('v1beta1.NetworkSecurityClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = networksecurityModule.v1beta1.NetworkSecurityClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = networksecurityModule.v1beta1.NetworkSecurityClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = networksecurityModule.v1beta1.NetworkSecurityClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.networkSecurityStub, undefined); - await client.initialize(); - assert(client.networkSecurityStub); - }); - - it('has close method for the initialized client', done => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.networkSecurityStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.networkSecurityStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - 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 networksecurityModule.v1beta1.NetworkSecurityClient({ - 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('getAuthorizationPolicy', () => { - it('invokes getAuthorizationPolicy without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.GetAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetAuthorizationPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy() - ); - client.innerApiCalls.getAuthorizationPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getAuthorizationPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAuthorizationPolicy without error using callback', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.GetAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetAuthorizationPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy() - ); - client.innerApiCalls.getAuthorizationPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getAuthorizationPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAuthorizationPolicy with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.GetAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetAuthorizationPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getAuthorizationPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAuthorizationPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAuthorizationPolicy with closed client', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.GetAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetAuthorizationPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getAuthorizationPolicy(request), expectedError); - }); - }); - - describe('getServerTlsPolicy', () => { - it('invokes getServerTlsPolicy without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.GetServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetServerTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy() - ); - client.innerApiCalls.getServerTlsPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getServerTlsPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getServerTlsPolicy without error using callback', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.GetServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetServerTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy() - ); - client.innerApiCalls.getServerTlsPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getServerTlsPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getServerTlsPolicy with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.GetServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetServerTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getServerTlsPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getServerTlsPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getServerTlsPolicy with closed client', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.GetServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetServerTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getServerTlsPolicy(request), expectedError); - }); - }); - - describe('getClientTlsPolicy', () => { - it('invokes getClientTlsPolicy without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.GetClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetClientTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy() - ); - client.innerApiCalls.getClientTlsPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getClientTlsPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getClientTlsPolicy without error using callback', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.GetClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetClientTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy() - ); - client.innerApiCalls.getClientTlsPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getClientTlsPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getClientTlsPolicy with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.GetClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetClientTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getClientTlsPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getClientTlsPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getClientTlsPolicy with closed client', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.GetClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.GetClientTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getClientTlsPolicy(request), expectedError); - }); - }); - - describe('createAuthorizationPolicy', () => { - it('invokes createAuthorizationPolicy without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.CreateAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateAuthorizationPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createAuthorizationPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.createAuthorizationPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createAuthorizationPolicy without error using callback', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.CreateAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateAuthorizationPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createAuthorizationPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createAuthorizationPolicy( - request, - (err?: Error|null, - result?: 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.createAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createAuthorizationPolicy with call error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.CreateAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateAuthorizationPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createAuthorizationPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createAuthorizationPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createAuthorizationPolicy with LRO error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.CreateAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateAuthorizationPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createAuthorizationPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createAuthorizationPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateAuthorizationPolicyProgress without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateAuthorizationPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateAuthorizationPolicyProgress with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateAuthorizationPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateAuthorizationPolicy', () => { - it('invokes updateAuthorizationPolicy without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.UpdateAuthorizationPolicyRequest() - ); - request.authorizationPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateAuthorizationPolicyRequest', ['authorizationPolicy', 'name']); - request.authorizationPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `authorization_policy.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateAuthorizationPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateAuthorizationPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateAuthorizationPolicy without error using callback', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.UpdateAuthorizationPolicyRequest() - ); - request.authorizationPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateAuthorizationPolicyRequest', ['authorizationPolicy', 'name']); - request.authorizationPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `authorization_policy.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateAuthorizationPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateAuthorizationPolicy( - request, - (err?: Error|null, - result?: 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.updateAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateAuthorizationPolicy with call error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.UpdateAuthorizationPolicyRequest() - ); - request.authorizationPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateAuthorizationPolicyRequest', ['authorizationPolicy', 'name']); - request.authorizationPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `authorization_policy.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAuthorizationPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateAuthorizationPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateAuthorizationPolicy with LRO error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.UpdateAuthorizationPolicyRequest() - ); - request.authorizationPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateAuthorizationPolicyRequest', ['authorizationPolicy', 'name']); - request.authorizationPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `authorization_policy.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAuthorizationPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateAuthorizationPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateAuthorizationPolicyProgress without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateAuthorizationPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateAuthorizationPolicyProgress with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateAuthorizationPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteAuthorizationPolicy', () => { - it('invokes deleteAuthorizationPolicy without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.DeleteAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteAuthorizationPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteAuthorizationPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteAuthorizationPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteAuthorizationPolicy without error using callback', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.DeleteAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteAuthorizationPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteAuthorizationPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteAuthorizationPolicy( - request, - (err?: Error|null, - result?: 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.deleteAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteAuthorizationPolicy with call error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.DeleteAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteAuthorizationPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteAuthorizationPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteAuthorizationPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteAuthorizationPolicy with LRO error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.DeleteAuthorizationPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteAuthorizationPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteAuthorizationPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteAuthorizationPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAuthorizationPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteAuthorizationPolicyProgress without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteAuthorizationPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteAuthorizationPolicyProgress with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteAuthorizationPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('createServerTlsPolicy', () => { - it('invokes createServerTlsPolicy without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.CreateServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateServerTlsPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createServerTlsPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.createServerTlsPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createServerTlsPolicy without error using callback', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.CreateServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateServerTlsPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createServerTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createServerTlsPolicy( - request, - (err?: Error|null, - result?: 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.createServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createServerTlsPolicy with call error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.CreateServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateServerTlsPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createServerTlsPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createServerTlsPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.createServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createServerTlsPolicy with LRO error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.CreateServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateServerTlsPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createServerTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createServerTlsPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateServerTlsPolicyProgress without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateServerTlsPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateServerTlsPolicyProgress with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateServerTlsPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateServerTlsPolicy', () => { - it('invokes updateServerTlsPolicy without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.UpdateServerTlsPolicyRequest() - ); - request.serverTlsPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateServerTlsPolicyRequest', ['serverTlsPolicy', 'name']); - request.serverTlsPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `server_tls_policy.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateServerTlsPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateServerTlsPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateServerTlsPolicy without error using callback', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.UpdateServerTlsPolicyRequest() - ); - request.serverTlsPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateServerTlsPolicyRequest', ['serverTlsPolicy', 'name']); - request.serverTlsPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `server_tls_policy.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateServerTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateServerTlsPolicy( - request, - (err?: Error|null, - result?: 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.updateServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateServerTlsPolicy with call error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.UpdateServerTlsPolicyRequest() - ); - request.serverTlsPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateServerTlsPolicyRequest', ['serverTlsPolicy', 'name']); - request.serverTlsPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `server_tls_policy.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateServerTlsPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateServerTlsPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateServerTlsPolicy with LRO error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.UpdateServerTlsPolicyRequest() - ); - request.serverTlsPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateServerTlsPolicyRequest', ['serverTlsPolicy', 'name']); - request.serverTlsPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `server_tls_policy.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateServerTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateServerTlsPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateServerTlsPolicyProgress without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateServerTlsPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateServerTlsPolicyProgress with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateServerTlsPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteServerTlsPolicy', () => { - it('invokes deleteServerTlsPolicy without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.DeleteServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteServerTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteServerTlsPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteServerTlsPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteServerTlsPolicy without error using callback', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.DeleteServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteServerTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteServerTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteServerTlsPolicy( - request, - (err?: Error|null, - result?: 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.deleteServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteServerTlsPolicy with call error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.DeleteServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteServerTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServerTlsPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteServerTlsPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteServerTlsPolicy with LRO error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.DeleteServerTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteServerTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServerTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteServerTlsPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServerTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteServerTlsPolicyProgress without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteServerTlsPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteServerTlsPolicyProgress with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteServerTlsPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('createClientTlsPolicy', () => { - it('invokes createClientTlsPolicy without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.CreateClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateClientTlsPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createClientTlsPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.createClientTlsPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createClientTlsPolicy without error using callback', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.CreateClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateClientTlsPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createClientTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createClientTlsPolicy( - request, - (err?: Error|null, - result?: 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.createClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createClientTlsPolicy with call error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.CreateClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateClientTlsPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createClientTlsPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createClientTlsPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.createClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createClientTlsPolicy with LRO error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.CreateClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.CreateClientTlsPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createClientTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createClientTlsPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateClientTlsPolicyProgress without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateClientTlsPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateClientTlsPolicyProgress with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateClientTlsPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateClientTlsPolicy', () => { - it('invokes updateClientTlsPolicy without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.UpdateClientTlsPolicyRequest() - ); - request.clientTlsPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateClientTlsPolicyRequest', ['clientTlsPolicy', 'name']); - request.clientTlsPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `client_tls_policy.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateClientTlsPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateClientTlsPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateClientTlsPolicy without error using callback', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.UpdateClientTlsPolicyRequest() - ); - request.clientTlsPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateClientTlsPolicyRequest', ['clientTlsPolicy', 'name']); - request.clientTlsPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `client_tls_policy.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateClientTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateClientTlsPolicy( - request, - (err?: Error|null, - result?: 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.updateClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateClientTlsPolicy with call error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.UpdateClientTlsPolicyRequest() - ); - request.clientTlsPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateClientTlsPolicyRequest', ['clientTlsPolicy', 'name']); - request.clientTlsPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `client_tls_policy.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateClientTlsPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateClientTlsPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateClientTlsPolicy with LRO error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.UpdateClientTlsPolicyRequest() - ); - request.clientTlsPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.UpdateClientTlsPolicyRequest', ['clientTlsPolicy', 'name']); - request.clientTlsPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `client_tls_policy.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateClientTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateClientTlsPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateClientTlsPolicyProgress without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateClientTlsPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateClientTlsPolicyProgress with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateClientTlsPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteClientTlsPolicy', () => { - it('invokes deleteClientTlsPolicy without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.DeleteClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteClientTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteClientTlsPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteClientTlsPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteClientTlsPolicy without error using callback', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.DeleteClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteClientTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteClientTlsPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteClientTlsPolicy( - request, - (err?: Error|null, - result?: 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.deleteClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteClientTlsPolicy with call error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.DeleteClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteClientTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteClientTlsPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteClientTlsPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteClientTlsPolicy with LRO error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.DeleteClientTlsPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.DeleteClientTlsPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteClientTlsPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteClientTlsPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteClientTlsPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteClientTlsPolicyProgress without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteClientTlsPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteClientTlsPolicyProgress with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteClientTlsPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listAuthorizationPolicies', () => { - it('invokes listAuthorizationPolicies without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), - ]; - client.innerApiCalls.listAuthorizationPolicies = stubSimpleCall(expectedResponse); - const [response] = await client.listAuthorizationPolicies(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAuthorizationPolicies without error using callback', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), - ]; - client.innerApiCalls.listAuthorizationPolicies = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listAuthorizationPolicies( - request, - (err?: Error|null, result?: protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAuthorizationPolicies with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listAuthorizationPolicies = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listAuthorizationPolicies(request), expectedError); - const actualRequest = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAuthorizationPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAuthorizationPoliciesStream without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), - ]; - client.descriptors.page.listAuthorizationPolicies.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listAuthorizationPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy[] = []; - stream.on('data', (response: protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy) => { - 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.listAuthorizationPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAuthorizationPolicies, request)); - assert( - (client.descriptors.page.listAuthorizationPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listAuthorizationPoliciesStream with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listAuthorizationPolicies.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listAuthorizationPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy[] = []; - stream.on('data', (response: protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listAuthorizationPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAuthorizationPolicies, request)); - assert( - (client.descriptors.page.listAuthorizationPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listAuthorizationPolicies without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.AuthorizationPolicy()), - ]; - client.descriptors.page.listAuthorizationPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy[] = []; - const iterable = client.listAuthorizationPoliciesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listAuthorizationPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAuthorizationPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listAuthorizationPolicies with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListAuthorizationPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listAuthorizationPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listAuthorizationPoliciesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networksecurity.v1beta1.IAuthorizationPolicy[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listAuthorizationPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAuthorizationPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listServerTlsPolicies', () => { - it('invokes listServerTlsPolicies without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), - ]; - client.innerApiCalls.listServerTlsPolicies = stubSimpleCall(expectedResponse); - const [response] = await client.listServerTlsPolicies(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServerTlsPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServerTlsPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServerTlsPolicies without error using callback', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), - ]; - client.innerApiCalls.listServerTlsPolicies = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServerTlsPolicies( - request, - (err?: Error|null, result?: protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServerTlsPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServerTlsPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServerTlsPolicies with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listServerTlsPolicies = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServerTlsPolicies(request), expectedError); - const actualRequest = (client.innerApiCalls.listServerTlsPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServerTlsPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServerTlsPoliciesStream without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), - ]; - client.descriptors.page.listServerTlsPolicies.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listServerTlsPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy[] = []; - stream.on('data', (response: protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy) => { - 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.listServerTlsPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServerTlsPolicies, request)); - assert( - (client.descriptors.page.listServerTlsPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listServerTlsPoliciesStream with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listServerTlsPolicies.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listServerTlsPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy[] = []; - stream.on('data', (response: protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listServerTlsPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServerTlsPolicies, request)); - assert( - (client.descriptors.page.listServerTlsPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listServerTlsPolicies without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ServerTlsPolicy()), - ]; - client.descriptors.page.listServerTlsPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy[] = []; - const iterable = client.listServerTlsPoliciesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listServerTlsPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServerTlsPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listServerTlsPolicies with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListServerTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listServerTlsPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listServerTlsPoliciesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networksecurity.v1beta1.IServerTlsPolicy[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listServerTlsPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServerTlsPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listClientTlsPolicies', () => { - it('invokes listClientTlsPolicies without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), - ]; - client.innerApiCalls.listClientTlsPolicies = stubSimpleCall(expectedResponse); - const [response] = await client.listClientTlsPolicies(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listClientTlsPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listClientTlsPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listClientTlsPolicies without error using callback', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), - ]; - client.innerApiCalls.listClientTlsPolicies = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listClientTlsPolicies( - request, - (err?: Error|null, result?: protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listClientTlsPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listClientTlsPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listClientTlsPolicies with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listClientTlsPolicies = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listClientTlsPolicies(request), expectedError); - const actualRequest = (client.innerApiCalls.listClientTlsPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listClientTlsPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listClientTlsPoliciesStream without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), - ]; - client.descriptors.page.listClientTlsPolicies.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listClientTlsPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy[] = []; - stream.on('data', (response: protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy) => { - 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.listClientTlsPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listClientTlsPolicies, request)); - assert( - (client.descriptors.page.listClientTlsPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listClientTlsPoliciesStream with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listClientTlsPolicies.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listClientTlsPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy[] = []; - stream.on('data', (response: protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listClientTlsPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listClientTlsPolicies, request)); - assert( - (client.descriptors.page.listClientTlsPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listClientTlsPolicies without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), - generateSampleMessage(new protos.google.cloud.networksecurity.v1beta1.ClientTlsPolicy()), - ]; - client.descriptors.page.listClientTlsPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy[] = []; - const iterable = client.listClientTlsPoliciesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listClientTlsPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listClientTlsPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listClientTlsPolicies with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networksecurity.v1beta1.ListClientTlsPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listClientTlsPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listClientTlsPoliciesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networksecurity.v1beta1.IClientTlsPolicy[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listClientTlsPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listClientTlsPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - 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 networksecurityModule.v1beta1.NetworkSecurityClient({ - 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 networksecurityModule.v1beta1.NetworkSecurityClient({ - 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 networksecurityModule.v1beta1.NetworkSecurityClient({ - 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 networksecurityModule.v1beta1.NetworkSecurityClient({ - 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 networksecurityModule.v1beta1.NetworkSecurityClient({ - 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 networksecurityModule.v1beta1.NetworkSecurityClient({ - 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 networksecurityModule.v1beta1.NetworkSecurityClient({ - 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 networksecurityModule.v1beta1.NetworkSecurityClient({ - 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 networksecurityModule.v1beta1.NetworkSecurityClient({ - 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 networksecurityModule.v1beta1.NetworkSecurityClient({ - 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 networksecurityModule.v1beta1.NetworkSecurityClient({ - 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 networksecurityModule.v1beta1.NetworkSecurityClient({ - 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 networksecurityModule.v1beta1.NetworkSecurityClient({ - 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 networksecurityModule.v1beta1.NetworkSecurityClient({ - 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 networksecurityModule.v1beta1.NetworkSecurityClient({ - 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('authorizationPolicy', () => { - const fakePath = "/rendered/path/authorizationPolicy"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - authorization_policy: "authorizationPolicyValue", - }; - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.authorizationPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.authorizationPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('authorizationPolicyPath', () => { - const result = client.authorizationPolicyPath("projectValue", "locationValue", "authorizationPolicyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.authorizationPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAuthorizationPolicyName', () => { - const result = client.matchProjectFromAuthorizationPolicyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.authorizationPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAuthorizationPolicyName', () => { - const result = client.matchLocationFromAuthorizationPolicyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.authorizationPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAuthorizationPolicyFromAuthorizationPolicyName', () => { - const result = client.matchAuthorizationPolicyFromAuthorizationPolicyName(fakePath); - assert.strictEqual(result, "authorizationPolicyValue"); - assert((client.pathTemplates.authorizationPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('clientTlsPolicy', () => { - const fakePath = "/rendered/path/clientTlsPolicy"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - client_tls_policy: "clientTlsPolicyValue", - }; - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.clientTlsPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.clientTlsPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('clientTlsPolicyPath', () => { - const result = client.clientTlsPolicyPath("projectValue", "locationValue", "clientTlsPolicyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.clientTlsPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromClientTlsPolicyName', () => { - const result = client.matchProjectFromClientTlsPolicyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.clientTlsPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromClientTlsPolicyName', () => { - const result = client.matchLocationFromClientTlsPolicyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.clientTlsPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchClientTlsPolicyFromClientTlsPolicyName', () => { - const result = client.matchClientTlsPolicyFromClientTlsPolicyName(fakePath); - assert.strictEqual(result, "clientTlsPolicyValue"); - assert((client.pathTemplates.clientTlsPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('serverTlsPolicy', () => { - const fakePath = "/rendered/path/serverTlsPolicy"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - server_tls_policy: "serverTlsPolicyValue", - }; - const client = new networksecurityModule.v1beta1.NetworkSecurityClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.serverTlsPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serverTlsPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serverTlsPolicyPath', () => { - const result = client.serverTlsPolicyPath("projectValue", "locationValue", "serverTlsPolicyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serverTlsPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServerTlsPolicyName', () => { - const result = client.matchProjectFromServerTlsPolicyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serverTlsPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServerTlsPolicyName', () => { - const result = client.matchLocationFromServerTlsPolicyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serverTlsPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServerTlsPolicyFromServerTlsPolicyName', () => { - const result = client.matchServerTlsPolicyFromServerTlsPolicyName(fakePath); - assert.strictEqual(result, "serverTlsPolicyValue"); - assert((client.pathTemplates.serverTlsPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-networksecurity/v1beta1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-networksecurity/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-networksecurity/v1beta1/webpack.config.js deleted file mode 100644 index d5abc33e904..00000000000 --- a/owl-bot-staging/google-cloud-networksecurity/v1beta1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'NetworkSecurity', - filename: './network-security.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-notebooks/v1/.eslintignore b/owl-bot-staging/google-cloud-notebooks/v1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-notebooks/v1/.eslintrc.json b/owl-bot-staging/google-cloud-notebooks/v1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/.gitignore b/owl-bot-staging/google-cloud-notebooks/v1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-notebooks/v1/.jsdoc.js b/owl-bot-staging/google-cloud-notebooks/v1/.jsdoc.js deleted file mode 100644 index b562faf1159..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/.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/notebooks', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-notebooks/v1/.mocharc.js b/owl-bot-staging/google-cloud-notebooks/v1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/.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-notebooks/v1/.prettierrc.js b/owl-bot-staging/google-cloud-notebooks/v1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/.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-notebooks/v1/README.md b/owl-bot-staging/google-cloud-notebooks/v1/README.md deleted file mode 100644 index 31cec215a8f..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Notebooks: Nodejs Client diff --git a/owl-bot-staging/google-cloud-notebooks/v1/package.json b/owl-bot-staging/google-cloud-notebooks/v1/package.json deleted file mode 100644 index 7ee890b3f9f..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/package.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "name": "@google-cloud/notebooks", - "version": "0.1.0", - "description": "Notebooks client for Node.js", - "repository": "googleapis/nodejs-notebooks", - "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 notebooks", - "notebooks", - "managed notebook service", - "notebook service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/diagnostic_config.proto b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/diagnostic_config.proto deleted file mode 100644 index ab8b98f1694..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/diagnostic_config.proto +++ /dev/null @@ -1,60 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.notebooks.v1; - -import "google/api/field_behavior.proto"; - -option go_package = "cloud.google.com/go/notebooks/apiv1/notebookspb;notebookspb"; -option java_multiple_files = true; -option java_outer_classname = "DiagnosticConfigProto"; -option java_package = "com.google.cloud.notebooks.v1"; - -// Defines flags that are used to run the diagnostic tool -message DiagnosticConfig { - // Required. User Cloud Storage bucket location (REQUIRED). - // Must be formatted with path prefix (`gs://$GCS_BUCKET`). - // - // Permissions: - // User Managed Notebooks: - // - storage.buckets.writer: Must be given to the project's service account - // attached to VM. - // Google Managed Notebooks: - // - storage.buckets.writer: Must be given to the project's service account or - // user credentials attached to VM depending on authentication mode. - // - // Cloud Storage bucket Log file will be written to - // `gs://$GCS_BUCKET/$RELATIVE_PATH/$VM_DATE_$TIME.tar.gz` - string gcs_bucket = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Defines the relative storage path in the Cloud Storage bucket - // where the diagnostic logs will be written: Default path will be the root - // directory of the Cloud Storage bucket - // (`gs://$GCS_BUCKET/$DATE_$TIME.tar.gz`) - // Example of full path where Log file will be written: - // `gs://$GCS_BUCKET/$RELATIVE_PATH/` - string relative_path = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Enables flag to repair service for instance - bool repair_flag_enabled = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Enables flag to capture packets from the instance for 30 seconds - bool packet_capture_flag_enabled = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Enables flag to copy all `/home/jupyter` folder contents - bool copy_home_files_flag_enabled = 5 - [(google.api.field_behavior) = OPTIONAL]; -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/environment.proto b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/environment.proto deleted file mode 100644 index cf947b8249d..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/environment.proto +++ /dev/null @@ -1,96 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.notebooks.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Notebooks.V1"; -option go_package = "cloud.google.com/go/notebooks/apiv1/notebookspb;notebookspb"; -option java_multiple_files = true; -option java_outer_classname = "EnvironmentProto"; -option java_package = "com.google.cloud.notebooks.v1"; -option php_namespace = "Google\\Cloud\\Notebooks\\V1"; -option ruby_package = "Google::Cloud::Notebooks::V1"; - -// Definition of a software environment that is used to start a notebook -// instance. -message Environment { - option (google.api.resource) = { - type: "notebooks.googleapis.com/Environment" - pattern: "projects/{project}/environments/{environment}" - }; - - // Output only. Name of this environment. - // Format: - // `projects/{project_id}/locations/{location}/environments/{environment_id}` - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Display name of this environment for the UI. - string display_name = 2; - - // A brief description of this environment. - string description = 3; - - // Type of the environment; can be one of VM image, or container image. - oneof image_type { - // Use a Compute Engine VM image to start the notebook instance. - VmImage vm_image = 6; - - // Use a container image to start the notebook instance. - ContainerImage container_image = 7; - } - - // Path to a Bash script that automatically runs after a notebook instance - // fully boots up. The path must be a URL or - // Cloud Storage path. Example: `"gs://path-to-file/file-name"` - string post_startup_script = 8; - - // Output only. The time at which this environment was created. - google.protobuf.Timestamp create_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Definition of a custom Compute Engine virtual machine image for starting a -// notebook instance with the environment installed directly on the VM. -message VmImage { - // Required. The name of the Google Cloud project that this VM image belongs to. - // Format: `{project_id}` - string project = 1 [(google.api.field_behavior) = REQUIRED]; - - // The reference to an external Compute Engine VM image. - oneof image { - // Use VM image name to find the image. - string image_name = 2; - - // Use this VM image family to find the image; the newest image in this - // family will be used. - string image_family = 3; - } -} - -// Definition of a container image for starting a notebook instance with the -// environment installed in a container. -message ContainerImage { - // Required. The path to the container image repository. For example: - // `gcr.io/{project_id}/{image_name}` - string repository = 1 [(google.api.field_behavior) = REQUIRED]; - - // The tag of the container image. If not specified, this defaults - // to the latest tag. - string tag = 2; -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/event.proto b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/event.proto deleted file mode 100644 index 2f62bda3217..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/event.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.notebooks.v1; - -import "google/api/field_behavior.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "cloud.google.com/go/notebooks/apiv1/notebookspb;notebookspb"; -option java_multiple_files = true; -option java_outer_classname = "EventProto"; -option java_package = "com.google.cloud.notebooks.v1"; - -// The definition of an Event for a managed / semi-managed notebook instance. -message Event { - // The definition of the event types. - enum EventType { - // Event is not specified. - EVENT_TYPE_UNSPECIFIED = 0; - - // The instance / runtime is idle - IDLE = 1; - - // The instance / runtime is available. - // This event indicates that instance / runtime underlying compute is - // operational. - HEARTBEAT = 2; - - // The instance / runtime health is available. - // This event indicates that instance / runtime health information. - HEALTH = 3; - - // The instance / runtime is available. - // This event allows instance / runtime to send Host maintenance - // information to Control Plane. - // https://cloud.google.com/compute/docs/gpus/gpu-host-maintenance - MAINTENANCE = 4; - } - - // Event report time. - google.protobuf.Timestamp report_time = 1; - - // Event type. - EventType type = 2; - - // Optional. Event details. This field is used to pass event information. - map details = 3 [(google.api.field_behavior) = OPTIONAL]; -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/execution.proto b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/execution.proto deleted file mode 100644 index c23545d31eb..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/execution.proto +++ /dev/null @@ -1,350 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.notebooks.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "cloud.google.com/go/notebooks/apiv1/notebookspb;notebookspb"; -option java_multiple_files = true; -option java_outer_classname = "ExecutionProto"; -option java_package = "com.google.cloud.notebooks.v1"; -option (google.api.resource_definition) = { - type: "aiplatform.googleapis.com/Tensorboard" - pattern: "projects/{project}/locations/{location}/tensorboards/{tensorboard}" -}; - -// The description a notebook execution workload. -message ExecutionTemplate { - // Required. Specifies the machine types, the number of replicas for workers - // and parameter servers. - enum ScaleTier { - // Unspecified Scale Tier. - SCALE_TIER_UNSPECIFIED = 0; - - // A single worker instance. This tier is suitable for learning how to use - // Cloud ML, and for experimenting with new models using small datasets. - BASIC = 1; - - // Many workers and a few parameter servers. - STANDARD_1 = 2; - - // A large number of workers with many parameter servers. - PREMIUM_1 = 3; - - // A single worker instance with a K80 GPU. - BASIC_GPU = 4; - - // A single worker instance with a Cloud TPU. - BASIC_TPU = 5; - - // The CUSTOM tier is not a set tier, but rather enables you to use your - // own cluster specification. When you use this tier, set values to - // configure your processing cluster according to these guidelines: - // - // * You _must_ set `ExecutionTemplate.masterType` to specify the type - // of machine to use for your master node. This is the only required - // setting. - CUSTOM = 6; - } - - // Hardware accelerator types for AI Platform Training jobs. - enum SchedulerAcceleratorType { - // Unspecified accelerator type. Default to no GPU. - SCHEDULER_ACCELERATOR_TYPE_UNSPECIFIED = 0; - - // Nvidia Tesla K80 GPU. - NVIDIA_TESLA_K80 = 1; - - // Nvidia Tesla P100 GPU. - NVIDIA_TESLA_P100 = 2; - - // Nvidia Tesla V100 GPU. - NVIDIA_TESLA_V100 = 3; - - // Nvidia Tesla P4 GPU. - NVIDIA_TESLA_P4 = 4; - - // Nvidia Tesla T4 GPU. - NVIDIA_TESLA_T4 = 5; - - // Nvidia Tesla A100 GPU. - NVIDIA_TESLA_A100 = 10; - - // TPU v2. - TPU_V2 = 6; - - // TPU v3. - TPU_V3 = 7; - } - - // Definition of a hardware accelerator. Note that not all combinations - // of `type` and `core_count` are valid. Check [GPUs on - // Compute Engine](https://cloud.google.com/compute/docs/gpus) to find a valid - // combination. TPUs are not supported. - message SchedulerAcceleratorConfig { - // Type of this accelerator. - SchedulerAcceleratorType type = 1; - - // Count of cores of this accelerator. - int64 core_count = 2; - } - - // The backend used for this execution. - enum JobType { - // No type specified. - JOB_TYPE_UNSPECIFIED = 0; - - // Custom Job in `aiplatform.googleapis.com`. - // Default value for an execution. - VERTEX_AI = 1; - - // Run execution on a cluster with Dataproc as a job. - // https://cloud.google.com/dataproc/docs/reference/rest/v1/projects.regions.jobs - DATAPROC = 2; - } - - // Parameters used in Dataproc JobType executions. - message DataprocParameters { - // URI for cluster used to run Dataproc execution. - // Format: `projects/{PROJECT_ID}/regions/{REGION}/clusters/{CLUSTER_NAME}` - string cluster = 1; - } - - // Parameters used in Vertex AI JobType executions. - message VertexAIParameters { - // The full name of the Compute Engine - // [network](https://cloud.google.com/compute/docs/networks-and-firewalls#networks) - // to which the Job should be peered. For example, - // `projects/12345/global/networks/myVPC`. - // [Format](https://cloud.google.com/compute/docs/reference/rest/v1/networks/insert) - // is of the form `projects/{project}/global/networks/{network}`. - // Where `{project}` is a project number, as in `12345`, and `{network}` is - // a network name. - // - // Private services access must already be configured for the network. If - // left unspecified, the job is not peered with any network. - string network = 1; - - // Environment variables. - // At most 100 environment variables can be specified and unique. - // Example: `GCP_BUCKET=gs://my-bucket/samples/` - map env = 2; - } - - // Required. Scale tier of the hardware used for notebook execution. - // DEPRECATED Will be discontinued. As right now only CUSTOM is supported. - ScaleTier scale_tier = 1 [ - deprecated = true, - (google.api.field_behavior) = REQUIRED - ]; - - // Specifies the type of virtual machine to use for your training - // job's master worker. You must specify this field when `scaleTier` is set to - // `CUSTOM`. - // - // You can use certain Compute Engine machine types directly in this field. - // The following types are supported: - // - // - `n1-standard-4` - // - `n1-standard-8` - // - `n1-standard-16` - // - `n1-standard-32` - // - `n1-standard-64` - // - `n1-standard-96` - // - `n1-highmem-2` - // - `n1-highmem-4` - // - `n1-highmem-8` - // - `n1-highmem-16` - // - `n1-highmem-32` - // - `n1-highmem-64` - // - `n1-highmem-96` - // - `n1-highcpu-16` - // - `n1-highcpu-32` - // - `n1-highcpu-64` - // - `n1-highcpu-96` - // - // - // Alternatively, you can use the following legacy machine types: - // - // - `standard` - // - `large_model` - // - `complex_model_s` - // - `complex_model_m` - // - `complex_model_l` - // - `standard_gpu` - // - `complex_model_m_gpu` - // - `complex_model_l_gpu` - // - `standard_p100` - // - `complex_model_m_p100` - // - `standard_v100` - // - `large_model_v100` - // - `complex_model_m_v100` - // - `complex_model_l_v100` - // - // - // Finally, if you want to use a TPU for training, specify `cloud_tpu` in this - // field. Learn more about the [special configuration options for training - // with - // TPU](https://cloud.google.com/ai-platform/training/docs/using-tpus#configuring_a_custom_tpu_machine). - string master_type = 2; - - // Configuration (count and accelerator type) for hardware running notebook - // execution. - SchedulerAcceleratorConfig accelerator_config = 3; - - // Labels for execution. - // If execution is scheduled, a field included will be 'nbs-scheduled'. - // Otherwise, it is an immediate execution, and an included field will be - // 'nbs-immediate'. Use fields to efficiently index between various types of - // executions. - map labels = 4; - - // Path to the notebook file to execute. - // Must be in a Google Cloud Storage bucket. - // Format: `gs://{bucket_name}/{folder}/{notebook_file_name}` - // Ex: `gs://notebook_user/scheduled_notebooks/sentiment_notebook.ipynb` - string input_notebook_file = 5; - - // Container Image URI to a DLVM - // Example: 'gcr.io/deeplearning-platform-release/base-cu100' - // More examples can be found at: - // https://cloud.google.com/ai-platform/deep-learning-containers/docs/choosing-container - string container_image_uri = 6; - - // Path to the notebook folder to write to. - // Must be in a Google Cloud Storage bucket path. - // Format: `gs://{bucket_name}/{folder}` - // Ex: `gs://notebook_user/scheduled_notebooks` - string output_notebook_folder = 7; - - // Parameters to be overridden in the notebook during execution. - // Ref https://papermill.readthedocs.io/en/latest/usage-parameterize.html on - // how to specifying parameters in the input notebook and pass them here - // in an YAML file. - // Ex: `gs://notebook_user/scheduled_notebooks/sentiment_notebook_params.yaml` - string params_yaml_file = 8; - - // Parameters used within the 'input_notebook_file' notebook. - string parameters = 9; - - // The email address of a service account to use when running the execution. - // You must have the `iam.serviceAccounts.actAs` permission for the specified - // service account. - string service_account = 10; - - // The type of Job to be used on this execution. - JobType job_type = 11; - - // Parameters for an execution type. - // NOTE: There are currently no extra parameters for VertexAI jobs. - oneof job_parameters { - // Parameters used in Dataproc JobType executions. - DataprocParameters dataproc_parameters = 12; - - // Parameters used in Vertex AI JobType executions. - VertexAIParameters vertex_ai_parameters = 13; - } - - // Name of the kernel spec to use. This must be specified if the - // kernel spec name on the execution target does not match the name in the - // input notebook file. - string kernel_spec = 14; - - // The name of a Vertex AI [Tensorboard] resource to which this execution - // will upload Tensorboard logs. - // Format: - // `projects/{project}/locations/{location}/tensorboards/{tensorboard}` - string tensorboard = 15 [(google.api.resource_reference) = { - type: "aiplatform.googleapis.com/Tensorboard" - }]; -} - -// The definition of a single executed notebook. -message Execution { - option (google.api.resource) = { - type: "notebooks.googleapis.com/Execution" - pattern: "projects/{project}/location/{location}/executions/{execution}" - }; - - // Enum description of the state of the underlying AIP job. - enum State { - // The job state is unspecified. - STATE_UNSPECIFIED = 0; - - // The job has been just created and processing has not yet begun. - QUEUED = 1; - - // The service is preparing to execution the job. - PREPARING = 2; - - // The job is in progress. - RUNNING = 3; - - // The job completed successfully. - SUCCEEDED = 4; - - // The job failed. - // `error_message` should contain the details of the failure. - FAILED = 5; - - // The job is being cancelled. - // `error_message` should describe the reason for the cancellation. - CANCELLING = 6; - - // The job has been cancelled. - // `error_message` should describe the reason for the cancellation. - CANCELLED = 7; - - // The job has become expired (relevant to Vertex AI jobs) - // https://cloud.google.com/vertex-ai/docs/reference/rest/v1/JobState - EXPIRED = 9; - - // The Execution is being created. - INITIALIZING = 10; - } - - // execute metadata including name, hardware spec, region, labels, etc. - ExecutionTemplate execution_template = 1; - - // Output only. The resource name of the execute. Format: - // `projects/{project_id}/locations/{location}/executions/{execution_id}` - string name = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Name used for UI purposes. - // Name can only contain alphanumeric characters and underscores '_'. - string display_name = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // A brief description of this execution. - string description = 4; - - // Output only. Time the Execution was instantiated. - google.protobuf.Timestamp create_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Time the Execution was last updated. - google.protobuf.Timestamp update_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. State of the underlying AI Platform job. - State state = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output notebook file generated by this execution - string output_notebook_file = 8; - - // Output only. The URI of the external job used to execute the notebook. - string job_uri = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/instance.proto b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/instance.proto deleted file mode 100644 index d7888393837..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/instance.proto +++ /dev/null @@ -1,541 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.notebooks.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/notebooks/v1/environment.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Notebooks.V1"; -option go_package = "cloud.google.com/go/notebooks/apiv1/notebookspb;notebookspb"; -option java_multiple_files = true; -option java_outer_classname = "InstanceProto"; -option java_package = "com.google.cloud.notebooks.v1"; -option php_namespace = "Google\\Cloud\\Notebooks\\V1"; -option ruby_package = "Google::Cloud::Notebooks::V1"; - -// Reservation Affinity for consuming Zonal reservation. -message ReservationAffinity { - // Indicates whether to consume capacity from an reservation or not. - enum Type { - // Default type. - TYPE_UNSPECIFIED = 0; - - // Do not consume from any allocated capacity. - NO_RESERVATION = 1; - - // Consume any reservation available. - ANY_RESERVATION = 2; - - // Must consume from a specific reservation. Must specify key value fields - // for specifying the reservations. - SPECIFIC_RESERVATION = 3; - } - - // Optional. Type of reservation to consume - Type consume_reservation_type = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Corresponds to the label key of reservation resource. - string key = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Corresponds to the label values of reservation resource. - repeated string values = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// The definition of a notebook instance. -message Instance { - option (google.api.resource) = { - type: "notebooks.googleapis.com/Instance" - pattern: "projects/{project}/instances/{instance}" - }; - - // Definition of the types of hardware accelerators that can be used on this - // instance. - enum AcceleratorType { - // Accelerator type is not specified. - ACCELERATOR_TYPE_UNSPECIFIED = 0; - - // Accelerator type is Nvidia Tesla K80. - NVIDIA_TESLA_K80 = 1; - - // Accelerator type is Nvidia Tesla P100. - NVIDIA_TESLA_P100 = 2; - - // Accelerator type is Nvidia Tesla V100. - NVIDIA_TESLA_V100 = 3; - - // Accelerator type is Nvidia Tesla P4. - NVIDIA_TESLA_P4 = 4; - - // Accelerator type is Nvidia Tesla T4. - NVIDIA_TESLA_T4 = 5; - - // Accelerator type is Nvidia Tesla A100. - NVIDIA_TESLA_A100 = 11; - - // Accelerator type is NVIDIA Tesla T4 Virtual Workstations. - NVIDIA_TESLA_T4_VWS = 8; - - // Accelerator type is NVIDIA Tesla P100 Virtual Workstations. - NVIDIA_TESLA_P100_VWS = 9; - - // Accelerator type is NVIDIA Tesla P4 Virtual Workstations. - NVIDIA_TESLA_P4_VWS = 10; - - // (Coming soon) Accelerator type is TPU V2. - TPU_V2 = 6; - - // (Coming soon) Accelerator type is TPU V3. - TPU_V3 = 7; - } - - // Definition of a hardware accelerator. Note that not all combinations - // of `type` and `core_count` are valid. Check [GPUs on Compute - // Engine](https://cloud.google.com/compute/docs/gpus/#gpus-list) to find a - // valid combination. TPUs are not supported. - message AcceleratorConfig { - // Type of this accelerator. - AcceleratorType type = 1; - - // Count of cores of this accelerator. - int64 core_count = 2; - } - - // The definition of the states of this instance. - enum State { - // State is not specified. - STATE_UNSPECIFIED = 0; - - // The control logic is starting the instance. - STARTING = 1; - - // The control logic is installing required frameworks and registering the - // instance with notebook proxy - PROVISIONING = 2; - - // The instance is running. - ACTIVE = 3; - - // The control logic is stopping the instance. - STOPPING = 4; - - // The instance is stopped. - STOPPED = 5; - - // The instance is deleted. - DELETED = 6; - - // The instance is upgrading. - UPGRADING = 7; - - // The instance is being created. - INITIALIZING = 8; - - // The instance is getting registered. - REGISTERING = 9; - - // The instance is suspending. - SUSPENDING = 10; - - // The instance is suspended. - SUSPENDED = 11; - } - - // Possible disk types for notebook instances. - enum DiskType { - // Disk type not set. - DISK_TYPE_UNSPECIFIED = 0; - - // Standard persistent disk type. - PD_STANDARD = 1; - - // SSD persistent disk type. - PD_SSD = 2; - - // Balanced persistent disk type. - PD_BALANCED = 3; - - // Extreme persistent disk type. - PD_EXTREME = 4; - } - - // Definition of the disk encryption options. - enum DiskEncryption { - // Disk encryption is not specified. - DISK_ENCRYPTION_UNSPECIFIED = 0; - - // Use Google managed encryption keys to encrypt the boot disk. - GMEK = 1; - - // Use customer managed encryption keys to encrypt the boot disk. - CMEK = 2; - } - - // An instance-attached disk resource. - message Disk { - // Guest OS features for boot disk. - message GuestOsFeature { - // The ID of a supported feature. Read Enabling guest operating system - // features to see a list of available options. - // Valid values: - // - // * `FEATURE_TYPE_UNSPECIFIED` - // * `MULTI_IP_SUBNET` - // * `SECURE_BOOT` - // * `UEFI_COMPATIBLE` - // * `VIRTIO_SCSI_MULTIQUEUE` - // * `WINDOWS` - string type = 1; - } - - // Indicates whether the disk will be auto-deleted when the instance is - // deleted (but not when the disk is detached from the instance). - bool auto_delete = 1; - - // Indicates that this is a boot disk. The virtual machine will use the - // first partition of the disk for its root filesystem. - bool boot = 2; - - // Indicates a unique device name of your choice that is reflected into the - // `/dev/disk/by-id/google-*` tree of a Linux operating system running - // within the instance. This name can be used to reference the device for - // mounting, resizing, and so on, from within the instance. - // - // If not specified, the server chooses a default device name to apply to - // this disk, in the form persistent-disk-x, where x is a number assigned by - // Google Compute Engine.This field is only applicable for persistent disks. - string device_name = 3; - - // Indicates the size of the disk in base-2 GB. - int64 disk_size_gb = 4; - - // Indicates a list of features to enable on the guest operating system. - // Applicable only for bootable images. Read Enabling guest operating - // system features to see a list of available options. - repeated GuestOsFeature guest_os_features = 5; - - // A zero-based index to this disk, where 0 is reserved for the - // boot disk. If you have many disks attached to an instance, each disk - // would have a unique index number. - int64 index = 6; - - // Indicates the disk interface to use for attaching this disk, which is - // either SCSI or NVME. The default is SCSI. Persistent disks must always - // use SCSI and the request will fail if you attempt to attach a persistent - // disk in any other format than SCSI. Local SSDs can use either NVME or - // SCSI. For performance characteristics of SCSI over NVMe, see Local SSD - // performance. - // Valid values: - // - // * `NVME` - // * `SCSI` - string interface = 7; - - // Type of the resource. Always compute#attachedDisk for attached - // disks. - string kind = 8; - - // A list of publicly visible licenses. Reserved for Google's use. - // A License represents billing and aggregate usage data for public - // and marketplace images. - repeated string licenses = 9; - - // The mode in which to attach this disk, either `READ_WRITE` or - // `READ_ONLY`. If not specified, the default is to attach the disk in - // `READ_WRITE` mode. Valid values: - // - // * `READ_ONLY` - // * `READ_WRITE` - string mode = 10; - - // Indicates a valid partial or full URL to an existing Persistent Disk - // resource. - string source = 11; - - // Indicates the type of the disk, either `SCRATCH` or `PERSISTENT`. - // Valid values: - // - // * `PERSISTENT` - // * `SCRATCH` - string type = 12; - } - - // A set of Shielded Instance options. - // Check [Images using supported Shielded VM - // features](https://cloud.google.com/compute/docs/instances/modifying-shielded-vm). - // Not all combinations are valid. - message ShieldedInstanceConfig { - // Defines whether the instance has Secure Boot enabled. - // - // Secure Boot helps ensure that the system only runs authentic software by - // verifying the digital signature of all boot components, and halting the - // boot process if signature verification fails. Disabled by default. - bool enable_secure_boot = 1; - - // Defines whether the instance has the vTPM enabled. Enabled by default. - bool enable_vtpm = 2; - - // Defines whether the instance has integrity monitoring enabled. - // - // Enables monitoring and attestation of the boot integrity of the instance. - // The attestation is performed against the integrity policy baseline. This - // baseline is initially derived from the implicitly trusted boot image when - // the instance is created. Enabled by default. - bool enable_integrity_monitoring = 3; - } - - // The entry of VM image upgrade history. - message UpgradeHistoryEntry { - // The definition of the states of this upgrade history entry. - enum State { - // State is not specified. - STATE_UNSPECIFIED = 0; - - // The instance upgrade is started. - STARTED = 1; - - // The instance upgrade is succeeded. - SUCCEEDED = 2; - - // The instance upgrade is failed. - FAILED = 3; - } - - // The definition of operations of this upgrade history entry. - enum Action { - // Operation is not specified. - ACTION_UNSPECIFIED = 0; - - // Upgrade. - UPGRADE = 1; - - // Rollback. - ROLLBACK = 2; - } - - // The snapshot of the boot disk of this notebook instance before upgrade. - string snapshot = 1; - - // The VM image before this instance upgrade. - string vm_image = 2; - - // The container image before this instance upgrade. - string container_image = 3; - - // The framework of this notebook instance. - string framework = 4; - - // The version of the notebook instance before this upgrade. - string version = 5; - - // The state of this instance upgrade history entry. - State state = 6; - - // The time that this instance upgrade history entry is created. - google.protobuf.Timestamp create_time = 7; - - // Target VM Image. Format: `ainotebooks-vm/project/image-name/name`. - string target_image = 8 [deprecated = true]; - - // Action. Rolloback or Upgrade. - Action action = 9; - - // Target VM Version, like m63. - string target_version = 10; - } - - // The type of vNIC driver. - // Default should be UNSPECIFIED_NIC_TYPE. - enum NicType { - // No type specified. - UNSPECIFIED_NIC_TYPE = 0; - - // VIRTIO - VIRTIO_NET = 1; - - // GVNIC - GVNIC = 2; - } - - // Output only. The name of this notebook instance. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Type of the environment; can be one of VM image, or container image. - oneof environment { - // Use a Compute Engine VM image to start the notebook instance. - VmImage vm_image = 2; - - // Use a container image to start the notebook instance. - ContainerImage container_image = 3; - } - - // Path to a Bash script that automatically runs after a notebook instance - // fully boots up. The path must be a URL or - // Cloud Storage path (`gs://path-to-file/file-name`). - string post_startup_script = 4; - - // Output only. The proxy endpoint that is used to access the Jupyter notebook. - string proxy_uri = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Input only. The owner of this instance after creation. Format: `alias@example.com` - // - // Currently supports one owner only. If not specified, all of the service - // account users of your VM instance's service account can use - // the instance. - repeated string instance_owners = 6 [(google.api.field_behavior) = INPUT_ONLY]; - - // The service account on this instance, giving access to other Google - // Cloud services. - // You can use any service account within the same project, but you - // must have the service account user permission to use the instance. - // - // If not specified, the [Compute Engine default service - // account](https://cloud.google.com/compute/docs/access/service-accounts#default_service_account) - // is used. - string service_account = 7; - - // Optional. The URIs of service account scopes to be included in - // Compute Engine instances. - // - // If not specified, the following - // [scopes](https://cloud.google.com/compute/docs/access/service-accounts#accesscopesiam) - // are defined: - // - https://www.googleapis.com/auth/cloud-platform - // - https://www.googleapis.com/auth/userinfo.email - // If not using default scopes, you need at least: - // https://www.googleapis.com/auth/compute - repeated string service_account_scopes = 31 [(google.api.field_behavior) = OPTIONAL]; - - // Required. The [Compute Engine machine - // type](https://cloud.google.com/compute/docs/machine-types) of this - // instance. - string machine_type = 8 [(google.api.field_behavior) = REQUIRED]; - - // The hardware accelerator used on this instance. If you use - // accelerators, make sure that your configuration has - // [enough vCPUs and memory to support the `machine_type` you have - // selected](https://cloud.google.com/compute/docs/gpus/#gpus-list). - AcceleratorConfig accelerator_config = 9; - - // Output only. The state of this instance. - State state = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Whether the end user authorizes Google Cloud to install GPU driver - // on this instance. - // If this field is empty or set to false, the GPU driver won't be installed. - // Only applicable to instances with GPUs. - bool install_gpu_driver = 11; - - // Specify a custom Cloud Storage path where the GPU driver is stored. - // If not specified, we'll automatically choose from official GPU drivers. - string custom_gpu_driver_path = 12; - - // Input only. The type of the boot disk attached to this instance, defaults to - // standard persistent disk (`PD_STANDARD`). - DiskType boot_disk_type = 13 [(google.api.field_behavior) = INPUT_ONLY]; - - // Input only. The size of the boot disk in GB attached to this instance, up to a maximum - // of 64000 GB (64 TB). The minimum recommended value is 100 GB. If not - // specified, this defaults to 100. - int64 boot_disk_size_gb = 14 [(google.api.field_behavior) = INPUT_ONLY]; - - // Input only. The type of the data disk attached to this instance, defaults to - // standard persistent disk (`PD_STANDARD`). - DiskType data_disk_type = 25 [(google.api.field_behavior) = INPUT_ONLY]; - - // Input only. The size of the data disk in GB attached to this instance, up to a maximum - // of 64000 GB (64 TB). You can choose the size of the data disk based on how - // big your notebooks and data are. If not specified, this defaults to 100. - int64 data_disk_size_gb = 26 [(google.api.field_behavior) = INPUT_ONLY]; - - // Input only. If true, the data disk will not be auto deleted when deleting the instance. - bool no_remove_data_disk = 27 [(google.api.field_behavior) = INPUT_ONLY]; - - // Input only. Disk encryption method used on the boot and data disks, defaults to GMEK. - DiskEncryption disk_encryption = 15 [(google.api.field_behavior) = INPUT_ONLY]; - - // Input only. The KMS key used to encrypt the disks, only applicable if disk_encryption - // is CMEK. - // Format: - // `projects/{project_id}/locations/{location}/keyRings/{key_ring_id}/cryptoKeys/{key_id}` - // - // Learn more about [using your own encryption keys](/kms/docs/quickstart). - string kms_key = 16 [(google.api.field_behavior) = INPUT_ONLY]; - - // Output only. Attached disks to notebook instance. - repeated Disk disks = 28 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Shielded VM configuration. - // [Images using supported Shielded VM - // features](https://cloud.google.com/compute/docs/instances/modifying-shielded-vm). - ShieldedInstanceConfig shielded_instance_config = 30 [(google.api.field_behavior) = OPTIONAL]; - - // If true, no public IP will be assigned to this instance. - bool no_public_ip = 17; - - // If true, the notebook instance will not register with the proxy. - bool no_proxy_access = 18; - - // The name of the VPC that this instance is in. - // Format: - // `projects/{project_id}/global/networks/{network_id}` - string network = 19; - - // The name of the subnet that this instance is in. - // Format: - // `projects/{project_id}/regions/{region}/subnetworks/{subnetwork_id}` - string subnet = 20; - - // Labels to apply to this instance. - // These can be later modified by the setLabels method. - map labels = 21; - - // Custom metadata to apply to this instance. - map metadata = 22; - - // Optional. The Compute Engine tags to add to runtime (see [Tagging - // instances](https://cloud.google.com/compute/docs/label-or-tag-resources#tags)). - repeated string tags = 32 [(google.api.field_behavior) = OPTIONAL]; - - // The upgrade history of this instance. - repeated UpgradeHistoryEntry upgrade_history = 29; - - // Optional. The type of vNIC to be used on this interface. This may be gVNIC or - // VirtioNet. - NicType nic_type = 33 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The optional reservation affinity. Setting this field will apply - // the specified [Zonal Compute - // Reservation](https://cloud.google.com/compute/docs/instances/reserving-zonal-resources) - // to this notebook instance. - ReservationAffinity reservation_affinity = 34 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. Email address of entity that sent original CreateInstance request. - string creator = 36 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Flag to enable ip forwarding or not, default false/off. - // https://cloud.google.com/vpc/docs/using-routes#canipforward - bool can_ip_forward = 39 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. Instance creation time. - google.protobuf.Timestamp create_time = 23 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Instance update time. - google.protobuf.Timestamp update_time = 24 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/instance_config.proto b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/instance_config.proto deleted file mode 100644 index 59fd01ef7ea..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/instance_config.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.notebooks.v1; - -option csharp_namespace = "Google.Cloud.Notebooks.V1"; -option go_package = "cloud.google.com/go/notebooks/apiv1/notebookspb;notebookspb"; -option java_multiple_files = true; -option java_outer_classname = "InstanceConfigProto"; -option java_package = "com.google.cloud.notebooks.v1"; -option php_namespace = "Google\\Cloud\\Notebooks\\V1"; -option ruby_package = "Google::Cloud::Notebooks::V1"; - -// Notebook instance configurations that can be updated. -message InstanceConfig { - // Cron expression in UTC timezone, used to schedule instance auto upgrade. - // Please follow the [cron format](https://en.wikipedia.org/wiki/Cron). - string notebook_upgrade_schedule = 1; - - // Verifies core internal services are running. - bool enable_health_monitoring = 2; -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/managed_service.proto b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/managed_service.proto deleted file mode 100644 index 245e0764006..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/managed_service.proto +++ /dev/null @@ -1,439 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.notebooks.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/notebooks/v1/diagnostic_config.proto"; -import "google/cloud/notebooks/v1/event.proto"; -import "google/cloud/notebooks/v1/runtime.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Notebooks.V1"; -option go_package = "cloud.google.com/go/notebooks/apiv1/notebookspb;notebookspb"; -option java_multiple_files = true; -option java_outer_classname = "ManagedNotebooksProto"; -option java_package = "com.google.cloud.notebooks.v1"; -option php_namespace = "Google\\Cloud\\Notebooks\\V1"; -option ruby_package = "Google::Cloud::Notebooks::V1"; - -// API v1 service for Managed Notebooks. -service ManagedNotebookService { - option (google.api.default_host) = "notebooks.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Lists Runtimes in a given project and location. - rpc ListRuntimes(ListRuntimesRequest) returns (ListRuntimesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/runtimes" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets details of a single Runtime. The location must be a regional endpoint - // rather than zonal. - rpc GetRuntime(GetRuntimeRequest) returns (Runtime) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/runtimes/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a new Runtime in a given project and location. - rpc CreateRuntime(CreateRuntimeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/runtimes" - body: "runtime" - }; - option (google.api.method_signature) = "parent,runtime_id,runtime"; - option (google.longrunning.operation_info) = { - response_type: "Runtime" - metadata_type: "OperationMetadata" - }; - } - - // Update Notebook Runtime configuration. - rpc UpdateRuntime(UpdateRuntimeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1/{runtime.name=projects/*/locations/*/runtimes/*}" - body: "runtime" - }; - option (google.api.method_signature) = "runtime,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "Runtime" - metadata_type: "OperationMetadata" - }; - } - - // Deletes a single Runtime. - rpc DeleteRuntime(DeleteRuntimeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/runtimes/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "OperationMetadata" - }; - } - - // Starts a Managed Notebook Runtime. - // Perform "Start" on GPU instances; "Resume" on CPU instances - // See: - // https://cloud.google.com/compute/docs/instances/stop-start-instance - // https://cloud.google.com/compute/docs/instances/suspend-resume-instance - rpc StartRuntime(StartRuntimeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/runtimes/*}:start" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Runtime" - metadata_type: "OperationMetadata" - }; - } - - // Stops a Managed Notebook Runtime. - // Perform "Stop" on GPU instances; "Suspend" on CPU instances - // See: - // https://cloud.google.com/compute/docs/instances/stop-start-instance - // https://cloud.google.com/compute/docs/instances/suspend-resume-instance - rpc StopRuntime(StopRuntimeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/runtimes/*}:stop" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Runtime" - metadata_type: "OperationMetadata" - }; - } - - // Switch a Managed Notebook Runtime. - rpc SwitchRuntime(SwitchRuntimeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/runtimes/*}:switch" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Runtime" - metadata_type: "OperationMetadata" - }; - } - - // Resets a Managed Notebook Runtime. - rpc ResetRuntime(ResetRuntimeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/runtimes/*}:reset" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Runtime" - metadata_type: "OperationMetadata" - }; - } - - // Upgrades a Managed Notebook Runtime to the latest version. - rpc UpgradeRuntime(UpgradeRuntimeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/runtimes/*}:upgrade" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Runtime" - metadata_type: "OperationMetadata" - }; - } - - // Report and process a runtime event. - rpc ReportRuntimeEvent(ReportRuntimeEventRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/runtimes/*}:reportEvent" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Runtime" - metadata_type: "OperationMetadata" - }; - } - - // Gets an access token for the consumer service account that the customer - // attached to the runtime. Only accessible from the tenant instance. - rpc RefreshRuntimeTokenInternal(RefreshRuntimeTokenInternalRequest) returns (RefreshRuntimeTokenInternalResponse) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/runtimes/*}:refreshRuntimeTokenInternal" - body: "*" - }; - option (google.api.method_signature) = "name,vm_id"; - } - - // Creates a Diagnostic File and runs Diagnostic Tool given a Runtime. - rpc DiagnoseRuntime(DiagnoseRuntimeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/runtimes/*}:diagnose" - body: "*" - }; - option (google.api.method_signature) = "name,diagnostic_config"; - option (google.longrunning.operation_info) = { - response_type: "Runtime" - metadata_type: "OperationMetadata" - }; - } -} - -// Request for listing Managed Notebook Runtimes. -message ListRuntimesRequest { - // Required. Format: - // `parent=projects/{project_id}/locations/{location}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "notebooks.googleapis.com/Runtime" - } - ]; - - // Maximum return size of the list call. - int32 page_size = 2; - - // A previous returned page token that can be used to continue listing - // from the last result. - string page_token = 3; -} - -// Response for listing Managed Notebook Runtimes. -message ListRuntimesResponse { - // A list of returned Runtimes. - repeated Runtime runtimes = 1; - - // Page token that can be used to continue listing from the last result in the - // next list call. - string next_page_token = 2; - - // Locations that could not be reached. For example, - // `['us-west1', 'us-central1']`. - // A ListRuntimesResponse will only contain either runtimes or unreachables, - repeated string unreachable = 3; -} - -// Request for getting a Managed Notebook Runtime. -message GetRuntimeRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "notebooks.googleapis.com/Runtime" - } - ]; -} - -// Request for creating a Managed Notebook Runtime. -message CreateRuntimeRequest { - // Required. Format: - // `parent=projects/{project_id}/locations/{location}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "notebooks.googleapis.com/Runtime" - } - ]; - - // Required. User-defined unique ID of this Runtime. - string runtime_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The Runtime to be created. - Runtime runtime = 3 [(google.api.field_behavior) = REQUIRED]; - - // Idempotent request UUID. - string request_id = 4; -} - -// Request for deleting a Managed Notebook Runtime. -message DeleteRuntimeRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "notebooks.googleapis.com/Runtime" - } - ]; - - // Idempotent request UUID. - string request_id = 2; -} - -// Request for starting a Managed Notebook Runtime. -message StartRuntimeRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Idempotent request UUID. - string request_id = 2; -} - -// Request for stopping a Managed Notebook Runtime. -message StopRuntimeRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Idempotent request UUID. - string request_id = 2; -} - -// Request for switching a Managed Notebook Runtime. -message SwitchRuntimeRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // machine type. - string machine_type = 2; - - // accelerator config. - RuntimeAcceleratorConfig accelerator_config = 3; - - // Idempotent request UUID. - string request_id = 4; -} - -// Request for resetting a Managed Notebook Runtime. -message ResetRuntimeRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Idempotent request UUID. - string request_id = 2; -} - -// Request for upgrading a Managed Notebook Runtime to the latest version. -// option (google.api.message_visibility).restriction = -// "TRUSTED_TESTER,SPECIAL_TESTER"; -message UpgradeRuntimeRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Idempotent request UUID. - string request_id = 2; -} - -// Request for reporting a Managed Notebook Event. -message ReportRuntimeEventRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "notebooks.googleapis.com/Runtime" - } - ]; - - // Required. The VM hardware token for authenticating the VM. - // https://cloud.google.com/compute/docs/instances/verifying-instance-identity - string vm_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The Event to be reported. - Event event = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for updating a Managed Notebook configuration. -message UpdateRuntimeRequest { - // Required. The Runtime to be updated. - Runtime runtime = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Specifies the path, relative to `Runtime`, of - // the field to update. For example, to change the software configuration - // kernels, the `update_mask` parameter would be - // specified as `software_config.kernels`, - // and the `PATCH` request body would specify the new value, as follows: - // - // { - // "software_config":{ - // "kernels": [{ - // 'repository': - // 'gcr.io/deeplearning-platform-release/pytorch-gpu', 'tag': - // 'latest' }], - // } - // } - // - // - // Currently, only the following fields can be updated: - // - `software_config.kernels` - // - `software_config.post_startup_script` - // - `software_config.custom_gpu_driver_path` - // - `software_config.idle_shutdown` - // - `software_config.idle_shutdown_timeout` - // - `software_config.disable_terminal` - google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED]; - - // Idempotent request UUID. - string request_id = 3; -} - -// Request for getting a new access token. -message RefreshRuntimeTokenInternalRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "notebooks.googleapis.com/Runtime" - } - ]; - - // Required. The VM hardware token for authenticating the VM. - // https://cloud.google.com/compute/docs/instances/verifying-instance-identity - string vm_id = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Response with a new access token. -message RefreshRuntimeTokenInternalResponse { - // The OAuth 2.0 access token. - string access_token = 1; - - // Output only. Token expiration time. - google.protobuf.Timestamp expire_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Request for creating a notebook instance diagnostic file. -message DiagnoseRuntimeRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/runtimes/{runtimes_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "notebooks.googleapis.com/Runtime" - } - ]; - - // Required. Defines flags that are used to run the diagnostic tool - DiagnosticConfig diagnostic_config = 2 [(google.api.field_behavior) = REQUIRED]; -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/runtime.proto b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/runtime.proto deleted file mode 100644 index 48505b537b5..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/runtime.proto +++ /dev/null @@ -1,611 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.notebooks.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/notebooks/v1/environment.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Notebooks.V1"; -option go_package = "cloud.google.com/go/notebooks/apiv1/notebookspb;notebookspb"; -option java_multiple_files = true; -option java_outer_classname = "RuntimeProto"; -option java_package = "com.google.cloud.notebooks.v1"; -option php_namespace = "Google\\Cloud\\Notebooks\\V1"; -option ruby_package = "Google::Cloud::Notebooks::V1"; - -// The definition of a Runtime for a managed notebook instance. -message Runtime { - option (google.api.resource) = { - type: "notebooks.googleapis.com/Runtime" - pattern: "projects/{project}/locations/{location}/runtimes/{runtime}" - }; - - // The definition of the states of this runtime. - enum State { - // State is not specified. - STATE_UNSPECIFIED = 0; - - // The compute layer is starting the runtime. It is not ready for use. - STARTING = 1; - - // The compute layer is installing required frameworks and registering the - // runtime with notebook proxy. It cannot be used. - PROVISIONING = 2; - - // The runtime is currently running. It is ready for use. - ACTIVE = 3; - - // The control logic is stopping the runtime. It cannot be used. - STOPPING = 4; - - // The runtime is stopped. It cannot be used. - STOPPED = 5; - - // The runtime is being deleted. It cannot be used. - DELETING = 6; - - // The runtime is upgrading. It cannot be used. - UPGRADING = 7; - - // The runtime is being created and set up. It is not ready for use. - INITIALIZING = 8; - } - - // The runtime substate. - enum HealthState { - // The runtime substate is unknown. - HEALTH_STATE_UNSPECIFIED = 0; - - // The runtime is known to be in an healthy state - // (for example, critical daemons are running) - // Applies to ACTIVE state. - HEALTHY = 1; - - // The runtime is known to be in an unhealthy state - // (for example, critical daemons are not running) - // Applies to ACTIVE state. - UNHEALTHY = 2; - - // The runtime has not installed health monitoring agent. - // Applies to ACTIVE state. - AGENT_NOT_INSTALLED = 3; - - // The runtime health monitoring agent is not running. - // Applies to ACTIVE state. - AGENT_NOT_RUNNING = 4; - } - - // Output only. The resource name of the runtime. - // Format: - // `projects/{project}/locations/{location}/runtimes/{runtimeId}` - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Type of the runtime; currently only supports Compute Engine VM. - oneof runtime_type { - // Use a Compute Engine VM image to start the managed notebook instance. - VirtualMachine virtual_machine = 2; - } - - // Output only. Runtime state. - State state = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Runtime health_state. - HealthState health_state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The config settings for accessing runtime. - RuntimeAccessConfig access_config = 5; - - // The config settings for software inside the runtime. - RuntimeSoftwareConfig software_config = 6; - - // Output only. Contains Runtime daemon metrics such as Service status and JupyterLab - // stats. - RuntimeMetrics metrics = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Runtime creation time. - google.protobuf.Timestamp create_time = 20 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Runtime update time. - google.protobuf.Timestamp update_time = 21 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Definition of the types of hardware accelerators that can be used. -// Definition of the types of hardware accelerators that can be used. -// See [Compute Engine -// AcceleratorTypes](https://cloud.google.com/compute/docs/reference/beta/acceleratorTypes). -// Examples: -// -// * `nvidia-tesla-k80` -// * `nvidia-tesla-p100` -// * `nvidia-tesla-v100` -// * `nvidia-tesla-p4` -// * `nvidia-tesla-t4` -// * `nvidia-tesla-a100` -message RuntimeAcceleratorConfig { - // Type of this accelerator. - enum AcceleratorType { - // Accelerator type is not specified. - ACCELERATOR_TYPE_UNSPECIFIED = 0; - - // Accelerator type is Nvidia Tesla K80. - NVIDIA_TESLA_K80 = 1 [deprecated = true]; - - // Accelerator type is Nvidia Tesla P100. - NVIDIA_TESLA_P100 = 2; - - // Accelerator type is Nvidia Tesla V100. - NVIDIA_TESLA_V100 = 3; - - // Accelerator type is Nvidia Tesla P4. - NVIDIA_TESLA_P4 = 4; - - // Accelerator type is Nvidia Tesla T4. - NVIDIA_TESLA_T4 = 5; - - // Accelerator type is Nvidia Tesla A100. - NVIDIA_TESLA_A100 = 6; - - // (Coming soon) Accelerator type is TPU V2. - TPU_V2 = 7; - - // (Coming soon) Accelerator type is TPU V3. - TPU_V3 = 8; - - // Accelerator type is NVIDIA Tesla T4 Virtual Workstations. - NVIDIA_TESLA_T4_VWS = 9; - - // Accelerator type is NVIDIA Tesla P100 Virtual Workstations. - NVIDIA_TESLA_P100_VWS = 10; - - // Accelerator type is NVIDIA Tesla P4 Virtual Workstations. - NVIDIA_TESLA_P4_VWS = 11; - } - - // Accelerator model. - AcceleratorType type = 1; - - // Count of cores of this accelerator. - int64 core_count = 2; -} - -// Represents a custom encryption key configuration that can be applied to -// a resource. This will encrypt all disks in Virtual Machine. -message EncryptionConfig { - // The Cloud KMS resource identifier of the customer-managed encryption key - // used to protect a resource, such as a disks. It has the following - // format: - // `projects/{PROJECT_ID}/locations/{REGION}/keyRings/{KEY_RING_NAME}/cryptoKeys/{KEY_NAME}` - string kms_key = 1; -} - -// A Local attached disk resource. -message LocalDisk { - // Optional. A list of features to enable on the guest operating system. - // Applicable only for bootable images. - // Read [Enabling guest operating system - // features](https://cloud.google.com/compute/docs/images/create-delete-deprecate-private-images#guest-os-features) - // to see a list of available options. - // Guest OS features for boot disk. - message RuntimeGuestOsFeature { - // The ID of a supported feature. Read [Enabling guest operating system - // features](https://cloud.google.com/compute/docs/images/create-delete-deprecate-private-images#guest-os-features) - // to see a list of available options. - // - // Valid values: - // - // * `FEATURE_TYPE_UNSPECIFIED` - // * `MULTI_IP_SUBNET` - // * `SECURE_BOOT` - // * `UEFI_COMPATIBLE` - // * `VIRTIO_SCSI_MULTIQUEUE` - // * `WINDOWS` - string type = 1; - } - - // Optional. Output only. Specifies whether the disk will be auto-deleted when the - // instance is deleted (but not when the disk is detached from the instance). - bool auto_delete = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Output only. Indicates that this is a boot disk. The virtual machine - // will use the first partition of the disk for its root filesystem. - bool boot = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Output only. Specifies a unique device name - // of your choice that is reflected into the - // `/dev/disk/by-id/google-*` tree of a Linux operating system running within - // the instance. This name can be used to reference the device for mounting, - // resizing, and so on, from within the instance. - // - // If not specified, the server chooses a default device name to apply to this - // disk, in the form persistent-disk-x, where x is a number assigned by Google - // Compute Engine. This field is only applicable for persistent disks. - string device_name = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Indicates a list of features to enable on the guest operating system. - // Applicable only for bootable images. Read Enabling guest operating - // system features to see a list of available options. - repeated RuntimeGuestOsFeature guest_os_features = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A zero-based index to this disk, where 0 is reserved for the - // boot disk. If you have many disks attached to an instance, each disk would - // have a unique index number. - int32 index = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Input only. Specifies the parameters for a new disk that will be created - // alongside the new instance. Use initialization parameters to create boot - // disks or local SSDs attached to the new instance. - // - // This property is mutually exclusive with the source property; you can only - // define one or the other, but not both. - LocalDiskInitializeParams initialize_params = 6 [(google.api.field_behavior) = INPUT_ONLY]; - - // Specifies the disk interface to use for attaching this disk, which is - // either SCSI or NVME. The default is SCSI. Persistent disks must always use - // SCSI and the request will fail if you attempt to attach a persistent disk - // in any other format than SCSI. Local SSDs can use either NVME or SCSI. For - // performance characteristics of SCSI over NVMe, see Local SSD performance. - // Valid values: - // - // * `NVME` - // * `SCSI` - string interface = 7; - - // Output only. Type of the resource. Always compute#attachedDisk for attached disks. - string kind = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Any valid publicly visible licenses. - repeated string licenses = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The mode in which to attach this disk, either `READ_WRITE` or `READ_ONLY`. - // If not specified, the default is to attach the disk in `READ_WRITE` mode. - // Valid values: - // - // * `READ_ONLY` - // * `READ_WRITE` - string mode = 10; - - // Specifies a valid partial or full URL to an existing Persistent Disk - // resource. - string source = 11; - - // Specifies the type of the disk, either `SCRATCH` or `PERSISTENT`. If not - // specified, the default is `PERSISTENT`. - // Valid values: - // - // * `PERSISTENT` - // * `SCRATCH` - string type = 12; -} - -// Input only. Specifies the parameters for a new disk that will be created -// alongside the new instance. Use initialization parameters to create boot -// disks or local SSDs attached to the new runtime. -// This property is mutually exclusive with the source property; you can only -// define one or the other, but not both. -message LocalDiskInitializeParams { - // Possible disk types. - enum DiskType { - // Disk type not set. - DISK_TYPE_UNSPECIFIED = 0; - - // Standard persistent disk type. - PD_STANDARD = 1; - - // SSD persistent disk type. - PD_SSD = 2; - - // Balanced persistent disk type. - PD_BALANCED = 3; - - // Extreme persistent disk type. - PD_EXTREME = 4; - } - - // Optional. Provide this property when creating the disk. - string description = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Specifies the disk name. If not specified, the default is to use the name - // of the instance. If the disk with the instance name exists already in the - // given zone/region, a new name will be automatically generated. - string disk_name = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Specifies the size of the disk in base-2 GB. If not specified, the disk - // will be the same size as the image (usually 10GB). If specified, the size - // must be equal to or larger than 10GB. Default 100 GB. - int64 disk_size_gb = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Input only. The type of the boot disk attached to this instance, defaults to - // standard persistent disk (`PD_STANDARD`). - DiskType disk_type = 4 [(google.api.field_behavior) = INPUT_ONLY]; - - // Optional. Labels to apply to this disk. These can be later modified by the - // disks.setLabels method. This field is only applicable for persistent disks. - map labels = 5 [(google.api.field_behavior) = OPTIONAL]; -} - -// Specifies the login configuration for Runtime -message RuntimeAccessConfig { - // Possible ways to access runtime. Authentication mode. - // Currently supports: Single User only. - enum RuntimeAccessType { - // Unspecified access. - RUNTIME_ACCESS_TYPE_UNSPECIFIED = 0; - - // Single user login. - SINGLE_USER = 1; - - // Service Account mode. - // In Service Account mode, Runtime creator will specify a SA that exists - // in the consumer project. Using Runtime Service Account field. - // Users accessing the Runtime need ActAs (Service Account User) permission. - SERVICE_ACCOUNT = 2; - } - - // The type of access mode this instance. - RuntimeAccessType access_type = 1; - - // The owner of this runtime after creation. Format: `alias@example.com` - // Currently supports one owner only. - string runtime_owner = 2; - - // Output only. The proxy endpoint that is used to access the runtime. - string proxy_uri = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Specifies the selection and configuration of software inside the runtime. -// The properties to set on runtime. -// Properties keys are specified in `key:value` format, for example: -// -// * `idle_shutdown: true` -// * `idle_shutdown_timeout: 180` -// * `enable_health_monitoring: true` -message RuntimeSoftwareConfig { - // Behavior for the post startup script. - enum PostStartupScriptBehavior { - // Unspecified post startup script behavior. Will run only once at creation. - POST_STARTUP_SCRIPT_BEHAVIOR_UNSPECIFIED = 0; - - // Runs the post startup script provided during creation at every start. - RUN_EVERY_START = 1; - - // Downloads and runs the provided post startup script at every start. - DOWNLOAD_AND_RUN_EVERY_START = 2; - } - - // Cron expression in UTC timezone, used to schedule instance auto upgrade. - // Please follow the [cron format](https://en.wikipedia.org/wiki/Cron). - string notebook_upgrade_schedule = 1; - - // Verifies core internal services are running. - // Default: True - optional bool enable_health_monitoring = 2; - - // Runtime will automatically shutdown after idle_shutdown_time. - // Default: True - optional bool idle_shutdown = 3; - - // Time in minutes to wait before shutting down runtime. Default: 180 minutes - int32 idle_shutdown_timeout = 4; - - // Install Nvidia Driver automatically. - // Default: True - bool install_gpu_driver = 5; - - // Specify a custom Cloud Storage path where the GPU driver is stored. - // If not specified, we'll automatically choose from official GPU drivers. - string custom_gpu_driver_path = 6; - - // Path to a Bash script that automatically runs after a notebook instance - // fully boots up. The path must be a URL or - // Cloud Storage path (`gs://path-to-file/file-name`). - string post_startup_script = 7; - - // Optional. Use a list of container images to use as Kernels in the notebook instance. - repeated ContainerImage kernels = 8 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. Bool indicating whether an newer image is available in an image family. - optional bool upgradeable = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Behavior for the post startup script. - PostStartupScriptBehavior post_startup_script_behavior = 10; - - // Bool indicating whether JupyterLab terminal will be available or not. - // Default: False - optional bool disable_terminal = 11; - - // Output only. version of boot image such as M100, from release label of the image. - optional string version = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Contains runtime daemon metrics, such as OS and kernels and sessions stats. -message RuntimeMetrics { - // Output only. The system metrics. - map system_metrics = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A set of Shielded Instance options. -// Check [Images using supported Shielded VM -// features](https://cloud.google.com/compute/docs/instances/modifying-shielded-vm). -// Not all combinations are valid. -message RuntimeShieldedInstanceConfig { - // Defines whether the instance has Secure Boot enabled. - // - // Secure Boot helps ensure that the system only runs authentic software by - // verifying the digital signature of all boot components, and halting the - // boot process if signature verification fails. Disabled by default. - bool enable_secure_boot = 1; - - // Defines whether the instance has the vTPM enabled. Enabled by default. - bool enable_vtpm = 2; - - // Defines whether the instance has integrity monitoring enabled. - // - // Enables monitoring and attestation of the boot integrity of the instance. - // The attestation is performed against the integrity policy baseline. This - // baseline is initially derived from the implicitly trusted boot image when - // the instance is created. Enabled by default. - bool enable_integrity_monitoring = 3; -} - -// Runtime using Virtual Machine for computing. -message VirtualMachine { - // Output only. The user-friendly name of the Managed Compute Engine instance. - string instance_name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The unique identifier of the Managed Compute Engine instance. - string instance_id = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Virtual Machine configuration settings. - VirtualMachineConfig virtual_machine_config = 3; -} - -// The config settings for virtual machine. -message VirtualMachineConfig { - // The type of vNIC driver. - // Default should be UNSPECIFIED_NIC_TYPE. - enum NicType { - // No type specified. - UNSPECIFIED_NIC_TYPE = 0; - - // VIRTIO - VIRTIO_NET = 1; - - // GVNIC - GVNIC = 2; - } - - // Definition of the boot image used by the Runtime. - // Used to facilitate runtime upgradeability. - message BootImage { - - } - - // Output only. The zone where the virtual machine is located. - // If using regional request, the notebooks service will pick a location - // in the corresponding runtime region. - // On a get request, zone will always be present. Example: - // * `us-central1-b` - string zone = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Required. The Compute Engine machine type used for runtimes. - // Short name is valid. Examples: - // * `n1-standard-2` - // * `e2-standard-8` - string machine_type = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Use a list of container images to use as Kernels in the notebook instance. - repeated ContainerImage container_images = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Required. Data disk option configuration settings. - LocalDisk data_disk = 4 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Encryption settings for virtual machine data disk. - EncryptionConfig encryption_config = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Shielded VM Instance configuration settings. - RuntimeShieldedInstanceConfig shielded_instance_config = 6 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The Compute Engine accelerator configuration for this runtime. - RuntimeAcceleratorConfig accelerator_config = 7 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The Compute Engine network to be used for machine - // communications. Cannot be specified with subnetwork. If neither - // `network` nor `subnet` is specified, the "default" network of - // the project is used, if it exists. - // - // A full URL or partial URI. Examples: - // - // * `https://www.googleapis.com/compute/v1/projects/[project_id]/global/networks/default` - // * `projects/[project_id]/global/networks/default` - // - // Runtimes are managed resources inside Google Infrastructure. - // Runtimes support the following network configurations: - // - // * Google Managed Network (Network & subnet are empty) - // * Consumer Project VPC (network & subnet are required). Requires - // configuring Private Service Access. - // * Shared VPC (network & subnet are required). Requires configuring Private - // Service Access. - string network = 8 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The Compute Engine subnetwork to be used for machine - // communications. Cannot be specified with network. - // - // A full URL or partial URI are valid. Examples: - // - // * `https://www.googleapis.com/compute/v1/projects/[project_id]/regions/us-east1/subnetworks/sub0` - // * `projects/[project_id]/regions/us-east1/subnetworks/sub0` - string subnet = 9 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. If true, runtime will only have internal IP - // addresses. By default, runtimes are not restricted to internal IP - // addresses, and will have ephemeral external IP addresses assigned to each - // vm. This `internal_ip_only` restriction can only be enabled for - // subnetwork enabled networks, and all dependencies must be - // configured to be accessible without external IP addresses. - bool internal_ip_only = 10 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The Compute Engine tags to add to runtime (see [Tagging - // instances](https://cloud.google.com/compute/docs/label-or-tag-resources#tags)). - repeated string tags = 13 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The Compute Engine guest attributes. (see - // [Project and instance - // guest - // attributes](https://cloud.google.com/compute/docs/storing-retrieving-metadata#guest_attributes)). - map guest_attributes = 14 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. The Compute Engine metadata entries to add to virtual machine. (see - // [Project and instance - // metadata](https://cloud.google.com/compute/docs/storing-retrieving-metadata#project_and_instance_metadata)). - map metadata = 15 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The labels to associate with this runtime. - // Label **keys** must contain 1 to 63 characters, and must conform to - // [RFC 1035](https://www.ietf.org/rfc/rfc1035.txt). - // Label **values** may be empty, but, if present, must contain 1 to 63 - // characters, and must conform to [RFC - // 1035](https://www.ietf.org/rfc/rfc1035.txt). No more than 32 labels can be - // associated with a cluster. - map labels = 16 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The type of vNIC to be used on this interface. This may be gVNIC or - // VirtioNet. - NicType nic_type = 17 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Reserved IP Range name is used for VPC Peering. - // The subnetwork allocation will use the range *name* if it's assigned. - // - // Example: managed-notebooks-range-c - // - // PEERING_RANGE_NAME_3=managed-notebooks-range-c - // gcloud compute addresses create $PEERING_RANGE_NAME_3 \ - // --global \ - // --prefix-length=24 \ - // --description="Google Cloud Managed Notebooks Range 24 c" \ - // --network=$NETWORK \ - // --addresses=192.168.0.0 \ - // --purpose=VPC_PEERING - // - // Field value will be: `managed-notebooks-range-c` - string reserved_ip_range = 18 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Boot image metadata used for runtime upgradeability. - BootImage boot_image = 19 [(google.api.field_behavior) = OPTIONAL]; -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/schedule.proto b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/schedule.proto deleted file mode 100644 index 9d30a17eed8..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/schedule.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.notebooks.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/notebooks/v1/execution.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "cloud.google.com/go/notebooks/apiv1/notebookspb;notebookspb"; -option java_multiple_files = true; -option java_outer_classname = "ScheduleProto"; -option java_package = "com.google.cloud.notebooks.v1"; - -// The definition of a schedule. -message Schedule { - option (google.api.resource) = { - type: "notebooks.googleapis.com/Schedule" - pattern: "projects/{project}/location/{location}/schedules/{schedule}" - }; - - // State of the job. - enum State { - // Unspecified state. - STATE_UNSPECIFIED = 0; - - // The job is executing normally. - ENABLED = 1; - - // The job is paused by the user. It will not execute. A user can - // intentionally pause the job using - // [PauseJobRequest][]. - PAUSED = 2; - - // The job is disabled by the system due to error. The user - // cannot directly set a job to be disabled. - DISABLED = 3; - - // The job state resulting from a failed [CloudScheduler.UpdateJob][] - // operation. To recover a job from this state, retry - // [CloudScheduler.UpdateJob][] until a successful response is received. - UPDATE_FAILED = 4; - - // The schedule resource is being created. - INITIALIZING = 5; - - // The schedule resource is being deleted. - DELETING = 6; - } - - // Output only. The name of this schedule. Format: - // `projects/{project_id}/locations/{location}/schedules/{schedule_id}` - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Display name used for UI purposes. - // Name can only contain alphanumeric characters, hyphens `-`, - // and underscores `_`. - string display_name = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // A brief description of this environment. - string description = 3; - - State state = 4; - - // Cron-tab formatted schedule by which the job will execute. - // Format: minute, hour, day of month, month, day of week, - // e.g. `0 0 * * WED` = every Wednesday - // More examples: https://crontab.guru/examples.html - string cron_schedule = 5; - - // Timezone on which the cron_schedule. - // The value of this field must be a time zone name from the tz database. - // TZ Database: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones - // - // Note that some time zones include a provision for daylight savings time. - // The rules for daylight saving time are determined by the chosen tz. - // For UTC use the string "utc". If a time zone is not specified, - // the default will be in UTC (also known as GMT). - string time_zone = 6; - - // Output only. Time the schedule was created. - google.protobuf.Timestamp create_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Time the schedule was last updated. - google.protobuf.Timestamp update_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Notebook Execution Template corresponding to this schedule. - ExecutionTemplate execution_template = 9; - - // Output only. The most recent execution names triggered from this schedule and their - // corresponding states. - repeated Execution recent_executions = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/service.proto b/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/service.proto deleted file mode 100644 index 04c42eddd12..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/protos/google/cloud/notebooks/v1/service.proto +++ /dev/null @@ -1,1017 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.notebooks.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/notebooks/v1/diagnostic_config.proto"; -import "google/cloud/notebooks/v1/environment.proto"; -import "google/cloud/notebooks/v1/execution.proto"; -import "google/cloud/notebooks/v1/instance.proto"; -import "google/cloud/notebooks/v1/instance_config.proto"; -import "google/cloud/notebooks/v1/schedule.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Notebooks.V1"; -option go_package = "cloud.google.com/go/notebooks/apiv1/notebookspb;notebookspb"; -option java_multiple_files = true; -option java_outer_classname = "NotebooksProto"; -option java_package = "com.google.cloud.notebooks.v1"; -option php_namespace = "Google\\Cloud\\Notebooks\\V1"; -option ruby_package = "Google::Cloud::Notebooks::V1"; - -// API v1 service for Cloud AI Platform Notebooks. -service NotebookService { - option (google.api.default_host) = "notebooks.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Lists instances in a given project and location. - rpc ListInstances(ListInstancesRequest) returns (ListInstancesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/instances" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets details of a single Instance. - rpc GetInstance(GetInstanceRequest) returns (Instance) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/instances/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a new Instance in a given project and location. - rpc CreateInstance(CreateInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/instances" - body: "instance" - }; - option (google.api.method_signature) = "parent,instance,instance_id"; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Registers an existing legacy notebook instance to the Notebooks API server. - // Legacy instances are instances created with the legacy Compute Engine - // calls. They are not manageable by the Notebooks API out of the box. This - // call makes these instances manageable by the Notebooks API. - rpc RegisterInstance(RegisterInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/instances:register" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Updates the guest accelerators of a single Instance. - rpc SetInstanceAccelerator(SetInstanceAcceleratorRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1/{name=projects/*/locations/*/instances/*}:setAccelerator" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Updates the machine type of a single Instance. - rpc SetInstanceMachineType(SetInstanceMachineTypeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1/{name=projects/*/locations/*/instances/*}:setMachineType" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Update Notebook Instance configurations. - rpc UpdateInstanceConfig(UpdateInstanceConfigRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1/{name=projects/*/locations/*/instances/*}:updateConfig" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Updates the Shielded instance configuration of a single Instance. - rpc UpdateShieldedInstanceConfig(UpdateShieldedInstanceConfigRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1/{name=projects/*/locations/*/instances/*}:updateShieldedInstanceConfig" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Replaces all the labels of an Instance. - rpc SetInstanceLabels(SetInstanceLabelsRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1/{name=projects/*/locations/*/instances/*}:setLabels" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Add/update metadata items for an instance. - rpc UpdateInstanceMetadataItems(UpdateInstanceMetadataItemsRequest) returns (UpdateInstanceMetadataItemsResponse) { - option (google.api.http) = { - patch: "/v1/{name=projects/*/locations/*/instances/*}:updateMetadataItems" - body: "*" - }; - } - - // Deletes a single Instance. - rpc DeleteInstance(DeleteInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/instances/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "OperationMetadata" - }; - } - - // Starts a notebook instance. - rpc StartInstance(StartInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/instances/*}:start" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Stops a notebook instance. - rpc StopInstance(StopInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/instances/*}:stop" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Resets a notebook instance. - rpc ResetInstance(ResetInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/instances/*}:reset" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Allows notebook instances to - // report their latest instance information to the Notebooks - // API server. The server will merge the reported information to - // the instance metadata store. Do not use this method directly. - rpc ReportInstanceInfo(ReportInstanceInfoRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/instances/*}:report" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Check if a notebook instance is upgradable. - rpc IsInstanceUpgradeable(IsInstanceUpgradeableRequest) returns (IsInstanceUpgradeableResponse) { - option (google.api.http) = { - get: "/v1/{notebook_instance=projects/*/locations/*/instances/*}:isUpgradeable" - }; - } - - // Check if a notebook instance is healthy. - rpc GetInstanceHealth(GetInstanceHealthRequest) returns (GetInstanceHealthResponse) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/instances/*}:getInstanceHealth" - }; - option (google.api.method_signature) = "name"; - } - - // Upgrades a notebook instance to the latest version. - rpc UpgradeInstance(UpgradeInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/instances/*}:upgrade" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Rollbacks a notebook instance to the previous version. - rpc RollbackInstance(RollbackInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/instances/*}:rollback" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Creates a Diagnostic File and runs Diagnostic Tool given an Instance. - rpc DiagnoseInstance(DiagnoseInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/instances/*}:diagnose" - body: "*" - }; - option (google.api.method_signature) = "name,diagnostic_config"; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Allows notebook instances to - // call this endpoint to upgrade themselves. Do not use this method directly. - rpc UpgradeInstanceInternal(UpgradeInstanceInternalRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/instances/*}:upgradeInternal" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Lists environments in a project. - rpc ListEnvironments(ListEnvironmentsRequest) returns (ListEnvironmentsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/environments" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets details of a single Environment. - rpc GetEnvironment(GetEnvironmentRequest) returns (Environment) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/environments/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a new Environment. - rpc CreateEnvironment(CreateEnvironmentRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/environments" - body: "environment" - }; - option (google.api.method_signature) = "parent,environment,environment_id"; - option (google.longrunning.operation_info) = { - response_type: "Environment" - metadata_type: "OperationMetadata" - }; - } - - // Deletes a single Environment. - rpc DeleteEnvironment(DeleteEnvironmentRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/environments/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "OperationMetadata" - }; - } - - // Lists schedules in a given project and location. - rpc ListSchedules(ListSchedulesRequest) returns (ListSchedulesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/schedules" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets details of schedule - rpc GetSchedule(GetScheduleRequest) returns (Schedule) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/schedules/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Deletes schedule and all underlying jobs - rpc DeleteSchedule(DeleteScheduleRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/schedules/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "OperationMetadata" - }; - } - - // Creates a new Scheduled Notebook in a given project and location. - rpc CreateSchedule(CreateScheduleRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/schedules" - body: "schedule" - }; - option (google.api.method_signature) = "parent,schedule,schedule_id"; - option (google.longrunning.operation_info) = { - response_type: "Schedule" - metadata_type: "OperationMetadata" - }; - } - - // Triggers execution of an existing schedule. - rpc TriggerSchedule(TriggerScheduleRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/schedules/*}:trigger" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Schedule" - metadata_type: "OperationMetadata" - }; - } - - // Lists executions in a given project and location - rpc ListExecutions(ListExecutionsRequest) returns (ListExecutionsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/executions" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets details of executions - rpc GetExecution(GetExecutionRequest) returns (Execution) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/executions/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Deletes execution - rpc DeleteExecution(DeleteExecutionRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/executions/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "OperationMetadata" - }; - } - - // Creates a new Execution in a given project and location. - rpc CreateExecution(CreateExecutionRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/executions" - body: "execution" - }; - option (google.api.method_signature) = "parent,execution,execution_id"; - option (google.longrunning.operation_info) = { - response_type: "Execution" - metadata_type: "OperationMetadata" - }; - } -} - -// Represents the metadata of the long-running operation. -message OperationMetadata { - // The time the operation was created. - google.protobuf.Timestamp create_time = 1; - - // The time the operation finished running. - google.protobuf.Timestamp end_time = 2; - - // Server-defined resource path for the target of the operation. - string target = 3; - - // Name of the verb executed by the operation. - string verb = 4; - - // Human-readable status of the operation, if any. - string status_message = 5; - - // Identifies whether the user has requested cancellation - // of the operation. Operations that have successfully been cancelled - // have [Operation.error][] value with a - // [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`. - bool requested_cancellation = 6; - - // API version used to start the operation. - string api_version = 7; - - // API endpoint name of this operation. - string endpoint = 8; -} - -// Request for listing notebook instances. -message ListInstancesRequest { - // Required. Format: - // `parent=projects/{project_id}/locations/{location}` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Maximum return size of the list call. - int32 page_size = 2; - - // A previous returned page token that can be used to continue listing - // from the last result. - string page_token = 3; -} - -// Response for listing notebook instances. -message ListInstancesResponse { - // A list of returned instances. - repeated Instance instances = 1; - - // Page token that can be used to continue listing from the last result in the - // next list call. - string next_page_token = 2; - - // Locations that could not be reached. For example, - // `['us-west1-a', 'us-central1-b']`. - // A ListInstancesResponse will only contain either instances or unreachables, - repeated string unreachable = 3; -} - -// Request for getting a notebook instance. -message GetInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for creating a notebook instance. -message CreateInstanceRequest { - // Required. Format: - // `parent=projects/{project_id}/locations/{location}` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. User-defined unique ID of this instance. - string instance_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The instance to be created. - Instance instance = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for registering a notebook instance. -message RegisterInstanceRequest { - // Required. Format: - // `parent=projects/{project_id}/locations/{location}` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. User defined unique ID of this instance. The `instance_id` must - // be 1 to 63 characters long and contain only lowercase letters, - // numeric characters, and dashes. The first character must be a lowercase - // letter and the last character cannot be a dash. - string instance_id = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for setting instance accelerator. -message SetInstanceAcceleratorRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Type of this accelerator. - Instance.AcceleratorType type = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. Count of cores of this accelerator. Note that not all combinations - // of `type` and `core_count` are valid. Check [GPUs on - // Compute Engine](https://cloud.google.com/compute/docs/gpus/#gpus-list) to - // find a valid combination. TPUs are not supported. - int64 core_count = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for setting instance machine type. -message SetInstanceMachineTypeRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The [Compute Engine machine - // type](https://cloud.google.com/compute/docs/machine-types). - string machine_type = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for updating instance configurations. -message UpdateInstanceConfigRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // The instance configurations to be updated. - InstanceConfig config = 2; -} - -// Request for setting instance labels. -message SetInstanceLabelsRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Labels to apply to this instance. - // These can be later modified by the setLabels method - map labels = 2; -} - -// Request for adding/changing metadata items for an instance. -message UpdateInstanceMetadataItemsRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Metadata items to add/update for the instance. - map items = 2; -} - -// Response for adding/changing metadata items for an instance. -message UpdateInstanceMetadataItemsResponse { - // Map of items that were added/updated to/in the metadata. - map items = 1; -} - -// Request for updating the Shielded Instance config for a notebook instance. -// You can only use this method on a stopped instance -message UpdateShieldedInstanceConfigRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // ShieldedInstance configuration to be updated. - Instance.ShieldedInstanceConfig shielded_instance_config = 2; -} - -// Request for deleting a notebook instance. -message DeleteInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for starting a notebook instance -message StartInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for stopping a notebook instance -message StopInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for resetting a notebook instance -message ResetInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for notebook instances to report information to Notebooks API. -message ReportInstanceInfoRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The VM hardware token for authenticating the VM. - // https://cloud.google.com/compute/docs/instances/verifying-instance-identity - string vm_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // The metadata reported to Notebooks API. This will be merged to the instance - // metadata store - map metadata = 3; -} - -// Request for checking if a notebook instance is upgradeable. -message IsInstanceUpgradeableRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string notebook_instance = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The optional UpgradeType. Setting this field will search for additional - // compute images to upgrade this instance. - UpgradeType type = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// Response for checking if a notebook instance is upgradeable. -message IsInstanceUpgradeableResponse { - // If an instance is upgradeable. - bool upgradeable = 1; - - // The version this instance will be upgraded to if calling the upgrade - // endpoint. This field will only be populated if field upgradeable is true. - string upgrade_version = 2; - - // Additional information about upgrade. - string upgrade_info = 3; - - // The new image self link this instance will be upgraded to if calling the - // upgrade endpoint. This field will only be populated if field upgradeable - // is true. - string upgrade_image = 4; -} - -// Request for checking if a notebook instance is healthy. -message GetInstanceHealthRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "notebooks.googleapis.com/Instance" - } - ]; -} - -// Response for checking if a notebook instance is healthy. -message GetInstanceHealthResponse { - // If an instance is healthy or not. - enum HealthState { - // The instance substate is unknown. - HEALTH_STATE_UNSPECIFIED = 0; - - // The instance is known to be in an healthy state - // (for example, critical daemons are running) - // Applies to ACTIVE state. - HEALTHY = 1; - - // The instance is known to be in an unhealthy state - // (for example, critical daemons are not running) - // Applies to ACTIVE state. - UNHEALTHY = 2; - - // The instance has not installed health monitoring agent. - // Applies to ACTIVE state. - AGENT_NOT_INSTALLED = 3; - - // The instance health monitoring agent is not running. - // Applies to ACTIVE state. - AGENT_NOT_RUNNING = 4; - } - - // Output only. Runtime health_state. - HealthState health_state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Additional information about instance health. - // Example: - // healthInfo": { - // "docker_proxy_agent_status": "1", - // "docker_status": "1", - // "jupyterlab_api_status": "-1", - // "jupyterlab_status": "-1", - // "updated": "2020-10-18 09:40:03.573409" - // } - map health_info = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Request for upgrading a notebook instance -message UpgradeInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The optional UpgradeType. Setting this field will search for additional - // compute images to upgrade this instance. - UpgradeType type = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request for rollbacking a notebook instance -message RollbackInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The snapshot for rollback. - // Example: `projects/test-project/global/snapshots/krwlzipynril`. - string target_snapshot = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for upgrading a notebook instance from within the VM -message UpgradeInstanceInternalRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The VM hardware token for authenticating the VM. - // https://cloud.google.com/compute/docs/instances/verifying-instance-identity - string vm_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The optional UpgradeType. Setting this field will search for additional - // compute images to upgrade this instance. - UpgradeType type = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request for listing environments. -message ListEnvironmentsRequest { - // Required. Format: `projects/{project_id}/locations/{location}` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Maximum return size of the list call. - int32 page_size = 2; - - // A previous returned page token that can be used to continue listing from - // the last result. - string page_token = 3; -} - -// Request for creating a notebook instance diagnostic file. -message DiagnoseInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "notebooks.googleapis.com/Instance" - } - ]; - - // Required. Defines flags that are used to run the diagnostic tool - DiagnosticConfig diagnostic_config = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Response for listing environments. -message ListEnvironmentsResponse { - // A list of returned environments. - repeated Environment environments = 1; - - // A page token that can be used to continue listing from the last result - // in the next list call. - string next_page_token = 2; - - // Locations that could not be reached. - repeated string unreachable = 3; -} - -// Request for getting a notebook environment. -message GetEnvironmentRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/environments/{environment_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for creating a notebook environment. -message CreateEnvironmentRequest { - // Required. Format: `projects/{project_id}/locations/{location}` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. User-defined unique ID of this environment. The `environment_id` must - // be 1 to 63 characters long and contain only lowercase letters, - // numeric characters, and dashes. The first character must be a lowercase - // letter and the last character cannot be a dash. - string environment_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The environment to be created. - Environment environment = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for deleting a notebook environment. -message DeleteEnvironmentRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/environments/{environment_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for listing scheduled notebook job. -message ListSchedulesRequest { - // Required. Format: - // `parent=projects/{project_id}/locations/{location}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "notebooks.googleapis.com/Schedule" - } - ]; - - // Maximum return size of the list call. - int32 page_size = 2; - - // A previous returned page token that can be used to continue listing - // from the last result. - string page_token = 3; - - // Filter applied to resulting schedules. - string filter = 4; - - // Field to order results by. - string order_by = 5; -} - -// Response for listing scheduled notebook job. -message ListSchedulesResponse { - // A list of returned instances. - repeated Schedule schedules = 1; - - // Page token that can be used to continue listing from the last result in the - // next list call. - string next_page_token = 2; - - // Schedules that could not be reached. For example: - // - // ['projects/{project_id}/location/{location}/schedules/monthly_digest', - // 'projects/{project_id}/location/{location}/schedules/weekly_sentiment'] - repeated string unreachable = 3; -} - -// Request for getting scheduled notebook. -message GetScheduleRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/schedules/{schedule_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "notebooks.googleapis.com/Schedule" - } - ]; -} - -// Request for deleting an Schedule -message DeleteScheduleRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/schedules/{schedule_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "notebooks.googleapis.com/Schedule" - } - ]; -} - -// Request for created scheduled notebooks -message CreateScheduleRequest { - // Required. Format: - // `parent=projects/{project_id}/locations/{location}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "notebooks.googleapis.com/Schedule" - } - ]; - - // Required. User-defined unique ID of this schedule. - string schedule_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The schedule to be created. - Schedule schedule = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for created scheduled notebooks -message TriggerScheduleRequest { - // Required. Format: - // `parent=projects/{project_id}/locations/{location}/schedules/{schedule_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "notebooks.googleapis.com/Schedule" - } - ]; -} - -// Request for listing scheduled notebook executions. -message ListExecutionsRequest { - // Required. Format: - // `parent=projects/{project_id}/locations/{location}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "notebooks.googleapis.com/Execution" - } - ]; - - // Maximum return size of the list call. - int32 page_size = 2; - - // A previous returned page token that can be used to continue listing - // from the last result. - string page_token = 3; - - // Filter applied to resulting executions. Currently only supports filtering - // executions by a specified `schedule_id`. - // Format: `schedule_id=` - string filter = 4; - - // Sort by field. - string order_by = 5; -} - -// Response for listing scheduled notebook executions -message ListExecutionsResponse { - // A list of returned instances. - repeated Execution executions = 1; - - // Page token that can be used to continue listing from the last result in the - // next list call. - string next_page_token = 2; - - // Executions IDs that could not be reached. For example: - // - // ['projects/{project_id}/location/{location}/executions/imagenet_test1', - // 'projects/{project_id}/location/{location}/executions/classifier_train1'] - repeated string unreachable = 3; -} - -// Request for getting scheduled notebook execution -message GetExecutionRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/executions/{execution_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "notebooks.googleapis.com/Execution" - } - ]; -} - -// Request for deleting a scheduled notebook execution -message DeleteExecutionRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/executions/{execution_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "notebooks.googleapis.com/Execution" - } - ]; -} - -// Request to create notebook execution -message CreateExecutionRequest { - // Required. Format: - // `parent=projects/{project_id}/locations/{location}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "notebooks.googleapis.com/Execution" - } - ]; - - // Required. User-defined unique ID of this execution. - string execution_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The execution to be created. - Execution execution = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Definition of the types of upgrade that can be used on this -// instance. -enum UpgradeType { - // Upgrade type is not specified. - UPGRADE_TYPE_UNSPECIFIED = 0; - - // Upgrade ML framework. - UPGRADE_FRAMEWORK = 1; - - // Upgrade Operating System. - UPGRADE_OS = 2; - - // Upgrade CUDA. - UPGRADE_CUDA = 3; - - // Upgrade All (OS, Framework and CUDA). - UPGRADE_ALL = 4; -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.create_runtime.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.create_runtime.js deleted file mode 100644 index 2c1efc1c9bd..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.create_runtime.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(parent, runtimeId, runtime) { - // [START notebooks_v1_generated_ManagedNotebookService_CreateRuntime_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - */ - // const parent = 'abc123' - /** - * Required. User-defined unique ID of this Runtime. - */ - // const runtimeId = 'abc123' - /** - * Required. The Runtime to be created. - */ - // const runtime = {} - /** - * Idempotent request UUID. - */ - // const requestId = 'abc123' - - // Imports the Notebooks library - const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new ManagedNotebookServiceClient(); - - async function callCreateRuntime() { - // Construct request - const request = { - parent, - runtimeId, - runtime, - }; - - // Run request - const [operation] = await notebooksClient.createRuntime(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateRuntime(); - // [END notebooks_v1_generated_ManagedNotebookService_CreateRuntime_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.delete_runtime.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.delete_runtime.js deleted file mode 100644 index e85d4f18750..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.delete_runtime.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(name) { - // [START notebooks_v1_generated_ManagedNotebookService_DeleteRuntime_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - */ - // const name = 'abc123' - /** - * Idempotent request UUID. - */ - // const requestId = 'abc123' - - // Imports the Notebooks library - const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new ManagedNotebookServiceClient(); - - async function callDeleteRuntime() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.deleteRuntime(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteRuntime(); - // [END notebooks_v1_generated_ManagedNotebookService_DeleteRuntime_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.diagnose_runtime.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.diagnose_runtime.js deleted file mode 100644 index 009022105ae..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.diagnose_runtime.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, diagnosticConfig) { - // [START notebooks_v1_generated_ManagedNotebookService_DiagnoseRuntime_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtimes_id}` - */ - // const name = 'abc123' - /** - * Required. Defines flags that are used to run the diagnostic tool - */ - // const diagnosticConfig = {} - - // Imports the Notebooks library - const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new ManagedNotebookServiceClient(); - - async function callDiagnoseRuntime() { - // Construct request - const request = { - name, - diagnosticConfig, - }; - - // Run request - const [operation] = await notebooksClient.diagnoseRuntime(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDiagnoseRuntime(); - // [END notebooks_v1_generated_ManagedNotebookService_DiagnoseRuntime_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.get_runtime.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.get_runtime.js deleted file mode 100644 index 221b3758754..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.get_runtime.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 notebooks_v1_generated_ManagedNotebookService_GetRuntime_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new ManagedNotebookServiceClient(); - - async function callGetRuntime() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await notebooksClient.getRuntime(request); - console.log(response); - } - - callGetRuntime(); - // [END notebooks_v1_generated_ManagedNotebookService_GetRuntime_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.list_runtimes.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.list_runtimes.js deleted file mode 100644 index fc7fd13a218..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.list_runtimes.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(parent) { - // [START notebooks_v1_generated_ManagedNotebookService_ListRuntimes_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - */ - // const parent = 'abc123' - /** - * Maximum return size of the list call. - */ - // const pageSize = 1234 - /** - * A previous returned page token that can be used to continue listing - * from the last result. - */ - // const pageToken = 'abc123' - - // Imports the Notebooks library - const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new ManagedNotebookServiceClient(); - - async function callListRuntimes() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await notebooksClient.listRuntimesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListRuntimes(); - // [END notebooks_v1_generated_ManagedNotebookService_ListRuntimes_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.refresh_runtime_token_internal.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.refresh_runtime_token_internal.js deleted file mode 100644 index 7f5cc0143ab..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.refresh_runtime_token_internal.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, vmId) { - // [START notebooks_v1_generated_ManagedNotebookService_RefreshRuntimeTokenInternal_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - */ - // const name = 'abc123' - /** - * Required. The VM hardware token for authenticating the VM. - * https://cloud.google.com/compute/docs/instances/verifying-instance-identity - */ - // const vmId = 'abc123' - - // Imports the Notebooks library - const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new ManagedNotebookServiceClient(); - - async function callRefreshRuntimeTokenInternal() { - // Construct request - const request = { - name, - vmId, - }; - - // Run request - const response = await notebooksClient.refreshRuntimeTokenInternal(request); - console.log(response); - } - - callRefreshRuntimeTokenInternal(); - // [END notebooks_v1_generated_ManagedNotebookService_RefreshRuntimeTokenInternal_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.report_runtime_event.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.report_runtime_event.js deleted file mode 100644 index cc3bd959a5f..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.report_runtime_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(name, vmId, event) { - // [START notebooks_v1_generated_ManagedNotebookService_ReportRuntimeEvent_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - */ - // const name = 'abc123' - /** - * Required. The VM hardware token for authenticating the VM. - * https://cloud.google.com/compute/docs/instances/verifying-instance-identity - */ - // const vmId = 'abc123' - /** - * Required. The Event to be reported. - */ - // const event = {} - - // Imports the Notebooks library - const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new ManagedNotebookServiceClient(); - - async function callReportRuntimeEvent() { - // Construct request - const request = { - name, - vmId, - event, - }; - - // Run request - const [operation] = await notebooksClient.reportRuntimeEvent(request); - const [response] = await operation.promise(); - console.log(response); - } - - callReportRuntimeEvent(); - // [END notebooks_v1_generated_ManagedNotebookService_ReportRuntimeEvent_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.reset_runtime.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.reset_runtime.js deleted file mode 100644 index 67ea0e65e35..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.reset_runtime.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(name) { - // [START notebooks_v1_generated_ManagedNotebookService_ResetRuntime_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - */ - // const name = 'abc123' - /** - * Idempotent request UUID. - */ - // const requestId = 'abc123' - - // Imports the Notebooks library - const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new ManagedNotebookServiceClient(); - - async function callResetRuntime() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.resetRuntime(request); - const [response] = await operation.promise(); - console.log(response); - } - - callResetRuntime(); - // [END notebooks_v1_generated_ManagedNotebookService_ResetRuntime_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.start_runtime.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.start_runtime.js deleted file mode 100644 index 3745d55e645..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.start_runtime.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(name) { - // [START notebooks_v1_generated_ManagedNotebookService_StartRuntime_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - */ - // const name = 'abc123' - /** - * Idempotent request UUID. - */ - // const requestId = 'abc123' - - // Imports the Notebooks library - const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new ManagedNotebookServiceClient(); - - async function callStartRuntime() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.startRuntime(request); - const [response] = await operation.promise(); - console.log(response); - } - - callStartRuntime(); - // [END notebooks_v1_generated_ManagedNotebookService_StartRuntime_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.stop_runtime.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.stop_runtime.js deleted file mode 100644 index 728bdd30463..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.stop_runtime.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(name) { - // [START notebooks_v1_generated_ManagedNotebookService_StopRuntime_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - */ - // const name = 'abc123' - /** - * Idempotent request UUID. - */ - // const requestId = 'abc123' - - // Imports the Notebooks library - const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new ManagedNotebookServiceClient(); - - async function callStopRuntime() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.stopRuntime(request); - const [response] = await operation.promise(); - console.log(response); - } - - callStopRuntime(); - // [END notebooks_v1_generated_ManagedNotebookService_StopRuntime_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.switch_runtime.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.switch_runtime.js deleted file mode 100644 index e50f396f885..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.switch_runtime.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(name) { - // [START notebooks_v1_generated_ManagedNotebookService_SwitchRuntime_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - */ - // const name = 'abc123' - /** - * machine type. - */ - // const machineType = 'abc123' - /** - * accelerator config. - */ - // const acceleratorConfig = {} - /** - * Idempotent request UUID. - */ - // const requestId = 'abc123' - - // Imports the Notebooks library - const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new ManagedNotebookServiceClient(); - - async function callSwitchRuntime() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.switchRuntime(request); - const [response] = await operation.promise(); - console.log(response); - } - - callSwitchRuntime(); - // [END notebooks_v1_generated_ManagedNotebookService_SwitchRuntime_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.update_runtime.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.update_runtime.js deleted file mode 100644 index 1d5e411c15a..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.update_runtime.js +++ /dev/null @@ -1,90 +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(runtime, updateMask) { - // [START notebooks_v1_generated_ManagedNotebookService_UpdateRuntime_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Runtime to be updated. - */ - // const runtime = {} - /** - * Required. Specifies the path, relative to `Runtime`, of - * the field to update. For example, to change the software configuration - * kernels, the `update_mask` parameter would be - * specified as `software_config.kernels`, - * and the `PATCH` request body would specify the new value, as follows: - * { - * "software_config":{ - * "kernels": { - * 'repository': - * 'gcr.io/deeplearning-platform-release/pytorch-gpu', 'tag': - * 'latest' }, - * } - * } - * Currently, only the following fields can be updated: - * - `software_config.kernels` - * - `software_config.post_startup_script` - * - `software_config.custom_gpu_driver_path` - * - `software_config.idle_shutdown` - * - `software_config.idle_shutdown_timeout` - * - `software_config.disable_terminal` - */ - // const updateMask = {} - /** - * Idempotent request UUID. - */ - // const requestId = 'abc123' - - // Imports the Notebooks library - const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new ManagedNotebookServiceClient(); - - async function callUpdateRuntime() { - // Construct request - const request = { - runtime, - updateMask, - }; - - // Run request - const [operation] = await notebooksClient.updateRuntime(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateRuntime(); - // [END notebooks_v1_generated_ManagedNotebookService_UpdateRuntime_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.upgrade_runtime.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.upgrade_runtime.js deleted file mode 100644 index 80093bc62cf..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/managed_notebook_service.upgrade_runtime.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(name) { - // [START notebooks_v1_generated_ManagedNotebookService_UpgradeRuntime_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - */ - // const name = 'abc123' - /** - * Idempotent request UUID. - */ - // const requestId = 'abc123' - - // Imports the Notebooks library - const {ManagedNotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new ManagedNotebookServiceClient(); - - async function callUpgradeRuntime() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.upgradeRuntime(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpgradeRuntime(); - // [END notebooks_v1_generated_ManagedNotebookService_UpgradeRuntime_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_environment.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_environment.js deleted file mode 100644 index 5508ef29a8d..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_environment.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, environmentId, environment) { - // [START notebooks_v1_generated_NotebookService_CreateEnvironment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: `projects/{project_id}/locations/{location}` - */ - // const parent = 'abc123' - /** - * Required. User-defined unique ID of this environment. The `environment_id` must - * be 1 to 63 characters long and contain only lowercase letters, - * numeric characters, and dashes. The first character must be a lowercase - * letter and the last character cannot be a dash. - */ - // const environmentId = 'abc123' - /** - * Required. The environment to be created. - */ - // const environment = {} - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callCreateEnvironment() { - // Construct request - const request = { - parent, - environmentId, - environment, - }; - - // Run request - const [operation] = await notebooksClient.createEnvironment(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateEnvironment(); - // [END notebooks_v1_generated_NotebookService_CreateEnvironment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_execution.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_execution.js deleted file mode 100644 index 6434cc9bd94..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_execution.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(parent, executionId, execution) { - // [START notebooks_v1_generated_NotebookService_CreateExecution_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - */ - // const parent = 'abc123' - /** - * Required. User-defined unique ID of this execution. - */ - // const executionId = 'abc123' - /** - * Required. The execution to be created. - */ - // const execution = {} - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callCreateExecution() { - // Construct request - const request = { - parent, - executionId, - execution, - }; - - // Run request - const [operation] = await notebooksClient.createExecution(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateExecution(); - // [END notebooks_v1_generated_NotebookService_CreateExecution_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_instance.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_instance.js deleted file mode 100644 index c59353d7f12..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_instance.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(parent, instanceId, instance) { - // [START notebooks_v1_generated_NotebookService_CreateInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - */ - // const parent = 'abc123' - /** - * Required. User-defined unique ID of this instance. - */ - // const instanceId = 'abc123' - /** - * Required. The instance to be created. - */ - // const instance = {} - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callCreateInstance() { - // Construct request - const request = { - parent, - instanceId, - instance, - }; - - // Run request - const [operation] = await notebooksClient.createInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateInstance(); - // [END notebooks_v1_generated_NotebookService_CreateInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_schedule.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_schedule.js deleted file mode 100644 index 8e52043dd40..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.create_schedule.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(parent, scheduleId, schedule) { - // [START notebooks_v1_generated_NotebookService_CreateSchedule_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - */ - // const parent = 'abc123' - /** - * Required. User-defined unique ID of this schedule. - */ - // const scheduleId = 'abc123' - /** - * Required. The schedule to be created. - */ - // const schedule = {} - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callCreateSchedule() { - // Construct request - const request = { - parent, - scheduleId, - schedule, - }; - - // Run request - const [operation] = await notebooksClient.createSchedule(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateSchedule(); - // [END notebooks_v1_generated_NotebookService_CreateSchedule_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_environment.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_environment.js deleted file mode 100644 index 899d01a5db7..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_environment.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 notebooks_v1_generated_NotebookService_DeleteEnvironment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/environments/{environment_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callDeleteEnvironment() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.deleteEnvironment(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteEnvironment(); - // [END notebooks_v1_generated_NotebookService_DeleteEnvironment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_execution.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_execution.js deleted file mode 100644 index 57c8e49f520..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_execution.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 notebooks_v1_generated_NotebookService_DeleteExecution_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/executions/{execution_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callDeleteExecution() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.deleteExecution(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteExecution(); - // [END notebooks_v1_generated_NotebookService_DeleteExecution_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_instance.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_instance.js deleted file mode 100644 index 7a828f3606f..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_instance.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 notebooks_v1_generated_NotebookService_DeleteInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callDeleteInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.deleteInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteInstance(); - // [END notebooks_v1_generated_NotebookService_DeleteInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_schedule.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_schedule.js deleted file mode 100644 index fcf20012a5d..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.delete_schedule.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 notebooks_v1_generated_NotebookService_DeleteSchedule_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/schedules/{schedule_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callDeleteSchedule() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.deleteSchedule(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteSchedule(); - // [END notebooks_v1_generated_NotebookService_DeleteSchedule_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.diagnose_instance.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.diagnose_instance.js deleted file mode 100644 index 67bfcb44975..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.diagnose_instance.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, diagnosticConfig) { - // [START notebooks_v1_generated_NotebookService_DiagnoseInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - /** - * Required. Defines flags that are used to run the diagnostic tool - */ - // const diagnosticConfig = {} - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callDiagnoseInstance() { - // Construct request - const request = { - name, - diagnosticConfig, - }; - - // Run request - const [operation] = await notebooksClient.diagnoseInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDiagnoseInstance(); - // [END notebooks_v1_generated_NotebookService_DiagnoseInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_environment.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_environment.js deleted file mode 100644 index a7ef2fedfb1..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_environment.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 notebooks_v1_generated_NotebookService_GetEnvironment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/environments/{environment_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callGetEnvironment() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await notebooksClient.getEnvironment(request); - console.log(response); - } - - callGetEnvironment(); - // [END notebooks_v1_generated_NotebookService_GetEnvironment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_execution.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_execution.js deleted file mode 100644 index 5e38f97f0eb..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_execution.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 notebooks_v1_generated_NotebookService_GetExecution_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/executions/{execution_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callGetExecution() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await notebooksClient.getExecution(request); - console.log(response); - } - - callGetExecution(); - // [END notebooks_v1_generated_NotebookService_GetExecution_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_instance.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_instance.js deleted file mode 100644 index 02effd56308..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_instance.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 notebooks_v1_generated_NotebookService_GetInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callGetInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await notebooksClient.getInstance(request); - console.log(response); - } - - callGetInstance(); - // [END notebooks_v1_generated_NotebookService_GetInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_instance_health.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_instance_health.js deleted file mode 100644 index e367e94aba7..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_instance_health.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 notebooks_v1_generated_NotebookService_GetInstanceHealth_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callGetInstanceHealth() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await notebooksClient.getInstanceHealth(request); - console.log(response); - } - - callGetInstanceHealth(); - // [END notebooks_v1_generated_NotebookService_GetInstanceHealth_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_schedule.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_schedule.js deleted file mode 100644 index 543e60e0a18..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.get_schedule.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 notebooks_v1_generated_NotebookService_GetSchedule_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/schedules/{schedule_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callGetSchedule() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await notebooksClient.getSchedule(request); - console.log(response); - } - - callGetSchedule(); - // [END notebooks_v1_generated_NotebookService_GetSchedule_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.is_instance_upgradeable.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.is_instance_upgradeable.js deleted file mode 100644 index d30fa51d3fd..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.is_instance_upgradeable.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(notebookInstance) { - // [START notebooks_v1_generated_NotebookService_IsInstanceUpgradeable_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const notebookInstance = 'abc123' - /** - * Optional. The optional UpgradeType. Setting this field will search for additional - * compute images to upgrade this instance. - */ - // const type = {} - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callIsInstanceUpgradeable() { - // Construct request - const request = { - notebookInstance, - }; - - // Run request - const response = await notebooksClient.isInstanceUpgradeable(request); - console.log(response); - } - - callIsInstanceUpgradeable(); - // [END notebooks_v1_generated_NotebookService_IsInstanceUpgradeable_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_environments.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_environments.js deleted file mode 100644 index 2d5dab68f11..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_environments.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) { - // [START notebooks_v1_generated_NotebookService_ListEnvironments_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: `projects/{project_id}/locations/{location}` - */ - // const parent = 'abc123' - /** - * Maximum return size of the list call. - */ - // const pageSize = 1234 - /** - * A previous returned page token that can be used to continue listing from - * the last result. - */ - // const pageToken = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callListEnvironments() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await notebooksClient.listEnvironmentsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListEnvironments(); - // [END notebooks_v1_generated_NotebookService_ListEnvironments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_executions.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_executions.js deleted file mode 100644 index 31ccc62092b..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_executions.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) { - // [START notebooks_v1_generated_NotebookService_ListExecutions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - */ - // const parent = 'abc123' - /** - * Maximum return size of the list call. - */ - // const pageSize = 1234 - /** - * A previous returned page token that can be used to continue listing - * from the last result. - */ - // const pageToken = 'abc123' - /** - * Filter applied to resulting executions. Currently only supports filtering - * executions by a specified `schedule_id`. - * Format: `schedule_id=` - */ - // const filter = 'abc123' - /** - * Sort by field. - */ - // const orderBy = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callListExecutions() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await notebooksClient.listExecutionsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListExecutions(); - // [END notebooks_v1_generated_NotebookService_ListExecutions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_instances.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_instances.js deleted file mode 100644 index 95716959568..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_instances.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(parent) { - // [START notebooks_v1_generated_NotebookService_ListInstances_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - */ - // const parent = 'abc123' - /** - * Maximum return size of the list call. - */ - // const pageSize = 1234 - /** - * A previous returned page token that can be used to continue listing - * from the last result. - */ - // const pageToken = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callListInstances() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await notebooksClient.listInstancesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListInstances(); - // [END notebooks_v1_generated_NotebookService_ListInstances_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_schedules.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_schedules.js deleted file mode 100644 index 663cefb6b9b..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.list_schedules.js +++ /dev/null @@ -1,81 +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 notebooks_v1_generated_NotebookService_ListSchedules_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - */ - // const parent = 'abc123' - /** - * Maximum return size of the list call. - */ - // const pageSize = 1234 - /** - * A previous returned page token that can be used to continue listing - * from the last result. - */ - // const pageToken = 'abc123' - /** - * Filter applied to resulting schedules. - */ - // const filter = 'abc123' - /** - * Field to order results by. - */ - // const orderBy = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callListSchedules() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await notebooksClient.listSchedulesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListSchedules(); - // [END notebooks_v1_generated_NotebookService_ListSchedules_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.register_instance.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.register_instance.js deleted file mode 100644 index a85bf3f93ab..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.register_instance.js +++ /dev/null @@ -1,71 +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, instanceId) { - // [START notebooks_v1_generated_NotebookService_RegisterInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - */ - // const parent = 'abc123' - /** - * Required. User defined unique ID of this instance. The `instance_id` must - * be 1 to 63 characters long and contain only lowercase letters, - * numeric characters, and dashes. The first character must be a lowercase - * letter and the last character cannot be a dash. - */ - // const instanceId = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callRegisterInstance() { - // Construct request - const request = { - parent, - instanceId, - }; - - // Run request - const [operation] = await notebooksClient.registerInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRegisterInstance(); - // [END notebooks_v1_generated_NotebookService_RegisterInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.report_instance_info.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.report_instance_info.js deleted file mode 100644 index bde15816407..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.report_instance_info.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(name, vmId) { - // [START notebooks_v1_generated_NotebookService_ReportInstanceInfo_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - /** - * Required. The VM hardware token for authenticating the VM. - * https://cloud.google.com/compute/docs/instances/verifying-instance-identity - */ - // const vmId = 'abc123' - /** - * The metadata reported to Notebooks API. This will be merged to the instance - * metadata store - */ - // const metadata = [1,2,3,4] - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callReportInstanceInfo() { - // Construct request - const request = { - name, - vmId, - }; - - // Run request - const [operation] = await notebooksClient.reportInstanceInfo(request); - const [response] = await operation.promise(); - console.log(response); - } - - callReportInstanceInfo(); - // [END notebooks_v1_generated_NotebookService_ReportInstanceInfo_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.reset_instance.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.reset_instance.js deleted file mode 100644 index bcc1ef34d20..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.reset_instance.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 notebooks_v1_generated_NotebookService_ResetInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callResetInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.resetInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callResetInstance(); - // [END notebooks_v1_generated_NotebookService_ResetInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.rollback_instance.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.rollback_instance.js deleted file mode 100644 index 963801eead1..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.rollback_instance.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(name, targetSnapshot) { - // [START notebooks_v1_generated_NotebookService_RollbackInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - /** - * Required. The snapshot for rollback. - * Example: `projects/test-project/global/snapshots/krwlzipynril`. - */ - // const targetSnapshot = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callRollbackInstance() { - // Construct request - const request = { - name, - targetSnapshot, - }; - - // Run request - const [operation] = await notebooksClient.rollbackInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRollbackInstance(); - // [END notebooks_v1_generated_NotebookService_RollbackInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_accelerator.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_accelerator.js deleted file mode 100644 index d0e42f8ebb3..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_accelerator.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(name, type, coreCount) { - // [START notebooks_v1_generated_NotebookService_SetInstanceAccelerator_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - /** - * Required. Type of this accelerator. - */ - // const type = {} - /** - * Required. Count of cores of this accelerator. Note that not all combinations - * of `type` and `core_count` are valid. Check GPUs on - * Compute Engine (https://cloud.google.com/compute/docs/gpus/#gpus-list) to - * find a valid combination. TPUs are not supported. - */ - // const coreCount = 1234 - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callSetInstanceAccelerator() { - // Construct request - const request = { - name, - type, - coreCount, - }; - - // Run request - const [operation] = await notebooksClient.setInstanceAccelerator(request); - const [response] = await operation.promise(); - console.log(response); - } - - callSetInstanceAccelerator(); - // [END notebooks_v1_generated_NotebookService_SetInstanceAccelerator_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_labels.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_labels.js deleted file mode 100644 index e3c35129fab..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_labels.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 notebooks_v1_generated_NotebookService_SetInstanceLabels_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - /** - * Labels to apply to this instance. - * These can be later modified by the setLabels method - */ - // const labels = [1,2,3,4] - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callSetInstanceLabels() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.setInstanceLabels(request); - const [response] = await operation.promise(); - console.log(response); - } - - callSetInstanceLabels(); - // [END notebooks_v1_generated_NotebookService_SetInstanceLabels_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_machine_type.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_machine_type.js deleted file mode 100644 index d2d37138214..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.set_instance_machine_type.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(name, machineType) { - // [START notebooks_v1_generated_NotebookService_SetInstanceMachineType_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - /** - * Required. The Compute Engine machine - * type (https://cloud.google.com/compute/docs/machine-types). - */ - // const machineType = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callSetInstanceMachineType() { - // Construct request - const request = { - name, - machineType, - }; - - // Run request - const [operation] = await notebooksClient.setInstanceMachineType(request); - const [response] = await operation.promise(); - console.log(response); - } - - callSetInstanceMachineType(); - // [END notebooks_v1_generated_NotebookService_SetInstanceMachineType_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.start_instance.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.start_instance.js deleted file mode 100644 index 627d0ad2a3f..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.start_instance.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 notebooks_v1_generated_NotebookService_StartInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callStartInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.startInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callStartInstance(); - // [END notebooks_v1_generated_NotebookService_StartInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.stop_instance.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.stop_instance.js deleted file mode 100644 index d8ed2784043..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.stop_instance.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 notebooks_v1_generated_NotebookService_StopInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callStopInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.stopInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callStopInstance(); - // [END notebooks_v1_generated_NotebookService_StopInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.trigger_schedule.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.trigger_schedule.js deleted file mode 100644 index 35135e288b0..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.trigger_schedule.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 notebooks_v1_generated_NotebookService_TriggerSchedule_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `parent=projects/{project_id}/locations/{location}/schedules/{schedule_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callTriggerSchedule() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.triggerSchedule(request); - const [response] = await operation.promise(); - console.log(response); - } - - callTriggerSchedule(); - // [END notebooks_v1_generated_NotebookService_TriggerSchedule_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_instance_config.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_instance_config.js deleted file mode 100644 index e326271d4c1..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_instance_config.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(name) { - // [START notebooks_v1_generated_NotebookService_UpdateInstanceConfig_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - /** - * The instance configurations to be updated. - */ - // const config = {} - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callUpdateInstanceConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.updateInstanceConfig(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateInstanceConfig(); - // [END notebooks_v1_generated_NotebookService_UpdateInstanceConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_instance_metadata_items.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_instance_metadata_items.js deleted file mode 100644 index 316c356ff8f..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_instance_metadata_items.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(name) { - // [START notebooks_v1_generated_NotebookService_UpdateInstanceMetadataItems_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - /** - * Metadata items to add/update for the instance. - */ - // const items = [1,2,3,4] - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callUpdateInstanceMetadataItems() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await notebooksClient.updateInstanceMetadataItems(request); - console.log(response); - } - - callUpdateInstanceMetadataItems(); - // [END notebooks_v1_generated_NotebookService_UpdateInstanceMetadataItems_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_shielded_instance_config.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_shielded_instance_config.js deleted file mode 100644 index 79a4789d1f2..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.update_shielded_instance_config.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(name) { - // [START notebooks_v1_generated_NotebookService_UpdateShieldedInstanceConfig_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - /** - * ShieldedInstance configuration to be updated. - */ - // const shieldedInstanceConfig = {} - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callUpdateShieldedInstanceConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.updateShieldedInstanceConfig(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateShieldedInstanceConfig(); - // [END notebooks_v1_generated_NotebookService_UpdateShieldedInstanceConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.upgrade_instance.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.upgrade_instance.js deleted file mode 100644 index 3dc2fe02e4f..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.upgrade_instance.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 notebooks_v1_generated_NotebookService_UpgradeInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - /** - * Optional. The optional UpgradeType. Setting this field will search for additional - * compute images to upgrade this instance. - */ - // const type = {} - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callUpgradeInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.upgradeInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpgradeInstance(); - // [END notebooks_v1_generated_NotebookService_UpgradeInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.upgrade_instance_internal.js b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.upgrade_instance_internal.js deleted file mode 100644 index c9b99adefa3..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/notebook_service.upgrade_instance_internal.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(name, vmId) { - // [START notebooks_v1_generated_NotebookService_UpgradeInstanceInternal_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - /** - * Required. The VM hardware token for authenticating the VM. - * https://cloud.google.com/compute/docs/instances/verifying-instance-identity - */ - // const vmId = 'abc123' - /** - * Optional. The optional UpgradeType. Setting this field will search for additional - * compute images to upgrade this instance. - */ - // const type = {} - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callUpgradeInstanceInternal() { - // Construct request - const request = { - name, - vmId, - }; - - // Run request - const [operation] = await notebooksClient.upgradeInstanceInternal(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpgradeInstanceInternal(); - // [END notebooks_v1_generated_NotebookService_UpgradeInstanceInternal_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/snippet_metadata_google.cloud.notebooks.v1.json b/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/snippet_metadata_google.cloud.notebooks.v1.json deleted file mode 100644 index 48fb0a043d9..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/samples/generated/v1/snippet_metadata_google.cloud.notebooks.v1.json +++ /dev/null @@ -1,2115 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-notebooks", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.notebooks.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "notebooks_v1_generated_ManagedNotebookService_ListRuntimes_async", - "title": "ManagedNotebookService listRuntimes Sample", - "origin": "API_DEFINITION", - "description": " Lists Runtimes in a given project and location.", - "canonical": true, - "file": "managed_notebook_service.list_runtimes.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListRuntimes", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.ListRuntimes", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.notebooks.v1.ListRuntimesResponse", - "client": { - "shortName": "ManagedNotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" - }, - "method": { - "shortName": "ListRuntimes", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.ListRuntimes", - "service": { - "shortName": "ManagedNotebookService", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_ManagedNotebookService_GetRuntime_async", - "title": "ManagedNotebookService getRuntime Sample", - "origin": "API_DEFINITION", - "description": " Gets details of a single Runtime. The location must be a regional endpoint rather than zonal.", - "canonical": true, - "file": "managed_notebook_service.get_runtime.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetRuntime", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.GetRuntime", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.notebooks.v1.Runtime", - "client": { - "shortName": "ManagedNotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" - }, - "method": { - "shortName": "GetRuntime", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.GetRuntime", - "service": { - "shortName": "ManagedNotebookService", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_ManagedNotebookService_CreateRuntime_async", - "title": "ManagedNotebookService createRuntime Sample", - "origin": "API_DEFINITION", - "description": " Creates a new Runtime in a given project and location.", - "canonical": true, - "file": "managed_notebook_service.create_runtime.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateRuntime", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.CreateRuntime", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "runtime_id", - "type": "TYPE_STRING" - }, - { - "name": "runtime", - "type": ".google.cloud.notebooks.v1.Runtime" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ManagedNotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" - }, - "method": { - "shortName": "CreateRuntime", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.CreateRuntime", - "service": { - "shortName": "ManagedNotebookService", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_ManagedNotebookService_UpdateRuntime_async", - "title": "ManagedNotebookService updateRuntime Sample", - "origin": "API_DEFINITION", - "description": " Update Notebook Runtime configuration.", - "canonical": true, - "file": "managed_notebook_service.update_runtime.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 82, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateRuntime", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.UpdateRuntime", - "async": true, - "parameters": [ - { - "name": "runtime", - "type": ".google.cloud.notebooks.v1.Runtime" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ManagedNotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" - }, - "method": { - "shortName": "UpdateRuntime", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.UpdateRuntime", - "service": { - "shortName": "ManagedNotebookService", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_ManagedNotebookService_DeleteRuntime_async", - "title": "ManagedNotebookService deleteRuntime Sample", - "origin": "API_DEFINITION", - "description": " Deletes a single Runtime.", - "canonical": true, - "file": "managed_notebook_service.delete_runtime.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteRuntime", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.DeleteRuntime", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ManagedNotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" - }, - "method": { - "shortName": "DeleteRuntime", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.DeleteRuntime", - "service": { - "shortName": "ManagedNotebookService", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_ManagedNotebookService_StartRuntime_async", - "title": "ManagedNotebookService startRuntime Sample", - "origin": "API_DEFINITION", - "description": " Starts a Managed Notebook Runtime. Perform \"Start\" on GPU instances; \"Resume\" on CPU instances See: https://cloud.google.com/compute/docs/instances/stop-start-instance https://cloud.google.com/compute/docs/instances/suspend-resume-instance", - "canonical": true, - "file": "managed_notebook_service.start_runtime.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "StartRuntime", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.StartRuntime", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ManagedNotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" - }, - "method": { - "shortName": "StartRuntime", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.StartRuntime", - "service": { - "shortName": "ManagedNotebookService", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_ManagedNotebookService_StopRuntime_async", - "title": "ManagedNotebookService stopRuntime Sample", - "origin": "API_DEFINITION", - "description": " Stops a Managed Notebook Runtime. Perform \"Stop\" on GPU instances; \"Suspend\" on CPU instances See: https://cloud.google.com/compute/docs/instances/stop-start-instance https://cloud.google.com/compute/docs/instances/suspend-resume-instance", - "canonical": true, - "file": "managed_notebook_service.stop_runtime.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "StopRuntime", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.StopRuntime", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ManagedNotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" - }, - "method": { - "shortName": "StopRuntime", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.StopRuntime", - "service": { - "shortName": "ManagedNotebookService", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_ManagedNotebookService_SwitchRuntime_async", - "title": "ManagedNotebookService switchRuntime Sample", - "origin": "API_DEFINITION", - "description": " Switch a Managed Notebook Runtime.", - "canonical": true, - "file": "managed_notebook_service.switch_runtime.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SwitchRuntime", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.SwitchRuntime", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "machine_type", - "type": "TYPE_STRING" - }, - { - "name": "accelerator_config", - "type": ".google.cloud.notebooks.v1.RuntimeAcceleratorConfig" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ManagedNotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" - }, - "method": { - "shortName": "SwitchRuntime", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.SwitchRuntime", - "service": { - "shortName": "ManagedNotebookService", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_ManagedNotebookService_ResetRuntime_async", - "title": "ManagedNotebookService resetRuntime Sample", - "origin": "API_DEFINITION", - "description": " Resets a Managed Notebook Runtime.", - "canonical": true, - "file": "managed_notebook_service.reset_runtime.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ResetRuntime", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.ResetRuntime", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ManagedNotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" - }, - "method": { - "shortName": "ResetRuntime", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.ResetRuntime", - "service": { - "shortName": "ManagedNotebookService", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_ManagedNotebookService_UpgradeRuntime_async", - "title": "ManagedNotebookService upgradeRuntime Sample", - "origin": "API_DEFINITION", - "description": " Upgrades a Managed Notebook Runtime to the latest version.", - "canonical": true, - "file": "managed_notebook_service.upgrade_runtime.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpgradeRuntime", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.UpgradeRuntime", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ManagedNotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" - }, - "method": { - "shortName": "UpgradeRuntime", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.UpgradeRuntime", - "service": { - "shortName": "ManagedNotebookService", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_ManagedNotebookService_ReportRuntimeEvent_async", - "title": "ManagedNotebookService reportRuntimeEvent Sample", - "origin": "API_DEFINITION", - "description": " Report and process a runtime event.", - "canonical": true, - "file": "managed_notebook_service.report_runtime_event.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ReportRuntimeEvent", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.ReportRuntimeEvent", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "vm_id", - "type": "TYPE_STRING" - }, - { - "name": "event", - "type": ".google.cloud.notebooks.v1.Event" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ManagedNotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" - }, - "method": { - "shortName": "ReportRuntimeEvent", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.ReportRuntimeEvent", - "service": { - "shortName": "ManagedNotebookService", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_ManagedNotebookService_RefreshRuntimeTokenInternal_async", - "title": "ManagedNotebookService refreshRuntimeTokenInternal Sample", - "origin": "API_DEFINITION", - "description": " Gets an access token for the consumer service account that the customer attached to the runtime. Only accessible from the tenant instance.", - "canonical": true, - "file": "managed_notebook_service.refresh_runtime_token_internal.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RefreshRuntimeTokenInternal", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.RefreshRuntimeTokenInternal", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "vm_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.notebooks.v1.RefreshRuntimeTokenInternalResponse", - "client": { - "shortName": "ManagedNotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" - }, - "method": { - "shortName": "RefreshRuntimeTokenInternal", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.RefreshRuntimeTokenInternal", - "service": { - "shortName": "ManagedNotebookService", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_ManagedNotebookService_DiagnoseRuntime_async", - "title": "ManagedNotebookService diagnoseRuntime Sample", - "origin": "API_DEFINITION", - "description": " Creates a Diagnostic File and runs Diagnostic Tool given a Runtime.", - "canonical": true, - "file": "managed_notebook_service.diagnose_runtime.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DiagnoseRuntime", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.DiagnoseRuntime", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "diagnostic_config", - "type": ".google.cloud.notebooks.v1.DiagnosticConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ManagedNotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookServiceClient" - }, - "method": { - "shortName": "DiagnoseRuntime", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.DiagnoseRuntime", - "service": { - "shortName": "ManagedNotebookService", - "fullName": "google.cloud.notebooks.v1.ManagedNotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_ListInstances_async", - "title": "ManagedNotebookService listInstances Sample", - "origin": "API_DEFINITION", - "description": " Lists instances in a given project and location.", - "canonical": true, - "file": "notebook_service.list_instances.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListInstances", - "fullName": "google.cloud.notebooks.v1.NotebookService.ListInstances", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.notebooks.v1.ListInstancesResponse", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "ListInstances", - "fullName": "google.cloud.notebooks.v1.NotebookService.ListInstances", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_GetInstance_async", - "title": "ManagedNotebookService getInstance Sample", - "origin": "API_DEFINITION", - "description": " Gets details of a single Instance.", - "canonical": true, - "file": "notebook_service.get_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetInstance", - "fullName": "google.cloud.notebooks.v1.NotebookService.GetInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.notebooks.v1.Instance", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "GetInstance", - "fullName": "google.cloud.notebooks.v1.NotebookService.GetInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_CreateInstance_async", - "title": "ManagedNotebookService createInstance Sample", - "origin": "API_DEFINITION", - "description": " Creates a new Instance in a given project and location.", - "canonical": true, - "file": "notebook_service.create_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateInstance", - "fullName": "google.cloud.notebooks.v1.NotebookService.CreateInstance", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "instance_id", - "type": "TYPE_STRING" - }, - { - "name": "instance", - "type": ".google.cloud.notebooks.v1.Instance" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "CreateInstance", - "fullName": "google.cloud.notebooks.v1.NotebookService.CreateInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_RegisterInstance_async", - "title": "ManagedNotebookService registerInstance Sample", - "origin": "API_DEFINITION", - "description": " Registers an existing legacy notebook instance to the Notebooks API server. Legacy instances are instances created with the legacy Compute Engine calls. They are not manageable by the Notebooks API out of the box. This call makes these instances manageable by the Notebooks API.", - "canonical": true, - "file": "notebook_service.register_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RegisterInstance", - "fullName": "google.cloud.notebooks.v1.NotebookService.RegisterInstance", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "instance_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "RegisterInstance", - "fullName": "google.cloud.notebooks.v1.NotebookService.RegisterInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_SetInstanceAccelerator_async", - "title": "ManagedNotebookService setInstanceAccelerator Sample", - "origin": "API_DEFINITION", - "description": " Updates the guest accelerators of a single Instance.", - "canonical": true, - "file": "notebook_service.set_instance_accelerator.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetInstanceAccelerator", - "fullName": "google.cloud.notebooks.v1.NotebookService.SetInstanceAccelerator", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "type", - "type": ".google.cloud.notebooks.v1.Instance.AcceleratorType" - }, - { - "name": "core_count", - "type": "TYPE_INT64" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "SetInstanceAccelerator", - "fullName": "google.cloud.notebooks.v1.NotebookService.SetInstanceAccelerator", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_SetInstanceMachineType_async", - "title": "ManagedNotebookService setInstanceMachineType Sample", - "origin": "API_DEFINITION", - "description": " Updates the machine type of a single Instance.", - "canonical": true, - "file": "notebook_service.set_instance_machine_type.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetInstanceMachineType", - "fullName": "google.cloud.notebooks.v1.NotebookService.SetInstanceMachineType", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "machine_type", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "SetInstanceMachineType", - "fullName": "google.cloud.notebooks.v1.NotebookService.SetInstanceMachineType", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_UpdateInstanceConfig_async", - "title": "ManagedNotebookService updateInstanceConfig Sample", - "origin": "API_DEFINITION", - "description": " Update Notebook Instance configurations.", - "canonical": true, - "file": "notebook_service.update_instance_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateInstanceConfig", - "fullName": "google.cloud.notebooks.v1.NotebookService.UpdateInstanceConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "config", - "type": ".google.cloud.notebooks.v1.InstanceConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "UpdateInstanceConfig", - "fullName": "google.cloud.notebooks.v1.NotebookService.UpdateInstanceConfig", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_UpdateShieldedInstanceConfig_async", - "title": "ManagedNotebookService updateShieldedInstanceConfig Sample", - "origin": "API_DEFINITION", - "description": " Updates the Shielded instance configuration of a single Instance.", - "canonical": true, - "file": "notebook_service.update_shielded_instance_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateShieldedInstanceConfig", - "fullName": "google.cloud.notebooks.v1.NotebookService.UpdateShieldedInstanceConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "shielded_instance_config", - "type": ".google.cloud.notebooks.v1.Instance.ShieldedInstanceConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "UpdateShieldedInstanceConfig", - "fullName": "google.cloud.notebooks.v1.NotebookService.UpdateShieldedInstanceConfig", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_SetInstanceLabels_async", - "title": "ManagedNotebookService setInstanceLabels Sample", - "origin": "API_DEFINITION", - "description": " Replaces all the labels of an Instance.", - "canonical": true, - "file": "notebook_service.set_instance_labels.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetInstanceLabels", - "fullName": "google.cloud.notebooks.v1.NotebookService.SetInstanceLabels", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "labels", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "SetInstanceLabels", - "fullName": "google.cloud.notebooks.v1.NotebookService.SetInstanceLabels", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_UpdateInstanceMetadataItems_async", - "title": "ManagedNotebookService updateInstanceMetadataItems Sample", - "origin": "API_DEFINITION", - "description": " Add/update metadata items for an instance.", - "canonical": true, - "file": "notebook_service.update_instance_metadata_items.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateInstanceMetadataItems", - "fullName": "google.cloud.notebooks.v1.NotebookService.UpdateInstanceMetadataItems", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "items", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.notebooks.v1.UpdateInstanceMetadataItemsResponse", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "UpdateInstanceMetadataItems", - "fullName": "google.cloud.notebooks.v1.NotebookService.UpdateInstanceMetadataItems", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_DeleteInstance_async", - "title": "ManagedNotebookService deleteInstance Sample", - "origin": "API_DEFINITION", - "description": " Deletes a single Instance.", - "canonical": true, - "file": "notebook_service.delete_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteInstance", - "fullName": "google.cloud.notebooks.v1.NotebookService.DeleteInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "DeleteInstance", - "fullName": "google.cloud.notebooks.v1.NotebookService.DeleteInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_StartInstance_async", - "title": "ManagedNotebookService startInstance Sample", - "origin": "API_DEFINITION", - "description": " Starts a notebook instance.", - "canonical": true, - "file": "notebook_service.start_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "StartInstance", - "fullName": "google.cloud.notebooks.v1.NotebookService.StartInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "StartInstance", - "fullName": "google.cloud.notebooks.v1.NotebookService.StartInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_StopInstance_async", - "title": "ManagedNotebookService stopInstance Sample", - "origin": "API_DEFINITION", - "description": " Stops a notebook instance.", - "canonical": true, - "file": "notebook_service.stop_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "StopInstance", - "fullName": "google.cloud.notebooks.v1.NotebookService.StopInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "StopInstance", - "fullName": "google.cloud.notebooks.v1.NotebookService.StopInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_ResetInstance_async", - "title": "ManagedNotebookService resetInstance Sample", - "origin": "API_DEFINITION", - "description": " Resets a notebook instance.", - "canonical": true, - "file": "notebook_service.reset_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ResetInstance", - "fullName": "google.cloud.notebooks.v1.NotebookService.ResetInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "ResetInstance", - "fullName": "google.cloud.notebooks.v1.NotebookService.ResetInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_ReportInstanceInfo_async", - "title": "ManagedNotebookService reportInstanceInfo Sample", - "origin": "API_DEFINITION", - "description": " Allows notebook instances to report their latest instance information to the Notebooks API server. The server will merge the reported information to the instance metadata store. Do not use this method directly.", - "canonical": true, - "file": "notebook_service.report_instance_info.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ReportInstanceInfo", - "fullName": "google.cloud.notebooks.v1.NotebookService.ReportInstanceInfo", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "vm_id", - "type": "TYPE_STRING" - }, - { - "name": "metadata", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "ReportInstanceInfo", - "fullName": "google.cloud.notebooks.v1.NotebookService.ReportInstanceInfo", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_IsInstanceUpgradeable_async", - "title": "ManagedNotebookService isInstanceUpgradeable Sample", - "origin": "API_DEFINITION", - "description": " Check if a notebook instance is upgradable.", - "canonical": true, - "file": "notebook_service.is_instance_upgradeable.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "IsInstanceUpgradeable", - "fullName": "google.cloud.notebooks.v1.NotebookService.IsInstanceUpgradeable", - "async": true, - "parameters": [ - { - "name": "notebook_instance", - "type": "TYPE_STRING" - }, - { - "name": "type", - "type": ".google.cloud.notebooks.v1.UpgradeType" - } - ], - "resultType": ".google.cloud.notebooks.v1.IsInstanceUpgradeableResponse", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "IsInstanceUpgradeable", - "fullName": "google.cloud.notebooks.v1.NotebookService.IsInstanceUpgradeable", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_GetInstanceHealth_async", - "title": "ManagedNotebookService getInstanceHealth Sample", - "origin": "API_DEFINITION", - "description": " Check if a notebook instance is healthy.", - "canonical": true, - "file": "notebook_service.get_instance_health.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetInstanceHealth", - "fullName": "google.cloud.notebooks.v1.NotebookService.GetInstanceHealth", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.notebooks.v1.GetInstanceHealthResponse", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "GetInstanceHealth", - "fullName": "google.cloud.notebooks.v1.NotebookService.GetInstanceHealth", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_UpgradeInstance_async", - "title": "ManagedNotebookService upgradeInstance Sample", - "origin": "API_DEFINITION", - "description": " Upgrades a notebook instance to the latest version.", - "canonical": true, - "file": "notebook_service.upgrade_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpgradeInstance", - "fullName": "google.cloud.notebooks.v1.NotebookService.UpgradeInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "type", - "type": ".google.cloud.notebooks.v1.UpgradeType" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "UpgradeInstance", - "fullName": "google.cloud.notebooks.v1.NotebookService.UpgradeInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_RollbackInstance_async", - "title": "ManagedNotebookService rollbackInstance Sample", - "origin": "API_DEFINITION", - "description": " Rollbacks a notebook instance to the previous version.", - "canonical": true, - "file": "notebook_service.rollback_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RollbackInstance", - "fullName": "google.cloud.notebooks.v1.NotebookService.RollbackInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "target_snapshot", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "RollbackInstance", - "fullName": "google.cloud.notebooks.v1.NotebookService.RollbackInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_DiagnoseInstance_async", - "title": "ManagedNotebookService diagnoseInstance Sample", - "origin": "API_DEFINITION", - "description": " Creates a Diagnostic File and runs Diagnostic Tool given an Instance.", - "canonical": true, - "file": "notebook_service.diagnose_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DiagnoseInstance", - "fullName": "google.cloud.notebooks.v1.NotebookService.DiagnoseInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "diagnostic_config", - "type": ".google.cloud.notebooks.v1.DiagnosticConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "DiagnoseInstance", - "fullName": "google.cloud.notebooks.v1.NotebookService.DiagnoseInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_UpgradeInstanceInternal_async", - "title": "ManagedNotebookService upgradeInstanceInternal Sample", - "origin": "API_DEFINITION", - "description": " Allows notebook instances to call this endpoint to upgrade themselves. Do not use this method directly.", - "canonical": true, - "file": "notebook_service.upgrade_instance_internal.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpgradeInstanceInternal", - "fullName": "google.cloud.notebooks.v1.NotebookService.UpgradeInstanceInternal", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "vm_id", - "type": "TYPE_STRING" - }, - { - "name": "type", - "type": ".google.cloud.notebooks.v1.UpgradeType" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "UpgradeInstanceInternal", - "fullName": "google.cloud.notebooks.v1.NotebookService.UpgradeInstanceInternal", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_ListEnvironments_async", - "title": "ManagedNotebookService listEnvironments Sample", - "origin": "API_DEFINITION", - "description": " Lists environments in a project.", - "canonical": true, - "file": "notebook_service.list_environments.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListEnvironments", - "fullName": "google.cloud.notebooks.v1.NotebookService.ListEnvironments", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.notebooks.v1.ListEnvironmentsResponse", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "ListEnvironments", - "fullName": "google.cloud.notebooks.v1.NotebookService.ListEnvironments", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_GetEnvironment_async", - "title": "ManagedNotebookService getEnvironment Sample", - "origin": "API_DEFINITION", - "description": " Gets details of a single Environment.", - "canonical": true, - "file": "notebook_service.get_environment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetEnvironment", - "fullName": "google.cloud.notebooks.v1.NotebookService.GetEnvironment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.notebooks.v1.Environment", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "GetEnvironment", - "fullName": "google.cloud.notebooks.v1.NotebookService.GetEnvironment", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_CreateEnvironment_async", - "title": "ManagedNotebookService createEnvironment Sample", - "origin": "API_DEFINITION", - "description": " Creates a new Environment.", - "canonical": true, - "file": "notebook_service.create_environment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateEnvironment", - "fullName": "google.cloud.notebooks.v1.NotebookService.CreateEnvironment", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "environment_id", - "type": "TYPE_STRING" - }, - { - "name": "environment", - "type": ".google.cloud.notebooks.v1.Environment" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "CreateEnvironment", - "fullName": "google.cloud.notebooks.v1.NotebookService.CreateEnvironment", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_DeleteEnvironment_async", - "title": "ManagedNotebookService deleteEnvironment Sample", - "origin": "API_DEFINITION", - "description": " Deletes a single Environment.", - "canonical": true, - "file": "notebook_service.delete_environment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteEnvironment", - "fullName": "google.cloud.notebooks.v1.NotebookService.DeleteEnvironment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "DeleteEnvironment", - "fullName": "google.cloud.notebooks.v1.NotebookService.DeleteEnvironment", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_ListSchedules_async", - "title": "ManagedNotebookService listSchedules Sample", - "origin": "API_DEFINITION", - "description": " Lists schedules in a given project and location.", - "canonical": true, - "file": "notebook_service.list_schedules.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 73, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListSchedules", - "fullName": "google.cloud.notebooks.v1.NotebookService.ListSchedules", - "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": "order_by", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.notebooks.v1.ListSchedulesResponse", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "ListSchedules", - "fullName": "google.cloud.notebooks.v1.NotebookService.ListSchedules", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_GetSchedule_async", - "title": "ManagedNotebookService getSchedule Sample", - "origin": "API_DEFINITION", - "description": " Gets details of schedule", - "canonical": true, - "file": "notebook_service.get_schedule.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetSchedule", - "fullName": "google.cloud.notebooks.v1.NotebookService.GetSchedule", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.notebooks.v1.Schedule", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "GetSchedule", - "fullName": "google.cloud.notebooks.v1.NotebookService.GetSchedule", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_DeleteSchedule_async", - "title": "ManagedNotebookService deleteSchedule Sample", - "origin": "API_DEFINITION", - "description": " Deletes schedule and all underlying jobs", - "canonical": true, - "file": "notebook_service.delete_schedule.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteSchedule", - "fullName": "google.cloud.notebooks.v1.NotebookService.DeleteSchedule", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "DeleteSchedule", - "fullName": "google.cloud.notebooks.v1.NotebookService.DeleteSchedule", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_CreateSchedule_async", - "title": "ManagedNotebookService createSchedule Sample", - "origin": "API_DEFINITION", - "description": " Creates a new Scheduled Notebook in a given project and location.", - "canonical": true, - "file": "notebook_service.create_schedule.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateSchedule", - "fullName": "google.cloud.notebooks.v1.NotebookService.CreateSchedule", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "schedule_id", - "type": "TYPE_STRING" - }, - { - "name": "schedule", - "type": ".google.cloud.notebooks.v1.Schedule" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "CreateSchedule", - "fullName": "google.cloud.notebooks.v1.NotebookService.CreateSchedule", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_TriggerSchedule_async", - "title": "ManagedNotebookService triggerSchedule Sample", - "origin": "API_DEFINITION", - "description": " Triggers execution of an existing schedule.", - "canonical": true, - "file": "notebook_service.trigger_schedule.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TriggerSchedule", - "fullName": "google.cloud.notebooks.v1.NotebookService.TriggerSchedule", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "TriggerSchedule", - "fullName": "google.cloud.notebooks.v1.NotebookService.TriggerSchedule", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_ListExecutions_async", - "title": "ManagedNotebookService listExecutions Sample", - "origin": "API_DEFINITION", - "description": " Lists executions in a given project and location", - "canonical": true, - "file": "notebook_service.list_executions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 75, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListExecutions", - "fullName": "google.cloud.notebooks.v1.NotebookService.ListExecutions", - "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": "order_by", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.notebooks.v1.ListExecutionsResponse", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "ListExecutions", - "fullName": "google.cloud.notebooks.v1.NotebookService.ListExecutions", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_GetExecution_async", - "title": "ManagedNotebookService getExecution Sample", - "origin": "API_DEFINITION", - "description": " Gets details of executions", - "canonical": true, - "file": "notebook_service.get_execution.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetExecution", - "fullName": "google.cloud.notebooks.v1.NotebookService.GetExecution", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.notebooks.v1.Execution", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "GetExecution", - "fullName": "google.cloud.notebooks.v1.NotebookService.GetExecution", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_DeleteExecution_async", - "title": "ManagedNotebookService deleteExecution Sample", - "origin": "API_DEFINITION", - "description": " Deletes execution", - "canonical": true, - "file": "notebook_service.delete_execution.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteExecution", - "fullName": "google.cloud.notebooks.v1.NotebookService.DeleteExecution", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "DeleteExecution", - "fullName": "google.cloud.notebooks.v1.NotebookService.DeleteExecution", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1_generated_NotebookService_CreateExecution_async", - "title": "ManagedNotebookService createExecution Sample", - "origin": "API_DEFINITION", - "description": " Creates a new Execution in a given project and location.", - "canonical": true, - "file": "notebook_service.create_execution.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateExecution", - "fullName": "google.cloud.notebooks.v1.NotebookService.CreateExecution", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "execution_id", - "type": "TYPE_STRING" - }, - { - "name": "execution", - "type": ".google.cloud.notebooks.v1.Execution" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1.NotebookServiceClient" - }, - "method": { - "shortName": "CreateExecution", - "fullName": "google.cloud.notebooks.v1.NotebookService.CreateExecution", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1.NotebookService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/src/index.ts b/owl-bot-staging/google-cloud-notebooks/v1/src/index.ts deleted file mode 100644 index c7a2a16c438..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/src/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. ** - -import * as v1 from './v1'; -const ManagedNotebookServiceClient = v1.ManagedNotebookServiceClient; -type ManagedNotebookServiceClient = v1.ManagedNotebookServiceClient; -const NotebookServiceClient = v1.NotebookServiceClient; -type NotebookServiceClient = v1.NotebookServiceClient; -export {v1, ManagedNotebookServiceClient, NotebookServiceClient}; -export default {v1, ManagedNotebookServiceClient, NotebookServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/gapic_metadata.json deleted file mode 100644 index f6aa197ee97..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,527 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.notebooks.v1", - "libraryPackage": "@google-cloud/notebooks", - "services": { - "ManagedNotebookService": { - "clients": { - "grpc": { - "libraryClient": "ManagedNotebookServiceClient", - "rpcs": { - "GetRuntime": { - "methods": [ - "getRuntime" - ] - }, - "RefreshRuntimeTokenInternal": { - "methods": [ - "refreshRuntimeTokenInternal" - ] - }, - "CreateRuntime": { - "methods": [ - "createRuntime" - ] - }, - "UpdateRuntime": { - "methods": [ - "updateRuntime" - ] - }, - "DeleteRuntime": { - "methods": [ - "deleteRuntime" - ] - }, - "StartRuntime": { - "methods": [ - "startRuntime" - ] - }, - "StopRuntime": { - "methods": [ - "stopRuntime" - ] - }, - "SwitchRuntime": { - "methods": [ - "switchRuntime" - ] - }, - "ResetRuntime": { - "methods": [ - "resetRuntime" - ] - }, - "UpgradeRuntime": { - "methods": [ - "upgradeRuntime" - ] - }, - "ReportRuntimeEvent": { - "methods": [ - "reportRuntimeEvent" - ] - }, - "DiagnoseRuntime": { - "methods": [ - "diagnoseRuntime" - ] - }, - "ListRuntimes": { - "methods": [ - "listRuntimes", - "listRuntimesStream", - "listRuntimesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ManagedNotebookServiceClient", - "rpcs": { - "GetRuntime": { - "methods": [ - "getRuntime" - ] - }, - "RefreshRuntimeTokenInternal": { - "methods": [ - "refreshRuntimeTokenInternal" - ] - }, - "CreateRuntime": { - "methods": [ - "createRuntime" - ] - }, - "UpdateRuntime": { - "methods": [ - "updateRuntime" - ] - }, - "DeleteRuntime": { - "methods": [ - "deleteRuntime" - ] - }, - "StartRuntime": { - "methods": [ - "startRuntime" - ] - }, - "StopRuntime": { - "methods": [ - "stopRuntime" - ] - }, - "SwitchRuntime": { - "methods": [ - "switchRuntime" - ] - }, - "ResetRuntime": { - "methods": [ - "resetRuntime" - ] - }, - "UpgradeRuntime": { - "methods": [ - "upgradeRuntime" - ] - }, - "ReportRuntimeEvent": { - "methods": [ - "reportRuntimeEvent" - ] - }, - "DiagnoseRuntime": { - "methods": [ - "diagnoseRuntime" - ] - }, - "ListRuntimes": { - "methods": [ - "listRuntimes", - "listRuntimesStream", - "listRuntimesAsync" - ] - } - } - } - } - }, - "NotebookService": { - "clients": { - "grpc": { - "libraryClient": "NotebookServiceClient", - "rpcs": { - "GetInstance": { - "methods": [ - "getInstance" - ] - }, - "UpdateInstanceMetadataItems": { - "methods": [ - "updateInstanceMetadataItems" - ] - }, - "IsInstanceUpgradeable": { - "methods": [ - "isInstanceUpgradeable" - ] - }, - "GetInstanceHealth": { - "methods": [ - "getInstanceHealth" - ] - }, - "GetEnvironment": { - "methods": [ - "getEnvironment" - ] - }, - "GetSchedule": { - "methods": [ - "getSchedule" - ] - }, - "GetExecution": { - "methods": [ - "getExecution" - ] - }, - "CreateInstance": { - "methods": [ - "createInstance" - ] - }, - "RegisterInstance": { - "methods": [ - "registerInstance" - ] - }, - "SetInstanceAccelerator": { - "methods": [ - "setInstanceAccelerator" - ] - }, - "SetInstanceMachineType": { - "methods": [ - "setInstanceMachineType" - ] - }, - "UpdateInstanceConfig": { - "methods": [ - "updateInstanceConfig" - ] - }, - "UpdateShieldedInstanceConfig": { - "methods": [ - "updateShieldedInstanceConfig" - ] - }, - "SetInstanceLabels": { - "methods": [ - "setInstanceLabels" - ] - }, - "DeleteInstance": { - "methods": [ - "deleteInstance" - ] - }, - "StartInstance": { - "methods": [ - "startInstance" - ] - }, - "StopInstance": { - "methods": [ - "stopInstance" - ] - }, - "ResetInstance": { - "methods": [ - "resetInstance" - ] - }, - "ReportInstanceInfo": { - "methods": [ - "reportInstanceInfo" - ] - }, - "UpgradeInstance": { - "methods": [ - "upgradeInstance" - ] - }, - "RollbackInstance": { - "methods": [ - "rollbackInstance" - ] - }, - "DiagnoseInstance": { - "methods": [ - "diagnoseInstance" - ] - }, - "UpgradeInstanceInternal": { - "methods": [ - "upgradeInstanceInternal" - ] - }, - "CreateEnvironment": { - "methods": [ - "createEnvironment" - ] - }, - "DeleteEnvironment": { - "methods": [ - "deleteEnvironment" - ] - }, - "DeleteSchedule": { - "methods": [ - "deleteSchedule" - ] - }, - "CreateSchedule": { - "methods": [ - "createSchedule" - ] - }, - "TriggerSchedule": { - "methods": [ - "triggerSchedule" - ] - }, - "DeleteExecution": { - "methods": [ - "deleteExecution" - ] - }, - "CreateExecution": { - "methods": [ - "createExecution" - ] - }, - "ListInstances": { - "methods": [ - "listInstances", - "listInstancesStream", - "listInstancesAsync" - ] - }, - "ListEnvironments": { - "methods": [ - "listEnvironments", - "listEnvironmentsStream", - "listEnvironmentsAsync" - ] - }, - "ListSchedules": { - "methods": [ - "listSchedules", - "listSchedulesStream", - "listSchedulesAsync" - ] - }, - "ListExecutions": { - "methods": [ - "listExecutions", - "listExecutionsStream", - "listExecutionsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "NotebookServiceClient", - "rpcs": { - "GetInstance": { - "methods": [ - "getInstance" - ] - }, - "UpdateInstanceMetadataItems": { - "methods": [ - "updateInstanceMetadataItems" - ] - }, - "IsInstanceUpgradeable": { - "methods": [ - "isInstanceUpgradeable" - ] - }, - "GetInstanceHealth": { - "methods": [ - "getInstanceHealth" - ] - }, - "GetEnvironment": { - "methods": [ - "getEnvironment" - ] - }, - "GetSchedule": { - "methods": [ - "getSchedule" - ] - }, - "GetExecution": { - "methods": [ - "getExecution" - ] - }, - "CreateInstance": { - "methods": [ - "createInstance" - ] - }, - "RegisterInstance": { - "methods": [ - "registerInstance" - ] - }, - "SetInstanceAccelerator": { - "methods": [ - "setInstanceAccelerator" - ] - }, - "SetInstanceMachineType": { - "methods": [ - "setInstanceMachineType" - ] - }, - "UpdateInstanceConfig": { - "methods": [ - "updateInstanceConfig" - ] - }, - "UpdateShieldedInstanceConfig": { - "methods": [ - "updateShieldedInstanceConfig" - ] - }, - "SetInstanceLabels": { - "methods": [ - "setInstanceLabels" - ] - }, - "DeleteInstance": { - "methods": [ - "deleteInstance" - ] - }, - "StartInstance": { - "methods": [ - "startInstance" - ] - }, - "StopInstance": { - "methods": [ - "stopInstance" - ] - }, - "ResetInstance": { - "methods": [ - "resetInstance" - ] - }, - "ReportInstanceInfo": { - "methods": [ - "reportInstanceInfo" - ] - }, - "UpgradeInstance": { - "methods": [ - "upgradeInstance" - ] - }, - "RollbackInstance": { - "methods": [ - "rollbackInstance" - ] - }, - "DiagnoseInstance": { - "methods": [ - "diagnoseInstance" - ] - }, - "UpgradeInstanceInternal": { - "methods": [ - "upgradeInstanceInternal" - ] - }, - "CreateEnvironment": { - "methods": [ - "createEnvironment" - ] - }, - "DeleteEnvironment": { - "methods": [ - "deleteEnvironment" - ] - }, - "DeleteSchedule": { - "methods": [ - "deleteSchedule" - ] - }, - "CreateSchedule": { - "methods": [ - "createSchedule" - ] - }, - "TriggerSchedule": { - "methods": [ - "triggerSchedule" - ] - }, - "DeleteExecution": { - "methods": [ - "deleteExecution" - ] - }, - "CreateExecution": { - "methods": [ - "createExecution" - ] - }, - "ListInstances": { - "methods": [ - "listInstances", - "listInstancesStream", - "listInstancesAsync" - ] - }, - "ListEnvironments": { - "methods": [ - "listEnvironments", - "listEnvironmentsStream", - "listEnvironmentsAsync" - ] - }, - "ListSchedules": { - "methods": [ - "listSchedules", - "listSchedulesStream", - "listSchedulesAsync" - ] - }, - "ListExecutions": { - "methods": [ - "listExecutions", - "listExecutionsStream", - "listExecutionsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/index.ts deleted file mode 100644 index 9ee9b360808..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/index.ts +++ /dev/null @@ -1,20 +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 {ManagedNotebookServiceClient} from './managed_notebook_service_client'; -export {NotebookServiceClient} from './notebook_service_client'; diff --git a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_client.ts b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_client.ts deleted file mode 100644 index 66a350c542c..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_client.ts +++ /dev/null @@ -1,2414 +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, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/managed_notebook_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './managed_notebook_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * API v1 service for Managed Notebooks. - * @class - * @memberof v1 - */ -export class ManagedNotebookServiceClient { - 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}; - iamClient: IamClient; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - managedNotebookServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ManagedNotebookServiceClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 ManagedNotebookServiceClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ManagedNotebookServiceClient; - 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.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - - 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 { - 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 = { - environmentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/environments/{environment}' - ), - executionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/location/{location}/executions/{execution}' - ), - instancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/instances/{instance}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - runtimePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/runtimes/{runtime}' - ), - schedulePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/location/{location}/schedules/{schedule}' - ), - }; - - // 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 = { - listRuntimes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'runtimes') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/*/instances/*}:getIamPolicy',additional_bindings: [{get: '/v1/{resource=projects/*/locations/*/runtimes/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/*/instances/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/runtimes/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/*/instances/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/runtimes/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createRuntimeResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; - const createRuntimeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const updateRuntimeResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; - const updateRuntimeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const deleteRuntimeResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteRuntimeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const startRuntimeResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; - const startRuntimeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const stopRuntimeResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; - const stopRuntimeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const switchRuntimeResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; - const switchRuntimeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const resetRuntimeResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; - const resetRuntimeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const upgradeRuntimeResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; - const upgradeRuntimeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const reportRuntimeEventResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; - const reportRuntimeEventMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const diagnoseRuntimeResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; - const diagnoseRuntimeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createRuntime: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createRuntimeResponse.decode.bind(createRuntimeResponse), - createRuntimeMetadata.decode.bind(createRuntimeMetadata)), - updateRuntime: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateRuntimeResponse.decode.bind(updateRuntimeResponse), - updateRuntimeMetadata.decode.bind(updateRuntimeMetadata)), - deleteRuntime: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteRuntimeResponse.decode.bind(deleteRuntimeResponse), - deleteRuntimeMetadata.decode.bind(deleteRuntimeMetadata)), - startRuntime: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - startRuntimeResponse.decode.bind(startRuntimeResponse), - startRuntimeMetadata.decode.bind(startRuntimeMetadata)), - stopRuntime: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - stopRuntimeResponse.decode.bind(stopRuntimeResponse), - stopRuntimeMetadata.decode.bind(stopRuntimeMetadata)), - switchRuntime: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - switchRuntimeResponse.decode.bind(switchRuntimeResponse), - switchRuntimeMetadata.decode.bind(switchRuntimeMetadata)), - resetRuntime: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - resetRuntimeResponse.decode.bind(resetRuntimeResponse), - resetRuntimeMetadata.decode.bind(resetRuntimeMetadata)), - upgradeRuntime: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - upgradeRuntimeResponse.decode.bind(upgradeRuntimeResponse), - upgradeRuntimeMetadata.decode.bind(upgradeRuntimeMetadata)), - reportRuntimeEvent: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - reportRuntimeEventResponse.decode.bind(reportRuntimeEventResponse), - reportRuntimeEventMetadata.decode.bind(reportRuntimeEventMetadata)), - diagnoseRuntime: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - diagnoseRuntimeResponse.decode.bind(diagnoseRuntimeResponse), - diagnoseRuntimeMetadata.decode.bind(diagnoseRuntimeMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.notebooks.v1.ManagedNotebookService', 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.managedNotebookServiceStub) { - return this.managedNotebookServiceStub; - } - - // Put together the "service stub" for - // google.cloud.notebooks.v1.ManagedNotebookService. - this.managedNotebookServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.notebooks.v1.ManagedNotebookService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.notebooks.v1.ManagedNotebookService, - 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 managedNotebookServiceStubMethods = - ['listRuntimes', 'getRuntime', 'createRuntime', 'updateRuntime', 'deleteRuntime', 'startRuntime', 'stopRuntime', 'switchRuntime', 'resetRuntime', 'upgradeRuntime', 'reportRuntimeEvent', 'refreshRuntimeTokenInternal', 'diagnoseRuntime']; - for (const methodName of managedNotebookServiceStubMethods) { - const callPromise = this.managedNotebookServiceStub.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.managedNotebookServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'notebooks.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 'notebooks.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 details of a single Runtime. The location must be a regional endpoint - * rather than zonal. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1.Runtime|Runtime}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.get_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_GetRuntime_async - */ - getRuntime( - request?: protos.google.cloud.notebooks.v1.IGetRuntimeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IRuntime, - protos.google.cloud.notebooks.v1.IGetRuntimeRequest|undefined, {}|undefined - ]>; - getRuntime( - request: protos.google.cloud.notebooks.v1.IGetRuntimeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1.IRuntime, - protos.google.cloud.notebooks.v1.IGetRuntimeRequest|null|undefined, - {}|null|undefined>): void; - getRuntime( - request: protos.google.cloud.notebooks.v1.IGetRuntimeRequest, - callback: Callback< - protos.google.cloud.notebooks.v1.IRuntime, - protos.google.cloud.notebooks.v1.IGetRuntimeRequest|null|undefined, - {}|null|undefined>): void; - getRuntime( - request?: protos.google.cloud.notebooks.v1.IGetRuntimeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1.IRuntime, - protos.google.cloud.notebooks.v1.IGetRuntimeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.notebooks.v1.IRuntime, - protos.google.cloud.notebooks.v1.IGetRuntimeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1.IRuntime, - protos.google.cloud.notebooks.v1.IGetRuntimeRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getRuntime(request, options, callback); - } -/** - * Gets an access token for the consumer service account that the customer - * attached to the runtime. Only accessible from the tenant instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - * @param {string} request.vmId - * Required. The VM hardware token for authenticating the VM. - * https://cloud.google.com/compute/docs/instances/verifying-instance-identity - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalResponse|RefreshRuntimeTokenInternalResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.refresh_runtime_token_internal.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_RefreshRuntimeTokenInternal_async - */ - refreshRuntimeTokenInternal( - request?: protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest|undefined, {}|undefined - ]>; - refreshRuntimeTokenInternal( - request: protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest|null|undefined, - {}|null|undefined>): void; - refreshRuntimeTokenInternal( - request: protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest, - callback: Callback< - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest|null|undefined, - {}|null|undefined>): void; - refreshRuntimeTokenInternal( - request?: protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.refreshRuntimeTokenInternal(request, options, callback); - } - -/** - * Creates a new Runtime in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {string} request.runtimeId - * Required. User-defined unique ID of this Runtime. - * @param {google.cloud.notebooks.v1.Runtime} request.runtime - * Required. The Runtime to be created. - * @param {string} request.requestId - * Idempotent request UUID. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.create_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_CreateRuntime_async - */ - createRuntime( - request?: protos.google.cloud.notebooks.v1.ICreateRuntimeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createRuntime( - request: protos.google.cloud.notebooks.v1.ICreateRuntimeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createRuntime( - request: protos.google.cloud.notebooks.v1.ICreateRuntimeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createRuntime( - request?: protos.google.cloud.notebooks.v1.ICreateRuntimeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createRuntime(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createRuntime()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.create_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_CreateRuntime_async - */ - async checkCreateRuntimeProgress(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.createRuntime, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Update Notebook Runtime configuration. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.notebooks.v1.Runtime} request.runtime - * Required. The Runtime to be updated. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Specifies the path, relative to `Runtime`, of - * the field to update. For example, to change the software configuration - * kernels, the `update_mask` parameter would be - * specified as `software_config.kernels`, - * and the `PATCH` request body would specify the new value, as follows: - * - * { - * "software_config":{ - * "kernels": [{ - * 'repository': - * 'gcr.io/deeplearning-platform-release/pytorch-gpu', 'tag': - * 'latest' }], - * } - * } - * - * - * Currently, only the following fields can be updated: - * - `software_config.kernels` - * - `software_config.post_startup_script` - * - `software_config.custom_gpu_driver_path` - * - `software_config.idle_shutdown` - * - `software_config.idle_shutdown_timeout` - * - `software_config.disable_terminal` - * @param {string} request.requestId - * Idempotent request UUID. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.update_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_UpdateRuntime_async - */ - updateRuntime( - request?: protos.google.cloud.notebooks.v1.IUpdateRuntimeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateRuntime( - request: protos.google.cloud.notebooks.v1.IUpdateRuntimeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateRuntime( - request: protos.google.cloud.notebooks.v1.IUpdateRuntimeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateRuntime( - request?: protos.google.cloud.notebooks.v1.IUpdateRuntimeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'runtime.name': request.runtime!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateRuntime(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateRuntime()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.update_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_UpdateRuntime_async - */ - async checkUpdateRuntimeProgress(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.updateRuntime, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a single Runtime. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - * @param {string} request.requestId - * Idempotent request UUID. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.delete_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_DeleteRuntime_async - */ - deleteRuntime( - request?: protos.google.cloud.notebooks.v1.IDeleteRuntimeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteRuntime( - request: protos.google.cloud.notebooks.v1.IDeleteRuntimeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteRuntime( - request: protos.google.cloud.notebooks.v1.IDeleteRuntimeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteRuntime( - request?: protos.google.cloud.notebooks.v1.IDeleteRuntimeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteRuntime(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteRuntime()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.delete_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_DeleteRuntime_async - */ - async checkDeleteRuntimeProgress(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.deleteRuntime, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Starts a Managed Notebook Runtime. - * Perform "Start" on GPU instances; "Resume" on CPU instances - * See: - * https://cloud.google.com/compute/docs/instances/stop-start-instance - * https://cloud.google.com/compute/docs/instances/suspend-resume-instance - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - * @param {string} request.requestId - * Idempotent request UUID. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.start_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_StartRuntime_async - */ - startRuntime( - request?: protos.google.cloud.notebooks.v1.IStartRuntimeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - startRuntime( - request: protos.google.cloud.notebooks.v1.IStartRuntimeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - startRuntime( - request: protos.google.cloud.notebooks.v1.IStartRuntimeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - startRuntime( - request?: protos.google.cloud.notebooks.v1.IStartRuntimeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.startRuntime(request, options, callback); - } -/** - * Check the status of the long running operation returned by `startRuntime()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.start_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_StartRuntime_async - */ - async checkStartRuntimeProgress(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.startRuntime, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Stops a Managed Notebook Runtime. - * Perform "Stop" on GPU instances; "Suspend" on CPU instances - * See: - * https://cloud.google.com/compute/docs/instances/stop-start-instance - * https://cloud.google.com/compute/docs/instances/suspend-resume-instance - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - * @param {string} request.requestId - * Idempotent request UUID. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.stop_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_StopRuntime_async - */ - stopRuntime( - request?: protos.google.cloud.notebooks.v1.IStopRuntimeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - stopRuntime( - request: protos.google.cloud.notebooks.v1.IStopRuntimeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - stopRuntime( - request: protos.google.cloud.notebooks.v1.IStopRuntimeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - stopRuntime( - request?: protos.google.cloud.notebooks.v1.IStopRuntimeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.stopRuntime(request, options, callback); - } -/** - * Check the status of the long running operation returned by `stopRuntime()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.stop_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_StopRuntime_async - */ - async checkStopRuntimeProgress(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.stopRuntime, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Switch a Managed Notebook Runtime. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - * @param {string} request.machineType - * machine type. - * @param {google.cloud.notebooks.v1.RuntimeAcceleratorConfig} request.acceleratorConfig - * accelerator config. - * @param {string} request.requestId - * Idempotent request UUID. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.switch_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_SwitchRuntime_async - */ - switchRuntime( - request?: protos.google.cloud.notebooks.v1.ISwitchRuntimeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - switchRuntime( - request: protos.google.cloud.notebooks.v1.ISwitchRuntimeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - switchRuntime( - request: protos.google.cloud.notebooks.v1.ISwitchRuntimeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - switchRuntime( - request?: protos.google.cloud.notebooks.v1.ISwitchRuntimeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.switchRuntime(request, options, callback); - } -/** - * Check the status of the long running operation returned by `switchRuntime()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.switch_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_SwitchRuntime_async - */ - async checkSwitchRuntimeProgress(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.switchRuntime, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Resets a Managed Notebook Runtime. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - * @param {string} request.requestId - * Idempotent request UUID. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.reset_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_ResetRuntime_async - */ - resetRuntime( - request?: protos.google.cloud.notebooks.v1.IResetRuntimeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - resetRuntime( - request: protos.google.cloud.notebooks.v1.IResetRuntimeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - resetRuntime( - request: protos.google.cloud.notebooks.v1.IResetRuntimeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - resetRuntime( - request?: protos.google.cloud.notebooks.v1.IResetRuntimeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.resetRuntime(request, options, callback); - } -/** - * Check the status of the long running operation returned by `resetRuntime()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.reset_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_ResetRuntime_async - */ - async checkResetRuntimeProgress(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.resetRuntime, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Upgrades a Managed Notebook Runtime to the latest version. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - * @param {string} request.requestId - * Idempotent request UUID. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.upgrade_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_UpgradeRuntime_async - */ - upgradeRuntime( - request?: protos.google.cloud.notebooks.v1.IUpgradeRuntimeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - upgradeRuntime( - request: protos.google.cloud.notebooks.v1.IUpgradeRuntimeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - upgradeRuntime( - request: protos.google.cloud.notebooks.v1.IUpgradeRuntimeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - upgradeRuntime( - request?: protos.google.cloud.notebooks.v1.IUpgradeRuntimeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.upgradeRuntime(request, options, callback); - } -/** - * Check the status of the long running operation returned by `upgradeRuntime()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.upgrade_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_UpgradeRuntime_async - */ - async checkUpgradeRuntimeProgress(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.upgradeRuntime, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Report and process a runtime event. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - * @param {string} request.vmId - * Required. The VM hardware token for authenticating the VM. - * https://cloud.google.com/compute/docs/instances/verifying-instance-identity - * @param {google.cloud.notebooks.v1.Event} request.event - * Required. The Event to be reported. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.report_runtime_event.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_ReportRuntimeEvent_async - */ - reportRuntimeEvent( - request?: protos.google.cloud.notebooks.v1.IReportRuntimeEventRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - reportRuntimeEvent( - request: protos.google.cloud.notebooks.v1.IReportRuntimeEventRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - reportRuntimeEvent( - request: protos.google.cloud.notebooks.v1.IReportRuntimeEventRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - reportRuntimeEvent( - request?: protos.google.cloud.notebooks.v1.IReportRuntimeEventRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.reportRuntimeEvent(request, options, callback); - } -/** - * Check the status of the long running operation returned by `reportRuntimeEvent()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.report_runtime_event.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_ReportRuntimeEvent_async - */ - async checkReportRuntimeEventProgress(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.reportRuntimeEvent, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Creates a Diagnostic File and runs Diagnostic Tool given a Runtime. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtimes_id}` - * @param {google.cloud.notebooks.v1.DiagnosticConfig} request.diagnosticConfig - * Required. Defines flags that are used to run the diagnostic tool - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.diagnose_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_DiagnoseRuntime_async - */ - diagnoseRuntime( - request?: protos.google.cloud.notebooks.v1.IDiagnoseRuntimeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - diagnoseRuntime( - request: protos.google.cloud.notebooks.v1.IDiagnoseRuntimeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - diagnoseRuntime( - request: protos.google.cloud.notebooks.v1.IDiagnoseRuntimeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - diagnoseRuntime( - request?: protos.google.cloud.notebooks.v1.IDiagnoseRuntimeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.diagnoseRuntime(request, options, callback); - } -/** - * Check the status of the long running operation returned by `diagnoseRuntime()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.diagnose_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_DiagnoseRuntime_async - */ - async checkDiagnoseRuntimeProgress(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.diagnoseRuntime, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists Runtimes in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.notebooks.v1.Runtime|Runtime}. - * 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 `listRuntimesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listRuntimes( - request?: protos.google.cloud.notebooks.v1.IListRuntimesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IRuntime[], - protos.google.cloud.notebooks.v1.IListRuntimesRequest|null, - protos.google.cloud.notebooks.v1.IListRuntimesResponse - ]>; - listRuntimes( - request: protos.google.cloud.notebooks.v1.IListRuntimesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListRuntimesRequest, - protos.google.cloud.notebooks.v1.IListRuntimesResponse|null|undefined, - protos.google.cloud.notebooks.v1.IRuntime>): void; - listRuntimes( - request: protos.google.cloud.notebooks.v1.IListRuntimesRequest, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListRuntimesRequest, - protos.google.cloud.notebooks.v1.IListRuntimesResponse|null|undefined, - protos.google.cloud.notebooks.v1.IRuntime>): void; - listRuntimes( - request?: protos.google.cloud.notebooks.v1.IListRuntimesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.notebooks.v1.IListRuntimesRequest, - protos.google.cloud.notebooks.v1.IListRuntimesResponse|null|undefined, - protos.google.cloud.notebooks.v1.IRuntime>, - callback?: PaginationCallback< - protos.google.cloud.notebooks.v1.IListRuntimesRequest, - protos.google.cloud.notebooks.v1.IListRuntimesResponse|null|undefined, - protos.google.cloud.notebooks.v1.IRuntime>): - Promise<[ - protos.google.cloud.notebooks.v1.IRuntime[], - protos.google.cloud.notebooks.v1.IListRuntimesRequest|null, - protos.google.cloud.notebooks.v1.IListRuntimesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listRuntimes(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. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @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 protos.google.cloud.notebooks.v1.Runtime|Runtime} 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 `listRuntimesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listRuntimesStream( - request?: protos.google.cloud.notebooks.v1.IListRuntimesRequest, - 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['listRuntimes']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRuntimes.createStream( - this.innerApiCalls.listRuntimes as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listRuntimes`, 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. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.notebooks.v1.Runtime|Runtime}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.list_runtimes.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_ListRuntimes_async - */ - listRuntimesAsync( - request?: protos.google.cloud.notebooks.v1.IListRuntimesRequest, - 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['listRuntimes']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRuntimes.asyncIterate( - this.innerApiCalls['listRuntimes'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @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/interfaces/CallOptions.html | 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.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - getIamPolicy( - request: IamProtos.google.iam.v1.GetIamPolicyRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, - {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { - return this.iamClient.getIamPolicy(request, options, callback); - } - -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - setIamPolicy( - request: IamProtos.google.iam.v1.SetIamPolicyRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, - {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { - return this.iamClient.setIamPolicy(request, options, callback); - } - -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ - testIamPermissions( - request: IamProtos.google.iam.v1.TestIamPermissionsRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.TestIamPermissionsResponse, - IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.TestIamPermissionsResponse, - IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, - {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { - return this.iamClient.testIamPermissions(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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 environment resource name string. - * - * @param {string} project - * @param {string} environment - * @returns {string} Resource name string. - */ - environmentPath(project:string,environment:string) { - return this.pathTemplates.environmentPathTemplate.render({ - project: project, - environment: environment, - }); - } - - /** - * Parse the project from Environment resource. - * - * @param {string} environmentName - * A fully-qualified path representing Environment resource. - * @returns {string} A string representing the project. - */ - matchProjectFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).project; - } - - /** - * Parse the environment from Environment resource. - * - * @param {string} environmentName - * A fully-qualified path representing Environment resource. - * @returns {string} A string representing the environment. - */ - matchEnvironmentFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).environment; - } - - /** - * Return a fully-qualified execution resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} execution - * @returns {string} Resource name string. - */ - executionPath(project:string,location:string,execution:string) { - return this.pathTemplates.executionPathTemplate.render({ - project: project, - location: location, - execution: execution, - }); - } - - /** - * Parse the project from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the project. - */ - matchProjectFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).project; - } - - /** - * Parse the location from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the location. - */ - matchLocationFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).location; - } - - /** - * Parse the execution from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the execution. - */ - matchExecutionFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).execution; - } - - /** - * Return a fully-qualified instance resource name string. - * - * @param {string} project - * @param {string} instance - * @returns {string} Resource name string. - */ - instancePath(project:string,instance:string) { - return this.pathTemplates.instancePathTemplate.render({ - project: project, - instance: instance, - }); - } - - /** - * Parse the project from Instance resource. - * - * @param {string} instanceName - * A fully-qualified path representing Instance resource. - * @returns {string} A string representing the project. - */ - matchProjectFromInstanceName(instanceName: string) { - return this.pathTemplates.instancePathTemplate.match(instanceName).project; - } - - /** - * Parse the instance from Instance resource. - * - * @param {string} instanceName - * A fully-qualified path representing Instance resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromInstanceName(instanceName: string) { - return this.pathTemplates.instancePathTemplate.match(instanceName).instance; - } - - /** - * 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 project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified runtime resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} runtime - * @returns {string} Resource name string. - */ - runtimePath(project:string,location:string,runtime:string) { - return this.pathTemplates.runtimePathTemplate.render({ - project: project, - location: location, - runtime: runtime, - }); - } - - /** - * Parse the project from Runtime resource. - * - * @param {string} runtimeName - * A fully-qualified path representing Runtime resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRuntimeName(runtimeName: string) { - return this.pathTemplates.runtimePathTemplate.match(runtimeName).project; - } - - /** - * Parse the location from Runtime resource. - * - * @param {string} runtimeName - * A fully-qualified path representing Runtime resource. - * @returns {string} A string representing the location. - */ - matchLocationFromRuntimeName(runtimeName: string) { - return this.pathTemplates.runtimePathTemplate.match(runtimeName).location; - } - - /** - * Parse the runtime from Runtime resource. - * - * @param {string} runtimeName - * A fully-qualified path representing Runtime resource. - * @returns {string} A string representing the runtime. - */ - matchRuntimeFromRuntimeName(runtimeName: string) { - return this.pathTemplates.runtimePathTemplate.match(runtimeName).runtime; - } - - /** - * Return a fully-qualified schedule resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} schedule - * @returns {string} Resource name string. - */ - schedulePath(project:string,location:string,schedule:string) { - return this.pathTemplates.schedulePathTemplate.render({ - project: project, - location: location, - schedule: schedule, - }); - } - - /** - * Parse the project from Schedule resource. - * - * @param {string} scheduleName - * A fully-qualified path representing Schedule resource. - * @returns {string} A string representing the project. - */ - matchProjectFromScheduleName(scheduleName: string) { - return this.pathTemplates.schedulePathTemplate.match(scheduleName).project; - } - - /** - * Parse the location from Schedule resource. - * - * @param {string} scheduleName - * A fully-qualified path representing Schedule resource. - * @returns {string} A string representing the location. - */ - matchLocationFromScheduleName(scheduleName: string) { - return this.pathTemplates.schedulePathTemplate.match(scheduleName).location; - } - - /** - * Parse the schedule from Schedule resource. - * - * @param {string} scheduleName - * A fully-qualified path representing Schedule resource. - * @returns {string} A string representing the schedule. - */ - matchScheduleFromScheduleName(scheduleName: string) { - return this.pathTemplates.schedulePathTemplate.match(scheduleName).schedule; - } - - /** - * 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.managedNotebookServiceStub && !this._terminated) { - return this.managedNotebookServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.iamClient.close(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_client_config.json b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_client_config.json deleted file mode 100644 index d44cface756..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_client_config.json +++ /dev/null @@ -1,94 +0,0 @@ -{ - "interfaces": { - "google.cloud.notebooks.v1.ManagedNotebookService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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": { - "ListRuntimes": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetRuntime": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateRuntime": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateRuntime": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteRuntime": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "StartRuntime": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "StopRuntime": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "SwitchRuntime": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ResetRuntime": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "UpgradeRuntime": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "ReportRuntimeEvent": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RefreshRuntimeTokenInternal": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "DiagnoseRuntime": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_proto_list.json b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_proto_list.json deleted file mode 100644 index 3861b9317a6..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/managed_notebook_service_proto_list.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - "../../protos/google/cloud/notebooks/v1/diagnostic_config.proto", - "../../protos/google/cloud/notebooks/v1/environment.proto", - "../../protos/google/cloud/notebooks/v1/event.proto", - "../../protos/google/cloud/notebooks/v1/execution.proto", - "../../protos/google/cloud/notebooks/v1/instance.proto", - "../../protos/google/cloud/notebooks/v1/instance_config.proto", - "../../protos/google/cloud/notebooks/v1/managed_service.proto", - "../../protos/google/cloud/notebooks/v1/runtime.proto", - "../../protos/google/cloud/notebooks/v1/schedule.proto", - "../../protos/google/cloud/notebooks/v1/service.proto" -] diff --git a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_client.ts b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_client.ts deleted file mode 100644 index bc34f4bcea2..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_client.ts +++ /dev/null @@ -1,4544 +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, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/notebook_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './notebook_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * API v1 service for Cloud AI Platform Notebooks. - * @class - * @memberof v1 - */ -export class NotebookServiceClient { - 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}; - iamClient: IamClient; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - notebookServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of NotebookServiceClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 NotebookServiceClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof NotebookServiceClient; - 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.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - - 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 { - 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 = { - environmentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/environments/{environment}' - ), - executionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/location/{location}/executions/{execution}' - ), - instancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/instances/{instance}' - ), - runtimePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/runtimes/{runtime}' - ), - schedulePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/location/{location}/schedules/{schedule}' - ), - }; - - // 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 = { - listInstances: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instances'), - listEnvironments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'environments'), - listSchedules: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'schedules'), - listExecutions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'executions') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/*/instances/*}:getIamPolicy',additional_bindings: [{get: '/v1/{resource=projects/*/locations/*/runtimes/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/*/instances/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/runtimes/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/*/instances/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/runtimes/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; - const createInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const registerInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; - const registerInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const setInstanceAcceleratorResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; - const setInstanceAcceleratorMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const setInstanceMachineTypeResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; - const setInstanceMachineTypeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const updateInstanceConfigResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; - const updateInstanceConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const updateShieldedInstanceConfigResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; - const updateShieldedInstanceConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const setInstanceLabelsResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; - const setInstanceLabelsMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const deleteInstanceResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const startInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; - const startInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const stopInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; - const stopInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const resetInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; - const resetInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const reportInstanceInfoResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; - const reportInstanceInfoMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const upgradeInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; - const upgradeInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const rollbackInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; - const rollbackInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const diagnoseInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; - const diagnoseInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const upgradeInstanceInternalResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; - const upgradeInstanceInternalMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const createEnvironmentResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Environment') as gax.protobuf.Type; - const createEnvironmentMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const deleteEnvironmentResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteEnvironmentMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const deleteScheduleResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteScheduleMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const createScheduleResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Schedule') as gax.protobuf.Type; - const createScheduleMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const triggerScheduleResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Schedule') as gax.protobuf.Type; - const triggerScheduleMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const deleteExecutionResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteExecutionMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - const createExecutionResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Execution') as gax.protobuf.Type; - const createExecutionMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createInstanceResponse.decode.bind(createInstanceResponse), - createInstanceMetadata.decode.bind(createInstanceMetadata)), - registerInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - registerInstanceResponse.decode.bind(registerInstanceResponse), - registerInstanceMetadata.decode.bind(registerInstanceMetadata)), - setInstanceAccelerator: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - setInstanceAcceleratorResponse.decode.bind(setInstanceAcceleratorResponse), - setInstanceAcceleratorMetadata.decode.bind(setInstanceAcceleratorMetadata)), - setInstanceMachineType: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - setInstanceMachineTypeResponse.decode.bind(setInstanceMachineTypeResponse), - setInstanceMachineTypeMetadata.decode.bind(setInstanceMachineTypeMetadata)), - updateInstanceConfig: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateInstanceConfigResponse.decode.bind(updateInstanceConfigResponse), - updateInstanceConfigMetadata.decode.bind(updateInstanceConfigMetadata)), - updateShieldedInstanceConfig: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateShieldedInstanceConfigResponse.decode.bind(updateShieldedInstanceConfigResponse), - updateShieldedInstanceConfigMetadata.decode.bind(updateShieldedInstanceConfigMetadata)), - setInstanceLabels: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - setInstanceLabelsResponse.decode.bind(setInstanceLabelsResponse), - setInstanceLabelsMetadata.decode.bind(setInstanceLabelsMetadata)), - deleteInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteInstanceResponse.decode.bind(deleteInstanceResponse), - deleteInstanceMetadata.decode.bind(deleteInstanceMetadata)), - startInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - startInstanceResponse.decode.bind(startInstanceResponse), - startInstanceMetadata.decode.bind(startInstanceMetadata)), - stopInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - stopInstanceResponse.decode.bind(stopInstanceResponse), - stopInstanceMetadata.decode.bind(stopInstanceMetadata)), - resetInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - resetInstanceResponse.decode.bind(resetInstanceResponse), - resetInstanceMetadata.decode.bind(resetInstanceMetadata)), - reportInstanceInfo: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - reportInstanceInfoResponse.decode.bind(reportInstanceInfoResponse), - reportInstanceInfoMetadata.decode.bind(reportInstanceInfoMetadata)), - upgradeInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - upgradeInstanceResponse.decode.bind(upgradeInstanceResponse), - upgradeInstanceMetadata.decode.bind(upgradeInstanceMetadata)), - rollbackInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - rollbackInstanceResponse.decode.bind(rollbackInstanceResponse), - rollbackInstanceMetadata.decode.bind(rollbackInstanceMetadata)), - diagnoseInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - diagnoseInstanceResponse.decode.bind(diagnoseInstanceResponse), - diagnoseInstanceMetadata.decode.bind(diagnoseInstanceMetadata)), - upgradeInstanceInternal: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - upgradeInstanceInternalResponse.decode.bind(upgradeInstanceInternalResponse), - upgradeInstanceInternalMetadata.decode.bind(upgradeInstanceInternalMetadata)), - createEnvironment: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createEnvironmentResponse.decode.bind(createEnvironmentResponse), - createEnvironmentMetadata.decode.bind(createEnvironmentMetadata)), - deleteEnvironment: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteEnvironmentResponse.decode.bind(deleteEnvironmentResponse), - deleteEnvironmentMetadata.decode.bind(deleteEnvironmentMetadata)), - deleteSchedule: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteScheduleResponse.decode.bind(deleteScheduleResponse), - deleteScheduleMetadata.decode.bind(deleteScheduleMetadata)), - createSchedule: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createScheduleResponse.decode.bind(createScheduleResponse), - createScheduleMetadata.decode.bind(createScheduleMetadata)), - triggerSchedule: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - triggerScheduleResponse.decode.bind(triggerScheduleResponse), - triggerScheduleMetadata.decode.bind(triggerScheduleMetadata)), - deleteExecution: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteExecutionResponse.decode.bind(deleteExecutionResponse), - deleteExecutionMetadata.decode.bind(deleteExecutionMetadata)), - createExecution: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createExecutionResponse.decode.bind(createExecutionResponse), - createExecutionMetadata.decode.bind(createExecutionMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.notebooks.v1.NotebookService', 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.notebookServiceStub) { - return this.notebookServiceStub; - } - - // Put together the "service stub" for - // google.cloud.notebooks.v1.NotebookService. - this.notebookServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.notebooks.v1.NotebookService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.notebooks.v1.NotebookService, - 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 notebookServiceStubMethods = - ['listInstances', 'getInstance', 'createInstance', 'registerInstance', 'setInstanceAccelerator', 'setInstanceMachineType', 'updateInstanceConfig', 'updateShieldedInstanceConfig', 'setInstanceLabels', 'updateInstanceMetadataItems', 'deleteInstance', 'startInstance', 'stopInstance', 'resetInstance', 'reportInstanceInfo', 'isInstanceUpgradeable', 'getInstanceHealth', 'upgradeInstance', 'rollbackInstance', 'diagnoseInstance', 'upgradeInstanceInternal', 'listEnvironments', 'getEnvironment', 'createEnvironment', 'deleteEnvironment', 'listSchedules', 'getSchedule', 'deleteSchedule', 'createSchedule', 'triggerSchedule', 'listExecutions', 'getExecution', 'deleteExecution', 'createExecution']; - for (const methodName of notebookServiceStubMethods) { - const callPromise = this.notebookServiceStub.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.notebookServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'notebooks.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 'notebooks.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 details of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1.Instance|Instance}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.get_instance.js - * region_tag:notebooks_v1_generated_NotebookService_GetInstance_async - */ - getInstance( - request?: protos.google.cloud.notebooks.v1.IGetInstanceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IInstance, - protos.google.cloud.notebooks.v1.IGetInstanceRequest|undefined, {}|undefined - ]>; - getInstance( - request: protos.google.cloud.notebooks.v1.IGetInstanceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1.IInstance, - protos.google.cloud.notebooks.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; - getInstance( - request: protos.google.cloud.notebooks.v1.IGetInstanceRequest, - callback: Callback< - protos.google.cloud.notebooks.v1.IInstance, - protos.google.cloud.notebooks.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; - getInstance( - request?: protos.google.cloud.notebooks.v1.IGetInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1.IInstance, - protos.google.cloud.notebooks.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.notebooks.v1.IInstance, - protos.google.cloud.notebooks.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1.IInstance, - protos.google.cloud.notebooks.v1.IGetInstanceRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getInstance(request, options, callback); - } -/** - * Add/update metadata items for an instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {number[]} request.items - * Metadata items to add/update for the instance. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsResponse|UpdateInstanceMetadataItemsResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.update_instance_metadata_items.js - * region_tag:notebooks_v1_generated_NotebookService_UpdateInstanceMetadataItems_async - */ - updateInstanceMetadataItems( - request?: protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest|undefined, {}|undefined - ]>; - updateInstanceMetadataItems( - request: protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest|null|undefined, - {}|null|undefined>): void; - updateInstanceMetadataItems( - request: protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest, - callback: Callback< - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest|null|undefined, - {}|null|undefined>): void; - updateInstanceMetadataItems( - request?: protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateInstanceMetadataItems(request, options, callback); - } -/** - * Check if a notebook instance is upgradable. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.notebookInstance - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {google.cloud.notebooks.v1.UpgradeType} [request.type] - * Optional. The optional UpgradeType. Setting this field will search for additional - * compute images to upgrade this instance. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1.IsInstanceUpgradeableResponse|IsInstanceUpgradeableResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.is_instance_upgradeable.js - * region_tag:notebooks_v1_generated_NotebookService_IsInstanceUpgradeable_async - */ - isInstanceUpgradeable( - request?: protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest|undefined, {}|undefined - ]>; - isInstanceUpgradeable( - request: protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest|null|undefined, - {}|null|undefined>): void; - isInstanceUpgradeable( - request: protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest, - callback: Callback< - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest|null|undefined, - {}|null|undefined>): void; - isInstanceUpgradeable( - request?: protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'notebook_instance': request.notebookInstance ?? '', - }); - this.initialize(); - return this.innerApiCalls.isInstanceUpgradeable(request, options, callback); - } -/** - * Check if a notebook instance is healthy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1.GetInstanceHealthResponse|GetInstanceHealthResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.get_instance_health.js - * region_tag:notebooks_v1_generated_NotebookService_GetInstanceHealth_async - */ - getInstanceHealth( - request?: protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, - protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest|undefined, {}|undefined - ]>; - getInstanceHealth( - request: protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, - protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest|null|undefined, - {}|null|undefined>): void; - getInstanceHealth( - request: protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest, - callback: Callback< - protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, - protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest|null|undefined, - {}|null|undefined>): void; - getInstanceHealth( - request?: protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, - protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, - protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, - protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getInstanceHealth(request, options, callback); - } -/** - * Gets details of a single Environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/environments/{environment_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1.Environment|Environment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.get_environment.js - * region_tag:notebooks_v1_generated_NotebookService_GetEnvironment_async - */ - getEnvironment( - request?: protos.google.cloud.notebooks.v1.IGetEnvironmentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IEnvironment, - protos.google.cloud.notebooks.v1.IGetEnvironmentRequest|undefined, {}|undefined - ]>; - getEnvironment( - request: protos.google.cloud.notebooks.v1.IGetEnvironmentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1.IEnvironment, - protos.google.cloud.notebooks.v1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>): void; - getEnvironment( - request: protos.google.cloud.notebooks.v1.IGetEnvironmentRequest, - callback: Callback< - protos.google.cloud.notebooks.v1.IEnvironment, - protos.google.cloud.notebooks.v1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>): void; - getEnvironment( - request?: protos.google.cloud.notebooks.v1.IGetEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1.IEnvironment, - protos.google.cloud.notebooks.v1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.notebooks.v1.IEnvironment, - protos.google.cloud.notebooks.v1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1.IEnvironment, - protos.google.cloud.notebooks.v1.IGetEnvironmentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getEnvironment(request, options, callback); - } -/** - * Gets details of schedule - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/schedules/{schedule_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1.Schedule|Schedule}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.get_schedule.js - * region_tag:notebooks_v1_generated_NotebookService_GetSchedule_async - */ - getSchedule( - request?: protos.google.cloud.notebooks.v1.IGetScheduleRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.ISchedule, - protos.google.cloud.notebooks.v1.IGetScheduleRequest|undefined, {}|undefined - ]>; - getSchedule( - request: protos.google.cloud.notebooks.v1.IGetScheduleRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1.ISchedule, - protos.google.cloud.notebooks.v1.IGetScheduleRequest|null|undefined, - {}|null|undefined>): void; - getSchedule( - request: protos.google.cloud.notebooks.v1.IGetScheduleRequest, - callback: Callback< - protos.google.cloud.notebooks.v1.ISchedule, - protos.google.cloud.notebooks.v1.IGetScheduleRequest|null|undefined, - {}|null|undefined>): void; - getSchedule( - request?: protos.google.cloud.notebooks.v1.IGetScheduleRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1.ISchedule, - protos.google.cloud.notebooks.v1.IGetScheduleRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.notebooks.v1.ISchedule, - protos.google.cloud.notebooks.v1.IGetScheduleRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1.ISchedule, - protos.google.cloud.notebooks.v1.IGetScheduleRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getSchedule(request, options, callback); - } -/** - * Gets details of executions - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/executions/{execution_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1.Execution|Execution}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.get_execution.js - * region_tag:notebooks_v1_generated_NotebookService_GetExecution_async - */ - getExecution( - request?: protos.google.cloud.notebooks.v1.IGetExecutionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IExecution, - protos.google.cloud.notebooks.v1.IGetExecutionRequest|undefined, {}|undefined - ]>; - getExecution( - request: protos.google.cloud.notebooks.v1.IGetExecutionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1.IExecution, - protos.google.cloud.notebooks.v1.IGetExecutionRequest|null|undefined, - {}|null|undefined>): void; - getExecution( - request: protos.google.cloud.notebooks.v1.IGetExecutionRequest, - callback: Callback< - protos.google.cloud.notebooks.v1.IExecution, - protos.google.cloud.notebooks.v1.IGetExecutionRequest|null|undefined, - {}|null|undefined>): void; - getExecution( - request?: protos.google.cloud.notebooks.v1.IGetExecutionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1.IExecution, - protos.google.cloud.notebooks.v1.IGetExecutionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.notebooks.v1.IExecution, - protos.google.cloud.notebooks.v1.IGetExecutionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1.IExecution, - protos.google.cloud.notebooks.v1.IGetExecutionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getExecution(request, options, callback); - } - -/** - * Creates a new Instance in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {string} request.instanceId - * Required. User-defined unique ID of this instance. - * @param {google.cloud.notebooks.v1.Instance} request.instance - * Required. The instance to be created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.create_instance.js - * region_tag:notebooks_v1_generated_NotebookService_CreateInstance_async - */ - createInstance( - request?: protos.google.cloud.notebooks.v1.ICreateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createInstance( - request: protos.google.cloud.notebooks.v1.ICreateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createInstance( - request: protos.google.cloud.notebooks.v1.ICreateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createInstance( - request?: protos.google.cloud.notebooks.v1.ICreateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.create_instance.js - * region_tag:notebooks_v1_generated_NotebookService_CreateInstance_async - */ - async checkCreateInstanceProgress(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.createInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Registers an existing legacy notebook instance to the Notebooks API server. - * Legacy instances are instances created with the legacy Compute Engine - * calls. They are not manageable by the Notebooks API out of the box. This - * call makes these instances manageable by the Notebooks API. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {string} request.instanceId - * Required. User defined unique ID of this instance. The `instance_id` must - * be 1 to 63 characters long and contain only lowercase letters, - * numeric characters, and dashes. The first character must be a lowercase - * letter and the last character cannot be a dash. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.register_instance.js - * region_tag:notebooks_v1_generated_NotebookService_RegisterInstance_async - */ - registerInstance( - request?: protos.google.cloud.notebooks.v1.IRegisterInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - registerInstance( - request: protos.google.cloud.notebooks.v1.IRegisterInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - registerInstance( - request: protos.google.cloud.notebooks.v1.IRegisterInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - registerInstance( - request?: protos.google.cloud.notebooks.v1.IRegisterInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.registerInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `registerInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.register_instance.js - * region_tag:notebooks_v1_generated_NotebookService_RegisterInstance_async - */ - async checkRegisterInstanceProgress(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.registerInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the guest accelerators of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {google.cloud.notebooks.v1.Instance.AcceleratorType} request.type - * Required. Type of this accelerator. - * @param {number} request.coreCount - * Required. Count of cores of this accelerator. Note that not all combinations - * of `type` and `core_count` are valid. Check [GPUs on - * Compute Engine](https://cloud.google.com/compute/docs/gpus/#gpus-list) to - * find a valid combination. TPUs are not supported. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.set_instance_accelerator.js - * region_tag:notebooks_v1_generated_NotebookService_SetInstanceAccelerator_async - */ - setInstanceAccelerator( - request?: protos.google.cloud.notebooks.v1.ISetInstanceAcceleratorRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - setInstanceAccelerator( - request: protos.google.cloud.notebooks.v1.ISetInstanceAcceleratorRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInstanceAccelerator( - request: protos.google.cloud.notebooks.v1.ISetInstanceAcceleratorRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInstanceAccelerator( - request?: protos.google.cloud.notebooks.v1.ISetInstanceAcceleratorRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.setInstanceAccelerator(request, options, callback); - } -/** - * Check the status of the long running operation returned by `setInstanceAccelerator()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.set_instance_accelerator.js - * region_tag:notebooks_v1_generated_NotebookService_SetInstanceAccelerator_async - */ - async checkSetInstanceAcceleratorProgress(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.setInstanceAccelerator, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the machine type of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {string} request.machineType - * Required. The [Compute Engine machine - * type](https://cloud.google.com/compute/docs/machine-types). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.set_instance_machine_type.js - * region_tag:notebooks_v1_generated_NotebookService_SetInstanceMachineType_async - */ - setInstanceMachineType( - request?: protos.google.cloud.notebooks.v1.ISetInstanceMachineTypeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - setInstanceMachineType( - request: protos.google.cloud.notebooks.v1.ISetInstanceMachineTypeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInstanceMachineType( - request: protos.google.cloud.notebooks.v1.ISetInstanceMachineTypeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInstanceMachineType( - request?: protos.google.cloud.notebooks.v1.ISetInstanceMachineTypeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.setInstanceMachineType(request, options, callback); - } -/** - * Check the status of the long running operation returned by `setInstanceMachineType()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.set_instance_machine_type.js - * region_tag:notebooks_v1_generated_NotebookService_SetInstanceMachineType_async - */ - async checkSetInstanceMachineTypeProgress(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.setInstanceMachineType, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Update Notebook Instance configurations. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {google.cloud.notebooks.v1.InstanceConfig} request.config - * The instance configurations to be 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.update_instance_config.js - * region_tag:notebooks_v1_generated_NotebookService_UpdateInstanceConfig_async - */ - updateInstanceConfig( - request?: protos.google.cloud.notebooks.v1.IUpdateInstanceConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateInstanceConfig( - request: protos.google.cloud.notebooks.v1.IUpdateInstanceConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateInstanceConfig( - request: protos.google.cloud.notebooks.v1.IUpdateInstanceConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateInstanceConfig( - request?: protos.google.cloud.notebooks.v1.IUpdateInstanceConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateInstanceConfig(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateInstanceConfig()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.update_instance_config.js - * region_tag:notebooks_v1_generated_NotebookService_UpdateInstanceConfig_async - */ - async checkUpdateInstanceConfigProgress(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.updateInstanceConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the Shielded instance configuration of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {google.cloud.notebooks.v1.Instance.ShieldedInstanceConfig} request.shieldedInstanceConfig - * ShieldedInstance configuration to be 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.update_shielded_instance_config.js - * region_tag:notebooks_v1_generated_NotebookService_UpdateShieldedInstanceConfig_async - */ - updateShieldedInstanceConfig( - request?: protos.google.cloud.notebooks.v1.IUpdateShieldedInstanceConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateShieldedInstanceConfig( - request: protos.google.cloud.notebooks.v1.IUpdateShieldedInstanceConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateShieldedInstanceConfig( - request: protos.google.cloud.notebooks.v1.IUpdateShieldedInstanceConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateShieldedInstanceConfig( - request?: protos.google.cloud.notebooks.v1.IUpdateShieldedInstanceConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateShieldedInstanceConfig(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateShieldedInstanceConfig()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.update_shielded_instance_config.js - * region_tag:notebooks_v1_generated_NotebookService_UpdateShieldedInstanceConfig_async - */ - async checkUpdateShieldedInstanceConfigProgress(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.updateShieldedInstanceConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Replaces all the labels of an Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {number[]} request.labels - * Labels to apply to this instance. - * These can be later modified by the setLabels method - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.set_instance_labels.js - * region_tag:notebooks_v1_generated_NotebookService_SetInstanceLabels_async - */ - setInstanceLabels( - request?: protos.google.cloud.notebooks.v1.ISetInstanceLabelsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - setInstanceLabels( - request: protos.google.cloud.notebooks.v1.ISetInstanceLabelsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInstanceLabels( - request: protos.google.cloud.notebooks.v1.ISetInstanceLabelsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInstanceLabels( - request?: protos.google.cloud.notebooks.v1.ISetInstanceLabelsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.setInstanceLabels(request, options, callback); - } -/** - * Check the status of the long running operation returned by `setInstanceLabels()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.set_instance_labels.js - * region_tag:notebooks_v1_generated_NotebookService_SetInstanceLabels_async - */ - async checkSetInstanceLabelsProgress(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.setInstanceLabels, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.delete_instance.js - * region_tag:notebooks_v1_generated_NotebookService_DeleteInstance_async - */ - deleteInstance( - request?: protos.google.cloud.notebooks.v1.IDeleteInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteInstance( - request: protos.google.cloud.notebooks.v1.IDeleteInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteInstance( - request: protos.google.cloud.notebooks.v1.IDeleteInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteInstance( - request?: protos.google.cloud.notebooks.v1.IDeleteInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.delete_instance.js - * region_tag:notebooks_v1_generated_NotebookService_DeleteInstance_async - */ - async checkDeleteInstanceProgress(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.deleteInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Starts a notebook instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.start_instance.js - * region_tag:notebooks_v1_generated_NotebookService_StartInstance_async - */ - startInstance( - request?: protos.google.cloud.notebooks.v1.IStartInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - startInstance( - request: protos.google.cloud.notebooks.v1.IStartInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - startInstance( - request: protos.google.cloud.notebooks.v1.IStartInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - startInstance( - request?: protos.google.cloud.notebooks.v1.IStartInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.startInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `startInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.start_instance.js - * region_tag:notebooks_v1_generated_NotebookService_StartInstance_async - */ - async checkStartInstanceProgress(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.startInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Stops a notebook instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.stop_instance.js - * region_tag:notebooks_v1_generated_NotebookService_StopInstance_async - */ - stopInstance( - request?: protos.google.cloud.notebooks.v1.IStopInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - stopInstance( - request: protos.google.cloud.notebooks.v1.IStopInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - stopInstance( - request: protos.google.cloud.notebooks.v1.IStopInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - stopInstance( - request?: protos.google.cloud.notebooks.v1.IStopInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.stopInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `stopInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.stop_instance.js - * region_tag:notebooks_v1_generated_NotebookService_StopInstance_async - */ - async checkStopInstanceProgress(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.stopInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Resets a notebook instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.reset_instance.js - * region_tag:notebooks_v1_generated_NotebookService_ResetInstance_async - */ - resetInstance( - request?: protos.google.cloud.notebooks.v1.IResetInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - resetInstance( - request: protos.google.cloud.notebooks.v1.IResetInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - resetInstance( - request: protos.google.cloud.notebooks.v1.IResetInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - resetInstance( - request?: protos.google.cloud.notebooks.v1.IResetInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.resetInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `resetInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.reset_instance.js - * region_tag:notebooks_v1_generated_NotebookService_ResetInstance_async - */ - async checkResetInstanceProgress(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.resetInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Allows notebook instances to - * report their latest instance information to the Notebooks - * API server. The server will merge the reported information to - * the instance metadata store. Do not use this method directly. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {string} request.vmId - * Required. The VM hardware token for authenticating the VM. - * https://cloud.google.com/compute/docs/instances/verifying-instance-identity - * @param {number[]} request.metadata - * The metadata reported to Notebooks API. This will be merged to the instance - * metadata store - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.report_instance_info.js - * region_tag:notebooks_v1_generated_NotebookService_ReportInstanceInfo_async - */ - reportInstanceInfo( - request?: protos.google.cloud.notebooks.v1.IReportInstanceInfoRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - reportInstanceInfo( - request: protos.google.cloud.notebooks.v1.IReportInstanceInfoRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - reportInstanceInfo( - request: protos.google.cloud.notebooks.v1.IReportInstanceInfoRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - reportInstanceInfo( - request?: protos.google.cloud.notebooks.v1.IReportInstanceInfoRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.reportInstanceInfo(request, options, callback); - } -/** - * Check the status of the long running operation returned by `reportInstanceInfo()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.report_instance_info.js - * region_tag:notebooks_v1_generated_NotebookService_ReportInstanceInfo_async - */ - async checkReportInstanceInfoProgress(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.reportInstanceInfo, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Upgrades a notebook instance to the latest version. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {google.cloud.notebooks.v1.UpgradeType} [request.type] - * Optional. The optional UpgradeType. Setting this field will search for additional - * compute images to upgrade this instance. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.upgrade_instance.js - * region_tag:notebooks_v1_generated_NotebookService_UpgradeInstance_async - */ - upgradeInstance( - request?: protos.google.cloud.notebooks.v1.IUpgradeInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - upgradeInstance( - request: protos.google.cloud.notebooks.v1.IUpgradeInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - upgradeInstance( - request: protos.google.cloud.notebooks.v1.IUpgradeInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - upgradeInstance( - request?: protos.google.cloud.notebooks.v1.IUpgradeInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.upgradeInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `upgradeInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.upgrade_instance.js - * region_tag:notebooks_v1_generated_NotebookService_UpgradeInstance_async - */ - async checkUpgradeInstanceProgress(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.upgradeInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Rollbacks a notebook instance to the previous version. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {string} request.targetSnapshot - * Required. The snapshot for rollback. - * Example: `projects/test-project/global/snapshots/krwlzipynril`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.rollback_instance.js - * region_tag:notebooks_v1_generated_NotebookService_RollbackInstance_async - */ - rollbackInstance( - request?: protos.google.cloud.notebooks.v1.IRollbackInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - rollbackInstance( - request: protos.google.cloud.notebooks.v1.IRollbackInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - rollbackInstance( - request: protos.google.cloud.notebooks.v1.IRollbackInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - rollbackInstance( - request?: protos.google.cloud.notebooks.v1.IRollbackInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.rollbackInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `rollbackInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.rollback_instance.js - * region_tag:notebooks_v1_generated_NotebookService_RollbackInstance_async - */ - async checkRollbackInstanceProgress(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.rollbackInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Creates a Diagnostic File and runs Diagnostic Tool given an Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {google.cloud.notebooks.v1.DiagnosticConfig} request.diagnosticConfig - * Required. Defines flags that are used to run the diagnostic tool - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.diagnose_instance.js - * region_tag:notebooks_v1_generated_NotebookService_DiagnoseInstance_async - */ - diagnoseInstance( - request?: protos.google.cloud.notebooks.v1.IDiagnoseInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - diagnoseInstance( - request: protos.google.cloud.notebooks.v1.IDiagnoseInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - diagnoseInstance( - request: protos.google.cloud.notebooks.v1.IDiagnoseInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - diagnoseInstance( - request?: protos.google.cloud.notebooks.v1.IDiagnoseInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.diagnoseInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `diagnoseInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.diagnose_instance.js - * region_tag:notebooks_v1_generated_NotebookService_DiagnoseInstance_async - */ - async checkDiagnoseInstanceProgress(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.diagnoseInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Allows notebook instances to - * call this endpoint to upgrade themselves. Do not use this method directly. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {string} request.vmId - * Required. The VM hardware token for authenticating the VM. - * https://cloud.google.com/compute/docs/instances/verifying-instance-identity - * @param {google.cloud.notebooks.v1.UpgradeType} [request.type] - * Optional. The optional UpgradeType. Setting this field will search for additional - * compute images to upgrade this instance. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.upgrade_instance_internal.js - * region_tag:notebooks_v1_generated_NotebookService_UpgradeInstanceInternal_async - */ - upgradeInstanceInternal( - request?: protos.google.cloud.notebooks.v1.IUpgradeInstanceInternalRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - upgradeInstanceInternal( - request: protos.google.cloud.notebooks.v1.IUpgradeInstanceInternalRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - upgradeInstanceInternal( - request: protos.google.cloud.notebooks.v1.IUpgradeInstanceInternalRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - upgradeInstanceInternal( - request?: protos.google.cloud.notebooks.v1.IUpgradeInstanceInternalRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.upgradeInstanceInternal(request, options, callback); - } -/** - * Check the status of the long running operation returned by `upgradeInstanceInternal()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.upgrade_instance_internal.js - * region_tag:notebooks_v1_generated_NotebookService_UpgradeInstanceInternal_async - */ - async checkUpgradeInstanceInternalProgress(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.upgradeInstanceInternal, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Creates a new Environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: `projects/{project_id}/locations/{location}` - * @param {string} request.environmentId - * Required. User-defined unique ID of this environment. The `environment_id` must - * be 1 to 63 characters long and contain only lowercase letters, - * numeric characters, and dashes. The first character must be a lowercase - * letter and the last character cannot be a dash. - * @param {google.cloud.notebooks.v1.Environment} request.environment - * Required. The environment to be created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.create_environment.js - * region_tag:notebooks_v1_generated_NotebookService_CreateEnvironment_async - */ - createEnvironment( - request?: protos.google.cloud.notebooks.v1.ICreateEnvironmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createEnvironment( - request: protos.google.cloud.notebooks.v1.ICreateEnvironmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createEnvironment( - request: protos.google.cloud.notebooks.v1.ICreateEnvironmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createEnvironment( - request?: protos.google.cloud.notebooks.v1.ICreateEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createEnvironment(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createEnvironment()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.create_environment.js - * region_tag:notebooks_v1_generated_NotebookService_CreateEnvironment_async - */ - async checkCreateEnvironmentProgress(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.createEnvironment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a single Environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/environments/{environment_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.delete_environment.js - * region_tag:notebooks_v1_generated_NotebookService_DeleteEnvironment_async - */ - deleteEnvironment( - request?: protos.google.cloud.notebooks.v1.IDeleteEnvironmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteEnvironment( - request: protos.google.cloud.notebooks.v1.IDeleteEnvironmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteEnvironment( - request: protos.google.cloud.notebooks.v1.IDeleteEnvironmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteEnvironment( - request?: protos.google.cloud.notebooks.v1.IDeleteEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteEnvironment(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteEnvironment()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.delete_environment.js - * region_tag:notebooks_v1_generated_NotebookService_DeleteEnvironment_async - */ - async checkDeleteEnvironmentProgress(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.deleteEnvironment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes schedule and all underlying jobs - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/schedules/{schedule_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.delete_schedule.js - * region_tag:notebooks_v1_generated_NotebookService_DeleteSchedule_async - */ - deleteSchedule( - request?: protos.google.cloud.notebooks.v1.IDeleteScheduleRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteSchedule( - request: protos.google.cloud.notebooks.v1.IDeleteScheduleRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteSchedule( - request: protos.google.cloud.notebooks.v1.IDeleteScheduleRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteSchedule( - request?: protos.google.cloud.notebooks.v1.IDeleteScheduleRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteSchedule(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteSchedule()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.delete_schedule.js - * region_tag:notebooks_v1_generated_NotebookService_DeleteSchedule_async - */ - async checkDeleteScheduleProgress(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.deleteSchedule, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Creates a new Scheduled Notebook in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {string} request.scheduleId - * Required. User-defined unique ID of this schedule. - * @param {google.cloud.notebooks.v1.Schedule} request.schedule - * Required. The schedule to be created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.create_schedule.js - * region_tag:notebooks_v1_generated_NotebookService_CreateSchedule_async - */ - createSchedule( - request?: protos.google.cloud.notebooks.v1.ICreateScheduleRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createSchedule( - request: protos.google.cloud.notebooks.v1.ICreateScheduleRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createSchedule( - request: protos.google.cloud.notebooks.v1.ICreateScheduleRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createSchedule( - request?: protos.google.cloud.notebooks.v1.ICreateScheduleRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createSchedule(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createSchedule()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.create_schedule.js - * region_tag:notebooks_v1_generated_NotebookService_CreateSchedule_async - */ - async checkCreateScheduleProgress(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.createSchedule, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Triggers execution of an existing schedule. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `parent=projects/{project_id}/locations/{location}/schedules/{schedule_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.trigger_schedule.js - * region_tag:notebooks_v1_generated_NotebookService_TriggerSchedule_async - */ - triggerSchedule( - request?: protos.google.cloud.notebooks.v1.ITriggerScheduleRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - triggerSchedule( - request: protos.google.cloud.notebooks.v1.ITriggerScheduleRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - triggerSchedule( - request: protos.google.cloud.notebooks.v1.ITriggerScheduleRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - triggerSchedule( - request?: protos.google.cloud.notebooks.v1.ITriggerScheduleRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.triggerSchedule(request, options, callback); - } -/** - * Check the status of the long running operation returned by `triggerSchedule()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.trigger_schedule.js - * region_tag:notebooks_v1_generated_NotebookService_TriggerSchedule_async - */ - async checkTriggerScheduleProgress(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.triggerSchedule, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes execution - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/executions/{execution_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.delete_execution.js - * region_tag:notebooks_v1_generated_NotebookService_DeleteExecution_async - */ - deleteExecution( - request?: protos.google.cloud.notebooks.v1.IDeleteExecutionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteExecution( - request: protos.google.cloud.notebooks.v1.IDeleteExecutionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteExecution( - request: protos.google.cloud.notebooks.v1.IDeleteExecutionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteExecution( - request?: protos.google.cloud.notebooks.v1.IDeleteExecutionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteExecution(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteExecution()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.delete_execution.js - * region_tag:notebooks_v1_generated_NotebookService_DeleteExecution_async - */ - async checkDeleteExecutionProgress(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.deleteExecution, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Creates a new Execution in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {string} request.executionId - * Required. User-defined unique ID of this execution. - * @param {google.cloud.notebooks.v1.Execution} request.execution - * Required. The execution to be created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.create_execution.js - * region_tag:notebooks_v1_generated_NotebookService_CreateExecution_async - */ - createExecution( - request?: protos.google.cloud.notebooks.v1.ICreateExecutionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createExecution( - request: protos.google.cloud.notebooks.v1.ICreateExecutionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createExecution( - request: protos.google.cloud.notebooks.v1.ICreateExecutionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createExecution( - request?: protos.google.cloud.notebooks.v1.ICreateExecutionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createExecution(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createExecution()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.create_execution.js - * region_tag:notebooks_v1_generated_NotebookService_CreateExecution_async - */ - async checkCreateExecutionProgress(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.createExecution, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists instances in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.notebooks.v1.Instance|Instance}. - * 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 `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listInstances( - request?: protos.google.cloud.notebooks.v1.IListInstancesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IInstance[], - protos.google.cloud.notebooks.v1.IListInstancesRequest|null, - protos.google.cloud.notebooks.v1.IListInstancesResponse - ]>; - listInstances( - request: protos.google.cloud.notebooks.v1.IListInstancesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListInstancesRequest, - protos.google.cloud.notebooks.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v1.IInstance>): void; - listInstances( - request: protos.google.cloud.notebooks.v1.IListInstancesRequest, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListInstancesRequest, - protos.google.cloud.notebooks.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v1.IInstance>): void; - listInstances( - request?: protos.google.cloud.notebooks.v1.IListInstancesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.notebooks.v1.IListInstancesRequest, - protos.google.cloud.notebooks.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v1.IInstance>, - callback?: PaginationCallback< - protos.google.cloud.notebooks.v1.IListInstancesRequest, - protos.google.cloud.notebooks.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v1.IInstance>): - Promise<[ - protos.google.cloud.notebooks.v1.IInstance[], - protos.google.cloud.notebooks.v1.IListInstancesRequest|null, - protos.google.cloud.notebooks.v1.IListInstancesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listInstances(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. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @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 protos.google.cloud.notebooks.v1.Instance|Instance} 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 `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listInstancesStream( - request?: protos.google.cloud.notebooks.v1.IListInstancesRequest, - 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['listInstances']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInstances.createStream( - this.innerApiCalls.listInstances as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listInstances`, 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. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.notebooks.v1.Instance|Instance}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.list_instances.js - * region_tag:notebooks_v1_generated_NotebookService_ListInstances_async - */ - listInstancesAsync( - request?: protos.google.cloud.notebooks.v1.IListInstancesRequest, - 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['listInstances']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInstances.asyncIterate( - this.innerApiCalls['listInstances'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists environments in a project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: `projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing from - * the last result. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.notebooks.v1.Environment|Environment}. - * 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 `listEnvironmentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listEnvironments( - request?: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IEnvironment[], - protos.google.cloud.notebooks.v1.IListEnvironmentsRequest|null, - protos.google.cloud.notebooks.v1.IListEnvironmentsResponse - ]>; - listEnvironments( - request: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, - protos.google.cloud.notebooks.v1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.notebooks.v1.IEnvironment>): void; - listEnvironments( - request: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, - protos.google.cloud.notebooks.v1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.notebooks.v1.IEnvironment>): void; - listEnvironments( - request?: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, - protos.google.cloud.notebooks.v1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.notebooks.v1.IEnvironment>, - callback?: PaginationCallback< - protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, - protos.google.cloud.notebooks.v1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.notebooks.v1.IEnvironment>): - Promise<[ - protos.google.cloud.notebooks.v1.IEnvironment[], - protos.google.cloud.notebooks.v1.IListEnvironmentsRequest|null, - protos.google.cloud.notebooks.v1.IListEnvironmentsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listEnvironments(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. Format: `projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing from - * the last result. - * @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 protos.google.cloud.notebooks.v1.Environment|Environment} 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 `listEnvironmentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listEnvironmentsStream( - request?: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, - 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['listEnvironments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listEnvironments.createStream( - this.innerApiCalls.listEnvironments as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listEnvironments`, 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. Format: `projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing from - * the last result. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.notebooks.v1.Environment|Environment}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.list_environments.js - * region_tag:notebooks_v1_generated_NotebookService_ListEnvironments_async - */ - listEnvironmentsAsync( - request?: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, - 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['listEnvironments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listEnvironments.asyncIterate( - this.innerApiCalls['listEnvironments'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists schedules in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {string} request.filter - * Filter applied to resulting schedules. - * @param {string} request.orderBy - * Field to order results by. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.notebooks.v1.Schedule|Schedule}. - * 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 `listSchedulesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listSchedules( - request?: protos.google.cloud.notebooks.v1.IListSchedulesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.ISchedule[], - protos.google.cloud.notebooks.v1.IListSchedulesRequest|null, - protos.google.cloud.notebooks.v1.IListSchedulesResponse - ]>; - listSchedules( - request: protos.google.cloud.notebooks.v1.IListSchedulesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListSchedulesRequest, - protos.google.cloud.notebooks.v1.IListSchedulesResponse|null|undefined, - protos.google.cloud.notebooks.v1.ISchedule>): void; - listSchedules( - request: protos.google.cloud.notebooks.v1.IListSchedulesRequest, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListSchedulesRequest, - protos.google.cloud.notebooks.v1.IListSchedulesResponse|null|undefined, - protos.google.cloud.notebooks.v1.ISchedule>): void; - listSchedules( - request?: protos.google.cloud.notebooks.v1.IListSchedulesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.notebooks.v1.IListSchedulesRequest, - protos.google.cloud.notebooks.v1.IListSchedulesResponse|null|undefined, - protos.google.cloud.notebooks.v1.ISchedule>, - callback?: PaginationCallback< - protos.google.cloud.notebooks.v1.IListSchedulesRequest, - protos.google.cloud.notebooks.v1.IListSchedulesResponse|null|undefined, - protos.google.cloud.notebooks.v1.ISchedule>): - Promise<[ - protos.google.cloud.notebooks.v1.ISchedule[], - protos.google.cloud.notebooks.v1.IListSchedulesRequest|null, - protos.google.cloud.notebooks.v1.IListSchedulesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listSchedules(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. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {string} request.filter - * Filter applied to resulting schedules. - * @param {string} request.orderBy - * Field to order results by. - * @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 protos.google.cloud.notebooks.v1.Schedule|Schedule} 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 `listSchedulesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listSchedulesStream( - request?: protos.google.cloud.notebooks.v1.IListSchedulesRequest, - 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['listSchedules']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listSchedules.createStream( - this.innerApiCalls.listSchedules as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listSchedules`, 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. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {string} request.filter - * Filter applied to resulting schedules. - * @param {string} request.orderBy - * Field to order results by. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.notebooks.v1.Schedule|Schedule}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.list_schedules.js - * region_tag:notebooks_v1_generated_NotebookService_ListSchedules_async - */ - listSchedulesAsync( - request?: protos.google.cloud.notebooks.v1.IListSchedulesRequest, - 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['listSchedules']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listSchedules.asyncIterate( - this.innerApiCalls['listSchedules'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists executions in a given project and location - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {string} request.filter - * Filter applied to resulting executions. Currently only supports filtering - * executions by a specified `schedule_id`. - * Format: `schedule_id=` - * @param {string} request.orderBy - * Sort by field. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.notebooks.v1.Execution|Execution}. - * 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 `listExecutionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listExecutions( - request?: protos.google.cloud.notebooks.v1.IListExecutionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IExecution[], - protos.google.cloud.notebooks.v1.IListExecutionsRequest|null, - protos.google.cloud.notebooks.v1.IListExecutionsResponse - ]>; - listExecutions( - request: protos.google.cloud.notebooks.v1.IListExecutionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListExecutionsRequest, - protos.google.cloud.notebooks.v1.IListExecutionsResponse|null|undefined, - protos.google.cloud.notebooks.v1.IExecution>): void; - listExecutions( - request: protos.google.cloud.notebooks.v1.IListExecutionsRequest, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListExecutionsRequest, - protos.google.cloud.notebooks.v1.IListExecutionsResponse|null|undefined, - protos.google.cloud.notebooks.v1.IExecution>): void; - listExecutions( - request?: protos.google.cloud.notebooks.v1.IListExecutionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.notebooks.v1.IListExecutionsRequest, - protos.google.cloud.notebooks.v1.IListExecutionsResponse|null|undefined, - protos.google.cloud.notebooks.v1.IExecution>, - callback?: PaginationCallback< - protos.google.cloud.notebooks.v1.IListExecutionsRequest, - protos.google.cloud.notebooks.v1.IListExecutionsResponse|null|undefined, - protos.google.cloud.notebooks.v1.IExecution>): - Promise<[ - protos.google.cloud.notebooks.v1.IExecution[], - protos.google.cloud.notebooks.v1.IListExecutionsRequest|null, - protos.google.cloud.notebooks.v1.IListExecutionsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listExecutions(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. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {string} request.filter - * Filter applied to resulting executions. Currently only supports filtering - * executions by a specified `schedule_id`. - * Format: `schedule_id=` - * @param {string} request.orderBy - * Sort by field. - * @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 protos.google.cloud.notebooks.v1.Execution|Execution} 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 `listExecutionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listExecutionsStream( - request?: protos.google.cloud.notebooks.v1.IListExecutionsRequest, - 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['listExecutions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listExecutions.createStream( - this.innerApiCalls.listExecutions as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listExecutions`, 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. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {string} request.filter - * Filter applied to resulting executions. Currently only supports filtering - * executions by a specified `schedule_id`. - * Format: `schedule_id=` - * @param {string} request.orderBy - * Sort by field. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.notebooks.v1.Execution|Execution}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.list_executions.js - * region_tag:notebooks_v1_generated_NotebookService_ListExecutions_async - */ - listExecutionsAsync( - request?: protos.google.cloud.notebooks.v1.IListExecutionsRequest, - 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['listExecutions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listExecutions.asyncIterate( - this.innerApiCalls['listExecutions'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @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/interfaces/CallOptions.html | 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.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - getIamPolicy( - request: IamProtos.google.iam.v1.GetIamPolicyRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, - {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { - return this.iamClient.getIamPolicy(request, options, callback); - } - -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - setIamPolicy( - request: IamProtos.google.iam.v1.SetIamPolicyRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, - {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { - return this.iamClient.setIamPolicy(request, options, callback); - } - -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ - testIamPermissions( - request: IamProtos.google.iam.v1.TestIamPermissionsRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.TestIamPermissionsResponse, - IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.TestIamPermissionsResponse, - IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, - {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { - return this.iamClient.testIamPermissions(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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 environment resource name string. - * - * @param {string} project - * @param {string} environment - * @returns {string} Resource name string. - */ - environmentPath(project:string,environment:string) { - return this.pathTemplates.environmentPathTemplate.render({ - project: project, - environment: environment, - }); - } - - /** - * Parse the project from Environment resource. - * - * @param {string} environmentName - * A fully-qualified path representing Environment resource. - * @returns {string} A string representing the project. - */ - matchProjectFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).project; - } - - /** - * Parse the environment from Environment resource. - * - * @param {string} environmentName - * A fully-qualified path representing Environment resource. - * @returns {string} A string representing the environment. - */ - matchEnvironmentFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).environment; - } - - /** - * Return a fully-qualified execution resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} execution - * @returns {string} Resource name string. - */ - executionPath(project:string,location:string,execution:string) { - return this.pathTemplates.executionPathTemplate.render({ - project: project, - location: location, - execution: execution, - }); - } - - /** - * Parse the project from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the project. - */ - matchProjectFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).project; - } - - /** - * Parse the location from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the location. - */ - matchLocationFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).location; - } - - /** - * Parse the execution from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the execution. - */ - matchExecutionFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).execution; - } - - /** - * Return a fully-qualified instance resource name string. - * - * @param {string} project - * @param {string} instance - * @returns {string} Resource name string. - */ - instancePath(project:string,instance:string) { - return this.pathTemplates.instancePathTemplate.render({ - project: project, - instance: instance, - }); - } - - /** - * Parse the project from Instance resource. - * - * @param {string} instanceName - * A fully-qualified path representing Instance resource. - * @returns {string} A string representing the project. - */ - matchProjectFromInstanceName(instanceName: string) { - return this.pathTemplates.instancePathTemplate.match(instanceName).project; - } - - /** - * Parse the instance from Instance resource. - * - * @param {string} instanceName - * A fully-qualified path representing Instance resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromInstanceName(instanceName: string) { - return this.pathTemplates.instancePathTemplate.match(instanceName).instance; - } - - /** - * Return a fully-qualified runtime resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} runtime - * @returns {string} Resource name string. - */ - runtimePath(project:string,location:string,runtime:string) { - return this.pathTemplates.runtimePathTemplate.render({ - project: project, - location: location, - runtime: runtime, - }); - } - - /** - * Parse the project from Runtime resource. - * - * @param {string} runtimeName - * A fully-qualified path representing Runtime resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRuntimeName(runtimeName: string) { - return this.pathTemplates.runtimePathTemplate.match(runtimeName).project; - } - - /** - * Parse the location from Runtime resource. - * - * @param {string} runtimeName - * A fully-qualified path representing Runtime resource. - * @returns {string} A string representing the location. - */ - matchLocationFromRuntimeName(runtimeName: string) { - return this.pathTemplates.runtimePathTemplate.match(runtimeName).location; - } - - /** - * Parse the runtime from Runtime resource. - * - * @param {string} runtimeName - * A fully-qualified path representing Runtime resource. - * @returns {string} A string representing the runtime. - */ - matchRuntimeFromRuntimeName(runtimeName: string) { - return this.pathTemplates.runtimePathTemplate.match(runtimeName).runtime; - } - - /** - * Return a fully-qualified schedule resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} schedule - * @returns {string} Resource name string. - */ - schedulePath(project:string,location:string,schedule:string) { - return this.pathTemplates.schedulePathTemplate.render({ - project: project, - location: location, - schedule: schedule, - }); - } - - /** - * Parse the project from Schedule resource. - * - * @param {string} scheduleName - * A fully-qualified path representing Schedule resource. - * @returns {string} A string representing the project. - */ - matchProjectFromScheduleName(scheduleName: string) { - return this.pathTemplates.schedulePathTemplate.match(scheduleName).project; - } - - /** - * Parse the location from Schedule resource. - * - * @param {string} scheduleName - * A fully-qualified path representing Schedule resource. - * @returns {string} A string representing the location. - */ - matchLocationFromScheduleName(scheduleName: string) { - return this.pathTemplates.schedulePathTemplate.match(scheduleName).location; - } - - /** - * Parse the schedule from Schedule resource. - * - * @param {string} scheduleName - * A fully-qualified path representing Schedule resource. - * @returns {string} A string representing the schedule. - */ - matchScheduleFromScheduleName(scheduleName: string) { - return this.pathTemplates.schedulePathTemplate.match(scheduleName).schedule; - } - - /** - * 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.notebookServiceStub && !this._terminated) { - return this.notebookServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.iamClient.close(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_client_config.json b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_client_config.json deleted file mode 100644 index 0d27109878e..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_client_config.json +++ /dev/null @@ -1,199 +0,0 @@ -{ - "interfaces": { - "google.cloud.notebooks.v1.NotebookService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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": { - "ListInstances": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RegisterInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "SetInstanceAccelerator": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "SetInstanceMachineType": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateInstanceConfig": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateShieldedInstanceConfig": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "SetInstanceLabels": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateInstanceMetadataItems": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "DeleteInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "StartInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "StopInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ResetInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ReportInstanceInfo": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "IsInstanceUpgradeable": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetInstanceHealth": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpgradeInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RollbackInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DiagnoseInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpgradeInstanceInternal": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListEnvironments": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetEnvironment": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateEnvironment": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteEnvironment": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListSchedules": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetSchedule": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteSchedule": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateSchedule": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "TriggerSchedule": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "ListExecutions": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetExecution": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteExecution": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateExecution": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_proto_list.json b/owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_proto_list.json deleted file mode 100644 index 3861b9317a6..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/src/v1/notebook_service_proto_list.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - "../../protos/google/cloud/notebooks/v1/diagnostic_config.proto", - "../../protos/google/cloud/notebooks/v1/environment.proto", - "../../protos/google/cloud/notebooks/v1/event.proto", - "../../protos/google/cloud/notebooks/v1/execution.proto", - "../../protos/google/cloud/notebooks/v1/instance.proto", - "../../protos/google/cloud/notebooks/v1/instance_config.proto", - "../../protos/google/cloud/notebooks/v1/managed_service.proto", - "../../protos/google/cloud/notebooks/v1/runtime.proto", - "../../protos/google/cloud/notebooks/v1/schedule.proto", - "../../protos/google/cloud/notebooks/v1/service.proto" -] diff --git a/owl-bot-staging/google-cloud-notebooks/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-notebooks/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index fd40b36724c..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const notebooks = require('@google-cloud/notebooks'); - -function main() { - const managedNotebookServiceClient = new notebooks.ManagedNotebookServiceClient(); - const notebookServiceClient = new notebooks.NotebookServiceClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-notebooks/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 6d7f3eac2b2..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +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 {ManagedNotebookServiceClient, NotebookServiceClient} from '@google-cloud/notebooks'; - -// check that the client class type name can be used -function doStuffWithManagedNotebookServiceClient(client: ManagedNotebookServiceClient) { - client.close(); -} -function doStuffWithNotebookServiceClient(client: NotebookServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const managedNotebookServiceClient = new ManagedNotebookServiceClient(); - doStuffWithManagedNotebookServiceClient(managedNotebookServiceClient); - // check that the client instance can be created - const notebookServiceClient = new NotebookServiceClient(); - doStuffWithNotebookServiceClient(notebookServiceClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/system-test/install.ts b/owl-bot-staging/google-cloud-notebooks/v1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/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-notebooks/v1/test/gapic_managed_notebook_service_v1.ts b/owl-bot-staging/google-cloud-notebooks/v1/test/gapic_managed_notebook_service_v1.ts deleted file mode 100644 index 874034af34f..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/test/gapic_managed_notebook_service_v1.ts +++ /dev/null @@ -1,3200 +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 managednotebookserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.ManagedNotebookServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = managednotebookserviceModule.v1.ManagedNotebookServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = managednotebookserviceModule.v1.ManagedNotebookServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = managednotebookserviceModule.v1.ManagedNotebookServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.managedNotebookServiceStub, undefined); - await client.initialize(); - assert(client.managedNotebookServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.managedNotebookServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.managedNotebookServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - 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('getRuntime', () => { - it('invokes getRuntime without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.Runtime() - ); - client.innerApiCalls.getRuntime = stubSimpleCall(expectedResponse); - const [response] = await client.getRuntime(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRuntime without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.Runtime() - ); - client.innerApiCalls.getRuntime = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getRuntime( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IRuntime|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRuntime with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getRuntime = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getRuntime(request), expectedError); - const actualRequest = (client.innerApiCalls.getRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRuntime with closed client', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getRuntime(request), expectedError); - }); - }); - - describe('refreshRuntimeTokenInternal', () => { - it('invokes refreshRuntimeTokenInternal without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalResponse() - ); - client.innerApiCalls.refreshRuntimeTokenInternal = stubSimpleCall(expectedResponse); - const [response] = await client.refreshRuntimeTokenInternal(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes refreshRuntimeTokenInternal without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalResponse() - ); - client.innerApiCalls.refreshRuntimeTokenInternal = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.refreshRuntimeTokenInternal( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes refreshRuntimeTokenInternal with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.refreshRuntimeTokenInternal = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.refreshRuntimeTokenInternal(request), expectedError); - const actualRequest = (client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes refreshRuntimeTokenInternal with closed client', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.refreshRuntimeTokenInternal(request), expectedError); - }); - }); - - describe('createRuntime', () => { - it('invokes createRuntime without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateRuntimeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createRuntime = stubLongRunningCall(expectedResponse); - const [operation] = await client.createRuntime(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createRuntime without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateRuntimeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createRuntime = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createRuntime( - request, - (err?: Error|null, - result?: 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.createRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createRuntime with call error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateRuntimeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createRuntime = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createRuntime(request), expectedError); - const actualRequest = (client.innerApiCalls.createRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createRuntime with LRO error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateRuntimeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createRuntime = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createRuntime(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateRuntimeProgress without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateRuntimeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateRuntimeProgress with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateRuntimeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateRuntime', () => { - it('invokes updateRuntime without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateRuntimeRequest() - ); - request.runtime ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateRuntimeRequest', ['runtime', 'name']); - request.runtime.name = defaultValue1; - const expectedHeaderRequestParams = `runtime.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateRuntime = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateRuntime(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateRuntime without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateRuntimeRequest() - ); - request.runtime ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateRuntimeRequest', ['runtime', 'name']); - request.runtime.name = defaultValue1; - const expectedHeaderRequestParams = `runtime.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateRuntime = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateRuntime( - request, - (err?: Error|null, - result?: 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.updateRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateRuntime with call error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateRuntimeRequest() - ); - request.runtime ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateRuntimeRequest', ['runtime', 'name']); - request.runtime.name = defaultValue1; - const expectedHeaderRequestParams = `runtime.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateRuntime = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateRuntime(request), expectedError); - const actualRequest = (client.innerApiCalls.updateRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateRuntime with LRO error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateRuntimeRequest() - ); - request.runtime ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateRuntimeRequest', ['runtime', 'name']); - request.runtime.name = defaultValue1; - const expectedHeaderRequestParams = `runtime.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateRuntime = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateRuntime(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateRuntimeProgress without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateRuntimeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateRuntimeProgress with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateRuntimeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteRuntime', () => { - it('invokes deleteRuntime without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteRuntime = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteRuntime(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteRuntime without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteRuntime = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteRuntime( - request, - (err?: Error|null, - result?: 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.deleteRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteRuntime with call error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteRuntime = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteRuntime(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteRuntime with LRO error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteRuntime = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteRuntime(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteRuntimeProgress without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteRuntimeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteRuntimeProgress with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteRuntimeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('startRuntime', () => { - it('invokes startRuntime without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StartRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StartRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startRuntime = stubLongRunningCall(expectedResponse); - const [operation] = await client.startRuntime(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startRuntime without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StartRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StartRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startRuntime = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.startRuntime( - request, - (err?: Error|null, - result?: 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.startRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startRuntime with call error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StartRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StartRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.startRuntime = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.startRuntime(request), expectedError); - const actualRequest = (client.innerApiCalls.startRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startRuntime with LRO error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StartRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StartRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.startRuntime = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.startRuntime(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.startRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkStartRuntimeProgress without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkStartRuntimeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkStartRuntimeProgress with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStartRuntimeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('stopRuntime', () => { - it('invokes stopRuntime without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StopRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StopRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopRuntime = stubLongRunningCall(expectedResponse); - const [operation] = await client.stopRuntime(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopRuntime without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StopRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StopRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopRuntime = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.stopRuntime( - request, - (err?: Error|null, - result?: 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.stopRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopRuntime with call error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StopRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StopRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopRuntime = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.stopRuntime(request), expectedError); - const actualRequest = (client.innerApiCalls.stopRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopRuntime with LRO error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StopRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StopRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopRuntime = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.stopRuntime(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.stopRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkStopRuntimeProgress without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkStopRuntimeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkStopRuntimeProgress with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStopRuntimeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('switchRuntime', () => { - it('invokes switchRuntime without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SwitchRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SwitchRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.switchRuntime = stubLongRunningCall(expectedResponse); - const [operation] = await client.switchRuntime(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.switchRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes switchRuntime without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SwitchRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SwitchRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.switchRuntime = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.switchRuntime( - request, - (err?: Error|null, - result?: 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.switchRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes switchRuntime with call error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SwitchRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SwitchRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.switchRuntime = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.switchRuntime(request), expectedError); - const actualRequest = (client.innerApiCalls.switchRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes switchRuntime with LRO error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SwitchRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SwitchRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.switchRuntime = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.switchRuntime(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.switchRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkSwitchRuntimeProgress without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkSwitchRuntimeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkSwitchRuntimeProgress with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSwitchRuntimeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('resetRuntime', () => { - it('invokes resetRuntime without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ResetRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ResetRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.resetRuntime = stubLongRunningCall(expectedResponse); - const [operation] = await client.resetRuntime(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetRuntime without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ResetRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ResetRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.resetRuntime = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resetRuntime( - request, - (err?: Error|null, - result?: 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.resetRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetRuntime with call error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ResetRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ResetRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.resetRuntime = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.resetRuntime(request), expectedError); - const actualRequest = (client.innerApiCalls.resetRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetRuntime with LRO error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ResetRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ResetRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.resetRuntime = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.resetRuntime(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.resetRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkResetRuntimeProgress without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkResetRuntimeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkResetRuntimeProgress with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkResetRuntimeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('upgradeRuntime', () => { - it('invokes upgradeRuntime without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeRuntime = stubLongRunningCall(expectedResponse); - const [operation] = await client.upgradeRuntime(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeRuntime without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeRuntime = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.upgradeRuntime( - request, - (err?: Error|null, - result?: 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.upgradeRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeRuntime with call error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeRuntime = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.upgradeRuntime(request), expectedError); - const actualRequest = (client.innerApiCalls.upgradeRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeRuntime with LRO error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeRuntime = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.upgradeRuntime(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.upgradeRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpgradeRuntimeProgress without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpgradeRuntimeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpgradeRuntimeProgress with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpgradeRuntimeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('reportRuntimeEvent', () => { - it('invokes reportRuntimeEvent without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ReportRuntimeEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ReportRuntimeEventRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.reportRuntimeEvent = stubLongRunningCall(expectedResponse); - const [operation] = await client.reportRuntimeEvent(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reportRuntimeEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportRuntimeEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reportRuntimeEvent without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ReportRuntimeEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ReportRuntimeEventRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.reportRuntimeEvent = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.reportRuntimeEvent( - request, - (err?: Error|null, - result?: 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.reportRuntimeEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportRuntimeEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reportRuntimeEvent with call error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ReportRuntimeEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ReportRuntimeEventRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.reportRuntimeEvent = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.reportRuntimeEvent(request), expectedError); - const actualRequest = (client.innerApiCalls.reportRuntimeEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportRuntimeEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reportRuntimeEvent with LRO error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ReportRuntimeEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ReportRuntimeEventRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.reportRuntimeEvent = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.reportRuntimeEvent(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.reportRuntimeEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportRuntimeEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkReportRuntimeEventProgress without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkReportRuntimeEventProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkReportRuntimeEventProgress with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkReportRuntimeEventProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('diagnoseRuntime', () => { - it('invokes diagnoseRuntime without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DiagnoseRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.diagnoseRuntime = stubLongRunningCall(expectedResponse); - const [operation] = await client.diagnoseRuntime(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.diagnoseRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes diagnoseRuntime without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DiagnoseRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.diagnoseRuntime = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.diagnoseRuntime( - request, - (err?: Error|null, - result?: 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.diagnoseRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes diagnoseRuntime with call error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DiagnoseRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.diagnoseRuntime = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.diagnoseRuntime(request), expectedError); - const actualRequest = (client.innerApiCalls.diagnoseRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes diagnoseRuntime with LRO error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DiagnoseRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.diagnoseRuntime = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.diagnoseRuntime(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.diagnoseRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDiagnoseRuntimeProgress without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDiagnoseRuntimeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDiagnoseRuntimeProgress with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDiagnoseRuntimeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listRuntimes', () => { - it('invokes listRuntimes without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListRuntimesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListRuntimesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - ]; - client.innerApiCalls.listRuntimes = stubSimpleCall(expectedResponse); - const [response] = await client.listRuntimes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRuntimes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRuntimes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRuntimes without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListRuntimesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListRuntimesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - ]; - client.innerApiCalls.listRuntimes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listRuntimes( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IRuntime[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRuntimes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRuntimes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRuntimes with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListRuntimesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListRuntimesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listRuntimes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listRuntimes(request), expectedError); - const actualRequest = (client.innerApiCalls.listRuntimes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRuntimes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRuntimesStream without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListRuntimesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListRuntimesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - ]; - client.descriptors.page.listRuntimes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listRuntimesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1.Runtime[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1.Runtime) => { - 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.listRuntimes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRuntimes, request)); - assert( - (client.descriptors.page.listRuntimes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listRuntimesStream with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListRuntimesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListRuntimesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listRuntimes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listRuntimesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1.Runtime[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1.Runtime) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listRuntimes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRuntimes, request)); - assert( - (client.descriptors.page.listRuntimes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRuntimes without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListRuntimesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListRuntimesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - ]; - client.descriptors.page.listRuntimes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.notebooks.v1.IRuntime[] = []; - const iterable = client.listRuntimesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listRuntimes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRuntimes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRuntimes with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListRuntimesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListRuntimesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listRuntimes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listRuntimesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.notebooks.v1.IRuntime[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listRuntimes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRuntimes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - 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 managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - 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('environment', () => { - const fakePath = "/rendered/path/environment"; - const expectedParameters = { - project: "projectValue", - environment: "environmentValue", - }; - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.environmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.environmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('environmentPath', () => { - const result = client.environmentPath("projectValue", "environmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.environmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEnvironmentName', () => { - const result = client.matchProjectFromEnvironmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEnvironmentFromEnvironmentName', () => { - const result = client.matchEnvironmentFromEnvironmentName(fakePath); - assert.strictEqual(result, "environmentValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('execution', () => { - const fakePath = "/rendered/path/execution"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - execution: "executionValue", - }; - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.executionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.executionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('executionPath', () => { - const result = client.executionPath("projectValue", "locationValue", "executionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.executionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromExecutionName', () => { - const result = client.matchProjectFromExecutionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromExecutionName', () => { - const result = client.matchLocationFromExecutionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExecutionFromExecutionName', () => { - const result = client.matchExecutionFromExecutionName(fakePath); - assert.strictEqual(result, "executionValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('instance', () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - }; - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - 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('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('runtime', () => { - const fakePath = "/rendered/path/runtime"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - runtime: "runtimeValue", - }; - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.runtimePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.runtimePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('runtimePath', () => { - const result = client.runtimePath("projectValue", "locationValue", "runtimeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.runtimePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRuntimeName', () => { - const result = client.matchProjectFromRuntimeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.runtimePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRuntimeName', () => { - const result = client.matchLocationFromRuntimeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.runtimePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRuntimeFromRuntimeName', () => { - const result = client.matchRuntimeFromRuntimeName(fakePath); - assert.strictEqual(result, "runtimeValue"); - assert((client.pathTemplates.runtimePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('schedule', () => { - const fakePath = "/rendered/path/schedule"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - schedule: "scheduleValue", - }; - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.schedulePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.schedulePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('schedulePath', () => { - const result = client.schedulePath("projectValue", "locationValue", "scheduleValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.schedulePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromScheduleName', () => { - const result = client.matchProjectFromScheduleName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.schedulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromScheduleName', () => { - const result = client.matchLocationFromScheduleName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.schedulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchScheduleFromScheduleName', () => { - const result = client.matchScheduleFromScheduleName(fakePath); - assert.strictEqual(result, "scheduleValue"); - assert((client.pathTemplates.schedulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/test/gapic_notebook_service_v1.ts b/owl-bot-staging/google-cloud-notebooks/v1/test/gapic_notebook_service_v1.ts deleted file mode 100644 index aa5feafcbb0..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/test/gapic_notebook_service_v1.ts +++ /dev/null @@ -1,6405 +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 notebookserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.NotebookServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = notebookserviceModule.v1.NotebookServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = notebookserviceModule.v1.NotebookServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = notebookserviceModule.v1.NotebookServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new notebookserviceModule.v1.NotebookServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.notebookServiceStub, undefined); - await client.initialize(); - assert(client.notebookServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.notebookServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.notebookServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new notebookserviceModule.v1.NotebookServiceClient({ - 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 notebookserviceModule.v1.NotebookServiceClient({ - 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('getInstance', () => { - it('invokes getInstance without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); - const [response] = await client.getInstance(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstance without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstance( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IInstance|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstance with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstance with closed client', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getInstance(request), expectedError); - }); - }); - - describe('updateInstanceMetadataItems', () => { - it('invokes updateInstanceMetadataItems without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsResponse() - ); - client.innerApiCalls.updateInstanceMetadataItems = stubSimpleCall(expectedResponse); - const [response] = await client.updateInstanceMetadataItems(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstanceMetadataItems as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceMetadataItems as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstanceMetadataItems without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsResponse() - ); - client.innerApiCalls.updateInstanceMetadataItems = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateInstanceMetadataItems( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstanceMetadataItems as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceMetadataItems as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstanceMetadataItems with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstanceMetadataItems = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateInstanceMetadataItems(request), expectedError); - const actualRequest = (client.innerApiCalls.updateInstanceMetadataItems as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceMetadataItems as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstanceMetadataItems with closed client', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateInstanceMetadataItems(request), expectedError); - }); - }); - - describe('isInstanceUpgradeable', () => { - it('invokes isInstanceUpgradeable without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedHeaderRequestParams = `notebook_instance=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableResponse() - ); - client.innerApiCalls.isInstanceUpgradeable = stubSimpleCall(expectedResponse); - const [response] = await client.isInstanceUpgradeable(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes isInstanceUpgradeable without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedHeaderRequestParams = `notebook_instance=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableResponse() - ); - client.innerApiCalls.isInstanceUpgradeable = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.isInstanceUpgradeable( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes isInstanceUpgradeable with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedHeaderRequestParams = `notebook_instance=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.isInstanceUpgradeable = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.isInstanceUpgradeable(request), expectedError); - const actualRequest = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes isInstanceUpgradeable with closed client', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.isInstanceUpgradeable(request), expectedError); - }); - }); - - describe('getInstanceHealth', () => { - it('invokes getInstanceHealth without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetInstanceHealthRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceHealthRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetInstanceHealthResponse() - ); - client.innerApiCalls.getInstanceHealth = stubSimpleCall(expectedResponse); - const [response] = await client.getInstanceHealth(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstanceHealth as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstanceHealth as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstanceHealth without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetInstanceHealthRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceHealthRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetInstanceHealthResponse() - ); - client.innerApiCalls.getInstanceHealth = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstanceHealth( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstanceHealth as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstanceHealth as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstanceHealth with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetInstanceHealthRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceHealthRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstanceHealth = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstanceHealth(request), expectedError); - const actualRequest = (client.innerApiCalls.getInstanceHealth as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstanceHealth as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstanceHealth with closed client', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetInstanceHealthRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceHealthRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getInstanceHealth(request), expectedError); - }); - }); - - describe('getEnvironment', () => { - it('invokes getEnvironment without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.Environment() - ); - client.innerApiCalls.getEnvironment = stubSimpleCall(expectedResponse); - const [response] = await client.getEnvironment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEnvironment without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.Environment() - ); - client.innerApiCalls.getEnvironment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getEnvironment( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IEnvironment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEnvironment with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getEnvironment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEnvironment with closed client', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getEnvironment(request), expectedError); - }); - }); - - describe('getSchedule', () => { - it('invokes getSchedule without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.Schedule() - ); - client.innerApiCalls.getSchedule = stubSimpleCall(expectedResponse); - const [response] = await client.getSchedule(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSchedule without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.Schedule() - ); - client.innerApiCalls.getSchedule = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getSchedule( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.ISchedule|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSchedule with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getSchedule = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getSchedule(request), expectedError); - const actualRequest = (client.innerApiCalls.getSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSchedule with closed client', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getSchedule(request), expectedError); - }); - }); - - describe('getExecution', () => { - it('invokes getExecution without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.Execution() - ); - client.innerApiCalls.getExecution = stubSimpleCall(expectedResponse); - const [response] = await client.getExecution(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getExecution without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.Execution() - ); - client.innerApiCalls.getExecution = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getExecution( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IExecution|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getExecution with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getExecution = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getExecution(request), expectedError); - const actualRequest = (client.innerApiCalls.getExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getExecution with closed client', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getExecution(request), expectedError); - }); - }); - - describe('createInstance', () => { - it('invokes createInstance without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.createInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInstance without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createInstance( - request, - (err?: Error|null, - result?: 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.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInstance with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInstance with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('registerInstance', () => { - it('invokes registerInstance without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RegisterInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RegisterInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.registerInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.registerInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes registerInstance without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RegisterInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RegisterInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.registerInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.registerInstance( - request, - (err?: Error|null, - result?: 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.registerInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes registerInstance with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RegisterInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RegisterInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.registerInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.registerInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes registerInstance with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RegisterInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RegisterInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.registerInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.registerInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkRegisterInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRegisterInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRegisterInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRegisterInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('setInstanceAccelerator', () => { - it('invokes setInstanceAccelerator without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall(expectedResponse); - const [operation] = await client.setInstanceAccelerator(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setInstanceAccelerator without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceAccelerator = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setInstanceAccelerator( - request, - (err?: Error|null, - result?: 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.setInstanceAccelerator as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setInstanceAccelerator with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setInstanceAccelerator(request), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setInstanceAccelerator with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setInstanceAccelerator(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkSetInstanceAcceleratorProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkSetInstanceAcceleratorProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkSetInstanceAcceleratorProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSetInstanceAcceleratorProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('setInstanceMachineType', () => { - it('invokes setInstanceMachineType without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceMachineType = stubLongRunningCall(expectedResponse); - const [operation] = await client.setInstanceMachineType(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setInstanceMachineType without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceMachineType = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setInstanceMachineType( - request, - (err?: Error|null, - result?: 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.setInstanceMachineType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setInstanceMachineType with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceMachineType = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setInstanceMachineType(request), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setInstanceMachineType with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceMachineType = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setInstanceMachineType(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkSetInstanceMachineTypeProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkSetInstanceMachineTypeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkSetInstanceMachineTypeProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSetInstanceMachineTypeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateInstanceConfig', () => { - it('invokes updateInstanceConfig without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstanceConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateInstanceConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstanceConfig without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstanceConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateInstanceConfig( - request, - (err?: Error|null, - result?: 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.updateInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstanceConfig with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstanceConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateInstanceConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstanceConfig with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstanceConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateInstanceConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateInstanceConfigProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateInstanceConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateInstanceConfigProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateInstanceConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateShieldedInstanceConfig', () => { - it('invokes updateShieldedInstanceConfig without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateShieldedInstanceConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateShieldedInstanceConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateShieldedInstanceConfig without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateShieldedInstanceConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateShieldedInstanceConfig( - request, - (err?: Error|null, - result?: 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.updateShieldedInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateShieldedInstanceConfig with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateShieldedInstanceConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateShieldedInstanceConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateShieldedInstanceConfig with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateShieldedInstanceConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateShieldedInstanceConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateShieldedInstanceConfigProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateShieldedInstanceConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateShieldedInstanceConfigProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateShieldedInstanceConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('setInstanceLabels', () => { - it('invokes setInstanceLabels without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceLabelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceLabelsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceLabels = stubLongRunningCall(expectedResponse); - const [operation] = await client.setInstanceLabels(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setInstanceLabels without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceLabelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceLabelsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceLabels = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setInstanceLabels( - request, - (err?: Error|null, - result?: 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.setInstanceLabels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setInstanceLabels with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceLabelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceLabelsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceLabels = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setInstanceLabels(request), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setInstanceLabels with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceLabelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceLabelsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceLabels = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setInstanceLabels(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkSetInstanceLabelsProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkSetInstanceLabelsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkSetInstanceLabelsProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSetInstanceLabelsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteInstance', () => { - it('invokes deleteInstance without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInstance without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteInstance( - request, - (err?: Error|null, - result?: 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.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInstance with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInstance with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('startInstance', () => { - it('invokes startInstance without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.startInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startInstance without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.startInstance( - request, - (err?: Error|null, - result?: 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.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startInstance with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.startInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.startInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startInstance with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.startInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.startInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkStartInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkStartInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkStartInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStartInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('stopInstance', () => { - it('invokes stopInstance without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.stopInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopInstance without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.stopInstance( - request, - (err?: Error|null, - result?: 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.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopInstance with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.stopInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopInstance with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.stopInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkStopInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkStopInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkStopInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStopInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('resetInstance', () => { - it('invokes resetInstance without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.resetInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.resetInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetInstance without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.resetInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resetInstance( - request, - (err?: Error|null, - result?: 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.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetInstance with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.resetInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.resetInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetInstance with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.resetInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.resetInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkResetInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkResetInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkResetInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkResetInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('reportInstanceInfo', () => { - it('invokes reportInstanceInfo without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ReportInstanceInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ReportInstanceInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.reportInstanceInfo = stubLongRunningCall(expectedResponse); - const [operation] = await client.reportInstanceInfo(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reportInstanceInfo without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ReportInstanceInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ReportInstanceInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.reportInstanceInfo = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.reportInstanceInfo( - request, - (err?: Error|null, - result?: 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.reportInstanceInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reportInstanceInfo with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ReportInstanceInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ReportInstanceInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.reportInstanceInfo = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.reportInstanceInfo(request), expectedError); - const actualRequest = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reportInstanceInfo with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ReportInstanceInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ReportInstanceInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.reportInstanceInfo = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.reportInstanceInfo(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkReportInstanceInfoProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkReportInstanceInfoProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkReportInstanceInfoProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkReportInstanceInfoProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('upgradeInstance', () => { - it('invokes upgradeInstance without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.upgradeInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstance without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.upgradeInstance( - request, - (err?: Error|null, - result?: 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.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstance with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.upgradeInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstance with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.upgradeInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpgradeInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpgradeInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpgradeInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpgradeInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('rollbackInstance', () => { - it('invokes rollbackInstance without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RollbackInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RollbackInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rollbackInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.rollbackInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rollbackInstance without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RollbackInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RollbackInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rollbackInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rollbackInstance( - request, - (err?: Error|null, - result?: 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.rollbackInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rollbackInstance with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RollbackInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RollbackInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.rollbackInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rollbackInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rollbackInstance with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RollbackInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RollbackInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.rollbackInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rollbackInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkRollbackInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRollbackInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRollbackInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRollbackInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('diagnoseInstance', () => { - it('invokes diagnoseInstance without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DiagnoseInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.diagnoseInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.diagnoseInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes diagnoseInstance without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DiagnoseInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.diagnoseInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.diagnoseInstance( - request, - (err?: Error|null, - result?: 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.diagnoseInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes diagnoseInstance with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DiagnoseInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.diagnoseInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.diagnoseInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes diagnoseInstance with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DiagnoseInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.diagnoseInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.diagnoseInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDiagnoseInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDiagnoseInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDiagnoseInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDiagnoseInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('upgradeInstanceInternal', () => { - it('invokes upgradeInstanceInternal without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall(expectedResponse); - const [operation] = await client.upgradeInstanceInternal(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstanceInternal without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.upgradeInstanceInternal( - request, - (err?: Error|null, - result?: 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.upgradeInstanceInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstanceInternal with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.upgradeInstanceInternal(request), expectedError); - const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstanceInternal with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.upgradeInstanceInternal(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpgradeInstanceInternalProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpgradeInstanceInternalProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpgradeInstanceInternalProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpgradeInstanceInternalProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('createEnvironment', () => { - it('invokes createEnvironment without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createEnvironment = stubLongRunningCall(expectedResponse); - const [operation] = await client.createEnvironment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createEnvironment without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createEnvironment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createEnvironment( - request, - (err?: Error|null, - result?: 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.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createEnvironment with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEnvironment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createEnvironment with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEnvironment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createEnvironment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateEnvironmentProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateEnvironmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateEnvironmentProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateEnvironmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteEnvironment', () => { - it('invokes deleteEnvironment without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteEnvironment = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteEnvironment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteEnvironment without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteEnvironment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteEnvironment( - request, - (err?: Error|null, - result?: 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.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteEnvironment with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteEnvironment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteEnvironment with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteEnvironment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteEnvironment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteEnvironmentProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteEnvironmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteEnvironmentProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteEnvironmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteSchedule', () => { - it('invokes deleteSchedule without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteSchedule = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteSchedule(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteSchedule without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteSchedule = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteSchedule( - request, - (err?: Error|null, - result?: 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.deleteSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteSchedule with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSchedule = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteSchedule(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteSchedule with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSchedule = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteSchedule(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteScheduleProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteScheduleProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteScheduleProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteScheduleProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('createSchedule', () => { - it('invokes createSchedule without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateScheduleRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSchedule = stubLongRunningCall(expectedResponse); - const [operation] = await client.createSchedule(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSchedule without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateScheduleRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSchedule = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createSchedule( - request, - (err?: Error|null, - result?: 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.createSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSchedule with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateScheduleRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSchedule = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createSchedule(request), expectedError); - const actualRequest = (client.innerApiCalls.createSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSchedule with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateScheduleRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSchedule = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createSchedule(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateScheduleProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateScheduleProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateScheduleProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateScheduleProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('triggerSchedule', () => { - it('invokes triggerSchedule without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.TriggerScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.TriggerScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.triggerSchedule = stubLongRunningCall(expectedResponse); - const [operation] = await client.triggerSchedule(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.triggerSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.triggerSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes triggerSchedule without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.TriggerScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.TriggerScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.triggerSchedule = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.triggerSchedule( - request, - (err?: Error|null, - result?: 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.triggerSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.triggerSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes triggerSchedule with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.TriggerScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.TriggerScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.triggerSchedule = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.triggerSchedule(request), expectedError); - const actualRequest = (client.innerApiCalls.triggerSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.triggerSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes triggerSchedule with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.TriggerScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.TriggerScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.triggerSchedule = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.triggerSchedule(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.triggerSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.triggerSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkTriggerScheduleProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkTriggerScheduleProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkTriggerScheduleProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkTriggerScheduleProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteExecution', () => { - it('invokes deleteExecution without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteExecution = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteExecution(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteExecution without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteExecution = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteExecution( - request, - (err?: Error|null, - result?: 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.deleteExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteExecution with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteExecution = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteExecution(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteExecution with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteExecution = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteExecution(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteExecutionProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteExecutionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteExecutionProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteExecutionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('createExecution', () => { - it('invokes createExecution without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateExecutionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createExecution = stubLongRunningCall(expectedResponse); - const [operation] = await client.createExecution(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createExecution without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateExecutionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createExecution = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createExecution( - request, - (err?: Error|null, - result?: 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.createExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createExecution with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateExecutionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createExecution = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createExecution(request), expectedError); - const actualRequest = (client.innerApiCalls.createExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createExecution with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateExecutionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createExecution = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createExecution(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateExecutionProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateExecutionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateExecutionProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateExecutionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listInstances', () => { - it('invokes listInstances without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); - const [response] = await client.listInstances(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstances without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInstances( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IInstance[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstances with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInstances(request), expectedError); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstancesStream without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - ]; - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1.Instance[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1.Instance) => { - 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.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listInstancesStream with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1.Instance[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInstances without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - ]; - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.notebooks.v1.IInstance[] = []; - const iterable = client.listInstancesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInstances with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInstancesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.notebooks.v1.IInstance[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listEnvironments', () => { - it('invokes listEnvironments without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - ]; - client.innerApiCalls.listEnvironments = stubSimpleCall(expectedResponse); - const [response] = await client.listEnvironments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEnvironments without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - ]; - client.innerApiCalls.listEnvironments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listEnvironments( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IEnvironment[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEnvironments with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listEnvironments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listEnvironments(request), expectedError); - const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEnvironmentsStream without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - ]; - client.descriptors.page.listEnvironments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listEnvironmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1.Environment[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1.Environment) => { - 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.listEnvironments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEnvironments, request)); - assert( - (client.descriptors.page.listEnvironments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listEnvironmentsStream with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listEnvironments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listEnvironmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1.Environment[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1.Environment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listEnvironments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEnvironments, request)); - assert( - (client.descriptors.page.listEnvironments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listEnvironments without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - ]; - client.descriptors.page.listEnvironments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.notebooks.v1.IEnvironment[] = []; - const iterable = client.listEnvironmentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listEnvironments with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listEnvironments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listEnvironmentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.notebooks.v1.IEnvironment[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listSchedules', () => { - it('invokes listSchedules without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListSchedulesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListSchedulesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - ]; - client.innerApiCalls.listSchedules = stubSimpleCall(expectedResponse); - const [response] = await client.listSchedules(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSchedules as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSchedules as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSchedules without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListSchedulesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListSchedulesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - ]; - client.innerApiCalls.listSchedules = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listSchedules( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.ISchedule[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSchedules as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSchedules as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSchedules with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListSchedulesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListSchedulesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listSchedules = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listSchedules(request), expectedError); - const actualRequest = (client.innerApiCalls.listSchedules as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSchedules as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSchedulesStream without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListSchedulesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListSchedulesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - ]; - client.descriptors.page.listSchedules.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listSchedulesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1.Schedule[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1.Schedule) => { - 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.listSchedules.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSchedules, request)); - assert( - (client.descriptors.page.listSchedules.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listSchedulesStream with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListSchedulesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListSchedulesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listSchedules.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listSchedulesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1.Schedule[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1.Schedule) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listSchedules.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSchedules, request)); - assert( - (client.descriptors.page.listSchedules.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSchedules without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListSchedulesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListSchedulesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - ]; - client.descriptors.page.listSchedules.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.notebooks.v1.ISchedule[] = []; - const iterable = client.listSchedulesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listSchedules.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSchedules.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSchedules with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListSchedulesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListSchedulesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listSchedules.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listSchedulesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.notebooks.v1.ISchedule[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listSchedules.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSchedules.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listExecutions', () => { - it('invokes listExecutions without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListExecutionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListExecutionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - ]; - client.innerApiCalls.listExecutions = stubSimpleCall(expectedResponse); - const [response] = await client.listExecutions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listExecutions without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListExecutionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListExecutionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - ]; - client.innerApiCalls.listExecutions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listExecutions( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IExecution[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listExecutions with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListExecutionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListExecutionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listExecutions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listExecutions(request), expectedError); - const actualRequest = (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listExecutionsStream without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListExecutionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListExecutionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - ]; - client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listExecutionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1.Execution[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1.Execution) => { - 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.listExecutions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); - assert( - (client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listExecutionsStream with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListExecutionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListExecutionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listExecutionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1.Execution[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1.Execution) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); - assert( - (client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listExecutions without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListExecutionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListExecutionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - ]; - client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.notebooks.v1.IExecution[] = []; - const iterable = client.listExecutionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listExecutions with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListExecutionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListExecutionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listExecutionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.notebooks.v1.IExecution[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - 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 notebookserviceModule.v1.NotebookServiceClient({ - 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 notebookserviceModule.v1.NotebookServiceClient({ - 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 notebookserviceModule.v1.NotebookServiceClient({ - 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 notebookserviceModule.v1.NotebookServiceClient({ - 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 notebookserviceModule.v1.NotebookServiceClient({ - 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 notebookserviceModule.v1.NotebookServiceClient({ - 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 notebookserviceModule.v1.NotebookServiceClient({ - 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 notebookserviceModule.v1.NotebookServiceClient({ - 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 notebookserviceModule.v1.NotebookServiceClient({ - 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 notebookserviceModule.v1.NotebookServiceClient({ - 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 notebookserviceModule.v1.NotebookServiceClient({ - 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 notebookserviceModule.v1.NotebookServiceClient({ - 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 notebookserviceModule.v1.NotebookServiceClient({ - 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 notebookserviceModule.v1.NotebookServiceClient({ - 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 notebookserviceModule.v1.NotebookServiceClient({ - 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('environment', () => { - const fakePath = "/rendered/path/environment"; - const expectedParameters = { - project: "projectValue", - environment: "environmentValue", - }; - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.environmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.environmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('environmentPath', () => { - const result = client.environmentPath("projectValue", "environmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.environmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEnvironmentName', () => { - const result = client.matchProjectFromEnvironmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEnvironmentFromEnvironmentName', () => { - const result = client.matchEnvironmentFromEnvironmentName(fakePath); - assert.strictEqual(result, "environmentValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('execution', () => { - const fakePath = "/rendered/path/execution"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - execution: "executionValue", - }; - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.executionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.executionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('executionPath', () => { - const result = client.executionPath("projectValue", "locationValue", "executionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.executionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromExecutionName', () => { - const result = client.matchProjectFromExecutionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromExecutionName', () => { - const result = client.matchLocationFromExecutionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExecutionFromExecutionName', () => { - const result = client.matchExecutionFromExecutionName(fakePath); - assert.strictEqual(result, "executionValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('instance', () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - }; - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('runtime', () => { - const fakePath = "/rendered/path/runtime"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - runtime: "runtimeValue", - }; - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.runtimePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.runtimePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('runtimePath', () => { - const result = client.runtimePath("projectValue", "locationValue", "runtimeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.runtimePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRuntimeName', () => { - const result = client.matchProjectFromRuntimeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.runtimePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRuntimeName', () => { - const result = client.matchLocationFromRuntimeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.runtimePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRuntimeFromRuntimeName', () => { - const result = client.matchRuntimeFromRuntimeName(fakePath); - assert.strictEqual(result, "runtimeValue"); - assert((client.pathTemplates.runtimePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('schedule', () => { - const fakePath = "/rendered/path/schedule"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - schedule: "scheduleValue", - }; - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.schedulePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.schedulePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('schedulePath', () => { - const result = client.schedulePath("projectValue", "locationValue", "scheduleValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.schedulePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromScheduleName', () => { - const result = client.matchProjectFromScheduleName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.schedulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromScheduleName', () => { - const result = client.matchLocationFromScheduleName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.schedulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchScheduleFromScheduleName', () => { - const result = client.matchScheduleFromScheduleName(fakePath); - assert.strictEqual(result, "scheduleValue"); - assert((client.pathTemplates.schedulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-notebooks/v1/tsconfig.json b/owl-bot-staging/google-cloud-notebooks/v1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1/webpack.config.js b/owl-bot-staging/google-cloud-notebooks/v1/webpack.config.js deleted file mode 100644 index 8b93a8e29df..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'ManagedNotebookService', - filename: './managed-notebook-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-notebooks/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-notebooks/v1beta1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-notebooks/v1beta1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/.gitignore b/owl-bot-staging/google-cloud-notebooks/v1beta1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/.jsdoc.js deleted file mode 100644 index b562faf1159..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/.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/notebooks', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/.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-notebooks/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/.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-notebooks/v1beta1/README.md b/owl-bot-staging/google-cloud-notebooks/v1beta1/README.md deleted file mode 100644 index 31cec215a8f..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Notebooks: Nodejs Client diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/package.json b/owl-bot-staging/google-cloud-notebooks/v1beta1/package.json deleted file mode 100644 index c3911a749c3..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/notebooks", - "version": "0.1.0", - "description": "Notebooks client for Node.js", - "repository": "googleapis/nodejs-notebooks", - "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 notebooks", - "notebooks", - "notebook service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/environment.proto b/owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/environment.proto deleted file mode 100644 index abe75507305..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/environment.proto +++ /dev/null @@ -1,96 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.notebooks.v1beta1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Notebooks.V1Beta1"; -option go_package = "cloud.google.com/go/notebooks/apiv1beta1/notebookspb;notebookspb"; -option java_multiple_files = true; -option java_outer_classname = "EnvironmentProto"; -option java_package = "com.google.cloud.notebooks.v1beta1"; -option php_namespace = "Google\\Cloud\\Notebooks\\V1beta1"; -option ruby_package = "Google::Cloud::Notebooks::V1beta1"; - -// Definition of a software environment that is used to start a notebook -// instance. -message Environment { - option (google.api.resource) = { - type: "notebooks.googleapis.com/Environment" - pattern: "projects/{project}/environments/{environment}" - }; - - // Output only. Name of this environment. - // Format: - // `projects/{project_id}/locations/{location}/environments/{environment_id}` - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Display name of this environment for the UI. - string display_name = 2; - - // A brief description of this environment. - string description = 3; - - // Type of the environment; can be one of VM image, or container image. - oneof image_type { - // Use a Compute Engine VM image to start the notebook instance. - VmImage vm_image = 6; - - // Use a container image to start the notebook instance. - ContainerImage container_image = 7; - } - - // Path to a Bash script that automatically runs after a notebook instance - // fully boots up. The path must be a URL or - // Cloud Storage path. Example: `"gs://path-to-file/file-name"` - string post_startup_script = 8; - - // Output only. The time at which this environment was created. - google.protobuf.Timestamp create_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Definition of a custom Compute Engine virtual machine image for starting a -// notebook instance with the environment installed directly on the VM. -message VmImage { - // Required. The name of the Google Cloud project that this VM image belongs to. - // Format: `projects/{project_id}` - string project = 1 [(google.api.field_behavior) = REQUIRED]; - - // The reference to an external Compute Engine VM image. - oneof image { - // Use VM image name to find the image. - string image_name = 2; - - // Use this VM image family to find the image; the newest image in this - // family will be used. - string image_family = 3; - } -} - -// Definition of a container image for starting a notebook instance with the -// environment installed in a container. -message ContainerImage { - // Required. The path to the container image repository. For example: - // `gcr.io/{project_id}/{image_name}` - string repository = 1 [(google.api.field_behavior) = REQUIRED]; - - // The tag of the container image. If not specified, this defaults - // to the latest tag. - string tag = 2; -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/instance.proto b/owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/instance.proto deleted file mode 100644 index 123ace8c1a1..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/instance.proto +++ /dev/null @@ -1,333 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.notebooks.v1beta1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/notebooks/v1beta1/environment.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Notebooks.V1Beta1"; -option go_package = "cloud.google.com/go/notebooks/apiv1beta1/notebookspb;notebookspb"; -option java_multiple_files = true; -option java_outer_classname = "InstanceProto"; -option java_package = "com.google.cloud.notebooks.v1beta1"; -option php_namespace = "Google\\Cloud\\Notebooks\\V1beta1"; -option ruby_package = "Google::Cloud::Notebooks::V1beta1"; - -// Reservation Affinity for consuming Zonal reservation. -message ReservationAffinity { - // Indicates whether to consume capacity from an reservation or not. - enum Type { - // Default type. - TYPE_UNSPECIFIED = 0; - - // Do not consume from any allocated capacity. - NO_RESERVATION = 1; - - // Consume any reservation available. - ANY_RESERVATION = 2; - - // Must consume from a specific reservation. Must specify key value fields - // for specifying the reservations. - SPECIFIC_RESERVATION = 3; - } - - // Optional. Type of reservation to consume - Type consume_reservation_type = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Corresponds to the label key of reservation resource. - string key = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Corresponds to the label values of reservation resource. - repeated string values = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// The definition of a notebook instance. -message Instance { - option (google.api.resource) = { - type: "notebooks.googleapis.com/Instance" - pattern: "projects/{project}/instances/{instance}" - }; - - // Definition of the types of hardware accelerators that can be used on this - // instance. - enum AcceleratorType { - // Accelerator type is not specified. - ACCELERATOR_TYPE_UNSPECIFIED = 0; - - // Accelerator type is Nvidia Tesla K80. - NVIDIA_TESLA_K80 = 1; - - // Accelerator type is Nvidia Tesla P100. - NVIDIA_TESLA_P100 = 2; - - // Accelerator type is Nvidia Tesla V100. - NVIDIA_TESLA_V100 = 3; - - // Accelerator type is Nvidia Tesla P4. - NVIDIA_TESLA_P4 = 4; - - // Accelerator type is Nvidia Tesla T4. - NVIDIA_TESLA_T4 = 5; - - // Accelerator type is NVIDIA Tesla T4 Virtual Workstations. - NVIDIA_TESLA_T4_VWS = 8; - - // Accelerator type is NVIDIA Tesla P100 Virtual Workstations. - NVIDIA_TESLA_P100_VWS = 9; - - // Accelerator type is NVIDIA Tesla P4 Virtual Workstations. - NVIDIA_TESLA_P4_VWS = 10; - - // (Coming soon) Accelerator type is TPU V2. - TPU_V2 = 6; - - // (Coming soon) Accelerator type is TPU V3. - TPU_V3 = 7; - } - - // Definition of a hardware accelerator. Note that not all combinations - // of `type` and `core_count` are valid. Check [GPUs on Compute - // Engine](https://cloud.google.com/compute/docs/gpus/#gpus-list) to find a - // valid combination. TPUs are not supported. - message AcceleratorConfig { - // Type of this accelerator. - AcceleratorType type = 1; - - // Count of cores of this accelerator. - int64 core_count = 2; - } - - // The definition of the states of this instance. - enum State { - // State is not specified. - STATE_UNSPECIFIED = 0; - - // The control logic is starting the instance. - STARTING = 1; - - // The control logic is installing required frameworks and registering the - // instance with notebook proxy - PROVISIONING = 2; - - // The instance is running. - ACTIVE = 3; - - // The control logic is stopping the instance. - STOPPING = 4; - - // The instance is stopped. - STOPPED = 5; - - // The instance is deleted. - DELETED = 6; - - // The instance is upgrading. - UPGRADING = 7; - - // The instance is being created. - INITIALIZING = 8; - - // The instance is getting registered. - REGISTERING = 9; - - // The instance is suspending. - SUSPENDING = 10; - - // The instance is suspended. - SUSPENDED = 11; - } - - // Possible disk types for notebook instances. - enum DiskType { - // Disk type not set. - DISK_TYPE_UNSPECIFIED = 0; - - // Standard persistent disk type. - PD_STANDARD = 1; - - // SSD persistent disk type. - PD_SSD = 2; - - // Balanced persistent disk type. - PD_BALANCED = 3; - } - - // Definition of the disk encryption options. - enum DiskEncryption { - // Disk encryption is not specified. - DISK_ENCRYPTION_UNSPECIFIED = 0; - - // Use Google managed encryption keys to encrypt the boot disk. - GMEK = 1; - - // Use customer managed encryption keys to encrypt the boot disk. - CMEK = 2; - } - - // The type of vNIC driver. - enum NicType { - // No type specified. Default should be UNSPECIFIED_NIC_TYPE. - UNSPECIFIED_NIC_TYPE = 0; - - // VIRTIO. Default in Notebooks DLVM. - VIRTIO_NET = 1; - - // GVNIC. Alternative to VIRTIO. - // https://github.com/GoogleCloudPlatform/compute-virtual-ethernet-linux - GVNIC = 2; - } - - // Output only. The name of this notebook instance. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Type of the environment; can be one of VM image, or container image. - oneof environment { - // Use a Compute Engine VM image to start the notebook instance. - VmImage vm_image = 2; - - // Use a container image to start the notebook instance. - ContainerImage container_image = 3; - } - - // Path to a Bash script that automatically runs after a notebook instance - // fully boots up. The path must be a URL or - // Cloud Storage path (`gs://path-to-file/file-name`). - string post_startup_script = 4; - - // Output only. The proxy endpoint that is used to access the Jupyter notebook. - string proxy_uri = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Input only. The owner of this instance after creation. Format: `alias@example.com` - // - // Currently supports one owner only. If not specified, all of the service - // account users of your VM instance's service account can use - // the instance. - repeated string instance_owners = 6 [(google.api.field_behavior) = INPUT_ONLY]; - - // The service account on this instance, giving access to other Google - // Cloud services. - // You can use any service account within the same project, but you - // must have the service account user permission to use the instance. - // - // If not specified, the [Compute Engine default service - // account](https://cloud.google.com/compute/docs/access/service-accounts#default_service_account) - // is used. - string service_account = 7; - - // Required. The [Compute Engine machine - // type](https://cloud.google.com/compute/docs/machine-types) of this - // instance. - string machine_type = 8 [(google.api.field_behavior) = REQUIRED]; - - // The hardware accelerator used on this instance. If you use - // accelerators, make sure that your configuration has - // [enough vCPUs and memory to support the `machine_type` you have - // selected](https://cloud.google.com/compute/docs/gpus/#gpus-list). - AcceleratorConfig accelerator_config = 9; - - // Output only. The state of this instance. - State state = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Whether the end user authorizes Google Cloud to install GPU driver - // on this instance. - // If this field is empty or set to false, the GPU driver won't be installed. - // Only applicable to instances with GPUs. - bool install_gpu_driver = 11; - - // Specify a custom Cloud Storage path where the GPU driver is stored. - // If not specified, we'll automatically choose from official GPU drivers. - string custom_gpu_driver_path = 12; - - // Input only. The type of the boot disk attached to this instance, defaults to - // standard persistent disk (`PD_STANDARD`). - DiskType boot_disk_type = 13 [(google.api.field_behavior) = INPUT_ONLY]; - - // Input only. The size of the boot disk in GB attached to this instance, up to a maximum - // of 64000 GB (64 TB). The minimum recommended value is 100 GB. If not - // specified, this defaults to 100. - int64 boot_disk_size_gb = 14 [(google.api.field_behavior) = INPUT_ONLY]; - - // Input only. The type of the data disk attached to this instance, defaults to - // standard persistent disk (`PD_STANDARD`). - DiskType data_disk_type = 25 [(google.api.field_behavior) = INPUT_ONLY]; - - // Input only. The size of the data disk in GB attached to this instance, up to a maximum - // of 64000 GB (64 TB). You can choose the size of the data disk based on how - // big your notebooks and data are. If not specified, this defaults to 100. - int64 data_disk_size_gb = 26 [(google.api.field_behavior) = INPUT_ONLY]; - - // Input only. If true, the data disk will not be auto deleted when deleting the instance. - bool no_remove_data_disk = 27 [(google.api.field_behavior) = INPUT_ONLY]; - - // Input only. Disk encryption method used on the boot and data disks, defaults to GMEK. - DiskEncryption disk_encryption = 15 [(google.api.field_behavior) = INPUT_ONLY]; - - // Input only. The KMS key used to encrypt the disks, only applicable if disk_encryption - // is CMEK. - // Format: - // `projects/{project_id}/locations/{location}/keyRings/{key_ring_id}/cryptoKeys/{key_id}` - // - // Learn more about [using your own encryption - // keys](https://cloud.google.com/kms/docs/quickstart). - string kms_key = 16 [(google.api.field_behavior) = INPUT_ONLY]; - - // If true, no public IP will be assigned to this instance. - bool no_public_ip = 17; - - // If true, the notebook instance will not register with the proxy. - bool no_proxy_access = 18; - - // The name of the VPC that this instance is in. - // Format: - // `projects/{project_id}/global/networks/{network_id}` - string network = 19; - - // The name of the subnet that this instance is in. - // Format: - // `projects/{project_id}/regions/{region}/subnetworks/{subnetwork_id}` - string subnet = 20; - - // Labels to apply to this instance. - // These can be later modified by the setLabels method. - map labels = 21; - - // Custom metadata to apply to this instance. - map metadata = 22; - - // Optional. The type of vNIC to be used on this interface. This may be gVNIC or - // VirtioNet. - NicType nic_type = 28 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The optional reservation affinity. Setting this field will apply - // the specified [Zonal Compute - // Reservation](https://cloud.google.com/compute/docs/instances/reserving-zonal-resources) - // to this notebook instance. - ReservationAffinity reservation_affinity = 29 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Flag to enable ip forwarding or not, default false/off. - // https://cloud.google.com/vpc/docs/using-routes#canipforward - bool can_ip_forward = 31 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. Instance creation time. - google.protobuf.Timestamp create_time = 23 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Instance update time. - google.protobuf.Timestamp update_time = 24 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/service.proto b/owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/service.proto deleted file mode 100644 index 57dfe2f381d..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/protos/google/cloud/notebooks/v1beta1/service.proto +++ /dev/null @@ -1,524 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.notebooks.v1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/notebooks/v1beta1/environment.proto"; -import "google/cloud/notebooks/v1beta1/instance.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Notebooks.V1Beta1"; -option go_package = "cloud.google.com/go/notebooks/apiv1beta1/notebookspb;notebookspb"; -option java_multiple_files = true; -option java_outer_classname = "NotebooksProto"; -option java_package = "com.google.cloud.notebooks.v1beta1"; -option php_namespace = "Google\\Cloud\\Notebooks\\V1beta1"; -option ruby_package = "Google::Cloud::Notebooks::V1beta1"; - -// API v1beta1 service for Cloud AI Platform Notebooks. -service NotebookService { - option (google.api.default_host) = "notebooks.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Lists instances in a given project and location. - rpc ListInstances(ListInstancesRequest) returns (ListInstancesResponse) { - option (google.api.http) = { - get: "/v1beta1/{parent=projects/*/locations/*}/instances" - }; - } - - // Gets details of a single Instance. - rpc GetInstance(GetInstanceRequest) returns (Instance) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/locations/*/instances/*}" - }; - } - - // Creates a new Instance in a given project and location. - rpc CreateInstance(CreateInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*/locations/*}/instances" - body: "instance" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Registers an existing legacy notebook instance to the Notebooks API server. - // Legacy instances are instances created with the legacy Compute Engine - // calls. They are not manageable by the Notebooks API out of the box. This - // call makes these instances manageable by the Notebooks API. - rpc RegisterInstance(RegisterInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*/locations/*}/instances:register" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Updates the guest accelerators of a single Instance. - rpc SetInstanceAccelerator(SetInstanceAcceleratorRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1beta1/{name=projects/*/locations/*/instances/*}:setAccelerator" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Updates the machine type of a single Instance. - rpc SetInstanceMachineType(SetInstanceMachineTypeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1beta1/{name=projects/*/locations/*/instances/*}:setMachineType" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Updates the labels of an Instance. - rpc SetInstanceLabels(SetInstanceLabelsRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1beta1/{name=projects/*/locations/*/instances/*}:setLabels" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Deletes a single Instance. - rpc DeleteInstance(DeleteInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1beta1/{name=projects/*/locations/*/instances/*}" - }; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "OperationMetadata" - }; - } - - // Starts a notebook instance. - rpc StartInstance(StartInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/instances/*}:start" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Stops a notebook instance. - rpc StopInstance(StopInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/instances/*}:stop" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Resets a notebook instance. - rpc ResetInstance(ResetInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/instances/*}:reset" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Allows notebook instances to - // report their latest instance information to the Notebooks - // API server. The server will merge the reported information to - // the instance metadata store. Do not use this method directly. - rpc ReportInstanceInfo(ReportInstanceInfoRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/instances/*}:report" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Check if a notebook instance is upgradable. - // Deprecated. Please consider using v1. - rpc IsInstanceUpgradeable(IsInstanceUpgradeableRequest) returns (IsInstanceUpgradeableResponse) { - option deprecated = true; - option (google.api.http) = { - get: "/v1beta1/{notebook_instance=projects/*/locations/*/instances/*}:isUpgradeable" - }; - } - - // Upgrades a notebook instance to the latest version. - // Deprecated. Please consider using v1. - rpc UpgradeInstance(UpgradeInstanceRequest) returns (google.longrunning.Operation) { - option deprecated = true; - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/instances/*}:upgrade" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Allows notebook instances to - // call this endpoint to upgrade themselves. Do not use this method directly. - // Deprecated. Please consider using v1. - rpc UpgradeInstanceInternal(UpgradeInstanceInternalRequest) returns (google.longrunning.Operation) { - option deprecated = true; - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/instances/*}:upgradeInternal" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Lists environments in a project. - rpc ListEnvironments(ListEnvironmentsRequest) returns (ListEnvironmentsResponse) { - option (google.api.http) = { - get: "/v1beta1/{parent=projects/*/locations/*}/environments" - }; - } - - // Gets details of a single Environment. - rpc GetEnvironment(GetEnvironmentRequest) returns (Environment) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/locations/*/environments/*}" - }; - } - - // Creates a new Environment. - rpc CreateEnvironment(CreateEnvironmentRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*/locations/*}/environments" - body: "environment" - }; - option (google.longrunning.operation_info) = { - response_type: "Environment" - metadata_type: "OperationMetadata" - }; - } - - // Deletes a single Environment. - rpc DeleteEnvironment(DeleteEnvironmentRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1beta1/{name=projects/*/locations/*/environments/*}" - }; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "OperationMetadata" - }; - } -} - -// Represents the metadata of the long-running operation. -message OperationMetadata { - // The time the operation was created. - google.protobuf.Timestamp create_time = 1; - - // The time the operation finished running. - google.protobuf.Timestamp end_time = 2; - - // Server-defined resource path for the target of the operation. - string target = 3; - - // Name of the verb executed by the operation. - string verb = 4; - - // Human-readable status of the operation, if any. - string status_message = 5; - - // Identifies whether the user has requested cancellation - // of the operation. Operations that have successfully been cancelled - // have [Operation.error][] value with a - // [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`. - bool requested_cancellation = 6; - - // API version used to start the operation. - string api_version = 7; - - // API endpoint name of this operation. - string endpoint = 8; -} - -// Request for listing notebook instances. -message ListInstancesRequest { - // Required. Format: - // `parent=projects/{project_id}/locations/{location}` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Maximum return size of the list call. - int32 page_size = 2; - - // A previous returned page token that can be used to continue listing - // from the last result. - string page_token = 3; -} - -// Response for listing notebook instances. -message ListInstancesResponse { - // A list of returned instances. - repeated Instance instances = 1; - - // Page token that can be used to continue listing from the last result in the - // next list call. - string next_page_token = 2; - - // Locations that could not be reached. For example, - // `['us-west1-a', 'us-central1-b']`. - // A ListInstancesResponse will only contain either instances or unreachables, - repeated string unreachable = 3; -} - -// Request for getting a notebook instance. -message GetInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for creating a notebook instance. -message CreateInstanceRequest { - // Required. Format: - // `parent=projects/{project_id}/locations/{location}` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. User-defined unique ID of this instance. - string instance_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The instance to be created. - Instance instance = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for registering a notebook instance. -message RegisterInstanceRequest { - // Required. Format: - // `parent=projects/{project_id}/locations/{location}` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. User defined unique ID of this instance. The `instance_id` must - // be 1 to 63 characters long and contain only lowercase letters, - // numeric characters, and dashes. The first character must be a lowercase - // letter and the last character cannot be a dash. - string instance_id = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for setting instance accelerator. -message SetInstanceAcceleratorRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Type of this accelerator. - Instance.AcceleratorType type = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. Count of cores of this accelerator. Note that not all combinations - // of `type` and `core_count` are valid. Check [GPUs on - // Compute Engine](https://cloud.google.com/compute/docs/gpus/#gpus-list) to - // find a valid combination. TPUs are not supported. - int64 core_count = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for setting instance machine type. -message SetInstanceMachineTypeRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The [Compute Engine machine - // type](https://cloud.google.com/compute/docs/machine-types). - string machine_type = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for setting instance labels. -message SetInstanceLabelsRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Labels to apply to this instance. - // These can be later modified by the setLabels method - map labels = 2; -} - -// Request for deleting a notebook instance. -message DeleteInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for starting a notebook instance -message StartInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for stopping a notebook instance -message StopInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for reseting a notebook instance -message ResetInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for notebook instances to report information to Notebooks API. -message ReportInstanceInfoRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The VM hardware token for authenticating the VM. - // https://cloud.google.com/compute/docs/instances/verifying-instance-identity - string vm_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // The metadata reported to Notebooks API. This will be merged to the instance - // metadata store - map metadata = 3; -} - -// Request for checking if a notebook instance is upgradeable. -message IsInstanceUpgradeableRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string notebook_instance = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response for checking if a notebook instance is upgradeable. -message IsInstanceUpgradeableResponse { - // If an instance is upgradeable. - bool upgradeable = 1; - - // The version this instance will be upgraded to if calling the upgrade - // endpoint. This field will only be populated if field upgradeable is true. - string upgrade_version = 2; - - // Additional information about upgrade. - string upgrade_info = 3; - - // The new image self link this instance will be upgraded to if calling the - // upgrade endpoint. This field will only be populated if field upgradeable - // is true. - string upgrade_image = 4; -} - -// Request for upgrading a notebook instance -message UpgradeInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for upgrading a notebook instance from within the VM -message UpgradeInstanceInternalRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The VM hardware token for authenticating the VM. - // https://cloud.google.com/compute/docs/instances/verifying-instance-identity - string vm_id = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for listing environments. -message ListEnvironmentsRequest { - // Required. Format: `projects/{project_id}/locations/{location}` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Maximum return size of the list call. - int32 page_size = 2; - - // A previous returned page token that can be used to continue listing from - // the last result. - string page_token = 3; -} - -// Response for listing environments. -message ListEnvironmentsResponse { - // A list of returned environments. - repeated Environment environments = 1; - - // A page token that can be used to continue listing from the last result - // in the next list call. - string next_page_token = 2; - - // Locations that could not be reached. - repeated string unreachable = 3; -} - -// Request for getting a notebook environment. -message GetEnvironmentRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/environments/{environment_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for creating a notebook environment. -message CreateEnvironmentRequest { - // Required. Format: `projects/{project_id}/locations/{location}` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. User-defined unique ID of this environment. The `environment_id` must - // be 1 to 63 characters long and contain only lowercase letters, - // numeric characters, and dashes. The first character must be a lowercase - // letter and the last character cannot be a dash. - string environment_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The environment to be created. - Environment environment = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for deleting a notebook environment. -message DeleteEnvironmentRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/environments/{environment_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.create_environment.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.create_environment.js deleted file mode 100644 index 8ce3685c35e..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.create_environment.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, environmentId, environment) { - // [START notebooks_v1beta1_generated_NotebookService_CreateEnvironment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: `projects/{project_id}/locations/{location}` - */ - // const parent = 'abc123' - /** - * Required. User-defined unique ID of this environment. The `environment_id` must - * be 1 to 63 characters long and contain only lowercase letters, - * numeric characters, and dashes. The first character must be a lowercase - * letter and the last character cannot be a dash. - */ - // const environmentId = 'abc123' - /** - * Required. The environment to be created. - */ - // const environment = {} - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callCreateEnvironment() { - // Construct request - const request = { - parent, - environmentId, - environment, - }; - - // Run request - const [operation] = await notebooksClient.createEnvironment(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateEnvironment(); - // [END notebooks_v1beta1_generated_NotebookService_CreateEnvironment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.create_instance.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.create_instance.js deleted file mode 100644 index bed48c95939..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.create_instance.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(parent, instanceId, instance) { - // [START notebooks_v1beta1_generated_NotebookService_CreateInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - */ - // const parent = 'abc123' - /** - * Required. User-defined unique ID of this instance. - */ - // const instanceId = 'abc123' - /** - * Required. The instance to be created. - */ - // const instance = {} - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callCreateInstance() { - // Construct request - const request = { - parent, - instanceId, - instance, - }; - - // Run request - const [operation] = await notebooksClient.createInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateInstance(); - // [END notebooks_v1beta1_generated_NotebookService_CreateInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.delete_environment.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.delete_environment.js deleted file mode 100644 index 32a94e35a7c..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.delete_environment.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 notebooks_v1beta1_generated_NotebookService_DeleteEnvironment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/environments/{environment_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callDeleteEnvironment() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.deleteEnvironment(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteEnvironment(); - // [END notebooks_v1beta1_generated_NotebookService_DeleteEnvironment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.delete_instance.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.delete_instance.js deleted file mode 100644 index eb82d4cfcb7..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.delete_instance.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 notebooks_v1beta1_generated_NotebookService_DeleteInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callDeleteInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.deleteInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteInstance(); - // [END notebooks_v1beta1_generated_NotebookService_DeleteInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.get_environment.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.get_environment.js deleted file mode 100644 index 7c2709563bb..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.get_environment.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 notebooks_v1beta1_generated_NotebookService_GetEnvironment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/environments/{environment_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callGetEnvironment() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await notebooksClient.getEnvironment(request); - console.log(response); - } - - callGetEnvironment(); - // [END notebooks_v1beta1_generated_NotebookService_GetEnvironment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.get_instance.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.get_instance.js deleted file mode 100644 index e8259ff7579..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.get_instance.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 notebooks_v1beta1_generated_NotebookService_GetInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callGetInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await notebooksClient.getInstance(request); - console.log(response); - } - - callGetInstance(); - // [END notebooks_v1beta1_generated_NotebookService_GetInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.is_instance_upgradeable.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.is_instance_upgradeable.js deleted file mode 100644 index 0062600b6d5..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.is_instance_upgradeable.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(notebookInstance) { - // [START notebooks_v1beta1_generated_NotebookService_IsInstanceUpgradeable_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const notebookInstance = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callIsInstanceUpgradeable() { - // Construct request - const request = { - notebookInstance, - }; - - // Run request - const response = await notebooksClient.isInstanceUpgradeable(request); - console.log(response); - } - - callIsInstanceUpgradeable(); - // [END notebooks_v1beta1_generated_NotebookService_IsInstanceUpgradeable_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.list_environments.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.list_environments.js deleted file mode 100644 index 2b45b6f6403..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.list_environments.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) { - // [START notebooks_v1beta1_generated_NotebookService_ListEnvironments_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: `projects/{project_id}/locations/{location}` - */ - // const parent = 'abc123' - /** - * Maximum return size of the list call. - */ - // const pageSize = 1234 - /** - * A previous returned page token that can be used to continue listing from - * the last result. - */ - // const pageToken = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callListEnvironments() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await notebooksClient.listEnvironmentsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListEnvironments(); - // [END notebooks_v1beta1_generated_NotebookService_ListEnvironments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.list_instances.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.list_instances.js deleted file mode 100644 index 1d74cc1e390..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.list_instances.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(parent) { - // [START notebooks_v1beta1_generated_NotebookService_ListInstances_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - */ - // const parent = 'abc123' - /** - * Maximum return size of the list call. - */ - // const pageSize = 1234 - /** - * A previous returned page token that can be used to continue listing - * from the last result. - */ - // const pageToken = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callListInstances() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await notebooksClient.listInstancesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListInstances(); - // [END notebooks_v1beta1_generated_NotebookService_ListInstances_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.register_instance.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.register_instance.js deleted file mode 100644 index b8aacbe7688..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.register_instance.js +++ /dev/null @@ -1,71 +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, instanceId) { - // [START notebooks_v1beta1_generated_NotebookService_RegisterInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - */ - // const parent = 'abc123' - /** - * Required. User defined unique ID of this instance. The `instance_id` must - * be 1 to 63 characters long and contain only lowercase letters, - * numeric characters, and dashes. The first character must be a lowercase - * letter and the last character cannot be a dash. - */ - // const instanceId = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callRegisterInstance() { - // Construct request - const request = { - parent, - instanceId, - }; - - // Run request - const [operation] = await notebooksClient.registerInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRegisterInstance(); - // [END notebooks_v1beta1_generated_NotebookService_RegisterInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.report_instance_info.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.report_instance_info.js deleted file mode 100644 index baddddb82a0..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.report_instance_info.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(name, vmId) { - // [START notebooks_v1beta1_generated_NotebookService_ReportInstanceInfo_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - /** - * Required. The VM hardware token for authenticating the VM. - * https://cloud.google.com/compute/docs/instances/verifying-instance-identity - */ - // const vmId = 'abc123' - /** - * The metadata reported to Notebooks API. This will be merged to the instance - * metadata store - */ - // const metadata = [1,2,3,4] - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callReportInstanceInfo() { - // Construct request - const request = { - name, - vmId, - }; - - // Run request - const [operation] = await notebooksClient.reportInstanceInfo(request); - const [response] = await operation.promise(); - console.log(response); - } - - callReportInstanceInfo(); - // [END notebooks_v1beta1_generated_NotebookService_ReportInstanceInfo_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.reset_instance.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.reset_instance.js deleted file mode 100644 index 8edc3b234cd..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.reset_instance.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 notebooks_v1beta1_generated_NotebookService_ResetInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callResetInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.resetInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callResetInstance(); - // [END notebooks_v1beta1_generated_NotebookService_ResetInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_accelerator.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_accelerator.js deleted file mode 100644 index 83a8cb9963e..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_accelerator.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(name, type, coreCount) { - // [START notebooks_v1beta1_generated_NotebookService_SetInstanceAccelerator_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - /** - * Required. Type of this accelerator. - */ - // const type = {} - /** - * Required. Count of cores of this accelerator. Note that not all combinations - * of `type` and `core_count` are valid. Check GPUs on - * Compute Engine (https://cloud.google.com/compute/docs/gpus/#gpus-list) to - * find a valid combination. TPUs are not supported. - */ - // const coreCount = 1234 - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callSetInstanceAccelerator() { - // Construct request - const request = { - name, - type, - coreCount, - }; - - // Run request - const [operation] = await notebooksClient.setInstanceAccelerator(request); - const [response] = await operation.promise(); - console.log(response); - } - - callSetInstanceAccelerator(); - // [END notebooks_v1beta1_generated_NotebookService_SetInstanceAccelerator_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_labels.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_labels.js deleted file mode 100644 index 285697d9fe0..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_labels.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 notebooks_v1beta1_generated_NotebookService_SetInstanceLabels_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - /** - * Labels to apply to this instance. - * These can be later modified by the setLabels method - */ - // const labels = [1,2,3,4] - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callSetInstanceLabels() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.setInstanceLabels(request); - const [response] = await operation.promise(); - console.log(response); - } - - callSetInstanceLabels(); - // [END notebooks_v1beta1_generated_NotebookService_SetInstanceLabels_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_machine_type.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_machine_type.js deleted file mode 100644 index d8ca6a3d2a2..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.set_instance_machine_type.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(name, machineType) { - // [START notebooks_v1beta1_generated_NotebookService_SetInstanceMachineType_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - /** - * Required. The Compute Engine machine - * type (https://cloud.google.com/compute/docs/machine-types). - */ - // const machineType = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callSetInstanceMachineType() { - // Construct request - const request = { - name, - machineType, - }; - - // Run request - const [operation] = await notebooksClient.setInstanceMachineType(request); - const [response] = await operation.promise(); - console.log(response); - } - - callSetInstanceMachineType(); - // [END notebooks_v1beta1_generated_NotebookService_SetInstanceMachineType_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.start_instance.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.start_instance.js deleted file mode 100644 index 683ea73caac..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.start_instance.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 notebooks_v1beta1_generated_NotebookService_StartInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callStartInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.startInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callStartInstance(); - // [END notebooks_v1beta1_generated_NotebookService_StartInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.stop_instance.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.stop_instance.js deleted file mode 100644 index ce9ff135eb7..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.stop_instance.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 notebooks_v1beta1_generated_NotebookService_StopInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callStopInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.stopInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callStopInstance(); - // [END notebooks_v1beta1_generated_NotebookService_StopInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.upgrade_instance.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.upgrade_instance.js deleted file mode 100644 index 16d68328574..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.upgrade_instance.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 notebooks_v1beta1_generated_NotebookService_UpgradeInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callUpgradeInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.upgradeInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpgradeInstance(); - // [END notebooks_v1beta1_generated_NotebookService_UpgradeInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.upgrade_instance_internal.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.upgrade_instance_internal.js deleted file mode 100644 index 9c967ae9616..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/notebook_service.upgrade_instance_internal.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(name, vmId) { - // [START notebooks_v1beta1_generated_NotebookService_UpgradeInstanceInternal_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - /** - * Required. The VM hardware token for authenticating the VM. - * https://cloud.google.com/compute/docs/instances/verifying-instance-identity - */ - // const vmId = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v1beta1; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callUpgradeInstanceInternal() { - // Construct request - const request = { - name, - vmId, - }; - - // Run request - const [operation] = await notebooksClient.upgradeInstanceInternal(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpgradeInstanceInternal(); - // [END notebooks_v1beta1_generated_NotebookService_UpgradeInstanceInternal_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.notebooks.v1beta1.json b/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.notebooks.v1beta1.json deleted file mode 100644 index e4feeb81fd3..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.notebooks.v1beta1.json +++ /dev/null @@ -1,839 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-notebooks", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.notebooks.v1beta1", - "version": "v1beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "notebooks_v1beta1_generated_NotebookService_ListInstances_async", - "title": "NotebookService listInstances Sample", - "origin": "API_DEFINITION", - "description": " Lists instances in a given project and location.", - "canonical": true, - "file": "notebook_service.list_instances.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListInstances", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.ListInstances", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.notebooks.v1beta1.ListInstancesResponse", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" - }, - "method": { - "shortName": "ListInstances", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.ListInstances", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1beta1_generated_NotebookService_GetInstance_async", - "title": "NotebookService getInstance Sample", - "origin": "API_DEFINITION", - "description": " Gets details of a single Instance.", - "canonical": true, - "file": "notebook_service.get_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetInstance", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.GetInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.notebooks.v1beta1.Instance", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" - }, - "method": { - "shortName": "GetInstance", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.GetInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1beta1_generated_NotebookService_CreateInstance_async", - "title": "NotebookService createInstance Sample", - "origin": "API_DEFINITION", - "description": " Creates a new Instance in a given project and location.", - "canonical": true, - "file": "notebook_service.create_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateInstance", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.CreateInstance", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "instance_id", - "type": "TYPE_STRING" - }, - { - "name": "instance", - "type": ".google.cloud.notebooks.v1beta1.Instance" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" - }, - "method": { - "shortName": "CreateInstance", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.CreateInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1beta1_generated_NotebookService_RegisterInstance_async", - "title": "NotebookService registerInstance Sample", - "origin": "API_DEFINITION", - "description": " Registers an existing legacy notebook instance to the Notebooks API server. Legacy instances are instances created with the legacy Compute Engine calls. They are not manageable by the Notebooks API out of the box. This call makes these instances manageable by the Notebooks API.", - "canonical": true, - "file": "notebook_service.register_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RegisterInstance", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.RegisterInstance", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "instance_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" - }, - "method": { - "shortName": "RegisterInstance", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.RegisterInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1beta1_generated_NotebookService_SetInstanceAccelerator_async", - "title": "NotebookService setInstanceAccelerator Sample", - "origin": "API_DEFINITION", - "description": " Updates the guest accelerators of a single Instance.", - "canonical": true, - "file": "notebook_service.set_instance_accelerator.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetInstanceAccelerator", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.SetInstanceAccelerator", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "type", - "type": ".google.cloud.notebooks.v1beta1.Instance.AcceleratorType" - }, - { - "name": "core_count", - "type": "TYPE_INT64" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" - }, - "method": { - "shortName": "SetInstanceAccelerator", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.SetInstanceAccelerator", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1beta1_generated_NotebookService_SetInstanceMachineType_async", - "title": "NotebookService setInstanceMachineType Sample", - "origin": "API_DEFINITION", - "description": " Updates the machine type of a single Instance.", - "canonical": true, - "file": "notebook_service.set_instance_machine_type.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetInstanceMachineType", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.SetInstanceMachineType", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "machine_type", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" - }, - "method": { - "shortName": "SetInstanceMachineType", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.SetInstanceMachineType", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1beta1_generated_NotebookService_SetInstanceLabels_async", - "title": "NotebookService setInstanceLabels Sample", - "origin": "API_DEFINITION", - "description": " Updates the labels of an Instance.", - "canonical": true, - "file": "notebook_service.set_instance_labels.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetInstanceLabels", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.SetInstanceLabels", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "labels", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" - }, - "method": { - "shortName": "SetInstanceLabels", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.SetInstanceLabels", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1beta1_generated_NotebookService_DeleteInstance_async", - "title": "NotebookService deleteInstance Sample", - "origin": "API_DEFINITION", - "description": " Deletes a single Instance.", - "canonical": true, - "file": "notebook_service.delete_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteInstance", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.DeleteInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" - }, - "method": { - "shortName": "DeleteInstance", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.DeleteInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1beta1_generated_NotebookService_StartInstance_async", - "title": "NotebookService startInstance Sample", - "origin": "API_DEFINITION", - "description": " Starts a notebook instance.", - "canonical": true, - "file": "notebook_service.start_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "StartInstance", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.StartInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" - }, - "method": { - "shortName": "StartInstance", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.StartInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1beta1_generated_NotebookService_StopInstance_async", - "title": "NotebookService stopInstance Sample", - "origin": "API_DEFINITION", - "description": " Stops a notebook instance.", - "canonical": true, - "file": "notebook_service.stop_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "StopInstance", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.StopInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" - }, - "method": { - "shortName": "StopInstance", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.StopInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1beta1_generated_NotebookService_ResetInstance_async", - "title": "NotebookService resetInstance Sample", - "origin": "API_DEFINITION", - "description": " Resets a notebook instance.", - "canonical": true, - "file": "notebook_service.reset_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ResetInstance", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.ResetInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" - }, - "method": { - "shortName": "ResetInstance", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.ResetInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1beta1_generated_NotebookService_ReportInstanceInfo_async", - "title": "NotebookService reportInstanceInfo Sample", - "origin": "API_DEFINITION", - "description": " Allows notebook instances to report their latest instance information to the Notebooks API server. The server will merge the reported information to the instance metadata store. Do not use this method directly.", - "canonical": true, - "file": "notebook_service.report_instance_info.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ReportInstanceInfo", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.ReportInstanceInfo", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "vm_id", - "type": "TYPE_STRING" - }, - { - "name": "metadata", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" - }, - "method": { - "shortName": "ReportInstanceInfo", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.ReportInstanceInfo", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1beta1_generated_NotebookService_IsInstanceUpgradeable_async", - "title": "NotebookService isInstanceUpgradeable Sample", - "origin": "API_DEFINITION", - "description": " Check if a notebook instance is upgradable. Deprecated. Please consider using v1.", - "canonical": true, - "file": "notebook_service.is_instance_upgradeable.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "IsInstanceUpgradeable", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.IsInstanceUpgradeable", - "async": true, - "parameters": [ - { - "name": "notebook_instance", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.notebooks.v1beta1.IsInstanceUpgradeableResponse", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" - }, - "method": { - "shortName": "IsInstanceUpgradeable", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.IsInstanceUpgradeable", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1beta1_generated_NotebookService_UpgradeInstance_async", - "title": "NotebookService upgradeInstance Sample", - "origin": "API_DEFINITION", - "description": " Upgrades a notebook instance to the latest version. Deprecated. Please consider using v1.", - "canonical": true, - "file": "notebook_service.upgrade_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpgradeInstance", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.UpgradeInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" - }, - "method": { - "shortName": "UpgradeInstance", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.UpgradeInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1beta1_generated_NotebookService_UpgradeInstanceInternal_async", - "title": "NotebookService upgradeInstanceInternal Sample", - "origin": "API_DEFINITION", - "description": " Allows notebook instances to call this endpoint to upgrade themselves. Do not use this method directly. Deprecated. Please consider using v1.", - "canonical": true, - "file": "notebook_service.upgrade_instance_internal.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpgradeInstanceInternal", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.UpgradeInstanceInternal", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "vm_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" - }, - "method": { - "shortName": "UpgradeInstanceInternal", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.UpgradeInstanceInternal", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1beta1_generated_NotebookService_ListEnvironments_async", - "title": "NotebookService listEnvironments Sample", - "origin": "API_DEFINITION", - "description": " Lists environments in a project.", - "canonical": true, - "file": "notebook_service.list_environments.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListEnvironments", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.ListEnvironments", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.notebooks.v1beta1.ListEnvironmentsResponse", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" - }, - "method": { - "shortName": "ListEnvironments", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.ListEnvironments", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1beta1_generated_NotebookService_GetEnvironment_async", - "title": "NotebookService getEnvironment Sample", - "origin": "API_DEFINITION", - "description": " Gets details of a single Environment.", - "canonical": true, - "file": "notebook_service.get_environment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetEnvironment", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.GetEnvironment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.notebooks.v1beta1.Environment", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" - }, - "method": { - "shortName": "GetEnvironment", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.GetEnvironment", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1beta1_generated_NotebookService_CreateEnvironment_async", - "title": "NotebookService createEnvironment Sample", - "origin": "API_DEFINITION", - "description": " Creates a new Environment.", - "canonical": true, - "file": "notebook_service.create_environment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateEnvironment", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.CreateEnvironment", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "environment_id", - "type": "TYPE_STRING" - }, - { - "name": "environment", - "type": ".google.cloud.notebooks.v1beta1.Environment" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" - }, - "method": { - "shortName": "CreateEnvironment", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.CreateEnvironment", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v1beta1_generated_NotebookService_DeleteEnvironment_async", - "title": "NotebookService deleteEnvironment Sample", - "origin": "API_DEFINITION", - "description": " Deletes a single Environment.", - "canonical": true, - "file": "notebook_service.delete_environment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteEnvironment", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.DeleteEnvironment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v1beta1.NotebookServiceClient" - }, - "method": { - "shortName": "DeleteEnvironment", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService.DeleteEnvironment", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v1beta1.NotebookService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-notebooks/v1beta1/src/index.ts deleted file mode 100644 index e46a09175ed..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/src/index.ts +++ /dev/null @@ -1,25 +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 v1beta1 from './v1beta1'; -const NotebookServiceClient = v1beta1.NotebookServiceClient; -type NotebookServiceClient = v1beta1.NotebookServiceClient; -export {v1beta1, NotebookServiceClient}; -export default {v1beta1, NotebookServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/gapic_metadata.json deleted file mode 100644 index 4a231d3bb35..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/gapic_metadata.json +++ /dev/null @@ -1,221 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.notebooks.v1beta1", - "libraryPackage": "@google-cloud/notebooks", - "services": { - "NotebookService": { - "clients": { - "grpc": { - "libraryClient": "NotebookServiceClient", - "rpcs": { - "GetInstance": { - "methods": [ - "getInstance" - ] - }, - "IsInstanceUpgradeable": { - "methods": [ - "isInstanceUpgradeable" - ] - }, - "GetEnvironment": { - "methods": [ - "getEnvironment" - ] - }, - "CreateInstance": { - "methods": [ - "createInstance" - ] - }, - "RegisterInstance": { - "methods": [ - "registerInstance" - ] - }, - "SetInstanceAccelerator": { - "methods": [ - "setInstanceAccelerator" - ] - }, - "SetInstanceMachineType": { - "methods": [ - "setInstanceMachineType" - ] - }, - "SetInstanceLabels": { - "methods": [ - "setInstanceLabels" - ] - }, - "DeleteInstance": { - "methods": [ - "deleteInstance" - ] - }, - "StartInstance": { - "methods": [ - "startInstance" - ] - }, - "StopInstance": { - "methods": [ - "stopInstance" - ] - }, - "ResetInstance": { - "methods": [ - "resetInstance" - ] - }, - "ReportInstanceInfo": { - "methods": [ - "reportInstanceInfo" - ] - }, - "UpgradeInstance": { - "methods": [ - "upgradeInstance" - ] - }, - "UpgradeInstanceInternal": { - "methods": [ - "upgradeInstanceInternal" - ] - }, - "CreateEnvironment": { - "methods": [ - "createEnvironment" - ] - }, - "DeleteEnvironment": { - "methods": [ - "deleteEnvironment" - ] - }, - "ListInstances": { - "methods": [ - "listInstances", - "listInstancesStream", - "listInstancesAsync" - ] - }, - "ListEnvironments": { - "methods": [ - "listEnvironments", - "listEnvironmentsStream", - "listEnvironmentsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "NotebookServiceClient", - "rpcs": { - "GetInstance": { - "methods": [ - "getInstance" - ] - }, - "IsInstanceUpgradeable": { - "methods": [ - "isInstanceUpgradeable" - ] - }, - "GetEnvironment": { - "methods": [ - "getEnvironment" - ] - }, - "CreateInstance": { - "methods": [ - "createInstance" - ] - }, - "RegisterInstance": { - "methods": [ - "registerInstance" - ] - }, - "SetInstanceAccelerator": { - "methods": [ - "setInstanceAccelerator" - ] - }, - "SetInstanceMachineType": { - "methods": [ - "setInstanceMachineType" - ] - }, - "SetInstanceLabels": { - "methods": [ - "setInstanceLabels" - ] - }, - "DeleteInstance": { - "methods": [ - "deleteInstance" - ] - }, - "StartInstance": { - "methods": [ - "startInstance" - ] - }, - "StopInstance": { - "methods": [ - "stopInstance" - ] - }, - "ResetInstance": { - "methods": [ - "resetInstance" - ] - }, - "ReportInstanceInfo": { - "methods": [ - "reportInstanceInfo" - ] - }, - "UpgradeInstance": { - "methods": [ - "upgradeInstance" - ] - }, - "UpgradeInstanceInternal": { - "methods": [ - "upgradeInstanceInternal" - ] - }, - "CreateEnvironment": { - "methods": [ - "createEnvironment" - ] - }, - "DeleteEnvironment": { - "methods": [ - "deleteEnvironment" - ] - }, - "ListInstances": { - "methods": [ - "listInstances", - "listInstancesStream", - "listInstancesAsync" - ] - }, - "ListEnvironments": { - "methods": [ - "listEnvironments", - "listEnvironmentsStream", - "listEnvironmentsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/index.ts deleted file mode 100644 index 5f1ec6b1546..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/index.ts +++ /dev/null @@ -1,19 +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 {NotebookServiceClient} from './notebook_service_client'; diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_client.ts b/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_client.ts deleted file mode 100644 index 0a2053a2053..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_client.ts +++ /dev/null @@ -1,2818 +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, IamClient, IamProtos, 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/v1beta1/notebook_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './notebook_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * API v1beta1 service for Cloud AI Platform Notebooks. - * @class - * @memberof v1beta1 - */ -export class NotebookServiceClient { - 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}; - iamClient: IamClient; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - notebookServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of NotebookServiceClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 NotebookServiceClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof NotebookServiceClient; - 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.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - - 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 { - 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 = { - environmentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/environments/{environment}' - ), - instancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/instances/{instance}' - ), - }; - - // 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 = { - listInstances: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instances'), - listEnvironments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'environments') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1beta1/{resource=projects/*/locations/*/instances/*}:getIamPolicy',},{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1beta1/{resource=projects/*/locations/*/instances/*}:setIamPolicy',body: '*',},{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1beta1/{resource=projects/*/locations/*/instances/*}:testIamPermissions',body: '*',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta1/{name=projects/*/locations/*}/operations',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; - const createInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; - const registerInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; - const registerInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; - const setInstanceAcceleratorResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; - const setInstanceAcceleratorMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; - const setInstanceMachineTypeResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; - const setInstanceMachineTypeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; - const setInstanceLabelsResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; - const setInstanceLabelsMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; - const deleteInstanceResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; - const startInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; - const startInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; - const stopInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; - const stopInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; - const resetInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; - const resetInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; - const reportInstanceInfoResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; - const reportInstanceInfoMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; - const upgradeInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; - const upgradeInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; - const upgradeInstanceInternalResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; - const upgradeInstanceInternalMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; - const createEnvironmentResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Environment') as gax.protobuf.Type; - const createEnvironmentMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; - const deleteEnvironmentResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteEnvironmentMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createInstanceResponse.decode.bind(createInstanceResponse), - createInstanceMetadata.decode.bind(createInstanceMetadata)), - registerInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - registerInstanceResponse.decode.bind(registerInstanceResponse), - registerInstanceMetadata.decode.bind(registerInstanceMetadata)), - setInstanceAccelerator: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - setInstanceAcceleratorResponse.decode.bind(setInstanceAcceleratorResponse), - setInstanceAcceleratorMetadata.decode.bind(setInstanceAcceleratorMetadata)), - setInstanceMachineType: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - setInstanceMachineTypeResponse.decode.bind(setInstanceMachineTypeResponse), - setInstanceMachineTypeMetadata.decode.bind(setInstanceMachineTypeMetadata)), - setInstanceLabels: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - setInstanceLabelsResponse.decode.bind(setInstanceLabelsResponse), - setInstanceLabelsMetadata.decode.bind(setInstanceLabelsMetadata)), - deleteInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteInstanceResponse.decode.bind(deleteInstanceResponse), - deleteInstanceMetadata.decode.bind(deleteInstanceMetadata)), - startInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - startInstanceResponse.decode.bind(startInstanceResponse), - startInstanceMetadata.decode.bind(startInstanceMetadata)), - stopInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - stopInstanceResponse.decode.bind(stopInstanceResponse), - stopInstanceMetadata.decode.bind(stopInstanceMetadata)), - resetInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - resetInstanceResponse.decode.bind(resetInstanceResponse), - resetInstanceMetadata.decode.bind(resetInstanceMetadata)), - reportInstanceInfo: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - reportInstanceInfoResponse.decode.bind(reportInstanceInfoResponse), - reportInstanceInfoMetadata.decode.bind(reportInstanceInfoMetadata)), - upgradeInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - upgradeInstanceResponse.decode.bind(upgradeInstanceResponse), - upgradeInstanceMetadata.decode.bind(upgradeInstanceMetadata)), - upgradeInstanceInternal: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - upgradeInstanceInternalResponse.decode.bind(upgradeInstanceInternalResponse), - upgradeInstanceInternalMetadata.decode.bind(upgradeInstanceInternalMetadata)), - createEnvironment: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createEnvironmentResponse.decode.bind(createEnvironmentResponse), - createEnvironmentMetadata.decode.bind(createEnvironmentMetadata)), - deleteEnvironment: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteEnvironmentResponse.decode.bind(deleteEnvironmentResponse), - deleteEnvironmentMetadata.decode.bind(deleteEnvironmentMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.notebooks.v1beta1.NotebookService', 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.notebookServiceStub) { - return this.notebookServiceStub; - } - - // Put together the "service stub" for - // google.cloud.notebooks.v1beta1.NotebookService. - this.notebookServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.notebooks.v1beta1.NotebookService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.notebooks.v1beta1.NotebookService, - 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 notebookServiceStubMethods = - ['listInstances', 'getInstance', 'createInstance', 'registerInstance', 'setInstanceAccelerator', 'setInstanceMachineType', 'setInstanceLabels', 'deleteInstance', 'startInstance', 'stopInstance', 'resetInstance', 'reportInstanceInfo', 'isInstanceUpgradeable', 'upgradeInstance', 'upgradeInstanceInternal', 'listEnvironments', 'getEnvironment', 'createEnvironment', 'deleteEnvironment']; - for (const methodName of notebookServiceStubMethods) { - const callPromise = this.notebookServiceStub.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.notebookServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'notebooks.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 'notebooks.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 details of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1beta1.Instance|Instance}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.get_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_GetInstance_async - */ - getInstance( - request?: protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1beta1.IInstance, - protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest|undefined, {}|undefined - ]>; - getInstance( - request: protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1beta1.IInstance, - protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; - getInstance( - request: protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest, - callback: Callback< - protos.google.cloud.notebooks.v1beta1.IInstance, - protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; - getInstance( - request?: protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1beta1.IInstance, - protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.notebooks.v1beta1.IInstance, - protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1beta1.IInstance, - protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getInstance(request, options, callback); - } -/** - * Check if a notebook instance is upgradable. - * Deprecated. Please consider using v1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.notebookInstance - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableResponse|IsInstanceUpgradeableResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.is_instance_upgradeable.js - * region_tag:notebooks_v1beta1_generated_NotebookService_IsInstanceUpgradeable_async - * @deprecated IsInstanceUpgradeable is deprecated and may be removed in a future version. - */ - isInstanceUpgradeable( - request?: protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest|undefined, {}|undefined - ]>; - isInstanceUpgradeable( - request: protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest|null|undefined, - {}|null|undefined>): void; - isInstanceUpgradeable( - request: protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest, - callback: Callback< - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest|null|undefined, - {}|null|undefined>): void; - isInstanceUpgradeable( - request?: protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'notebook_instance': request.notebookInstance ?? '', - }); - this.initialize(); - this.warn('DEP$NotebookService-$IsInstanceUpgradeable','IsInstanceUpgradeable is deprecated and may be removed in a future version.', 'DeprecationWarning'); - return this.innerApiCalls.isInstanceUpgradeable(request, options, callback); - } -/** - * Gets details of a single Environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/environments/{environment_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v1beta1.Environment|Environment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.get_environment.js - * region_tag:notebooks_v1beta1_generated_NotebookService_GetEnvironment_async - */ - getEnvironment( - request?: protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1beta1.IEnvironment, - protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest|undefined, {}|undefined - ]>; - getEnvironment( - request: protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1beta1.IEnvironment, - protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>): void; - getEnvironment( - request: protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest, - callback: Callback< - protos.google.cloud.notebooks.v1beta1.IEnvironment, - protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>): void; - getEnvironment( - request?: protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1beta1.IEnvironment, - protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.notebooks.v1beta1.IEnvironment, - protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1beta1.IEnvironment, - protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getEnvironment(request, options, callback); - } - -/** - * Creates a new Instance in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {string} request.instanceId - * Required. User-defined unique ID of this instance. - * @param {google.cloud.notebooks.v1beta1.Instance} request.instance - * Required. The instance to be created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.create_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_CreateInstance_async - */ - createInstance( - request?: protos.google.cloud.notebooks.v1beta1.ICreateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createInstance( - request: protos.google.cloud.notebooks.v1beta1.ICreateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createInstance( - request: protos.google.cloud.notebooks.v1beta1.ICreateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createInstance( - request?: protos.google.cloud.notebooks.v1beta1.ICreateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.create_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_CreateInstance_async - */ - async checkCreateInstanceProgress(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.createInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Registers an existing legacy notebook instance to the Notebooks API server. - * Legacy instances are instances created with the legacy Compute Engine - * calls. They are not manageable by the Notebooks API out of the box. This - * call makes these instances manageable by the Notebooks API. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {string} request.instanceId - * Required. User defined unique ID of this instance. The `instance_id` must - * be 1 to 63 characters long and contain only lowercase letters, - * numeric characters, and dashes. The first character must be a lowercase - * letter and the last character cannot be a dash. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.register_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_RegisterInstance_async - */ - registerInstance( - request?: protos.google.cloud.notebooks.v1beta1.IRegisterInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - registerInstance( - request: protos.google.cloud.notebooks.v1beta1.IRegisterInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - registerInstance( - request: protos.google.cloud.notebooks.v1beta1.IRegisterInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - registerInstance( - request?: protos.google.cloud.notebooks.v1beta1.IRegisterInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.registerInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `registerInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.register_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_RegisterInstance_async - */ - async checkRegisterInstanceProgress(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.registerInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the guest accelerators of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {google.cloud.notebooks.v1beta1.Instance.AcceleratorType} request.type - * Required. Type of this accelerator. - * @param {number} request.coreCount - * Required. Count of cores of this accelerator. Note that not all combinations - * of `type` and `core_count` are valid. Check [GPUs on - * Compute Engine](https://cloud.google.com/compute/docs/gpus/#gpus-list) to - * find a valid combination. TPUs are not supported. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.set_instance_accelerator.js - * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceAccelerator_async - */ - setInstanceAccelerator( - request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceAcceleratorRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - setInstanceAccelerator( - request: protos.google.cloud.notebooks.v1beta1.ISetInstanceAcceleratorRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInstanceAccelerator( - request: protos.google.cloud.notebooks.v1beta1.ISetInstanceAcceleratorRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInstanceAccelerator( - request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceAcceleratorRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.setInstanceAccelerator(request, options, callback); - } -/** - * Check the status of the long running operation returned by `setInstanceAccelerator()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.set_instance_accelerator.js - * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceAccelerator_async - */ - async checkSetInstanceAcceleratorProgress(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.setInstanceAccelerator, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the machine type of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {string} request.machineType - * Required. The [Compute Engine machine - * type](https://cloud.google.com/compute/docs/machine-types). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.set_instance_machine_type.js - * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceMachineType_async - */ - setInstanceMachineType( - request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceMachineTypeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - setInstanceMachineType( - request: protos.google.cloud.notebooks.v1beta1.ISetInstanceMachineTypeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInstanceMachineType( - request: protos.google.cloud.notebooks.v1beta1.ISetInstanceMachineTypeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInstanceMachineType( - request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceMachineTypeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.setInstanceMachineType(request, options, callback); - } -/** - * Check the status of the long running operation returned by `setInstanceMachineType()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.set_instance_machine_type.js - * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceMachineType_async - */ - async checkSetInstanceMachineTypeProgress(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.setInstanceMachineType, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the labels of an Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {number[]} request.labels - * Labels to apply to this instance. - * These can be later modified by the setLabels method - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.set_instance_labels.js - * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceLabels_async - */ - setInstanceLabels( - request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceLabelsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - setInstanceLabels( - request: protos.google.cloud.notebooks.v1beta1.ISetInstanceLabelsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInstanceLabels( - request: protos.google.cloud.notebooks.v1beta1.ISetInstanceLabelsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInstanceLabels( - request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceLabelsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.setInstanceLabels(request, options, callback); - } -/** - * Check the status of the long running operation returned by `setInstanceLabels()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.set_instance_labels.js - * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceLabels_async - */ - async checkSetInstanceLabelsProgress(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.setInstanceLabels, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.delete_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_DeleteInstance_async - */ - deleteInstance( - request?: protos.google.cloud.notebooks.v1beta1.IDeleteInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteInstance( - request: protos.google.cloud.notebooks.v1beta1.IDeleteInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteInstance( - request: protos.google.cloud.notebooks.v1beta1.IDeleteInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteInstance( - request?: protos.google.cloud.notebooks.v1beta1.IDeleteInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.delete_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_DeleteInstance_async - */ - async checkDeleteInstanceProgress(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.deleteInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Starts a notebook instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.start_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_StartInstance_async - */ - startInstance( - request?: protos.google.cloud.notebooks.v1beta1.IStartInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - startInstance( - request: protos.google.cloud.notebooks.v1beta1.IStartInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - startInstance( - request: protos.google.cloud.notebooks.v1beta1.IStartInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - startInstance( - request?: protos.google.cloud.notebooks.v1beta1.IStartInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.startInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `startInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.start_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_StartInstance_async - */ - async checkStartInstanceProgress(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.startInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Stops a notebook instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.stop_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_StopInstance_async - */ - stopInstance( - request?: protos.google.cloud.notebooks.v1beta1.IStopInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - stopInstance( - request: protos.google.cloud.notebooks.v1beta1.IStopInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - stopInstance( - request: protos.google.cloud.notebooks.v1beta1.IStopInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - stopInstance( - request?: protos.google.cloud.notebooks.v1beta1.IStopInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.stopInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `stopInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.stop_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_StopInstance_async - */ - async checkStopInstanceProgress(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.stopInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Resets a notebook instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.reset_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_ResetInstance_async - */ - resetInstance( - request?: protos.google.cloud.notebooks.v1beta1.IResetInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - resetInstance( - request: protos.google.cloud.notebooks.v1beta1.IResetInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - resetInstance( - request: protos.google.cloud.notebooks.v1beta1.IResetInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - resetInstance( - request?: protos.google.cloud.notebooks.v1beta1.IResetInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.resetInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `resetInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.reset_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_ResetInstance_async - */ - async checkResetInstanceProgress(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.resetInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Allows notebook instances to - * report their latest instance information to the Notebooks - * API server. The server will merge the reported information to - * the instance metadata store. Do not use this method directly. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {string} request.vmId - * Required. The VM hardware token for authenticating the VM. - * https://cloud.google.com/compute/docs/instances/verifying-instance-identity - * @param {number[]} request.metadata - * The metadata reported to Notebooks API. This will be merged to the instance - * metadata store - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.report_instance_info.js - * region_tag:notebooks_v1beta1_generated_NotebookService_ReportInstanceInfo_async - */ - reportInstanceInfo( - request?: protos.google.cloud.notebooks.v1beta1.IReportInstanceInfoRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - reportInstanceInfo( - request: protos.google.cloud.notebooks.v1beta1.IReportInstanceInfoRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - reportInstanceInfo( - request: protos.google.cloud.notebooks.v1beta1.IReportInstanceInfoRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - reportInstanceInfo( - request?: protos.google.cloud.notebooks.v1beta1.IReportInstanceInfoRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.reportInstanceInfo(request, options, callback); - } -/** - * Check the status of the long running operation returned by `reportInstanceInfo()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.report_instance_info.js - * region_tag:notebooks_v1beta1_generated_NotebookService_ReportInstanceInfo_async - */ - async checkReportInstanceInfoProgress(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.reportInstanceInfo, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Upgrades a notebook instance to the latest version. - * Deprecated. Please consider using v1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.upgrade_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_UpgradeInstance_async - * @deprecated UpgradeInstance is deprecated and may be removed in a future version. - */ - upgradeInstance( - request?: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - upgradeInstance( - request: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - upgradeInstance( - request: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - upgradeInstance( - request?: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - this.warn('DEP$NotebookService-$UpgradeInstance','UpgradeInstance is deprecated and may be removed in a future version.', 'DeprecationWarning'); - return this.innerApiCalls.upgradeInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `upgradeInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.upgrade_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_UpgradeInstance_async - * @deprecated UpgradeInstance is deprecated and may be removed in a future version. - */ - async checkUpgradeInstanceProgress(name: string): Promise>{ - this.warn('DEP$NotebookService-$checkUpgradeInstanceProgress','checkUpgradeInstanceProgress is deprecated and may be removed in a future version.', 'DeprecationWarning'); - 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.upgradeInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Allows notebook instances to - * call this endpoint to upgrade themselves. Do not use this method directly. - * Deprecated. Please consider using v1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {string} request.vmId - * Required. The VM hardware token for authenticating the VM. - * https://cloud.google.com/compute/docs/instances/verifying-instance-identity - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.upgrade_instance_internal.js - * region_tag:notebooks_v1beta1_generated_NotebookService_UpgradeInstanceInternal_async - * @deprecated UpgradeInstanceInternal is deprecated and may be removed in a future version. - */ - upgradeInstanceInternal( - request?: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceInternalRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - upgradeInstanceInternal( - request: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceInternalRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - upgradeInstanceInternal( - request: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceInternalRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - upgradeInstanceInternal( - request?: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceInternalRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - this.warn('DEP$NotebookService-$UpgradeInstanceInternal','UpgradeInstanceInternal is deprecated and may be removed in a future version.', 'DeprecationWarning'); - return this.innerApiCalls.upgradeInstanceInternal(request, options, callback); - } -/** - * Check the status of the long running operation returned by `upgradeInstanceInternal()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.upgrade_instance_internal.js - * region_tag:notebooks_v1beta1_generated_NotebookService_UpgradeInstanceInternal_async - * @deprecated UpgradeInstanceInternal is deprecated and may be removed in a future version. - */ - async checkUpgradeInstanceInternalProgress(name: string): Promise>{ - this.warn('DEP$NotebookService-$checkUpgradeInstanceInternalProgress','checkUpgradeInstanceInternalProgress is deprecated and may be removed in a future version.', 'DeprecationWarning'); - 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.upgradeInstanceInternal, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Creates a new Environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: `projects/{project_id}/locations/{location}` - * @param {string} request.environmentId - * Required. User-defined unique ID of this environment. The `environment_id` must - * be 1 to 63 characters long and contain only lowercase letters, - * numeric characters, and dashes. The first character must be a lowercase - * letter and the last character cannot be a dash. - * @param {google.cloud.notebooks.v1beta1.Environment} request.environment - * Required. The environment to be created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.create_environment.js - * region_tag:notebooks_v1beta1_generated_NotebookService_CreateEnvironment_async - */ - createEnvironment( - request?: protos.google.cloud.notebooks.v1beta1.ICreateEnvironmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createEnvironment( - request: protos.google.cloud.notebooks.v1beta1.ICreateEnvironmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createEnvironment( - request: protos.google.cloud.notebooks.v1beta1.ICreateEnvironmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createEnvironment( - request?: protos.google.cloud.notebooks.v1beta1.ICreateEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createEnvironment(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createEnvironment()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.create_environment.js - * region_tag:notebooks_v1beta1_generated_NotebookService_CreateEnvironment_async - */ - async checkCreateEnvironmentProgress(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.createEnvironment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a single Environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/environments/{environment_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.delete_environment.js - * region_tag:notebooks_v1beta1_generated_NotebookService_DeleteEnvironment_async - */ - deleteEnvironment( - request?: protos.google.cloud.notebooks.v1beta1.IDeleteEnvironmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteEnvironment( - request: protos.google.cloud.notebooks.v1beta1.IDeleteEnvironmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteEnvironment( - request: protos.google.cloud.notebooks.v1beta1.IDeleteEnvironmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteEnvironment( - request?: protos.google.cloud.notebooks.v1beta1.IDeleteEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteEnvironment(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteEnvironment()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.delete_environment.js - * region_tag:notebooks_v1beta1_generated_NotebookService_DeleteEnvironment_async - */ - async checkDeleteEnvironmentProgress(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.deleteEnvironment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists instances in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.notebooks.v1beta1.Instance|Instance}. - * 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 `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listInstances( - request?: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1beta1.IInstance[], - protos.google.cloud.notebooks.v1beta1.IListInstancesRequest|null, - protos.google.cloud.notebooks.v1beta1.IListInstancesResponse - ]>; - listInstances( - request: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, - protos.google.cloud.notebooks.v1beta1.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v1beta1.IInstance>): void; - listInstances( - request: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, - protos.google.cloud.notebooks.v1beta1.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v1beta1.IInstance>): void; - listInstances( - request?: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, - protos.google.cloud.notebooks.v1beta1.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v1beta1.IInstance>, - callback?: PaginationCallback< - protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, - protos.google.cloud.notebooks.v1beta1.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v1beta1.IInstance>): - Promise<[ - protos.google.cloud.notebooks.v1beta1.IInstance[], - protos.google.cloud.notebooks.v1beta1.IListInstancesRequest|null, - protos.google.cloud.notebooks.v1beta1.IListInstancesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listInstances(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. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @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 protos.google.cloud.notebooks.v1beta1.Instance|Instance} 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 `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listInstancesStream( - request?: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, - 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['listInstances']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInstances.createStream( - this.innerApiCalls.listInstances as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listInstances`, 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. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.notebooks.v1beta1.Instance|Instance}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.list_instances.js - * region_tag:notebooks_v1beta1_generated_NotebookService_ListInstances_async - */ - listInstancesAsync( - request?: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, - 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['listInstances']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInstances.asyncIterate( - this.innerApiCalls['listInstances'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists environments in a project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: `projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing from - * the last result. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.notebooks.v1beta1.Environment|Environment}. - * 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 `listEnvironmentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listEnvironments( - request?: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1beta1.IEnvironment[], - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest|null, - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse - ]>; - listEnvironments( - request: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.notebooks.v1beta1.IEnvironment>): void; - listEnvironments( - request: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.notebooks.v1beta1.IEnvironment>): void; - listEnvironments( - request?: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.notebooks.v1beta1.IEnvironment>, - callback?: PaginationCallback< - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.notebooks.v1beta1.IEnvironment>): - Promise<[ - protos.google.cloud.notebooks.v1beta1.IEnvironment[], - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest|null, - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listEnvironments(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. Format: `projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing from - * the last result. - * @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 protos.google.cloud.notebooks.v1beta1.Environment|Environment} 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 `listEnvironmentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listEnvironmentsStream( - request?: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, - 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['listEnvironments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listEnvironments.createStream( - this.innerApiCalls.listEnvironments as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listEnvironments`, 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. Format: `projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing from - * the last result. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.notebooks.v1beta1.Environment|Environment}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.list_environments.js - * region_tag:notebooks_v1beta1_generated_NotebookService_ListEnvironments_async - */ - listEnvironmentsAsync( - request?: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, - 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['listEnvironments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listEnvironments.asyncIterate( - this.innerApiCalls['listEnvironments'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @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/interfaces/CallOptions.html | 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.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - getIamPolicy( - request: IamProtos.google.iam.v1.GetIamPolicyRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, - {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { - return this.iamClient.getIamPolicy(request, options, callback); - } - -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - setIamPolicy( - request: IamProtos.google.iam.v1.SetIamPolicyRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, - {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { - return this.iamClient.setIamPolicy(request, options, callback); - } - -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ - testIamPermissions( - request: IamProtos.google.iam.v1.TestIamPermissionsRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.TestIamPermissionsResponse, - IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.TestIamPermissionsResponse, - IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, - {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { - return this.iamClient.testIamPermissions(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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 environment resource name string. - * - * @param {string} project - * @param {string} environment - * @returns {string} Resource name string. - */ - environmentPath(project:string,environment:string) { - return this.pathTemplates.environmentPathTemplate.render({ - project: project, - environment: environment, - }); - } - - /** - * Parse the project from Environment resource. - * - * @param {string} environmentName - * A fully-qualified path representing Environment resource. - * @returns {string} A string representing the project. - */ - matchProjectFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).project; - } - - /** - * Parse the environment from Environment resource. - * - * @param {string} environmentName - * A fully-qualified path representing Environment resource. - * @returns {string} A string representing the environment. - */ - matchEnvironmentFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).environment; - } - - /** - * Return a fully-qualified instance resource name string. - * - * @param {string} project - * @param {string} instance - * @returns {string} Resource name string. - */ - instancePath(project:string,instance:string) { - return this.pathTemplates.instancePathTemplate.render({ - project: project, - instance: instance, - }); - } - - /** - * Parse the project from Instance resource. - * - * @param {string} instanceName - * A fully-qualified path representing Instance resource. - * @returns {string} A string representing the project. - */ - matchProjectFromInstanceName(instanceName: string) { - return this.pathTemplates.instancePathTemplate.match(instanceName).project; - } - - /** - * Parse the instance from Instance resource. - * - * @param {string} instanceName - * A fully-qualified path representing Instance resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromInstanceName(instanceName: string) { - return this.pathTemplates.instancePathTemplate.match(instanceName).instance; - } - - /** - * 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.notebookServiceStub && !this._terminated) { - return this.notebookServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.iamClient.close(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_client_config.json b/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_client_config.json deleted file mode 100644 index f50e40f8530..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_client_config.json +++ /dev/null @@ -1,121 +0,0 @@ -{ - "interfaces": { - "google.cloud.notebooks.v1beta1.NotebookService": { - "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": { - "ListInstances": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RegisterInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "SetInstanceAccelerator": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "SetInstanceMachineType": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "SetInstanceLabels": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "StartInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "StopInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ResetInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ReportInstanceInfo": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "IsInstanceUpgradeable": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpgradeInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpgradeInstanceInternal": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListEnvironments": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetEnvironment": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateEnvironment": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteEnvironment": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_proto_list.json b/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_proto_list.json deleted file mode 100644 index 40c171063ca..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/src/v1beta1/notebook_service_proto_list.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - "../../protos/google/cloud/notebooks/v1beta1/environment.proto", - "../../protos/google/cloud/notebooks/v1beta1/instance.proto", - "../../protos/google/cloud/notebooks/v1beta1/service.proto" -] diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 193e9b0e75d..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const notebooks = require('@google-cloud/notebooks'); - -function main() { - const notebookServiceClient = new notebooks.NotebookServiceClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 624792a563f..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {NotebookServiceClient} from '@google-cloud/notebooks'; - -// check that the client class type name can be used -function doStuffWithNotebookServiceClient(client: NotebookServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const notebookServiceClient = new NotebookServiceClient(); - doStuffWithNotebookServiceClient(notebookServiceClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-notebooks/v1beta1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/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-notebooks/v1beta1/test/gapic_notebook_service_v1beta1.ts b/owl-bot-staging/google-cloud-notebooks/v1beta1/test/gapic_notebook_service_v1beta1.ts deleted file mode 100644 index 488faefa079..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/test/gapic_notebook_service_v1beta1.ts +++ /dev/null @@ -1,3991 +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 notebookserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos, IamProtos, 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('v1beta1.NotebookServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = notebookserviceModule.v1beta1.NotebookServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = notebookserviceModule.v1beta1.NotebookServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = notebookserviceModule.v1beta1.NotebookServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.notebookServiceStub, undefined); - await client.initialize(); - assert(client.notebookServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.notebookServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.notebookServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - 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 notebookserviceModule.v1beta1.NotebookServiceClient({ - 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('getInstance', () => { - it('invokes getInstance without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); - const [response] = await client.getInstance(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstance without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstance( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1beta1.IInstance|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstance with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstance with closed client', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getInstance(request), expectedError); - }); - }); - - describe('isInstanceUpgradeable', () => { - it('invokes isInstanceUpgradeable without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedHeaderRequestParams = `notebook_instance=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableResponse() - ); - client.innerApiCalls.isInstanceUpgradeable = stubSimpleCall(expectedResponse); - const [response] = await client.isInstanceUpgradeable(request); - assert(stub.calledOnce); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes isInstanceUpgradeable without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedHeaderRequestParams = `notebook_instance=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableResponse() - ); - client.innerApiCalls.isInstanceUpgradeable = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.isInstanceUpgradeable( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert(stub.calledOnce); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes isInstanceUpgradeable with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedHeaderRequestParams = `notebook_instance=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.isInstanceUpgradeable = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.isInstanceUpgradeable(request), expectedError); - assert(stub.calledOnce); - const actualRequest = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes isInstanceUpgradeable with closed client', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.isInstanceUpgradeable(request), expectedError); - assert(stub.calledOnce); - }); - }); - - describe('getEnvironment', () => { - it('invokes getEnvironment without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.Environment() - ); - client.innerApiCalls.getEnvironment = stubSimpleCall(expectedResponse); - const [response] = await client.getEnvironment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEnvironment without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.Environment() - ); - client.innerApiCalls.getEnvironment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getEnvironment( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1beta1.IEnvironment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEnvironment with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getEnvironment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEnvironment with closed client', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getEnvironment(request), expectedError); - }); - }); - - describe('createInstance', () => { - it('invokes createInstance without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.createInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInstance without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createInstance( - request, - (err?: Error|null, - result?: 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.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInstance with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInstance with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('registerInstance', () => { - it('invokes registerInstance without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.RegisterInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.RegisterInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.registerInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.registerInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes registerInstance without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.RegisterInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.RegisterInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.registerInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.registerInstance( - request, - (err?: Error|null, - result?: 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.registerInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes registerInstance with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.RegisterInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.RegisterInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.registerInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.registerInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes registerInstance with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.RegisterInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.RegisterInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.registerInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.registerInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkRegisterInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRegisterInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRegisterInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRegisterInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('setInstanceAccelerator', () => { - it('invokes setInstanceAccelerator without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall(expectedResponse); - const [operation] = await client.setInstanceAccelerator(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setInstanceAccelerator without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceAccelerator = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setInstanceAccelerator( - request, - (err?: Error|null, - result?: 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.setInstanceAccelerator as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setInstanceAccelerator with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setInstanceAccelerator(request), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setInstanceAccelerator with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setInstanceAccelerator(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkSetInstanceAcceleratorProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkSetInstanceAcceleratorProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkSetInstanceAcceleratorProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSetInstanceAcceleratorProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('setInstanceMachineType', () => { - it('invokes setInstanceMachineType without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceMachineType = stubLongRunningCall(expectedResponse); - const [operation] = await client.setInstanceMachineType(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setInstanceMachineType without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceMachineType = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setInstanceMachineType( - request, - (err?: Error|null, - result?: 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.setInstanceMachineType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setInstanceMachineType with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceMachineType = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setInstanceMachineType(request), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setInstanceMachineType with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceMachineType = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setInstanceMachineType(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkSetInstanceMachineTypeProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkSetInstanceMachineTypeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkSetInstanceMachineTypeProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSetInstanceMachineTypeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('setInstanceLabels', () => { - it('invokes setInstanceLabels without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceLabels = stubLongRunningCall(expectedResponse); - const [operation] = await client.setInstanceLabels(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setInstanceLabels without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceLabels = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setInstanceLabels( - request, - (err?: Error|null, - result?: 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.setInstanceLabels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setInstanceLabels with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceLabels = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setInstanceLabels(request), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setInstanceLabels with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceLabels = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setInstanceLabels(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkSetInstanceLabelsProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkSetInstanceLabelsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkSetInstanceLabelsProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSetInstanceLabelsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteInstance', () => { - it('invokes deleteInstance without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInstance without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteInstance( - request, - (err?: Error|null, - result?: 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.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInstance with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInstance with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('startInstance', () => { - it('invokes startInstance without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.startInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startInstance without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.startInstance( - request, - (err?: Error|null, - result?: 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.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startInstance with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.startInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.startInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startInstance with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.startInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.startInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkStartInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkStartInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkStartInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStartInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('stopInstance', () => { - it('invokes stopInstance without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.stopInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopInstance without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.stopInstance( - request, - (err?: Error|null, - result?: 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.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopInstance with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.stopInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopInstance with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.stopInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkStopInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkStopInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkStopInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStopInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('resetInstance', () => { - it('invokes resetInstance without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.resetInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.resetInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetInstance without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.resetInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resetInstance( - request, - (err?: Error|null, - result?: 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.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetInstance with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.resetInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.resetInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetInstance with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.resetInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.resetInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkResetInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkResetInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkResetInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkResetInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('reportInstanceInfo', () => { - it('invokes reportInstanceInfo without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.reportInstanceInfo = stubLongRunningCall(expectedResponse); - const [operation] = await client.reportInstanceInfo(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reportInstanceInfo without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.reportInstanceInfo = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.reportInstanceInfo( - request, - (err?: Error|null, - result?: 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.reportInstanceInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reportInstanceInfo with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.reportInstanceInfo = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.reportInstanceInfo(request), expectedError); - const actualRequest = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reportInstanceInfo with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.reportInstanceInfo = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.reportInstanceInfo(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkReportInstanceInfoProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkReportInstanceInfoProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkReportInstanceInfoProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkReportInstanceInfoProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('upgradeInstance', () => { - it('invokes upgradeInstance without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.upgradeInstance(request); - const [response] = await operation.promise(); - assert(stub.calledOnce); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstance without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.upgradeInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert(stub.calledOnce); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstance with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.upgradeInstance(request), expectedError); - assert(stub.calledOnce); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstance with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.upgradeInstance(request); - await assert.rejects(operation.promise(), expectedError); - assert(stub.calledOnce); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpgradeInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpgradeInstanceProgress(expectedResponse.name); - assert(stub.calledOnce); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpgradeInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpgradeInstanceProgress(''), expectedError); - assert(stub.calledOnce); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('upgradeInstanceInternal', () => { - it('invokes upgradeInstanceInternal without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall(expectedResponse); - const [operation] = await client.upgradeInstanceInternal(request); - const [response] = await operation.promise(); - assert(stub.calledOnce); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstanceInternal without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.upgradeInstanceInternal( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert(stub.calledOnce); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstanceInternal with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.upgradeInstanceInternal(request), expectedError); - assert(stub.calledOnce); - const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstanceInternal with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.upgradeInstanceInternal(request); - await assert.rejects(operation.promise(), expectedError); - assert(stub.calledOnce); - const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpgradeInstanceInternalProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpgradeInstanceInternalProgress(expectedResponse.name); - assert(stub.calledOnce); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpgradeInstanceInternalProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpgradeInstanceInternalProgress(''), expectedError); - assert(stub.calledOnce); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('createEnvironment', () => { - it('invokes createEnvironment without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createEnvironment = stubLongRunningCall(expectedResponse); - const [operation] = await client.createEnvironment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createEnvironment without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createEnvironment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createEnvironment( - request, - (err?: Error|null, - result?: 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.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createEnvironment with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEnvironment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createEnvironment with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEnvironment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createEnvironment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateEnvironmentProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateEnvironmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateEnvironmentProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateEnvironmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteEnvironment', () => { - it('invokes deleteEnvironment without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteEnvironment = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteEnvironment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteEnvironment without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteEnvironment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteEnvironment( - request, - (err?: Error|null, - result?: 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.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteEnvironment with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteEnvironment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteEnvironment with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteEnvironment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteEnvironment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteEnvironmentProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteEnvironmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteEnvironmentProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteEnvironmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listInstances', () => { - it('invokes listInstances without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); - const [response] = await client.listInstances(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstances without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInstances( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1beta1.IInstance[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstances with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInstances(request), expectedError); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstancesStream without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - ]; - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1beta1.Instance[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1beta1.Instance) => { - 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.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listInstancesStream with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1beta1.Instance[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1beta1.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInstances without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - ]; - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.notebooks.v1beta1.IInstance[] = []; - const iterable = client.listInstancesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInstances with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInstancesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.notebooks.v1beta1.IInstance[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listEnvironments', () => { - it('invokes listEnvironments without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - ]; - client.innerApiCalls.listEnvironments = stubSimpleCall(expectedResponse); - const [response] = await client.listEnvironments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEnvironments without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - ]; - client.innerApiCalls.listEnvironments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listEnvironments( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1beta1.IEnvironment[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEnvironments with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listEnvironments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listEnvironments(request), expectedError); - const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEnvironmentsStream without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - ]; - client.descriptors.page.listEnvironments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listEnvironmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1beta1.Environment[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1beta1.Environment) => { - 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.listEnvironments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEnvironments, request)); - assert( - (client.descriptors.page.listEnvironments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listEnvironmentsStream with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listEnvironments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listEnvironmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1beta1.Environment[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1beta1.Environment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listEnvironments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEnvironments, request)); - assert( - (client.descriptors.page.listEnvironments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listEnvironments without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - ]; - client.descriptors.page.listEnvironments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.notebooks.v1beta1.IEnvironment[] = []; - const iterable = client.listEnvironmentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listEnvironments with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listEnvironments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listEnvironmentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.notebooks.v1beta1.IEnvironment[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - 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 notebookserviceModule.v1beta1.NotebookServiceClient({ - 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 notebookserviceModule.v1beta1.NotebookServiceClient({ - 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 notebookserviceModule.v1beta1.NotebookServiceClient({ - 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 notebookserviceModule.v1beta1.NotebookServiceClient({ - 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 notebookserviceModule.v1beta1.NotebookServiceClient({ - 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 notebookserviceModule.v1beta1.NotebookServiceClient({ - 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 notebookserviceModule.v1beta1.NotebookServiceClient({ - 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 notebookserviceModule.v1beta1.NotebookServiceClient({ - 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 notebookserviceModule.v1beta1.NotebookServiceClient({ - 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 notebookserviceModule.v1beta1.NotebookServiceClient({ - 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 notebookserviceModule.v1beta1.NotebookServiceClient({ - 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 notebookserviceModule.v1beta1.NotebookServiceClient({ - 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 notebookserviceModule.v1beta1.NotebookServiceClient({ - 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 notebookserviceModule.v1beta1.NotebookServiceClient({ - 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 notebookserviceModule.v1beta1.NotebookServiceClient({ - 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('environment', () => { - const fakePath = "/rendered/path/environment"; - const expectedParameters = { - project: "projectValue", - environment: "environmentValue", - }; - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.environmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.environmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('environmentPath', () => { - const result = client.environmentPath("projectValue", "environmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.environmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEnvironmentName', () => { - const result = client.matchProjectFromEnvironmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEnvironmentFromEnvironmentName', () => { - const result = client.matchEnvironmentFromEnvironmentName(fakePath); - assert.strictEqual(result, "environmentValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('instance', () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - }; - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-notebooks/v1beta1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-notebooks/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-notebooks/v1beta1/webpack.config.js deleted file mode 100644 index b41a2c182e9..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v1beta1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'NotebookService', - filename: './notebook-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-notebooks/v2/.eslintignore b/owl-bot-staging/google-cloud-notebooks/v2/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/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-notebooks/v2/.eslintrc.json b/owl-bot-staging/google-cloud-notebooks/v2/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/.gitignore b/owl-bot-staging/google-cloud-notebooks/v2/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/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-notebooks/v2/.jsdoc.js b/owl-bot-staging/google-cloud-notebooks/v2/.jsdoc.js deleted file mode 100644 index b562faf1159..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/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/notebooks', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-notebooks/v2/.mocharc.js b/owl-bot-staging/google-cloud-notebooks/v2/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/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-notebooks/v2/.prettierrc.js b/owl-bot-staging/google-cloud-notebooks/v2/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/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-notebooks/v2/README.md b/owl-bot-staging/google-cloud-notebooks/v2/README.md deleted file mode 100644 index 31cec215a8f..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/README.md +++ /dev/null @@ -1 +0,0 @@ -Notebooks: Nodejs Client diff --git a/owl-bot-staging/google-cloud-notebooks/v2/package.json b/owl-bot-staging/google-cloud-notebooks/v2/package.json deleted file mode 100644 index c3911a749c3..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/notebooks", - "version": "0.1.0", - "description": "Notebooks client for Node.js", - "repository": "googleapis/nodejs-notebooks", - "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 notebooks", - "notebooks", - "notebook service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/diagnostic_config.proto b/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/diagnostic_config.proto deleted file mode 100644 index ccd60acd05c..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/diagnostic_config.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.notebooks.v2; - -import "google/api/field_behavior.proto"; - -option csharp_namespace = "Google.Cloud.Notebooks.V2"; -option go_package = "cloud.google.com/go/notebooks/apiv2/notebookspb;notebookspb"; -option java_multiple_files = true; -option java_outer_classname = "DiagnosticConfigProto"; -option java_package = "com.google.cloud.notebooks.v2"; -option php_namespace = "Google\\Cloud\\Notebooks\\V2"; -option ruby_package = "Google::Cloud::Notebooks::V2"; - -// Defines flags that are used to run the diagnostic tool -message DiagnosticConfig { - // Required. User Cloud Storage bucket location (REQUIRED). - // Must be formatted with path prefix (`gs://$GCS_BUCKET`). - // - // Permissions: - // User Managed Notebooks: - // - storage.buckets.writer: Must be given to the project's service account - // attached to VM. - // Google Managed Notebooks: - // - storage.buckets.writer: Must be given to the project's service account or - // user credentials attached to VM depending on authentication mode. - // - // Cloud Storage bucket Log file will be written to - // `gs://$GCS_BUCKET/$RELATIVE_PATH/$VM_DATE_$TIME.tar.gz` - string gcs_bucket = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Defines the relative storage path in the Cloud Storage bucket - // where the diagnostic logs will be written: Default path will be the root - // directory of the Cloud Storage bucket - // (`gs://$GCS_BUCKET/$DATE_$TIME.tar.gz`) Example of full path where Log file - // will be written: `gs://$GCS_BUCKET/$RELATIVE_PATH/` - string relative_path = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Enables flag to repair service for instance - bool enable_repair_flag = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Enables flag to capture packets from the instance for 30 seconds - bool enable_packet_capture_flag = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Enables flag to copy all `/home/jupyter` folder contents - bool enable_copy_home_files_flag = 5 [(google.api.field_behavior) = OPTIONAL]; -} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/event.proto b/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/event.proto deleted file mode 100644 index 1480bbc3e46..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/event.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.notebooks.v2; - -import "google/api/field_behavior.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Notebooks.V2"; -option go_package = "cloud.google.com/go/notebooks/apiv2/notebookspb;notebookspb"; -option java_multiple_files = true; -option java_outer_classname = "EventProto"; -option java_package = "com.google.cloud.notebooks.v2"; -option php_namespace = "Google\\Cloud\\Notebooks\\V2"; -option ruby_package = "Google::Cloud::Notebooks::V2"; - -// The definition of an Event for a managed / semi-managed notebook instance. -message Event { - // The definition of the event types. - enum EventType { - // Event is not specified. - EVENT_TYPE_UNSPECIFIED = 0; - - // The instance / runtime is idle - IDLE = 1; - - // The instance / runtime is available. - // This event indicates that instance / runtime underlying compute is - // operational. - HEARTBEAT = 2; - - // The instance / runtime health is available. - // This event indicates that instance / runtime health information. - HEALTH = 3; - - // The instance / runtime is available. - // This event allows instance / runtime to send Host maintenance - // information to Control Plane. - // https://cloud.google.com/compute/docs/gpus/gpu-host-maintenance - MAINTENANCE = 4; - - // The instance / runtime is available. - // This event indicates that the instance had metadata that needs to be - // modified. - METADATA_CHANGE = 5; - } - - // Optional. Event report time. - google.protobuf.Timestamp report_time = 1 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Event type. - EventType type = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Event details. This field is used to pass event information. - map details = 3 [(google.api.field_behavior) = OPTIONAL]; -} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/gce_setup.proto b/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/gce_setup.proto deleted file mode 100644 index e3fb8b18d6f..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/gce_setup.proto +++ /dev/null @@ -1,340 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.notebooks.v2; - -import "google/api/field_behavior.proto"; - -option csharp_namespace = "Google.Cloud.Notebooks.V2"; -option go_package = "cloud.google.com/go/notebooks/apiv2/notebookspb;notebookspb"; -option java_multiple_files = true; -option java_outer_classname = "GceSetupProto"; -option java_package = "com.google.cloud.notebooks.v2"; -option php_namespace = "Google\\Cloud\\Notebooks\\V2"; -option ruby_package = "Google::Cloud::Notebooks::V2"; - -// The definition of a network interface resource attached to a VM. -message NetworkInterface { - // The type of vNIC driver. - // Default should be NIC_TYPE_UNSPECIFIED. - enum NicType { - // No type specified. - NIC_TYPE_UNSPECIFIED = 0; - - // VIRTIO - VIRTIO_NET = 1; - - // GVNIC - GVNIC = 2; - } - - // Optional. The name of the VPC that this VM instance is in. - // Format: - // `projects/{project_id}/global/networks/{network_id}` - string network = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The name of the subnet that this VM instance is in. - // Format: - // `projects/{project_id}/regions/{region}/subnetworks/{subnetwork_id}` - string subnet = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The type of vNIC to be used on this interface. This may be gVNIC - // or VirtioNet. - NicType nic_type = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Definition of a custom Compute Engine virtual machine image for starting a -// notebook instance with the environment installed directly on the VM. -message VmImage { - // Required. The name of the Google Cloud project that this VM image belongs - // to. Format: `{project_id}` - string project = 1 [(google.api.field_behavior) = REQUIRED]; - - // The reference to an external Compute Engine VM image. - oneof image { - // Optional. Use VM image name to find the image. - string name = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Use this VM image family to find the image; the newest image in - // this family will be used. - string family = 3 [(google.api.field_behavior) = OPTIONAL]; - } -} - -// Definition of a container image for starting a notebook instance with the -// environment installed in a container. -message ContainerImage { - // Required. The path to the container image repository. For example: - // `gcr.io/{project_id}/{image_name}` - string repository = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The tag of the container image. If not specified, this defaults - // to the latest tag. - string tag = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// An accelerator configuration for a VM instance -// Definition of a hardware accelerator. Note that there is no check on `type` -// and `core_count` combinations. TPUs are not supported. -// See [GPUs on Compute -// Engine](https://cloud.google.com/compute/docs/gpus/#gpus-list) to find a -// valid combination. -message AcceleratorConfig { - // Definition of the types of hardware accelerators that can be used on - // this instance. - enum AcceleratorType { - // Accelerator type is not specified. - ACCELERATOR_TYPE_UNSPECIFIED = 0; - - // Accelerator type is Nvidia Tesla P100. - NVIDIA_TESLA_P100 = 2; - - // Accelerator type is Nvidia Tesla V100. - NVIDIA_TESLA_V100 = 3; - - // Accelerator type is Nvidia Tesla P4. - NVIDIA_TESLA_P4 = 4; - - // Accelerator type is Nvidia Tesla T4. - NVIDIA_TESLA_T4 = 5; - - // Accelerator type is Nvidia Tesla A100 - 40GB. - NVIDIA_TESLA_A100 = 11; - - // Accelerator type is Nvidia Tesla A100 - 80GB. - NVIDIA_A100_80GB = 12; - - // Accelerator type is Nvidia Tesla L4. - NVIDIA_L4 = 13; - - // Accelerator type is NVIDIA Tesla T4 Virtual Workstations. - NVIDIA_TESLA_T4_VWS = 8; - - // Accelerator type is NVIDIA Tesla P100 Virtual Workstations. - NVIDIA_TESLA_P100_VWS = 9; - - // Accelerator type is NVIDIA Tesla P4 Virtual Workstations. - NVIDIA_TESLA_P4_VWS = 10; - } - - // Optional. Type of this accelerator. - AcceleratorType type = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Count of cores of this accelerator. - int64 core_count = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// A set of Shielded Instance options. -// See [Images using supported Shielded VM -// features](https://cloud.google.com/compute/docs/instances/modifying-shielded-vm). -// Not all combinations are valid. -message ShieldedInstanceConfig { - // Optional. Defines whether the VM instance has Secure Boot enabled. - // - // Secure Boot helps ensure that the system only runs authentic software by - // verifying the digital signature of all boot components, and halting the - // boot process if signature verification fails. Disabled by default. - bool enable_secure_boot = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Defines whether the VM instance has the vTPM enabled. Enabled by - // default. - bool enable_vtpm = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Defines whether the VM instance has integrity monitoring enabled. - // - // Enables monitoring and attestation of the boot integrity of the VM - // instance. The attestation is performed against the integrity policy - // baseline. This baseline is initially derived from the implicitly trusted - // boot image when the VM instance is created. Enabled by default. - bool enable_integrity_monitoring = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// A GPU driver configuration -message GPUDriverConfig { - // Optional. Whether the end user authorizes Google Cloud to install GPU - // driver on this VM instance. If this field is empty or set to false, the GPU - // driver won't be installed. Only applicable to instances with GPUs. - bool enable_gpu_driver = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Specify a custom Cloud Storage path where the GPU driver is - // stored. If not specified, we'll automatically choose from official GPU - // drivers. - string custom_gpu_driver_path = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// An instance-attached disk resource. -message DataDisk { - // Optional. The size of the disk in GB attached to this VM instance, up to a - // maximum of 64000 GB (64 TB). If not specified, this defaults to 100. - int64 disk_size_gb = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Input only. Indicates the type of the disk. - DiskType disk_type = 2 [ - (google.api.field_behavior) = INPUT_ONLY, - (google.api.field_behavior) = OPTIONAL - ]; - - // Optional. Input only. Disk encryption method used on the boot and data - // disks, defaults to GMEK. - DiskEncryption disk_encryption = 5 [ - (google.api.field_behavior) = INPUT_ONLY, - (google.api.field_behavior) = OPTIONAL - ]; - - // Optional. Input only. The KMS key used to encrypt the disks, only - // applicable if disk_encryption is CMEK. Format: - // `projects/{project_id}/locations/{location}/keyRings/{key_ring_id}/cryptoKeys/{key_id}` - // - // Learn more about using your own encryption keys. - string kms_key = 6 [ - (google.api.field_behavior) = INPUT_ONLY, - (google.api.field_behavior) = OPTIONAL - ]; -} - -// The definition of a boot disk. -message BootDisk { - // Optional. The size of the boot disk in GB attached to this instance, up to - // a maximum of 64000 GB (64 TB). If not specified, this defaults to the - // recommended value of 150GB. - int64 disk_size_gb = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Indicates the type of the disk. - DiskType disk_type = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Input only. Disk encryption method used on the boot and data - // disks, defaults to GMEK. - DiskEncryption disk_encryption = 3 [ - (google.api.field_behavior) = INPUT_ONLY, - (google.api.field_behavior) = OPTIONAL - ]; - - // Optional. Input only. The KMS key used to encrypt the disks, only - // applicable if disk_encryption is CMEK. Format: - // `projects/{project_id}/locations/{location}/keyRings/{key_ring_id}/cryptoKeys/{key_id}` - // - // Learn more about using your own encryption keys. - string kms_key = 4 [ - (google.api.field_behavior) = INPUT_ONLY, - (google.api.field_behavior) = OPTIONAL - ]; -} - -// A service account that acts as an identity. -message ServiceAccount { - // Optional. Email address of the service account. - string email = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The list of scopes to be made available for this service - // account. Set by the CLH to https://www.googleapis.com/auth/cloud-platform - repeated string scopes = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// The definition of how to configure a VM instance outside of Resources and -// Identity. -message GceSetup { - // Optional. The machine type of the VM instance. - // https://cloud.google.com/compute/docs/machine-resource - string machine_type = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The hardware accelerators used on this instance. If you use - // accelerators, make sure that your configuration has - // [enough vCPUs and memory to support the `machine_type` you have - // selected](https://cloud.google.com/compute/docs/gpus/#gpus-list). - // Currently supports only one accelerator configuration. - repeated AcceleratorConfig accelerator_configs = 2 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The service account that serves as an identity for the VM - // instance. Currently supports only one service account. - repeated ServiceAccount service_accounts = 3 - [(google.api.field_behavior) = OPTIONAL]; - - // Type of the image; can be one of VM image, or container image. - oneof image { - // Optional. Use a Compute Engine VM image to start the notebook instance. - VmImage vm_image = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Use a container image to start the notebook instance. - ContainerImage container_image = 5 [(google.api.field_behavior) = OPTIONAL]; - } - - // Optional. The boot disk for the VM. - BootDisk boot_disk = 6 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Data disks attached to the VM instance. - // Currently supports only one data disk. - repeated DataDisk data_disks = 7 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Shielded VM configuration. - // [Images using supported Shielded VM - // features](https://cloud.google.com/compute/docs/instances/modifying-shielded-vm). - ShieldedInstanceConfig shielded_instance_config = 8 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The network interfaces for the VM. - // Supports only one interface. - repeated NetworkInterface network_interfaces = 9 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. If true, no external IP will be assigned to this VM instance. - bool disable_public_ip = 10 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The Compute Engine tags to add to runtime (see [Tagging - // instances](https://cloud.google.com/compute/docs/label-or-tag-resources#tags)). - repeated string tags = 11 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Custom metadata to apply to this instance. - map metadata = 12 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Flag to enable ip forwarding or not, default false/off. - // https://cloud.google.com/vpc/docs/using-routes#canipforward - bool enable_ip_forwarding = 13 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Configuration for GPU drivers. - GPUDriverConfig gpu_driver_config = 14 - [(google.api.field_behavior) = OPTIONAL]; -} - -// Definition of the disk encryption options. -enum DiskEncryption { - // Disk encryption is not specified. - DISK_ENCRYPTION_UNSPECIFIED = 0; - - // Use Google managed encryption keys to encrypt the boot disk. - GMEK = 1; - - // Use customer managed encryption keys to encrypt the boot disk. - CMEK = 2; -} - -// Possible disk types. -enum DiskType { - // Disk type not set. - DISK_TYPE_UNSPECIFIED = 0; - - // Standard persistent disk type. - PD_STANDARD = 1; - - // SSD persistent disk type. - PD_SSD = 2; - - // Balanced persistent disk type. - PD_BALANCED = 3; - - // Extreme persistent disk type. - PD_EXTREME = 4; -} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/instance.proto b/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/instance.proto deleted file mode 100644 index 9a3dff5bfe5..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/instance.proto +++ /dev/null @@ -1,231 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.notebooks.v2; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/notebooks/v2/gce_setup.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Notebooks.V2"; -option go_package = "cloud.google.com/go/notebooks/apiv2/notebookspb;notebookspb"; -option java_multiple_files = true; -option java_outer_classname = "InstanceProto"; -option java_package = "com.google.cloud.notebooks.v2"; -option php_namespace = "Google\\Cloud\\Notebooks\\V2"; -option ruby_package = "Google::Cloud::Notebooks::V2"; - -// The entry of VM image upgrade history. -message UpgradeHistoryEntry { - // The definition of the states of this upgrade history entry. - enum State { - // State is not specified. - STATE_UNSPECIFIED = 0; - - // The instance upgrade is started. - STARTED = 1; - - // The instance upgrade is succeeded. - SUCCEEDED = 2; - - // The instance upgrade is failed. - FAILED = 3; - } - - // The definition of operations of this upgrade history entry. - enum Action { - // Operation is not specified. - ACTION_UNSPECIFIED = 0; - - // Upgrade. - UPGRADE = 1; - - // Rollback. - ROLLBACK = 2; - } - - // Optional. The snapshot of the boot disk of this notebook instance before - // upgrade. - string snapshot = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The VM image before this instance upgrade. - string vm_image = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The container image before this instance upgrade. - string container_image = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The framework of this notebook instance. - string framework = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The version of the notebook instance before this upgrade. - string version = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The state of this instance upgrade history entry. - State state = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Immutable. The time that this instance upgrade history entry is created. - google.protobuf.Timestamp create_time = 7 - [(google.api.field_behavior) = IMMUTABLE]; - - // Optional. Action. Rolloback or Upgrade. - Action action = 8 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Target VM Version, like m63. - string target_version = 9 [(google.api.field_behavior) = OPTIONAL]; -} - -// The definition of a notebook instance. -message Instance { - option (google.api.resource) = { - type: "notebooks.googleapis.com/Instance" - pattern: "projects/{project}/locations/{location}/instances/{instance}" - plural: "instances" - singular: "instance" - }; - - // Output only. The name of this notebook instance. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Setup for the Notebook instance. - oneof infrastructure { - // Optional. Compute Engine setup for the notebook. Uses notebook-defined - // fields. - GceSetup gce_setup = 2 [(google.api.field_behavior) = OPTIONAL]; - } - - // Output only. The proxy endpoint that is used to access the Jupyter - // notebook. - string proxy_uri = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Input only. The owner of this instance after creation. Format: - // `alias@example.com` - // - // Currently supports one owner only. If not specified, all of the service - // account users of your VM instance's service account can use - // the instance. - repeated string instance_owners = 4 [ - (google.api.field_behavior) = INPUT_ONLY, - (google.api.field_behavior) = OPTIONAL - ]; - - // Output only. Email address of entity that sent original CreateInstance - // request. - string creator = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The state of this instance. - State state = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The upgrade history of this instance. - repeated UpgradeHistoryEntry upgrade_history = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Unique ID of the resource. - string id = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Instance health_state. - HealthState health_state = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Additional information about instance health. - // Example: - // - // healthInfo": { - // "docker_proxy_agent_status": "1", - // "docker_status": "1", - // "jupyterlab_api_status": "-1", - // "jupyterlab_status": "-1", - // "updated": "2020-10-18 09:40:03.573409" - // } - map health_info = 10 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Instance creation time. - google.protobuf.Timestamp create_time = 11 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Instance update time. - google.protobuf.Timestamp update_time = 12 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. If true, the notebook instance will not register with the proxy. - bool disable_proxy_access = 13 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Labels to apply to this instance. - // These can be later modified by the UpdateInstance method. - map labels = 14 [(google.api.field_behavior) = OPTIONAL]; -} - -// The definition of the states of this instance. -enum State { - // State is not specified. - STATE_UNSPECIFIED = 0; - - // The control logic is starting the instance. - STARTING = 1; - - // The control logic is installing required frameworks and registering the - // instance with notebook proxy - PROVISIONING = 2; - - // The instance is running. - ACTIVE = 3; - - // The control logic is stopping the instance. - STOPPING = 4; - - // The instance is stopped. - STOPPED = 5; - - // The instance is deleted. - DELETED = 6; - - // The instance is upgrading. - UPGRADING = 7; - - // The instance is being created. - INITIALIZING = 8; - - // The instance is suspending. - SUSPENDING = 9; - - // The instance is suspended. - SUSPENDED = 10; -} - -// The instance health state. -enum HealthState { - // The instance substate is unknown. - HEALTH_STATE_UNSPECIFIED = 0; - - // The instance is known to be in an healthy state - // (for example, critical daemons are running) - // Applies to ACTIVE state. - HEALTHY = 1; - - // The instance is known to be in an unhealthy state - // (for example, critical daemons are not running) - // Applies to ACTIVE state. - UNHEALTHY = 2; - - // The instance has not installed health monitoring agent. - // Applies to ACTIVE state. - AGENT_NOT_INSTALLED = 3; - - // The instance health monitoring agent is not running. - // Applies to ACTIVE state. - AGENT_NOT_RUNNING = 4; -} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/service.proto b/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/service.proto deleted file mode 100644 index 04bcb485cc8..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/protos/google/cloud/notebooks/v2/service.proto +++ /dev/null @@ -1,413 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.notebooks.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/notebooks/v2/diagnostic_config.proto"; -import "google/cloud/notebooks/v2/instance.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.Notebooks.V2"; -option go_package = "cloud.google.com/go/notebooks/apiv2/notebookspb;notebookspb"; -option java_multiple_files = true; -option java_outer_classname = "ServiceProto"; -option java_package = "com.google.cloud.notebooks.v2"; -option php_namespace = "Google\\Cloud\\Notebooks\\V2"; -option ruby_package = "Google::Cloud::Notebooks::V2"; - -// API v2 service for Workbench Notebooks Instances. -service NotebookService { - option (google.api.default_host) = "notebooks.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Lists instances in a given project and location. - rpc ListInstances(ListInstancesRequest) returns (ListInstancesResponse) { - option (google.api.http) = { - get: "/v2/{parent=projects/*/locations/*}/instances" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets details of a single Instance. - rpc GetInstance(GetInstanceRequest) returns (Instance) { - option (google.api.http) = { - get: "/v2/{name=projects/*/locations/*/instances/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a new Instance in a given project and location. - rpc CreateInstance(CreateInstanceRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{parent=projects/*/locations/*}/instances" - body: "instance" - }; - option (google.api.method_signature) = "parent,instance,instance_id"; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // UpdateInstance updates an Instance. - rpc UpdateInstance(UpdateInstanceRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v2/{instance.name=projects/*/locations/*/instances/*}" - body: "instance" - }; - option (google.api.method_signature) = "instance,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Deletes a single Instance. - rpc DeleteInstance(DeleteInstanceRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v2/{name=projects/*/locations/*/instances/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "OperationMetadata" - }; - } - - // Starts a notebook instance. - rpc StartInstance(StartInstanceRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{name=projects/*/locations/*/instances/*}:start" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Stops a notebook instance. - rpc StopInstance(StopInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{name=projects/*/locations/*/instances/*}:stop" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Resets a notebook instance. - rpc ResetInstance(ResetInstanceRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{name=projects/*/locations/*/instances/*}:reset" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Checks whether a notebook instance is upgradable. - rpc CheckInstanceUpgradability(CheckInstanceUpgradabilityRequest) - returns (CheckInstanceUpgradabilityResponse) { - option (google.api.http) = { - get: "/v2/{notebook_instance=projects/*/locations/*/instances/*}:checkUpgradability" - }; - } - - // Upgrades a notebook instance to the latest version. - rpc UpgradeInstance(UpgradeInstanceRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{name=projects/*/locations/*/instances/*}:upgrade" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Rollbacks a notebook instance to the previous version. - rpc RollbackInstance(RollbackInstanceRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{name=projects/*/locations/*/instances/*}:rollback" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } - - // Creates a Diagnostic File and runs Diagnostic Tool given an Instance. - rpc DiagnoseInstance(DiagnoseInstanceRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{name=projects/*/locations/*/instances/*}:diagnose" - body: "*" - }; - option (google.api.method_signature) = "name,diagnostic_config"; - option (google.longrunning.operation_info) = { - response_type: "Instance" - metadata_type: "OperationMetadata" - }; - } -} - -// Represents the metadata of the long-running operation. -message OperationMetadata { - // The time the operation was created. - google.protobuf.Timestamp create_time = 1; - - // The time the operation finished running. - google.protobuf.Timestamp end_time = 2; - - // Server-defined resource path for the target of the operation. - string target = 3; - - // Name of the verb executed by the operation. - string verb = 4; - - // Human-readable status of the operation, if any. - string status_message = 5; - - // Identifies whether the user has requested cancellation - // of the operation. Operations that have successfully been cancelled - // have [Operation.error][] value with a - // [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to - // `Code.CANCELLED`. - bool requested_cancellation = 6; - - // API version used to start the operation. - string api_version = 7; - - // API endpoint name of this operation. - string endpoint = 8; -} - -// Request for listing notebook instances. -message ListInstancesRequest { - // Required. Format: - // `parent=projects/{project_id}/locations/{location}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "notebooks.googleapis.com/Instance" - } - ]; - - // Optional. Maximum return size of the list call. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A previous returned page token that can be used to continue - // listing from the last result. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Sort results. Supported values are "name", "name desc" or "" - // (unsorted). - string order_by = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. List filter. - string filter = 5 [(google.api.field_behavior) = OPTIONAL]; -} - -// Response for listing notebook instances. -message ListInstancesResponse { - // A list of returned instances. - repeated Instance instances = 1; - - // Page token that can be used to continue listing from the last result in the - // next list call. - string next_page_token = 2; - - // Locations that could not be reached. For example, - // ['us-west1-a', 'us-central1-b']. - // A ListInstancesResponse will only contain either instances or unreachables, - repeated string unreachable = 3; -} - -// Request for getting a notebook instance. -message GetInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "notebooks.googleapis.com/Instance" - } - ]; -} - -// Request for creating a notebook instance. -message CreateInstanceRequest { - // Required. Format: - // `parent=projects/{project_id}/locations/{location}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "notebooks.googleapis.com/Instance" - } - ]; - - // Required. User-defined unique ID of this instance. - string instance_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The instance to be created. - Instance instance = 3 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Idempotent request UUID. - string request_id = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request for updating a notebook instance. -message UpdateInstanceRequest { - // Required. A representation of an instance. - Instance instance = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Mask used to update an instance - google.protobuf.FieldMask update_mask = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Optional. Idempotent request UUID. - string request_id = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request for deleting a notebook instance. -message DeleteInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "notebooks.googleapis.com/Instance" - } - ]; - - // Optional. Idempotent request UUID. - string request_id = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request for starting a notebook instance -message StartInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for stopping a notebook instance -message StopInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for resetting a notebook instance -message ResetInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for checking if a notebook instance is upgradeable. -message CheckInstanceUpgradabilityRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string notebook_instance = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response for checking if a notebook instance is upgradeable. -message CheckInstanceUpgradabilityResponse { - // If an instance is upgradeable. - bool upgradeable = 1; - - // The version this instance will be upgraded to if calling the upgrade - // endpoint. This field will only be populated if field upgradeable is true. - string upgrade_version = 2; - - // Additional information about upgrade. - string upgrade_info = 3; - - // The new image self link this instance will be upgraded to if calling the - // upgrade endpoint. This field will only be populated if field upgradeable - // is true. - string upgrade_image = 4; -} - -// Request for upgrading a notebook instance -message UpgradeInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for rollbacking a notebook instance -message RollbackInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "notebooks.googleapis.com/Instance" - } - ]; - - // Required. The snapshot for rollback. - // Example: "projects/test-project/global/snapshots/krwlzipynril". - string target_snapshot = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. Output only. Revision Id - string revision_id = 3 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.field_behavior) = REQUIRED - ]; -} - -// Request for creating a notebook instance diagnostic file. -message DiagnoseInstanceRequest { - // Required. Format: - // `projects/{project_id}/locations/{location}/instances/{instance_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "notebooks.googleapis.com/Instance" - } - ]; - - // Required. Defines flags that are used to run the diagnostic tool - DiagnosticConfig diagnostic_config = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Optional. Maxmium amount of time in minutes before the operation times out. - int32 timeout_minutes = 3 [(google.api.field_behavior) = OPTIONAL]; -} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.check_instance_upgradability.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.check_instance_upgradability.js deleted file mode 100644 index 226e4e33fb3..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.check_instance_upgradability.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(notebookInstance) { - // [START notebooks_v2_generated_NotebookService_CheckInstanceUpgradability_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const notebookInstance = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callCheckInstanceUpgradability() { - // Construct request - const request = { - notebookInstance, - }; - - // Run request - const response = await notebooksClient.checkInstanceUpgradability(request); - console.log(response); - } - - callCheckInstanceUpgradability(); - // [END notebooks_v2_generated_NotebookService_CheckInstanceUpgradability_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.create_instance.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.create_instance.js deleted file mode 100644 index c47a2f0c711..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.create_instance.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(parent, instanceId, instance) { - // [START notebooks_v2_generated_NotebookService_CreateInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - */ - // const parent = 'abc123' - /** - * Required. User-defined unique ID of this instance. - */ - // const instanceId = 'abc123' - /** - * Required. The instance to be created. - */ - // const instance = {} - /** - * Optional. Idempotent request UUID. - */ - // const requestId = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callCreateInstance() { - // Construct request - const request = { - parent, - instanceId, - instance, - }; - - // Run request - const [operation] = await notebooksClient.createInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateInstance(); - // [END notebooks_v2_generated_NotebookService_CreateInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.delete_instance.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.delete_instance.js deleted file mode 100644 index d20dd83e65b..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.delete_instance.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(name) { - // [START notebooks_v2_generated_NotebookService_DeleteInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - /** - * Optional. Idempotent request UUID. - */ - // const requestId = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callDeleteInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.deleteInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteInstance(); - // [END notebooks_v2_generated_NotebookService_DeleteInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.diagnose_instance.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.diagnose_instance.js deleted file mode 100644 index 2a68a795b57..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.diagnose_instance.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(name, diagnosticConfig) { - // [START notebooks_v2_generated_NotebookService_DiagnoseInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - /** - * Required. Defines flags that are used to run the diagnostic tool - */ - // const diagnosticConfig = {} - /** - * Optional. Maxmium amount of time in minutes before the operation times out. - */ - // const timeoutMinutes = 1234 - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callDiagnoseInstance() { - // Construct request - const request = { - name, - diagnosticConfig, - }; - - // Run request - const [operation] = await notebooksClient.diagnoseInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDiagnoseInstance(); - // [END notebooks_v2_generated_NotebookService_DiagnoseInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.get_instance.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.get_instance.js deleted file mode 100644 index 1f75cd51458..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.get_instance.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 notebooks_v2_generated_NotebookService_GetInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callGetInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await notebooksClient.getInstance(request); - console.log(response); - } - - callGetInstance(); - // [END notebooks_v2_generated_NotebookService_GetInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.list_instances.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.list_instances.js deleted file mode 100644 index 996876dfe70..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.list_instances.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 notebooks_v2_generated_NotebookService_ListInstances_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - */ - // const parent = 'abc123' - /** - * Optional. Maximum return size of the list call. - */ - // const pageSize = 1234 - /** - * Optional. A previous returned page token that can be used to continue - * listing from the last result. - */ - // const pageToken = 'abc123' - /** - * Optional. Sort results. Supported values are "name", "name desc" or "" - * (unsorted). - */ - // const orderBy = 'abc123' - /** - * Optional. List filter. - */ - // const filter = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callListInstances() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await notebooksClient.listInstancesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListInstances(); - // [END notebooks_v2_generated_NotebookService_ListInstances_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.reset_instance.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.reset_instance.js deleted file mode 100644 index 2e35fc2e837..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.reset_instance.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 notebooks_v2_generated_NotebookService_ResetInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callResetInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.resetInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callResetInstance(); - // [END notebooks_v2_generated_NotebookService_ResetInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.rollback_instance.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.rollback_instance.js deleted file mode 100644 index 5af331d50df..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.rollback_instance.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(name, targetSnapshot, revisionId) { - // [START notebooks_v2_generated_NotebookService_RollbackInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - /** - * Required. The snapshot for rollback. - * Example: "projects/test-project/global/snapshots/krwlzipynril". - */ - // const targetSnapshot = 'abc123' - /** - * Required. Output only. Revision Id - */ - // const revisionId = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callRollbackInstance() { - // Construct request - const request = { - name, - targetSnapshot, - revisionId, - }; - - // Run request - const [operation] = await notebooksClient.rollbackInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRollbackInstance(); - // [END notebooks_v2_generated_NotebookService_RollbackInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.start_instance.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.start_instance.js deleted file mode 100644 index 0e25373f5cf..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.start_instance.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 notebooks_v2_generated_NotebookService_StartInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callStartInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.startInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callStartInstance(); - // [END notebooks_v2_generated_NotebookService_StartInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.stop_instance.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.stop_instance.js deleted file mode 100644 index 5be18e647aa..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.stop_instance.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 notebooks_v2_generated_NotebookService_StopInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callStopInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.stopInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callStopInstance(); - // [END notebooks_v2_generated_NotebookService_StopInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.update_instance.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.update_instance.js deleted file mode 100644 index ecbc45352f0..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.update_instance.js +++ /dev/null @@ -1,71 +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(instance, updateMask) { - // [START notebooks_v2_generated_NotebookService_UpdateInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A representation of an instance. - */ - // const instance = {} - /** - * Required. Mask used to update an instance - */ - // const updateMask = {} - /** - * Optional. Idempotent request UUID. - */ - // const requestId = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callUpdateInstance() { - // Construct request - const request = { - instance, - updateMask, - }; - - // Run request - const [operation] = await notebooksClient.updateInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateInstance(); - // [END notebooks_v2_generated_NotebookService_UpdateInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.upgrade_instance.js b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.upgrade_instance.js deleted file mode 100644 index 43bd123be1b..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/notebook_service.upgrade_instance.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 notebooks_v2_generated_NotebookService_UpgradeInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - */ - // const name = 'abc123' - - // Imports the Notebooks library - const {NotebookServiceClient} = require('@google-cloud/notebooks').v2; - - // Instantiates a client - const notebooksClient = new NotebookServiceClient(); - - async function callUpgradeInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await notebooksClient.upgradeInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpgradeInstance(); - // [END notebooks_v2_generated_NotebookService_UpgradeInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/snippet_metadata_google.cloud.notebooks.v2.json b/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/snippet_metadata_google.cloud.notebooks.v2.json deleted file mode 100644 index 51586370b43..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/samples/generated/v2/snippet_metadata_google.cloud.notebooks.v2.json +++ /dev/null @@ -1,551 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-notebooks", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.notebooks.v2", - "version": "v2" - } - ] - }, - "snippets": [ - { - "regionTag": "notebooks_v2_generated_NotebookService_ListInstances_async", - "title": "NotebookService listInstances Sample", - "origin": "API_DEFINITION", - "description": " Lists instances in a given project and location.", - "canonical": true, - "file": "notebook_service.list_instances.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 74, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListInstances", - "fullName": "google.cloud.notebooks.v2.NotebookService.ListInstances", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "order_by", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.notebooks.v2.ListInstancesResponse", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" - }, - "method": { - "shortName": "ListInstances", - "fullName": "google.cloud.notebooks.v2.NotebookService.ListInstances", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v2.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v2_generated_NotebookService_GetInstance_async", - "title": "NotebookService getInstance Sample", - "origin": "API_DEFINITION", - "description": " Gets details of a single Instance.", - "canonical": true, - "file": "notebook_service.get_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetInstance", - "fullName": "google.cloud.notebooks.v2.NotebookService.GetInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.notebooks.v2.Instance", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" - }, - "method": { - "shortName": "GetInstance", - "fullName": "google.cloud.notebooks.v2.NotebookService.GetInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v2.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v2_generated_NotebookService_CreateInstance_async", - "title": "NotebookService createInstance Sample", - "origin": "API_DEFINITION", - "description": " Creates a new Instance in a given project and location.", - "canonical": true, - "file": "notebook_service.create_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateInstance", - "fullName": "google.cloud.notebooks.v2.NotebookService.CreateInstance", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "instance_id", - "type": "TYPE_STRING" - }, - { - "name": "instance", - "type": ".google.cloud.notebooks.v2.Instance" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" - }, - "method": { - "shortName": "CreateInstance", - "fullName": "google.cloud.notebooks.v2.NotebookService.CreateInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v2.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v2_generated_NotebookService_UpdateInstance_async", - "title": "NotebookService updateInstance Sample", - "origin": "API_DEFINITION", - "description": " UpdateInstance updates an Instance.", - "canonical": true, - "file": "notebook_service.update_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateInstance", - "fullName": "google.cloud.notebooks.v2.NotebookService.UpdateInstance", - "async": true, - "parameters": [ - { - "name": "instance", - "type": ".google.cloud.notebooks.v2.Instance" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" - }, - "method": { - "shortName": "UpdateInstance", - "fullName": "google.cloud.notebooks.v2.NotebookService.UpdateInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v2.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v2_generated_NotebookService_DeleteInstance_async", - "title": "NotebookService deleteInstance Sample", - "origin": "API_DEFINITION", - "description": " Deletes a single Instance.", - "canonical": true, - "file": "notebook_service.delete_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteInstance", - "fullName": "google.cloud.notebooks.v2.NotebookService.DeleteInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" - }, - "method": { - "shortName": "DeleteInstance", - "fullName": "google.cloud.notebooks.v2.NotebookService.DeleteInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v2.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v2_generated_NotebookService_StartInstance_async", - "title": "NotebookService startInstance Sample", - "origin": "API_DEFINITION", - "description": " Starts a notebook instance.", - "canonical": true, - "file": "notebook_service.start_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "StartInstance", - "fullName": "google.cloud.notebooks.v2.NotebookService.StartInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" - }, - "method": { - "shortName": "StartInstance", - "fullName": "google.cloud.notebooks.v2.NotebookService.StartInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v2.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v2_generated_NotebookService_StopInstance_async", - "title": "NotebookService stopInstance Sample", - "origin": "API_DEFINITION", - "description": " Stops a notebook instance.", - "canonical": true, - "file": "notebook_service.stop_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "StopInstance", - "fullName": "google.cloud.notebooks.v2.NotebookService.StopInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" - }, - "method": { - "shortName": "StopInstance", - "fullName": "google.cloud.notebooks.v2.NotebookService.StopInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v2.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v2_generated_NotebookService_ResetInstance_async", - "title": "NotebookService resetInstance Sample", - "origin": "API_DEFINITION", - "description": " Resets a notebook instance.", - "canonical": true, - "file": "notebook_service.reset_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ResetInstance", - "fullName": "google.cloud.notebooks.v2.NotebookService.ResetInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" - }, - "method": { - "shortName": "ResetInstance", - "fullName": "google.cloud.notebooks.v2.NotebookService.ResetInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v2.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v2_generated_NotebookService_CheckInstanceUpgradability_async", - "title": "NotebookService checkInstanceUpgradability Sample", - "origin": "API_DEFINITION", - "description": " Checks whether a notebook instance is upgradable.", - "canonical": true, - "file": "notebook_service.check_instance_upgradability.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CheckInstanceUpgradability", - "fullName": "google.cloud.notebooks.v2.NotebookService.CheckInstanceUpgradability", - "async": true, - "parameters": [ - { - "name": "notebook_instance", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.notebooks.v2.CheckInstanceUpgradabilityResponse", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" - }, - "method": { - "shortName": "CheckInstanceUpgradability", - "fullName": "google.cloud.notebooks.v2.NotebookService.CheckInstanceUpgradability", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v2.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v2_generated_NotebookService_UpgradeInstance_async", - "title": "NotebookService upgradeInstance Sample", - "origin": "API_DEFINITION", - "description": " Upgrades a notebook instance to the latest version.", - "canonical": true, - "file": "notebook_service.upgrade_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpgradeInstance", - "fullName": "google.cloud.notebooks.v2.NotebookService.UpgradeInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" - }, - "method": { - "shortName": "UpgradeInstance", - "fullName": "google.cloud.notebooks.v2.NotebookService.UpgradeInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v2.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v2_generated_NotebookService_RollbackInstance_async", - "title": "NotebookService rollbackInstance Sample", - "origin": "API_DEFINITION", - "description": " Rollbacks a notebook instance to the previous version.", - "canonical": true, - "file": "notebook_service.rollback_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RollbackInstance", - "fullName": "google.cloud.notebooks.v2.NotebookService.RollbackInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "target_snapshot", - "type": "TYPE_STRING" - }, - { - "name": "revision_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" - }, - "method": { - "shortName": "RollbackInstance", - "fullName": "google.cloud.notebooks.v2.NotebookService.RollbackInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v2.NotebookService" - } - } - } - }, - { - "regionTag": "notebooks_v2_generated_NotebookService_DiagnoseInstance_async", - "title": "NotebookService diagnoseInstance Sample", - "origin": "API_DEFINITION", - "description": " Creates a Diagnostic File and runs Diagnostic Tool given an Instance.", - "canonical": true, - "file": "notebook_service.diagnose_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DiagnoseInstance", - "fullName": "google.cloud.notebooks.v2.NotebookService.DiagnoseInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "diagnostic_config", - "type": ".google.cloud.notebooks.v2.DiagnosticConfig" - }, - { - "name": "timeout_minutes", - "type": "TYPE_INT32" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "NotebookServiceClient", - "fullName": "google.cloud.notebooks.v2.NotebookServiceClient" - }, - "method": { - "shortName": "DiagnoseInstance", - "fullName": "google.cloud.notebooks.v2.NotebookService.DiagnoseInstance", - "service": { - "shortName": "NotebookService", - "fullName": "google.cloud.notebooks.v2.NotebookService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/src/index.ts b/owl-bot-staging/google-cloud-notebooks/v2/src/index.ts deleted file mode 100644 index a05bfd55a28..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/src/index.ts +++ /dev/null @@ -1,25 +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 NotebookServiceClient = v2.NotebookServiceClient; -type NotebookServiceClient = v2.NotebookServiceClient; -export {v2, NotebookServiceClient}; -export default {v2, NotebookServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/src/v2/gapic_metadata.json b/owl-bot-staging/google-cloud-notebooks/v2/src/v2/gapic_metadata.json deleted file mode 100644 index 07e9638a231..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/src/v2/gapic_metadata.json +++ /dev/null @@ -1,147 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.notebooks.v2", - "libraryPackage": "@google-cloud/notebooks", - "services": { - "NotebookService": { - "clients": { - "grpc": { - "libraryClient": "NotebookServiceClient", - "rpcs": { - "GetInstance": { - "methods": [ - "getInstance" - ] - }, - "CheckInstanceUpgradability": { - "methods": [ - "checkInstanceUpgradability" - ] - }, - "CreateInstance": { - "methods": [ - "createInstance" - ] - }, - "UpdateInstance": { - "methods": [ - "updateInstance" - ] - }, - "DeleteInstance": { - "methods": [ - "deleteInstance" - ] - }, - "StartInstance": { - "methods": [ - "startInstance" - ] - }, - "StopInstance": { - "methods": [ - "stopInstance" - ] - }, - "ResetInstance": { - "methods": [ - "resetInstance" - ] - }, - "UpgradeInstance": { - "methods": [ - "upgradeInstance" - ] - }, - "RollbackInstance": { - "methods": [ - "rollbackInstance" - ] - }, - "DiagnoseInstance": { - "methods": [ - "diagnoseInstance" - ] - }, - "ListInstances": { - "methods": [ - "listInstances", - "listInstancesStream", - "listInstancesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "NotebookServiceClient", - "rpcs": { - "GetInstance": { - "methods": [ - "getInstance" - ] - }, - "CheckInstanceUpgradability": { - "methods": [ - "checkInstanceUpgradability" - ] - }, - "CreateInstance": { - "methods": [ - "createInstance" - ] - }, - "UpdateInstance": { - "methods": [ - "updateInstance" - ] - }, - "DeleteInstance": { - "methods": [ - "deleteInstance" - ] - }, - "StartInstance": { - "methods": [ - "startInstance" - ] - }, - "StopInstance": { - "methods": [ - "stopInstance" - ] - }, - "ResetInstance": { - "methods": [ - "resetInstance" - ] - }, - "UpgradeInstance": { - "methods": [ - "upgradeInstance" - ] - }, - "RollbackInstance": { - "methods": [ - "rollbackInstance" - ] - }, - "DiagnoseInstance": { - "methods": [ - "diagnoseInstance" - ] - }, - "ListInstances": { - "methods": [ - "listInstances", - "listInstancesStream", - "listInstancesAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/src/v2/index.ts b/owl-bot-staging/google-cloud-notebooks/v2/src/v2/index.ts deleted file mode 100644 index 5f1ec6b1546..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/src/v2/index.ts +++ /dev/null @@ -1,19 +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 {NotebookServiceClient} from './notebook_service_client'; diff --git a/owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_client.ts b/owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_client.ts deleted file mode 100644 index 126c4b7441e..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_client.ts +++ /dev/null @@ -1,2099 +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, IamClient, IamProtos, 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/notebook_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './notebook_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * API v2 service for Workbench Notebooks Instances. - * @class - * @memberof v2 - */ -export class NotebookServiceClient { - 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}; - iamClient: IamClient; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - notebookServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of NotebookServiceClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 NotebookServiceClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof NotebookServiceClient; - 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.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - - 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 { - 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 = { - instancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listInstances: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instances') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v2/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v2/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v2/{resource=projects/*/locations/*/instances/*}:getIamPolicy',},{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v2/{resource=projects/*/locations/*/instances/*}:setIamPolicy',body: '*',},{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v2/{resource=projects/*/locations/*/instances/*}:testIamPermissions',body: '*',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v2/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; - const createInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; - const updateInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; - const updateInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; - const deleteInstanceResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; - const startInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; - const startInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; - const stopInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; - const stopInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; - const resetInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; - const resetInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; - const upgradeInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; - const upgradeInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; - const rollbackInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; - const rollbackInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; - const diagnoseInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; - const diagnoseInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createInstanceResponse.decode.bind(createInstanceResponse), - createInstanceMetadata.decode.bind(createInstanceMetadata)), - updateInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateInstanceResponse.decode.bind(updateInstanceResponse), - updateInstanceMetadata.decode.bind(updateInstanceMetadata)), - deleteInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteInstanceResponse.decode.bind(deleteInstanceResponse), - deleteInstanceMetadata.decode.bind(deleteInstanceMetadata)), - startInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - startInstanceResponse.decode.bind(startInstanceResponse), - startInstanceMetadata.decode.bind(startInstanceMetadata)), - stopInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - stopInstanceResponse.decode.bind(stopInstanceResponse), - stopInstanceMetadata.decode.bind(stopInstanceMetadata)), - resetInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - resetInstanceResponse.decode.bind(resetInstanceResponse), - resetInstanceMetadata.decode.bind(resetInstanceMetadata)), - upgradeInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - upgradeInstanceResponse.decode.bind(upgradeInstanceResponse), - upgradeInstanceMetadata.decode.bind(upgradeInstanceMetadata)), - rollbackInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - rollbackInstanceResponse.decode.bind(rollbackInstanceResponse), - rollbackInstanceMetadata.decode.bind(rollbackInstanceMetadata)), - diagnoseInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - diagnoseInstanceResponse.decode.bind(diagnoseInstanceResponse), - diagnoseInstanceMetadata.decode.bind(diagnoseInstanceMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.notebooks.v2.NotebookService', 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.notebookServiceStub) { - return this.notebookServiceStub; - } - - // Put together the "service stub" for - // google.cloud.notebooks.v2.NotebookService. - this.notebookServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.notebooks.v2.NotebookService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.notebooks.v2.NotebookService, - 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 notebookServiceStubMethods = - ['listInstances', 'getInstance', 'createInstance', 'updateInstance', 'deleteInstance', 'startInstance', 'stopInstance', 'resetInstance', 'checkInstanceUpgradability', 'upgradeInstance', 'rollbackInstance', 'diagnoseInstance']; - for (const methodName of notebookServiceStubMethods) { - const callPromise = this.notebookServiceStub.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.notebookServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'notebooks.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 'notebooks.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 details of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v2.Instance|Instance}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.get_instance.js - * region_tag:notebooks_v2_generated_NotebookService_GetInstance_async - */ - getInstance( - request?: protos.google.cloud.notebooks.v2.IGetInstanceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v2.IInstance, - protos.google.cloud.notebooks.v2.IGetInstanceRequest|undefined, {}|undefined - ]>; - getInstance( - request: protos.google.cloud.notebooks.v2.IGetInstanceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v2.IInstance, - protos.google.cloud.notebooks.v2.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; - getInstance( - request: protos.google.cloud.notebooks.v2.IGetInstanceRequest, - callback: Callback< - protos.google.cloud.notebooks.v2.IInstance, - protos.google.cloud.notebooks.v2.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; - getInstance( - request?: protos.google.cloud.notebooks.v2.IGetInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v2.IInstance, - protos.google.cloud.notebooks.v2.IGetInstanceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.notebooks.v2.IInstance, - protos.google.cloud.notebooks.v2.IGetInstanceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v2.IInstance, - protos.google.cloud.notebooks.v2.IGetInstanceRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getInstance(request, options, callback); - } -/** - * Checks whether a notebook instance is upgradable. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.notebookInstance - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityResponse|CheckInstanceUpgradabilityResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.check_instance_upgradability.js - * region_tag:notebooks_v2_generated_NotebookService_CheckInstanceUpgradability_async - */ - checkInstanceUpgradability( - request?: protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest|undefined, {}|undefined - ]>; - checkInstanceUpgradability( - request: protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest|null|undefined, - {}|null|undefined>): void; - checkInstanceUpgradability( - request: protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest, - callback: Callback< - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest|null|undefined, - {}|null|undefined>): void; - checkInstanceUpgradability( - request?: protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'notebook_instance': request.notebookInstance ?? '', - }); - this.initialize(); - return this.innerApiCalls.checkInstanceUpgradability(request, options, callback); - } - -/** - * Creates a new Instance in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {string} request.instanceId - * Required. User-defined unique ID of this instance. - * @param {google.cloud.notebooks.v2.Instance} request.instance - * Required. The instance to be created. - * @param {string} [request.requestId] - * Optional. Idempotent request UUID. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.create_instance.js - * region_tag:notebooks_v2_generated_NotebookService_CreateInstance_async - */ - createInstance( - request?: protos.google.cloud.notebooks.v2.ICreateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createInstance( - request: protos.google.cloud.notebooks.v2.ICreateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createInstance( - request: protos.google.cloud.notebooks.v2.ICreateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createInstance( - request?: protos.google.cloud.notebooks.v2.ICreateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.create_instance.js - * region_tag:notebooks_v2_generated_NotebookService_CreateInstance_async - */ - async checkCreateInstanceProgress(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.createInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * UpdateInstance updates an Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.notebooks.v2.Instance} request.instance - * Required. A representation of an instance. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask used to update an instance - * @param {string} [request.requestId] - * Optional. Idempotent request UUID. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.update_instance.js - * region_tag:notebooks_v2_generated_NotebookService_UpdateInstance_async - */ - updateInstance( - request?: protos.google.cloud.notebooks.v2.IUpdateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateInstance( - request: protos.google.cloud.notebooks.v2.IUpdateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateInstance( - request: protos.google.cloud.notebooks.v2.IUpdateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateInstance( - request?: protos.google.cloud.notebooks.v2.IUpdateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'instance.name': request.instance!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.update_instance.js - * region_tag:notebooks_v2_generated_NotebookService_UpdateInstance_async - */ - async checkUpdateInstanceProgress(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.updateInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {string} [request.requestId] - * Optional. Idempotent request UUID. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.delete_instance.js - * region_tag:notebooks_v2_generated_NotebookService_DeleteInstance_async - */ - deleteInstance( - request?: protos.google.cloud.notebooks.v2.IDeleteInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteInstance( - request: protos.google.cloud.notebooks.v2.IDeleteInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteInstance( - request: protos.google.cloud.notebooks.v2.IDeleteInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteInstance( - request?: protos.google.cloud.notebooks.v2.IDeleteInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.delete_instance.js - * region_tag:notebooks_v2_generated_NotebookService_DeleteInstance_async - */ - async checkDeleteInstanceProgress(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.deleteInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Starts a notebook instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.start_instance.js - * region_tag:notebooks_v2_generated_NotebookService_StartInstance_async - */ - startInstance( - request?: protos.google.cloud.notebooks.v2.IStartInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - startInstance( - request: protos.google.cloud.notebooks.v2.IStartInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - startInstance( - request: protos.google.cloud.notebooks.v2.IStartInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - startInstance( - request?: protos.google.cloud.notebooks.v2.IStartInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.startInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `startInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.start_instance.js - * region_tag:notebooks_v2_generated_NotebookService_StartInstance_async - */ - async checkStartInstanceProgress(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.startInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Stops a notebook instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.stop_instance.js - * region_tag:notebooks_v2_generated_NotebookService_StopInstance_async - */ - stopInstance( - request?: protos.google.cloud.notebooks.v2.IStopInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - stopInstance( - request: protos.google.cloud.notebooks.v2.IStopInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - stopInstance( - request: protos.google.cloud.notebooks.v2.IStopInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - stopInstance( - request?: protos.google.cloud.notebooks.v2.IStopInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.stopInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `stopInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.stop_instance.js - * region_tag:notebooks_v2_generated_NotebookService_StopInstance_async - */ - async checkStopInstanceProgress(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.stopInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Resets a notebook instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.reset_instance.js - * region_tag:notebooks_v2_generated_NotebookService_ResetInstance_async - */ - resetInstance( - request?: protos.google.cloud.notebooks.v2.IResetInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - resetInstance( - request: protos.google.cloud.notebooks.v2.IResetInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - resetInstance( - request: protos.google.cloud.notebooks.v2.IResetInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - resetInstance( - request?: protos.google.cloud.notebooks.v2.IResetInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.resetInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `resetInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.reset_instance.js - * region_tag:notebooks_v2_generated_NotebookService_ResetInstance_async - */ - async checkResetInstanceProgress(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.resetInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Upgrades a notebook instance to the latest version. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.upgrade_instance.js - * region_tag:notebooks_v2_generated_NotebookService_UpgradeInstance_async - */ - upgradeInstance( - request?: protos.google.cloud.notebooks.v2.IUpgradeInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - upgradeInstance( - request: protos.google.cloud.notebooks.v2.IUpgradeInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - upgradeInstance( - request: protos.google.cloud.notebooks.v2.IUpgradeInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - upgradeInstance( - request?: protos.google.cloud.notebooks.v2.IUpgradeInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.upgradeInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `upgradeInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.upgrade_instance.js - * region_tag:notebooks_v2_generated_NotebookService_UpgradeInstance_async - */ - async checkUpgradeInstanceProgress(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.upgradeInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Rollbacks a notebook instance to the previous version. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {string} request.targetSnapshot - * Required. The snapshot for rollback. - * Example: "projects/test-project/global/snapshots/krwlzipynril". - * @param {string} request.revisionId - * Required. Output only. Revision Id - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.rollback_instance.js - * region_tag:notebooks_v2_generated_NotebookService_RollbackInstance_async - */ - rollbackInstance( - request?: protos.google.cloud.notebooks.v2.IRollbackInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - rollbackInstance( - request: protos.google.cloud.notebooks.v2.IRollbackInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - rollbackInstance( - request: protos.google.cloud.notebooks.v2.IRollbackInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - rollbackInstance( - request?: protos.google.cloud.notebooks.v2.IRollbackInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.rollbackInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `rollbackInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.rollback_instance.js - * region_tag:notebooks_v2_generated_NotebookService_RollbackInstance_async - */ - async checkRollbackInstanceProgress(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.rollbackInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Creates a Diagnostic File and runs Diagnostic Tool given an Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {google.cloud.notebooks.v2.DiagnosticConfig} request.diagnosticConfig - * Required. Defines flags that are used to run the diagnostic tool - * @param {number} [request.timeoutMinutes] - * Optional. Maxmium amount of time in minutes before the operation times out. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.diagnose_instance.js - * region_tag:notebooks_v2_generated_NotebookService_DiagnoseInstance_async - */ - diagnoseInstance( - request?: protos.google.cloud.notebooks.v2.IDiagnoseInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - diagnoseInstance( - request: protos.google.cloud.notebooks.v2.IDiagnoseInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - diagnoseInstance( - request: protos.google.cloud.notebooks.v2.IDiagnoseInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - diagnoseInstance( - request?: protos.google.cloud.notebooks.v2.IDiagnoseInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.diagnoseInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `diagnoseInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.diagnose_instance.js - * region_tag:notebooks_v2_generated_NotebookService_DiagnoseInstance_async - */ - async checkDiagnoseInstanceProgress(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.diagnoseInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists instances in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} [request.pageSize] - * Optional. Maximum return size of the list call. - * @param {string} [request.pageToken] - * Optional. A previous returned page token that can be used to continue - * listing from the last result. - * @param {string} [request.orderBy] - * Optional. Sort results. Supported values are "name", "name desc" or "" - * (unsorted). - * @param {string} [request.filter] - * Optional. List filter. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.notebooks.v2.Instance|Instance}. - * 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 `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listInstances( - request?: protos.google.cloud.notebooks.v2.IListInstancesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v2.IInstance[], - protos.google.cloud.notebooks.v2.IListInstancesRequest|null, - protos.google.cloud.notebooks.v2.IListInstancesResponse - ]>; - listInstances( - request: protos.google.cloud.notebooks.v2.IListInstancesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.notebooks.v2.IListInstancesRequest, - protos.google.cloud.notebooks.v2.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v2.IInstance>): void; - listInstances( - request: protos.google.cloud.notebooks.v2.IListInstancesRequest, - callback: PaginationCallback< - protos.google.cloud.notebooks.v2.IListInstancesRequest, - protos.google.cloud.notebooks.v2.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v2.IInstance>): void; - listInstances( - request?: protos.google.cloud.notebooks.v2.IListInstancesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.notebooks.v2.IListInstancesRequest, - protos.google.cloud.notebooks.v2.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v2.IInstance>, - callback?: PaginationCallback< - protos.google.cloud.notebooks.v2.IListInstancesRequest, - protos.google.cloud.notebooks.v2.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v2.IInstance>): - Promise<[ - protos.google.cloud.notebooks.v2.IInstance[], - protos.google.cloud.notebooks.v2.IListInstancesRequest|null, - protos.google.cloud.notebooks.v2.IListInstancesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listInstances(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. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} [request.pageSize] - * Optional. Maximum return size of the list call. - * @param {string} [request.pageToken] - * Optional. A previous returned page token that can be used to continue - * listing from the last result. - * @param {string} [request.orderBy] - * Optional. Sort results. Supported values are "name", "name desc" or "" - * (unsorted). - * @param {string} [request.filter] - * Optional. List filter. - * @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 protos.google.cloud.notebooks.v2.Instance|Instance} 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 `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listInstancesStream( - request?: protos.google.cloud.notebooks.v2.IListInstancesRequest, - 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['listInstances']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInstances.createStream( - this.innerApiCalls.listInstances as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listInstances`, 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. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} [request.pageSize] - * Optional. Maximum return size of the list call. - * @param {string} [request.pageToken] - * Optional. A previous returned page token that can be used to continue - * listing from the last result. - * @param {string} [request.orderBy] - * Optional. Sort results. Supported values are "name", "name desc" or "" - * (unsorted). - * @param {string} [request.filter] - * Optional. List filter. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.notebooks.v2.Instance|Instance}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.list_instances.js - * region_tag:notebooks_v2_generated_NotebookService_ListInstances_async - */ - listInstancesAsync( - request?: protos.google.cloud.notebooks.v2.IListInstancesRequest, - 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['listInstances']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInstances.asyncIterate( - this.innerApiCalls['listInstances'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @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/interfaces/CallOptions.html | 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.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - getIamPolicy( - request: IamProtos.google.iam.v1.GetIamPolicyRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, - {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { - return this.iamClient.getIamPolicy(request, options, callback); - } - -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - setIamPolicy( - request: IamProtos.google.iam.v1.SetIamPolicyRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, - {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { - return this.iamClient.setIamPolicy(request, options, callback); - } - -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @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/interfaces/CallOptions.html | 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.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ - testIamPermissions( - request: IamProtos.google.iam.v1.TestIamPermissionsRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.TestIamPermissionsResponse, - IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.TestIamPermissionsResponse, - IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, - {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { - return this.iamClient.testIamPermissions(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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 instance resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} instance - * @returns {string} Resource name string. - */ - instancePath(project:string,location:string,instance:string) { - return this.pathTemplates.instancePathTemplate.render({ - project: project, - location: location, - instance: instance, - }); - } - - /** - * Parse the project from Instance resource. - * - * @param {string} instanceName - * A fully-qualified path representing Instance resource. - * @returns {string} A string representing the project. - */ - matchProjectFromInstanceName(instanceName: string) { - return this.pathTemplates.instancePathTemplate.match(instanceName).project; - } - - /** - * Parse the location from Instance resource. - * - * @param {string} instanceName - * A fully-qualified path representing Instance resource. - * @returns {string} A string representing the location. - */ - matchLocationFromInstanceName(instanceName: string) { - return this.pathTemplates.instancePathTemplate.match(instanceName).location; - } - - /** - * Parse the instance from Instance resource. - * - * @param {string} instanceName - * A fully-qualified path representing Instance resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromInstanceName(instanceName: string) { - return this.pathTemplates.instancePathTemplate.match(instanceName).instance; - } - - /** - * 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 project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.notebookServiceStub && !this._terminated) { - return this.notebookServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.iamClient.close(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_client_config.json b/owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_client_config.json deleted file mode 100644 index e8f6f421921..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_client_config.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "interfaces": { - "google.cloud.notebooks.v2.NotebookService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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": { - "ListInstances": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateInstance": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "DeleteInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "StartInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "StopInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ResetInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CheckInstanceUpgradability": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "UpgradeInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RollbackInstance": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DiagnoseInstance": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_proto_list.json b/owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_proto_list.json deleted file mode 100644 index 3b19a9b7a72..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/src/v2/notebook_service_proto_list.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - "../../protos/google/cloud/notebooks/v2/diagnostic_config.proto", - "../../protos/google/cloud/notebooks/v2/event.proto", - "../../protos/google/cloud/notebooks/v2/gce_setup.proto", - "../../protos/google/cloud/notebooks/v2/instance.proto", - "../../protos/google/cloud/notebooks/v2/service.proto" -] diff --git a/owl-bot-staging/google-cloud-notebooks/v2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-notebooks/v2/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 193e9b0e75d..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const notebooks = require('@google-cloud/notebooks'); - -function main() { - const notebookServiceClient = new notebooks.NotebookServiceClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-notebooks/v2/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 624792a563f..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {NotebookServiceClient} from '@google-cloud/notebooks'; - -// check that the client class type name can be used -function doStuffWithNotebookServiceClient(client: NotebookServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const notebookServiceClient = new NotebookServiceClient(); - doStuffWithNotebookServiceClient(notebookServiceClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/system-test/install.ts b/owl-bot-staging/google-cloud-notebooks/v2/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/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-notebooks/v2/test/gapic_notebook_service_v2.ts b/owl-bot-staging/google-cloud-notebooks/v2/test/gapic_notebook_service_v2.ts deleted file mode 100644 index c85784f8a2f..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/v2/test/gapic_notebook_service_v2.ts +++ /dev/null @@ -1,2878 +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 notebookserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos, IamProtos, 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.NotebookServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = notebookserviceModule.v2.NotebookServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = notebookserviceModule.v2.NotebookServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = notebookserviceModule.v2.NotebookServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new notebookserviceModule.v2.NotebookServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.notebookServiceStub, undefined); - await client.initialize(); - assert(client.notebookServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.notebookServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.notebookServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new notebookserviceModule.v2.NotebookServiceClient({ - 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 notebookserviceModule.v2.NotebookServiceClient({ - 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('getInstance', () => { - it('invokes getInstance without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v2.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); - const [response] = await client.getInstance(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstance without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v2.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstance( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v2.IInstance|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstance with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstance with closed client', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getInstance(request), expectedError); - }); - }); - - describe('checkInstanceUpgradability', () => { - it('invokes checkInstanceUpgradability without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedHeaderRequestParams = `notebook_instance=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityResponse() - ); - client.innerApiCalls.checkInstanceUpgradability = stubSimpleCall(expectedResponse); - const [response] = await client.checkInstanceUpgradability(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.checkInstanceUpgradability as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.checkInstanceUpgradability as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkInstanceUpgradability without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedHeaderRequestParams = `notebook_instance=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityResponse() - ); - client.innerApiCalls.checkInstanceUpgradability = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.checkInstanceUpgradability( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.checkInstanceUpgradability as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.checkInstanceUpgradability as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkInstanceUpgradability with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedHeaderRequestParams = `notebook_instance=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.checkInstanceUpgradability = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkInstanceUpgradability(request), expectedError); - const actualRequest = (client.innerApiCalls.checkInstanceUpgradability as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.checkInstanceUpgradability as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkInstanceUpgradability with closed client', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.checkInstanceUpgradability(request), expectedError); - }); - }); - - describe('createInstance', () => { - it('invokes createInstance without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.createInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInstance without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createInstance( - request, - (err?: Error|null, - result?: 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.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInstance with call error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInstance with LRO error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateInstanceProgress without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateInstanceProgress with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateInstance', () => { - it('invokes updateInstance without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstance without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateInstance( - request, - (err?: Error|null, - result?: 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.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstance with call error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstance with LRO error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateInstanceProgress without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateInstanceProgress with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteInstance', () => { - it('invokes deleteInstance without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInstance without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteInstance( - request, - (err?: Error|null, - result?: 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.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInstance with call error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInstance with LRO error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteInstanceProgress without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteInstanceProgress with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('startInstance', () => { - it('invokes startInstance without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.startInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startInstance without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.startInstance( - request, - (err?: Error|null, - result?: 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.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startInstance with call error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.startInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.startInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startInstance with LRO error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.startInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.startInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkStartInstanceProgress without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkStartInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkStartInstanceProgress with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStartInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('stopInstance', () => { - it('invokes stopInstance without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.stopInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopInstance without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.stopInstance( - request, - (err?: Error|null, - result?: 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.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopInstance with call error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.stopInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopInstance with LRO error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.stopInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkStopInstanceProgress without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkStopInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkStopInstanceProgress with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStopInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('resetInstance', () => { - it('invokes resetInstance without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.resetInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.resetInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetInstance without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.resetInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resetInstance( - request, - (err?: Error|null, - result?: 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.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetInstance with call error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.resetInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.resetInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetInstance with LRO error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.resetInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.resetInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkResetInstanceProgress without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkResetInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkResetInstanceProgress with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkResetInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('upgradeInstance', () => { - it('invokes upgradeInstance without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.upgradeInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstance without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.upgradeInstance( - request, - (err?: Error|null, - result?: 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.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstance with call error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.upgradeInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstance with LRO error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.upgradeInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpgradeInstanceProgress without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpgradeInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpgradeInstanceProgress with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpgradeInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('rollbackInstance', () => { - it('invokes rollbackInstance without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.RollbackInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.RollbackInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rollbackInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.rollbackInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rollbackInstance without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.RollbackInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.RollbackInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rollbackInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rollbackInstance( - request, - (err?: Error|null, - result?: 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.rollbackInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rollbackInstance with call error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.RollbackInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.RollbackInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.rollbackInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rollbackInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rollbackInstance with LRO error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.RollbackInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.RollbackInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.rollbackInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rollbackInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkRollbackInstanceProgress without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRollbackInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRollbackInstanceProgress with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRollbackInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('diagnoseInstance', () => { - it('invokes diagnoseInstance without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.DiagnoseInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.DiagnoseInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.diagnoseInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.diagnoseInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes diagnoseInstance without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.DiagnoseInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.DiagnoseInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.diagnoseInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.diagnoseInstance( - request, - (err?: Error|null, - result?: 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.diagnoseInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes diagnoseInstance with call error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.DiagnoseInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.DiagnoseInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.diagnoseInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.diagnoseInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes diagnoseInstance with LRO error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.DiagnoseInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.DiagnoseInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.diagnoseInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.diagnoseInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDiagnoseInstanceProgress without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDiagnoseInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDiagnoseInstanceProgress with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDiagnoseInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listInstances', () => { - it('invokes listInstances without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); - const [response] = await client.listInstances(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstances without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInstances( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v2.IInstance[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstances with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInstances(request), expectedError); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstancesStream without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - ]; - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v2.Instance[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v2.Instance) => { - 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.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listInstancesStream with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v2.Instance[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v2.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInstances without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - ]; - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.notebooks.v2.IInstance[] = []; - const iterable = client.listInstancesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInstances with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInstancesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.notebooks.v2.IInstance[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - 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 notebookserviceModule.v2.NotebookServiceClient({ - 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 notebookserviceModule.v2.NotebookServiceClient({ - 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 notebookserviceModule.v2.NotebookServiceClient({ - 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 notebookserviceModule.v2.NotebookServiceClient({ - 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 notebookserviceModule.v2.NotebookServiceClient({ - 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 notebookserviceModule.v2.NotebookServiceClient({ - 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 notebookserviceModule.v2.NotebookServiceClient({ - 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 notebookserviceModule.v2.NotebookServiceClient({ - 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 notebookserviceModule.v2.NotebookServiceClient({ - 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 notebookserviceModule.v2.NotebookServiceClient({ - 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 notebookserviceModule.v2.NotebookServiceClient({ - 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 notebookserviceModule.v2.NotebookServiceClient({ - 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 notebookserviceModule.v2.NotebookServiceClient({ - 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 notebookserviceModule.v2.NotebookServiceClient({ - 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 notebookserviceModule.v2.NotebookServiceClient({ - 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('instance', () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - }; - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "locationValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromInstanceName', () => { - const result = client.matchLocationFromInstanceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new notebookserviceModule.v2.NotebookServiceClient({ - 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('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-notebooks/v2/tsconfig.json b/owl-bot-staging/google-cloud-notebooks/v2/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/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-notebooks/v2/webpack.config.js b/owl-bot-staging/google-cloud-notebooks/v2/webpack.config.js deleted file mode 100644 index b41a2c182e9..00000000000 --- a/owl-bot-staging/google-cloud-notebooks/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: 'NotebookService', - filename: './notebook-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-optimization/v1/.eslintignore b/owl-bot-staging/google-cloud-optimization/v1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-optimization/v1/.eslintrc.json b/owl-bot-staging/google-cloud-optimization/v1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-optimization/v1/.gitignore b/owl-bot-staging/google-cloud-optimization/v1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-optimization/v1/.jsdoc.js b/owl-bot-staging/google-cloud-optimization/v1/.jsdoc.js deleted file mode 100644 index 0c4bf8eb4ef..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/.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/optimization', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-optimization/v1/.mocharc.js b/owl-bot-staging/google-cloud-optimization/v1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/.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-optimization/v1/.prettierrc.js b/owl-bot-staging/google-cloud-optimization/v1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/.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-optimization/v1/README.md b/owl-bot-staging/google-cloud-optimization/v1/README.md deleted file mode 100644 index 14af819c25c..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Optimization: Nodejs Client diff --git a/owl-bot-staging/google-cloud-optimization/v1/package.json b/owl-bot-staging/google-cloud-optimization/v1/package.json deleted file mode 100644 index 812b062d0e7..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/optimization", - "version": "0.1.0", - "description": "Optimization client for Node.js", - "repository": "googleapis/nodejs-optimization", - "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 optimization", - "optimization", - "fleet routing" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-optimization/v1/protos/google/cloud/optimization/v1/async_model.proto b/owl-bot-staging/google-cloud-optimization/v1/protos/google/cloud/optimization/v1/async_model.proto deleted file mode 100644 index a3da0e47970..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/protos/google/cloud/optimization/v1/async_model.proto +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.optimization.v1; - -import "google/api/field_behavior.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "cloud.google.com/go/optimization/apiv1/optimizationpb;optimizationpb"; -option java_multiple_files = true; -option java_outer_classname = "AsyncModelProto"; -option java_package = "com.google.cloud.optimization.v1"; - -// The desired input location information. -message InputConfig { - // The location of the input model in cloud storage. - // Required. - oneof source { - // The Google Cloud Storage location to read the input from. This must be a - // single file. - GcsSource gcs_source = 1; - } - - // The input data format that used to store the model in Cloud Storage. - DataFormat data_format = 2; -} - -// The desired output location. -message OutputConfig { - // The location of the output result in cloud storage. - // Required. - oneof destination { - // The Google Cloud Storage location to write the output to. - GcsDestination gcs_destination = 1; - } - - // The output data format that used to store the results in Cloud Storage. - DataFormat data_format = 2; -} - -// The Google Cloud Storage location where the input file will be read from. -message GcsSource { - // Required. URI of the Google Cloud Storage location. - string uri = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// The Google Cloud Storage location where the output file will be written to. -message GcsDestination { - // Required. URI of the Google Cloud Storage location. - string uri = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// The long running operation metadata for async model related methods. -message AsyncModelMetadata { - // Possible states of the operation. - enum State { - // The default value. This value is used if the state is omitted. - STATE_UNSPECIFIED = 0; - - // Request is being processed. - RUNNING = 1; - - // The operation completed successfully. - SUCCEEDED = 2; - - // The operation was cancelled. - CANCELLED = 3; - - // The operation has failed. - FAILED = 4; - } - - // The state of the current operation. - State state = 1; - - // A message providing more details about the current state of the operation. - // For example, the error message if the operation is failed. - string state_message = 2; - - // The creation time of the operation. - google.protobuf.Timestamp create_time = 3; - - // The last update time of the operation. - google.protobuf.Timestamp update_time = 4; -} - -// Data formats for input and output files. -enum DataFormat { - // Default value. - DATA_FORMAT_UNSPECIFIED = 0; - - // Input data in json format. - JSON = 1; - - // Input data in string format. - STRING = 2; -} diff --git a/owl-bot-staging/google-cloud-optimization/v1/protos/google/cloud/optimization/v1/fleet_routing.proto b/owl-bot-staging/google-cloud-optimization/v1/protos/google/cloud/optimization/v1/fleet_routing.proto deleted file mode 100644 index cef17ad7ef3..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/protos/google/cloud/optimization/v1/fleet_routing.proto +++ /dev/null @@ -1,2750 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.optimization.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/optimization/v1/async_model.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; -import "google/type/latlng.proto"; - -option go_package = "cloud.google.com/go/optimization/apiv1/optimizationpb;optimizationpb"; -option java_multiple_files = true; -option java_outer_classname = "FleetRoutingProto"; -option java_package = "com.google.cloud.optimization.v1"; - -// A service for optimizing vehicle tours. -// -// Validity of certain types of fields: -// -// * `google.protobuf.Timestamp` -// * Times are in Unix time: seconds since 1970-01-01T00:00:00+00:00. -// * seconds must be in [0, 253402300799], -// i.e. in [1970-01-01T00:00:00+00:00, 9999-12-31T23:59:59+00:00]. -// * nanos must be unset or set to 0. -// * `google.protobuf.Duration` -// * seconds must be in [0, 253402300799], -// i.e. in [1970-01-01T00:00:00+00:00, 9999-12-31T23:59:59+00:00]. -// * nanos must be unset or set to 0. -// * `google.type.LatLng` -// * latitude must be in [-90.0, 90.0]. -// * longitude must be in [-180.0, 180.0]. -// * at least one of latitude and longitude must be non-zero. -service FleetRouting { - option (google.api.default_host) = "cloudoptimization.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Sends an `OptimizeToursRequest` containing a `ShipmentModel` and returns an - // `OptimizeToursResponse` containing `ShipmentRoute`s, which are a set of - // routes to be performed by vehicles minimizing the overall cost. - // - // A `ShipmentModel` model consists mainly of `Shipment`s that need to be - // carried out and `Vehicle`s that can be used to transport the `Shipment`s. - // The `ShipmentRoute`s assign `Shipment`s to `Vehicle`s. More specifically, - // they assign a series of `Visit`s to each vehicle, where a `Visit` - // corresponds to a `VisitRequest`, which is a pickup or delivery for a - // `Shipment`. - // - // The goal is to provide an assignment of `ShipmentRoute`s to `Vehicle`s that - // minimizes the total cost where cost has many components defined in the - // `ShipmentModel`. - rpc OptimizeTours(OptimizeToursRequest) returns (OptimizeToursResponse) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}:optimizeTours" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*}:optimizeTours" - body: "*" - } - }; - } - - // Optimizes vehicle tours for one or more `OptimizeToursRequest` - // messages as a batch. - // - // This method is a Long Running Operation (LRO). The inputs for optimization - // (`OptimizeToursRequest` messages) and outputs (`OptimizeToursResponse` - // messages) are read/written from/to Cloud Storage in user-specified - // format. Like the `OptimizeTours` method, each `OptimizeToursRequest` - // contains a `ShipmentModel` and returns an `OptimizeToursResponse` - // containing `ShipmentRoute`s, which are a set of routes to be performed by - // vehicles minimizing the overall cost. - rpc BatchOptimizeTours(BatchOptimizeToursRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}:batchOptimizeTours" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*}:batchOptimizeTours" - body: "*" - } - }; - option (google.longrunning.operation_info) = { - response_type: "BatchOptimizeToursResponse" - metadata_type: "AsyncModelMetadata" - }; - } -} - -// Request to be given to a tour optimization solver which defines the -// shipment model to solve as well as optimization parameters. -message OptimizeToursRequest { - // Defines how the solver should handle the request. In all modes but - // `VALIDATE_ONLY`, if the request is invalid, you will receive an - // `INVALID_REQUEST` error. See - // [max_validation_errors][google.cloud.optimization.v1.OptimizeToursRequest.max_validation_errors] - // to cap the number of errors returned. - enum SolvingMode { - // Solve the model. - DEFAULT_SOLVE = 0; - - // Only validates the model without solving it: populates as many - // [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors] - // as possible. - VALIDATE_ONLY = 1; - - // Only populates - // [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments], - // and doesn't actually solve the rest of the request (`status` and `routes` - // are unset in the response). - // - // *IMPORTANT*: not all infeasible shipments are returned here, but only the - // ones that are detected as infeasible as a preprocessing. - DETECT_SOME_INFEASIBLE_SHIPMENTS = 2; - } - - // Mode defining the behavior of the search, trading off latency versus - // solution quality. In all modes, the global request deadline is enforced. - enum SearchMode { - // Unspecified search mode, equivalent to `RETURN_FAST`. - SEARCH_MODE_UNSPECIFIED = 0; - - // Stop the search after finding the first good solution. - RETURN_FAST = 1; - - // Spend all the available time to search for better solutions. - CONSUME_ALL_AVAILABLE_TIME = 2; - } - - // Required. Target project and location to make a call. - // - // Format: `projects/{project-id}/locations/{location-id}`. - // - // If no location is specified, a region will be chosen automatically. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // If this timeout is set, the server returns a response before the timeout - // period has elapsed or the server deadline for synchronous requests is - // reached, whichever is sooner. - // - // For asynchronous requests, the server will generate a solution (if - // possible) before the timeout has elapsed. - google.protobuf.Duration timeout = 2; - - // Shipment model to solve. - ShipmentModel model = 3; - - // By default, the solving mode is `DEFAULT_SOLVE` (0). - SolvingMode solving_mode = 4; - - // Truncates the number of validation errors returned. These errors are - // typically attached to an INVALID_ARGUMENT error payload as a BadRequest - // error detail (https://cloud.google.com/apis/design/errors#error_details), - // unless solving_mode=VALIDATE_ONLY: see the - // [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors] - // field. - // This defaults to 100 and is capped at 10,000. - optional int32 max_validation_errors = 5; - - // Search mode used to solve the request. - SearchMode search_mode = 6; - - // Guide the optimization algorithm in finding a first solution that is - // similar to a previous solution. - // - // The model is constrained when the first solution is built. - // Any shipments not performed on a route are implicitly skipped in the first - // solution, but they may be performed in successive solutions. - // - // The solution must satisfy some basic validity assumptions: - // - // * for all routes, `vehicle_index` must be in range and not be duplicated. - // * for all visits, `shipment_index` and `visit_request_index` must be - // in range. - // * a shipment may only be referenced on one route. - // * the pickup of a pickup-delivery shipment must be performed before - // the delivery. - // * no more than one pickup alternative or delivery alternative of - // a shipment may be performed. - // * for all routes, times are increasing (i.e., `vehicle_start_time - // <= visits[0].start_time <= visits[1].start_time ... - // <= vehicle_end_time`). - // * a shipment may only be performed on a vehicle that is allowed. A - // vehicle is allowed if - // [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices] - // is empty or its `vehicle_index` is included in - // [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices]. - // - // If the injected solution is not feasible, a validation error is not - // necessarily returned and an error indicating infeasibility may be returned - // instead. - repeated ShipmentRoute injected_first_solution_routes = 7; - - // Constrain the optimization algorithm to find a final solution that is - // similar to a previous solution. For example, this may be used to freeze - // portions of routes which have already been completed or which are to be - // completed but must not be modified. - // - // If the injected solution is not feasible, a validation error is not - // necessarily returned and an error indicating infeasibility may be returned - // instead. - InjectedSolutionConstraint injected_solution_constraint = 8; - - // If non-empty, the given routes will be refreshed, without modifying their - // underlying sequence of visits or travel times: only other details will be - // updated. This does not solve the model. - // - // As of 2020/11, this only populates the polylines of non-empty routes and - // requires that `populate_polylines` is true. - // - // The `route_polyline` fields of the passed-in routes may be inconsistent - // with route `transitions`. - // - // This field must not be used together with `injected_first_solution_routes` - // or `injected_solution_constraint`. - // - // `Shipment.ignore` and `Vehicle.ignore` have no effect on the behavior. - // Polylines are still populated between all visits in all non-empty routes - // regardless of whether the related shipments or vehicles are ignored. - repeated ShipmentRoute refresh_details_routes = 9; - - // If true: - // - // * uses - // [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label] - // instead of `vehicle_index` to - // match routes in an injected solution with vehicles in the request; - // reuses the mapping of original - // [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index] - // to new - // [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index] - // to update - // [ConstraintRelaxation.vehicle_indices][google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices] - // if non-empty, but the mapping must be unambiguous (i.e., multiple - // `ShipmentRoute`s must not share the same original `vehicle_index`). - // * uses - // [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label] - // instead of `shipment_index` - // to match visits in an injected solution with shipments in the request; - // * uses - // [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label] - // instead of - // [SkippedShipment.index][google.cloud.optimization.v1.SkippedShipment.index] - // to - // match skipped shipments in the injected solution with request - // shipments. - // - // This interpretation applies to the `injected_first_solution_routes`, - // `injected_solution_constraint`, and `refresh_details_routes` fields. - // It can be used when shipment or vehicle indices in the request have - // changed since the solution was created, perhaps because shipments or - // vehicles have been removed from or added to the request. - // - // If true, labels in the following categories must appear at most once in - // their category: - // - // * [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] in the - // request; - // * [Shipment.label][google.cloud.optimization.v1.Shipment.label] in the - // request; - // * [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label] in the injected solution; - // * [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label] and [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label] in - // the injected solution (except pickup/delivery visit pairs, whose - // `shipment_label` must appear twice). - // - // If a `vehicle_label` in the injected solution does not correspond to a - // request vehicle, the corresponding route is removed from the solution - // along with its visits. If a `shipment_label` in the injected solution does - // not correspond to a request shipment, the corresponding visit is removed - // from the solution. If a - // [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label] - // in the injected solution does not correspond to a request shipment, the - // `SkippedShipment` is removed from the solution. - // - // Removing route visits or entire routes from an injected solution may - // have an effect on the implied constraints, which may lead to change in - // solution, validation errors, or infeasibility. - // - // NOTE: The caller must ensure that each - // [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] (resp. - // [Shipment.label][google.cloud.optimization.v1.Shipment.label]) uniquely - // identifies a vehicle (resp. shipment) entity used across the two relevant - // requests: the past request that produced the `OptimizeToursResponse` used - // in the injected solution and the current request that includes the injected - // solution. The uniqueness checks described above are not enough to guarantee - // this requirement. - bool interpret_injected_solutions_using_labels = 10; - - // Consider traffic estimation in calculating `ShipmentRoute` fields - // [Transition.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration], - // [Visit.start_time][google.cloud.optimization.v1.ShipmentRoute.Visit.start_time], - // and `vehicle_end_time`; in setting the - // [ShipmentRoute.has_traffic_infeasibilities][google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities] - // field, and in calculating the - // [OptimizeToursResponse.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.total_cost] - // field. - bool consider_road_traffic = 11; - - // If true, polylines will be populated in response `ShipmentRoute`s. - bool populate_polylines = 12; - - // If true, polylines will be populated in response - // [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]. - // Note that in this case, the polylines will also be populated in the - // deprecated `travel_steps`. - bool populate_transition_polylines = 13; - - // If this is set, then the request can have a deadline - // (see https://grpc.io/blog/deadlines) of up to 60 minutes. - // Otherwise, the maximum deadline is only 30 minutes. - // Note that long-lived requests have a significantly larger (but still small) - // risk of interruption. - bool allow_large_deadline_despite_interruption_risk = 14; - - // If true, travel distances will be computed using geodesic distances instead - // of Google Maps distances, and travel times will be computed using geodesic - // distances with a speed defined by `geodesic_meters_per_second`. - bool use_geodesic_distances = 15; - - // When `use_geodesic_distances` is true, this field must be set and defines - // the speed applied to compute travel times. Its value must be at least 1.0 - // meters/seconds. - optional double geodesic_meters_per_second = 16; - - // Label that may be used to identify this request, reported back in the - // [OptimizeToursResponse.request_label][google.cloud.optimization.v1.OptimizeToursResponse.request_label]. - string label = 17; - - // Deprecated: Use - // [OptimizeToursRequest.populate_transition_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines] - // instead. If true, polylines will be populated in response - // [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]. - // Note that in this case, the polylines will also be populated in the - // deprecated `travel_steps`. - bool populate_travel_step_polylines = 20 [deprecated = true]; -} - -// Response after solving a tour optimization problem containing the routes -// followed by each vehicle, the shipments which have been skipped and the -// overall cost of the solution. -message OptimizeToursResponse { - // Overall metrics, aggregated over all routes. - message Metrics { - // Aggregated over the routes. Each metric is the sum (or max, for loads) - // over all - // [ShipmentRoute.metrics][google.cloud.optimization.v1.ShipmentRoute.metrics] - // fields of the same name. - AggregatedMetrics aggregated_route_metrics = 1; - - // Number of mandatory shipments skipped. - int32 skipped_mandatory_shipment_count = 2; - - // Number of vehicles used. Note: if a vehicle route is empty and - // [Vehicle.used_if_route_is_empty][google.cloud.optimization.v1.Vehicle.used_if_route_is_empty] - // is true, the vehicle is considered used. - int32 used_vehicle_count = 3; - - // The earliest start time for a used vehicle, computed as the minimum over - // all used vehicles of - // [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]. - google.protobuf.Timestamp earliest_vehicle_start_time = 4; - - // The latest end time for a used vehicle, computed as the maximum over all - // used vehicles of - // [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]. - google.protobuf.Timestamp latest_vehicle_end_time = 5; - - // Cost of the solution, broken down by cost-related request fields. - // The keys are proto paths, relative to the input OptimizeToursRequest, - // e.g. "model.shipments.pickups.cost", and the values are the total cost - // generated by the corresponding cost field, aggregated over the whole - // solution. In other words, costs["model.shipments.pickups.cost"] is the - // sum of all pickup costs over the solution. All costs defined in the model - // are reported in detail here with the exception of costs related to - // TransitionAttributes that are only reported in an aggregated way as of - // 2022/01. - map costs = 10; - - // Total cost of the solution. The sum of all values in the costs map. - double total_cost = 6; - } - - // Routes computed for each vehicle; the i-th route corresponds to the i-th - // vehicle in the model. - repeated ShipmentRoute routes = 1; - - // Copy of the - // [OptimizeToursRequest.label][google.cloud.optimization.v1.OptimizeToursRequest.label], - // if a label was specified in the request. - string request_label = 3; - - // The list of all shipments skipped. - repeated SkippedShipment skipped_shipments = 4; - - // List of all the validation errors that we were able to detect - // independently. See the "MULTIPLE ERRORS" explanation for the - // [OptimizeToursValidationError][google.cloud.optimization.v1.OptimizeToursValidationError] - // message. - repeated OptimizeToursValidationError validation_errors = 5; - - // Duration, distance and usage metrics for this solution. - Metrics metrics = 6; - - // Deprecated: Use - // [Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost] - // instead. Total cost of the solution. This takes into account all costs: - // costs per per hour and travel hour, fixed vehicle costs, unperformed - // shipment penalty costs, global duration cost, etc. - double total_cost = 2 [deprecated = true]; -} - -// Request to batch optimize tours as an asynchronous operation. -// Each input file should contain one `OptimizeToursRequest`, and each output -// file will contain one `OptimizeToursResponse`. The request contains -// information to read/write and parse the files. All the input and output files -// should be under the same project. -message BatchOptimizeToursRequest { - // Information for solving one optimization model asynchronously. - message AsyncModelConfig { - // User defined model name, can be used as alias by users to keep track of - // models. - string display_name = 1; - - // Required. Information about the input model. - InputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The desired output location information. - OutputConfig output_config = 3 [(google.api.field_behavior) = REQUIRED]; - - // If this is set, the model will be solved in the checkpoint mode. In this - // mode, the input model can have a deadline longer than 30 mins without the - // risk of interruption. The model will be solved in multiple short-running - // stages. Each stage generates an intermediate checkpoint - // and stores it in the user's Cloud Storage buckets. The checkpoint - // mode should be preferred over - // allow_large_deadline_despite_interruption_risk since it prevents the risk - // of interruption. - bool enable_checkpoints = 4; - } - - // Required. Target project and location to make a call. - // - // Format: `projects/{project-id}/locations/{location-id}`. - // - // If no location is specified, a region will be chosen automatically. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Input/Output information each purchase model, such as file paths - // and data formats. - repeated AsyncModelConfig model_configs = 2 - [(google.api.field_behavior) = REQUIRED]; -} - -// Response to a `BatchOptimizeToursRequest`. This is returned in -// the LRO Operation after the operation is complete. -message BatchOptimizeToursResponse {} - -// A shipment model contains a set of shipments which must be performed by a -// set of vehicles, while minimizing the overall cost, which is the sum of: -// -// * the cost of routing the vehicles (sum of cost per total time, cost per -// travel time, and fixed cost over all vehicles). -// * the unperformed shipment penalties. -// * the cost of the global duration of the shipments -message ShipmentModel { - // Specifies a duration and distance matrix from visit and vehicle start - // locations to visit and vehicle end locations. - message DurationDistanceMatrix { - // Specifies a row of the duration and distance matrix. - message Row { - // Duration values for a given row. It must have as many elements as - // [ShipmentModel.duration_distance_matrix_dst_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_dst_tags]. - repeated google.protobuf.Duration durations = 1; - - // Distance values for a given row. If no costs or constraints refer to - // distances in the model, this can be left empty; otherwise it must have - // as many elements as `durations`. - repeated double meters = 2; - } - - // Specifies the rows of the duration and distance matrix. It must have as - // many elements as - // [ShipmentModel.duration_distance_matrix_src_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_src_tags]. - repeated Row rows = 1; - - // Tag defining to which vehicles this duration and distance matrix applies. - // If empty, this applies to all vehicles, and there can only be a single - // matrix. - // - // Each vehicle start must match exactly one matrix, i.e. exactly one of - // their `start_tags` field must match the `vehicle_start_tag` of a matrix - // (and of that matrix only). - // - // All matrices must have a different `vehicle_start_tag`. - string vehicle_start_tag = 2; - } - - // A precedence rule between two events (each event is the pickup or the - // delivery of a shipment): the "second" event has to start at least - // `offset_duration` after "first" has started. - // - // Several precedences can refer to the same (or related) events, e.g., - // "pickup of B happens after delivery of A" and "pickup of C happens after - // pickup of B". - // - // Furthermore, precedences only apply when both shipments are performed and - // are otherwise ignored. - message PrecedenceRule { - // Shipment index of the "first" event. This field must be specified. - optional int32 first_index = 1; - - // Indicates if the "first" event is a delivery. - bool first_is_delivery = 3; - - // Shipment index of the "second" event. This field must be specified. - optional int32 second_index = 2; - - // Indicates if the "second" event is a delivery. - bool second_is_delivery = 4; - - // The offset between the "first" and "second" event. It can be negative. - google.protobuf.Duration offset_duration = 5; - } - - // Deprecated: Use top level - // [BreakRule][google.cloud.optimization.v1.ShipmentModel.BreakRule] instead. - // Rules to generate time breaks for a vehicle (e.g. lunch - // breaks). A break is a contiguous period of time during which the vehicle - // remains idle at its current position and cannot perform any visit. A break - // may occur: - // - // * during the travel between two visits (which includes the time right - // before or right after a visit, but not in the middle of a visit), in - // which case it extends the corresponding transit time between the visits - // * before the vehicle start (the vehicle may not start in the middle of - // a break), in which case it does not affect the vehicle start time. - // * after the vehicle end (ditto, with the vehicle end time). - message BreakRule { - option deprecated = true; - - // The sequence of breaks (i.e. their number and order) that apply to each - // vehicle must be known beforehand. The repeated `BreakRequest`s define - // that sequence, in the order in which they must occur. Their time windows - // (`earliest_start_time` / `latest_start_time`) may overlap, but they must - // be compatible with the order (this is checked). - message BreakRequest { - // Required. Lower bound (inclusive) on the start of the break. - google.protobuf.Timestamp earliest_start_time = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. Upper bound (inclusive) on the start of the break. - google.protobuf.Timestamp latest_start_time = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Required. Minimum duration of the break. Must be positive. - google.protobuf.Duration min_duration = 3 - [(google.api.field_behavior) = REQUIRED]; - } - - // One may further constrain the frequency and duration of the breaks - // specified above, by enforcing a minimum break frequency, such as - // "There must be a break of at least 1 hour every 12 hours". Assuming that - // this can be interpreted as "Within any sliding time window of 12h, there - // must be at least one break of at least one hour", that example would - // translate to the following `FrequencyConstraint`: - // ``` - // { - // min_break_duration { seconds: 3600 } # 1 hour. - // max_inter_break_duration { seconds: 39600 } # 11 hours (12 - 1 = 11). - // } - // ``` - // - // The timing and duration of the breaks in the solution will respect all - // such constraints, in addition to the time windows and minimum durations - // already specified in the `BreakRequest`. - // - // A `FrequencyConstraint` may in practice apply to non-consecutive breaks. - // For example, the following schedule honors the "1h every 12h" example: - // ``` - // 04:00 vehicle start - // .. performing travel and visits .. - // 09:00 1 hour break - // 10:00 end of the break - // .. performing travel and visits .. - // 12:00 20-min lunch break - // 12:20 end of the break - // .. performing travel and visits .. - // 21:00 1 hour break - // 22:00 end of the break - // .. performing travel and visits .. - // 23:59 vehicle end - // ``` - message FrequencyConstraint { - // Required. Minimum break duration for this constraint. Nonnegative. - // See description of `FrequencyConstraint`. - google.protobuf.Duration min_break_duration = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. Maximum allowed span of any interval of time in the route - // that does not include at least partially a break of `duration >= - // min_break_duration`. Must be positive. - google.protobuf.Duration max_inter_break_duration = 2 - [(google.api.field_behavior) = REQUIRED]; - } - - // Sequence of breaks. See the `BreakRequest` message. - repeated BreakRequest break_requests = 1; - - // Several `FrequencyConstraint` may apply. They must all be satisfied by - // the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`. - repeated FrequencyConstraint frequency_constraints = 2; - } - - // Set of shipments which must be performed in the model. - repeated Shipment shipments = 1; - - // Set of vehicles which can be used to perform visits. - repeated Vehicle vehicles = 2; - - // Constrains the maximum number of active vehicles. A vehicle is active if - // its route performs at least one shipment. This can be used to limit the - // number of routes in the case where there are fewer drivers than - // vehicles and that the fleet of vehicles is heterogeneous. The optimization - // will then select the best subset of vehicles to use. - // Must be strictly positive. - optional int32 max_active_vehicles = 4; - - // Global start and end time of the model: no times outside of this range - // can be considered valid. - // - // The model's time span must be less than a year, i.e. the `global_end_time` - // and the `global_start_time` must be within 31536000 seconds of each other. - // - // When using `cost_per_*hour` fields, you might want to set this window to a - // smaller interval to increase performance (eg. if you model a single day, - // you should set the global time limits to that day). - // If unset, 00:00:00 UTC, January 1, 1970 (i.e. seconds: 0, nanos: 0) is used - // as default. - google.protobuf.Timestamp global_start_time = 5; - - // If unset, 00:00:00 UTC, January 1, 1971 (i.e. seconds: 31536000, nanos: 0) - // is used as default. - google.protobuf.Timestamp global_end_time = 6; - - // The "global duration" of the overall plan is the difference between the - // earliest effective start time and the latest effective end time of - // all vehicles. Users can assign a cost per hour to that quantity to try - // and optimize for earliest job completion, for example. This cost must be in - // the same unit as - // [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost]. - double global_duration_cost_per_hour = 7; - - // Specifies duration and distance matrices used in the model. If this field - // is empty, Google Maps or geodesic distances will be used instead, depending - // on the value of the `use_geodesic_distances` field. If it is not empty, - // `use_geodesic_distances` cannot be true and neither - // `duration_distance_matrix_src_tags` nor `duration_distance_matrix_dst_tags` - // can be empty. - // - // Usage examples: - // - // * There are two locations: locA and locB. - // * 1 vehicle starting its route at locA and ending it at locA. - // * 1 pickup visit request at locB. - // - // ``` - // model { - // vehicles { start_tags: "locA" end_tags: "locA" } - // shipments { pickups { tags: "locB" } } - // duration_distance_matrix_src_tags: "locA" - // duration_distance_matrix_src_tags: "locB" - // duration_distance_matrix_dst_tags: "locA" - // duration_distance_matrix_dst_tags: "locB" - // duration_distance_matrices { - // rows { # from: locA - // durations { seconds: 0 } meters: 0 # to: locA - // durations { seconds: 100 } meters: 1000 # to: locB - // } - // rows { # from: locB - // durations { seconds: 102 } meters: 990 # to: locA - // durations { seconds: 0 } meters: 0 # to: locB - // } - // } - // } - // ``` - // - // - // * There are three locations: locA, locB and locC. - // * 1 vehicle starting its route at locA and ending it at locB, using - // matrix "fast". - // * 1 vehicle starting its route at locB and ending it at locB, using - // matrix "slow". - // * 1 vehicle starting its route at locB and ending it at locB, using - // matrix "fast". - // * 1 pickup visit request at locC. - // - // ``` - // model { - // vehicles { start_tags: "locA" end_tags: "locB" start_tags: "fast" } - // vehicles { start_tags: "locB" end_tags: "locB" start_tags: "slow" } - // vehicles { start_tags: "locB" end_tags: "locB" start_tags: "fast" } - // shipments { pickups { tags: "locC" } } - // duration_distance_matrix_src_tags: "locA" - // duration_distance_matrix_src_tags: "locB" - // duration_distance_matrix_src_tags: "locC" - // duration_distance_matrix_dst_tags: "locB" - // duration_distance_matrix_dst_tags: "locC" - // duration_distance_matrices { - // vehicle_start_tag: "fast" - // rows { # from: locA - // durations { seconds: 1000 } meters: 2000 # to: locB - // durations { seconds: 600 } meters: 1000 # to: locC - // } - // rows { # from: locB - // durations { seconds: 0 } meters: 0 # to: locB - // durations { seconds: 700 } meters: 1200 # to: locC - // } - // rows { # from: locC - // durations { seconds: 702 } meters: 1190 # to: locB - // durations { seconds: 0 } meters: 0 # to: locC - // } - // } - // duration_distance_matrices { - // vehicle_start_tag: "slow" - // rows { # from: locA - // durations { seconds: 1800 } meters: 2001 # to: locB - // durations { seconds: 900 } meters: 1002 # to: locC - // } - // rows { # from: locB - // durations { seconds: 0 } meters: 0 # to: locB - // durations { seconds: 1000 } meters: 1202 # to: locC - // } - // rows { # from: locC - // durations { seconds: 1001 } meters: 1195 # to: locB - // durations { seconds: 0 } meters: 0 # to: locC - // } - // } - // } - // ``` - repeated DurationDistanceMatrix duration_distance_matrices = 8; - - // Tags defining the sources of the duration and distance matrices; - // `duration_distance_matrices(i).rows(j)` defines durations and distances - // from visits with tag `duration_distance_matrix_src_tags(j)` to other visits - // in matrix i. - // - // Tags correspond to - // [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags] - // or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags]. - // A given `VisitRequest` or `Vehicle` must match exactly one tag in this - // field. Note that a `Vehicle`'s source, destination and matrix tags may be - // the same; similarly a `VisitRequest`'s source and destination tags may be - // the same. All tags must be different and cannot be empty strings. If this - // field is not empty, then `duration_distance_matrices` must not be empty. - repeated string duration_distance_matrix_src_tags = 9; - - // Tags defining the destinations of the duration and distance matrices; - // `duration_distance_matrices(i).rows(j).durations(k)` (resp. - // `duration_distance_matrices(i).rows(j).meters(k))` defines the duration - // (resp. the distance) of the travel from visits with tag - // `duration_distance_matrix_src_tags(j)` to visits with tag - // `duration_distance_matrix_dst_tags(k)` in matrix i. - // - // Tags correspond to - // [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags] - // or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags]. - // A given `VisitRequest` or `Vehicle` must match exactly one tag in this - // field. Note that a `Vehicle`'s source, destination and matrix tags may be - // the same; similarly a `VisitRequest`'s source and destination tags may be - // the same. All tags must be different and cannot be empty strings. If this - // field is not empty, then `duration_distance_matrices` must not be empty. - repeated string duration_distance_matrix_dst_tags = 10; - - // Transition attributes added to the model. - repeated TransitionAttributes transition_attributes = 11; - - // Sets of incompatible shipment_types (see `ShipmentTypeIncompatibility`). - repeated ShipmentTypeIncompatibility shipment_type_incompatibilities = 12; - - // Sets of `shipment_type` requirements (see `ShipmentTypeRequirement`). - repeated ShipmentTypeRequirement shipment_type_requirements = 13; - - // Set of precedence rules which must be enforced in the model. - repeated PrecedenceRule precedence_rules = 14; - - // Deprecated: No longer used. - // Set of break rules used in the model. - // Each vehicle specifies the `BreakRule` that applies to it via the - // [Vehicle.break_rule_indices][google.cloud.optimization.v1.Vehicle.break_rule_indices] - // field (which must be a singleton). - repeated BreakRule break_rules = 15 [deprecated = true]; -} - -// The shipment of a single item, from one of its pickups to one of its -// deliveries. For the shipment to be considered as performed, a unique vehicle -// must visit one of its pickup locations (and decrease its spare capacities -// accordingly), then visit one of its delivery locations later on (and -// therefore re-increase its spare capacities accordingly). -message Shipment { - // Request for a visit which can be done by a vehicle: it has a geo-location - // (or two, see below), opening and closing times represented by time windows, - // and a service duration time (time spent by the vehicle once it has arrived - // to pickup or drop off goods). - message VisitRequest { - // The geo-location where the vehicle arrives when performing this - // `VisitRequest`. If the shipment model has duration distance matrices, - // `arrival_location` must not be specified. - google.type.LatLng arrival_location = 1; - - // The waypoint where the vehicle arrives when performing this - // `VisitRequest`. If the shipment model has duration distance matrices, - // `arrival_waypoint` must not be specified. - Waypoint arrival_waypoint = 2; - - // The geo-location where the vehicle departs after completing this - // `VisitRequest`. Can be omitted if it is the same as `arrival_location`. - // If the shipment model has duration distance matrices, - // `departure_location` must not be specified. - google.type.LatLng departure_location = 3; - - // The waypoint where the vehicle departs after completing this - // `VisitRequest`. Can be omitted if it is the same as `arrival_waypoint`. - // If the shipment model has duration distance matrices, - // `departure_waypoint` must not be specified. - Waypoint departure_waypoint = 4; - - // Specifies tags attached to the visit request. - // Empty or duplicate strings are not allowed. - repeated string tags = 5; - - // Time windows which constrain the arrival time at a visit. - // Note that a vehicle may depart outside of the arrival time window, i.e. - // arrival time + duration do not need to be inside a time window. This can - // result in waiting time if the vehicle arrives before - // [TimeWindow.start_time][google.cloud.optimization.v1.TimeWindow.start_time]. - // - // The absence of `TimeWindow` means that the vehicle can perform this visit - // at any time. - // - // Time windows must be disjoint, i.e. no time window must overlap with or - // be adjacent to another, and they must be in increasing order. - // - // `cost_per_hour_after_soft_end_time` and `soft_end_time` can only - // be set if there is a single time window. - repeated TimeWindow time_windows = 6; - - // Duration of the visit, i.e. time spent by the vehicle between arrival - // and departure (to be added to the possible waiting time; see - // `time_windows`). - google.protobuf.Duration duration = 7; - - // Cost to service this visit request on a vehicle route. This can be used - // to pay different costs for each alternative pickup or delivery of a - // shipment. This cost must be in the same unit as `Shipment.penalty_cost` - // and must not be negative. - double cost = 8; - - // Load demands of this visit request. This is just like - // [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands] - // field, except that it only applies to this - // [VisitRequest][google.cloud.optimization.v1.Shipment.VisitRequest] - // instead of the whole [Shipment][google.cloud.optimization.v1.Shipment]. - // The demands listed here are added to the demands listed in - // [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]. - map load_demands = 12; - - // Specifies the types of the visit. This may be used to allocate additional - // time required for a vehicle to complete this visit (see - // [Vehicle.extra_visit_duration_for_visit_type][google.cloud.optimization.v1.Vehicle.extra_visit_duration_for_visit_type]). - // - // A type can only appear once. - repeated string visit_types = 10; - - // Specifies a label for this `VisitRequest`. This label is reported in the - // response as `visit_label` in the corresponding - // [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit]. - string label = 11; - - // Deprecated: Use - // [VisitRequest.load_demands][google.cloud.optimization.v1.Shipment.VisitRequest.load_demands] - // instead. - repeated CapacityQuantity demands = 9 [deprecated = true]; - } - - // When performing a visit, a predefined amount may be added to the vehicle - // load if it's a pickup, or subtracted if it's a delivery. This message - // defines such amount. See - // [load_demands][google.cloud.optimization.v1.Shipment.load_demands]. - message Load { - // The amount by which the load of the vehicle performing the corresponding - // visit will vary. Since it is an integer, users are advised to choose an - // appropriate unit to avoid loss of precision. Must be ≥ 0. - int64 amount = 2; - } - - // Set of pickup alternatives associated to the shipment. If not specified, - // the vehicle only needs to visit a location corresponding to the deliveries. - repeated VisitRequest pickups = 1; - - // Set of delivery alternatives associated to the shipment. If not specified, - // the vehicle only needs to visit a location corresponding to the pickups. - repeated VisitRequest deliveries = 2; - - // Load demands of the shipment (for example weight, volume, number of - // pallets etc). The keys in the map should be identifiers describing the type - // of the corresponding load, ideally also including the units. - // For example: "weight_kg", "volume_gallons", "pallet_count", etc. - // If a given key does not appear in the map, the corresponding load is - // considered as null. - map load_demands = 14; - - // If the shipment is not completed, this penalty is added to the overall - // cost of the routes. A shipment is considered completed if one of its pickup - // and delivery alternatives is visited. The cost may be expressed in the - // same unit used for all other cost-related fields in the model and must be - // positive. - // - // *IMPORTANT*: If this penalty is not specified, it is considered infinite, - // i.e. the shipment must be completed. - optional double penalty_cost = 4; - - // The set of vehicles that may perform this shipment. If empty, all vehicles - // may perform it. Vehicles are given by their index in the `ShipmentModel`'s - // `vehicles` list. - repeated int32 allowed_vehicle_indices = 5; - - // Specifies the cost that is incurred when this shipment is delivered by each - // vehicle. If specified, it must have EITHER: - // - // * the same number of elements as `costs_per_vehicle_indices`. - // `costs_per_vehicle[i]` corresponds to vehicle - // `costs_per_vehicle_indices[i]` of the model. - // * the same number of elements as there are vehicles in the model. The - // i-th element corresponds to vehicle #i of the model. - // - // These costs must be in the same unit as `penalty_cost` and must not be - // negative. Leave this field empty, if there are no such costs. - repeated double costs_per_vehicle = 6; - - // Indices of the vehicles to which `costs_per_vehicle` applies. If non-empty, - // it must have the same number of elements as `costs_per_vehicle`. A vehicle - // index may not be specified more than once. If a vehicle is excluded from - // `costs_per_vehicle_indices`, its cost is zero. - repeated int32 costs_per_vehicle_indices = 7; - - // Specifies the maximum relative detour time compared to the shortest path - // from pickup to delivery. If specified, it must be nonnegative, and the - // shipment must contain at least a pickup and a delivery. - // - // For example, let t be the shortest time taken to go from the selected - // pickup alternative directly to the selected delivery alternative. Then - // setting `pickup_to_delivery_relative_detour_limit` enforces: - // - // ``` - // start_time(delivery) - start_time(pickup) <= - // std::ceil(t * (1.0 + pickup_to_delivery_relative_detour_limit)) - // ``` - // - // If both relative and absolute limits are specified on the same shipment, - // the more constraining limit is used for each possible pickup/delivery pair. - // As of 2017/10, detours are only supported when travel durations do not - // depend on vehicles. - optional double pickup_to_delivery_relative_detour_limit = 8; - - // Specifies the maximum absolute detour time compared to the shortest path - // from pickup to delivery. If specified, it must be nonnegative, and the - // shipment must contain at least a pickup and a delivery. - // - // For example, let t be the shortest time taken to go from the selected - // pickup alternative directly to the selected delivery alternative. Then - // setting `pickup_to_delivery_absolute_detour_limit` enforces: - // - // ``` - // start_time(delivery) - start_time(pickup) <= - // t + pickup_to_delivery_absolute_detour_limit - // ``` - // - // If both relative and absolute limits are specified on the same shipment, - // the more constraining limit is used for each possible pickup/delivery pair. - // As of 2017/10, detours are only supported when travel durations do not - // depend on vehicles. - google.protobuf.Duration pickup_to_delivery_absolute_detour_limit = 9; - - // Specifies the maximum duration from start of pickup to start of delivery of - // a shipment. If specified, it must be nonnegative, and the shipment must - // contain at least a pickup and a delivery. This does not depend on which - // alternatives are selected for pickup and delivery, nor on vehicle speed. - // This can be specified alongside maximum detour constraints: the solution - // will respect both specifications. - google.protobuf.Duration pickup_to_delivery_time_limit = 10; - - // Non-empty string specifying a "type" for this shipment. - // This feature can be used to define incompatibilities or requirements - // between `shipment_types` (see `shipment_type_incompatibilities` and - // `shipment_type_requirements` in `ShipmentModel`). - // - // Differs from `visit_types` which is specified for a single visit: All - // pickup/deliveries belonging to the same shipment share the same - // `shipment_type`. - string shipment_type = 11; - - // Specifies a label for this shipment. This label is reported in the response - // in the `shipment_label` of the corresponding - // [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit]. - string label = 12; - - // If true, skip this shipment, but don't apply a `penalty_cost`. - // - // Ignoring a shipment results in a validation error when there are any - // `shipment_type_requirements` in the model. - // - // Ignoring a shipment that is performed in `injected_first_solution_routes` - // or `injected_solution_constraint` is permitted; the solver removes the - // related pickup/delivery visits from the performing route. - // `precedence_rules` that reference ignored shipments will also be ignored. - bool ignore = 13; - - // Deprecated: Use - // [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands] - // instead. - repeated CapacityQuantity demands = 3 [deprecated = true]; -} - -// Specifies incompatibilties between shipments depending on their -// shipment_type. The appearance of incompatible shipments on the same route is -// restricted based on the incompatibility mode. -message ShipmentTypeIncompatibility { - // Modes defining how the appearance of incompatible shipments are restricted - // on the same route. - enum IncompatibilityMode { - // Unspecified incompatibility mode. This value should never be used. - INCOMPATIBILITY_MODE_UNSPECIFIED = 0; - - // In this mode, two shipments with incompatible types can never share the - // same vehicle. - NOT_PERFORMED_BY_SAME_VEHICLE = 1; - - // For two shipments with incompatible types with the - // `NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY` incompatibility mode: - // - // * If both are pickups only (no deliveries) or deliveries only (no - // pickups), they cannot share the same vehicle at all. - // * If one of the shipments has a delivery and the other a pickup, the two - // shipments can share the same vehicle iff the former shipment is - // delivered before the latter is picked up. - NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY = 2; - } - - // List of incompatible types. Two shipments having different `shipment_types` - // among those listed are "incompatible". - repeated string types = 1; - - // Mode applied to the incompatibility. - IncompatibilityMode incompatibility_mode = 2; -} - -// Specifies requirements between shipments based on their shipment_type. -// The specifics of the requirement are defined by the requirement mode. -message ShipmentTypeRequirement { - // Modes defining the appearance of dependent shipments on a route. - enum RequirementMode { - // Unspecified requirement mode. This value should never be used. - REQUIREMENT_MODE_UNSPECIFIED = 0; - - // In this mode, all "dependent" shipments must share the same vehicle as at - // least one of their "required" shipments. - PERFORMED_BY_SAME_VEHICLE = 1; - - // With the `IN_SAME_VEHICLE_AT_PICKUP_TIME` mode, all "dependent" - // shipments need to have at least one "required" shipment on their vehicle - // at the time of their pickup. - // - // A "dependent" shipment pickup must therefore have either: - // - // * A delivery-only "required" shipment delivered on the route after, or - // * A "required" shipment picked up on the route before it, and if the - // "required" shipment has a delivery, this delivery must be performed - // after the "dependent" shipment's pickup. - IN_SAME_VEHICLE_AT_PICKUP_TIME = 2; - - // Same as before, except the "dependent" shipments need to have a - // "required" shipment on their vehicle at the time of their *delivery*. - IN_SAME_VEHICLE_AT_DELIVERY_TIME = 3; - } - - // List of alternative shipment types required by the - // `dependent_shipment_types`. - repeated string required_shipment_type_alternatives = 1; - - // All shipments with a type in the `dependent_shipment_types` field require - // at least one shipment of type `required_shipment_type_alternatives` to be - // visited on the same route. - // - // NOTE: Chains of requirements such that a `shipment_type` depends on itself - // are not allowed. - repeated string dependent_shipment_types = 2; - - // Mode applied to the requirement. - RequirementMode requirement_mode = 3; -} - -// Models a vehicle in a shipment problem. Solving a shipment problem will -// build a route starting from `start_location` and ending at `end_location` -// for this vehicle. A route is a sequence of visits (see `ShipmentRoute`). -message Vehicle { - // Travel modes which can be used by vehicles. - // - // These should be a subset of the Google Maps Platform Routes Preferred API - // travel modes, see: - // https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/RouteTravelMode. - enum TravelMode { - // Unspecified travel mode, equivalent to `DRIVING`. - TRAVEL_MODE_UNSPECIFIED = 0; - - // Travel mode corresponding to driving directions (car, ...). - DRIVING = 1; - } - - // Policy on how a vehicle can be unloaded. Applies only to shipments having - // both a pickup and a delivery. - // - // Other shipments are free to occur anywhere on the route independent of - // `unloading_policy`. - enum UnloadingPolicy { - // Unspecified unloading policy; deliveries must just occur after their - // corresponding pickups. - UNLOADING_POLICY_UNSPECIFIED = 0; - - // Deliveries must occur in reverse order of pickups - LAST_IN_FIRST_OUT = 1; - - // Deliveries must occur in the same order as pickups - FIRST_IN_FIRST_OUT = 2; - } - - // Defines a load limit applying to a vehicle, e.g. "this truck may only - // carry up to 3500 kg". See - // [load_limits][google.cloud.optimization.v1.Vehicle.load_limits]. - message LoadLimit { - // Interval of acceptable load amounts. - message Interval { - // A minimum acceptable load. Must be ≥ 0. - // If they're both specified, - // [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must - // be ≤ - // [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]. - int64 min = 1; - - // A maximum acceptable load. Must be ≥ 0. If unspecified, the maximum - // load is unrestricted by this message. - // If they're both specified, - // [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must - // be ≤ - // [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]. - optional int64 max = 2; - } - - // The maximum acceptable amount of load. - optional int64 max_load = 1; - - // A soft limit of the load. See - // [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]. - int64 soft_max_load = 2; - - // If the load ever exceeds - // [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load] - // along this vehicle's route, the following cost penalty applies (only once - // per vehicle): (load - - // [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load]) - // * [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]. All costs - // add up and must be in the same unit as - // [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost]. - double cost_per_unit_above_soft_max = 3; - - // The acceptable load interval of the vehicle at the start of the route. - Interval start_load_interval = 4; - - // The acceptable load interval of the vehicle at the end of the route. - Interval end_load_interval = 5; - } - - // A limit defining a maximum duration of the route of a vehicle. It can be - // either hard or soft. - // - // When a soft limit field is defined, both the soft max threshold and its - // associated cost must be defined together. - message DurationLimit { - // A hard limit constraining the duration to be at most max_duration. - google.protobuf.Duration max_duration = 1; - - // A soft limit not enforcing a maximum duration limit, but when violated - // makes the route incur a cost. This cost adds up to other costs defined in - // the model, with the same unit. - // - // If defined, `soft_max_duration` must be nonnegative. If max_duration is - // also defined, `soft_max_duration` must be less than max_duration. - google.protobuf.Duration soft_max_duration = 2; - - // Cost per hour incurred if the `soft_max_duration` threshold is violated. - // The additional cost is 0 if the duration is under the threshold, - // otherwise the cost depends on the duration as follows: - // ``` - // cost_per_hour_after_soft_max * (duration - soft_max_duration) - // ``` - // The cost must be nonnegative. - optional double cost_per_hour_after_soft_max = 3; - - // A soft limit not enforcing a maximum duration limit, but when violated - // makes the route incur a cost, quadratic in the duration. This cost adds - // up to other costs defined in the model, with the same unit. - // - // If defined, `quadratic_soft_max_duration` must be nonnegative. If - // `max_duration` is also defined, `quadratic_soft_max_duration` must be - // less than `max_duration`, and the difference must be no larger than one - // day: - // - // `max_duration - quadratic_soft_max_duration <= 86400 seconds` - google.protobuf.Duration quadratic_soft_max_duration = 4; - - // Cost per square hour incurred if the - // `quadratic_soft_max_duration` threshold is violated. - // - // The additional cost is 0 if the duration is under the threshold, - // otherwise the cost depends on the duration as follows: - // - // ``` - // cost_per_square_hour_after_quadratic_soft_max * - // (duration - quadratic_soft_max_duration)^2 - // ``` - // - // The cost must be nonnegative. - optional double cost_per_square_hour_after_quadratic_soft_max = 5; - } - - // The travel mode which affects the roads usable by the vehicle and its - // speed. See also `travel_duration_multiple`. - TravelMode travel_mode = 1; - - // Geographic location where the vehicle starts before picking up any - // shipments. If not specified, the vehicle starts at its first pickup. - // If the shipment model has duration and distance matrices, `start_location` - // must not be specified. - google.type.LatLng start_location = 3; - - // Waypoint representing a geographic location where the vehicle starts before - // picking up any shipments. If neither `start_waypoint` nor `start_location` - // is specified, the vehicle starts at its first pickup. - // If the shipment model has duration and distance matrices, `start_waypoint` - // must not be specified. - Waypoint start_waypoint = 4; - - // Geographic location where the vehicle ends after it has completed its last - // `VisitRequest`. If not specified the vehicle's `ShipmentRoute` ends - // immediately when it completes its last `VisitRequest`. - // If the shipment model has duration and distance matrices, `end_location` - // must not be specified. - google.type.LatLng end_location = 5; - - // Waypoint representing a geographic location where the vehicle ends after - // it has completed its last `VisitRequest`. If neither `end_waypoint` nor - // `end_location` is specified, the vehicle's `ShipmentRoute` ends immediately - // when it completes its last `VisitRequest`. - // If the shipment model has duration and distance matrices, `end_waypoint` - // must not be specified. - Waypoint end_waypoint = 6; - - // Specifies tags attached to the start of the vehicle's route. - // - // Empty or duplicate strings are not allowed. - repeated string start_tags = 7; - - // Specifies tags attached to the end of the vehicle's route. - // - // Empty or duplicate strings are not allowed. - repeated string end_tags = 8; - - // Time windows during which the vehicle may depart its start location. - // They must be within the global time limits (see - // [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time] - // fields). If unspecified, there is no limitation besides those global time - // limits. - // - // Time windows belonging to the same repeated field must be disjoint, i.e. no - // time window can overlap with or be adjacent to another, and they must be in - // chronological order. - // - // `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if - // there is a single time window. - repeated TimeWindow start_time_windows = 9; - - // Time windows during which the vehicle may arrive at its end location. - // They must be within the global time limits (see - // [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time] - // fields). If unspecified, there is no limitation besides those global time - // limits. - // - // Time windows belonging to the same repeated field must be disjoint, i.e. no - // time window can overlap with or be adjacent to another, and they must be in - // chronological order. - // - // `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if - // there is a single time window. - repeated TimeWindow end_time_windows = 10; - - // Specifies a multiplicative factor that can be used to increase or decrease - // travel times of this vehicle. For example, setting this to 2.0 means - // that this vehicle is slower and has travel times that are twice what they - // are for standard vehicles. This multiple does not affect visit durations. - // It does affect cost if `cost_per_hour` or `cost_per_traveled_hour` are - // specified. This must be in the range [0.001, 1000.0]. If unset, the vehicle - // is standard, and this multiple is considered 1.0. - // - // WARNING: Travel times will be rounded to the nearest second after this - // multiple is applied but before performing any numerical operations, thus, - // a small multiple may result in a loss of precision. - // - // See also `extra_visit_duration_for_visit_type` below. - optional double travel_duration_multiple = 11; - - // Unloading policy enforced on the vehicle. - UnloadingPolicy unloading_policy = 12; - - // Capacities of the vehicle (weight, volume, # of pallets for example). - // The keys in the map are the identifiers of the type of load, consistent - // with the keys of the - // [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands] - // field. If a given key is absent from this map, the corresponding capacity - // is considered to be limitless. - map load_limits = 30; - - // Vehicle costs: all costs add up and must be in the same unit as - // [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost]. - // - // Cost per hour of the vehicle route. This cost is applied to the total time - // taken by the route, and includes travel time, waiting time, and visit time. - // Using `cost_per_hour` instead of just `cost_per_traveled_hour` may result - // in additional latency. - double cost_per_hour = 16; - - // Cost per traveled hour of the vehicle route. This cost is applied only to - // travel time taken by the route (i.e., that reported in - // [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]), - // and excludes waiting time and visit time. - double cost_per_traveled_hour = 17; - - // Cost per kilometer of the vehicle route. This cost is applied to the - // distance reported in the - // [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions] - // and does not apply to any distance implicitly traveled from the - // `arrival_location` to the `departure_location` of a single `VisitRequest`. - double cost_per_kilometer = 18; - - // Fixed cost applied if this vehicle is used to handle a shipment. - double fixed_cost = 19; - - // This field only applies to vehicles when their route does not serve any - // shipments. It indicates if the vehicle should be considered as used or not - // in this case. - // - // If true, the vehicle goes from its start to its end location even if it - // doesn't serve any shipments, and time and distance costs resulting from its - // start --> end travel are taken into account. - // - // Otherwise, it doesn't travel from its start to its end location, and no - // `break_rule` or delay (from `TransitionAttributes`) are scheduled for this - // vehicle. In this case, the vehicle's `ShipmentRoute` doesn't contain any - // information except for the vehicle index and label. - bool used_if_route_is_empty = 20; - - // Limit applied to the total duration of the vehicle's route. In a given - // `OptimizeToursResponse`, the route duration of a vehicle is the - // difference between its `vehicle_end_time` and `vehicle_start_time`. - DurationLimit route_duration_limit = 21; - - // Limit applied to the travel duration of the vehicle's route. In a given - // `OptimizeToursResponse`, the route travel duration is the sum of all its - // [transitions.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration]. - DurationLimit travel_duration_limit = 22; - - // Limit applied to the total distance of the vehicle's route. In a given - // `OptimizeToursResponse`, the route distance is the sum of all its - // [transitions.travel_distance_meters][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_distance_meters]. - DistanceLimit route_distance_limit = 23; - - // Specifies a map from visit_types strings to durations. The duration is time - // in addition to - // [VisitRequest.duration][google.cloud.optimization.v1.Shipment.VisitRequest.duration] - // to be taken at visits with the specified `visit_types`. This extra visit - // duration adds cost if `cost_per_hour` is specified. Keys (i.e. - // `visit_types`) cannot be empty strings. - // - // If a visit request has multiple types, a duration will be added for each - // type in the map. - map extra_visit_duration_for_visit_type = - 24; - - // Describes the break schedule to be enforced on this vehicle. - // If empty, no breaks will be scheduled for this vehicle. - BreakRule break_rule = 25; - - // Specifies a label for this vehicle. This label is reported in the response - // as the `vehicle_label` of the corresponding - // [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute]. - string label = 27; - - // If true, `used_if_route_is_empty` must be false, and this vehicle will - // remain unused. - // - // If a shipment is performed by an ignored vehicle in - // `injected_first_solution_routes`, it is skipped in the first solution but - // is free to be performed in the response. - // - // If a shipment is performed by an ignored vehicle in - // `injected_solution_constraint` and any related pickup/delivery is - // constrained to remain on the vehicle (i.e., not relaxed to level - // `RELAX_ALL_AFTER_THRESHOLD`), it is skipped in the response. - // If a shipment has a non-empty `allowed_vehicle_indices` field and all of - // the allowed vehicles are ignored, it is skipped in the response. - bool ignore = 28; - - // Deprecated: No longer used. - // Indices in the `break_rule` field in the source - // [ShipmentModel][google.cloud.optimization.v1.ShipmentModel]. They - // correspond to break rules enforced on the vehicle. - // - // As of 2018/03, at most one rule index per vehicle can be specified. - repeated int32 break_rule_indices = 29 [deprecated = true]; - - // Deprecated: Use - // [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits] - // instead. - repeated CapacityQuantity capacities = 13 [deprecated = true]; - - // Deprecated: Use - // [Vehicle.LoadLimit.start_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.start_load_interval] - // instead. - repeated CapacityQuantityInterval start_load_intervals = 14 - [deprecated = true]; - - // Deprecated: Use - // [Vehicle.LoadLimit.end_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.end_load_interval] - // instead. - repeated CapacityQuantityInterval end_load_intervals = 15 [deprecated = true]; -} - -// Time windows constrain the time of an event, such as the arrival time at a -// visit, or the start and end time of a vehicle. -// -// Hard time window bounds, `start_time` and `end_time`, enforce the earliest -// and latest time of the event, such that `start_time <= event_time <= -// end_time`. The soft time window lower bound, `soft_start_time`, expresses a -// preference for the event to happen at or after `soft_start_time` by incurring -// a cost proportional to how long before soft_start_time the event occurs. The -// soft time window upper bound, `soft_end_time`, expresses a preference for the -// event to happen at or before `soft_end_time` by incurring a cost proportional -// to how long after `soft_end_time` the event occurs. `start_time`, `end_time`, -// `soft_start_time` and `soft_end_time` should be within the global time limits -// (see -// [ShipmentModel.global_start_time][google.cloud.optimization.v1.ShipmentModel.global_start_time] -// and -// [ShipmentModel.global_end_time][google.cloud.optimization.v1.ShipmentModel.global_end_time]) -// and should respect: -// ``` -// 0 <= `start_time` <= `soft_start_time` <= `end_time` and -// 0 <= `start_time` <= `soft_end_time` <= `end_time`. -// ``` -message TimeWindow { - // The hard time window start time. If unspecified it will be set to - // `ShipmentModel.global_start_time`. - google.protobuf.Timestamp start_time = 1; - - // The hard time window end time. If unspecified it will be set to - // `ShipmentModel.global_end_time`. - google.protobuf.Timestamp end_time = 2; - - // The soft start time of the time window. - google.protobuf.Timestamp soft_start_time = 3; - - // The soft end time of the time window. - google.protobuf.Timestamp soft_end_time = 4; - - // A cost per hour added to other costs in the model if the event occurs - // before soft_start_time, computed as: - // - // ``` - // max(0, soft_start_time - t.seconds) - // * cost_per_hour_before_soft_start_time / 3600, - // t being the time of the event. - // ``` - // - // This cost must be positive, and the field can only be set if - // soft_start_time has been set. - optional double cost_per_hour_before_soft_start_time = 5; - - // A cost per hour added to other costs in the model if the event occurs after - // `soft_end_time`, computed as: - // - // ``` - // max(0, t.seconds - soft_end_time.seconds) - // * cost_per_hour_after_soft_end_time / 3600, - // t being the time of the event. - // ``` - // - // This cost must be positive, and the field can only be set if - // `soft_end_time` has been set. - optional double cost_per_hour_after_soft_end_time = 6; -} - -// Deprecated: Use -// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval] -// instead. -message CapacityQuantity { - option deprecated = true; - - string type = 1; - - int64 value = 2; -} - -// Deprecated: Use -// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval] -// instead. -message CapacityQuantityInterval { - option deprecated = true; - - string type = 1; - - optional int64 min_value = 2; - - optional int64 max_value = 3; -} - -// A limit defining a maximum distance which can be traveled. It can be either -// hard or soft. -// -// If a soft limit is defined, both `soft_max_meters` and -// `cost_per_kilometer_above_soft_max` must be defined and be nonnegative. -message DistanceLimit { - // A hard limit constraining the distance to be at most max_meters. The limit - // must be nonnegative. - optional int64 max_meters = 1; - - // A soft limit not enforcing a maximum distance limit, but when violated - // results in a cost which adds up to other costs defined in the model, - // with the same unit. - // - // If defined soft_max_meters must be less than max_meters and must be - // nonnegative. - optional int64 soft_max_meters = 2; - - // Cost per kilometer incurred if distance is above `soft_max_meters` limit. - // The additional cost is 0 if the distance is under the limit, otherwise the - // formula used to compute the cost is the following: - // ``` - // (distance_meters - soft_max_meters) / 1000.0 * - // cost_per_kilometer_above_soft_max. - // ``` - // The cost must be nonnegative. - optional double cost_per_kilometer_above_soft_max = 3; -} - -// Specifies attributes of transitions between two consecutive visits on a -// route. Several `TransitionAttributes` may apply to the same transition: in -// that case, all extra costs add up and the strictest constraint or limit -// applies (following natural "AND" semantics). -message TransitionAttributes { - // Tags defining the set of (src->dst) transitions these attributes apply to. - // - // A source visit or vehicle start matches iff its - // [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags] - // or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags] - // either contains `src_tag` or does not contain `excluded_src_tag` (depending - // on which of these two fields is non-empty). - string src_tag = 1; - - // See `src_tag`. Exactly one of `src_tag` and `excluded_src_tag` must be - // non-empty. - string excluded_src_tag = 2; - - // A destination visit or vehicle end matches iff its - // [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags] - // or [Vehicle.end_tags][google.cloud.optimization.v1.Vehicle.end_tags] either - // contains `dst_tag` or does not contain `excluded_dst_tag` (depending on - // which of these two fields is non-empty). - string dst_tag = 3; - - // See `dst_tag`. Exactly one of `dst_tag` and `excluded_dst_tag` must be - // non-empty. - string excluded_dst_tag = 4; - - // Specifies a cost for performing this transition. This is in the same unit - // as all other costs in the model and must not be negative. It is applied on - // top of all other existing costs. - double cost = 5; - - // Specifies a cost per kilometer applied to the distance traveled while - // performing this transition. It adds up to any - // [Vehicle.cost_per_kilometer][google.cloud.optimization.v1.Vehicle.cost_per_kilometer] - // specified on vehicles. - double cost_per_kilometer = 6; - - // Specifies a limit on the distance traveled while performing this - // transition. - // - // As of 2021/06, only soft limits are supported. - DistanceLimit distance_limit = 7; - - // Specifies a delay incurred when performing this transition. - // - // This delay always occurs *after* finishing the source visit and *before* - // starting the destination visit. - google.protobuf.Duration delay = 8; -} - -// Encapsulates a waypoint. Waypoints mark arrival and departure locations of -// VisitRequests, and start and end locations of Vehicles. -message Waypoint { - // Different ways to represent a location. - oneof location_type { - // A point specified using geographic coordinates, including an optional - // heading. - Location location = 1; - - // The POI Place ID associated with the waypoint. - string place_id = 2; - } - - // Indicates that the location of this waypoint is meant to have a preference - // for the vehicle to stop at a particular side of road. When you set this - // value, the route will pass through the location so that the vehicle can - // stop at the side of road that the location is biased towards from the - // center of the road. This option works only for the 'DRIVING' travel mode, - // and when the 'location_type' is set to 'location'. - bool side_of_road = 3; -} - -// Encapsulates a location (a geographic point, and an optional heading). -message Location { - // The waypoint's geographic coordinates. - google.type.LatLng lat_lng = 1; - - // The compass heading associated with the direction of the flow of traffic. - // This value is used to specify the side of the road to use for pickup and - // drop-off. Heading values can be from 0 to 360, where 0 specifies a heading - // of due North, 90 specifies a heading of due East, etc. - optional int32 heading = 2; -} - -// Rules to generate time breaks for a vehicle (e.g. lunch breaks). A break -// is a contiguous period of time during which the vehicle remains idle at its -// current position and cannot perform any visit. A break may occur: -// -// * during the travel between two visits (which includes the time right -// before or right after a visit, but not in the middle of a visit), in -// which case it extends the corresponding transit time between the visits, -// * or before the vehicle start (the vehicle may not start in the middle of -// a break), in which case it does not affect the vehicle start time. -// * or after the vehicle end (ditto, with the vehicle end time). -message BreakRule { - // The sequence of breaks (i.e. their number and order) that apply to each - // vehicle must be known beforehand. The repeated `BreakRequest`s define - // that sequence, in the order in which they must occur. Their time windows - // (`earliest_start_time` / `latest_start_time`) may overlap, but they must - // be compatible with the order (this is checked). - message BreakRequest { - // Required. Lower bound (inclusive) on the start of the break. - google.protobuf.Timestamp earliest_start_time = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. Upper bound (inclusive) on the start of the break. - google.protobuf.Timestamp latest_start_time = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Required. Minimum duration of the break. Must be positive. - google.protobuf.Duration min_duration = 3 - [(google.api.field_behavior) = REQUIRED]; - } - - // One may further constrain the frequency and duration of the breaks - // specified above, by enforcing a minimum break frequency, such as - // "There must be a break of at least 1 hour every 12 hours". Assuming that - // this can be interpreted as "Within any sliding time window of 12h, there - // must be at least one break of at least one hour", that example would - // translate to the following `FrequencyConstraint`: - // ``` - // { - // min_break_duration { seconds: 3600 } # 1 hour. - // max_inter_break_duration { seconds: 39600 } # 11 hours (12 - 1 = 11). - // } - // ``` - // - // The timing and duration of the breaks in the solution will respect all - // such constraints, in addition to the time windows and minimum durations - // already specified in the `BreakRequest`. - // - // A `FrequencyConstraint` may in practice apply to non-consecutive breaks. - // For example, the following schedule honors the "1h every 12h" example: - // ``` - // 04:00 vehicle start - // .. performing travel and visits .. - // 09:00 1 hour break - // 10:00 end of the break - // .. performing travel and visits .. - // 12:00 20-min lunch break - // 12:20 end of the break - // .. performing travel and visits .. - // 21:00 1 hour break - // 22:00 end of the break - // .. performing travel and visits .. - // 23:59 vehicle end - // ``` - message FrequencyConstraint { - // Required. Minimum break duration for this constraint. Nonnegative. - // See description of `FrequencyConstraint`. - google.protobuf.Duration min_break_duration = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. Maximum allowed span of any interval of time in the route that - // does not include at least partially a break of `duration >= - // min_break_duration`. Must be positive. - google.protobuf.Duration max_inter_break_duration = 2 - [(google.api.field_behavior) = REQUIRED]; - } - - // Sequence of breaks. See the `BreakRequest` message. - repeated BreakRequest break_requests = 1; - - // Several `FrequencyConstraint` may apply. They must all be satisfied by - // the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`. - repeated FrequencyConstraint frequency_constraints = 2; -} - -// A vehicle's route can be decomposed, along the time axis, like this (we -// assume there are n visits): -// ``` -// | | | | | T[2], | | | -// | Transition | Visit #0 | | | V[2], | | | -// | #0 | aka | T[1] | V[1] | ... | V[n-1] | T[n] | -// | aka T[0] | V[0] | | | V[n-2],| | | -// | | | | | T[n-1] | | | -// ^ ^ ^ ^ ^ ^ ^ ^ -// vehicle V[0].start V[0].end V[1]. V[1]. V[n]. V[n]. vehicle -// start (arrival) (departure) start end start end end -// ``` -// Note that we make a difference between: -// -// * "punctual events", such as the vehicle start and end and each visit's start -// and end (aka arrival and departure). They happen at a given second. -// * "time intervals", such as the visits themselves, and the transition between -// visits. Though time intervals can sometimes have zero duration, i.e. start -// and end at the same second, they often have a positive duration. -// -// Invariants: -// -// * If there are n visits, there are n+1 transitions. -// * A visit is always surrounded by a transition before it (same index) and a -// transition after it (index + 1). -// * The vehicle start is always followed by transition #0. -// * The vehicle end is always preceded by transition #n. -// -// Zooming in, here is what happens during a `Transition` and a `Visit`: -// ``` -// ---+-------------------------------------+-----------------------------+--> -// | TRANSITION[i] | VISIT[i] | -// | | | -// | * TRAVEL: the vehicle moves from | PERFORM the visit: | -// | VISIT[i-1].departure_location to | | -// | VISIT[i].arrival_location, which | * Spend some time: | -// | takes a given travel duration | the "visit duration". | -// | and distance | | -// | | * Load or unload | -// | * BREAKS: the driver may have | some quantities from the | -// | breaks (e.g. lunch break). | vehicle: the "demand". | -// | | | -// | * WAIT: the driver/vehicle does | | -// | nothing. This can happen for | | -// | many reasons, for example when | | -// | the vehicle reaches the next | | -// | event's destination before the | | -// | start of its time window | | -// | | | -// | * DELAY: *right before* the next | | -// | arrival. E.g. the vehicle and/or | | -// | driver spends time unloading. | | -// | | | -// ---+-------------------------------------+-----------------------------+--> -// ^ ^ ^ -// V[i-1].end V[i].start V[i].end -// ``` -// Lastly, here is how the TRAVEL, BREAKS, DELAY and WAIT can be arranged -// during a transition. -// -// * They don't overlap. -// * The DELAY is unique and *must* be a contiguous period of time right -// before the next visit (or vehicle end). Thus, it suffice to know the -// delay duration to know its start and end time. -// * The BREAKS are contiguous, non-overlapping periods of time. The -// response specifies the start time and duration of each break. -// * TRAVEL and WAIT are "preemptable": they can be interrupted several times -// during this transition. Clients can assume that travel happens "as soon as -// possible" and that "wait" fills the remaining time. -// -// A (complex) example: -// ``` -// TRANSITION[i] -// --++-----+-----------------------------------------------------------++--> -// || | | | | | | || -// || T | B | T | | B | | D || -// || r | r | r | W | r | W | e || -// || a | e | a | a | e | a | l || -// || v | a | v | i | a | i | a || -// || e | k | e | t | k | t | y || -// || l | | l | | | | || -// || | | | | | | || -// --++-----------------------------------------------------------------++--> -// ``` -message ShipmentRoute { - // Deprecated: Use - // [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration] - // instead. Time interval spent on the route resulting from a - // [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay]. - message Delay { - option deprecated = true; - - // Start of the delay. - google.protobuf.Timestamp start_time = 1; - - // Duration of the delay. - google.protobuf.Duration duration = 2; - } - - // A visit performed during a route. This visit corresponds to a pickup or a - // delivery of a `Shipment`. - message Visit { - // Index of the `shipments` field in the source - // [ShipmentModel][google.cloud.optimization.v1.ShipmentModel]. - int32 shipment_index = 1; - - // If true the visit corresponds to a pickup of a `Shipment`. Otherwise, it - // corresponds to a delivery. - bool is_pickup = 2; - - // Index of `VisitRequest` in either the pickup or delivery field of the - // `Shipment` (see `is_pickup`). - int32 visit_request_index = 3; - - // Time at which the visit starts. Note that the vehicle may arrive earlier - // than this at the visit location. Times are consistent with the - // `ShipmentModel`. - google.protobuf.Timestamp start_time = 4; - - // Total visit load demand as the sum of the shipment and the visit request - // `load_demands`. The values are negative if the visit is a delivery. - // Demands are reported for the same types as the - // [Transition.loads][google.cloud.optimization.v1.ShipmentRoute.Transition] - // (see this field). - map load_demands = 11; - - // Extra detour time due to the shipments visited on the route before the - // visit and to the potential waiting time induced by time windows. - // If the visit is a delivery, the detour is computed from the corresponding - // pickup visit and is equal to: - // ``` - // start_time(delivery) - start_time(pickup) - // - (duration(pickup) + travel duration from the pickup location - // to the delivery location). - // ``` - // Otherwise, it is computed from the vehicle `start_location` and is equal - // to: - // ``` - // start_time - vehicle_start_time - travel duration from - // the vehicle's `start_location` to the visit. - // ``` - google.protobuf.Duration detour = 6; - - // Copy of the corresponding `Shipment.label`, if specified in the - // `Shipment`. - string shipment_label = 7; - - // Copy of the corresponding - // [VisitRequest.label][google.cloud.optimization.v1.Shipment.VisitRequest.label], - // if specified in the `VisitRequest`. - string visit_label = 8; - - // Deprecated: Use - // [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads] - // instead. Vehicle loads upon arrival at the visit location, for each type - // specified in - // [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities], - // `start_load_intervals`, `end_load_intervals` or `demands`. - // - // Exception: we omit loads for quantity types unconstrained by intervals - // and that don't have any non-zero demand on the route. - repeated CapacityQuantity arrival_loads = 9 [deprecated = true]; - - // Deprecated: Use - // [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration] - // instead. Delay occurring before the visit starts. - Delay delay_before_start = 10 [deprecated = true]; - - // Deprecated: Use - // [Visit.load_demands][google.cloud.optimization.v1.ShipmentRoute.Visit.load_demands] - // instead. - repeated CapacityQuantity demands = 5 [deprecated = true]; - } - - // Transition between two events on the route. See the description of - // [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute]. - // - // If the vehicle does not have a `start_location` and/or `end_location`, the - // corresponding travel metrics are 0. - message Transition { - // Travel duration during this transition. - google.protobuf.Duration travel_duration = 1; - - // Distance traveled during the transition. - double travel_distance_meters = 2; - - // When traffic is requested via - // [OptimizeToursRequest.consider_road_traffic] - // [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic], - // and the traffic info couldn't be retrieved for a `Transition`, this - // boolean is set to true. This may be temporary (rare hiccup in the - // realtime traffic servers) or permanent (no data for this location). - bool traffic_info_unavailable = 3; - - // Sum of the delay durations applied to this transition. If any, the delay - // starts exactly `delay_duration` seconds before the next event (visit or - // vehicle end). See - // [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay]. - google.protobuf.Duration delay_duration = 4; - - // Sum of the duration of the breaks occurring during this transition, if - // any. Details about each break's start time and duration are stored in - // [ShipmentRoute.breaks][google.cloud.optimization.v1.ShipmentRoute.breaks]. - google.protobuf.Duration break_duration = 5; - - // Time spent waiting during this transition. Wait duration corresponds to - // idle time and does not include break time. Also note that this wait time - // may be split into several non-contiguous intervals. - google.protobuf.Duration wait_duration = 6; - - // Total duration of the transition, provided for convenience. It is equal - // to: - // - // * next visit `start_time` (or `vehicle_end_time` if this is the last - // transition) - this transition's `start_time`; - // * if `ShipmentRoute.has_traffic_infeasibilities` is false, the following - // additionally holds: `total_duration = travel_duration + delay_duration - // + break_duration + wait_duration`. - google.protobuf.Duration total_duration = 7; - - // Start time of this transition. - google.protobuf.Timestamp start_time = 8; - - // The encoded polyline representation of the route followed during the - // transition. - // This field is only populated if [populate_transition_polylines] - // [google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines] - // is set to true. - EncodedPolyline route_polyline = 9; - - // Vehicle loads during this transition, for each type that either appears - // in this vehicle's - // [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits], - // or that have non-zero - // [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands] - // on some shipment performed on this route. - // - // The loads during the first transition are the starting loads of the - // vehicle route. Then, after each visit, the visit's `load_demands` are - // either added or subtracted to get the next transition's loads, depending - // on whether the visit was a pickup or a delivery. - map vehicle_loads = 11; - - // Deprecated: Use - // [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads] - // instead. - repeated CapacityQuantity loads = 10 [deprecated = true]; - } - - // Reports the actual load of the vehicle at some point along the route, - // for a given type (see - // [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]). - message VehicleLoad { - // The amount of load on the vehicle, for the given type. The unit of load - // is usually indicated by the type. See - // [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]. - int64 amount = 1; - } - - // The encoded representation of a polyline. More information on polyline - // encoding can be found here: - // https://developers.google.com/maps/documentation/utilities/polylinealgorithm - // https://developers.google.com/maps/documentation/javascript/reference/geometry#encoding. - message EncodedPolyline { - // String representing encoded points of the polyline. - string points = 1; - } - - // Data representing the execution of a break. - message Break { - // Start time of a break. - google.protobuf.Timestamp start_time = 1; - - // Duration of a break. - google.protobuf.Duration duration = 2; - } - - // Deprecated: Use - // [ShipmentRoute.Transition][google.cloud.optimization.v1.ShipmentRoute.Transition] - // instead. Travel between each visit along the route: from the vehicle's - // `start_location` to the first visit's `arrival_location`, then from the - // first visit's `departure_location` to the second visit's - // `arrival_location`, and so on until the vehicle's `end_location`. This - // accounts only for the actual travel between visits, not counting the - // waiting time, the time spent performing a visit, nor the distance covered - // during a visit. - // - // Invariant: `travel_steps_size() == visits_size() + 1`. - // - // If the vehicle does not have a start_ and/or end_location, the - // corresponding travel metrics are 0 and/or empty. - message TravelStep { - option deprecated = true; - - // Duration of the travel step. - google.protobuf.Duration duration = 1; - - // Distance traveled during the step. - double distance_meters = 2; - - // When traffic is requested via - // [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic], - // and the traffic info couldn't be retrieved for a TravelStep, this boolean - // is set to true. This may be temporary (rare hiccup in the realtime - // traffic servers) or permanent (no data for this location). - bool traffic_info_unavailable = 3; - - // The encoded polyline representation of the route followed during the - // step. - // - // This field is only populated if - // [OptimizeToursRequest.populate_travel_step_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_travel_step_polylines] - // is set to true. - EncodedPolyline route_polyline = 4; - } - - // Vehicle performing the route, identified by its index in the source - // `ShipmentModel`. - int32 vehicle_index = 1; - - // Label of the vehicle performing this route, equal to - // `ShipmentModel.vehicles(vehicle_index).label`, if specified. - string vehicle_label = 2; - - // Time at which the vehicle starts its route. - google.protobuf.Timestamp vehicle_start_time = 5; - - // Time at which the vehicle finishes its route. - google.protobuf.Timestamp vehicle_end_time = 6; - - // Ordered sequence of visits representing a route. - // visits[i] is the i-th visit in the route. - // If this field is empty, the vehicle is considered as unused. - repeated Visit visits = 7; - - // Ordered list of transitions for the route. - repeated Transition transitions = 8; - - // When - // [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic], - // is set to true, this field indicates that inconsistencies in route timings - // are predicted using traffic-based travel duration estimates. There may be - // insufficient time to complete traffic-adjusted travel, delays, and breaks - // between visits, before the first visit, or after the last visit, while - // still satisfying the visit and vehicle time windows. For example, - // - // ``` - // start_time(previous_visit) + duration(previous_visit) + - // travel_duration(previous_visit, next_visit) > start_time(next_visit) - // ``` - // - // Arrival at next_visit will likely happen later than its current - // time window due the increased estimate of travel time - // `travel_duration(previous_visit, next_visit)` due to traffic. Also, a break - // may be forced to overlap with a visit due to an increase in travel time - // estimates and visit or break time window restrictions. - bool has_traffic_infeasibilities = 9; - - // The encoded polyline representation of the route. - // This field is only populated if - // [OptimizeToursRequest.populate_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_polylines] - // is set to true. - EncodedPolyline route_polyline = 10; - - // Breaks scheduled for the vehicle performing this route. - // The `breaks` sequence represents time intervals, each starting at the - // corresponding `start_time` and lasting `duration` seconds. - repeated Break breaks = 11; - - // Duration, distance and load metrics for this route. The fields of - // [AggregatedMetrics][google.cloud.optimization.v1.AggregatedMetrics] are - // summed over all - // [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions] - // or - // [ShipmentRoute.visits][google.cloud.optimization.v1.ShipmentRoute.visits], - // depending on the context. - AggregatedMetrics metrics = 12; - - // Cost of the route, broken down by cost-related request fields. - // The keys are proto paths, relative to the input OptimizeToursRequest, e.g. - // "model.shipments.pickups.cost", and the values are the total cost - // generated by the corresponding cost field, aggregated over the whole route. - // In other words, costs["model.shipments.pickups.cost"] is the sum of all - // pickup costs over the route. All costs defined in the model are reported in - // detail here with the exception of costs related to TransitionAttributes - // that are only reported in an aggregated way as of 2022/01. - map route_costs = 17; - - // Total cost of the route. The sum of all costs in the cost map. - double route_total_cost = 18; - - // Deprecated: Use - // [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads] - // instead. Vehicle loads upon arrival at its end location, for each type - // specified in - // [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities], - // `start_load_intervals`, `end_load_intervals` or demands. Exception: we omit - // loads for quantity types unconstrained by intervals and that don't have any - // non-zero demand on the route. - repeated CapacityQuantity end_loads = 13 [deprecated = true]; - - // Deprecated: Use - // [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions] - // instead. Ordered list of travel steps for the route. - repeated TravelStep travel_steps = 14 [deprecated = true]; - - // Deprecated: No longer used. - // This field will only be populated at the - // [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit] - // level. - // - // This field is the extra detour time due to the shipments visited on the - // route. - // - // It is equal to `vehicle_end_time` - `vehicle_start_time` - travel duration - // from the vehicle's start_location to its `end_location`. - google.protobuf.Duration vehicle_detour = 15 [deprecated = true]; - - // Deprecated: Delay occurring before the vehicle end. See - // [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay]. - Delay delay_before_vehicle_end = 16 [deprecated = true]; -} - -// Specifies details of unperformed shipments in a solution. For trivial cases -// and/or if we are able to identify the cause for skipping, we report the -// reason here. -message SkippedShipment { - // If we can explain why the shipment was skipped, reasons will be listed - // here. If the reason is not the same for all vehicles, `reason` will have - // more than 1 element. A skipped shipment cannot have duplicate reasons, - // i.e. where all fields are the same except for `example_vehicle_index`. - // Example: - // ``` - // reasons { - // code: DEMAND_EXCEEDS_VEHICLE_CAPACITY - // example_vehicle_index: 1 - // example_exceeded_capacity_type: "Apples" - // } - // reasons { - // code: DEMAND_EXCEEDS_VEHICLE_CAPACITY - // example_vehicle_index: 3 - // example_exceeded_capacity_type: "Pears" - // } - // reasons { - // code: CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT - // example_vehicle_index: 1 - // } - // ``` - // The skipped shipment is incompatible with all vehicles. The reasons may - // be different for all vehicles but at least one vehicle's "Apples" - // capacity would be exceeded (including vehicle 1), at least one vehicle's - // "Pears" capacity would be exceeded (including vehicle 3) and at least one - // vehicle's distance limit would be exceeded (including vehicle 1). - message Reason { - // Code identifying the reason type. The order here is meaningless. In - // particular, it gives no indication of whether a given reason will - // appear before another in the solution, if both apply. - enum Code { - // This should never be used. If we are unable to understand why a - // shipment was skipped, we simply return an empty set of reasons. - CODE_UNSPECIFIED = 0; - - // There is no vehicle in the model making all shipments infeasible. - NO_VEHICLE = 1; - - // The demand of the shipment exceeds a vehicle's capacity for some - // capacity types, one of which is `example_exceeded_capacity_type`. - DEMAND_EXCEEDS_VEHICLE_CAPACITY = 2; - - // The minimum distance necessary to perform this shipment, i.e. from - // the vehicle's `start_location` to the shipment's pickup and/or delivery - // locations and to the vehicle's end location exceeds the vehicle's - // `route_distance_limit`. - // - // Note that for this computation we use the geodesic distances. - CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT = 3; - - // The minimum time necessary to perform this shipment, including travel - // time, wait time and service time exceeds the vehicle's - // `route_duration_limit`. - // - // Note: travel time is computed in the best-case scenario, namely as - // geodesic distance x 36 m/s (roughly 130 km/hour). - CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT = 4; - - // Same as above but we only compare minimum travel time and the - // vehicle's `travel_duration_limit`. - CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT = 5; - - // The vehicle cannot perform this shipment in the best-case scenario - // (see `CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT` for time - // computation) if it starts at its earliest start time: the total time - // would make the vehicle end after its latest end time. - CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS = 6; - - // The `allowed_vehicle_indices` field of the shipment is not empty and - // this vehicle does not belong to it. - VEHICLE_NOT_ALLOWED = 7; - } - - // Refer to the comments of Code. - Code code = 1; - - // If the reason is related to a shipment-vehicle incompatibility, this - // field provides the index of one relevant vehicle. - optional int32 example_vehicle_index = 2; - - // If the reason code is `DEMAND_EXCEEDS_VEHICLE_CAPACITY`, documents one - // capacity type that is exceeded. - string example_exceeded_capacity_type = 3; - } - - // The index corresponds to the index of the shipment in the source - // `ShipmentModel`. - int32 index = 1; - - // Copy of the corresponding - // [Shipment.label][google.cloud.optimization.v1.Shipment.label], if specified - // in the `Shipment`. - string label = 2; - - // A list of reasons that explain why the shipment was skipped. See comment - // above `Reason`. - repeated Reason reasons = 3; -} - -// Aggregated metrics for -// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute] (resp. for -// [OptimizeToursResponse][google.cloud.optimization.v1.OptimizeToursResponse] -// over all [Transition][google.cloud.optimization.v1.ShipmentRoute.Transition] -// and/or [Visit][google.cloud.optimization.v1.ShipmentRoute.Visit] (resp. over -// all [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute]) elements. -message AggregatedMetrics { - // Number of shipments performed. Note that a pickup and delivery pair only - // counts once. - int32 performed_shipment_count = 1; - - // Total travel duration for a route or a solution. - google.protobuf.Duration travel_duration = 2; - - // Total wait duration for a route or a solution. - google.protobuf.Duration wait_duration = 3; - - // Total delay duration for a route or a solution. - google.protobuf.Duration delay_duration = 4; - - // Total break duration for a route or a solution. - google.protobuf.Duration break_duration = 5; - - // Total visit duration for a route or a solution. - google.protobuf.Duration visit_duration = 6; - - // The total duration should be equal to the sum of all durations above. - // For routes, it also corresponds to: - // [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time] - // `-` - // [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time] - google.protobuf.Duration total_duration = 7; - - // Total travel distance for a route or a solution. - double travel_distance_meters = 8; - - // Maximum load achieved over the entire route (resp. solution), for each of - // the quantities on this route (resp. solution), computed as the maximum over - // all - // [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads] - // (resp. - // [ShipmentRoute.metrics.max_loads][google.cloud.optimization.v1.AggregatedMetrics.max_loads]. - map max_loads = 9; - - // Deprecated: Use - // [ShipmentRoute.route_costs][google.cloud.optimization.v1.ShipmentRoute.route_costs] - // and - // [OptimizeToursResponse.Metrics.costs][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.costs] - // instead. - map costs = 10 [deprecated = true]; - - // Deprecated: Use - // [ShipmentRoute.route_total_cost][google.cloud.optimization.v1.ShipmentRoute.route_total_cost] - // and - // [OptimizeToursResponse.Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost] - // instead. - double total_cost = 11 [deprecated = true]; -} - -// Solution injected in the request including information about which visits -// must be constrained and how they must be constrained. -message InjectedSolutionConstraint { - // For a group of vehicles, specifies at what threshold(s) constraints on - // visits will be relaxed and to which level. Shipments listed in - // the `skipped_shipment` field are constrained to be skipped; i.e., they - // cannot be performed. - message ConstraintRelaxation { - // If `relaxations` is empty, the start time and sequence of all visits - // on `routes` are fully constrained and no new visits may be inserted or - // added to those routes. Also, a vehicle's start and end time in - // `routes` is fully constrained, unless the vehicle is empty (i.e., has no - // visits and has `used_if_route_is_empty` set to false in the model). - // - // `relaxations(i).level` specifies the constraint relaxation level applied - // to a visit #j that satisfies: - // - // * `route.visits(j).start_time >= relaxations(i).threshold_time` AND - // * `j + 1 >= relaxations(i).threshold_visit_count` - // - // Similarly, the vehicle start is relaxed to `relaxations(i).level` if it - // satisfies: - // - // * `vehicle_start_time >= relaxations(i).threshold_time` AND - // * `relaxations(i).threshold_visit_count == 0` - // and the vehicle end is relaxed to `relaxations(i).level` if it satisfies: - // * `vehicle_end_time >= relaxations(i).threshold_time` AND - // * `route.visits_size() + 1 >= relaxations(i).threshold_visit_count` - // - // To apply a relaxation level if a visit meets the `threshold_visit_count` - // OR the `threshold_time` add two `relaxations` with the same `level`: - // one with only `threshold_visit_count` set and the other with only - // `threshold_time` set. If a visit satisfies the conditions of multiple - // `relaxations`, the most relaxed level applies. As a result, from the - // vehicle start through the route visits in order to the vehicle end, the - // relaxation level becomes more relaxed: i.e., the relaxation level is - // non-decreasing as the route progresses. - // - // The timing and sequence of route visits that do not satisfy the - // threshold conditions of any `relaxations` are fully constrained - // and no visits may be inserted into these sequences. Also, if a - // vehicle start or end does not satisfy the conditions of any - // relaxation the time is fixed, unless the vehicle is empty. - message Relaxation { - // Expresses the different constraint relaxation levels, which are - // applied for a visit and those that follow when it satisfies the - // threshold conditions. - // - // The enumeration below is in order of increasing relaxation. - enum Level { - // Implicit default relaxation level: no constraints are relaxed, - // i.e., all visits are fully constrained. - // - // This value must not be explicitly used in `level`. - LEVEL_UNSPECIFIED = 0; - - // Visit start times and vehicle start/end times will be relaxed, but - // each visit remains bound to the same vehicle and the visit sequence - // must be observed: no visit can be inserted between them or before - // them. - RELAX_VISIT_TIMES_AFTER_THRESHOLD = 1; - - // Same as `RELAX_VISIT_TIMES_AFTER_THRESHOLD`, but the visit sequence - // is also relaxed: visits remain simply bound to their vehicle. - RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD = 2; - - // Same as `RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD`, but the - // vehicle is also relaxed: visits are completely free at or after the - // threshold time and can potentially become unperformed. - RELAX_ALL_AFTER_THRESHOLD = 3; - } - - // The constraint relaxation level that applies when the conditions - // at or after `threshold_time` AND at least `threshold_visit_count` are - // satisfied. - Level level = 1; - - // The time at or after which the relaxation `level` may be applied. - google.protobuf.Timestamp threshold_time = 2; - - // The number of visits at or after which the relaxation `level` may be - // applied. If `threshold_visit_count` is 0 (or unset), the `level` may be - // applied directly at the vehicle start. - // - // If it is `route.visits_size() + 1`, the `level` may only be applied to - // the vehicle end. If it is more than `route.visits_size() + 1`, - // `level` is not applied at all for that route. - int32 threshold_visit_count = 3; - } - - // All the visit constraint relaxations that will apply to visits on - // routes with vehicles in `vehicle_indices`. - repeated Relaxation relaxations = 1; - - // Specifies the vehicle indices to which the visit constraint - // `relaxations` apply. If empty, this is considered the default and the - // `relaxations` apply to all vehicles that are not specified in other - // `constraint_relaxations`. There can be at most one default, i.e., at - // most one constraint relaxation field is allowed empty - // `vehicle_indices`. A vehicle index can only be listed once, even within - // several `constraint_relaxations`. - // - // A vehicle index is mapped the same as - // [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index], - // if `interpret_injected_solutions_using_labels` is true (see `fields` - // comment). - repeated int32 vehicle_indices = 2; - } - - // Routes of the solution to inject. Some routes may be omitted from the - // original solution. The routes and skipped shipments must satisfy the basic - // validity assumptions listed for `injected_first_solution_routes`. - repeated ShipmentRoute routes = 1; - - // Skipped shipments of the solution to inject. Some may be omitted from the - // original solution. See the `routes` field. - repeated SkippedShipment skipped_shipments = 2; - - // For zero or more groups of vehicles, specifies when and how much to relax - // constraints. If this field is empty, all non-empty vehicle routes are - // fully constrained. - repeated ConstraintRelaxation constraint_relaxations = 3; -} - -// Describes an error encountered when validating an `OptimizeToursRequest`. -message OptimizeToursValidationError { - // Specifies a context for the validation error. A `FieldReference` always - // refers to a given field in this file and follows the same hierarchical - // structure. For example, we may specify element #2 of `start_time_windows` - // of vehicle #5 using: - // ``` - // name: "vehicles" index: 5 sub_field { name: "end_time_windows" index: 2 } - // ``` - // We however omit top-level entities such as `OptimizeToursRequest` or - // `ShipmentModel` to avoid crowding the message. - message FieldReference { - // Name of the field, e.g., "vehicles". - string name = 1; - - oneof index_or_key { - // Index of the field if repeated. - int32 index = 2; - - // Key if the field is a map. - string key = 4; - } - - // Recursively nested sub-field, if needed. - FieldReference sub_field = 3; - } - - // A validation error is defined by the pair (`code`, `display_name`) which - // are always present. - // - // Other fields (below) provide more context about the error. - // - // *MULTIPLE ERRORS*: - // When there are multiple errors, the validation process tries to output - // several of them. Much like a compiler, this is an imperfect process. Some - // validation errors will be "fatal", meaning that they stop the entire - // validation process. This is the case for `display_name="UNSPECIFIED"` - // errors, among others. Some may cause the validation process to skip other - // errors. - // - // *STABILITY*: - // `code` and `display_name` should be very stable. But new codes and - // display names may appear over time, which may cause a given (invalid) - // request to yield a different (`code`, `display_name`) pair because the new - // error hid the old one (see "MULTIPLE ERRORS"). - // - // *REFERENCE*: A list of all (code, name) pairs: - // - // * UNSPECIFIED = 0; - // * VALIDATION_TIMEOUT_ERROR = 10; Validation couldn't be completed within - // the deadline. - // - // * REQUEST_OPTIONS_ERROR = 12; - // * REQUEST_OPTIONS_INVALID_SOLVING_MODE = 1201; - // * REQUEST_OPTIONS_INVALID_MAX_VALIDATION_ERRORS = 1203; - // * REQUEST_OPTIONS_INVALID_GEODESIC_METERS_PER_SECOND = 1204; - // * REQUEST_OPTIONS_GEODESIC_METERS_PER_SECOND_TOO_SMALL = 1205; - // * REQUEST_OPTIONS_MISSING_GEODESIC_METERS_PER_SECOND = 1206; - // * REQUEST_OPTIONS_POPULATE_PATHFINDER_TRIPS_AND_GEODESIC_DISTANCE - // = 1207; - // * REQUEST_OPTIONS_COST_MODEL_OPTIONS_AND_GEODESIC_DISTANCE = 1208; - // * REQUEST_OPTIONS_TRAVEL_MODE_INCOMPATIBLE_WITH_TRAFFIC = 1211; - // * REQUEST_OPTIONS_MULTIPLE_TRAFFIC_FLAVORS = 1212; - // * REQUEST_OPTIONS_INVALID_TRAFFIC_FLAVOR = 1213; - // * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITHOUT_GLOBAL_START_TIME = 1214; - // * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITH_PRECEDENCES = 1215; - // * REQUEST_OPTIONS_TRAFFIC_PREFILL_MODE_INVALID = 1216; - // * REQUEST_OPTIONS_TRAFFIC_PREFILL_ENABLED_WITHOUT_TRAFFIC = 1217; - // * INJECTED_SOLUTION_ERROR = 20; - // * INJECTED_SOLUTION_MISSING_LABEL = 2000; - // * INJECTED_SOLUTION_DUPLICATE_LABEL = 2001; - // * INJECTED_SOLUTION_AMBIGUOUS_INDEX = 2002; - // * INJECTED_SOLUTION_INFEASIBLE_AFTER_GETTING_TRAVEL_TIMES = 2003; - // * INJECTED_SOLUTION_TRANSITION_INCONSISTENT_WITH_ACTUAL_TRAVEL = 2004; - // * INJECTED_SOLUTION_CONCURRENT_SOLUTION_TYPES = 2005; - // * INJECTED_SOLUTION_MORE_THAN_ONE_PER_TYPE = 2006; - // * INJECTED_SOLUTION_REFRESH_WITHOUT_POPULATE = 2008; - // * SHIPMENT_MODEL_ERROR = 22; - // * SHIPMENT_MODEL_TOO_LARGE = 2200; - // * SHIPMENT_MODEL_TOO_MANY_CAPACITY_TYPES = 2201; - // * SHIPMENT_MODEL_GLOBAL_START_TIME_NEGATIVE_OR_NAN = 2202; - // * SHIPMENT_MODEL_GLOBAL_END_TIME_TOO_LARGE_OR_NAN = 2203; - // * SHIPMENT_MODEL_GLOBAL_START_TIME_AFTER_GLOBAL_END_TIME = 2204; - // * SHIPMENT_MODEL_GLOBAL_DURATION_TOO_LONG = 2205; - // * SHIPMENT_MODEL_MAX_ACTIVE_VEHICLES_NOT_POSITIVE = 2206; - // * SHIPMENT_MODEL_DURATION_MATRIX_TOO_LARGE = 2207; - // * INDEX_ERROR = 24; - // * TAG_ERROR = 26; - // * TIME_WINDOW_ERROR = 28; - // * TIME_WINDOW_INVALID_START_TIME = 2800; - // * TIME_WINDOW_INVALID_END_TIME = 2801; - // * TIME_WINDOW_INVALID_SOFT_START_TIME = 2802; - // * TIME_WINDOW_INVALID_SOFT_END_TIME = 2803; - // * TIME_WINDOW_OUTSIDE_GLOBAL_TIME_WINDOW = 2804; - // * TIME_WINDOW_START_TIME_AFTER_END_TIME = 2805; - // * TIME_WINDOW_INVALID_COST_PER_HOUR_BEFORE_SOFT_START_TIME = 2806; - // * TIME_WINDOW_INVALID_COST_PER_HOUR_AFTER_SOFT_END_TIME = 2807; - // * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_WITHOUT_SOFT_START_TIME - // = 2808; - // * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_WITHOUT_SOFT_END_TIME = 2809; - // * TIME_WINDOW_SOFT_START_TIME_WITHOUT_COST_BEFORE_SOFT_START_TIME - // = 2810; - // * TIME_WINDOW_SOFT_END_TIME_WITHOUT_COST_AFTER_SOFT_END_TIME = 2811; - // * TIME_WINDOW_OVERLAPPING_ADJACENT_OR_EARLIER_THAN_PREVIOUS = 2812; - // * TIME_WINDOW_START_TIME_AFTER_SOFT_START_TIME = 2813; - // * TIME_WINDOW_SOFT_START_TIME_AFTER_END_TIME = 2814; - // * TIME_WINDOW_START_TIME_AFTER_SOFT_END_TIME = 2815; - // * TIME_WINDOW_SOFT_END_TIME_AFTER_END_TIME = 2816; - // * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_SET_AND_MULTIPLE_WINDOWS - // = 2817; - // * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_SET_AND_MULTIPLE_WINDOWS = 2818; - // * TRANSITION_ATTRIBUTES_ERROR = 30; - // * TRANSITION_ATTRIBUTES_INVALID_COST = 3000; - // * TRANSITION_ATTRIBUTES_INVALID_COST_PER_KILOMETER = 3001; - // * TRANSITION_ATTRIBUTES_DUPLICATE_TAG_PAIR = 3002; - // * TRANSITION_ATTRIBUTES_DISTANCE_LIMIT_MAX_METERS_UNSUPPORTED = 3003; - // * TRANSITION_ATTRIBUTES_UNSPECIFIED_SOURCE_TAGS = 3004; - // * TRANSITION_ATTRIBUTES_CONFLICTING_SOURCE_TAGS_FIELDS = 3005; - // * TRANSITION_ATTRIBUTES_UNSPECIFIED_DESTINATION_TAGS = 3006; - // * TRANSITION_ATTRIBUTES_CONFLICTING_DESTINATION_TAGS_FIELDS = 3007; - // * TRANSITION_ATTRIBUTES_DELAY_DURATION_NEGATIVE_OR_NAN = 3008; - // * TRANSITION_ATTRIBUTES_DELAY_DURATION_EXCEEDS_GLOBAL_DURATION = 3009; - // * AMOUNT_ERROR = 31; - // * AMOUNT_NEGATIVE_VALUE = 3100; - // * LOAD_LIMIT_ERROR = 33; - // * LOAD_LIMIT_INVALID_COST_ABOVE_SOFT_MAX = 3303; - // * LOAD_LIMIT_SOFT_MAX_WITHOUT_COST_ABOVE_SOFT_MAX = 3304; - // * LOAD_LIMIT_COST_ABOVE_SOFT_MAX_WITHOUT_SOFT_MAX = 3305; - // * LOAD_LIMIT_NEGATIVE_SOFT_MAX = 3306; - // * LOAD_LIMIT_MIXED_DEMAND_TYPE = 3307; - // * LOAD_LIMIT_MAX_LOAD_NEGATIVE_VALUE = 3308; - // * LOAD_LIMIT_SOFT_MAX_ABOVE_MAX = 3309; - // * INTERVAL_ERROR = 34; - // * INTERVAL_MIN_EXCEEDS_MAX = 3401; - // * INTERVAL_NEGATIVE_MIN = 3402; - // * INTERVAL_NEGATIVE_MAX = 3403; - // * INTERVAL_MIN_EXCEEDS_CAPACITY = 3404; - // * INTERVAL_MAX_EXCEEDS_CAPACITY = 3405; - // * DISTANCE_LIMIT_ERROR = 36; - // * DISTANCE_LIMIT_INVALID_COST_AFTER_SOFT_MAX = 3601; - // * DISTANCE_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3602; - // * DISTANCE_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3603; - // * DISTANCE_LIMIT_NEGATIVE_MAX = 3604; - // * DISTANCE_LIMIT_NEGATIVE_SOFT_MAX = 3605; - // * DISTANCE_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3606; - // * DURATION_LIMIT_ERROR = 38; - // * DURATION_LIMIT_MAX_DURATION_NEGATIVE_OR_NAN = 3800; - // * DURATION_LIMIT_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3801; - // * DURATION_LIMIT_INVALID_COST_PER_HOUR_AFTER_SOFT_MAX = 3802; - // * DURATION_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3803; - // * DURATION_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3804; - // * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3805; - // * DURATION_LIMIT_INVALID_COST_AFTER_QUADRATIC_SOFT_MAX = 3806; - // * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_COST_PER_SQUARE_HOUR - // = 3807; - // * DURATION_LIMIT_COST_PER_SQUARE_HOUR_WITHOUT_QUADRATIC_SOFT_MAX - // = 3808; - // * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_MAX = 3809; - // * DURATION_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3810; - // * DURATION_LIMIT_QUADRATIC_SOFT_MAX_LARGER_THAN_MAX = 3811; - // * DURATION_LIMIT_DIFF_BETWEEN_MAX_AND_QUADRATIC_SOFT_MAX_TOO_LARGE - // = 3812; - // * DURATION_LIMIT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3813; - // * DURATION_LIMIT_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3814; - // * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION - // = 3815; - // * SHIPMENT_ERROR = 40; - // * SHIPMENT_PD_LIMIT_WITHOUT_PICKUP_AND_DELIVERY = 4014; - // * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_NEGATIVE_OR_NAN = 4000; - // * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION - // = 4001; - // * SHIPMENT_PD_RELATIVE_DETOUR_LIMIT_INVALID = 4015; - // * SHIPMENT_PD_DETOUR_LIMIT_AND_EXTRA_VISIT_DURATION = 4016; - // * SHIPMENT_PD_TIME_LIMIT_DURATION_NEGATIVE_OR_NAN = 4002; - // * SHIPMENT_PD_TIME_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4003; - // * SHIPMENT_EMPTY_SHIPMENT_TYPE = 4004; - // * SHIPMENT_NO_PICKUP_NO_DELIVERY = 4005; - // * SHIPMENT_INVALID_PENALTY_COST = 4006; - // * SHIPMENT_ALLOWED_VEHICLE_INDEX_OUT_OF_BOUNDS = 4007; - // * SHIPMENT_DUPLICATE_ALLOWED_VEHICLE_INDEX = 4008; - // * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITHOUT_INDEX = 4009; - // * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITH_INDEX = 4010; - // * SHIPMENT_INVALID_COST_FOR_VEHICLE = 4011; - // * SHIPMENT_COST_FOR_VEHICLE_INDEX_OUT_OF_BOUNDS = 4012; - // * SHIPMENT_DUPLICATE_COST_FOR_VEHICLE_INDEX = 4013; - // * VEHICLE_ERROR = 42; - // * VEHICLE_EMPTY_REQUIRED_OPERATOR_TYPE = 4200; - // * VEHICLE_DUPLICATE_REQUIRED_OPERATOR_TYPE = 4201; - // * VEHICLE_NO_OPERATOR_WITH_REQUIRED_OPERATOR_TYPE = 4202; - // * VEHICLE_EMPTY_START_TAG = 4203; - // * VEHICLE_DUPLICATE_START_TAG = 4204; - // * VEHICLE_EMPTY_END_TAG = 4205; - // * VEHICLE_DUPLICATE_END_TAG = 4206; - // * VEHICLE_EXTRA_VISIT_DURATION_NEGATIVE_OR_NAN = 4207; - // * VEHICLE_EXTRA_VISIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4208; - // * VEHICLE_EXTRA_VISIT_DURATION_EMPTY_KEY = 4209; - // * VEHICLE_FIRST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4210; - // * VEHICLE_FIRST_SHIPMENT_IGNORED = 4211; - // * VEHICLE_FIRST_SHIPMENT_NOT_BOUND = 4212; - // * VEHICLE_LAST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4213; - // * VEHICLE_LAST_SHIPMENT_IGNORED = 4214; - // * VEHICLE_LAST_SHIPMENT_NOT_BOUND = 4215; - // * VEHICLE_IGNORED_WITH_USED_IF_ROUTE_IS_EMPTY = 4216; - // * VEHICLE_INVALID_COST_PER_KILOMETER = 4217; - // * VEHICLE_INVALID_COST_PER_HOUR = 4218; - // * VEHICLE_INVALID_COST_PER_TRAVELED_HOUR = 4219; - // * VEHICLE_INVALID_FIXED_COST = 4220; - // * VEHICLE_INVALID_TRAVEL_DURATION_MULTIPLE = 4221; - // * VEHICLE_TRAVEL_DURATION_MULTIPLE_WITH_SHIPMENT_PD_DETOUR_LIMITS - // = 4223; - // * VEHICLE_MATRIX_INDEX_WITH_SHIPMENT_PD_DETOUR_LIMITS = 4224; - // * VEHICLE_MINIMUM_DURATION_LONGER_THAN_DURATION_LIMIT = 4222; - // * VISIT_REQUEST_ERROR = 44; - // * VISIT_REQUEST_EMPTY_TAG = 4400; - // * VISIT_REQUEST_DUPLICATE_TAG = 4401; - // * VISIT_REQUEST_DURATION_NEGATIVE_OR_NAN = 4404; - // * VISIT_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4405; - // * PRECEDENCE_ERROR = 46; - // * BREAK_ERROR = 48; - // * BREAK_RULE_EMPTY = 4800; - // * BREAK_REQUEST_UNSPECIFIED_DURATION = 4801; - // * BREAK_REQUEST_UNSPECIFIED_EARLIEST_START_TIME = 4802; - // * BREAK_REQUEST_UNSPECIFIED_LATEST_START_TIME = 4803; - // * BREAK_REQUEST_DURATION_NEGATIVE_OR_NAN = 4804; = 4804; - // * BREAK_REQUEST_LATEST_START_TIME_BEFORE_EARLIEST_START_TIME = 4805; - // * BREAK_REQUEST_EARLIEST_START_TIME_BEFORE_GLOBAL_START_TIME = 4806; - // * BREAK_REQUEST_LATEST_END_TIME_AFTER_GLOBAL_END_TIME = 4807; - // * BREAK_REQUEST_NON_SCHEDULABLE = 4808; - // * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_NEGATIVE_OR_NAN = 4809; - // * BREAK_FREQUENCY_MIN_BREAK_DURATION_NEGATIVE_OR_NAN = 4810; - // * BREAK_FREQUENCY_MIN_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION = 4811; - // * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION - // = 4812; - // * BREAK_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4813; - // * BREAK_FREQUENCY_MISSING_MAX_INTER_BREAK_DURATION = 4814; - // * BREAK_FREQUENCY_MISSING_MIN_BREAK_DURATION = 4815; - // * SHIPMENT_TYPE_INCOMPATIBILITY_ERROR = 50; - // * SHIPMENT_TYPE_INCOMPATIBILITY_EMPTY_TYPE = 5001; - // * SHIPMENT_TYPE_INCOMPATIBILITY_LESS_THAN_TWO_TYPES = 5002; - // * SHIPMENT_TYPE_INCOMPATIBILITY_DUPLICATE_TYPE = 5003; - // * SHIPMENT_TYPE_INCOMPATIBILITY_INVALID_INCOMPATIBILITY_MODE = 5004; - // * SHIPMENT_TYPE_INCOMPATIBILITY_TOO_MANY_INCOMPATIBILITIES = 5005; - // * SHIPMENT_TYPE_REQUIREMENT_ERROR = 52; - // * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE = 52001; - // * SHIPMENT_TYPE_REQUIREMENT_NO_DEPENDENT_TYPE = 52002; - // * SHIPMENT_TYPE_REQUIREMENT_INVALID_REQUIREMENT_MODE = 52003; - // * SHIPMENT_TYPE_REQUIREMENT_TOO_MANY_REQUIREMENTS = 52004; - // * SHIPMENT_TYPE_REQUIREMENT_EMPTY_REQUIRED_TYPE = 52005; - // * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_REQUIRED_TYPE = 52006; - // * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE_FOUND = 52007; - // * SHIPMENT_TYPE_REQUIREMENT_EMPTY_DEPENDENT_TYPE = 52008; - // * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_DEPENDENT_TYPE = 52009; - // * SHIPMENT_TYPE_REQUIREMENT_SELF_DEPENDENT_TYPE = 52010; - // * SHIPMENT_TYPE_REQUIREMENT_GRAPH_HAS_CYCLES = 52011; - // * VEHICLE_OPERATOR_ERROR = 54; - // * VEHICLE_OPERATOR_EMPTY_TYPE = 5400; - // * VEHICLE_OPERATOR_MULTIPLE_START_TIME_WINDOWS = 5401; - // * VEHICLE_OPERATOR_SOFT_START_TIME_WINDOW = 5402; - // * VEHICLE_OPERATOR_MULTIPLE_END_TIME_WINDOWS = 5403; - // * VEHICLE_OPERATOR_SOFT_END_TIME_WINDOW = 5404; - // * DURATION_SECONDS_MATRIX_ERROR = 56; - // * DURATION_SECONDS_MATRIX_DURATION_NEGATIVE_OR_NAN = 5600; - // * DURATION_SECONDS_MATRIX_DURATION_EXCEEDS_GLOBAL_DURATION = 5601; - int32 code = 1; - - // The error display name. - string display_name = 2; - - // An error context may involve 0, 1 (most of the time) or more fields. For - // example, referring to vehicle #4 and shipment #2's first pickup can be - // done as follows: - // ``` - // fields { name: "vehicles" index: 4} - // fields { name: "shipments" index: 2 sub_field {name: "pickups" index: 0} } - // ``` - // Note, however, that the cardinality of `fields` should not change for a - // given error code. - repeated FieldReference fields = 3; - - // Human-readable string describing the error. There is a 1:1 mapping - // between `code` and `error_message` (when code != "UNSPECIFIED"). - // - // *STABILITY*: Not stable: the error message associated to a given `code` may - // change (hopefully to clarify it) over time. Please rely on the - // `display_name` and `code` instead. - string error_message = 4; - - // May contain the value(s) of the field(s). This is not always available. You - // should absolutely not rely on it and use it only for manual model - // debugging. - string offending_values = 5; -} diff --git a/owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/fleet_routing.batch_optimize_tours.js b/owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/fleet_routing.batch_optimize_tours.js deleted file mode 100644 index 1570044fc50..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/fleet_routing.batch_optimize_tours.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, modelConfigs) { - // [START cloudoptimization_v1_generated_FleetRouting_BatchOptimizeTours_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Target project and location to make a call. - * Format: `projects/{project-id}/locations/{location-id}`. - * If no location is specified, a region will be chosen automatically. - */ - // const parent = 'abc123' - /** - * Required. Input/Output information each purchase model, such as file paths - * and data formats. - */ - // const modelConfigs = [1,2,3,4] - - // Imports the Optimization library - const {FleetRoutingClient} = require('@google-cloud/optimization').v1; - - // Instantiates a client - const optimizationClient = new FleetRoutingClient(); - - async function callBatchOptimizeTours() { - // Construct request - const request = { - parent, - modelConfigs, - }; - - // Run request - const [operation] = await optimizationClient.batchOptimizeTours(request); - const [response] = await operation.promise(); - console.log(response); - } - - callBatchOptimizeTours(); - // [END cloudoptimization_v1_generated_FleetRouting_BatchOptimizeTours_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/fleet_routing.optimize_tours.js b/owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/fleet_routing.optimize_tours.js deleted file mode 100644 index 0caaa8a2573..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/fleet_routing.optimize_tours.js +++ /dev/null @@ -1,254 +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 cloudoptimization_v1_generated_FleetRouting_OptimizeTours_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Target project and location to make a call. - * Format: `projects/{project-id}/locations/{location-id}`. - * If no location is specified, a region will be chosen automatically. - */ - // const parent = 'abc123' - /** - * If this timeout is set, the server returns a response before the timeout - * period has elapsed or the server deadline for synchronous requests is - * reached, whichever is sooner. - * For asynchronous requests, the server will generate a solution (if - * possible) before the timeout has elapsed. - */ - // const timeout = {} - /** - * Shipment model to solve. - */ - // const model = {} - /** - * By default, the solving mode is `DEFAULT_SOLVE` (0). - */ - // const solvingMode = {} - /** - * Truncates the number of validation errors returned. These errors are - * typically attached to an INVALID_ARGUMENT error payload as a BadRequest - * error detail (https://cloud.google.com/apis/design/errors#error_details), - * unless solving_mode=VALIDATE_ONLY: see the - * OptimizeToursResponse.validation_errors google.cloud.optimization.v1.OptimizeToursResponse.validation_errors - * field. - * This defaults to 100 and is capped at 10,000. - */ - // const maxValidationErrors = 1234 - /** - * Search mode used to solve the request. - */ - // const searchMode = {} - /** - * Guide the optimization algorithm in finding a first solution that is - * similar to a previous solution. - * The model is constrained when the first solution is built. - * Any shipments not performed on a route are implicitly skipped in the first - * solution, but they may be performed in successive solutions. - * The solution must satisfy some basic validity assumptions: - * * for all routes, `vehicle_index` must be in range and not be duplicated. - * * for all visits, `shipment_index` and `visit_request_index` must be - * in range. - * * a shipment may only be referenced on one route. - * * the pickup of a pickup-delivery shipment must be performed before - * the delivery. - * * no more than one pickup alternative or delivery alternative of - * a shipment may be performed. - * * for all routes, times are increasing (i.e., `vehicle_start_time - * <= visits0.start_time <= visits1.start_time ... - * <= vehicle_end_time`). - * * a shipment may only be performed on a vehicle that is allowed. A - * vehicle is allowed if - * Shipment.allowed_vehicle_indices google.cloud.optimization.v1.Shipment.allowed_vehicle_indices - * is empty or its `vehicle_index` is included in - * Shipment.allowed_vehicle_indices google.cloud.optimization.v1.Shipment.allowed_vehicle_indices. - * If the injected solution is not feasible, a validation error is not - * necessarily returned and an error indicating infeasibility may be returned - * instead. - */ - // const injectedFirstSolutionRoutes = [1,2,3,4] - /** - * Constrain the optimization algorithm to find a final solution that is - * similar to a previous solution. For example, this may be used to freeze - * portions of routes which have already been completed or which are to be - * completed but must not be modified. - * If the injected solution is not feasible, a validation error is not - * necessarily returned and an error indicating infeasibility may be returned - * instead. - */ - // const injectedSolutionConstraint = {} - /** - * If non-empty, the given routes will be refreshed, without modifying their - * underlying sequence of visits or travel times: only other details will be - * updated. This does not solve the model. - * As of 2020/11, this only populates the polylines of non-empty routes and - * requires that `populate_polylines` is true. - * The `route_polyline` fields of the passed-in routes may be inconsistent - * with route `transitions`. - * This field must not be used together with `injected_first_solution_routes` - * or `injected_solution_constraint`. - * `Shipment.ignore` and `Vehicle.ignore` have no effect on the behavior. - * Polylines are still populated between all visits in all non-empty routes - * regardless of whether the related shipments or vehicles are ignored. - */ - // const refreshDetailsRoutes = [1,2,3,4] - /** - * If true: - * * uses - * ShipmentRoute.vehicle_label google.cloud.optimization.v1.ShipmentRoute.vehicle_label - * instead of `vehicle_index` to - * match routes in an injected solution with vehicles in the request; - * reuses the mapping of original - * ShipmentRoute.vehicle_index google.cloud.optimization.v1.ShipmentRoute.vehicle_index - * to new - * ShipmentRoute.vehicle_index google.cloud.optimization.v1.ShipmentRoute.vehicle_index - * to update - * ConstraintRelaxation.vehicle_indices google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices - * if non-empty, but the mapping must be unambiguous (i.e., multiple - * `ShipmentRoute`s must not share the same original `vehicle_index`). - * * uses - * ShipmentRoute.Visit.shipment_label google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label - * instead of `shipment_index` - * to match visits in an injected solution with shipments in the request; - * * uses - * SkippedShipment.label google.cloud.optimization.v1.SkippedShipment.label - * instead of - * SkippedShipment.index google.cloud.optimization.v1.SkippedShipment.index - * to - * match skipped shipments in the injected solution with request - * shipments. - * This interpretation applies to the `injected_first_solution_routes`, - * `injected_solution_constraint`, and `refresh_details_routes` fields. - * It can be used when shipment or vehicle indices in the request have - * changed since the solution was created, perhaps because shipments or - * vehicles have been removed from or added to the request. - * If true, labels in the following categories must appear at most once in - * their category: - * * Vehicle.label google.cloud.optimization.v1.Vehicle.label in the - * request; - * * Shipment.label google.cloud.optimization.v1.Shipment.label in the - * request; - * * ShipmentRoute.vehicle_label google.cloud.optimization.v1.ShipmentRoute.vehicle_label in the injected solution; - * * SkippedShipment.label google.cloud.optimization.v1.SkippedShipment.label and ShipmentRoute.Visit.shipment_label google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label in - * the injected solution (except pickup/delivery visit pairs, whose - * `shipment_label` must appear twice). - * If a `vehicle_label` in the injected solution does not correspond to a - * request vehicle, the corresponding route is removed from the solution - * along with its visits. If a `shipment_label` in the injected solution does - * not correspond to a request shipment, the corresponding visit is removed - * from the solution. If a - * SkippedShipment.label google.cloud.optimization.v1.SkippedShipment.label - * in the injected solution does not correspond to a request shipment, the - * `SkippedShipment` is removed from the solution. - * Removing route visits or entire routes from an injected solution may - * have an effect on the implied constraints, which may lead to change in - * solution, validation errors, or infeasibility. - * NOTE: The caller must ensure that each - * Vehicle.label google.cloud.optimization.v1.Vehicle.label (resp. - * Shipment.label google.cloud.optimization.v1.Shipment.label) uniquely - * identifies a vehicle (resp. shipment) entity used across the two relevant - * requests: the past request that produced the `OptimizeToursResponse` used - * in the injected solution and the current request that includes the injected - * solution. The uniqueness checks described above are not enough to guarantee - * this requirement. - */ - // const interpretInjectedSolutionsUsingLabels = true - /** - * Consider traffic estimation in calculating `ShipmentRoute` fields - * Transition.travel_duration google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration, - * Visit.start_time google.cloud.optimization.v1.ShipmentRoute.Visit.start_time, - * and `vehicle_end_time`; in setting the - * ShipmentRoute.has_traffic_infeasibilities google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities - * field, and in calculating the - * OptimizeToursResponse.total_cost google.cloud.optimization.v1.OptimizeToursResponse.total_cost - * field. - */ - // const considerRoadTraffic = true - /** - * If true, polylines will be populated in response `ShipmentRoute`s. - */ - // const populatePolylines = true - /** - * If true, polylines will be populated in response - * ShipmentRoute.transitions google.cloud.optimization.v1.ShipmentRoute.transitions. - * Note that in this case, the polylines will also be populated in the - * deprecated `travel_steps`. - */ - // const populateTransitionPolylines = true - /** - * If this is set, then the request can have a deadline - * (see https://grpc.io/blog/deadlines) of up to 60 minutes. - * Otherwise, the maximum deadline is only 30 minutes. - * Note that long-lived requests have a significantly larger (but still small) - * risk of interruption. - */ - // const allowLargeDeadlineDespiteInterruptionRisk = true - /** - * If true, travel distances will be computed using geodesic distances instead - * of Google Maps distances, and travel times will be computed using geodesic - * distances with a speed defined by `geodesic_meters_per_second`. - */ - // const useGeodesicDistances = true - /** - * When `use_geodesic_distances` is true, this field must be set and defines - * the speed applied to compute travel times. Its value must be at least 1.0 - * meters/seconds. - */ - // const geodesicMetersPerSecond = 1234 - /** - * Label that may be used to identify this request, reported back in the - * OptimizeToursResponse.request_label google.cloud.optimization.v1.OptimizeToursResponse.request_label. - */ - // const label = 'abc123' - - // Imports the Optimization library - const {FleetRoutingClient} = require('@google-cloud/optimization').v1; - - // Instantiates a client - const optimizationClient = new FleetRoutingClient(); - - async function callOptimizeTours() { - // Construct request - const request = { - parent, - }; - - // Run request - const response = await optimizationClient.optimizeTours(request); - console.log(response); - } - - callOptimizeTours(); - // [END cloudoptimization_v1_generated_FleetRouting_OptimizeTours_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/snippet_metadata_google.cloud.optimization.v1.json b/owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/snippet_metadata_google.cloud.optimization.v1.json deleted file mode 100644 index e31dd183275..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/samples/generated/v1/snippet_metadata_google.cloud.optimization.v1.json +++ /dev/null @@ -1,167 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-optimization", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.optimization.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "cloudoptimization_v1_generated_FleetRouting_OptimizeTours_async", - "title": "FleetRouting optimizeTours Sample", - "origin": "API_DEFINITION", - "description": " Sends an `OptimizeToursRequest` containing a `ShipmentModel` and returns an `OptimizeToursResponse` containing `ShipmentRoute`s, which are a set of routes to be performed by vehicles minimizing the overall cost. A `ShipmentModel` model consists mainly of `Shipment`s that need to be carried out and `Vehicle`s that can be used to transport the `Shipment`s. The `ShipmentRoute`s assign `Shipment`s to `Vehicle`s. More specifically, they assign a series of `Visit`s to each vehicle, where a `Visit` corresponds to a `VisitRequest`, which is a pickup or delivery for a `Shipment`. The goal is to provide an assignment of `ShipmentRoute`s to `Vehicle`s that minimizes the total cost where cost has many components defined in the `ShipmentModel`.", - "canonical": true, - "file": "fleet_routing.optimize_tours.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 246, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "OptimizeTours", - "fullName": "google.cloud.optimization.v1.FleetRouting.OptimizeTours", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "timeout", - "type": ".google.protobuf.Duration" - }, - { - "name": "model", - "type": ".google.cloud.optimization.v1.ShipmentModel" - }, - { - "name": "solving_mode", - "type": ".google.cloud.optimization.v1.OptimizeToursRequest.SolvingMode" - }, - { - "name": "max_validation_errors", - "type": "TYPE_INT32" - }, - { - "name": "search_mode", - "type": ".google.cloud.optimization.v1.OptimizeToursRequest.SearchMode" - }, - { - "name": "injected_first_solution_routes", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "injected_solution_constraint", - "type": ".google.cloud.optimization.v1.InjectedSolutionConstraint" - }, - { - "name": "refresh_details_routes", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "interpret_injected_solutions_using_labels", - "type": "TYPE_BOOL" - }, - { - "name": "consider_road_traffic", - "type": "TYPE_BOOL" - }, - { - "name": "populate_polylines", - "type": "TYPE_BOOL" - }, - { - "name": "populate_transition_polylines", - "type": "TYPE_BOOL" - }, - { - "name": "allow_large_deadline_despite_interruption_risk", - "type": "TYPE_BOOL" - }, - { - "name": "use_geodesic_distances", - "type": "TYPE_BOOL" - }, - { - "name": "geodesic_meters_per_second", - "type": "TYPE_DOUBLE" - }, - { - "name": "label", - "type": "TYPE_STRING" - }, - { - "name": "populate_travel_step_polylines", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.optimization.v1.OptimizeToursResponse", - "client": { - "shortName": "FleetRoutingClient", - "fullName": "google.cloud.optimization.v1.FleetRoutingClient" - }, - "method": { - "shortName": "OptimizeTours", - "fullName": "google.cloud.optimization.v1.FleetRouting.OptimizeTours", - "service": { - "shortName": "FleetRouting", - "fullName": "google.cloud.optimization.v1.FleetRouting" - } - } - } - }, - { - "regionTag": "cloudoptimization_v1_generated_FleetRouting_BatchOptimizeTours_async", - "title": "FleetRouting batchOptimizeTours Sample", - "origin": "API_DEFINITION", - "description": " Optimizes vehicle tours for one or more `OptimizeToursRequest` messages as a batch. This method is a Long Running Operation (LRO). The inputs for optimization (`OptimizeToursRequest` messages) and outputs (`OptimizeToursResponse` messages) are read/written from/to Cloud Storage in user-specified format. Like the `OptimizeTours` method, each `OptimizeToursRequest` contains a `ShipmentModel` and returns an `OptimizeToursResponse` containing `ShipmentRoute`s, which are a set of routes to be performed by vehicles minimizing the overall cost.", - "canonical": true, - "file": "fleet_routing.batch_optimize_tours.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchOptimizeTours", - "fullName": "google.cloud.optimization.v1.FleetRouting.BatchOptimizeTours", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "model_configs", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "FleetRoutingClient", - "fullName": "google.cloud.optimization.v1.FleetRoutingClient" - }, - "method": { - "shortName": "BatchOptimizeTours", - "fullName": "google.cloud.optimization.v1.FleetRouting.BatchOptimizeTours", - "service": { - "shortName": "FleetRouting", - "fullName": "google.cloud.optimization.v1.FleetRouting" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-optimization/v1/src/index.ts b/owl-bot-staging/google-cloud-optimization/v1/src/index.ts deleted file mode 100644 index 377737cae6b..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/src/index.ts +++ /dev/null @@ -1,25 +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 v1 from './v1'; -const FleetRoutingClient = v1.FleetRoutingClient; -type FleetRoutingClient = v1.FleetRoutingClient; -export {v1, FleetRoutingClient}; -export default {v1, FleetRoutingClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_client.ts b/owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_client.ts deleted file mode 100644 index 5a41957cc75..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_client.ts +++ /dev/null @@ -1,901 +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} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/fleet_routing_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './fleet_routing_client_config.json'; -const version = require('../../../package.json').version; - -/** - * A service for optimizing vehicle tours. - * - * Validity of certain types of fields: - * - * * `google.protobuf.Timestamp` - * * Times are in Unix time: seconds since 1970-01-01T00:00:00+00:00. - * * seconds must be in [0, 253402300799], - * i.e. in [1970-01-01T00:00:00+00:00, 9999-12-31T23:59:59+00:00]. - * * nanos must be unset or set to 0. - * * `google.protobuf.Duration` - * * seconds must be in [0, 253402300799], - * i.e. in [1970-01-01T00:00:00+00:00, 9999-12-31T23:59:59+00:00]. - * * nanos must be unset or set to 0. - * * `google.type.LatLng` - * * latitude must be in [-90.0, 90.0]. - * * longitude must be in [-180.0, 180.0]. - * * at least one of latitude and longitude must be non-zero. - * @class - * @memberof v1 - */ -export class FleetRoutingClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - operationsClient: gax.OperationsClient; - fleetRoutingStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of FleetRoutingClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 FleetRoutingClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof FleetRoutingClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const batchOptimizeToursResponse = protoFilesRoot.lookup( - '.google.cloud.optimization.v1.BatchOptimizeToursResponse') as gax.protobuf.Type; - const batchOptimizeToursMetadata = protoFilesRoot.lookup( - '.google.cloud.optimization.v1.AsyncModelMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - batchOptimizeTours: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - batchOptimizeToursResponse.decode.bind(batchOptimizeToursResponse), - batchOptimizeToursMetadata.decode.bind(batchOptimizeToursMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.optimization.v1.FleetRouting', 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.fleetRoutingStub) { - return this.fleetRoutingStub; - } - - // Put together the "service stub" for - // google.cloud.optimization.v1.FleetRouting. - this.fleetRoutingStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.optimization.v1.FleetRouting') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.optimization.v1.FleetRouting, - 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 fleetRoutingStubMethods = - ['optimizeTours', 'batchOptimizeTours']; - for (const methodName of fleetRoutingStubMethods) { - const callPromise = this.fleetRoutingStub.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.fleetRoutingStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudoptimization.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 'cloudoptimization.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 -- - // ------------------- -/** - * Sends an `OptimizeToursRequest` containing a `ShipmentModel` and returns an - * `OptimizeToursResponse` containing `ShipmentRoute`s, which are a set of - * routes to be performed by vehicles minimizing the overall cost. - * - * A `ShipmentModel` model consists mainly of `Shipment`s that need to be - * carried out and `Vehicle`s that can be used to transport the `Shipment`s. - * The `ShipmentRoute`s assign `Shipment`s to `Vehicle`s. More specifically, - * they assign a series of `Visit`s to each vehicle, where a `Visit` - * corresponds to a `VisitRequest`, which is a pickup or delivery for a - * `Shipment`. - * - * The goal is to provide an assignment of `ShipmentRoute`s to `Vehicle`s that - * minimizes the total cost where cost has many components defined in the - * `ShipmentModel`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Target project and location to make a call. - * - * Format: `projects/{project-id}/locations/{location-id}`. - * - * If no location is specified, a region will be chosen automatically. - * @param {google.protobuf.Duration} request.timeout - * If this timeout is set, the server returns a response before the timeout - * period has elapsed or the server deadline for synchronous requests is - * reached, whichever is sooner. - * - * For asynchronous requests, the server will generate a solution (if - * possible) before the timeout has elapsed. - * @param {google.cloud.optimization.v1.ShipmentModel} request.model - * Shipment model to solve. - * @param {google.cloud.optimization.v1.OptimizeToursRequest.SolvingMode} request.solvingMode - * By default, the solving mode is `DEFAULT_SOLVE` (0). - * @param {number} request.maxValidationErrors - * Truncates the number of validation errors returned. These errors are - * typically attached to an INVALID_ARGUMENT error payload as a BadRequest - * error detail (https://cloud.google.com/apis/design/errors#error_details), - * unless solving_mode=VALIDATE_ONLY: see the - * {@link protos.google.cloud.optimization.v1.OptimizeToursResponse.validation_errors|OptimizeToursResponse.validation_errors} - * field. - * This defaults to 100 and is capped at 10,000. - * @param {google.cloud.optimization.v1.OptimizeToursRequest.SearchMode} request.searchMode - * Search mode used to solve the request. - * @param {number[]} request.injectedFirstSolutionRoutes - * Guide the optimization algorithm in finding a first solution that is - * similar to a previous solution. - * - * The model is constrained when the first solution is built. - * Any shipments not performed on a route are implicitly skipped in the first - * solution, but they may be performed in successive solutions. - * - * The solution must satisfy some basic validity assumptions: - * - * * for all routes, `vehicle_index` must be in range and not be duplicated. - * * for all visits, `shipment_index` and `visit_request_index` must be - * in range. - * * a shipment may only be referenced on one route. - * * the pickup of a pickup-delivery shipment must be performed before - * the delivery. - * * no more than one pickup alternative or delivery alternative of - * a shipment may be performed. - * * for all routes, times are increasing (i.e., `vehicle_start_time - * <= visits[0].start_time <= visits[1].start_time ... - * <= vehicle_end_time`). - * * a shipment may only be performed on a vehicle that is allowed. A - * vehicle is allowed if - * {@link protos.google.cloud.optimization.v1.Shipment.allowed_vehicle_indices|Shipment.allowed_vehicle_indices} - * is empty or its `vehicle_index` is included in - * {@link protos.google.cloud.optimization.v1.Shipment.allowed_vehicle_indices|Shipment.allowed_vehicle_indices}. - * - * If the injected solution is not feasible, a validation error is not - * necessarily returned and an error indicating infeasibility may be returned - * instead. - * @param {google.cloud.optimization.v1.InjectedSolutionConstraint} request.injectedSolutionConstraint - * Constrain the optimization algorithm to find a final solution that is - * similar to a previous solution. For example, this may be used to freeze - * portions of routes which have already been completed or which are to be - * completed but must not be modified. - * - * If the injected solution is not feasible, a validation error is not - * necessarily returned and an error indicating infeasibility may be returned - * instead. - * @param {number[]} request.refreshDetailsRoutes - * If non-empty, the given routes will be refreshed, without modifying their - * underlying sequence of visits or travel times: only other details will be - * updated. This does not solve the model. - * - * As of 2020/11, this only populates the polylines of non-empty routes and - * requires that `populate_polylines` is true. - * - * The `route_polyline` fields of the passed-in routes may be inconsistent - * with route `transitions`. - * - * This field must not be used together with `injected_first_solution_routes` - * or `injected_solution_constraint`. - * - * `Shipment.ignore` and `Vehicle.ignore` have no effect on the behavior. - * Polylines are still populated between all visits in all non-empty routes - * regardless of whether the related shipments or vehicles are ignored. - * @param {boolean} request.interpretInjectedSolutionsUsingLabels - * If true: - * - * * uses - * {@link protos.google.cloud.optimization.v1.ShipmentRoute.vehicle_label|ShipmentRoute.vehicle_label} - * instead of `vehicle_index` to - * match routes in an injected solution with vehicles in the request; - * reuses the mapping of original - * {@link protos.google.cloud.optimization.v1.ShipmentRoute.vehicle_index|ShipmentRoute.vehicle_index} - * to new - * {@link protos.google.cloud.optimization.v1.ShipmentRoute.vehicle_index|ShipmentRoute.vehicle_index} - * to update - * {@link protos.google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices|ConstraintRelaxation.vehicle_indices} - * if non-empty, but the mapping must be unambiguous (i.e., multiple - * `ShipmentRoute`s must not share the same original `vehicle_index`). - * * uses - * {@link protos.google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label|ShipmentRoute.Visit.shipment_label} - * instead of `shipment_index` - * to match visits in an injected solution with shipments in the request; - * * uses - * {@link protos.google.cloud.optimization.v1.SkippedShipment.label|SkippedShipment.label} - * instead of - * {@link protos.google.cloud.optimization.v1.SkippedShipment.index|SkippedShipment.index} - * to - * match skipped shipments in the injected solution with request - * shipments. - * - * This interpretation applies to the `injected_first_solution_routes`, - * `injected_solution_constraint`, and `refresh_details_routes` fields. - * It can be used when shipment or vehicle indices in the request have - * changed since the solution was created, perhaps because shipments or - * vehicles have been removed from or added to the request. - * - * If true, labels in the following categories must appear at most once in - * their category: - * - * * {@link protos.google.cloud.optimization.v1.Vehicle.label|Vehicle.label} in the - * request; - * * {@link protos.google.cloud.optimization.v1.Shipment.label|Shipment.label} in the - * request; - * * {@link protos.google.cloud.optimization.v1.ShipmentRoute.vehicle_label|ShipmentRoute.vehicle_label} in the injected solution; - * * {@link protos.google.cloud.optimization.v1.SkippedShipment.label|SkippedShipment.label} and {@link protos.google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label|ShipmentRoute.Visit.shipment_label} in - * the injected solution (except pickup/delivery visit pairs, whose - * `shipment_label` must appear twice). - * - * If a `vehicle_label` in the injected solution does not correspond to a - * request vehicle, the corresponding route is removed from the solution - * along with its visits. If a `shipment_label` in the injected solution does - * not correspond to a request shipment, the corresponding visit is removed - * from the solution. If a - * {@link protos.google.cloud.optimization.v1.SkippedShipment.label|SkippedShipment.label} - * in the injected solution does not correspond to a request shipment, the - * `SkippedShipment` is removed from the solution. - * - * Removing route visits or entire routes from an injected solution may - * have an effect on the implied constraints, which may lead to change in - * solution, validation errors, or infeasibility. - * - * NOTE: The caller must ensure that each - * {@link protos.google.cloud.optimization.v1.Vehicle.label|Vehicle.label} (resp. - * {@link protos.google.cloud.optimization.v1.Shipment.label|Shipment.label}) uniquely - * identifies a vehicle (resp. shipment) entity used across the two relevant - * requests: the past request that produced the `OptimizeToursResponse` used - * in the injected solution and the current request that includes the injected - * solution. The uniqueness checks described above are not enough to guarantee - * this requirement. - * @param {boolean} request.considerRoadTraffic - * Consider traffic estimation in calculating `ShipmentRoute` fields - * {@link protos.google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration|Transition.travel_duration}, - * {@link protos.google.cloud.optimization.v1.ShipmentRoute.Visit.start_time|Visit.start_time}, - * and `vehicle_end_time`; in setting the - * {@link protos.google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities|ShipmentRoute.has_traffic_infeasibilities} - * field, and in calculating the - * {@link protos.google.cloud.optimization.v1.OptimizeToursResponse.total_cost|OptimizeToursResponse.total_cost} - * field. - * @param {boolean} request.populatePolylines - * If true, polylines will be populated in response `ShipmentRoute`s. - * @param {boolean} request.populateTransitionPolylines - * If true, polylines will be populated in response - * {@link protos.google.cloud.optimization.v1.ShipmentRoute.transitions|ShipmentRoute.transitions}. - * Note that in this case, the polylines will also be populated in the - * deprecated `travel_steps`. - * @param {boolean} request.allowLargeDeadlineDespiteInterruptionRisk - * If this is set, then the request can have a deadline - * (see https://grpc.io/blog/deadlines) of up to 60 minutes. - * Otherwise, the maximum deadline is only 30 minutes. - * Note that long-lived requests have a significantly larger (but still small) - * risk of interruption. - * @param {boolean} request.useGeodesicDistances - * If true, travel distances will be computed using geodesic distances instead - * of Google Maps distances, and travel times will be computed using geodesic - * distances with a speed defined by `geodesic_meters_per_second`. - * @param {number} request.geodesicMetersPerSecond - * When `use_geodesic_distances` is true, this field must be set and defines - * the speed applied to compute travel times. Its value must be at least 1.0 - * meters/seconds. - * @param {string} request.label - * Label that may be used to identify this request, reported back in the - * {@link protos.google.cloud.optimization.v1.OptimizeToursResponse.request_label|OptimizeToursResponse.request_label}. - * @param {boolean} request.populateTravelStepPolylines - * Deprecated: Use - * {@link protos.google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines|OptimizeToursRequest.populate_transition_polylines} - * instead. If true, polylines will be populated in response - * {@link protos.google.cloud.optimization.v1.ShipmentRoute.transitions|ShipmentRoute.transitions}. - * Note that in this case, the polylines will also be populated in the - * deprecated `travel_steps`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.optimization.v1.OptimizeToursResponse|OptimizeToursResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/fleet_routing.optimize_tours.js - * region_tag:cloudoptimization_v1_generated_FleetRouting_OptimizeTours_async - */ - optimizeTours( - request?: protos.google.cloud.optimization.v1.IOptimizeToursRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.optimization.v1.IOptimizeToursResponse, - protos.google.cloud.optimization.v1.IOptimizeToursRequest|undefined, {}|undefined - ]>; - optimizeTours( - request: protos.google.cloud.optimization.v1.IOptimizeToursRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.optimization.v1.IOptimizeToursResponse, - protos.google.cloud.optimization.v1.IOptimizeToursRequest|null|undefined, - {}|null|undefined>): void; - optimizeTours( - request: protos.google.cloud.optimization.v1.IOptimizeToursRequest, - callback: Callback< - protos.google.cloud.optimization.v1.IOptimizeToursResponse, - protos.google.cloud.optimization.v1.IOptimizeToursRequest|null|undefined, - {}|null|undefined>): void; - optimizeTours( - request?: protos.google.cloud.optimization.v1.IOptimizeToursRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.optimization.v1.IOptimizeToursResponse, - protos.google.cloud.optimization.v1.IOptimizeToursRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.optimization.v1.IOptimizeToursResponse, - protos.google.cloud.optimization.v1.IOptimizeToursRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.optimization.v1.IOptimizeToursResponse, - protos.google.cloud.optimization.v1.IOptimizeToursRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.optimizeTours(request, options, callback); - } - -/** - * Optimizes vehicle tours for one or more `OptimizeToursRequest` - * messages as a batch. - * - * This method is a Long Running Operation (LRO). The inputs for optimization - * (`OptimizeToursRequest` messages) and outputs (`OptimizeToursResponse` - * messages) are read/written from/to Cloud Storage in user-specified - * format. Like the `OptimizeTours` method, each `OptimizeToursRequest` - * contains a `ShipmentModel` and returns an `OptimizeToursResponse` - * containing `ShipmentRoute`s, which are a set of routes to be performed by - * vehicles minimizing the overall cost. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Target project and location to make a call. - * - * Format: `projects/{project-id}/locations/{location-id}`. - * - * If no location is specified, a region will be chosen automatically. - * @param {number[]} request.modelConfigs - * Required. Input/Output information each purchase model, such as file paths - * and data formats. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/fleet_routing.batch_optimize_tours.js - * region_tag:cloudoptimization_v1_generated_FleetRouting_BatchOptimizeTours_async - */ - batchOptimizeTours( - request?: protos.google.cloud.optimization.v1.IBatchOptimizeToursRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - batchOptimizeTours( - request: protos.google.cloud.optimization.v1.IBatchOptimizeToursRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - batchOptimizeTours( - request: protos.google.cloud.optimization.v1.IBatchOptimizeToursRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - batchOptimizeTours( - request?: protos.google.cloud.optimization.v1.IBatchOptimizeToursRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.batchOptimizeTours(request, options, callback); - } -/** - * Check the status of the long running operation returned by `batchOptimizeTours()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/fleet_routing.batch_optimize_tours.js - * region_tag:cloudoptimization_v1_generated_FleetRouting_BatchOptimizeTours_async - */ - async checkBatchOptimizeToursProgress(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.batchOptimizeTours, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * 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); - } - - - /** - * 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.fleetRoutingStub && !this._terminated) { - return this.fleetRoutingStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_client_config.json b/owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_client_config.json deleted file mode 100644 index 5ab463afe2f..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_client_config.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "interfaces": { - "google.cloud.optimization.v1.FleetRouting": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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 - }, - "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "OptimizeTours": { - "timeout_millis": 3600000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "BatchOptimizeTours": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_proto_list.json b/owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_proto_list.json deleted file mode 100644 index 0c22e3cf34b..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/src/v1/fleet_routing_proto_list.json +++ /dev/null @@ -1,4 +0,0 @@ -[ - "../../protos/google/cloud/optimization/v1/async_model.proto", - "../../protos/google/cloud/optimization/v1/fleet_routing.proto" -] diff --git a/owl-bot-staging/google-cloud-optimization/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-optimization/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 85ace5d715c..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.optimization.v1", - "libraryPackage": "@google-cloud/optimization", - "services": { - "FleetRouting": { - "clients": { - "grpc": { - "libraryClient": "FleetRoutingClient", - "rpcs": { - "OptimizeTours": { - "methods": [ - "optimizeTours" - ] - }, - "BatchOptimizeTours": { - "methods": [ - "batchOptimizeTours" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "FleetRoutingClient", - "rpcs": { - "OptimizeTours": { - "methods": [ - "optimizeTours" - ] - }, - "BatchOptimizeTours": { - "methods": [ - "batchOptimizeTours" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-optimization/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-optimization/v1/src/v1/index.ts deleted file mode 100644 index 01c3381e53a..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +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 {FleetRoutingClient} from './fleet_routing_client'; diff --git a/owl-bot-staging/google-cloud-optimization/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-optimization/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 63874cd148e..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const optimization = require('@google-cloud/optimization'); - -function main() { - const fleetRoutingClient = new optimization.FleetRoutingClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-optimization/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-optimization/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index df036f012d4..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {FleetRoutingClient} from '@google-cloud/optimization'; - -// check that the client class type name can be used -function doStuffWithFleetRoutingClient(client: FleetRoutingClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const fleetRoutingClient = new FleetRoutingClient(); - doStuffWithFleetRoutingClient(fleetRoutingClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-optimization/v1/system-test/install.ts b/owl-bot-staging/google-cloud-optimization/v1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/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-optimization/v1/test/gapic_fleet_routing_v1.ts b/owl-bot-staging/google-cloud-optimization/v1/test/gapic_fleet_routing_v1.ts deleted file mode 100644 index cd0b1e4e588..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/test/gapic_fleet_routing_v1.ts +++ /dev/null @@ -1,703 +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 fleetroutingModule from '../src'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.FleetRoutingClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = fleetroutingModule.v1.FleetRoutingClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = fleetroutingModule.v1.FleetRoutingClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = fleetroutingModule.v1.FleetRoutingClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new fleetroutingModule.v1.FleetRoutingClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new fleetroutingModule.v1.FleetRoutingClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new fleetroutingModule.v1.FleetRoutingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.fleetRoutingStub, undefined); - await client.initialize(); - assert(client.fleetRoutingStub); - }); - - it('has close method for the initialized client', done => { - const client = new fleetroutingModule.v1.FleetRoutingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.fleetRoutingStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new fleetroutingModule.v1.FleetRoutingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.fleetRoutingStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new fleetroutingModule.v1.FleetRoutingClient({ - 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 fleetroutingModule.v1.FleetRoutingClient({ - 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('optimizeTours', () => { - it('invokes optimizeTours without error', async () => { - const client = new fleetroutingModule.v1.FleetRoutingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.optimization.v1.OptimizeToursRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.optimization.v1.OptimizeToursRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.optimization.v1.OptimizeToursResponse() - ); - client.innerApiCalls.optimizeTours = stubSimpleCall(expectedResponse); - const [response] = await client.optimizeTours(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.optimizeTours as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.optimizeTours as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes optimizeTours without error using callback', async () => { - const client = new fleetroutingModule.v1.FleetRoutingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.optimization.v1.OptimizeToursRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.optimization.v1.OptimizeToursRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.optimization.v1.OptimizeToursResponse() - ); - client.innerApiCalls.optimizeTours = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.optimizeTours( - request, - (err?: Error|null, result?: protos.google.cloud.optimization.v1.IOptimizeToursResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.optimizeTours as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.optimizeTours as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes optimizeTours with error', async () => { - const client = new fleetroutingModule.v1.FleetRoutingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.optimization.v1.OptimizeToursRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.optimization.v1.OptimizeToursRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.optimizeTours = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.optimizeTours(request), expectedError); - const actualRequest = (client.innerApiCalls.optimizeTours as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.optimizeTours as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes optimizeTours with closed client', async () => { - const client = new fleetroutingModule.v1.FleetRoutingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.optimization.v1.OptimizeToursRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.optimization.v1.OptimizeToursRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.optimizeTours(request), expectedError); - }); - }); - - describe('batchOptimizeTours', () => { - it('invokes batchOptimizeTours without error', async () => { - const client = new fleetroutingModule.v1.FleetRoutingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.optimization.v1.BatchOptimizeToursRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.optimization.v1.BatchOptimizeToursRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.batchOptimizeTours = stubLongRunningCall(expectedResponse); - const [operation] = await client.batchOptimizeTours(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchOptimizeTours as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchOptimizeTours as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchOptimizeTours without error using callback', async () => { - const client = new fleetroutingModule.v1.FleetRoutingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.optimization.v1.BatchOptimizeToursRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.optimization.v1.BatchOptimizeToursRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.batchOptimizeTours = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchOptimizeTours( - request, - (err?: Error|null, - result?: 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.batchOptimizeTours as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchOptimizeTours as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchOptimizeTours with call error', async () => { - const client = new fleetroutingModule.v1.FleetRoutingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.optimization.v1.BatchOptimizeToursRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.optimization.v1.BatchOptimizeToursRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchOptimizeTours = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.batchOptimizeTours(request), expectedError); - const actualRequest = (client.innerApiCalls.batchOptimizeTours as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchOptimizeTours as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchOptimizeTours with LRO error', async () => { - const client = new fleetroutingModule.v1.FleetRoutingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.optimization.v1.BatchOptimizeToursRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.optimization.v1.BatchOptimizeToursRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchOptimizeTours = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.batchOptimizeTours(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.batchOptimizeTours as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchOptimizeTours as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkBatchOptimizeToursProgress without error', async () => { - const client = new fleetroutingModule.v1.FleetRoutingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkBatchOptimizeToursProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkBatchOptimizeToursProgress with error', async () => { - const client = new fleetroutingModule.v1.FleetRoutingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkBatchOptimizeToursProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new fleetroutingModule.v1.FleetRoutingClient({ - 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 fleetroutingModule.v1.FleetRoutingClient({ - 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 fleetroutingModule.v1.FleetRoutingClient({ - 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 fleetroutingModule.v1.FleetRoutingClient({ - 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 fleetroutingModule.v1.FleetRoutingClient({ - 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 fleetroutingModule.v1.FleetRoutingClient({ - 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 fleetroutingModule.v1.FleetRoutingClient({ - 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 fleetroutingModule.v1.FleetRoutingClient({ - 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 fleetroutingModule.v1.FleetRoutingClient({ - 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 fleetroutingModule.v1.FleetRoutingClient({ - 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 fleetroutingModule.v1.FleetRoutingClient({ - 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); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-optimization/v1/tsconfig.json b/owl-bot-staging/google-cloud-optimization/v1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-optimization/v1/webpack.config.js b/owl-bot-staging/google-cloud-optimization/v1/webpack.config.js deleted file mode 100644 index 28740a021c3..00000000000 --- a/owl-bot-staging/google-cloud-optimization/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'FleetRouting', - filename: './fleet-routing.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-orchestration-airflow-service/v1/.eslintignore b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.eslintrc.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.gitignore b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.jsdoc.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.jsdoc.js deleted file mode 100644 index 1eacba42fba..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.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/orchestration-airflow', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.mocharc.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.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-orchestration-airflow-service/v1/.prettierrc.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/.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-orchestration-airflow-service/v1/README.md b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/README.md deleted file mode 100644 index 536af38a9bb..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Service: Nodejs Client diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/package.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/package.json deleted file mode 100644 index 42943d9c4a6..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/package.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "name": "@google-cloud/orchestration-airflow", - "version": "0.1.0", - "description": "Service client for Node.js", - "repository": "googleapis/nodejs-service", - "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 service", - "service", - "environments", - "image versions" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/environments.proto b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/environments.proto deleted file mode 100644 index e83af80a94a..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/environments.proto +++ /dev/null @@ -1,1392 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.orchestration.airflow.service.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/orchestration/airflow/service/v1/operations.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "cloud.google.com/go/orchestration/airflow/service/apiv1/servicepb;servicepb"; -option java_multiple_files = true; -option java_package = "com.google.cloud.orchestration.airflow.service.v1"; - -// Managed Apache Airflow Environments. -service Environments { - option (google.api.default_host) = "composer.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Create a new environment. - rpc CreateEnvironment(CreateEnvironmentRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/environments" - body: "environment" - }; - option (google.api.method_signature) = "parent,environment"; - option (google.longrunning.operation_info) = { - response_type: "Environment" - metadata_type: "google.cloud.orchestration.airflow.service.v1.OperationMetadata" - }; - } - - // Get an existing environment. - rpc GetEnvironment(GetEnvironmentRequest) returns (Environment) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/environments/*}" - }; - option (google.api.method_signature) = "name"; - } - - // List environments. - rpc ListEnvironments(ListEnvironmentsRequest) - returns (ListEnvironmentsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/environments" - }; - option (google.api.method_signature) = "parent"; - } - - // Update an environment. - rpc UpdateEnvironment(UpdateEnvironmentRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1/{name=projects/*/locations/*/environments/*}" - body: "environment" - }; - option (google.api.method_signature) = "name,environment,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "Environment" - metadata_type: "google.cloud.orchestration.airflow.service.v1.OperationMetadata" - }; - } - - // Delete an environment. - rpc DeleteEnvironment(DeleteEnvironmentRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/environments/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "google.cloud.orchestration.airflow.service.v1.OperationMetadata" - }; - } - - // Executes Airflow CLI command. - rpc ExecuteAirflowCommand(ExecuteAirflowCommandRequest) - returns (ExecuteAirflowCommandResponse) { - option (google.api.http) = { - post: "/v1/{environment=projects/*/locations/*/environments/*}:executeAirflowCommand" - body: "*" - }; - } - - // Stops Airflow CLI command execution. - rpc StopAirflowCommand(StopAirflowCommandRequest) - returns (StopAirflowCommandResponse) { - option (google.api.http) = { - post: "/v1/{environment=projects/*/locations/*/environments/*}:stopAirflowCommand" - body: "*" - }; - } - - // Polls Airflow CLI command execution and fetches logs. - rpc PollAirflowCommand(PollAirflowCommandRequest) - returns (PollAirflowCommandResponse) { - option (google.api.http) = { - post: "/v1/{environment=projects/*/locations/*/environments/*}:pollAirflowCommand" - body: "*" - }; - } - - // Creates a snapshots of a Cloud Composer environment. - // - // As a result of this operation, snapshot of environment's state is stored - // in a location specified in the SaveSnapshotRequest. - rpc SaveSnapshot(SaveSnapshotRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{environment=projects/*/locations/*/environments/*}:saveSnapshot" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.orchestration.airflow.service.v1.SaveSnapshotResponse" - metadata_type: "google.cloud.orchestration.airflow.service.v1.OperationMetadata" - }; - } - - // Loads a snapshot of a Cloud Composer environment. - // - // As a result of this operation, a snapshot of environment's specified in - // LoadSnapshotRequest is loaded into the environment. - rpc LoadSnapshot(LoadSnapshotRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{environment=projects/*/locations/*/environments/*}:loadSnapshot" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.orchestration.airflow.service.v1.LoadSnapshotResponse" - metadata_type: "google.cloud.orchestration.airflow.service.v1.OperationMetadata" - }; - } - - // Triggers database failover (only for highly resilient environments). - rpc DatabaseFailover(DatabaseFailoverRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{environment=projects/*/locations/*/environments/*}:databaseFailover" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.orchestration.airflow.service.v1.DatabaseFailoverResponse" - metadata_type: "google.cloud.orchestration.airflow.service.v1.OperationMetadata" - }; - } - - // Fetches database properties. - rpc FetchDatabaseProperties(FetchDatabasePropertiesRequest) - returns (FetchDatabasePropertiesResponse) { - option (google.api.http) = { - get: "/v1/{environment=projects/*/locations/*/environments/*}:fetchDatabaseProperties" - }; - } -} - -// Create a new environment. -message CreateEnvironmentRequest { - // The parent must be of the form - // "projects/{projectId}/locations/{locationId}". - string parent = 1; - - // The environment to create. - Environment environment = 2; -} - -// Get an environment. -message GetEnvironmentRequest { - // The resource name of the environment to get, in the form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - string name = 1; -} - -// List environments in a project and location. -message ListEnvironmentsRequest { - // List environments in the given project and location, in the form: - // "projects/{projectId}/locations/{locationId}" - string parent = 1; - - // The maximum number of environments to return. - int32 page_size = 2; - - // The next_page_token value returned from a previous List request, if any. - string page_token = 3; -} - -// The environments in a project and location. -message ListEnvironmentsResponse { - // The list of environments returned by a ListEnvironmentsRequest. - repeated Environment environments = 1; - - // The page token used to query for the next page if one exists. - string next_page_token = 2; -} - -// Delete an environment. -message DeleteEnvironmentRequest { - // The environment to delete, in the form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - string name = 1; -} - -// Update an environment. -message UpdateEnvironmentRequest { - // The relative resource name of the environment to update, in the form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - string name = 2; - - // A patch environment. Fields specified by the `updateMask` will be copied - // from the patch environment into the environment under update. - Environment environment = 1; - - // Required. A comma-separated list of paths, relative to `Environment`, of - // fields to update. - // For example, to set the version of scikit-learn to install in the - // environment to 0.19.0 and to remove an existing installation of - // numpy, the `updateMask` parameter would include the following two - // `paths` values: "config.softwareConfig.pypiPackages.scikit-learn" and - // "config.softwareConfig.pypiPackages.numpy". The included patch - // environment would specify the scikit-learn version as follows: - // - // { - // "config":{ - // "softwareConfig":{ - // "pypiPackages":{ - // "scikit-learn":"==0.19.0" - // } - // } - // } - // } - // - // Note that in the above example, any existing PyPI packages - // other than scikit-learn and numpy will be unaffected. - // - // Only one update type may be included in a single request's `updateMask`. - // For example, one cannot update both the PyPI packages and - // labels in the same request. However, it is possible to update multiple - // members of a map field simultaneously in the same request. For example, - // to set the labels "label1" and "label2" while clearing "label3" (assuming - // it already exists), one can - // provide the paths "labels.label1", "labels.label2", and "labels.label3" - // and populate the patch environment as follows: - // - // { - // "labels":{ - // "label1":"new-label1-value" - // "label2":"new-label2-value" - // } - // } - // - // Note that in the above example, any existing labels that are not - // included in the `updateMask` will be unaffected. - // - // It is also possible to replace an entire map field by providing the - // map field's path in the `updateMask`. The new value of the field will - // be that which is provided in the patch environment. For example, to - // delete all pre-existing user-specified PyPI packages and - // install botocore at version 1.7.14, the `updateMask` would contain - // the path "config.softwareConfig.pypiPackages", and - // the patch environment would be the following: - // - // { - // "config":{ - // "softwareConfig":{ - // "pypiPackages":{ - // "botocore":"==1.7.14" - // } - // } - // } - // } - // - // **Note:** Only the following fields can be updated: - // - // * `config.softwareConfig.pypiPackages` - // * Replace all custom custom PyPI packages. If a replacement - // package map is not included in `environment`, all custom - // PyPI packages are cleared. It is an error to provide both - // this mask and a mask specifying an individual package. - // * `config.softwareConfig.pypiPackages.`packagename - // * Update the custom PyPI package *packagename*, - // preserving other packages. To delete the package, include it in - // `updateMask`, and omit the mapping for it in - // `environment.config.softwareConfig.pypiPackages`. It is an error - // to provide both a mask of this form and the - // `config.softwareConfig.pypiPackages` mask. - // * `labels` - // * Replace all environment labels. If a replacement labels map is not - // included in `environment`, all labels are cleared. It is an error to - // provide both this mask and a mask specifying one or more individual - // labels. - // * `labels.`labelName - // * Set the label named *labelName*, while preserving other - // labels. To delete the label, include it in `updateMask` and omit its - // mapping in `environment.labels`. It is an error to provide both a - // mask of this form and the `labels` mask. - // * `config.nodeCount` - // * Horizontally scale the number of nodes in the environment. An integer - // greater than or equal to 3 must be provided in the `config.nodeCount` - // field. Supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - // * `config.webServerNetworkAccessControl` - // * Replace the environment's current `WebServerNetworkAccessControl`. - // * `config.softwareConfig.airflowConfigOverrides` - // * Replace all Apache Airflow config overrides. If a replacement config - // overrides map is not included in `environment`, all config overrides - // are cleared. - // It is an error to provide both this mask and a mask specifying one or - // more individual config overrides. - // * `config.softwareConfig.airflowConfigOverrides.`section-name - // * Override the Apache Airflow config property *name* in the - // section named *section*, preserving other properties. To - // delete the property override, include it in `updateMask` and omit its - // mapping in - // `environment.config.softwareConfig.airflowConfigOverrides`. - // It is an error to provide both a mask of this form and the - // `config.softwareConfig.airflowConfigOverrides` mask. - // * `config.softwareConfig.envVariables` - // * Replace all environment variables. If a replacement environment - // variable map is not included in `environment`, all custom environment - // variables are cleared. - // * `config.softwareConfig.schedulerCount` - // * Horizontally scale the number of schedulers in Airflow. A positive - // integer not greater than the number of nodes must be provided in the - // `config.softwareConfig.schedulerCount` field. Supported for Cloud - // Composer environments in versions composer-1.*.*-airflow-2.*.*. - // * `config.databaseConfig.machineType` - // * Cloud SQL machine type used by Airflow database. - // It has to be one of: db-n1-standard-2, db-n1-standard-4, - // db-n1-standard-8 or db-n1-standard-16. Supported for Cloud Composer - // environments in versions composer-1.*.*-airflow-*.*.*. - // * `config.webServerConfig.machineType` - // * Machine type on which Airflow web server is running. - // It has to be one of: composer-n1-webserver-2, composer-n1-webserver-4 - // or composer-n1-webserver-8. Supported for Cloud Composer environments - // in versions composer-1.*.*-airflow-*.*.*. - google.protobuf.FieldMask update_mask = 3; -} - -// Execute Airflow Command request. -message ExecuteAirflowCommandRequest { - // The resource name of the environment in the form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}". - string environment = 1; - - // Airflow command. - string command = 2; - - // Airflow subcommand. - string subcommand = 3; - - // Parameters for the Airflow command/subcommand as an array of arguments. - // It may contain positional arguments like `["my-dag-id"]`, key-value - // parameters like `["--foo=bar"]` or `["--foo","bar"]`, - // or other flags like `["-f"]`. - repeated string parameters = 4; -} - -// Response to ExecuteAirflowCommandRequest. -message ExecuteAirflowCommandResponse { - // The unique ID of the command execution for polling. - string execution_id = 1; - - // The name of the pod where the command is executed. - string pod = 2; - - // The namespace of the pod where the command is executed. - string pod_namespace = 3; - - // Error message. Empty if there was no error. - string error = 4; -} - -// Stop Airflow Command request. -message StopAirflowCommandRequest { - // The resource name of the environment in the form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}". - string environment = 1; - - // The unique ID of the command execution. - string execution_id = 2; - - // The name of the pod where the command is executed. - string pod = 3; - - // The namespace of the pod where the command is executed. - string pod_namespace = 4; - - // If true, the execution is terminated forcefully (SIGKILL). If false, the - // execution is stopped gracefully, giving it time for cleanup. - bool force = 5; -} - -// Response to StopAirflowCommandRequest. -message StopAirflowCommandResponse { - // Whether the execution is still running. - bool is_done = 1; - - // Output message from stopping execution request. - repeated string output = 2; -} - -// Poll Airflow Command request. -message PollAirflowCommandRequest { - // The resource name of the environment in the form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - string environment = 1; - - // The unique ID of the command execution. - string execution_id = 2; - - // The name of the pod where the command is executed. - string pod = 3; - - // The namespace of the pod where the command is executed. - string pod_namespace = 4; - - // Line number from which new logs should be fetched. - int32 next_line_number = 5; -} - -// Response to PollAirflowCommandRequest. -message PollAirflowCommandResponse { - // Contains information about a single line from logs. - message Line { - // Number of the line. - int32 line_number = 1; - - // Text content of the log line. - string content = 2; - } - - // Information about how a command ended. - message ExitInfo { - // The exit code from the command execution. - int32 exit_code = 1; - - // Error message. Empty if there was no error. - string error = 2; - } - - // Output from the command execution. It may not contain the full output - // and the caller may need to poll for more lines. - repeated Line output = 1; - - // Whether the command execution has finished and there is no more output. - bool output_end = 2; - - // The result exit status of the command. - ExitInfo exit_info = 3; -} - -// Request to create a snapshot of a Cloud Composer environment. -message SaveSnapshotRequest { - // The resource name of the source environment in the form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - string environment = 1; - - // Location in a Cloud Storage where the snapshot is going to be stored, e.g.: - // "gs://my-bucket/snapshots". - string snapshot_location = 2; -} - -// Response to SaveSnapshotRequest. -message SaveSnapshotResponse { - // The fully-resolved Cloud Storage path of the created snapshot, - // e.g.: - // "gs://my-bucket/snapshots/project_location_environment_timestamp". - // This field is populated only if the snapshot creation was successful. - string snapshot_path = 1; -} - -// Request to load a snapshot into a Cloud Composer environment. -message LoadSnapshotRequest { - // The resource name of the target environment in the form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - string environment = 1; - - // A Cloud Storage path to a snapshot to load, e.g.: - // "gs://my-bucket/snapshots/project_location_environment_timestamp". - string snapshot_path = 2; - - // Whether or not to skip installing Pypi packages when loading the - // environment's state. - bool skip_pypi_packages_installation = 3; - - // Whether or not to skip setting environment variables when loading the - // environment's state. - bool skip_environment_variables_setting = 4; - - // Whether or not to skip setting Airflow overrides when loading the - // environment's state. - bool skip_airflow_overrides_setting = 5; - - // Whether or not to skip copying Cloud Storage data when loading the - // environment's state. - bool skip_gcs_data_copying = 6; -} - -// Response to LoadSnapshotRequest. -message LoadSnapshotResponse {} - -// Request to trigger database failover (only for highly resilient -// environments). -message DatabaseFailoverRequest { - // Target environment: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - string environment = 1; -} - -// Response for DatabaseFailoverRequest. -message DatabaseFailoverResponse {} - -// Request to fetch properties of environment's database. -message FetchDatabasePropertiesRequest { - // Required. The resource name of the environment, in the form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - string environment = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "composer.googleapis.com/Environment" - } - ]; -} - -// Response for FetchDatabasePropertiesRequest. -message FetchDatabasePropertiesResponse { - // The Compute Engine zone that the instance is currently serving from. - string primary_gce_zone = 1; - - // The Compute Engine zone that the failover instance is currently serving - // from for a regional Cloud SQL instance. - string secondary_gce_zone = 2; - - // The availability status of the failover replica. A false status indicates - // that the failover replica is out of sync. The primary instance can only - // fail over to the failover replica when the status is true. - bool is_failover_replica_available = 3; -} - -// Configuration information for an environment. -message EnvironmentConfig { - // The size of the Cloud Composer environment. - enum EnvironmentSize { - // The size of the environment is unspecified. - ENVIRONMENT_SIZE_UNSPECIFIED = 0; - - // The environment size is small. - ENVIRONMENT_SIZE_SMALL = 1; - - // The environment size is medium. - ENVIRONMENT_SIZE_MEDIUM = 2; - - // The environment size is large. - ENVIRONMENT_SIZE_LARGE = 3; - } - - // Resilience mode of the Cloud Composer Environment. - enum ResilienceMode { - // Default mode doesn't change environment parameters. - RESILIENCE_MODE_UNSPECIFIED = 0; - - // Enabled High Resilience mode, including Cloud SQL HA. - HIGH_RESILIENCE = 1; - } - - // Output only. The Kubernetes Engine cluster used to run this environment. - string gke_cluster = 1; - - // Output only. The Cloud Storage prefix of the DAGs for this environment. - // Although Cloud Storage objects reside in a flat namespace, a hierarchical - // file tree can be simulated using "/"-delimited object name prefixes. DAG - // objects for this environment reside in a simulated directory with the given - // prefix. - string dag_gcs_prefix = 2; - - // The number of nodes in the Kubernetes Engine cluster that will be - // used to run this environment. - // - // This field is supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - int32 node_count = 3; - - // The configuration settings for software inside the environment. - SoftwareConfig software_config = 4; - - // The configuration used for the Kubernetes Engine cluster. - NodeConfig node_config = 5; - - // The configuration used for the Private IP Cloud Composer environment. - PrivateEnvironmentConfig private_environment_config = 7; - - // Optional. The network-level access control policy for the Airflow web - // server. If unspecified, no network-level access restrictions will be - // applied. - WebServerNetworkAccessControl web_server_network_access_control = 8 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The configuration settings for Cloud SQL instance used internally - // by Apache Airflow software. - DatabaseConfig database_config = 9 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The configuration settings for the Airflow web server App Engine - // instance. - WebServerConfig web_server_config = 10 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The encryption options for the Cloud Composer environment - // and its dependencies. Cannot be updated. - EncryptionConfig encryption_config = 11 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The maintenance window is the period when Cloud Composer - // components may undergo maintenance. It is defined so that maintenance is - // not executed during peak hours or critical time periods. - // - // The system will not be under maintenance for every occurrence of this - // window, but when maintenance is planned, it will be scheduled - // during the window. - // - // The maintenance window period must encompass at least 12 hours per week. - // This may be split into multiple chunks, each with a size of - // at least 4 hours. - // - // If this value is omitted, the default value for maintenance window will be - // applied. The default value is Saturday and Sunday 00-06 GMT. - MaintenanceWindow maintenance_window = 12 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The workloads configuration settings for the GKE cluster - // associated with the Cloud Composer environment. The GKE cluster runs - // Airflow scheduler, web server and workers workloads. - // - // This field is supported for Cloud Composer environments in versions - // composer-2.*.*-airflow-*.*.* and newer. - WorkloadsConfig workloads_config = 15 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The size of the Cloud Composer environment. - // - // This field is supported for Cloud Composer environments in versions - // composer-2.*.*-airflow-*.*.* and newer. - EnvironmentSize environment_size = 16 - [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The URI of the Apache Airflow Web UI hosted within this - // environment (see [Airflow web - // interface](/composer/docs/how-to/accessing/airflow-web-interface)). - string airflow_uri = 6; - - // Output only. The 'bring your own identity' variant of the URI of the Apache - // Airflow Web UI hosted within this environment, to be accessed with external - // identities using workforce identity federation (see [Access environments - // with workforce identity - // federation](/composer/docs/composer-2/access-environments-with-workforce-identity-federation)). - string airflow_byoid_uri = 20 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. The configuration options for GKE cluster master authorized - // networks. By default master authorized networks feature is: - // - in case of private environment: enabled with no external networks - // allowlisted. - // - in case of public environment: disabled. - MasterAuthorizedNetworksConfig master_authorized_networks_config = 17 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The Recovery settings configuration of an environment. - // - // This field is supported for Cloud Composer environments in versions - // composer-2.*.*-airflow-*.*.* and newer. - RecoveryConfig recovery_config = 18 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Resilience mode of the Cloud Composer Environment. - // - // This field is supported for Cloud Composer environments in versions - // composer-2.2.0-airflow-*.*.* and newer. - ResilienceMode resilience_mode = 19 [(google.api.field_behavior) = OPTIONAL]; -} - -// Network-level access control policy for the Airflow web server. -message WebServerNetworkAccessControl { - // Allowed IP range with user-provided description. - message AllowedIpRange { - // IP address or range, defined using CIDR notation, of requests that this - // rule applies to. - // Examples: `192.168.1.1` or `192.168.0.0/16` or `2001:db8::/32` - // or `2001:0db8:0000:0042:0000:8a2e:0370:7334`. - // - // IP range prefixes should be properly truncated. For example, - // `1.2.3.4/24` should be truncated to `1.2.3.0/24`. Similarly, for IPv6, - // `2001:db8::1/32` should be truncated to `2001:db8::/32`. - string value = 1; - - // Optional. User-provided description. It must contain at most 300 - // characters. - string description = 2 [(google.api.field_behavior) = OPTIONAL]; - } - - // A collection of allowed IP ranges with descriptions. - repeated AllowedIpRange allowed_ip_ranges = 1; -} - -// The configuration of Cloud SQL instance that is used by the Apache Airflow -// software. -message DatabaseConfig { - // Optional. Cloud SQL machine type used by Airflow database. - // It has to be one of: db-n1-standard-2, db-n1-standard-4, db-n1-standard-8 - // or db-n1-standard-16. If not specified, db-n1-standard-2 will be used. - // Supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - string machine_type = 1 [(google.api.field_behavior) = OPTIONAL]; -} - -// The configuration settings for the Airflow web server App Engine instance. -// Supported for Cloud Composer environments in versions -// composer-1.*.*-airflow-*.*.* -message WebServerConfig { - // Optional. Machine type on which Airflow web server is running. - // It has to be one of: composer-n1-webserver-2, composer-n1-webserver-4 or - // composer-n1-webserver-8. - // If not specified, composer-n1-webserver-2 will be used. - // Value custom is returned only in response, if Airflow web server parameters - // were manually changed to a non-standard values. - string machine_type = 1 [(google.api.field_behavior) = OPTIONAL]; -} - -// The encryption options for the Cloud Composer environment -// and its dependencies.Supported for Cloud Composer environments in versions -// composer-1.*.*-airflow-*.*.*. -message EncryptionConfig { - // Optional. Customer-managed Encryption Key available through Google's Key - // Management Service. Cannot be updated. If not specified, Google-managed key - // will be used. - string kms_key_name = 1 [(google.api.field_behavior) = OPTIONAL]; -} - -// The configuration settings for Cloud Composer maintenance window. -// The following example: -// -// ``` -// { -// "startTime":"2019-08-01T01:00:00Z" -// "endTime":"2019-08-01T07:00:00Z" -// "recurrence":"FREQ=WEEKLY;BYDAY=TU,WE" -// } -// ``` -// -// would define a maintenance window between 01 and 07 hours UTC during -// each Tuesday and Wednesday. -message MaintenanceWindow { - // Required. Start time of the first recurrence of the maintenance window. - google.protobuf.Timestamp start_time = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. Maintenance window end time. It is used only to calculate the - // duration of the maintenance window. The value for end-time must be in the - // future, relative to `start_time`. - google.protobuf.Timestamp end_time = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Required. Maintenance window recurrence. Format is a subset of - // [RFC-5545](https://tools.ietf.org/html/rfc5545) `RRULE`. The only allowed - // values for `FREQ` field are `FREQ=DAILY` and `FREQ=WEEKLY;BYDAY=...` - // Example values: `FREQ=WEEKLY;BYDAY=TU,WE`, `FREQ=DAILY`. - string recurrence = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Specifies the selection and configuration of software inside the environment. -message SoftwareConfig { - // The version of the software running in the environment. - // This encapsulates both the version of Cloud Composer functionality and the - // version of Apache Airflow. It must match the regular expression - // `composer-([0-9]+(\.[0-9]+\.[0-9]+(-preview\.[0-9]+)?)?|latest)-airflow-([0-9]+(\.[0-9]+(\.[0-9]+)?)?)`. - // When used as input, the server also checks if the provided version is - // supported and denies the request for an unsupported version. - // - // The Cloud Composer portion of the image version is a full - // [semantic version](https://semver.org), or an alias in the form of major - // version number or `latest`. When an alias is provided, the server replaces - // it with the current Cloud Composer version that satisfies the alias. - // - // The Apache Airflow portion of the image version is a full semantic version - // that points to one of the supported Apache Airflow versions, or an alias in - // the form of only major or major.minor versions specified. When an alias is - // provided, the server replaces it with the latest Apache Airflow version - // that satisfies the alias and is supported in the given Cloud Composer - // version. - // - // In all cases, the resolved image version is stored in the same field. - // - // See also [version - // list](/composer/docs/concepts/versioning/composer-versions) and [versioning - // overview](/composer/docs/concepts/versioning/composer-versioning-overview). - string image_version = 1; - - // Optional. Apache Airflow configuration properties to override. - // - // Property keys contain the section and property names, separated by a - // hyphen, for example "core-dags_are_paused_at_creation". Section names must - // not contain hyphens ("-"), opening square brackets ("["), or closing - // square brackets ("]"). The property name must not be empty and must not - // contain an equals sign ("=") or semicolon (";"). Section and property names - // must not contain a period ("."). Apache Airflow configuration property - // names must be written in - // [snake_case](https://en.wikipedia.org/wiki/Snake_case). Property values can - // contain any character, and can be written in any lower/upper case format. - // - // Certain Apache Airflow configuration property values are - // [blocked](/composer/docs/concepts/airflow-configurations), - // and cannot be overridden. - map airflow_config_overrides = 2; - - // Optional. Custom Python Package Index (PyPI) packages to be installed in - // the environment. - // - // Keys refer to the lowercase package name such as "numpy" - // and values are the lowercase extras and version specifier such as - // "==1.12.0", "[devel,gcp_api]", or "[devel]>=1.8.2, <1.9.2". To specify a - // package without pinning it to a version specifier, use the empty string as - // the value. - map pypi_packages = 3; - - // Optional. Additional environment variables to provide to the Apache Airflow - // scheduler, worker, and webserver processes. - // - // Environment variable names must match the regular expression - // `[a-zA-Z_][a-zA-Z0-9_]*`. They cannot specify Apache Airflow - // software configuration overrides (they cannot match the regular expression - // `AIRFLOW__[A-Z0-9_]+__[A-Z0-9_]+`), and they cannot match any of the - // following reserved names: - // - // * `AIRFLOW_HOME` - // * `C_FORCE_ROOT` - // * `CONTAINER_NAME` - // * `DAGS_FOLDER` - // * `GCP_PROJECT` - // * `GCS_BUCKET` - // * `GKE_CLUSTER_NAME` - // * `SQL_DATABASE` - // * `SQL_INSTANCE` - // * `SQL_PASSWORD` - // * `SQL_PROJECT` - // * `SQL_REGION` - // * `SQL_USER` - map env_variables = 4; - - // Optional. The major version of Python used to run the Apache Airflow - // scheduler, worker, and webserver processes. - // - // Can be set to '2' or '3'. If not specified, the default is '3'. Cannot be - // updated. - // - // This field is only supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. Environments in newer versions always use - // Python major version 3. - string python_version = 6; - - // Optional. The number of schedulers for Airflow. - // - // This field is supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-2.*.*. - int32 scheduler_count = 7 [(google.api.field_behavior) = OPTIONAL]; -} - -// Configuration for controlling how IPs are allocated in the -// GKE cluster running the Apache Airflow software. -message IPAllocationPolicy { - // Optional. Whether or not to enable Alias IPs in the GKE cluster. - // If `true`, a VPC-native cluster is created. - // - // This field is only supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. Environments in newer versions always use - // VPC-native GKE clusters. - bool use_ip_aliases = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Configuration of allocating IP addresses for pods in the GKE cluster. - oneof cluster_ip_allocation { - // Optional. The name of the GKE cluster's secondary range used to allocate - // IP addresses to pods. - // - // For Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*, - // this field is applicable only when `use_ip_aliases` is true. - string cluster_secondary_range_name = 2 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The IP address range used to allocate IP addresses to pods in - // the GKE cluster. - // - // For Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*, - // this field is applicable only when `use_ip_aliases` is true. - // - // Set to blank to have GKE choose a range with the default size. - // - // Set to /netmask (e.g. `/14`) to have GKE choose a range with a specific - // netmask. - // - // Set to a - // [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) - // notation (e.g. `10.96.0.0/14`) from the RFC-1918 private networks (e.g. - // `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`) to pick a specific range - // to use. - string cluster_ipv4_cidr_block = 4 [(google.api.field_behavior) = OPTIONAL]; - } - - // Configuration of allocating IP addresses for services in the GKE cluster. - oneof services_ip_allocation { - // Optional. The name of the services' secondary range used to allocate - // IP addresses to the GKE cluster. - // - // For Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*, - // this field is applicable only when `use_ip_aliases` is true. - string services_secondary_range_name = 3 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The IP address range of the services IP addresses in this - // GKE cluster. - // - // For Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*, - // this field is applicable only when `use_ip_aliases` is true. - // - // Set to blank to have GKE choose a range with the default size. - // - // Set to /netmask (e.g. `/14`) to have GKE choose a range with a specific - // netmask. - // - // Set to a - // [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) - // notation (e.g. `10.96.0.0/14`) from the RFC-1918 private networks (e.g. - // `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`) to pick a specific range - // to use. - string services_ipv4_cidr_block = 5 - [(google.api.field_behavior) = OPTIONAL]; - } -} - -// The configuration information for the Kubernetes Engine nodes running -// the Apache Airflow software. -message NodeConfig { - // Optional. The Compute Engine [zone](/compute/docs/regions-zones) in which - // to deploy the VMs used to run the Apache Airflow software, specified as a - // [relative resource - // name](/apis/design/resource_names#relative_resource_name). For example: - // "projects/{projectId}/zones/{zoneId}". - // - // This `location` must belong to the enclosing environment's project and - // location. If both this field and `nodeConfig.machineType` are specified, - // `nodeConfig.machineType` must belong to this `location`; if both are - // unspecified, the service will pick a zone in the Compute Engine region - // corresponding to the Cloud Composer location, and propagate that choice to - // both fields. If only one field (`location` or `nodeConfig.machineType`) is - // specified, the location information from the specified field will be - // propagated to the unspecified field. - // - // This field is supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - string location = 1; - - // Optional. The Compute Engine - // [machine type](/compute/docs/machine-types) used for cluster instances, - // specified as a - // [relative resource - // name](/apis/design/resource_names#relative_resource_name). For example: - // "projects/{projectId}/zones/{zoneId}/machineTypes/{machineTypeId}". - // - // The `machineType` must belong to the enclosing environment's project and - // location. If both this field and `nodeConfig.location` are specified, - // this `machineType` must belong to the `nodeConfig.location`; if both are - // unspecified, the service will pick a zone in the Compute Engine region - // corresponding to the Cloud Composer location, and propagate that choice to - // both fields. If exactly one of this field and `nodeConfig.location` is - // specified, the location information from the specified field will be - // propagated to the unspecified field. - // - // The `machineTypeId` must not be a [shared-core machine - // type](/compute/docs/machine-types#sharedcore). - // - // If this field is unspecified, the `machineTypeId` defaults - // to "n1-standard-1". - // - // This field is supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - string machine_type = 2; - - // Optional. The Compute Engine network to be used for machine - // communications, specified as a - // [relative resource - // name](/apis/design/resource_names#relative_resource_name). For example: - // "projects/{projectId}/global/networks/{networkId}". - // - // If unspecified, the "default" network ID in the environment's project is - // used. If a [Custom Subnet Network](/vpc/docs/vpc#vpc_networks_and_subnets) - // is provided, `nodeConfig.subnetwork` must also be provided. For - // [Shared VPC](/vpc/docs/shared-vpc) subnetwork requirements, see - // `nodeConfig.subnetwork`. - string network = 3; - - // Optional. The Compute Engine subnetwork to be used for machine - // communications, specified as a - // [relative resource - // name](/apis/design/resource_names#relative_resource_name). For example: - // "projects/{projectId}/regions/{regionId}/subnetworks/{subnetworkId}" - // - // If a subnetwork is provided, `nodeConfig.network` must also be provided, - // and the subnetwork must belong to the enclosing environment's project and - // location. - string subnetwork = 4; - - // Optional. The disk size in GB used for node VMs. Minimum size is 30GB. - // If unspecified, defaults to 100GB. Cannot be updated. - // - // This field is supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - int32 disk_size_gb = 5; - - // Optional. The set of Google API scopes to be made available on all - // node VMs. If `oauth_scopes` is empty, defaults to - // ["https://www.googleapis.com/auth/cloud-platform"]. Cannot be updated. - // - // This field is supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - repeated string oauth_scopes = 6; - - // Optional. The Google Cloud Platform Service Account to be used by the node - // VMs. If a service account is not specified, the "default" Compute Engine - // service account is used. Cannot be updated. - string service_account = 7; - - // Optional. The list of instance tags applied to all node VMs. Tags are used - // to identify valid sources or targets for network firewalls. Each tag within - // the list must comply with [RFC1035](https://www.ietf.org/rfc/rfc1035.txt). - // Cannot be updated. - repeated string tags = 8; - - // Optional. The configuration for controlling how IPs are allocated in the - // GKE cluster. - IPAllocationPolicy ip_allocation_policy = 9 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Deploys 'ip-masq-agent' daemon set in the GKE cluster and defines - // nonMasqueradeCIDRs equals to pod IP range so IP masquerading is used for - // all destination addresses, except between pods traffic. - // - // See: - // https://cloud.google.com/kubernetes-engine/docs/how-to/ip-masquerade-agent - bool enable_ip_masq_agent = 11 [(google.api.field_behavior) = OPTIONAL]; -} - -// Configuration options for the private GKE cluster in a Cloud Composer -// environment. -message PrivateClusterConfig { - // Optional. If `true`, access to the public endpoint of the GKE cluster is - // denied. - bool enable_private_endpoint = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The CIDR block from which IPv4 range for GKE master will be - // reserved. If left blank, the default value of '172.16.0.0/23' is used. - string master_ipv4_cidr_block = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The IP range in CIDR notation to use for the hosted master - // network. This range is used for assigning internal IP addresses to the GKE - // cluster master or set of masters and to the internal load balancer virtual - // IP. This range must not overlap with any other ranges in use within the - // cluster's network. - string master_ipv4_reserved_range = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Configuration options for networking connections in the Composer 2 -// environment. -message NetworkingConfig { - // Represents connection type between Composer environment in Customer - // Project and the corresponding Tenant project, from a predefined list - // of available connection modes. - enum ConnectionType { - // No specific connection type was requested, so the environment uses - // the default value corresponding to the rest of its configuration. - CONNECTION_TYPE_UNSPECIFIED = 0; - - // Requests the use of VPC peerings for connecting the Customer and Tenant - // projects. - VPC_PEERING = 1; - - // Requests the use of Private Service Connect for connecting the Customer - // and Tenant projects. - PRIVATE_SERVICE_CONNECT = 2; - } - - // Optional. Indicates the user requested specifc connection type between - // Tenant and Customer projects. You cannot set networking connection type in - // public IP environment. - ConnectionType connection_type = 1 [(google.api.field_behavior) = OPTIONAL]; -} - -// The configuration information for configuring a Private IP Cloud Composer -// environment. -message PrivateEnvironmentConfig { - // Optional. If `true`, a Private IP Cloud Composer environment is created. - // If this field is set to true, `IPAllocationPolicy.use_ip_aliases` must be - // set to true for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - bool enable_private_environment = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Configuration for the private GKE cluster for a Private IP - // Cloud Composer environment. - PrivateClusterConfig private_cluster_config = 2 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The CIDR block from which IP range for web server will be - // reserved. Needs to be disjoint from - // `private_cluster_config.master_ipv4_cidr_block` and - // `cloud_sql_ipv4_cidr_block`. - // - // This field is supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - string web_server_ipv4_cidr_block = 3 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The CIDR block from which IP range in tenant project will be - // reserved for Cloud SQL. Needs to be disjoint from - // `web_server_ipv4_cidr_block`. - string cloud_sql_ipv4_cidr_block = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The IP range reserved for the tenant project's App Engine VMs. - // - // This field is supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - string web_server_ipv4_reserved_range = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. The CIDR block from which IP range for Cloud Composer Network in - // tenant project will be reserved. Needs to be disjoint from - // private_cluster_config.master_ipv4_cidr_block and - // cloud_sql_ipv4_cidr_block. - // - // This field is supported for Cloud Composer environments in versions - // composer-2.*.*-airflow-*.*.* and newer. - string cloud_composer_network_ipv4_cidr_block = 7 - [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The IP range reserved for the tenant project's Cloud Composer - // network. - // - // This field is supported for Cloud Composer environments in versions - // composer-2.*.*-airflow-*.*.* and newer. - string cloud_composer_network_ipv4_reserved_range = 8 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. When enabled, IPs from public (non-RFC1918) ranges can be used - // for `IPAllocationPolicy.cluster_ipv4_cidr_block` and - // `IPAllocationPolicy.service_ipv4_cidr_block`. - bool enable_privately_used_public_ips = 6 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. When specified, the environment will use Private Service Connect - // instead of VPC peerings to connect to Cloud SQL in the Tenant Project, - // and the PSC endpoint in the Customer Project will use an IP address from - // this subnetwork. - string cloud_composer_connection_subnetwork = 9 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Configuration for the network connections configuration in the - // environment. - NetworkingConfig networking_config = 10 - [(google.api.field_behavior) = OPTIONAL]; -} - -// The Kubernetes workloads configuration for GKE cluster associated with the -// Cloud Composer environment. Supported for Cloud Composer environments in -// versions composer-2.*.*-airflow-*.*.* and newer. -message WorkloadsConfig { - // Configuration for resources used by Airflow schedulers. - message SchedulerResource { - // Optional. CPU request and limit for a single Airflow scheduler replica. - float cpu = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Memory (GB) request and limit for a single Airflow scheduler - // replica. - float memory_gb = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Storage (GB) request and limit for a single Airflow scheduler - // replica. - float storage_gb = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The number of schedulers. - int32 count = 4 [(google.api.field_behavior) = OPTIONAL]; - } - - // Configuration for resources used by Airflow web server. - message WebServerResource { - // Optional. CPU request and limit for Airflow web server. - float cpu = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Memory (GB) request and limit for Airflow web server. - float memory_gb = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Storage (GB) request and limit for Airflow web server. - float storage_gb = 3 [(google.api.field_behavior) = OPTIONAL]; - } - - // Configuration for resources used by Airflow workers. - message WorkerResource { - // Optional. CPU request and limit for a single Airflow worker replica. - float cpu = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Memory (GB) request and limit for a single Airflow worker - // replica. - float memory_gb = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Storage (GB) request and limit for a single Airflow worker - // replica. - float storage_gb = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Minimum number of workers for autoscaling. - int32 min_count = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Maximum number of workers for autoscaling. - int32 max_count = 5 [(google.api.field_behavior) = OPTIONAL]; - } - - // Optional. Resources used by Airflow schedulers. - SchedulerResource scheduler = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Resources used by Airflow web server. - WebServerResource web_server = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Resources used by Airflow workers. - WorkerResource worker = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// The Recovery settings of an environment. -message RecoveryConfig { - // Optional. The configuration for scheduled snapshot creation mechanism. - ScheduledSnapshotsConfig scheduled_snapshots_config = 1 - [(google.api.field_behavior) = OPTIONAL]; -} - -// The configuration for scheduled snapshot creation mechanism. -message ScheduledSnapshotsConfig { - // Optional. Whether scheduled snapshots creation is enabled. - bool enabled = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The Cloud Storage location for storing automatically created - // snapshots. - string snapshot_location = 6 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The cron expression representing the time when snapshots creation - // mechanism runs. This field is subject to additional validation around - // frequency of execution. - string snapshot_creation_schedule = 3 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Time zone that sets the context to interpret - // snapshot_creation_schedule. - string time_zone = 5 [(google.api.field_behavior) = OPTIONAL]; -} - -// Configuration options for the master authorized networks feature. Enabled -// master authorized networks will disallow all external traffic to access -// Kubernetes master through HTTPS except traffic from the given CIDR blocks, -// Google Compute Engine Public IPs and Google Prod IPs. -message MasterAuthorizedNetworksConfig { - // CIDR block with an optional name. - message CidrBlock { - // User-defined name that identifies the CIDR block. - string display_name = 1; - - // CIDR block that must be specified in CIDR notation. - string cidr_block = 2; - } - - // Whether or not master authorized networks feature is enabled. - bool enabled = 1; - - // Up to 50 external networks that could access Kubernetes master through - // HTTPS. - repeated CidrBlock cidr_blocks = 2; -} - -// An environment for running orchestration tasks. -message Environment { - option (google.api.resource) = { - type: "composer.googleapis.com/Environment" - pattern: "projects/{project}/locations/{location}/environments/{environment}" - }; - - // State of the environment. - enum State { - // The state of the environment is unknown. - STATE_UNSPECIFIED = 0; - - // The environment is in the process of being created. - CREATING = 1; - - // The environment is currently running and healthy. It is ready for use. - RUNNING = 2; - - // The environment is being updated. It remains usable but cannot receive - // additional update requests or be deleted at this time. - UPDATING = 3; - - // The environment is undergoing deletion. It cannot be used. - DELETING = 4; - - // The environment has encountered an error and cannot be used. - ERROR = 5; - } - - // The resource name of the environment, in the form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - // - // EnvironmentId must start with a lowercase letter followed by up to 63 - // lowercase letters, numbers, or hyphens, and cannot end with a hyphen. - string name = 1; - - // Configuration parameters for this environment. - EnvironmentConfig config = 2; - - // Output only. The UUID (Universally Unique IDentifier) associated with this - // environment. This value is generated when the environment is created. - string uuid = 3; - - // The current state of the environment. - State state = 4; - - // Output only. The time at which this environment was created. - google.protobuf.Timestamp create_time = 5; - - // Output only. The time at which this environment was last modified. - google.protobuf.Timestamp update_time = 6; - - // Optional. User-defined labels for this environment. - // The labels map can contain no more than 64 entries. Entries of the labels - // map are UTF8 strings that comply with the following restrictions: - // - // * Keys must conform to regexp: [\p{Ll}\p{Lo}][\p{Ll}\p{Lo}\p{N}_-]{0,62} - // * Values must conform to regexp: [\p{Ll}\p{Lo}\p{N}_-]{0,63} - // * Both keys and values are additionally constrained to be <= 128 bytes in - // size. - map labels = 7; -} - -// Message containing information about the result of an upgrade check -// operation. -message CheckUpgradeResponse { - // Whether there were python modules conflict during image build. - enum ConflictResult { - // It is unknown whether build had conflicts or not. - CONFLICT_RESULT_UNSPECIFIED = 0; - - // There were python packages conflicts. - CONFLICT = 1; - - // There were no python packages conflicts. - NO_CONFLICT = 2; - } - - // Output only. Url for a docker build log of an upgraded image. - string build_log_uri = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Whether build has succeeded or failed on modules conflicts. - ConflictResult contains_pypi_modules_conflict = 4 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Extract from a docker image build log containing information - // about pypi modules conflicts. - string pypi_conflict_build_log_extract = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Composer image for which the build was happening. - string image_version = 5; - - // Pypi dependencies specified in the environment configuration, at the time - // when the build was triggered. - map pypi_dependencies = 6; -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/image_versions.proto b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/image_versions.proto deleted file mode 100644 index 0f458cc5c6f..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/image_versions.proto +++ /dev/null @@ -1,90 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.orchestration.airflow.service.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/type/date.proto"; - -option go_package = "cloud.google.com/go/orchestration/airflow/service/apiv1/servicepb;servicepb"; -option java_multiple_files = true; -option java_package = "com.google.cloud.orchestration.airflow.service.v1"; - -// Readonly service to query available ImageVersions. -service ImageVersions { - option (google.api.default_host) = "composer.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // List ImageVersions for provided location. - rpc ListImageVersions(ListImageVersionsRequest) - returns (ListImageVersionsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/imageVersions" - }; - option (google.api.method_signature) = "parent"; - } -} - -// List ImageVersions in a project and location. -message ListImageVersionsRequest { - // List ImageVersions in the given project and location, in the form: - // "projects/{projectId}/locations/{locationId}" - string parent = 1; - - // The maximum number of image_versions to return. - int32 page_size = 2; - - // The next_page_token value returned from a previous List request, if any. - string page_token = 3; - - // Whether or not image versions from old releases should be included. - bool include_past_releases = 4; -} - -// The ImageVersions in a project and location. -message ListImageVersionsResponse { - // The list of supported ImageVersions in a location. - repeated ImageVersion image_versions = 1; - - // The page token used to query for the next page if one exists. - string next_page_token = 2; -} - -// ImageVersion information -message ImageVersion { - // The string identifier of the ImageVersion, in the form: - // "composer-x.y.z-airflow-a.b.c" - string image_version_id = 1; - - // Whether this is the default ImageVersion used by Composer during - // environment creation if no input ImageVersion is specified. - bool is_default = 2; - - // supported python versions - repeated string supported_python_versions = 3; - - // The date of the version release. - google.type.Date release_date = 4; - - // Whether it is impossible to create an environment with the image version. - bool creation_disabled = 5; - - // Whether it is impossible to upgrade an environment running with the image - // version. - bool upgrade_disabled = 6; -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/operations.proto b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/operations.proto deleted file mode 100644 index 71672aa3c8e..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/protos/google/cloud/orchestration/airflow/service/v1/operations.proto +++ /dev/null @@ -1,97 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.orchestration.airflow.service.v1; - -import "google/protobuf/timestamp.proto"; - -option go_package = "cloud.google.com/go/orchestration/airflow/service/apiv1/servicepb;servicepb"; -option java_multiple_files = true; -option java_outer_classname = "OperationsProto"; -option java_package = "com.google.cloud.orchestration.airflow.service.v1"; - -// Metadata describing an operation. -message OperationMetadata { - // An enum describing the overall state of an operation. - enum State { - option allow_alias = true; - - // Unused. - STATE_UNSPECIFIED = 0; - - // The operation has been created but is not yet started. - PENDING = 1; - - // The operation is underway. - RUNNING = 2; - - // The operation completed successfully. - SUCCEEDED = 3; - - SUCCESSFUL = 3; - - // The operation is no longer running but did not succeed. - FAILED = 4; - } - - // Type of longrunning operation. - enum Type { - // Unused. - TYPE_UNSPECIFIED = 0; - - // A resource creation operation. - CREATE = 1; - - // A resource deletion operation. - DELETE = 2; - - // A resource update operation. - UPDATE = 3; - - // A resource check operation. - CHECK = 4; - - // Saves snapshot of the resource operation. - SAVE_SNAPSHOT = 5; - - // Loads snapshot of the resource operation. - LOAD_SNAPSHOT = 6; - - // Triggers failover of environment's Cloud SQL instance (only for highly - // resilient environments). - DATABASE_FAILOVER = 7; - } - - // Output only. The current operation state. - State state = 1; - - // Output only. The type of operation being performed. - Type operation_type = 2; - - // Output only. The resource being operated on, as a [relative resource name]( - // /apis/design/resource_names#relative_resource_name). - string resource = 3; - - // Output only. The UUID of the resource being operated on. - string resource_uuid = 4; - - // Output only. The time the operation was submitted to the server. - google.protobuf.Timestamp create_time = 5; - - // Output only. The time when the operation terminated, regardless of its - // success. This field is unset if the operation is still ongoing. - google.protobuf.Timestamp end_time = 6; -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.create_environment.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.create_environment.js deleted file mode 100644 index 6f22fd302cb..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.create_environment.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() { - // [START composer_v1_generated_Environments_CreateEnvironment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 must be of the form - * "projects/{projectId}/locations/{locationId}". - */ - // const parent = 'abc123' - /** - * The environment to create. - */ - // const environment = {} - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callCreateEnvironment() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await serviceClient.createEnvironment(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateEnvironment(); - // [END composer_v1_generated_Environments_CreateEnvironment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.database_failover.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.database_failover.js deleted file mode 100644 index fa2c0df10a5..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.database_failover.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() { - // [START composer_v1_generated_Environments_DatabaseFailover_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Target environment: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - */ - // const environment = 'abc123' - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callDatabaseFailover() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await serviceClient.databaseFailover(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDatabaseFailover(); - // [END composer_v1_generated_Environments_DatabaseFailover_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.delete_environment.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.delete_environment.js deleted file mode 100644 index 939b7fb7084..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.delete_environment.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() { - // [START composer_v1_generated_Environments_DeleteEnvironment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 environment to delete, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - */ - // const name = 'abc123' - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callDeleteEnvironment() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await serviceClient.deleteEnvironment(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteEnvironment(); - // [END composer_v1_generated_Environments_DeleteEnvironment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.execute_airflow_command.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.execute_airflow_command.js deleted file mode 100644 index f997ed827e1..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.execute_airflow_command.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() { - // [START composer_v1_generated_Environments_ExecuteAirflowCommand_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 resource name of the environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}". - */ - // const environment = 'abc123' - /** - * Airflow command. - */ - // const command = 'abc123' - /** - * Airflow subcommand. - */ - // const subcommand = 'abc123' - /** - * Parameters for the Airflow command/subcommand as an array of arguments. - * It may contain positional arguments like `["my-dag-id"]`, key-value - * parameters like `["--foo=bar"]` or `["--foo","bar"]`, - * or other flags like `["-f"]`. - */ - // const parameters = ['abc','def'] - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callExecuteAirflowCommand() { - // Construct request - const request = { - }; - - // Run request - const response = await serviceClient.executeAirflowCommand(request); - console.log(response); - } - - callExecuteAirflowCommand(); - // [END composer_v1_generated_Environments_ExecuteAirflowCommand_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.fetch_database_properties.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.fetch_database_properties.js deleted file mode 100644 index 53391a937d2..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.fetch_database_properties.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(environment) { - // [START composer_v1_generated_Environments_FetchDatabaseProperties_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 environment, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - */ - // const environment = 'abc123' - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callFetchDatabaseProperties() { - // Construct request - const request = { - environment, - }; - - // Run request - const response = await serviceClient.fetchDatabaseProperties(request); - console.log(response); - } - - callFetchDatabaseProperties(); - // [END composer_v1_generated_Environments_FetchDatabaseProperties_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.get_environment.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.get_environment.js deleted file mode 100644 index 7329b82691c..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.get_environment.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 composer_v1_generated_Environments_GetEnvironment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 resource name of the environment to get, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - */ - // const name = 'abc123' - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callGetEnvironment() { - // Construct request - const request = { - }; - - // Run request - const response = await serviceClient.getEnvironment(request); - console.log(response); - } - - callGetEnvironment(); - // [END composer_v1_generated_Environments_GetEnvironment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.list_environments.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.list_environments.js deleted file mode 100644 index 3300e3bfed1..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.list_environments.js +++ /dev/null @@ -1,71 +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 composer_v1_generated_Environments_ListEnvironments_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * List environments in the given project and location, in the form: - * "projects/{projectId}/locations/{locationId}" - */ - // const parent = 'abc123' - /** - * The maximum number of environments to return. - */ - // const pageSize = 1234 - /** - * The next_page_token value returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callListEnvironments() { - // Construct request - const request = { - }; - - // Run request - const iterable = await serviceClient.listEnvironmentsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListEnvironments(); - // [END composer_v1_generated_Environments_ListEnvironments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.load_snapshot.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.load_snapshot.js deleted file mode 100644 index 1bb1092893a..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.load_snapshot.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() { - // [START composer_v1_generated_Environments_LoadSnapshot_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 resource name of the target environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - */ - // const environment = 'abc123' - /** - * A Cloud Storage path to a snapshot to load, e.g.: - * "gs://my-bucket/snapshots/project_location_environment_timestamp". - */ - // const snapshotPath = 'abc123' - /** - * Whether or not to skip installing Pypi packages when loading the - * environment's state. - */ - // const skipPypiPackagesInstallation = true - /** - * Whether or not to skip setting environment variables when loading the - * environment's state. - */ - // const skipEnvironmentVariablesSetting = true - /** - * Whether or not to skip setting Airflow overrides when loading the - * environment's state. - */ - // const skipAirflowOverridesSetting = true - /** - * Whether or not to skip copying Cloud Storage data when loading the - * environment's state. - */ - // const skipGcsDataCopying = true - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callLoadSnapshot() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await serviceClient.loadSnapshot(request); - const [response] = await operation.promise(); - console.log(response); - } - - callLoadSnapshot(); - // [END composer_v1_generated_Environments_LoadSnapshot_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.poll_airflow_command.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.poll_airflow_command.js deleted file mode 100644 index 13f8af79815..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.poll_airflow_command.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() { - // [START composer_v1_generated_Environments_PollAirflowCommand_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 resource name of the environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - */ - // const environment = 'abc123' - /** - * The unique ID of the command execution. - */ - // const executionId = 'abc123' - /** - * The name of the pod where the command is executed. - */ - // const pod = 'abc123' - /** - * The namespace of the pod where the command is executed. - */ - // const podNamespace = 'abc123' - /** - * Line number from which new logs should be fetched. - */ - // const nextLineNumber = 1234 - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callPollAirflowCommand() { - // Construct request - const request = { - }; - - // Run request - const response = await serviceClient.pollAirflowCommand(request); - console.log(response); - } - - callPollAirflowCommand(); - // [END composer_v1_generated_Environments_PollAirflowCommand_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.save_snapshot.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.save_snapshot.js deleted file mode 100644 index dcfce442272..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.save_snapshot.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() { - // [START composer_v1_generated_Environments_SaveSnapshot_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 resource name of the source environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - */ - // const environment = 'abc123' - /** - * Location in a Cloud Storage where the snapshot is going to be stored, e.g.: - * "gs://my-bucket/snapshots". - */ - // const snapshotLocation = 'abc123' - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callSaveSnapshot() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await serviceClient.saveSnapshot(request); - const [response] = await operation.promise(); - console.log(response); - } - - callSaveSnapshot(); - // [END composer_v1_generated_Environments_SaveSnapshot_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.stop_airflow_command.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.stop_airflow_command.js deleted file mode 100644 index 82973bd018b..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.stop_airflow_command.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() { - // [START composer_v1_generated_Environments_StopAirflowCommand_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 resource name of the environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}". - */ - // const environment = 'abc123' - /** - * The unique ID of the command execution. - */ - // const executionId = 'abc123' - /** - * The name of the pod where the command is executed. - */ - // const pod = 'abc123' - /** - * The namespace of the pod where the command is executed. - */ - // const podNamespace = 'abc123' - /** - * If true, the execution is terminated forcefully (SIGKILL). If false, the - * execution is stopped gracefully, giving it time for cleanup. - */ - // const force = true - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callStopAirflowCommand() { - // Construct request - const request = { - }; - - // Run request - const response = await serviceClient.stopAirflowCommand(request); - console.log(response); - } - - callStopAirflowCommand(); - // [END composer_v1_generated_Environments_StopAirflowCommand_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.update_environment.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.update_environment.js deleted file mode 100644 index 4f3b5d2da3c..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/environments.update_environment.js +++ /dev/null @@ -1,184 +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 composer_v1_generated_Environments_UpdateEnvironment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 relative resource name of the environment to update, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - */ - // const name = 'abc123' - /** - * A patch environment. Fields specified by the `updateMask` will be copied - * from the patch environment into the environment under update. - */ - // const environment = {} - /** - * Required. A comma-separated list of paths, relative to `Environment`, of - * fields to update. - * For example, to set the version of scikit-learn to install in the - * environment to 0.19.0 and to remove an existing installation of - * numpy, the `updateMask` parameter would include the following two - * `paths` values: "config.softwareConfig.pypiPackages.scikit-learn" and - * "config.softwareConfig.pypiPackages.numpy". The included patch - * environment would specify the scikit-learn version as follows: - * { - * "config":{ - * "softwareConfig":{ - * "pypiPackages":{ - * "scikit-learn":"==0.19.0" - * } - * } - * } - * } - * Note that in the above example, any existing PyPI packages - * other than scikit-learn and numpy will be unaffected. - * Only one update type may be included in a single request's `updateMask`. - * For example, one cannot update both the PyPI packages and - * labels in the same request. However, it is possible to update multiple - * members of a map field simultaneously in the same request. For example, - * to set the labels "label1" and "label2" while clearing "label3" (assuming - * it already exists), one can - * provide the paths "labels.label1", "labels.label2", and "labels.label3" - * and populate the patch environment as follows: - * { - * "labels":{ - * "label1":"new-label1-value" - * "label2":"new-label2-value" - * } - * } - * Note that in the above example, any existing labels that are not - * included in the `updateMask` will be unaffected. - * It is also possible to replace an entire map field by providing the - * map field's path in the `updateMask`. The new value of the field will - * be that which is provided in the patch environment. For example, to - * delete all pre-existing user-specified PyPI packages and - * install botocore at version 1.7.14, the `updateMask` would contain - * the path "config.softwareConfig.pypiPackages", and - * the patch environment would be the following: - * { - * "config":{ - * "softwareConfig":{ - * "pypiPackages":{ - * "botocore":"==1.7.14" - * } - * } - * } - * } - * **Note:** Only the following fields can be updated: - * * `config.softwareConfig.pypiPackages` - * * Replace all custom custom PyPI packages. If a replacement - * package map is not included in `environment`, all custom - * PyPI packages are cleared. It is an error to provide both - * this mask and a mask specifying an individual package. - * * `config.softwareConfig.pypiPackages.`packagename - * * Update the custom PyPI package *packagename*, - * preserving other packages. To delete the package, include it in - * `updateMask`, and omit the mapping for it in - * `environment.config.softwareConfig.pypiPackages`. It is an error - * to provide both a mask of this form and the - * `config.softwareConfig.pypiPackages` mask. - * * `labels` - * * Replace all environment labels. If a replacement labels map is not - * included in `environment`, all labels are cleared. It is an error to - * provide both this mask and a mask specifying one or more individual - * labels. - * * `labels.`labelName - * * Set the label named *labelName*, while preserving other - * labels. To delete the label, include it in `updateMask` and omit its - * mapping in `environment.labels`. It is an error to provide both a - * mask of this form and the `labels` mask. - * * `config.nodeCount` - * * Horizontally scale the number of nodes in the environment. An integer - * greater than or equal to 3 must be provided in the `config.nodeCount` - * field. Supported for Cloud Composer environments in versions - * composer-1.*.*-airflow-*.*.*. - * * `config.webServerNetworkAccessControl` - * * Replace the environment's current `WebServerNetworkAccessControl`. - * * `config.softwareConfig.airflowConfigOverrides` - * * Replace all Apache Airflow config overrides. If a replacement config - * overrides map is not included in `environment`, all config overrides - * are cleared. - * It is an error to provide both this mask and a mask specifying one or - * more individual config overrides. - * * `config.softwareConfig.airflowConfigOverrides.`section-name - * * Override the Apache Airflow config property *name* in the - * section named *section*, preserving other properties. To - * delete the property override, include it in `updateMask` and omit its - * mapping in - * `environment.config.softwareConfig.airflowConfigOverrides`. - * It is an error to provide both a mask of this form and the - * `config.softwareConfig.airflowConfigOverrides` mask. - * * `config.softwareConfig.envVariables` - * * Replace all environment variables. If a replacement environment - * variable map is not included in `environment`, all custom environment - * variables are cleared. - * * `config.softwareConfig.schedulerCount` - * * Horizontally scale the number of schedulers in Airflow. A positive - * integer not greater than the number of nodes must be provided in the - * `config.softwareConfig.schedulerCount` field. Supported for Cloud - * Composer environments in versions composer-1.*.*-airflow-2.*.*. - * * `config.databaseConfig.machineType` - * * Cloud SQL machine type used by Airflow database. - * It has to be one of: db-n1-standard-2, db-n1-standard-4, - * db-n1-standard-8 or db-n1-standard-16. Supported for Cloud Composer - * environments in versions composer-1.*.*-airflow-*.*.*. - * * `config.webServerConfig.machineType` - * * Machine type on which Airflow web server is running. - * It has to be one of: composer-n1-webserver-2, composer-n1-webserver-4 - * or composer-n1-webserver-8. Supported for Cloud Composer environments - * in versions composer-1.*.*-airflow-*.*.*. - */ - // const updateMask = {} - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callUpdateEnvironment() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await serviceClient.updateEnvironment(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateEnvironment(); - // [END composer_v1_generated_Environments_UpdateEnvironment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/image_versions.list_image_versions.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/image_versions.list_image_versions.js deleted file mode 100644 index 89c1b917345..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/image_versions.list_image_versions.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() { - // [START composer_v1_generated_ImageVersions_ListImageVersions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * List ImageVersions in the given project and location, in the form: - * "projects/{projectId}/locations/{locationId}" - */ - // const parent = 'abc123' - /** - * The maximum number of image_versions to return. - */ - // const pageSize = 1234 - /** - * The next_page_token value returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - /** - * Whether or not image versions from old releases should be included. - */ - // const includePastReleases = true - - // Imports the Service library - const {ImageVersionsClient} = require('@google-cloud/orchestration-airflow').v1; - - // Instantiates a client - const serviceClient = new ImageVersionsClient(); - - async function callListImageVersions() { - // Construct request - const request = { - }; - - // Run request - const iterable = await serviceClient.listImageVersionsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListImageVersions(); - // [END composer_v1_generated_ImageVersions_ListImageVersions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/snippet_metadata_google.cloud.orchestration.airflow.service.v1.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/snippet_metadata_google.cloud.orchestration.airflow.service.v1.json deleted file mode 100644 index 90fa8df7f10..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/samples/generated/v1/snippet_metadata_google.cloud.orchestration.airflow.service.v1.json +++ /dev/null @@ -1,635 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-service", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.orchestration.airflow.service.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "composer_v1_generated_Environments_CreateEnvironment_async", - "title": "Environments createEnvironment Sample", - "origin": "API_DEFINITION", - "description": " Create a new environment.", - "canonical": true, - "file": "environments.create_environment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateEnvironment", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.CreateEnvironment", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "environment", - "type": ".google.cloud.orchestration.airflow.service.v1.Environment" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" - }, - "method": { - "shortName": "CreateEnvironment", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.CreateEnvironment", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1_generated_Environments_GetEnvironment_async", - "title": "Environments getEnvironment Sample", - "origin": "API_DEFINITION", - "description": " Get an existing environment.", - "canonical": true, - "file": "environments.get_environment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetEnvironment", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.GetEnvironment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.orchestration.airflow.service.v1.Environment", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" - }, - "method": { - "shortName": "GetEnvironment", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.GetEnvironment", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1_generated_Environments_ListEnvironments_async", - "title": "Environments listEnvironments Sample", - "origin": "API_DEFINITION", - "description": " List environments.", - "canonical": true, - "file": "environments.list_environments.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListEnvironments", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.ListEnvironments", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.orchestration.airflow.service.v1.ListEnvironmentsResponse", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" - }, - "method": { - "shortName": "ListEnvironments", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.ListEnvironments", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1_generated_Environments_UpdateEnvironment_async", - "title": "Environments updateEnvironment Sample", - "origin": "API_DEFINITION", - "description": " Update an environment.", - "canonical": true, - "file": "environments.update_environment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 176, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateEnvironment", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.UpdateEnvironment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "environment", - "type": ".google.cloud.orchestration.airflow.service.v1.Environment" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" - }, - "method": { - "shortName": "UpdateEnvironment", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.UpdateEnvironment", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1_generated_Environments_DeleteEnvironment_async", - "title": "Environments deleteEnvironment Sample", - "origin": "API_DEFINITION", - "description": " Delete an environment.", - "canonical": true, - "file": "environments.delete_environment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteEnvironment", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.DeleteEnvironment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" - }, - "method": { - "shortName": "DeleteEnvironment", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.DeleteEnvironment", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1_generated_Environments_ExecuteAirflowCommand_async", - "title": "Environments executeAirflowCommand Sample", - "origin": "API_DEFINITION", - "description": " Executes Airflow CLI command.", - "canonical": true, - "file": "environments.execute_airflow_command.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ExecuteAirflowCommand", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.ExecuteAirflowCommand", - "async": true, - "parameters": [ - { - "name": "environment", - "type": "TYPE_STRING" - }, - { - "name": "command", - "type": "TYPE_STRING" - }, - { - "name": "subcommand", - "type": "TYPE_STRING" - }, - { - "name": "parameters", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandResponse", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" - }, - "method": { - "shortName": "ExecuteAirflowCommand", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.ExecuteAirflowCommand", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1_generated_Environments_StopAirflowCommand_async", - "title": "Environments stopAirflowCommand Sample", - "origin": "API_DEFINITION", - "description": " Stops Airflow CLI command execution.", - "canonical": true, - "file": "environments.stop_airflow_command.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "StopAirflowCommand", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.StopAirflowCommand", - "async": true, - "parameters": [ - { - "name": "environment", - "type": "TYPE_STRING" - }, - { - "name": "execution_id", - "type": "TYPE_STRING" - }, - { - "name": "pod", - "type": "TYPE_STRING" - }, - { - "name": "pod_namespace", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.orchestration.airflow.service.v1.StopAirflowCommandResponse", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" - }, - "method": { - "shortName": "StopAirflowCommand", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.StopAirflowCommand", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1_generated_Environments_PollAirflowCommand_async", - "title": "Environments pollAirflowCommand Sample", - "origin": "API_DEFINITION", - "description": " Polls Airflow CLI command execution and fetches logs.", - "canonical": true, - "file": "environments.poll_airflow_command.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PollAirflowCommand", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.PollAirflowCommand", - "async": true, - "parameters": [ - { - "name": "environment", - "type": "TYPE_STRING" - }, - { - "name": "execution_id", - "type": "TYPE_STRING" - }, - { - "name": "pod", - "type": "TYPE_STRING" - }, - { - "name": "pod_namespace", - "type": "TYPE_STRING" - }, - { - "name": "next_line_number", - "type": "TYPE_INT32" - } - ], - "resultType": ".google.cloud.orchestration.airflow.service.v1.PollAirflowCommandResponse", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" - }, - "method": { - "shortName": "PollAirflowCommand", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.PollAirflowCommand", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1_generated_Environments_SaveSnapshot_async", - "title": "Environments saveSnapshot Sample", - "origin": "API_DEFINITION", - "description": " Creates a snapshots of a Cloud Composer environment. As a result of this operation, snapshot of environment's state is stored in a location specified in the SaveSnapshotRequest.", - "canonical": true, - "file": "environments.save_snapshot.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SaveSnapshot", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.SaveSnapshot", - "async": true, - "parameters": [ - { - "name": "environment", - "type": "TYPE_STRING" - }, - { - "name": "snapshot_location", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" - }, - "method": { - "shortName": "SaveSnapshot", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.SaveSnapshot", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1_generated_Environments_LoadSnapshot_async", - "title": "Environments loadSnapshot Sample", - "origin": "API_DEFINITION", - "description": " Loads a snapshot of a Cloud Composer environment. As a result of this operation, a snapshot of environment's specified in LoadSnapshotRequest is loaded into the environment.", - "canonical": true, - "file": "environments.load_snapshot.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 79, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "LoadSnapshot", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.LoadSnapshot", - "async": true, - "parameters": [ - { - "name": "environment", - "type": "TYPE_STRING" - }, - { - "name": "snapshot_path", - "type": "TYPE_STRING" - }, - { - "name": "skip_pypi_packages_installation", - "type": "TYPE_BOOL" - }, - { - "name": "skip_environment_variables_setting", - "type": "TYPE_BOOL" - }, - { - "name": "skip_airflow_overrides_setting", - "type": "TYPE_BOOL" - }, - { - "name": "skip_gcs_data_copying", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" - }, - "method": { - "shortName": "LoadSnapshot", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.LoadSnapshot", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1_generated_Environments_DatabaseFailover_async", - "title": "Environments databaseFailover Sample", - "origin": "API_DEFINITION", - "description": " Triggers database failover (only for highly resilient environments).", - "canonical": true, - "file": "environments.database_failover.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DatabaseFailover", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.DatabaseFailover", - "async": true, - "parameters": [ - { - "name": "environment", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" - }, - "method": { - "shortName": "DatabaseFailover", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.DatabaseFailover", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1_generated_Environments_FetchDatabaseProperties_async", - "title": "Environments fetchDatabaseProperties Sample", - "origin": "API_DEFINITION", - "description": " Fetches database properties.", - "canonical": true, - "file": "environments.fetch_database_properties.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "FetchDatabaseProperties", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.FetchDatabaseProperties", - "async": true, - "parameters": [ - { - "name": "environment", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesResponse", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1.EnvironmentsClient" - }, - "method": { - "shortName": "FetchDatabaseProperties", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments.FetchDatabaseProperties", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1_generated_ImageVersions_ListImageVersions_async", - "title": "Environments listImageVersions Sample", - "origin": "API_DEFINITION", - "description": " List ImageVersions for provided location.", - "canonical": true, - "file": "image_versions.list_image_versions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListImageVersions", - "fullName": "google.cloud.orchestration.airflow.service.v1.ImageVersions.ListImageVersions", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "include_past_releases", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.orchestration.airflow.service.v1.ListImageVersionsResponse", - "client": { - "shortName": "ImageVersionsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1.ImageVersionsClient" - }, - "method": { - "shortName": "ListImageVersions", - "fullName": "google.cloud.orchestration.airflow.service.v1.ImageVersions.ListImageVersions", - "service": { - "shortName": "ImageVersions", - "fullName": "google.cloud.orchestration.airflow.service.v1.ImageVersions" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/index.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/index.ts deleted file mode 100644 index 797920b268e..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/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. ** - -import * as v1 from './v1'; -const EnvironmentsClient = v1.EnvironmentsClient; -type EnvironmentsClient = v1.EnvironmentsClient; -const ImageVersionsClient = v1.ImageVersionsClient; -type ImageVersionsClient = v1.ImageVersionsClient; -export {v1, EnvironmentsClient, ImageVersionsClient}; -export default {v1, EnvironmentsClient, ImageVersionsClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_client.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_client.ts deleted file mode 100644 index 7df3705e8a6..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_client.ts +++ /dev/null @@ -1,1867 +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} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/environments_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './environments_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Managed Apache Airflow Environments. - * @class - * @memberof v1 - */ -export class EnvironmentsClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - environmentsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of EnvironmentsClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 EnvironmentsClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof EnvironmentsClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - environmentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/environments/{environment}' - ), - }; - - // 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 = { - listEnvironments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'environments') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createEnvironmentResponse = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1.Environment') as gax.protobuf.Type; - const createEnvironmentMetadata = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1.OperationMetadata') as gax.protobuf.Type; - const updateEnvironmentResponse = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1.Environment') as gax.protobuf.Type; - const updateEnvironmentMetadata = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1.OperationMetadata') as gax.protobuf.Type; - const deleteEnvironmentResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteEnvironmentMetadata = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1.OperationMetadata') as gax.protobuf.Type; - const saveSnapshotResponse = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1.SaveSnapshotResponse') as gax.protobuf.Type; - const saveSnapshotMetadata = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1.OperationMetadata') as gax.protobuf.Type; - const loadSnapshotResponse = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1.LoadSnapshotResponse') as gax.protobuf.Type; - const loadSnapshotMetadata = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1.OperationMetadata') as gax.protobuf.Type; - const databaseFailoverResponse = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1.DatabaseFailoverResponse') as gax.protobuf.Type; - const databaseFailoverMetadata = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createEnvironment: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createEnvironmentResponse.decode.bind(createEnvironmentResponse), - createEnvironmentMetadata.decode.bind(createEnvironmentMetadata)), - updateEnvironment: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateEnvironmentResponse.decode.bind(updateEnvironmentResponse), - updateEnvironmentMetadata.decode.bind(updateEnvironmentMetadata)), - deleteEnvironment: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteEnvironmentResponse.decode.bind(deleteEnvironmentResponse), - deleteEnvironmentMetadata.decode.bind(deleteEnvironmentMetadata)), - saveSnapshot: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - saveSnapshotResponse.decode.bind(saveSnapshotResponse), - saveSnapshotMetadata.decode.bind(saveSnapshotMetadata)), - loadSnapshot: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - loadSnapshotResponse.decode.bind(loadSnapshotResponse), - loadSnapshotMetadata.decode.bind(loadSnapshotMetadata)), - databaseFailover: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - databaseFailoverResponse.decode.bind(databaseFailoverResponse), - databaseFailoverMetadata.decode.bind(databaseFailoverMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.orchestration.airflow.service.v1.Environments', 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.environmentsStub) { - return this.environmentsStub; - } - - // Put together the "service stub" for - // google.cloud.orchestration.airflow.service.v1.Environments. - this.environmentsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.orchestration.airflow.service.v1.Environments') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.orchestration.airflow.service.v1.Environments, - 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 environmentsStubMethods = - ['createEnvironment', 'getEnvironment', 'listEnvironments', 'updateEnvironment', 'deleteEnvironment', 'executeAirflowCommand', 'stopAirflowCommand', 'pollAirflowCommand', 'saveSnapshot', 'loadSnapshot', 'databaseFailover', 'fetchDatabaseProperties']; - for (const methodName of environmentsStubMethods) { - const callPromise = this.environmentsStub.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.environmentsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'composer.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 'composer.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 -- - // ------------------- -/** - * Get an existing environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource name of the environment to get, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.orchestration.airflow.service.v1.Environment|Environment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/environments.get_environment.js - * region_tag:composer_v1_generated_Environments_GetEnvironment_async - */ - getEnvironment( - request?: protos.google.cloud.orchestration.airflow.service.v1.IGetEnvironmentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1.IEnvironment, - protos.google.cloud.orchestration.airflow.service.v1.IGetEnvironmentRequest|undefined, {}|undefined - ]>; - getEnvironment( - request: protos.google.cloud.orchestration.airflow.service.v1.IGetEnvironmentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.orchestration.airflow.service.v1.IEnvironment, - protos.google.cloud.orchestration.airflow.service.v1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>): void; - getEnvironment( - request: protos.google.cloud.orchestration.airflow.service.v1.IGetEnvironmentRequest, - callback: Callback< - protos.google.cloud.orchestration.airflow.service.v1.IEnvironment, - protos.google.cloud.orchestration.airflow.service.v1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>): void; - getEnvironment( - request?: protos.google.cloud.orchestration.airflow.service.v1.IGetEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.orchestration.airflow.service.v1.IEnvironment, - protos.google.cloud.orchestration.airflow.service.v1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.orchestration.airflow.service.v1.IEnvironment, - protos.google.cloud.orchestration.airflow.service.v1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1.IEnvironment, - protos.google.cloud.orchestration.airflow.service.v1.IGetEnvironmentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getEnvironment(request, options, callback); - } -/** - * Executes Airflow CLI command. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.environment - * The resource name of the environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}". - * @param {string} request.command - * Airflow command. - * @param {string} request.subcommand - * Airflow subcommand. - * @param {string[]} request.parameters - * Parameters for the Airflow command/subcommand as an array of arguments. - * It may contain positional arguments like `["my-dag-id"]`, key-value - * parameters like `["--foo=bar"]` or `["--foo","bar"]`, - * or other flags like `["-f"]`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandResponse|ExecuteAirflowCommandResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/environments.execute_airflow_command.js - * region_tag:composer_v1_generated_Environments_ExecuteAirflowCommand_async - */ - executeAirflowCommand( - request?: protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandRequest|undefined, {}|undefined - ]>; - executeAirflowCommand( - request: protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandRequest|null|undefined, - {}|null|undefined>): void; - executeAirflowCommand( - request: protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandRequest, - callback: Callback< - protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandRequest|null|undefined, - {}|null|undefined>): void; - executeAirflowCommand( - request?: protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'environment': request.environment ?? '', - }); - this.initialize(); - return this.innerApiCalls.executeAirflowCommand(request, options, callback); - } -/** - * Stops Airflow CLI command execution. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.environment - * The resource name of the environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}". - * @param {string} request.executionId - * The unique ID of the command execution. - * @param {string} request.pod - * The name of the pod where the command is executed. - * @param {string} request.podNamespace - * The namespace of the pod where the command is executed. - * @param {boolean} request.force - * If true, the execution is terminated forcefully (SIGKILL). If false, the - * execution is stopped gracefully, giving it time for cleanup. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandResponse|StopAirflowCommandResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/environments.stop_airflow_command.js - * region_tag:composer_v1_generated_Environments_StopAirflowCommand_async - */ - stopAirflowCommand( - request?: protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandRequest|undefined, {}|undefined - ]>; - stopAirflowCommand( - request: protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandRequest|null|undefined, - {}|null|undefined>): void; - stopAirflowCommand( - request: protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandRequest, - callback: Callback< - protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandRequest|null|undefined, - {}|null|undefined>): void; - stopAirflowCommand( - request?: protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'environment': request.environment ?? '', - }); - this.initialize(); - return this.innerApiCalls.stopAirflowCommand(request, options, callback); - } -/** - * Polls Airflow CLI command execution and fetches logs. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.environment - * The resource name of the environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @param {string} request.executionId - * The unique ID of the command execution. - * @param {string} request.pod - * The name of the pod where the command is executed. - * @param {string} request.podNamespace - * The namespace of the pod where the command is executed. - * @param {number} request.nextLineNumber - * Line number from which new logs should be fetched. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandResponse|PollAirflowCommandResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/environments.poll_airflow_command.js - * region_tag:composer_v1_generated_Environments_PollAirflowCommand_async - */ - pollAirflowCommand( - request?: protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandRequest|undefined, {}|undefined - ]>; - pollAirflowCommand( - request: protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandRequest|null|undefined, - {}|null|undefined>): void; - pollAirflowCommand( - request: protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandRequest, - callback: Callback< - protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandRequest|null|undefined, - {}|null|undefined>): void; - pollAirflowCommand( - request?: protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'environment': request.environment ?? '', - }); - this.initialize(); - return this.innerApiCalls.pollAirflowCommand(request, options, callback); - } -/** - * Fetches database properties. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.environment - * Required. The resource name of the environment, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesResponse|FetchDatabasePropertiesResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/environments.fetch_database_properties.js - * region_tag:composer_v1_generated_Environments_FetchDatabaseProperties_async - */ - fetchDatabaseProperties( - request?: protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesResponse, - protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesRequest|undefined, {}|undefined - ]>; - fetchDatabaseProperties( - request: protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesResponse, - protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesRequest|null|undefined, - {}|null|undefined>): void; - fetchDatabaseProperties( - request: protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesRequest, - callback: Callback< - protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesResponse, - protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesRequest|null|undefined, - {}|null|undefined>): void; - fetchDatabaseProperties( - request?: protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesResponse, - protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesResponse, - protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesResponse, - protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'environment': request.environment ?? '', - }); - this.initialize(); - return this.innerApiCalls.fetchDatabaseProperties(request, options, callback); - } - -/** - * Create a new environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The parent must be of the form - * "projects/{projectId}/locations/{locationId}". - * @param {google.cloud.orchestration.airflow.service.v1.Environment} request.environment - * The environment to create. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/environments.create_environment.js - * region_tag:composer_v1_generated_Environments_CreateEnvironment_async - */ - createEnvironment( - request?: protos.google.cloud.orchestration.airflow.service.v1.ICreateEnvironmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createEnvironment( - request: protos.google.cloud.orchestration.airflow.service.v1.ICreateEnvironmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createEnvironment( - request: protos.google.cloud.orchestration.airflow.service.v1.ICreateEnvironmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createEnvironment( - request?: protos.google.cloud.orchestration.airflow.service.v1.ICreateEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createEnvironment(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createEnvironment()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/environments.create_environment.js - * region_tag:composer_v1_generated_Environments_CreateEnvironment_async - */ - async checkCreateEnvironmentProgress(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.createEnvironment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Update an environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The relative resource name of the environment to update, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @param {google.cloud.orchestration.airflow.service.v1.Environment} request.environment - * A patch environment. Fields specified by the `updateMask` will be copied - * from the patch environment into the environment under update. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. A comma-separated list of paths, relative to `Environment`, of - * fields to update. - * For example, to set the version of scikit-learn to install in the - * environment to 0.19.0 and to remove an existing installation of - * numpy, the `updateMask` parameter would include the following two - * `paths` values: "config.softwareConfig.pypiPackages.scikit-learn" and - * "config.softwareConfig.pypiPackages.numpy". The included patch - * environment would specify the scikit-learn version as follows: - * - * { - * "config":{ - * "softwareConfig":{ - * "pypiPackages":{ - * "scikit-learn":"==0.19.0" - * } - * } - * } - * } - * - * Note that in the above example, any existing PyPI packages - * other than scikit-learn and numpy will be unaffected. - * - * Only one update type may be included in a single request's `updateMask`. - * For example, one cannot update both the PyPI packages and - * labels in the same request. However, it is possible to update multiple - * members of a map field simultaneously in the same request. For example, - * to set the labels "label1" and "label2" while clearing "label3" (assuming - * it already exists), one can - * provide the paths "labels.label1", "labels.label2", and "labels.label3" - * and populate the patch environment as follows: - * - * { - * "labels":{ - * "label1":"new-label1-value" - * "label2":"new-label2-value" - * } - * } - * - * Note that in the above example, any existing labels that are not - * included in the `updateMask` will be unaffected. - * - * It is also possible to replace an entire map field by providing the - * map field's path in the `updateMask`. The new value of the field will - * be that which is provided in the patch environment. For example, to - * delete all pre-existing user-specified PyPI packages and - * install botocore at version 1.7.14, the `updateMask` would contain - * the path "config.softwareConfig.pypiPackages", and - * the patch environment would be the following: - * - * { - * "config":{ - * "softwareConfig":{ - * "pypiPackages":{ - * "botocore":"==1.7.14" - * } - * } - * } - * } - * - * **Note:** Only the following fields can be updated: - * - * * `config.softwareConfig.pypiPackages` - * * Replace all custom custom PyPI packages. If a replacement - * package map is not included in `environment`, all custom - * PyPI packages are cleared. It is an error to provide both - * this mask and a mask specifying an individual package. - * * `config.softwareConfig.pypiPackages.`packagename - * * Update the custom PyPI package *packagename*, - * preserving other packages. To delete the package, include it in - * `updateMask`, and omit the mapping for it in - * `environment.config.softwareConfig.pypiPackages`. It is an error - * to provide both a mask of this form and the - * `config.softwareConfig.pypiPackages` mask. - * * `labels` - * * Replace all environment labels. If a replacement labels map is not - * included in `environment`, all labels are cleared. It is an error to - * provide both this mask and a mask specifying one or more individual - * labels. - * * `labels.`labelName - * * Set the label named *labelName*, while preserving other - * labels. To delete the label, include it in `updateMask` and omit its - * mapping in `environment.labels`. It is an error to provide both a - * mask of this form and the `labels` mask. - * * `config.nodeCount` - * * Horizontally scale the number of nodes in the environment. An integer - * greater than or equal to 3 must be provided in the `config.nodeCount` - * field. Supported for Cloud Composer environments in versions - * composer-1.*.*-airflow-*.*.*. - * * `config.webServerNetworkAccessControl` - * * Replace the environment's current `WebServerNetworkAccessControl`. - * * `config.softwareConfig.airflowConfigOverrides` - * * Replace all Apache Airflow config overrides. If a replacement config - * overrides map is not included in `environment`, all config overrides - * are cleared. - * It is an error to provide both this mask and a mask specifying one or - * more individual config overrides. - * * `config.softwareConfig.airflowConfigOverrides.`section-name - * * Override the Apache Airflow config property *name* in the - * section named *section*, preserving other properties. To - * delete the property override, include it in `updateMask` and omit its - * mapping in - * `environment.config.softwareConfig.airflowConfigOverrides`. - * It is an error to provide both a mask of this form and the - * `config.softwareConfig.airflowConfigOverrides` mask. - * * `config.softwareConfig.envVariables` - * * Replace all environment variables. If a replacement environment - * variable map is not included in `environment`, all custom environment - * variables are cleared. - * * `config.softwareConfig.schedulerCount` - * * Horizontally scale the number of schedulers in Airflow. A positive - * integer not greater than the number of nodes must be provided in the - * `config.softwareConfig.schedulerCount` field. Supported for Cloud - * Composer environments in versions composer-1.*.*-airflow-2.*.*. - * * `config.databaseConfig.machineType` - * * Cloud SQL machine type used by Airflow database. - * It has to be one of: db-n1-standard-2, db-n1-standard-4, - * db-n1-standard-8 or db-n1-standard-16. Supported for Cloud Composer - * environments in versions composer-1.*.*-airflow-*.*.*. - * * `config.webServerConfig.machineType` - * * Machine type on which Airflow web server is running. - * It has to be one of: composer-n1-webserver-2, composer-n1-webserver-4 - * or composer-n1-webserver-8. Supported for Cloud Composer environments - * in versions composer-1.*.*-airflow-*.*.*. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/environments.update_environment.js - * region_tag:composer_v1_generated_Environments_UpdateEnvironment_async - */ - updateEnvironment( - request?: protos.google.cloud.orchestration.airflow.service.v1.IUpdateEnvironmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateEnvironment( - request: protos.google.cloud.orchestration.airflow.service.v1.IUpdateEnvironmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateEnvironment( - request: protos.google.cloud.orchestration.airflow.service.v1.IUpdateEnvironmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateEnvironment( - request?: protos.google.cloud.orchestration.airflow.service.v1.IUpdateEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateEnvironment(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateEnvironment()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/environments.update_environment.js - * region_tag:composer_v1_generated_Environments_UpdateEnvironment_async - */ - async checkUpdateEnvironmentProgress(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.updateEnvironment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Delete an environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The environment to delete, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/environments.delete_environment.js - * region_tag:composer_v1_generated_Environments_DeleteEnvironment_async - */ - deleteEnvironment( - request?: protos.google.cloud.orchestration.airflow.service.v1.IDeleteEnvironmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteEnvironment( - request: protos.google.cloud.orchestration.airflow.service.v1.IDeleteEnvironmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteEnvironment( - request: protos.google.cloud.orchestration.airflow.service.v1.IDeleteEnvironmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteEnvironment( - request?: protos.google.cloud.orchestration.airflow.service.v1.IDeleteEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteEnvironment(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteEnvironment()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/environments.delete_environment.js - * region_tag:composer_v1_generated_Environments_DeleteEnvironment_async - */ - async checkDeleteEnvironmentProgress(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.deleteEnvironment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Creates a snapshots of a Cloud Composer environment. - * - * As a result of this operation, snapshot of environment's state is stored - * in a location specified in the SaveSnapshotRequest. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.environment - * The resource name of the source environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @param {string} request.snapshotLocation - * Location in a Cloud Storage where the snapshot is going to be stored, e.g.: - * "gs://my-bucket/snapshots". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/environments.save_snapshot.js - * region_tag:composer_v1_generated_Environments_SaveSnapshot_async - */ - saveSnapshot( - request?: protos.google.cloud.orchestration.airflow.service.v1.ISaveSnapshotRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - saveSnapshot( - request: protos.google.cloud.orchestration.airflow.service.v1.ISaveSnapshotRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - saveSnapshot( - request: protos.google.cloud.orchestration.airflow.service.v1.ISaveSnapshotRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - saveSnapshot( - request?: protos.google.cloud.orchestration.airflow.service.v1.ISaveSnapshotRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'environment': request.environment ?? '', - }); - this.initialize(); - return this.innerApiCalls.saveSnapshot(request, options, callback); - } -/** - * Check the status of the long running operation returned by `saveSnapshot()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/environments.save_snapshot.js - * region_tag:composer_v1_generated_Environments_SaveSnapshot_async - */ - async checkSaveSnapshotProgress(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.saveSnapshot, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Loads a snapshot of a Cloud Composer environment. - * - * As a result of this operation, a snapshot of environment's specified in - * LoadSnapshotRequest is loaded into the environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.environment - * The resource name of the target environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @param {string} request.snapshotPath - * A Cloud Storage path to a snapshot to load, e.g.: - * "gs://my-bucket/snapshots/project_location_environment_timestamp". - * @param {boolean} request.skipPypiPackagesInstallation - * Whether or not to skip installing Pypi packages when loading the - * environment's state. - * @param {boolean} request.skipEnvironmentVariablesSetting - * Whether or not to skip setting environment variables when loading the - * environment's state. - * @param {boolean} request.skipAirflowOverridesSetting - * Whether or not to skip setting Airflow overrides when loading the - * environment's state. - * @param {boolean} request.skipGcsDataCopying - * Whether or not to skip copying Cloud Storage data when loading the - * environment's state. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/environments.load_snapshot.js - * region_tag:composer_v1_generated_Environments_LoadSnapshot_async - */ - loadSnapshot( - request?: protos.google.cloud.orchestration.airflow.service.v1.ILoadSnapshotRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - loadSnapshot( - request: protos.google.cloud.orchestration.airflow.service.v1.ILoadSnapshotRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - loadSnapshot( - request: protos.google.cloud.orchestration.airflow.service.v1.ILoadSnapshotRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - loadSnapshot( - request?: protos.google.cloud.orchestration.airflow.service.v1.ILoadSnapshotRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'environment': request.environment ?? '', - }); - this.initialize(); - return this.innerApiCalls.loadSnapshot(request, options, callback); - } -/** - * Check the status of the long running operation returned by `loadSnapshot()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/environments.load_snapshot.js - * region_tag:composer_v1_generated_Environments_LoadSnapshot_async - */ - async checkLoadSnapshotProgress(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.loadSnapshot, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Triggers database failover (only for highly resilient environments). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.environment - * Target environment: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/environments.database_failover.js - * region_tag:composer_v1_generated_Environments_DatabaseFailover_async - */ - databaseFailover( - request?: protos.google.cloud.orchestration.airflow.service.v1.IDatabaseFailoverRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - databaseFailover( - request: protos.google.cloud.orchestration.airflow.service.v1.IDatabaseFailoverRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - databaseFailover( - request: protos.google.cloud.orchestration.airflow.service.v1.IDatabaseFailoverRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - databaseFailover( - request?: protos.google.cloud.orchestration.airflow.service.v1.IDatabaseFailoverRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'environment': request.environment ?? '', - }); - this.initialize(); - return this.innerApiCalls.databaseFailover(request, options, callback); - } -/** - * Check the status of the long running operation returned by `databaseFailover()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/environments.database_failover.js - * region_tag:composer_v1_generated_Environments_DatabaseFailover_async - */ - async checkDatabaseFailoverProgress(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.databaseFailover, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * List environments. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * List environments in the given project and location, in the form: - * "projects/{projectId}/locations/{locationId}" - * @param {number} request.pageSize - * The maximum number of environments to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.orchestration.airflow.service.v1.Environment|Environment}. - * 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 `listEnvironmentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listEnvironments( - request?: protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1.IEnvironment[], - protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest|null, - protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsResponse - ]>; - listEnvironments( - request: protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest, - protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.orchestration.airflow.service.v1.IEnvironment>): void; - listEnvironments( - request: protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest, - callback: PaginationCallback< - protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest, - protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.orchestration.airflow.service.v1.IEnvironment>): void; - listEnvironments( - request?: protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest, - protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.orchestration.airflow.service.v1.IEnvironment>, - callback?: PaginationCallback< - protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest, - protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.orchestration.airflow.service.v1.IEnvironment>): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1.IEnvironment[], - protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest|null, - protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listEnvironments(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 - * List environments in the given project and location, in the form: - * "projects/{projectId}/locations/{locationId}" - * @param {number} request.pageSize - * The maximum number of environments to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.orchestration.airflow.service.v1.Environment|Environment} 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 `listEnvironmentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listEnvironmentsStream( - request?: protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest, - 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['listEnvironments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listEnvironments.createStream( - this.innerApiCalls.listEnvironments as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listEnvironments`, 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 - * List environments in the given project and location, in the form: - * "projects/{projectId}/locations/{locationId}" - * @param {number} request.pageSize - * The maximum number of environments to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.orchestration.airflow.service.v1.Environment|Environment}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/environments.list_environments.js - * region_tag:composer_v1_generated_Environments_ListEnvironments_async - */ - listEnvironmentsAsync( - request?: protos.google.cloud.orchestration.airflow.service.v1.IListEnvironmentsRequest, - 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['listEnvironments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listEnvironments.asyncIterate( - this.innerApiCalls['listEnvironments'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * 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 environment resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} environment - * @returns {string} Resource name string. - */ - environmentPath(project:string,location:string,environment:string) { - return this.pathTemplates.environmentPathTemplate.render({ - project: project, - location: location, - environment: environment, - }); - } - - /** - * Parse the project from Environment resource. - * - * @param {string} environmentName - * A fully-qualified path representing Environment resource. - * @returns {string} A string representing the project. - */ - matchProjectFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).project; - } - - /** - * Parse the location from Environment resource. - * - * @param {string} environmentName - * A fully-qualified path representing Environment resource. - * @returns {string} A string representing the location. - */ - matchLocationFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).location; - } - - /** - * Parse the environment from Environment resource. - * - * @param {string} environmentName - * A fully-qualified path representing Environment resource. - * @returns {string} A string representing the environment. - */ - matchEnvironmentFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).environment; - } - - /** - * 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.environmentsStub && !this._terminated) { - return this.environmentsStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_client_config.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_client_config.json deleted file mode 100644 index f6e68e30717..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_client_config.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "interfaces": { - "google.cloud.orchestration.airflow.service.v1.Environments": { - "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": { - "CreateEnvironment": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetEnvironment": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListEnvironments": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateEnvironment": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteEnvironment": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ExecuteAirflowCommand": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "StopAirflowCommand": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "PollAirflowCommand": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "SaveSnapshot": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "LoadSnapshot": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DatabaseFailover": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "FetchDatabaseProperties": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_proto_list.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_proto_list.json deleted file mode 100644 index 674df9932cf..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/environments_proto_list.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - "../../protos/google/cloud/orchestration/airflow/service/v1/environments.proto", - "../../protos/google/cloud/orchestration/airflow/service/v1/image_versions.proto", - "../../protos/google/cloud/orchestration/airflow/service/v1/operations.proto" -] diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 0ab43de4e60..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,175 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.orchestration.airflow.service.v1", - "libraryPackage": "@google-cloud/orchestration-airflow", - "services": { - "Environments": { - "clients": { - "grpc": { - "libraryClient": "EnvironmentsClient", - "rpcs": { - "GetEnvironment": { - "methods": [ - "getEnvironment" - ] - }, - "ExecuteAirflowCommand": { - "methods": [ - "executeAirflowCommand" - ] - }, - "StopAirflowCommand": { - "methods": [ - "stopAirflowCommand" - ] - }, - "PollAirflowCommand": { - "methods": [ - "pollAirflowCommand" - ] - }, - "FetchDatabaseProperties": { - "methods": [ - "fetchDatabaseProperties" - ] - }, - "CreateEnvironment": { - "methods": [ - "createEnvironment" - ] - }, - "UpdateEnvironment": { - "methods": [ - "updateEnvironment" - ] - }, - "DeleteEnvironment": { - "methods": [ - "deleteEnvironment" - ] - }, - "SaveSnapshot": { - "methods": [ - "saveSnapshot" - ] - }, - "LoadSnapshot": { - "methods": [ - "loadSnapshot" - ] - }, - "DatabaseFailover": { - "methods": [ - "databaseFailover" - ] - }, - "ListEnvironments": { - "methods": [ - "listEnvironments", - "listEnvironmentsStream", - "listEnvironmentsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "EnvironmentsClient", - "rpcs": { - "GetEnvironment": { - "methods": [ - "getEnvironment" - ] - }, - "ExecuteAirflowCommand": { - "methods": [ - "executeAirflowCommand" - ] - }, - "StopAirflowCommand": { - "methods": [ - "stopAirflowCommand" - ] - }, - "PollAirflowCommand": { - "methods": [ - "pollAirflowCommand" - ] - }, - "FetchDatabaseProperties": { - "methods": [ - "fetchDatabaseProperties" - ] - }, - "CreateEnvironment": { - "methods": [ - "createEnvironment" - ] - }, - "UpdateEnvironment": { - "methods": [ - "updateEnvironment" - ] - }, - "DeleteEnvironment": { - "methods": [ - "deleteEnvironment" - ] - }, - "SaveSnapshot": { - "methods": [ - "saveSnapshot" - ] - }, - "LoadSnapshot": { - "methods": [ - "loadSnapshot" - ] - }, - "DatabaseFailover": { - "methods": [ - "databaseFailover" - ] - }, - "ListEnvironments": { - "methods": [ - "listEnvironments", - "listEnvironmentsStream", - "listEnvironmentsAsync" - ] - } - } - } - } - }, - "ImageVersions": { - "clients": { - "grpc": { - "libraryClient": "ImageVersionsClient", - "rpcs": { - "ListImageVersions": { - "methods": [ - "listImageVersions", - "listImageVersionsStream", - "listImageVersionsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageVersionsClient", - "rpcs": { - "ListImageVersions": { - "methods": [ - "listImageVersions", - "listImageVersionsStream", - "listImageVersionsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_client.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_client.ts deleted file mode 100644 index b5ec371ebed..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_client.ts +++ /dev/null @@ -1,556 +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, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/image_versions_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_versions_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Readonly service to query available ImageVersions. - * @class - * @memberof v1 - */ -export class ImageVersionsClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - imageVersionsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageVersionsClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 ImageVersionsClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ImageVersionsClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - environmentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/environments/{environment}' - ), - }; - - // 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 = { - listImageVersions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'imageVersions') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.orchestration.airflow.service.v1.ImageVersions', 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.imageVersionsStub) { - return this.imageVersionsStub; - } - - // Put together the "service stub" for - // google.cloud.orchestration.airflow.service.v1.ImageVersions. - this.imageVersionsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.orchestration.airflow.service.v1.ImageVersions') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.orchestration.airflow.service.v1.ImageVersions, - 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 imageVersionsStubMethods = - ['listImageVersions']; - for (const methodName of imageVersionsStubMethods) { - const callPromise = this.imageVersionsStub.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.imageVersionsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'composer.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 'composer.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 -- - // ------------------- - - /** - * List ImageVersions for provided location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * List ImageVersions in the given project and location, in the form: - * "projects/{projectId}/locations/{locationId}" - * @param {number} request.pageSize - * The maximum number of image_versions to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {boolean} request.includePastReleases - * Whether or not image versions from old releases should be included. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.orchestration.airflow.service.v1.ImageVersion|ImageVersion}. - * 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 `listImageVersionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listImageVersions( - request?: protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1.IImageVersion[], - protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest|null, - protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsResponse - ]>; - listImageVersions( - request: protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest, - protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsResponse|null|undefined, - protos.google.cloud.orchestration.airflow.service.v1.IImageVersion>): void; - listImageVersions( - request: protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest, - callback: PaginationCallback< - protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest, - protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsResponse|null|undefined, - protos.google.cloud.orchestration.airflow.service.v1.IImageVersion>): void; - listImageVersions( - request?: protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest, - protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsResponse|null|undefined, - protos.google.cloud.orchestration.airflow.service.v1.IImageVersion>, - callback?: PaginationCallback< - protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest, - protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsResponse|null|undefined, - protos.google.cloud.orchestration.airflow.service.v1.IImageVersion>): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1.IImageVersion[], - protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest|null, - protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listImageVersions(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 - * List ImageVersions in the given project and location, in the form: - * "projects/{projectId}/locations/{locationId}" - * @param {number} request.pageSize - * The maximum number of image_versions to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {boolean} request.includePastReleases - * Whether or not image versions from old releases should be included. - * @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 protos.google.cloud.orchestration.airflow.service.v1.ImageVersion|ImageVersion} 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 `listImageVersionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listImageVersionsStream( - request?: protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest, - 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['listImageVersions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listImageVersions.createStream( - this.innerApiCalls.listImageVersions as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listImageVersions`, 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 - * List ImageVersions in the given project and location, in the form: - * "projects/{projectId}/locations/{locationId}" - * @param {number} request.pageSize - * The maximum number of image_versions to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {boolean} request.includePastReleases - * Whether or not image versions from old releases should be included. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.orchestration.airflow.service.v1.ImageVersion|ImageVersion}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/image_versions.list_image_versions.js - * region_tag:composer_v1_generated_ImageVersions_ListImageVersions_async - */ - listImageVersionsAsync( - request?: protos.google.cloud.orchestration.airflow.service.v1.IListImageVersionsRequest, - 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['listImageVersions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listImageVersions.asyncIterate( - this.innerApiCalls['listImageVersions'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified environment resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} environment - * @returns {string} Resource name string. - */ - environmentPath(project:string,location:string,environment:string) { - return this.pathTemplates.environmentPathTemplate.render({ - project: project, - location: location, - environment: environment, - }); - } - - /** - * Parse the project from Environment resource. - * - * @param {string} environmentName - * A fully-qualified path representing Environment resource. - * @returns {string} A string representing the project. - */ - matchProjectFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).project; - } - - /** - * Parse the location from Environment resource. - * - * @param {string} environmentName - * A fully-qualified path representing Environment resource. - * @returns {string} A string representing the location. - */ - matchLocationFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).location; - } - - /** - * Parse the environment from Environment resource. - * - * @param {string} environmentName - * A fully-qualified path representing Environment resource. - * @returns {string} A string representing the environment. - */ - matchEnvironmentFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).environment; - } - - /** - * 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.imageVersionsStub && !this._terminated) { - return this.imageVersionsStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_client_config.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_client_config.json deleted file mode 100644 index 6ae2b5fc9c6..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_client_config.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "interfaces": { - "google.cloud.orchestration.airflow.service.v1.ImageVersions": { - "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": { - "ListImageVersions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_proto_list.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_proto_list.json deleted file mode 100644 index 674df9932cf..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/image_versions_proto_list.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - "../../protos/google/cloud/orchestration/airflow/service/v1/environments.proto", - "../../protos/google/cloud/orchestration/airflow/service/v1/image_versions.proto", - "../../protos/google/cloud/orchestration/airflow/service/v1/operations.proto" -] diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/index.ts deleted file mode 100644 index f861aaef0c3..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/src/v1/index.ts +++ /dev/null @@ -1,20 +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 {EnvironmentsClient} from './environments_client'; -export {ImageVersionsClient} from './image_versions_client'; diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 6621821e725..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const service = require('@google-cloud/orchestration-airflow'); - -function main() { - const environmentsClient = new service.EnvironmentsClient(); - const imageVersionsClient = new service.ImageVersionsClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index fe7224b8add..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +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 {EnvironmentsClient, ImageVersionsClient} from '@google-cloud/orchestration-airflow'; - -// check that the client class type name can be used -function doStuffWithEnvironmentsClient(client: EnvironmentsClient) { - client.close(); -} -function doStuffWithImageVersionsClient(client: ImageVersionsClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const environmentsClient = new EnvironmentsClient(); - doStuffWithEnvironmentsClient(environmentsClient); - // check that the client instance can be created - const imageVersionsClient = new ImageVersionsClient(); - doStuffWithImageVersionsClient(imageVersionsClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/install.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/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-orchestration-airflow-service/v1/test/gapic_environments_v1.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/test/gapic_environments_v1.ts deleted file mode 100644 index 7ded90c60b8..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/test/gapic_environments_v1.ts +++ /dev/null @@ -1,2226 +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 environmentsModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.EnvironmentsClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = environmentsModule.v1.EnvironmentsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = environmentsModule.v1.EnvironmentsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = environmentsModule.v1.EnvironmentsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new environmentsModule.v1.EnvironmentsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.environmentsStub, undefined); - await client.initialize(); - assert(client.environmentsStub); - }); - - it('has close method for the initialized client', done => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.environmentsStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.environmentsStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new environmentsModule.v1.EnvironmentsClient({ - 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 environmentsModule.v1.EnvironmentsClient({ - 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('getEnvironment', () => { - it('invokes getEnvironment without error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.Environment() - ); - client.innerApiCalls.getEnvironment = stubSimpleCall(expectedResponse); - const [response] = await client.getEnvironment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEnvironment without error using callback', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.Environment() - ); - client.innerApiCalls.getEnvironment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getEnvironment( - request, - (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1.IEnvironment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEnvironment with error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getEnvironment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEnvironment with closed client', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getEnvironment(request), expectedError); - }); - }); - - describe('executeAirflowCommand', () => { - it('invokes executeAirflowCommand without error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandResponse() - ); - client.innerApiCalls.executeAirflowCommand = stubSimpleCall(expectedResponse); - const [response] = await client.executeAirflowCommand(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeAirflowCommand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeAirflowCommand as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executeAirflowCommand without error using callback', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandResponse() - ); - client.innerApiCalls.executeAirflowCommand = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.executeAirflowCommand( - request, - (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1.IExecuteAirflowCommandResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeAirflowCommand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeAirflowCommand as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executeAirflowCommand with error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.executeAirflowCommand = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.executeAirflowCommand(request), expectedError); - const actualRequest = (client.innerApiCalls.executeAirflowCommand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeAirflowCommand as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executeAirflowCommand with closed client', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ExecuteAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.executeAirflowCommand(request), expectedError); - }); - }); - - describe('stopAirflowCommand', () => { - it('invokes stopAirflowCommand without error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandResponse() - ); - client.innerApiCalls.stopAirflowCommand = stubSimpleCall(expectedResponse); - const [response] = await client.stopAirflowCommand(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopAirflowCommand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopAirflowCommand as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopAirflowCommand without error using callback', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandResponse() - ); - client.innerApiCalls.stopAirflowCommand = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.stopAirflowCommand( - request, - (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1.IStopAirflowCommandResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopAirflowCommand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopAirflowCommand as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopAirflowCommand with error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopAirflowCommand = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.stopAirflowCommand(request), expectedError); - const actualRequest = (client.innerApiCalls.stopAirflowCommand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopAirflowCommand as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopAirflowCommand with closed client', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.StopAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.stopAirflowCommand(request), expectedError); - }); - }); - - describe('pollAirflowCommand', () => { - it('invokes pollAirflowCommand without error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandResponse() - ); - client.innerApiCalls.pollAirflowCommand = stubSimpleCall(expectedResponse); - const [response] = await client.pollAirflowCommand(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pollAirflowCommand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pollAirflowCommand as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pollAirflowCommand without error using callback', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandResponse() - ); - client.innerApiCalls.pollAirflowCommand = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.pollAirflowCommand( - request, - (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1.IPollAirflowCommandResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pollAirflowCommand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pollAirflowCommand as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pollAirflowCommand with error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.pollAirflowCommand = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.pollAirflowCommand(request), expectedError); - const actualRequest = (client.innerApiCalls.pollAirflowCommand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pollAirflowCommand as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pollAirflowCommand with closed client', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.PollAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.pollAirflowCommand(request), expectedError); - }); - }); - - describe('fetchDatabaseProperties', () => { - it('invokes fetchDatabaseProperties without error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesResponse() - ); - client.innerApiCalls.fetchDatabaseProperties = stubSimpleCall(expectedResponse); - const [response] = await client.fetchDatabaseProperties(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes fetchDatabaseProperties without error using callback', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesResponse() - ); - client.innerApiCalls.fetchDatabaseProperties = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.fetchDatabaseProperties( - request, - (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1.IFetchDatabasePropertiesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes fetchDatabaseProperties with error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.fetchDatabaseProperties = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.fetchDatabaseProperties(request), expectedError); - const actualRequest = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes fetchDatabaseProperties with closed client', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.FetchDatabasePropertiesRequest', ['environment']); - request.environment = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.fetchDatabaseProperties(request), expectedError); - }); - }); - - describe('createEnvironment', () => { - it('invokes createEnvironment without error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createEnvironment = stubLongRunningCall(expectedResponse); - const [operation] = await client.createEnvironment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createEnvironment without error using callback', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createEnvironment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createEnvironment( - request, - (err?: Error|null, - result?: 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.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createEnvironment with call error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEnvironment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createEnvironment with LRO error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEnvironment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createEnvironment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateEnvironmentProgress without error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateEnvironmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateEnvironmentProgress with error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateEnvironmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateEnvironment', () => { - it('invokes updateEnvironment without error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.UpdateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.UpdateEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateEnvironment = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateEnvironment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateEnvironment without error using callback', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.UpdateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.UpdateEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateEnvironment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateEnvironment( - request, - (err?: Error|null, - result?: 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.updateEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateEnvironment with call error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.UpdateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.UpdateEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateEnvironment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.updateEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateEnvironment with LRO error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.UpdateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.UpdateEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateEnvironment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateEnvironment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateEnvironmentProgress without error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateEnvironmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateEnvironmentProgress with error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateEnvironmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteEnvironment', () => { - it('invokes deleteEnvironment without error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteEnvironment = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteEnvironment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteEnvironment without error using callback', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteEnvironment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteEnvironment( - request, - (err?: Error|null, - result?: 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.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteEnvironment with call error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteEnvironment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteEnvironment with LRO error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteEnvironment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteEnvironment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteEnvironmentProgress without error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteEnvironmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteEnvironmentProgress with error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteEnvironmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('saveSnapshot', () => { - it('invokes saveSnapshot without error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.SaveSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.SaveSnapshotRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.saveSnapshot = stubLongRunningCall(expectedResponse); - const [operation] = await client.saveSnapshot(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.saveSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.saveSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes saveSnapshot without error using callback', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.SaveSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.SaveSnapshotRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.saveSnapshot = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.saveSnapshot( - request, - (err?: Error|null, - result?: 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.saveSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.saveSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes saveSnapshot with call error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.SaveSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.SaveSnapshotRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.saveSnapshot = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.saveSnapshot(request), expectedError); - const actualRequest = (client.innerApiCalls.saveSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.saveSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes saveSnapshot with LRO error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.SaveSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.SaveSnapshotRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.saveSnapshot = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.saveSnapshot(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.saveSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.saveSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkSaveSnapshotProgress without error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkSaveSnapshotProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkSaveSnapshotProgress with error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSaveSnapshotProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('loadSnapshot', () => { - it('invokes loadSnapshot without error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.LoadSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.LoadSnapshotRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.loadSnapshot = stubLongRunningCall(expectedResponse); - const [operation] = await client.loadSnapshot(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.loadSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.loadSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes loadSnapshot without error using callback', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.LoadSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.LoadSnapshotRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.loadSnapshot = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.loadSnapshot( - request, - (err?: Error|null, - result?: 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.loadSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.loadSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes loadSnapshot with call error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.LoadSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.LoadSnapshotRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.loadSnapshot = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.loadSnapshot(request), expectedError); - const actualRequest = (client.innerApiCalls.loadSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.loadSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes loadSnapshot with LRO error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.LoadSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.LoadSnapshotRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.loadSnapshot = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.loadSnapshot(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.loadSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.loadSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkLoadSnapshotProgress without error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkLoadSnapshotProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkLoadSnapshotProgress with error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkLoadSnapshotProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('databaseFailover', () => { - it('invokes databaseFailover without error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.DatabaseFailoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.DatabaseFailoverRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.databaseFailover = stubLongRunningCall(expectedResponse); - const [operation] = await client.databaseFailover(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.databaseFailover as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.databaseFailover as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes databaseFailover without error using callback', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.DatabaseFailoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.DatabaseFailoverRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.databaseFailover = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.databaseFailover( - request, - (err?: Error|null, - result?: 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.databaseFailover as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.databaseFailover as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes databaseFailover with call error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.DatabaseFailoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.DatabaseFailoverRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.databaseFailover = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.databaseFailover(request), expectedError); - const actualRequest = (client.innerApiCalls.databaseFailover as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.databaseFailover as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes databaseFailover with LRO error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.DatabaseFailoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.DatabaseFailoverRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.databaseFailover = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.databaseFailover(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.databaseFailover as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.databaseFailover as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDatabaseFailoverProgress without error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDatabaseFailoverProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDatabaseFailoverProgress with error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDatabaseFailoverProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listEnvironments', () => { - it('invokes listEnvironments without error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), - ]; - client.innerApiCalls.listEnvironments = stubSimpleCall(expectedResponse); - const [response] = await client.listEnvironments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEnvironments without error using callback', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), - ]; - client.innerApiCalls.listEnvironments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listEnvironments( - request, - (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1.IEnvironment[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEnvironments with error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listEnvironments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listEnvironments(request), expectedError); - const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEnvironmentsStream without error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), - ]; - client.descriptors.page.listEnvironments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listEnvironmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.orchestration.airflow.service.v1.Environment[] = []; - stream.on('data', (response: protos.google.cloud.orchestration.airflow.service.v1.Environment) => { - 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.listEnvironments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEnvironments, request)); - assert( - (client.descriptors.page.listEnvironments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listEnvironmentsStream with error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listEnvironments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listEnvironmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.orchestration.airflow.service.v1.Environment[] = []; - stream.on('data', (response: protos.google.cloud.orchestration.airflow.service.v1.Environment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listEnvironments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEnvironments, request)); - assert( - (client.descriptors.page.listEnvironments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listEnvironments without error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.Environment()), - ]; - client.descriptors.page.listEnvironments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.orchestration.airflow.service.v1.IEnvironment[] = []; - const iterable = client.listEnvironmentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listEnvironments with error', async () => { - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listEnvironments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listEnvironmentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.orchestration.airflow.service.v1.IEnvironment[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEnvironments.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 environmentsModule.v1.EnvironmentsClient({ - 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 environmentsModule.v1.EnvironmentsClient({ - 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 environmentsModule.v1.EnvironmentsClient({ - 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 environmentsModule.v1.EnvironmentsClient({ - 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 environmentsModule.v1.EnvironmentsClient({ - 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 environmentsModule.v1.EnvironmentsClient({ - 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 environmentsModule.v1.EnvironmentsClient({ - 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 environmentsModule.v1.EnvironmentsClient({ - 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 environmentsModule.v1.EnvironmentsClient({ - 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 environmentsModule.v1.EnvironmentsClient({ - 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 environmentsModule.v1.EnvironmentsClient({ - 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('environment', () => { - const fakePath = "/rendered/path/environment"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - environment: "environmentValue", - }; - const client = new environmentsModule.v1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.environmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.environmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('environmentPath', () => { - const result = client.environmentPath("projectValue", "locationValue", "environmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.environmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEnvironmentName', () => { - const result = client.matchProjectFromEnvironmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEnvironmentName', () => { - const result = client.matchLocationFromEnvironmentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEnvironmentFromEnvironmentName', () => { - const result = client.matchEnvironmentFromEnvironmentName(fakePath); - assert.strictEqual(result, "environmentValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/test/gapic_image_versions_v1.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/test/gapic_image_versions_v1.ts deleted file mode 100644 index ea0470ef6f0..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/test/gapic_image_versions_v1.ts +++ /dev/null @@ -1,491 +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 imageversionsModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.ImageVersionsClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageversionsModule.v1.ImageVersionsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageversionsModule.v1.ImageVersionsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageversionsModule.v1.ImageVersionsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageversionsModule.v1.ImageVersionsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageversionsModule.v1.ImageVersionsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageversionsModule.v1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageVersionsStub, undefined); - await client.initialize(); - assert(client.imageVersionsStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageversionsModule.v1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageVersionsStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageversionsModule.v1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageVersionsStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageversionsModule.v1.ImageVersionsClient({ - 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 imageversionsModule.v1.ImageVersionsClient({ - 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('listImageVersions', () => { - it('invokes listImageVersions without error', async () => { - const client = new imageversionsModule.v1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), - ]; - client.innerApiCalls.listImageVersions = stubSimpleCall(expectedResponse); - const [response] = await client.listImageVersions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listImageVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listImageVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listImageVersions without error using callback', async () => { - const client = new imageversionsModule.v1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), - ]; - client.innerApiCalls.listImageVersions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listImageVersions( - request, - (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1.IImageVersion[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listImageVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listImageVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listImageVersions with error', async () => { - const client = new imageversionsModule.v1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listImageVersions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listImageVersions(request), expectedError); - const actualRequest = (client.innerApiCalls.listImageVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listImageVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listImageVersionsStream without error', async () => { - const client = new imageversionsModule.v1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), - ]; - client.descriptors.page.listImageVersions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listImageVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.orchestration.airflow.service.v1.ImageVersion[] = []; - stream.on('data', (response: protos.google.cloud.orchestration.airflow.service.v1.ImageVersion) => { - 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.listImageVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listImageVersions, request)); - assert( - (client.descriptors.page.listImageVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listImageVersionsStream with error', async () => { - const client = new imageversionsModule.v1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listImageVersions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listImageVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.orchestration.airflow.service.v1.ImageVersion[] = []; - stream.on('data', (response: protos.google.cloud.orchestration.airflow.service.v1.ImageVersion) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listImageVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listImageVersions, request)); - assert( - (client.descriptors.page.listImageVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listImageVersions without error', async () => { - const client = new imageversionsModule.v1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1.ImageVersion()), - ]; - client.descriptors.page.listImageVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.orchestration.airflow.service.v1.IImageVersion[] = []; - const iterable = client.listImageVersionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listImageVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listImageVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listImageVersions with error', async () => { - const client = new imageversionsModule.v1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listImageVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listImageVersionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.orchestration.airflow.service.v1.IImageVersion[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listImageVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listImageVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('environment', () => { - const fakePath = "/rendered/path/environment"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - environment: "environmentValue", - }; - const client = new imageversionsModule.v1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.environmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.environmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('environmentPath', () => { - const result = client.environmentPath("projectValue", "locationValue", "environmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.environmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEnvironmentName', () => { - const result = client.matchProjectFromEnvironmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEnvironmentName', () => { - const result = client.matchLocationFromEnvironmentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEnvironmentFromEnvironmentName', () => { - const result = client.matchEnvironmentFromEnvironmentName(fakePath); - assert.strictEqual(result, "environmentValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/tsconfig.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/webpack.config.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/webpack.config.js deleted file mode 100644 index 9b7becac60a..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'Environments', - filename: './environments.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-orchestration-airflow-service/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.gitignore b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.jsdoc.js deleted file mode 100644 index 1eacba42fba..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.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/orchestration-airflow', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.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-orchestration-airflow-service/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/.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-orchestration-airflow-service/v1beta1/README.md b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/README.md deleted file mode 100644 index 536af38a9bb..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Service: Nodejs Client diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/package.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/package.json deleted file mode 100644 index 42943d9c4a6..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/package.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "name": "@google-cloud/orchestration-airflow", - "version": "0.1.0", - "description": "Service client for Node.js", - "repository": "googleapis/nodejs-service", - "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 service", - "service", - "environments", - "image versions" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/environments.proto b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/environments.proto deleted file mode 100644 index 51da9f3c152..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/environments.proto +++ /dev/null @@ -1,1530 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.orchestration.airflow.service.v1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/orchestration/airflow/service/v1beta1/operations.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "cloud.google.com/go/orchestration/airflow/service/apiv1beta1/servicepb;servicepb"; -option java_multiple_files = true; -option java_package = "com.google.cloud.orchestration.airflow.service.v1beta1"; - -// Managed Apache Airflow Environments. -service Environments { - option (google.api.default_host) = "composer.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Create a new environment. - rpc CreateEnvironment(CreateEnvironmentRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*/locations/*}/environments" - body: "environment" - }; - option (google.api.method_signature) = "parent,environment"; - option (google.longrunning.operation_info) = { - response_type: "Environment" - metadata_type: "google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata" - }; - } - - // Get an existing environment. - rpc GetEnvironment(GetEnvironmentRequest) returns (Environment) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/locations/*/environments/*}" - }; - option (google.api.method_signature) = "name"; - } - - // List environments. - rpc ListEnvironments(ListEnvironmentsRequest) - returns (ListEnvironmentsResponse) { - option (google.api.http) = { - get: "/v1beta1/{parent=projects/*/locations/*}/environments" - }; - option (google.api.method_signature) = "parent"; - } - - // Update an environment. - rpc UpdateEnvironment(UpdateEnvironmentRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1beta1/{name=projects/*/locations/*/environments/*}" - body: "environment" - }; - option (google.api.method_signature) = "name,environment,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "Environment" - metadata_type: "google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata" - }; - } - - // Delete an environment. - rpc DeleteEnvironment(DeleteEnvironmentRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1beta1/{name=projects/*/locations/*/environments/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata" - }; - } - - // Restart Airflow web server. - rpc RestartWebServer(RestartWebServerRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/environments/*}:restartWebServer" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Environment" - metadata_type: "google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata" - }; - } - - // Check if an upgrade operation on the environment will succeed. - // - // In case of problems detailed info can be found in the returned Operation. - rpc CheckUpgrade(CheckUpgradeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{environment=projects/*/locations/*/environments/*}:checkUpgrade" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeResponse" - metadata_type: "google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata" - }; - } - - // Executes Airflow CLI command. - rpc ExecuteAirflowCommand(ExecuteAirflowCommandRequest) - returns (ExecuteAirflowCommandResponse) { - option (google.api.http) = { - post: "/v1beta1/{environment=projects/*/locations/*/environments/*}:executeAirflowCommand" - body: "*" - }; - } - - // Stops Airflow CLI command execution. - rpc StopAirflowCommand(StopAirflowCommandRequest) - returns (StopAirflowCommandResponse) { - option (google.api.http) = { - post: "/v1beta1/{environment=projects/*/locations/*/environments/*}:stopAirflowCommand" - body: "*" - }; - } - - // Polls Airflow CLI command execution and fetches logs. - rpc PollAirflowCommand(PollAirflowCommandRequest) - returns (PollAirflowCommandResponse) { - option (google.api.http) = { - post: "/v1beta1/{environment=projects/*/locations/*/environments/*}:pollAirflowCommand" - body: "*" - }; - } - - // Creates a snapshots of a Cloud Composer environment. - // - // As a result of this operation, snapshot of environment's state is stored - // in a location specified in the SaveSnapshotRequest. - rpc SaveSnapshot(SaveSnapshotRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{environment=projects/*/locations/*/environments/*}:saveSnapshot" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.orchestration.airflow.service.v1beta1.SaveSnapshotResponse" - metadata_type: "google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata" - }; - } - - // Loads a snapshot of a Cloud Composer environment. - // - // As a result of this operation, a snapshot of environment's specified in - // LoadSnapshotRequest is loaded into the environment. - rpc LoadSnapshot(LoadSnapshotRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{environment=projects/*/locations/*/environments/*}:loadSnapshot" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.orchestration.airflow.service.v1beta1.LoadSnapshotResponse" - metadata_type: "google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata" - }; - } - - // Triggers database failover (only for highly resilient environments). - rpc DatabaseFailover(DatabaseFailoverRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{environment=projects/*/locations/*/environments/*}:databaseFailover" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverResponse" - metadata_type: "google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata" - }; - } - - // Fetches database properties. - rpc FetchDatabaseProperties(FetchDatabasePropertiesRequest) - returns (FetchDatabasePropertiesResponse) { - option (google.api.http) = { - get: "/v1beta1/{environment=projects/*/locations/*/environments/*}:fetchDatabaseProperties" - }; - } -} - -// Create a new environment. -message CreateEnvironmentRequest { - // The parent must be of the form - // "projects/{projectId}/locations/{locationId}". - string parent = 1; - - // The environment to create. - Environment environment = 2; -} - -// Get an environment. -message GetEnvironmentRequest { - // The resource name of the environment to get, in the form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - string name = 1; -} - -// List environments in a project and location. -message ListEnvironmentsRequest { - // List environments in the given project and location, in the form: - // "projects/{projectId}/locations/{locationId}" - string parent = 1; - - // The maximum number of environments to return. - int32 page_size = 2; - - // The next_page_token value returned from a previous List request, if any. - string page_token = 3; -} - -// The environments in a project and location. -message ListEnvironmentsResponse { - // The list of environments returned by a ListEnvironmentsRequest. - repeated Environment environments = 1; - - // The page token used to query for the next page if one exists. - string next_page_token = 2; -} - -// Delete an environment. -message DeleteEnvironmentRequest { - // The environment to delete, in the form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - string name = 1; -} - -// Update an environment. -message UpdateEnvironmentRequest { - // The relative resource name of the environment to update, in the form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - string name = 2; - - // A patch environment. Fields specified by the `updateMask` will be copied - // from the patch environment into the environment under update. - Environment environment = 1; - - // Required. A comma-separated list of paths, relative to `Environment`, of - // fields to update. - // For example, to set the version of scikit-learn to install in the - // environment to 0.19.0 and to remove an existing installation of - // argparse, the `updateMask` parameter would include the following two - // `paths` values: "config.softwareConfig.pypiPackages.scikit-learn" and - // "config.softwareConfig.pypiPackages.argparse". The included patch - // environment would specify the scikit-learn version as follows: - // - // { - // "config":{ - // "softwareConfig":{ - // "pypiPackages":{ - // "scikit-learn":"==0.19.0" - // } - // } - // } - // } - // - // Note that in the above example, any existing PyPI packages - // other than scikit-learn and argparse will be unaffected. - // - // Only one update type may be included in a single request's `updateMask`. - // For example, one cannot update both the PyPI packages and - // labels in the same request. However, it is possible to update multiple - // members of a map field simultaneously in the same request. For example, - // to set the labels "label1" and "label2" while clearing "label3" (assuming - // it already exists), one can - // provide the paths "labels.label1", "labels.label2", and "labels.label3" - // and populate the patch environment as follows: - // - // { - // "labels":{ - // "label1":"new-label1-value" - // "label2":"new-label2-value" - // } - // } - // - // Note that in the above example, any existing labels that are not - // included in the `updateMask` will be unaffected. - // - // It is also possible to replace an entire map field by providing the - // map field's path in the `updateMask`. The new value of the field will - // be that which is provided in the patch environment. For example, to - // delete all pre-existing user-specified PyPI packages and - // install botocore at version 1.7.14, the `updateMask` would contain - // the path "config.softwareConfig.pypiPackages", and - // the patch environment would be the following: - // - // { - // "config":{ - // "softwareConfig":{ - // "pypiPackages":{ - // "botocore":"==1.7.14" - // } - // } - // } - // } - // - // **Note:** Only the following fields can be updated: - // - // * `config.softwareConfig.pypiPackages` - // * Replace all custom custom PyPI packages. If a replacement - // package map is not included in `environment`, all custom - // PyPI packages are cleared. It is an error to provide both - // this mask and a mask specifying an individual package. - // * `config.softwareConfig.pypiPackages.`packagename - // * Update the custom PyPI package *packagename*, - // preserving other packages. To delete the package, include it in - // `updateMask`, and omit the mapping for it in - // `environment.config.softwareConfig.pypiPackages`. It is an error - // to provide both a mask of this form and the - // `config.softwareConfig.pypiPackages` mask. - // * `labels` - // * Replace all environment labels. If a replacement labels map is not - // included in `environment`, all labels are cleared. It is an error to - // provide both this mask and a mask specifying one or more individual - // labels. - // * `labels.`labelName - // * Set the label named *labelName*, while preserving other - // labels. To delete the label, include it in `updateMask` and omit its - // mapping in `environment.labels`. It is an error to provide both a - // mask of this form and the `labels` mask. - // * `config.nodeCount` - // * Horizontally scale the number of nodes in the environment. An integer - // greater than or equal to 3 must be provided in the `config.nodeCount` - // field. Supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - // * `config.webServerNetworkAccessControl` - // * Replace the environment's current WebServerNetworkAccessControl. - // * `config.softwareConfig.airflowConfigOverrides` - // * Replace all Apache Airflow config overrides. If a replacement config - // overrides map is not included in `environment`, all config overrides - // are cleared. - // It is an error to provide both this mask and a mask specifying one or - // more individual config overrides. - // * `config.softwareConfig.airflowConfigOverrides.`section-name - // * Override the Apache Airflow config property *name* in the - // section named *section*, preserving other properties. To - // delete the property override, include it in `updateMask` and omit its - // mapping in - // `environment.config.softwareConfig.airflowConfigOverrides`. - // It is an error to provide both a mask of this form and the - // `config.softwareConfig.airflowConfigOverrides` mask. - // * `config.softwareConfig.envVariables` - // * Replace all environment variables. If a replacement environment - // variable map is not included in `environment`, all custom environment - // variables are cleared. - // * `config.softwareConfig.imageVersion` - // * Upgrade the version of the environment in-place. Refer to - // `SoftwareConfig.image_version` for information on how to format the - // new image version. Additionally, the new image version cannot effect - // a version downgrade, and must match the current image version's - // Composer and Airflow major versions. Consult the [Cloud Composer - // version list](/composer/docs/concepts/versioning/composer-versions) - // for valid values. - // * `config.softwareConfig.schedulerCount` - // * Horizontally scale the number of schedulers in Airflow. A positive - // integer not greater than the number of nodes must be provided in the - // `config.softwareConfig.schedulerCount` field. Supported for Cloud - // Composer environments in versions composer-1.*.*-airflow-2.*.*. - // * `config.softwareConfig.cloudDataLineageIntegration` - // * Configuration for Cloud Data Lineage integration. - // * `config.databaseConfig.machineType` - // * Cloud SQL machine type used by Airflow database. - // It has to be one of: db-n1-standard-2, db-n1-standard-4, - // db-n1-standard-8 or db-n1-standard-16. Supported for Cloud Composer - // environments in versions composer-1.*.*-airflow-*.*.*. - // * `config.webServerConfig.machineType` - // * Machine type on which Airflow web server is running. - // It has to be one of: composer-n1-webserver-2, composer-n1-webserver-4 - // or composer-n1-webserver-8. Supported for Cloud Composer environments - // in versions composer-1.*.*-airflow-*.*.*. - // * `config.maintenanceWindow` - // * Maintenance window during which Cloud Composer components may be - // under maintenance. - // * `config.workloadsConfig` - // * The workloads configuration settings for the GKE cluster associated - // with the Cloud Composer environment. Supported for Cloud Composer - // environments in versions composer-2.*.*-airflow-*.*.* and newer. - // * `config.environmentSize` - // * The size of the Cloud Composer environment. Supported for Cloud - // Composer environments in versions composer-2.*.*-airflow-*.*.* and - // newer. - google.protobuf.FieldMask update_mask = 3 - [(google.api.field_behavior) = REQUIRED]; -} - -// Restart Airflow web server. -message RestartWebServerRequest { - // The resource name of the environment to restart the web server for, in the - // form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - string name = 1; -} - -// Execute Airflow Command request. -message ExecuteAirflowCommandRequest { - // The resource name of the environment in the form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}". - string environment = 1; - - // Airflow command. - string command = 2; - - // Airflow subcommand. - string subcommand = 3; - - // Parameters for the Airflow command/subcommand as an array of arguments. - // It may contain positional arguments like `["my-dag-id"]`, key-value - // parameters like `["--foo=bar"]` or `["--foo","bar"]`, - // or other flags like `["-f"]`. - repeated string parameters = 4; -} - -// Response to ExecuteAirflowCommandRequest. -message ExecuteAirflowCommandResponse { - // The unique ID of the command execution for polling. - string execution_id = 1; - - // The name of the pod where the command is executed. - string pod = 2; - - // The namespace of the pod where the command is executed. - string pod_namespace = 3; - - // Error message. Empty if there was no error. - string error = 4; -} - -// Stop Airflow Command request. -message StopAirflowCommandRequest { - // The resource name of the environment in the form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}". - string environment = 1; - - // The unique ID of the command execution. - string execution_id = 2; - - // The name of the pod where the command is executed. - string pod = 3; - - // The namespace of the pod where the command is executed. - string pod_namespace = 4; - - // If true, the execution is terminated forcefully (SIGKILL). If false, the - // execution is stopped gracefully, giving it time for cleanup. - bool force = 5; -} - -// Response to StopAirflowCommandRequest. -message StopAirflowCommandResponse { - // Whether the execution is still running. - bool is_done = 1; - - // Output message from stopping execution request. - repeated string output = 2; -} - -// Poll Airflow Command request. -message PollAirflowCommandRequest { - // The resource name of the environment in the form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - string environment = 1; - - // The unique ID of the command execution. - string execution_id = 2; - - // The name of the pod where the command is executed. - string pod = 3; - - // The namespace of the pod where the command is executed. - string pod_namespace = 4; - - // Line number from which new logs should be fetched. - int32 next_line_number = 5; -} - -// Response to PollAirflowCommandRequest. -message PollAirflowCommandResponse { - // Contains information about a single line from logs. - message Line { - // Number of the line. - int32 line_number = 1; - - // Text content of the log line. - string content = 2; - } - - // Information about how a command ended. - message ExitInfo { - // The exit code from the command execution. - int32 exit_code = 1; - - // Error message. Empty if there was no error. - string error = 2; - } - - // Output from the command execution. It may not contain the full output - // and the caller may need to poll for more lines. - repeated Line output = 1; - - // Whether the command execution has finished and there is no more output. - bool output_end = 2; - - // The result exit status of the command. - ExitInfo exit_info = 3; -} - -// Request to create a snapshot of a Cloud Composer environment. -message SaveSnapshotRequest { - // The resource name of the source environment in the form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - string environment = 1; - - // Location in a Cloud Storage where the snapshot is going to be stored, e.g.: - // "gs://my-bucket/snapshots". - string snapshot_location = 2; -} - -// Response to SaveSnapshotRequest. -message SaveSnapshotResponse { - // The fully-resolved Cloud Storage path of the created snapshot, - // e.g.: - // "gs://my-bucket/snapshots/project_location_environment_timestamp". - // This field is populated only if the snapshot creation was successful. - string snapshot_path = 1; -} - -// Request to load a snapshot into a Cloud Composer environment. -message LoadSnapshotRequest { - // The resource name of the target environment in the form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - string environment = 1; - - // A Cloud Storage path to a snapshot to load, e.g.: - // "gs://my-bucket/snapshots/project_location_environment_timestamp". - string snapshot_path = 2; - - // Whether or not to skip installing Pypi packages when loading the - // environment's state. - bool skip_pypi_packages_installation = 3; - - // Whether or not to skip setting environment variables when loading the - // environment's state. - bool skip_environment_variables_setting = 4; - - // Whether or not to skip setting Airflow overrides when loading the - // environment's state. - bool skip_airflow_overrides_setting = 5; - - // Whether or not to skip copying Cloud Storage data when loading the - // environment's state. - bool skip_gcs_data_copying = 6; -} - -// Response to LoadSnapshotRequest. -message LoadSnapshotResponse {} - -// Request to trigger database failover (only for highly resilient -// environments). -message DatabaseFailoverRequest { - // Target environment: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - string environment = 1; -} - -// Response for DatabaseFailoverRequest. -message DatabaseFailoverResponse {} - -// Request to fetch properties of environment's database. -message FetchDatabasePropertiesRequest { - // Required. The resource name of the environment, in the form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - string environment = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "composer.googleapis.com/Environment" - } - ]; -} - -// Response for FetchDatabasePropertiesRequest. -message FetchDatabasePropertiesResponse { - // The Compute Engine zone that the instance is currently serving from. - string primary_gce_zone = 1; - - // The Compute Engine zone that the failover instance is currently serving - // from for a regional Cloud SQL instance. - string secondary_gce_zone = 2; - - // The availability status of the failover replica. A false status indicates - // that the failover replica is out of sync. The primary instance can only - // fail over to the failover replica when the status is true. - bool is_failover_replica_available = 3; -} - -// Configuration information for an environment. -message EnvironmentConfig { - // The size of the Cloud Composer environment. - enum EnvironmentSize { - // The size of the environment is unspecified. - ENVIRONMENT_SIZE_UNSPECIFIED = 0; - - // The environment size is small. - ENVIRONMENT_SIZE_SMALL = 1; - - // The environment size is medium. - ENVIRONMENT_SIZE_MEDIUM = 2; - - // The environment size is large. - ENVIRONMENT_SIZE_LARGE = 3; - } - - // Resilience mode of the Cloud Composer Environment. - enum ResilienceMode { - // Default mode doesn't change environment parameters. - RESILIENCE_MODE_UNSPECIFIED = 0; - - // Enabled High Resilience mode, including Cloud SQL HA. - HIGH_RESILIENCE = 1; - } - - // Output only. The Kubernetes Engine cluster used to run this environment. - string gke_cluster = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The Cloud Storage prefix of the DAGs for this environment. - // Although Cloud Storage objects reside in a flat namespace, a hierarchical - // file tree can be simulated using "/"-delimited object name prefixes. DAG - // objects for this environment reside in a simulated directory with the given - // prefix. - string dag_gcs_prefix = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The number of nodes in the Kubernetes Engine cluster that will be - // used to run this environment. - // - // This field is supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - int32 node_count = 3; - - // The configuration settings for software inside the environment. - SoftwareConfig software_config = 4; - - // The configuration used for the Kubernetes Engine cluster. - NodeConfig node_config = 5; - - // The configuration used for the Private IP Cloud Composer environment. - PrivateEnvironmentConfig private_environment_config = 7; - - // Optional. The network-level access control policy for the Airflow web - // server. If unspecified, no network-level access restrictions will be - // applied. - WebServerNetworkAccessControl web_server_network_access_control = 9 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The configuration settings for Cloud SQL instance used internally - // by Apache Airflow software. - DatabaseConfig database_config = 10 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The configuration settings for the Airflow web server App Engine - // instance. - // - // This field is supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - WebServerConfig web_server_config = 11 - [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The URI of the Apache Airflow Web UI hosted within this - // environment (see [Airflow web - // interface](/composer/docs/how-to/accessing/airflow-web-interface)). - string airflow_uri = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The 'bring your own identity' variant of the URI of the Apache - // Airflow Web UI hosted within this environment, to be accessed with external - // identities using workforce identity federation (see [Access environments - // with workforce identity - // federation](/composer/docs/composer-2/access-environments-with-workforce-identity-federation)). - string airflow_byoid_uri = 21 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. The encryption options for the Cloud Composer environment and its - // dependencies. Cannot be updated. - EncryptionConfig encryption_config = 12 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The maintenance window is the period when Cloud Composer - // components may undergo maintenance. It is defined so that maintenance is - // not executed during peak hours or critical time periods. - // - // The system will not be under maintenance for every occurrence of this - // window, but when maintenance is planned, it will be scheduled - // during the window. - // - // The maintenance window period must encompass at least 12 hours per week. - // This may be split into multiple chunks, each with a size of - // at least 4 hours. - // - // If this value is omitted, Cloud Composer components may be subject to - // maintenance at any time. - MaintenanceWindow maintenance_window = 13 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The workloads configuration settings for the GKE cluster - // associated with the Cloud Composer environment. The GKE cluster runs - // Airflow scheduler, web server and workers workloads. - // - // This field is supported for Cloud Composer environments in versions - // composer-2.*.*-airflow-*.*.* and newer. - WorkloadsConfig workloads_config = 15 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The size of the Cloud Composer environment. - // - // This field is supported for Cloud Composer environments in versions - // composer-2.*.*-airflow-*.*.* and newer. - EnvironmentSize environment_size = 16 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The configuration options for GKE cluster master authorized - // networks. By default master authorized networks feature is: - // - in case of private environment: enabled with no external networks - // allowlisted. - // - in case of public environment: disabled. - MasterAuthorizedNetworksConfig master_authorized_networks_config = 17 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The Recovery settings configuration of an environment. - // - // This field is supported for Cloud Composer environments in versions - // composer-2.*.*-airflow-*.*.* and newer. - RecoveryConfig recovery_config = 18 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Resilience mode of the Cloud Composer Environment. - // - // This field is supported for Cloud Composer environments in versions - // composer-2.2.0-airflow-*.*.* and newer. - ResilienceMode resilience_mode = 20 [(google.api.field_behavior) = OPTIONAL]; -} - -// Network-level access control policy for the Airflow web server. -message WebServerNetworkAccessControl { - // Allowed IP range with user-provided description. - message AllowedIpRange { - // IP address or range, defined using CIDR notation, of requests that this - // rule applies to. - // Examples: `192.168.1.1` or `192.168.0.0/16` or `2001:db8::/32` - // or `2001:0db8:0000:0042:0000:8a2e:0370:7334`. - // - // IP range prefixes should be properly truncated. For example, - // `1.2.3.4/24` should be truncated to `1.2.3.0/24`. Similarly, for IPv6, - // `2001:db8::1/32` should be truncated to `2001:db8::/32`. - string value = 1; - - // Optional. User-provided description. It must contain at most 300 - // characters. - string description = 2 [(google.api.field_behavior) = OPTIONAL]; - } - - // A collection of allowed IP ranges with descriptions. - repeated AllowedIpRange allowed_ip_ranges = 1; -} - -// Specifies the selection and configuration of software inside the environment. -message SoftwareConfig { - // The version of the software running in the environment. - // This encapsulates both the version of Cloud Composer functionality and the - // version of Apache Airflow. It must match the regular expression - // `composer-([0-9]+(\.[0-9]+\.[0-9]+(-preview\.[0-9]+)?)?|latest)-airflow-([0-9]+(\.[0-9]+(\.[0-9]+)?)?)`. - // When used as input, the server also checks if the provided version is - // supported and denies the request for an unsupported version. - // - // The Cloud Composer portion of the image version is a full - // [semantic version](https://semver.org), or an alias in the form of major - // version number or `latest`. When an alias is provided, the server replaces - // it with the current Cloud Composer version that satisfies the alias. - // - // The Apache Airflow portion of the image version is a full semantic version - // that points to one of the supported Apache Airflow versions, or an alias in - // the form of only major or major.minor versions specified. When an alias is - // provided, the server replaces it with the latest Apache Airflow version - // that satisfies the alias and is supported in the given Cloud Composer - // version. - // - // In all cases, the resolved image version is stored in the same field. - // - // See also [version - // list](/composer/docs/concepts/versioning/composer-versions) and [versioning - // overview](/composer/docs/concepts/versioning/composer-versioning-overview). - string image_version = 1; - - // Optional. Apache Airflow configuration properties to override. - // - // Property keys contain the section and property names, separated by a - // hyphen, for example "core-dags_are_paused_at_creation". Section names must - // not contain hyphens ("-"), opening square brackets ("["), or closing - // square brackets ("]"). The property name must not be empty and must not - // contain an equals sign ("=") or semicolon (";"). Section and property names - // must not contain a period ("."). Apache Airflow configuration property - // names must be written in - // [snake_case](https://en.wikipedia.org/wiki/Snake_case). Property values can - // contain any character, and can be written in any lower/upper case format. - // - // Certain Apache Airflow configuration property values are - // [blocked](/composer/docs/concepts/airflow-configurations), - // and cannot be overridden. - map airflow_config_overrides = 2 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Custom Python Package Index (PyPI) packages to be installed in - // the environment. - // - // Keys refer to the lowercase package name such as "numpy" - // and values are the lowercase extras and version specifier such as - // "==1.12.0", "[devel,gcp_api]", or "[devel]>=1.8.2, <1.9.2". To specify a - // package without pinning it to a version specifier, use the empty string as - // the value. - map pypi_packages = 3 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Additional environment variables to provide to the Apache Airflow - // scheduler, worker, and webserver processes. - // - // Environment variable names must match the regular expression - // `[a-zA-Z_][a-zA-Z0-9_]*`. They cannot specify Apache Airflow - // software configuration overrides (they cannot match the regular expression - // `AIRFLOW__[A-Z0-9_]+__[A-Z0-9_]+`), and they cannot match any of the - // following reserved names: - // - // * `AIRFLOW_HOME` - // * `C_FORCE_ROOT` - // * `CONTAINER_NAME` - // * `DAGS_FOLDER` - // * `GCP_PROJECT` - // * `GCS_BUCKET` - // * `GKE_CLUSTER_NAME` - // * `SQL_DATABASE` - // * `SQL_INSTANCE` - // * `SQL_PASSWORD` - // * `SQL_PROJECT` - // * `SQL_REGION` - // * `SQL_USER` - map env_variables = 4 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The major version of Python used to run the Apache Airflow - // scheduler, worker, and webserver processes. - // - // Can be set to '2' or '3'. If not specified, the default is '3'. Cannot be - // updated. - // - // This field is only supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. Environments in newer versions always use - // Python major version 3. - string python_version = 6 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The number of schedulers for Airflow. - // - // This field is supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-2.*.*. - int32 scheduler_count = 7 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The configuration for Cloud Data Lineage integration. - CloudDataLineageIntegration cloud_data_lineage_integration = 8 - [(google.api.field_behavior) = OPTIONAL]; -} - -// Configuration for controlling how IPs are allocated in the -// GKE cluster. -message IPAllocationPolicy { - // Optional. Whether or not to enable Alias IPs in the GKE cluster. - // If `true`, a VPC-native cluster is created. - // - // This field is only supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. Environments in newer versions always use - // VPC-native GKE clusters. - bool use_ip_aliases = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The name of the cluster's secondary range used to allocate - // IP addresses to pods. Specify either `cluster_secondary_range_name` - // or `cluster_ipv4_cidr_block` but not both. - // - // For Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*, - // this field is applicable only when `use_ip_aliases` is true. - string cluster_secondary_range_name = 2 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The name of the services' secondary range used to allocate - // IP addresses to the cluster. Specify either `services_secondary_range_name` - // or `services_ipv4_cidr_block` but not both. - // - // For Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*, - // this field is applicable only when `use_ip_aliases` is true. - string services_secondary_range_name = 3 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The IP address range used to allocate IP addresses to pods in - // the cluster. - // - // For Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*, - // this field is applicable only when `use_ip_aliases` is true. - // - // Set to blank to have GKE choose a range with the default size. - // - // Set to /netmask (e.g. `/14`) to have GKE choose a range with a specific - // netmask. - // - // Set to a - // [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) - // notation (e.g. `10.96.0.0/14`) from the RFC-1918 private networks (e.g. - // `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`) to pick a specific range - // to use. - // Specify `cluster_secondary_range_name` or `cluster_ipv4_cidr_block` - // but not both. - string cluster_ipv4_cidr_block = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The IP address range of the services IP addresses in this - // cluster. - // - // For Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*, - // this field is applicable only when `use_ip_aliases` is true. - // - // Set to blank to have GKE choose a range with the default size. - // - // Set to /netmask (e.g. `/14`) to have GKE choose a range with a specific - // netmask. - // - // Set to a - // [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) - // notation (e.g. `10.96.0.0/14`) from the RFC-1918 private networks (e.g. - // `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`) to pick a specific range - // to use. - // Specify `services_secondary_range_name` or `services_ipv4_cidr_block` - // but not both. - string services_ipv4_cidr_block = 5 [(google.api.field_behavior) = OPTIONAL]; -} - -// The configuration information for the Kubernetes Engine nodes running -// the Apache Airflow software. -message NodeConfig { - // Optional. The Compute Engine [zone](/compute/docs/regions-zones) in which - // to deploy the VMs used to run the Apache Airflow software, specified as a - // [relative resource - // name](/apis/design/resource_names#relative_resource_name). For example: - // "projects/{projectId}/zones/{zoneId}". - // - // This `location` must belong to the enclosing environment's project and - // location. If both this field and `nodeConfig.machineType` are specified, - // `nodeConfig.machineType` must belong to this `location`; if both are - // unspecified, the service will pick a zone in the Compute Engine region - // corresponding to the Cloud Composer location, and propagate that choice to - // both fields. If only one field (`location` or `nodeConfig.machineType`) is - // specified, the location information from the specified field will be - // propagated to the unspecified field. - // - // This field is supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - string location = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The Compute Engine - // [machine type](/compute/docs/machine-types) used for cluster instances, - // specified as a - // [relative resource - // name](/apis/design/resource_names#relative_resource_name). For example: - // "projects/{projectId}/zones/{zoneId}/machineTypes/{machineTypeId}". - // - // The `machineType` must belong to the enclosing environment's project and - // location. If both this field and `nodeConfig.location` are specified, - // this `machineType` must belong to the `nodeConfig.location`; if both are - // unspecified, the service will pick a zone in the Compute Engine region - // corresponding to the Cloud Composer location, and propagate that choice to - // both fields. If exactly one of this field and `nodeConfig.location` is - // specified, the location information from the specified field will be - // propagated to the unspecified field. - // - // The `machineTypeId` must not be a [shared-core machine - // type](/compute/docs/machine-types#sharedcore). - // - // If this field is unspecified, the `machineTypeId` defaults - // to "n1-standard-1". - // - // This field is supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - string machine_type = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The Compute Engine network to be used for machine - // communications, specified as a - // [relative resource - // name](/apis/design/resource_names#relative_resource_name). For example: - // "projects/{projectId}/global/networks/{networkId}". - // - // If unspecified, the default network in the environment's project is used. - // If a [Custom Subnet Network](/vpc/docs/vpc#vpc_networks_and_subnets) - // is provided, `nodeConfig.subnetwork` must also be provided. For - // [Shared VPC](/vpc/docs/shared-vpc) subnetwork requirements, see - // `nodeConfig.subnetwork`. - string network = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The Compute Engine subnetwork to be used for machine - // communications, specified as a - // [relative resource - // name](/apis/design/resource_names#relative_resource_name). For example: - // "projects/{projectId}/regions/{regionId}/subnetworks/{subnetworkId}" - // - // If a subnetwork is provided, `nodeConfig.network` must also be provided, - // and the subnetwork must belong to the enclosing environment's project and - // location. - string subnetwork = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The disk size in GB used for node VMs. Minimum size is 30GB. - // If unspecified, defaults to 100GB. Cannot be updated. - // - // This field is supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - int32 disk_size_gb = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The set of Google API scopes to be made available on all - // node VMs. If `oauth_scopes` is empty, defaults to - // ["https://www.googleapis.com/auth/cloud-platform"]. Cannot be updated. - // - // This field is supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - repeated string oauth_scopes = 6 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The Google Cloud Platform Service Account to be used by the - // workloads. If a service account is not specified, the "default" Compute - // Engine service account is used. Cannot be updated. - string service_account = 7 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The list of instance tags applied to all node VMs. Tags are used - // to identify valid sources or targets for network firewalls. Each tag within - // the list must comply with [RFC1035](https://www.ietf.org/rfc/rfc1035.txt). - // Cannot be updated. - repeated string tags = 8 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The IPAllocationPolicy fields for the GKE cluster. - IPAllocationPolicy ip_allocation_policy = 9 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The maximum number of pods per node in the Cloud Composer GKE - // cluster. The value must be between 8 and 110 and it can be set only if the - // environment is VPC-native. The default value is 32. Values of this field - // will be propagated both to the `default-pool` node pool of the newly - // created GKE cluster, and to the default "Maximum Pods per Node" value which - // is used for newly created node pools if their value is not explicitly set - // during node pool creation. For more information, see [Optimizing IP address - // allocation] - // (https://cloud.google.com/kubernetes-engine/docs/how-to/flexible-pod-cidr). - // Cannot be updated. - // - // This field is supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - int32 max_pods_per_node = 10 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Deploys 'ip-masq-agent' daemon set in the GKE cluster and defines - // nonMasqueradeCIDRs equals to pod IP range so IP masquerading is used for - // all destination addresses, except between pods traffic. - // - // See: - // https://cloud.google.com/kubernetes-engine/docs/how-to/ip-masquerade-agent - bool enable_ip_masq_agent = 11 [(google.api.field_behavior) = OPTIONAL]; -} - -// Configuration options for the private GKE cluster in a Cloud Composer -// environment. -message PrivateClusterConfig { - // Optional. If `true`, access to the public endpoint of the GKE cluster is - // denied. - bool enable_private_endpoint = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The CIDR block from which IPv4 range for GKE master will be - // reserved. If left blank, the default value of '172.16.0.0/23' is used. - string master_ipv4_cidr_block = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The IP range in CIDR notation to use for the hosted master - // network. This range is used for assigning internal IP addresses to the - // cluster master or set of masters and to the internal load balancer virtual - // IP. This range must not overlap with any other ranges in use within the - // cluster's network. - string master_ipv4_reserved_range = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Configuration options for networking connections in the Composer 2 -// environment. -message NetworkingConfig { - // Represents connection type between Composer environment in Customer - // Project and the corresponding Tenant project, from a predefined list - // of available connection modes. - enum ConnectionType { - // No specific connection type was requested, so the environment uses - // the default value corresponding to the rest of its configuration. - CONNECTION_TYPE_UNSPECIFIED = 0; - - // Requests the use of VPC peerings for connecting the Customer and Tenant - // projects. - VPC_PEERING = 1; - - // Requests the use of Private Service Connect for connecting the Customer - // and Tenant projects. - PRIVATE_SERVICE_CONNECT = 2; - } - - // Optional. Indicates the user requested specifc connection type between - // Tenant and Customer projects. You cannot set networking connection type in - // public IP environment. - ConnectionType connection_type = 1 [(google.api.field_behavior) = OPTIONAL]; -} - -// The configuration information for configuring a Private IP Cloud Composer -// environment. -message PrivateEnvironmentConfig { - // Optional. If `true`, a Private IP Cloud Composer environment is created. - // If this field is set to true, `IPAllocationPolicy.use_ip_aliases` must be - // set to true for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - bool enable_private_environment = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Configuration for the private GKE cluster for a Private IP - // Cloud Composer environment. - PrivateClusterConfig private_cluster_config = 2 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The CIDR block from which IP range for web server will be - // reserved. Needs to be disjoint from - // private_cluster_config.master_ipv4_cidr_block and - // cloud_sql_ipv4_cidr_block. - // - // This field is supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - string web_server_ipv4_cidr_block = 3 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The CIDR block from which IP range in tenant project will be - // reserved for Cloud SQL. Needs to be disjoint from - // web_server_ipv4_cidr_block - string cloud_sql_ipv4_cidr_block = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The IP range reserved for the tenant project's App Engine VMs. - // - // This field is supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - string web_server_ipv4_reserved_range = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. The CIDR block from which IP range for Cloud Composer Network in - // tenant project will be reserved. Needs to be disjoint from - // private_cluster_config.master_ipv4_cidr_block and - // cloud_sql_ipv4_cidr_block. - // - // This field is supported for Cloud Composer environments in versions - // composer-2.*.*-airflow-*.*.* and newer. - string cloud_composer_network_ipv4_cidr_block = 7 - [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The IP range reserved for the tenant project's Cloud Composer - // network. - // - // This field is supported for Cloud Composer environments in versions - // composer-2.*.*-airflow-*.*.* and newer. - string cloud_composer_network_ipv4_reserved_range = 8 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. When enabled, IPs from public (non-RFC1918) ranges can be used - // for `IPAllocationPolicy.cluster_ipv4_cidr_block` and - // `IPAllocationPolicy.service_ipv4_cidr_block`. - bool enable_privately_used_public_ips = 6 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. When specified, the environment will use Private Service Connect - // instead of VPC peerings to connect to Cloud SQL in the Tenant Project, - // and the PSC endpoint in the Customer Project will use an IP address from - // this subnetwork. - string cloud_composer_connection_subnetwork = 9 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Configuration for the network connections configuration in the - // environment. - NetworkingConfig networking_config = 10 - [(google.api.field_behavior) = OPTIONAL]; -} - -// The configuration of Cloud SQL instance that is used by the Apache Airflow -// software. -message DatabaseConfig { - // Optional. Cloud SQL machine type used by Airflow database. - // It has to be one of: db-n1-standard-2, db-n1-standard-4, db-n1-standard-8 - // or db-n1-standard-16. If not specified, db-n1-standard-2 will be used. - // Supported for Cloud Composer environments in versions - // composer-1.*.*-airflow-*.*.*. - string machine_type = 1 [(google.api.field_behavior) = OPTIONAL]; -} - -// The configuration settings for the Airflow web server App Engine instance. -// Supported for Cloud Composer environments in versions -// composer-1.*.*-airflow-*.*.*. -message WebServerConfig { - // Optional. Machine type on which Airflow web server is running. - // It has to be one of: composer-n1-webserver-2, composer-n1-webserver-4 or - // composer-n1-webserver-8. - // If not specified, composer-n1-webserver-2 will be used. - // Value custom is returned only in response, if Airflow web server parameters - // were manually changed to a non-standard values. - string machine_type = 1 [(google.api.field_behavior) = OPTIONAL]; -} - -// The encryption options for the Cloud Composer environment and its -// dependencies. Supported for Cloud Composer environments in versions -// composer-1.*.*-airflow-*.*.*. -message EncryptionConfig { - // Optional. Customer-managed Encryption Key available through Google's Key - // Management Service. Cannot be updated. If not specified, Google-managed key - // will be used. - string kms_key_name = 1 [(google.api.field_behavior) = OPTIONAL]; -} - -// The configuration settings for Cloud Composer maintenance window. -// The following example: -// -// ``` -// { -// "startTime":"2019-08-01T01:00:00Z" -// "endTime":"2019-08-01T07:00:00Z" -// "recurrence":"FREQ=WEEKLY;BYDAY=TU,WE" -// } -// ``` -// -// would define a maintenance window between 01 and 07 hours UTC during -// each Tuesday and Wednesday. -message MaintenanceWindow { - // Required. Start time of the first recurrence of the maintenance window. - google.protobuf.Timestamp start_time = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. Maintenance window end time. It is used only to calculate the - // duration of the maintenance window. The value for end_time must be in the - // future, relative to `start_time`. - google.protobuf.Timestamp end_time = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Required. Maintenance window recurrence. Format is a subset of - // [RFC-5545](https://tools.ietf.org/html/rfc5545) `RRULE`. The only allowed - // values for `FREQ` field are `FREQ=DAILY` and `FREQ=WEEKLY;BYDAY=...` - // Example values: `FREQ=WEEKLY;BYDAY=TU,WE`, `FREQ=DAILY`. - string recurrence = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// The Kubernetes workloads configuration for GKE cluster associated with the -// Cloud Composer environment. Supported for Cloud Composer environments in -// versions composer-2.*.*-airflow-*.*.* and newer. -message WorkloadsConfig { - // Configuration for resources used by Airflow schedulers. - message SchedulerResource { - // Optional. CPU request and limit for a single Airflow scheduler replica. - float cpu = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Memory (GB) request and limit for a single Airflow scheduler - // replica. - float memory_gb = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Storage (GB) request and limit for a single Airflow scheduler - // replica. - float storage_gb = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The number of schedulers. - int32 count = 4 [(google.api.field_behavior) = OPTIONAL]; - } - - // Configuration for resources used by Airflow web server. - message WebServerResource { - // Optional. CPU request and limit for Airflow web server. - float cpu = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Memory (GB) request and limit for Airflow web server. - float memory_gb = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Storage (GB) request and limit for Airflow web server. - float storage_gb = 3 [(google.api.field_behavior) = OPTIONAL]; - } - - // Configuration for resources used by Airflow workers. - message WorkerResource { - // Optional. CPU request and limit for a single Airflow worker replica. - float cpu = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Memory (GB) request and limit for a single Airflow worker - // replica. - float memory_gb = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Storage (GB) request and limit for a single Airflow worker - // replica. - float storage_gb = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Minimum number of workers for autoscaling. - int32 min_count = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Maximum number of workers for autoscaling. - int32 max_count = 5 [(google.api.field_behavior) = OPTIONAL]; - } - - // Configuration for resources used by Airflow triggerers. - message TriggererResource { - // Optional. The number of triggerers. - int32 count = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. CPU request and limit for a single Airflow triggerer replica. - float cpu = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Memory (GB) request and limit for a single Airflow triggerer - // replica. - float memory_gb = 3 [(google.api.field_behavior) = OPTIONAL]; - } - - // Optional. Resources used by Airflow schedulers. - SchedulerResource scheduler = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Resources used by Airflow web server. - WebServerResource web_server = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Resources used by Airflow workers. - WorkerResource worker = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Resources used by Airflow triggerers. - TriggererResource triggerer = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// The Recovery settings of an environment. -message RecoveryConfig { - // Optional. The configuration for scheduled snapshot creation mechanism. - ScheduledSnapshotsConfig scheduled_snapshots_config = 1 - [(google.api.field_behavior) = OPTIONAL]; -} - -// The configuration for scheduled snapshot creation mechanism. -message ScheduledSnapshotsConfig { - // Optional. Whether scheduled snapshots creation is enabled. - bool enabled = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The Cloud Storage location for storing automatically created - // snapshots. - string snapshot_location = 6 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The cron expression representing the time when snapshots creation - // mechanism runs. This field is subject to additional validation around - // frequency of execution. - string snapshot_creation_schedule = 3 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Time zone that sets the context to interpret - // snapshot_creation_schedule. - string time_zone = 5 [(google.api.field_behavior) = OPTIONAL]; -} - -// Configuration options for the master authorized networks feature. Enabled -// master authorized networks will disallow all external traffic to access -// Kubernetes master through HTTPS except traffic from the given CIDR blocks, -// Google Compute Engine Public IPs and Google Prod IPs. -message MasterAuthorizedNetworksConfig { - // CIDR block with an optional name. - message CidrBlock { - // User-defined name that identifies the CIDR block. - string display_name = 1; - - // CIDR block that must be specified in CIDR notation. - string cidr_block = 2; - } - - // Whether or not master authorized networks feature is enabled. - bool enabled = 1; - - // Up to 50 external networks that could access Kubernetes master through - // HTTPS. - repeated CidrBlock cidr_blocks = 2; -} - -// Configuration for Cloud Data Lineage integration. -message CloudDataLineageIntegration { - // Optional. Whether or not Cloud Data Lineage integration is enabled. - bool enabled = 1 [(google.api.field_behavior) = OPTIONAL]; -} - -// An environment for running orchestration tasks. -message Environment { - option (google.api.resource) = { - type: "composer.googleapis.com/Environment" - pattern: "projects/{project}/locations/{location}/environments/{environment}" - }; - - // State of the environment. - enum State { - // The state of the environment is unknown. - STATE_UNSPECIFIED = 0; - - // The environment is in the process of being created. - CREATING = 1; - - // The environment is currently running and healthy. It is ready for use. - RUNNING = 2; - - // The environment is being updated. It remains usable but cannot receive - // additional update requests or be deleted at this time. - UPDATING = 3; - - // The environment is undergoing deletion. It cannot be used. - DELETING = 4; - - // The environment has encountered an error and cannot be used. - ERROR = 5; - } - - // The resource name of the environment, in the form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - // - // EnvironmentId must start with a lowercase letter followed by up to 63 - // lowercase letters, numbers, or hyphens, and cannot end with a hyphen. - string name = 1; - - // Configuration parameters for this environment. - EnvironmentConfig config = 2; - - // Output only. The UUID (Universally Unique IDentifier) associated with this - // environment. This value is generated when the environment is created. - string uuid = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The current state of the environment. - State state = 4; - - // Output only. The time at which this environment was created. - google.protobuf.Timestamp create_time = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time at which this environment was last modified. - google.protobuf.Timestamp update_time = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. User-defined labels for this environment. - // The labels map can contain no more than 64 entries. Entries of the labels - // map are UTF8 strings that comply with the following restrictions: - // - // * Keys must conform to regexp: [\p{Ll}\p{Lo}][\p{Ll}\p{Lo}\p{N}_-]{0,62} - // * Values must conform to regexp: [\p{Ll}\p{Lo}\p{N}_-]{0,63} - // * Both keys and values are additionally constrained to be <= 128 bytes in - // size. - map labels = 7 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request to check whether image upgrade will succeed. -message CheckUpgradeRequest { - // The resource name of the environment to check upgrade for, in the - // form: - // "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - string environment = 1; - - // The version of the software running in the environment. - // This encapsulates both the version of Cloud Composer functionality and the - // version of Apache Airflow. It must match the regular expression - // `composer-([0-9]+(\.[0-9]+\.[0-9]+(-preview\.[0-9]+)?)?|latest)-airflow-([0-9]+(\.[0-9]+(\.[0-9]+)?)?)`. - // When used as input, the server also checks if the provided version is - // supported and denies the request for an unsupported version. - // - // The Cloud Composer portion of the image version is a full - // [semantic version](https://semver.org), or an alias in the form of major - // version number or `latest`. When an alias is provided, the server replaces - // it with the current Cloud Composer version that satisfies the alias. - // - // The Apache Airflow portion of the image version is a full semantic version - // that points to one of the supported Apache Airflow versions, or an alias in - // the form of only major or major.minor versions specified. When an alias is - // provided, the server replaces it with the latest Apache Airflow version - // that satisfies the alias and is supported in the given Cloud Composer - // version. - // - // In all cases, the resolved image version is stored in the same field. - // - // See also [version - // list](/composer/docs/concepts/versioning/composer-versions) and [versioning - // overview](/composer/docs/concepts/versioning/composer-versioning-overview). - string image_version = 2; -} - -// Message containing information about the result of an upgrade check -// operation. -message CheckUpgradeResponse { - // Whether there were python modules conflict during image build. - enum ConflictResult { - // It is unknown whether build had conflicts or not. - CONFLICT_RESULT_UNSPECIFIED = 0; - - // There were python packages conflicts. - CONFLICT = 1; - - // There were no python packages conflicts. - NO_CONFLICT = 2; - } - - // Output only. Url for a docker build log of an upgraded image. - string build_log_uri = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Whether build has succeeded or failed on modules conflicts. - ConflictResult contains_pypi_modules_conflict = 4 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Extract from a docker image build log containing information - // about pypi modules conflicts. - string pypi_conflict_build_log_extract = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Composer image for which the build was happening. - string image_version = 5; - - // Pypi dependencies specified in the environment configuration, at the time - // when the build was triggered. - map pypi_dependencies = 6; -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/image_versions.proto b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/image_versions.proto deleted file mode 100644 index e462bee578b..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/image_versions.proto +++ /dev/null @@ -1,90 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.orchestration.airflow.service.v1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/type/date.proto"; - -option go_package = "cloud.google.com/go/orchestration/airflow/service/apiv1beta1/servicepb;servicepb"; -option java_multiple_files = true; -option java_package = "com.google.cloud.orchestration.airflow.service.v1beta1"; - -// Readonly service to query available ImageVersions. -service ImageVersions { - option (google.api.default_host) = "composer.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // List ImageVersions for provided location. - rpc ListImageVersions(ListImageVersionsRequest) - returns (ListImageVersionsResponse) { - option (google.api.http) = { - get: "/v1beta1/{parent=projects/*/locations/*}/imageVersions" - }; - option (google.api.method_signature) = "parent"; - } -} - -// List ImageVersions in a project and location. -message ListImageVersionsRequest { - // List ImageVersions in the given project and location, in the form: - // "projects/{projectId}/locations/{locationId}" - string parent = 1; - - // The maximum number of image_versions to return. - int32 page_size = 2; - - // The next_page_token value returned from a previous List request, if any. - string page_token = 3; - - // Whether or not image versions from old releases should be included. - bool include_past_releases = 4; -} - -// The ImageVersions in a project and location. -message ListImageVersionsResponse { - // The list of supported ImageVersions in a location. - repeated ImageVersion image_versions = 1; - - // The page token used to query for the next page if one exists. - string next_page_token = 2; -} - -// Image Version information -message ImageVersion { - // The string identifier of the ImageVersion, in the form: - // "composer-x.y.z-airflow-a.b.c" - string image_version_id = 1; - - // Whether this is the default ImageVersion used by Composer during - // environment creation if no input ImageVersion is specified. - bool is_default = 2; - - // supported python versions - repeated string supported_python_versions = 3; - - // The date of the version release. - google.type.Date release_date = 4; - - // Whether it is impossible to create an environment with the image version. - bool creation_disabled = 5; - - // Whether it is impossible to upgrade an environment running with the image - // version. - bool upgrade_disabled = 6; -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/operations.proto b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/operations.proto deleted file mode 100644 index 6596658a0be..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/protos/google/cloud/orchestration/airflow/service/v1beta1/operations.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.orchestration.airflow.service.v1beta1; - -import "google/protobuf/timestamp.proto"; - -option go_package = "cloud.google.com/go/orchestration/airflow/service/apiv1beta1/servicepb;servicepb"; -option java_multiple_files = true; -option java_outer_classname = "OperationsProto"; -option java_package = "com.google.cloud.orchestration.airflow.service.v1beta1"; - -// Metadata describing an operation. -message OperationMetadata { - // An enum describing the overall state of an operation. - enum State { - // Unused. - STATE_UNSPECIFIED = 0; - - // The operation has been created but is not yet started. - PENDING = 1; - - // The operation is underway. - RUNNING = 2; - - // The operation completed successfully. - SUCCESSFUL = 3; - - // The operation is no longer running but did not succeed. - FAILED = 4; - } - - // Type of longrunning operation. - enum Type { - // Unused. - TYPE_UNSPECIFIED = 0; - - // A resource creation operation. - CREATE = 1; - - // A resource deletion operation. - DELETE = 2; - - // A resource update operation. - UPDATE = 3; - - // A resource check operation. - CHECK = 4; - - // Saves snapshot of the resource operation. - SAVE_SNAPSHOT = 5; - - // Loads snapshot of the resource operation. - LOAD_SNAPSHOT = 6; - - // Triggers failover of environment's Cloud SQL instance (only for highly - // resilient environments). - DATABASE_FAILOVER = 7; - } - - // Output only. The current operation state. - State state = 1; - - // Output only. The type of operation being performed. - Type operation_type = 2; - - // Output only. The resource being operated on, as a [relative resource name]( - // /apis/design/resource_names#relative_resource_name). - string resource = 3; - - // Output only. The UUID of the resource being operated on. - string resource_uuid = 4; - - // Output only. The time the operation was submitted to the server. - google.protobuf.Timestamp create_time = 5; - - // Output only. The time when the operation terminated, regardless of its - // success. This field is unset if the operation is still ongoing. - google.protobuf.Timestamp end_time = 6; -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.check_upgrade.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.check_upgrade.js deleted file mode 100644 index f3c78a96f03..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.check_upgrade.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() { - // [START composer_v1beta1_generated_Environments_CheckUpgrade_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 resource name of the environment to check upgrade for, in the - * form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - */ - // const environment = 'abc123' - /** - * The version of the software running in the environment. - * This encapsulates both the version of Cloud Composer functionality and the - * version of Apache Airflow. It must match the regular expression - * `composer-([0-9]+(\.[0-9]+\.[0-9]+(-preview\.[0-9]+)?)?|latest)-airflow-([0-9]+(\.[0-9]+(\.[0-9]+)?)?)`. - * When used as input, the server also checks if the provided version is - * supported and denies the request for an unsupported version. - * The Cloud Composer portion of the image version is a full - * semantic version (https://semver.org), or an alias in the form of major - * version number or `latest`. When an alias is provided, the server replaces - * it with the current Cloud Composer version that satisfies the alias. - * The Apache Airflow portion of the image version is a full semantic version - * that points to one of the supported Apache Airflow versions, or an alias in - * the form of only major or major.minor versions specified. When an alias is - * provided, the server replaces it with the latest Apache Airflow version - * that satisfies the alias and is supported in the given Cloud Composer - * version. - * In all cases, the resolved image version is stored in the same field. - * See also version - * list (/composer/docs/concepts/versioning/composer-versions) and versioning - * overview (/composer/docs/concepts/versioning/composer-versioning-overview). - */ - // const imageVersion = 'abc123' - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callCheckUpgrade() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await serviceClient.checkUpgrade(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCheckUpgrade(); - // [END composer_v1beta1_generated_Environments_CheckUpgrade_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.create_environment.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.create_environment.js deleted file mode 100644 index f04ffc54699..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.create_environment.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() { - // [START composer_v1beta1_generated_Environments_CreateEnvironment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 must be of the form - * "projects/{projectId}/locations/{locationId}". - */ - // const parent = 'abc123' - /** - * The environment to create. - */ - // const environment = {} - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callCreateEnvironment() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await serviceClient.createEnvironment(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateEnvironment(); - // [END composer_v1beta1_generated_Environments_CreateEnvironment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.database_failover.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.database_failover.js deleted file mode 100644 index bb558fa6504..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.database_failover.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() { - // [START composer_v1beta1_generated_Environments_DatabaseFailover_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Target environment: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - */ - // const environment = 'abc123' - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callDatabaseFailover() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await serviceClient.databaseFailover(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDatabaseFailover(); - // [END composer_v1beta1_generated_Environments_DatabaseFailover_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.delete_environment.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.delete_environment.js deleted file mode 100644 index 68193b50961..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.delete_environment.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() { - // [START composer_v1beta1_generated_Environments_DeleteEnvironment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 environment to delete, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - */ - // const name = 'abc123' - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callDeleteEnvironment() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await serviceClient.deleteEnvironment(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteEnvironment(); - // [END composer_v1beta1_generated_Environments_DeleteEnvironment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.execute_airflow_command.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.execute_airflow_command.js deleted file mode 100644 index 896d2ec8e0d..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.execute_airflow_command.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() { - // [START composer_v1beta1_generated_Environments_ExecuteAirflowCommand_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 resource name of the environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}". - */ - // const environment = 'abc123' - /** - * Airflow command. - */ - // const command = 'abc123' - /** - * Airflow subcommand. - */ - // const subcommand = 'abc123' - /** - * Parameters for the Airflow command/subcommand as an array of arguments. - * It may contain positional arguments like `["my-dag-id"]`, key-value - * parameters like `["--foo=bar"]` or `["--foo","bar"]`, - * or other flags like `["-f"]`. - */ - // const parameters = ['abc','def'] - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callExecuteAirflowCommand() { - // Construct request - const request = { - }; - - // Run request - const response = await serviceClient.executeAirflowCommand(request); - console.log(response); - } - - callExecuteAirflowCommand(); - // [END composer_v1beta1_generated_Environments_ExecuteAirflowCommand_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.fetch_database_properties.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.fetch_database_properties.js deleted file mode 100644 index 29d78af48ca..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.fetch_database_properties.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(environment) { - // [START composer_v1beta1_generated_Environments_FetchDatabaseProperties_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 environment, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - */ - // const environment = 'abc123' - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callFetchDatabaseProperties() { - // Construct request - const request = { - environment, - }; - - // Run request - const response = await serviceClient.fetchDatabaseProperties(request); - console.log(response); - } - - callFetchDatabaseProperties(); - // [END composer_v1beta1_generated_Environments_FetchDatabaseProperties_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.get_environment.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.get_environment.js deleted file mode 100644 index 10090e1abea..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.get_environment.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 composer_v1beta1_generated_Environments_GetEnvironment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 resource name of the environment to get, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - */ - // const name = 'abc123' - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callGetEnvironment() { - // Construct request - const request = { - }; - - // Run request - const response = await serviceClient.getEnvironment(request); - console.log(response); - } - - callGetEnvironment(); - // [END composer_v1beta1_generated_Environments_GetEnvironment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.list_environments.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.list_environments.js deleted file mode 100644 index 763992469ec..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.list_environments.js +++ /dev/null @@ -1,71 +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 composer_v1beta1_generated_Environments_ListEnvironments_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * List environments in the given project and location, in the form: - * "projects/{projectId}/locations/{locationId}" - */ - // const parent = 'abc123' - /** - * The maximum number of environments to return. - */ - // const pageSize = 1234 - /** - * The next_page_token value returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callListEnvironments() { - // Construct request - const request = { - }; - - // Run request - const iterable = await serviceClient.listEnvironmentsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListEnvironments(); - // [END composer_v1beta1_generated_Environments_ListEnvironments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.load_snapshot.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.load_snapshot.js deleted file mode 100644 index c29bf688b73..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.load_snapshot.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() { - // [START composer_v1beta1_generated_Environments_LoadSnapshot_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 resource name of the target environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - */ - // const environment = 'abc123' - /** - * A Cloud Storage path to a snapshot to load, e.g.: - * "gs://my-bucket/snapshots/project_location_environment_timestamp". - */ - // const snapshotPath = 'abc123' - /** - * Whether or not to skip installing Pypi packages when loading the - * environment's state. - */ - // const skipPypiPackagesInstallation = true - /** - * Whether or not to skip setting environment variables when loading the - * environment's state. - */ - // const skipEnvironmentVariablesSetting = true - /** - * Whether or not to skip setting Airflow overrides when loading the - * environment's state. - */ - // const skipAirflowOverridesSetting = true - /** - * Whether or not to skip copying Cloud Storage data when loading the - * environment's state. - */ - // const skipGcsDataCopying = true - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callLoadSnapshot() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await serviceClient.loadSnapshot(request); - const [response] = await operation.promise(); - console.log(response); - } - - callLoadSnapshot(); - // [END composer_v1beta1_generated_Environments_LoadSnapshot_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.poll_airflow_command.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.poll_airflow_command.js deleted file mode 100644 index 45909ccfdbc..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.poll_airflow_command.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() { - // [START composer_v1beta1_generated_Environments_PollAirflowCommand_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 resource name of the environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - */ - // const environment = 'abc123' - /** - * The unique ID of the command execution. - */ - // const executionId = 'abc123' - /** - * The name of the pod where the command is executed. - */ - // const pod = 'abc123' - /** - * The namespace of the pod where the command is executed. - */ - // const podNamespace = 'abc123' - /** - * Line number from which new logs should be fetched. - */ - // const nextLineNumber = 1234 - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callPollAirflowCommand() { - // Construct request - const request = { - }; - - // Run request - const response = await serviceClient.pollAirflowCommand(request); - console.log(response); - } - - callPollAirflowCommand(); - // [END composer_v1beta1_generated_Environments_PollAirflowCommand_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.restart_web_server.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.restart_web_server.js deleted file mode 100644 index 92462671db2..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.restart_web_server.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() { - // [START composer_v1beta1_generated_Environments_RestartWebServer_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 resource name of the environment to restart the web server for, in the - * form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - */ - // const name = 'abc123' - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callRestartWebServer() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await serviceClient.restartWebServer(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRestartWebServer(); - // [END composer_v1beta1_generated_Environments_RestartWebServer_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.save_snapshot.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.save_snapshot.js deleted file mode 100644 index 2b3dd3a816e..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.save_snapshot.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() { - // [START composer_v1beta1_generated_Environments_SaveSnapshot_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 resource name of the source environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - */ - // const environment = 'abc123' - /** - * Location in a Cloud Storage where the snapshot is going to be stored, e.g.: - * "gs://my-bucket/snapshots". - */ - // const snapshotLocation = 'abc123' - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callSaveSnapshot() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await serviceClient.saveSnapshot(request); - const [response] = await operation.promise(); - console.log(response); - } - - callSaveSnapshot(); - // [END composer_v1beta1_generated_Environments_SaveSnapshot_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.stop_airflow_command.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.stop_airflow_command.js deleted file mode 100644 index 5a2140f7fef..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.stop_airflow_command.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() { - // [START composer_v1beta1_generated_Environments_StopAirflowCommand_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 resource name of the environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}". - */ - // const environment = 'abc123' - /** - * The unique ID of the command execution. - */ - // const executionId = 'abc123' - /** - * The name of the pod where the command is executed. - */ - // const pod = 'abc123' - /** - * The namespace of the pod where the command is executed. - */ - // const podNamespace = 'abc123' - /** - * If true, the execution is terminated forcefully (SIGKILL). If false, the - * execution is stopped gracefully, giving it time for cleanup. - */ - // const force = true - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callStopAirflowCommand() { - // Construct request - const request = { - }; - - // Run request - const response = await serviceClient.stopAirflowCommand(request); - console.log(response); - } - - callStopAirflowCommand(); - // [END composer_v1beta1_generated_Environments_StopAirflowCommand_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.update_environment.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.update_environment.js deleted file mode 100644 index 4ac87ab1c36..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/environments.update_environment.js +++ /dev/null @@ -1,206 +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(updateMask) { - // [START composer_v1beta1_generated_Environments_UpdateEnvironment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 relative resource name of the environment to update, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - */ - // const name = 'abc123' - /** - * A patch environment. Fields specified by the `updateMask` will be copied - * from the patch environment into the environment under update. - */ - // const environment = {} - /** - * Required. A comma-separated list of paths, relative to `Environment`, of - * fields to update. - * For example, to set the version of scikit-learn to install in the - * environment to 0.19.0 and to remove an existing installation of - * argparse, the `updateMask` parameter would include the following two - * `paths` values: "config.softwareConfig.pypiPackages.scikit-learn" and - * "config.softwareConfig.pypiPackages.argparse". The included patch - * environment would specify the scikit-learn version as follows: - * { - * "config":{ - * "softwareConfig":{ - * "pypiPackages":{ - * "scikit-learn":"==0.19.0" - * } - * } - * } - * } - * Note that in the above example, any existing PyPI packages - * other than scikit-learn and argparse will be unaffected. - * Only one update type may be included in a single request's `updateMask`. - * For example, one cannot update both the PyPI packages and - * labels in the same request. However, it is possible to update multiple - * members of a map field simultaneously in the same request. For example, - * to set the labels "label1" and "label2" while clearing "label3" (assuming - * it already exists), one can - * provide the paths "labels.label1", "labels.label2", and "labels.label3" - * and populate the patch environment as follows: - * { - * "labels":{ - * "label1":"new-label1-value" - * "label2":"new-label2-value" - * } - * } - * Note that in the above example, any existing labels that are not - * included in the `updateMask` will be unaffected. - * It is also possible to replace an entire map field by providing the - * map field's path in the `updateMask`. The new value of the field will - * be that which is provided in the patch environment. For example, to - * delete all pre-existing user-specified PyPI packages and - * install botocore at version 1.7.14, the `updateMask` would contain - * the path "config.softwareConfig.pypiPackages", and - * the patch environment would be the following: - * { - * "config":{ - * "softwareConfig":{ - * "pypiPackages":{ - * "botocore":"==1.7.14" - * } - * } - * } - * } - * **Note:** Only the following fields can be updated: - * * `config.softwareConfig.pypiPackages` - * * Replace all custom custom PyPI packages. If a replacement - * package map is not included in `environment`, all custom - * PyPI packages are cleared. It is an error to provide both - * this mask and a mask specifying an individual package. - * * `config.softwareConfig.pypiPackages.`packagename - * * Update the custom PyPI package *packagename*, - * preserving other packages. To delete the package, include it in - * `updateMask`, and omit the mapping for it in - * `environment.config.softwareConfig.pypiPackages`. It is an error - * to provide both a mask of this form and the - * `config.softwareConfig.pypiPackages` mask. - * * `labels` - * * Replace all environment labels. If a replacement labels map is not - * included in `environment`, all labels are cleared. It is an error to - * provide both this mask and a mask specifying one or more individual - * labels. - * * `labels.`labelName - * * Set the label named *labelName*, while preserving other - * labels. To delete the label, include it in `updateMask` and omit its - * mapping in `environment.labels`. It is an error to provide both a - * mask of this form and the `labels` mask. - * * `config.nodeCount` - * * Horizontally scale the number of nodes in the environment. An integer - * greater than or equal to 3 must be provided in the `config.nodeCount` - * field. Supported for Cloud Composer environments in versions - * composer-1.*.*-airflow-*.*.*. - * * `config.webServerNetworkAccessControl` - * * Replace the environment's current WebServerNetworkAccessControl. - * * `config.softwareConfig.airflowConfigOverrides` - * * Replace all Apache Airflow config overrides. If a replacement config - * overrides map is not included in `environment`, all config overrides - * are cleared. - * It is an error to provide both this mask and a mask specifying one or - * more individual config overrides. - * * `config.softwareConfig.airflowConfigOverrides.`section-name - * * Override the Apache Airflow config property *name* in the - * section named *section*, preserving other properties. To - * delete the property override, include it in `updateMask` and omit its - * mapping in - * `environment.config.softwareConfig.airflowConfigOverrides`. - * It is an error to provide both a mask of this form and the - * `config.softwareConfig.airflowConfigOverrides` mask. - * * `config.softwareConfig.envVariables` - * * Replace all environment variables. If a replacement environment - * variable map is not included in `environment`, all custom environment - * variables are cleared. - * * `config.softwareConfig.imageVersion` - * * Upgrade the version of the environment in-place. Refer to - * `SoftwareConfig.image_version` for information on how to format the - * new image version. Additionally, the new image version cannot effect - * a version downgrade, and must match the current image version's - * Composer and Airflow major versions. Consult the Cloud Composer - * version list (/composer/docs/concepts/versioning/composer-versions) - * for valid values. - * * `config.softwareConfig.schedulerCount` - * * Horizontally scale the number of schedulers in Airflow. A positive - * integer not greater than the number of nodes must be provided in the - * `config.softwareConfig.schedulerCount` field. Supported for Cloud - * Composer environments in versions composer-1.*.*-airflow-2.*.*. - * * `config.softwareConfig.cloudDataLineageIntegration` - * * Configuration for Cloud Data Lineage integration. - * * `config.databaseConfig.machineType` - * * Cloud SQL machine type used by Airflow database. - * It has to be one of: db-n1-standard-2, db-n1-standard-4, - * db-n1-standard-8 or db-n1-standard-16. Supported for Cloud Composer - * environments in versions composer-1.*.*-airflow-*.*.*. - * * `config.webServerConfig.machineType` - * * Machine type on which Airflow web server is running. - * It has to be one of: composer-n1-webserver-2, composer-n1-webserver-4 - * or composer-n1-webserver-8. Supported for Cloud Composer environments - * in versions composer-1.*.*-airflow-*.*.*. - * * `config.maintenanceWindow` - * * Maintenance window during which Cloud Composer components may be - * under maintenance. - * * `config.workloadsConfig` - * * The workloads configuration settings for the GKE cluster associated - * with the Cloud Composer environment. Supported for Cloud Composer - * environments in versions composer-2.*.*-airflow-*.*.* and newer. - * * `config.environmentSize` - * * The size of the Cloud Composer environment. Supported for Cloud - * Composer environments in versions composer-2.*.*-airflow-*.*.* and - * newer. - */ - // const updateMask = {} - - // Imports the Service library - const {EnvironmentsClient} = require('@google-cloud/orchestration-airflow').v1beta1; - - // Instantiates a client - const serviceClient = new EnvironmentsClient(); - - async function callUpdateEnvironment() { - // Construct request - const request = { - updateMask, - }; - - // Run request - const [operation] = await serviceClient.updateEnvironment(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateEnvironment(); - // [END composer_v1beta1_generated_Environments_UpdateEnvironment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/image_versions.list_image_versions.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/image_versions.list_image_versions.js deleted file mode 100644 index 7e62f694394..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/image_versions.list_image_versions.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() { - // [START composer_v1beta1_generated_ImageVersions_ListImageVersions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * List ImageVersions in the given project and location, in the form: - * "projects/{projectId}/locations/{locationId}" - */ - // const parent = 'abc123' - /** - * The maximum number of image_versions to return. - */ - // const pageSize = 1234 - /** - * The next_page_token value returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - /** - * Whether or not image versions from old releases should be included. - */ - // const includePastReleases = true - - // Imports the Service library - const {ImageVersionsClient} = require('@google-cloud/orchestration-airflow').v1beta1; - - // Instantiates a client - const serviceClient = new ImageVersionsClient(); - - async function callListImageVersions() { - // Construct request - const request = { - }; - - // Run request - const iterable = await serviceClient.listImageVersionsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListImageVersions(); - // [END composer_v1beta1_generated_ImageVersions_ListImageVersions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.orchestration.airflow.service.v1beta1.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.orchestration.airflow.service.v1beta1.json deleted file mode 100644 index 5ee66b6b4a1..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.orchestration.airflow.service.v1beta1.json +++ /dev/null @@ -1,719 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-service", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.orchestration.airflow.service.v1beta1", - "version": "v1beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "composer_v1beta1_generated_Environments_CreateEnvironment_async", - "title": "Environments createEnvironment Sample", - "origin": "API_DEFINITION", - "description": " Create a new environment.", - "canonical": true, - "file": "environments.create_environment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateEnvironment", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.CreateEnvironment", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "environment", - "type": ".google.cloud.orchestration.airflow.service.v1beta1.Environment" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" - }, - "method": { - "shortName": "CreateEnvironment", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.CreateEnvironment", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1beta1_generated_Environments_GetEnvironment_async", - "title": "Environments getEnvironment Sample", - "origin": "API_DEFINITION", - "description": " Get an existing environment.", - "canonical": true, - "file": "environments.get_environment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetEnvironment", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.GetEnvironment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.orchestration.airflow.service.v1beta1.Environment", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" - }, - "method": { - "shortName": "GetEnvironment", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.GetEnvironment", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1beta1_generated_Environments_ListEnvironments_async", - "title": "Environments listEnvironments Sample", - "origin": "API_DEFINITION", - "description": " List environments.", - "canonical": true, - "file": "environments.list_environments.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListEnvironments", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.ListEnvironments", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsResponse", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" - }, - "method": { - "shortName": "ListEnvironments", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.ListEnvironments", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1beta1_generated_Environments_UpdateEnvironment_async", - "title": "Environments updateEnvironment Sample", - "origin": "API_DEFINITION", - "description": " Update an environment.", - "canonical": true, - "file": "environments.update_environment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 198, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateEnvironment", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.UpdateEnvironment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "environment", - "type": ".google.cloud.orchestration.airflow.service.v1beta1.Environment" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" - }, - "method": { - "shortName": "UpdateEnvironment", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.UpdateEnvironment", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1beta1_generated_Environments_DeleteEnvironment_async", - "title": "Environments deleteEnvironment Sample", - "origin": "API_DEFINITION", - "description": " Delete an environment.", - "canonical": true, - "file": "environments.delete_environment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteEnvironment", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.DeleteEnvironment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" - }, - "method": { - "shortName": "DeleteEnvironment", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.DeleteEnvironment", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1beta1_generated_Environments_RestartWebServer_async", - "title": "Environments restartWebServer Sample", - "origin": "API_DEFINITION", - "description": " Restart Airflow web server.", - "canonical": true, - "file": "environments.restart_web_server.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RestartWebServer", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.RestartWebServer", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" - }, - "method": { - "shortName": "RestartWebServer", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.RestartWebServer", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1beta1_generated_Environments_CheckUpgrade_async", - "title": "Environments checkUpgrade Sample", - "origin": "API_DEFINITION", - "description": " Check if an upgrade operation on the environment will succeed. In case of problems detailed info can be found in the returned Operation.", - "canonical": true, - "file": "environments.check_upgrade.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 78, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CheckUpgrade", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.CheckUpgrade", - "async": true, - "parameters": [ - { - "name": "environment", - "type": "TYPE_STRING" - }, - { - "name": "image_version", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" - }, - "method": { - "shortName": "CheckUpgrade", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.CheckUpgrade", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1beta1_generated_Environments_ExecuteAirflowCommand_async", - "title": "Environments executeAirflowCommand Sample", - "origin": "API_DEFINITION", - "description": " Executes Airflow CLI command.", - "canonical": true, - "file": "environments.execute_airflow_command.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ExecuteAirflowCommand", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.ExecuteAirflowCommand", - "async": true, - "parameters": [ - { - "name": "environment", - "type": "TYPE_STRING" - }, - { - "name": "command", - "type": "TYPE_STRING" - }, - { - "name": "subcommand", - "type": "TYPE_STRING" - }, - { - "name": "parameters", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandResponse", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" - }, - "method": { - "shortName": "ExecuteAirflowCommand", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.ExecuteAirflowCommand", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1beta1_generated_Environments_StopAirflowCommand_async", - "title": "Environments stopAirflowCommand Sample", - "origin": "API_DEFINITION", - "description": " Stops Airflow CLI command execution.", - "canonical": true, - "file": "environments.stop_airflow_command.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "StopAirflowCommand", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.StopAirflowCommand", - "async": true, - "parameters": [ - { - "name": "environment", - "type": "TYPE_STRING" - }, - { - "name": "execution_id", - "type": "TYPE_STRING" - }, - { - "name": "pod", - "type": "TYPE_STRING" - }, - { - "name": "pod_namespace", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandResponse", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" - }, - "method": { - "shortName": "StopAirflowCommand", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.StopAirflowCommand", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1beta1_generated_Environments_PollAirflowCommand_async", - "title": "Environments pollAirflowCommand Sample", - "origin": "API_DEFINITION", - "description": " Polls Airflow CLI command execution and fetches logs.", - "canonical": true, - "file": "environments.poll_airflow_command.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PollAirflowCommand", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.PollAirflowCommand", - "async": true, - "parameters": [ - { - "name": "environment", - "type": "TYPE_STRING" - }, - { - "name": "execution_id", - "type": "TYPE_STRING" - }, - { - "name": "pod", - "type": "TYPE_STRING" - }, - { - "name": "pod_namespace", - "type": "TYPE_STRING" - }, - { - "name": "next_line_number", - "type": "TYPE_INT32" - } - ], - "resultType": ".google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandResponse", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" - }, - "method": { - "shortName": "PollAirflowCommand", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.PollAirflowCommand", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1beta1_generated_Environments_SaveSnapshot_async", - "title": "Environments saveSnapshot Sample", - "origin": "API_DEFINITION", - "description": " Creates a snapshots of a Cloud Composer environment. As a result of this operation, snapshot of environment's state is stored in a location specified in the SaveSnapshotRequest.", - "canonical": true, - "file": "environments.save_snapshot.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SaveSnapshot", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.SaveSnapshot", - "async": true, - "parameters": [ - { - "name": "environment", - "type": "TYPE_STRING" - }, - { - "name": "snapshot_location", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" - }, - "method": { - "shortName": "SaveSnapshot", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.SaveSnapshot", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1beta1_generated_Environments_LoadSnapshot_async", - "title": "Environments loadSnapshot Sample", - "origin": "API_DEFINITION", - "description": " Loads a snapshot of a Cloud Composer environment. As a result of this operation, a snapshot of environment's specified in LoadSnapshotRequest is loaded into the environment.", - "canonical": true, - "file": "environments.load_snapshot.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 79, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "LoadSnapshot", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.LoadSnapshot", - "async": true, - "parameters": [ - { - "name": "environment", - "type": "TYPE_STRING" - }, - { - "name": "snapshot_path", - "type": "TYPE_STRING" - }, - { - "name": "skip_pypi_packages_installation", - "type": "TYPE_BOOL" - }, - { - "name": "skip_environment_variables_setting", - "type": "TYPE_BOOL" - }, - { - "name": "skip_airflow_overrides_setting", - "type": "TYPE_BOOL" - }, - { - "name": "skip_gcs_data_copying", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" - }, - "method": { - "shortName": "LoadSnapshot", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.LoadSnapshot", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1beta1_generated_Environments_DatabaseFailover_async", - "title": "Environments databaseFailover Sample", - "origin": "API_DEFINITION", - "description": " Triggers database failover (only for highly resilient environments).", - "canonical": true, - "file": "environments.database_failover.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DatabaseFailover", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.DatabaseFailover", - "async": true, - "parameters": [ - { - "name": "environment", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" - }, - "method": { - "shortName": "DatabaseFailover", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.DatabaseFailover", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1beta1_generated_Environments_FetchDatabaseProperties_async", - "title": "Environments fetchDatabaseProperties Sample", - "origin": "API_DEFINITION", - "description": " Fetches database properties.", - "canonical": true, - "file": "environments.fetch_database_properties.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "FetchDatabaseProperties", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.FetchDatabaseProperties", - "async": true, - "parameters": [ - { - "name": "environment", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesResponse", - "client": { - "shortName": "EnvironmentsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient" - }, - "method": { - "shortName": "FetchDatabaseProperties", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments.FetchDatabaseProperties", - "service": { - "shortName": "Environments", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.Environments" - } - } - } - }, - { - "regionTag": "composer_v1beta1_generated_ImageVersions_ListImageVersions_async", - "title": "Environments listImageVersions Sample", - "origin": "API_DEFINITION", - "description": " List ImageVersions for provided location.", - "canonical": true, - "file": "image_versions.list_image_versions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListImageVersions", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.ImageVersions.ListImageVersions", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "include_past_releases", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsResponse", - "client": { - "shortName": "ImageVersionsClient", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.ImageVersionsClient" - }, - "method": { - "shortName": "ListImageVersions", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.ImageVersions.ListImageVersions", - "service": { - "shortName": "ImageVersions", - "fullName": "google.cloud.orchestration.airflow.service.v1beta1.ImageVersions" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/index.ts deleted file mode 100644 index 06b3dd52c3b..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/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. ** - -import * as v1beta1 from './v1beta1'; -const EnvironmentsClient = v1beta1.EnvironmentsClient; -type EnvironmentsClient = v1beta1.EnvironmentsClient; -const ImageVersionsClient = v1beta1.ImageVersionsClient; -type ImageVersionsClient = v1beta1.ImageVersionsClient; -export {v1beta1, EnvironmentsClient, ImageVersionsClient}; -export default {v1beta1, EnvironmentsClient, ImageVersionsClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_client.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_client.ts deleted file mode 100644 index 3e37b62e07d..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_client.ts +++ /dev/null @@ -1,2113 +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} 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/v1beta1/environments_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './environments_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Managed Apache Airflow Environments. - * @class - * @memberof v1beta1 - */ -export class EnvironmentsClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - environmentsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of EnvironmentsClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 EnvironmentsClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof EnvironmentsClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - environmentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/environments/{environment}' - ), - }; - - // 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 = { - listEnvironments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'environments') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta1/{name=projects/*/locations/*}/operations',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createEnvironmentResponse = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1beta1.Environment') as gax.protobuf.Type; - const createEnvironmentMetadata = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata') as gax.protobuf.Type; - const updateEnvironmentResponse = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1beta1.Environment') as gax.protobuf.Type; - const updateEnvironmentMetadata = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata') as gax.protobuf.Type; - const deleteEnvironmentResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteEnvironmentMetadata = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata') as gax.protobuf.Type; - const restartWebServerResponse = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1beta1.Environment') as gax.protobuf.Type; - const restartWebServerMetadata = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata') as gax.protobuf.Type; - const checkUpgradeResponse = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeResponse') as gax.protobuf.Type; - const checkUpgradeMetadata = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata') as gax.protobuf.Type; - const saveSnapshotResponse = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1beta1.SaveSnapshotResponse') as gax.protobuf.Type; - const saveSnapshotMetadata = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata') as gax.protobuf.Type; - const loadSnapshotResponse = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1beta1.LoadSnapshotResponse') as gax.protobuf.Type; - const loadSnapshotMetadata = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata') as gax.protobuf.Type; - const databaseFailoverResponse = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverResponse') as gax.protobuf.Type; - const databaseFailoverMetadata = protoFilesRoot.lookup( - '.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createEnvironment: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createEnvironmentResponse.decode.bind(createEnvironmentResponse), - createEnvironmentMetadata.decode.bind(createEnvironmentMetadata)), - updateEnvironment: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateEnvironmentResponse.decode.bind(updateEnvironmentResponse), - updateEnvironmentMetadata.decode.bind(updateEnvironmentMetadata)), - deleteEnvironment: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteEnvironmentResponse.decode.bind(deleteEnvironmentResponse), - deleteEnvironmentMetadata.decode.bind(deleteEnvironmentMetadata)), - restartWebServer: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - restartWebServerResponse.decode.bind(restartWebServerResponse), - restartWebServerMetadata.decode.bind(restartWebServerMetadata)), - checkUpgrade: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - checkUpgradeResponse.decode.bind(checkUpgradeResponse), - checkUpgradeMetadata.decode.bind(checkUpgradeMetadata)), - saveSnapshot: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - saveSnapshotResponse.decode.bind(saveSnapshotResponse), - saveSnapshotMetadata.decode.bind(saveSnapshotMetadata)), - loadSnapshot: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - loadSnapshotResponse.decode.bind(loadSnapshotResponse), - loadSnapshotMetadata.decode.bind(loadSnapshotMetadata)), - databaseFailover: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - databaseFailoverResponse.decode.bind(databaseFailoverResponse), - databaseFailoverMetadata.decode.bind(databaseFailoverMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.orchestration.airflow.service.v1beta1.Environments', 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.environmentsStub) { - return this.environmentsStub; - } - - // Put together the "service stub" for - // google.cloud.orchestration.airflow.service.v1beta1.Environments. - this.environmentsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.orchestration.airflow.service.v1beta1.Environments') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.orchestration.airflow.service.v1beta1.Environments, - 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 environmentsStubMethods = - ['createEnvironment', 'getEnvironment', 'listEnvironments', 'updateEnvironment', 'deleteEnvironment', 'restartWebServer', 'checkUpgrade', 'executeAirflowCommand', 'stopAirflowCommand', 'pollAirflowCommand', 'saveSnapshot', 'loadSnapshot', 'databaseFailover', 'fetchDatabaseProperties']; - for (const methodName of environmentsStubMethods) { - const callPromise = this.environmentsStub.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.environmentsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'composer.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 'composer.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 -- - // ------------------- -/** - * Get an existing environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource name of the environment to get, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.orchestration.airflow.service.v1beta1.Environment|Environment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.get_environment.js - * region_tag:composer_v1beta1_generated_Environments_GetEnvironment_async - */ - getEnvironment( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IGetEnvironmentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment, - protos.google.cloud.orchestration.airflow.service.v1beta1.IGetEnvironmentRequest|undefined, {}|undefined - ]>; - getEnvironment( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IGetEnvironmentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment, - protos.google.cloud.orchestration.airflow.service.v1beta1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>): void; - getEnvironment( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IGetEnvironmentRequest, - callback: Callback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment, - protos.google.cloud.orchestration.airflow.service.v1beta1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>): void; - getEnvironment( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IGetEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment, - protos.google.cloud.orchestration.airflow.service.v1beta1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment, - protos.google.cloud.orchestration.airflow.service.v1beta1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment, - protos.google.cloud.orchestration.airflow.service.v1beta1.IGetEnvironmentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getEnvironment(request, options, callback); - } -/** - * Executes Airflow CLI command. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.environment - * The resource name of the environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}". - * @param {string} request.command - * Airflow command. - * @param {string} request.subcommand - * Airflow subcommand. - * @param {string[]} request.parameters - * Parameters for the Airflow command/subcommand as an array of arguments. - * It may contain positional arguments like `["my-dag-id"]`, key-value - * parameters like `["--foo=bar"]` or `["--foo","bar"]`, - * or other flags like `["-f"]`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandResponse|ExecuteAirflowCommandResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.execute_airflow_command.js - * region_tag:composer_v1beta1_generated_Environments_ExecuteAirflowCommand_async - */ - executeAirflowCommand( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandRequest|undefined, {}|undefined - ]>; - executeAirflowCommand( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandRequest|null|undefined, - {}|null|undefined>): void; - executeAirflowCommand( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandRequest, - callback: Callback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandRequest|null|undefined, - {}|null|undefined>): void; - executeAirflowCommand( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'environment': request.environment ?? '', - }); - this.initialize(); - return this.innerApiCalls.executeAirflowCommand(request, options, callback); - } -/** - * Stops Airflow CLI command execution. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.environment - * The resource name of the environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}". - * @param {string} request.executionId - * The unique ID of the command execution. - * @param {string} request.pod - * The name of the pod where the command is executed. - * @param {string} request.podNamespace - * The namespace of the pod where the command is executed. - * @param {boolean} request.force - * If true, the execution is terminated forcefully (SIGKILL). If false, the - * execution is stopped gracefully, giving it time for cleanup. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandResponse|StopAirflowCommandResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.stop_airflow_command.js - * region_tag:composer_v1beta1_generated_Environments_StopAirflowCommand_async - */ - stopAirflowCommand( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandRequest|undefined, {}|undefined - ]>; - stopAirflowCommand( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandRequest|null|undefined, - {}|null|undefined>): void; - stopAirflowCommand( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandRequest, - callback: Callback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandRequest|null|undefined, - {}|null|undefined>): void; - stopAirflowCommand( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'environment': request.environment ?? '', - }); - this.initialize(); - return this.innerApiCalls.stopAirflowCommand(request, options, callback); - } -/** - * Polls Airflow CLI command execution and fetches logs. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.environment - * The resource name of the environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @param {string} request.executionId - * The unique ID of the command execution. - * @param {string} request.pod - * The name of the pod where the command is executed. - * @param {string} request.podNamespace - * The namespace of the pod where the command is executed. - * @param {number} request.nextLineNumber - * Line number from which new logs should be fetched. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandResponse|PollAirflowCommandResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.poll_airflow_command.js - * region_tag:composer_v1beta1_generated_Environments_PollAirflowCommand_async - */ - pollAirflowCommand( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandRequest|undefined, {}|undefined - ]>; - pollAirflowCommand( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandRequest|null|undefined, - {}|null|undefined>): void; - pollAirflowCommand( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandRequest, - callback: Callback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandRequest|null|undefined, - {}|null|undefined>): void; - pollAirflowCommand( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'environment': request.environment ?? '', - }); - this.initialize(); - return this.innerApiCalls.pollAirflowCommand(request, options, callback); - } -/** - * Fetches database properties. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.environment - * Required. The resource name of the environment, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesResponse|FetchDatabasePropertiesResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.fetch_database_properties.js - * region_tag:composer_v1beta1_generated_Environments_FetchDatabaseProperties_async - */ - fetchDatabaseProperties( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesRequest|undefined, {}|undefined - ]>; - fetchDatabaseProperties( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesRequest|null|undefined, - {}|null|undefined>): void; - fetchDatabaseProperties( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesRequest, - callback: Callback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesRequest|null|undefined, - {}|null|undefined>): void; - fetchDatabaseProperties( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesResponse, - protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'environment': request.environment ?? '', - }); - this.initialize(); - return this.innerApiCalls.fetchDatabaseProperties(request, options, callback); - } - -/** - * Create a new environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The parent must be of the form - * "projects/{projectId}/locations/{locationId}". - * @param {google.cloud.orchestration.airflow.service.v1beta1.Environment} request.environment - * The environment to create. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.create_environment.js - * region_tag:composer_v1beta1_generated_Environments_CreateEnvironment_async - */ - createEnvironment( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.ICreateEnvironmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createEnvironment( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.ICreateEnvironmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createEnvironment( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.ICreateEnvironmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createEnvironment( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.ICreateEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createEnvironment(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createEnvironment()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.create_environment.js - * region_tag:composer_v1beta1_generated_Environments_CreateEnvironment_async - */ - async checkCreateEnvironmentProgress(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.createEnvironment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Update an environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The relative resource name of the environment to update, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @param {google.cloud.orchestration.airflow.service.v1beta1.Environment} request.environment - * A patch environment. Fields specified by the `updateMask` will be copied - * from the patch environment into the environment under update. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. A comma-separated list of paths, relative to `Environment`, of - * fields to update. - * For example, to set the version of scikit-learn to install in the - * environment to 0.19.0 and to remove an existing installation of - * argparse, the `updateMask` parameter would include the following two - * `paths` values: "config.softwareConfig.pypiPackages.scikit-learn" and - * "config.softwareConfig.pypiPackages.argparse". The included patch - * environment would specify the scikit-learn version as follows: - * - * { - * "config":{ - * "softwareConfig":{ - * "pypiPackages":{ - * "scikit-learn":"==0.19.0" - * } - * } - * } - * } - * - * Note that in the above example, any existing PyPI packages - * other than scikit-learn and argparse will be unaffected. - * - * Only one update type may be included in a single request's `updateMask`. - * For example, one cannot update both the PyPI packages and - * labels in the same request. However, it is possible to update multiple - * members of a map field simultaneously in the same request. For example, - * to set the labels "label1" and "label2" while clearing "label3" (assuming - * it already exists), one can - * provide the paths "labels.label1", "labels.label2", and "labels.label3" - * and populate the patch environment as follows: - * - * { - * "labels":{ - * "label1":"new-label1-value" - * "label2":"new-label2-value" - * } - * } - * - * Note that in the above example, any existing labels that are not - * included in the `updateMask` will be unaffected. - * - * It is also possible to replace an entire map field by providing the - * map field's path in the `updateMask`. The new value of the field will - * be that which is provided in the patch environment. For example, to - * delete all pre-existing user-specified PyPI packages and - * install botocore at version 1.7.14, the `updateMask` would contain - * the path "config.softwareConfig.pypiPackages", and - * the patch environment would be the following: - * - * { - * "config":{ - * "softwareConfig":{ - * "pypiPackages":{ - * "botocore":"==1.7.14" - * } - * } - * } - * } - * - * **Note:** Only the following fields can be updated: - * - * * `config.softwareConfig.pypiPackages` - * * Replace all custom custom PyPI packages. If a replacement - * package map is not included in `environment`, all custom - * PyPI packages are cleared. It is an error to provide both - * this mask and a mask specifying an individual package. - * * `config.softwareConfig.pypiPackages.`packagename - * * Update the custom PyPI package *packagename*, - * preserving other packages. To delete the package, include it in - * `updateMask`, and omit the mapping for it in - * `environment.config.softwareConfig.pypiPackages`. It is an error - * to provide both a mask of this form and the - * `config.softwareConfig.pypiPackages` mask. - * * `labels` - * * Replace all environment labels. If a replacement labels map is not - * included in `environment`, all labels are cleared. It is an error to - * provide both this mask and a mask specifying one or more individual - * labels. - * * `labels.`labelName - * * Set the label named *labelName*, while preserving other - * labels. To delete the label, include it in `updateMask` and omit its - * mapping in `environment.labels`. It is an error to provide both a - * mask of this form and the `labels` mask. - * * `config.nodeCount` - * * Horizontally scale the number of nodes in the environment. An integer - * greater than or equal to 3 must be provided in the `config.nodeCount` - * field. Supported for Cloud Composer environments in versions - * composer-1.*.*-airflow-*.*.*. - * * `config.webServerNetworkAccessControl` - * * Replace the environment's current WebServerNetworkAccessControl. - * * `config.softwareConfig.airflowConfigOverrides` - * * Replace all Apache Airflow config overrides. If a replacement config - * overrides map is not included in `environment`, all config overrides - * are cleared. - * It is an error to provide both this mask and a mask specifying one or - * more individual config overrides. - * * `config.softwareConfig.airflowConfigOverrides.`section-name - * * Override the Apache Airflow config property *name* in the - * section named *section*, preserving other properties. To - * delete the property override, include it in `updateMask` and omit its - * mapping in - * `environment.config.softwareConfig.airflowConfigOverrides`. - * It is an error to provide both a mask of this form and the - * `config.softwareConfig.airflowConfigOverrides` mask. - * * `config.softwareConfig.envVariables` - * * Replace all environment variables. If a replacement environment - * variable map is not included in `environment`, all custom environment - * variables are cleared. - * * `config.softwareConfig.imageVersion` - * * Upgrade the version of the environment in-place. Refer to - * `SoftwareConfig.image_version` for information on how to format the - * new image version. Additionally, the new image version cannot effect - * a version downgrade, and must match the current image version's - * Composer and Airflow major versions. Consult the [Cloud Composer - * version list](/composer/docs/concepts/versioning/composer-versions) - * for valid values. - * * `config.softwareConfig.schedulerCount` - * * Horizontally scale the number of schedulers in Airflow. A positive - * integer not greater than the number of nodes must be provided in the - * `config.softwareConfig.schedulerCount` field. Supported for Cloud - * Composer environments in versions composer-1.*.*-airflow-2.*.*. - * * `config.softwareConfig.cloudDataLineageIntegration` - * * Configuration for Cloud Data Lineage integration. - * * `config.databaseConfig.machineType` - * * Cloud SQL machine type used by Airflow database. - * It has to be one of: db-n1-standard-2, db-n1-standard-4, - * db-n1-standard-8 or db-n1-standard-16. Supported for Cloud Composer - * environments in versions composer-1.*.*-airflow-*.*.*. - * * `config.webServerConfig.machineType` - * * Machine type on which Airflow web server is running. - * It has to be one of: composer-n1-webserver-2, composer-n1-webserver-4 - * or composer-n1-webserver-8. Supported for Cloud Composer environments - * in versions composer-1.*.*-airflow-*.*.*. - * * `config.maintenanceWindow` - * * Maintenance window during which Cloud Composer components may be - * under maintenance. - * * `config.workloadsConfig` - * * The workloads configuration settings for the GKE cluster associated - * with the Cloud Composer environment. Supported for Cloud Composer - * environments in versions composer-2.*.*-airflow-*.*.* and newer. - * * `config.environmentSize` - * * The size of the Cloud Composer environment. Supported for Cloud - * Composer environments in versions composer-2.*.*-airflow-*.*.* and - * newer. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.update_environment.js - * region_tag:composer_v1beta1_generated_Environments_UpdateEnvironment_async - */ - updateEnvironment( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IUpdateEnvironmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateEnvironment( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IUpdateEnvironmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateEnvironment( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IUpdateEnvironmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateEnvironment( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IUpdateEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateEnvironment(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateEnvironment()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.update_environment.js - * region_tag:composer_v1beta1_generated_Environments_UpdateEnvironment_async - */ - async checkUpdateEnvironmentProgress(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.updateEnvironment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Delete an environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The environment to delete, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.delete_environment.js - * region_tag:composer_v1beta1_generated_Environments_DeleteEnvironment_async - */ - deleteEnvironment( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IDeleteEnvironmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteEnvironment( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IDeleteEnvironmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteEnvironment( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IDeleteEnvironmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteEnvironment( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IDeleteEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteEnvironment(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteEnvironment()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.delete_environment.js - * region_tag:composer_v1beta1_generated_Environments_DeleteEnvironment_async - */ - async checkDeleteEnvironmentProgress(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.deleteEnvironment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Restart Airflow web server. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource name of the environment to restart the web server for, in the - * form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.restart_web_server.js - * region_tag:composer_v1beta1_generated_Environments_RestartWebServer_async - */ - restartWebServer( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IRestartWebServerRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - restartWebServer( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IRestartWebServerRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - restartWebServer( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IRestartWebServerRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - restartWebServer( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IRestartWebServerRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.restartWebServer(request, options, callback); - } -/** - * Check the status of the long running operation returned by `restartWebServer()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.restart_web_server.js - * region_tag:composer_v1beta1_generated_Environments_RestartWebServer_async - */ - async checkRestartWebServerProgress(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.restartWebServer, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Check if an upgrade operation on the environment will succeed. - * - * In case of problems detailed info can be found in the returned Operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.environment - * The resource name of the environment to check upgrade for, in the - * form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @param {string} request.imageVersion - * The version of the software running in the environment. - * This encapsulates both the version of Cloud Composer functionality and the - * version of Apache Airflow. It must match the regular expression - * `composer-([0-9]+(\.[0-9]+\.[0-9]+(-preview\.[0-9]+)?)?|latest)-airflow-([0-9]+(\.[0-9]+(\.[0-9]+)?)?)`. - * When used as input, the server also checks if the provided version is - * supported and denies the request for an unsupported version. - * - * The Cloud Composer portion of the image version is a full - * [semantic version](https://semver.org), or an alias in the form of major - * version number or `latest`. When an alias is provided, the server replaces - * it with the current Cloud Composer version that satisfies the alias. - * - * The Apache Airflow portion of the image version is a full semantic version - * that points to one of the supported Apache Airflow versions, or an alias in - * the form of only major or major.minor versions specified. When an alias is - * provided, the server replaces it with the latest Apache Airflow version - * that satisfies the alias and is supported in the given Cloud Composer - * version. - * - * In all cases, the resolved image version is stored in the same field. - * - * See also [version - * list](/composer/docs/concepts/versioning/composer-versions) and [versioning - * overview](/composer/docs/concepts/versioning/composer-versioning-overview). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.check_upgrade.js - * region_tag:composer_v1beta1_generated_Environments_CheckUpgrade_async - */ - checkUpgrade( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.ICheckUpgradeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - checkUpgrade( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.ICheckUpgradeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - checkUpgrade( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.ICheckUpgradeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - checkUpgrade( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.ICheckUpgradeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'environment': request.environment ?? '', - }); - this.initialize(); - return this.innerApiCalls.checkUpgrade(request, options, callback); - } -/** - * Check the status of the long running operation returned by `checkUpgrade()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.check_upgrade.js - * region_tag:composer_v1beta1_generated_Environments_CheckUpgrade_async - */ - async checkCheckUpgradeProgress(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.checkUpgrade, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Creates a snapshots of a Cloud Composer environment. - * - * As a result of this operation, snapshot of environment's state is stored - * in a location specified in the SaveSnapshotRequest. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.environment - * The resource name of the source environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @param {string} request.snapshotLocation - * Location in a Cloud Storage where the snapshot is going to be stored, e.g.: - * "gs://my-bucket/snapshots". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.save_snapshot.js - * region_tag:composer_v1beta1_generated_Environments_SaveSnapshot_async - */ - saveSnapshot( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.ISaveSnapshotRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - saveSnapshot( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.ISaveSnapshotRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - saveSnapshot( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.ISaveSnapshotRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - saveSnapshot( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.ISaveSnapshotRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'environment': request.environment ?? '', - }); - this.initialize(); - return this.innerApiCalls.saveSnapshot(request, options, callback); - } -/** - * Check the status of the long running operation returned by `saveSnapshot()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.save_snapshot.js - * region_tag:composer_v1beta1_generated_Environments_SaveSnapshot_async - */ - async checkSaveSnapshotProgress(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.saveSnapshot, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Loads a snapshot of a Cloud Composer environment. - * - * As a result of this operation, a snapshot of environment's specified in - * LoadSnapshotRequest is loaded into the environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.environment - * The resource name of the target environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @param {string} request.snapshotPath - * A Cloud Storage path to a snapshot to load, e.g.: - * "gs://my-bucket/snapshots/project_location_environment_timestamp". - * @param {boolean} request.skipPypiPackagesInstallation - * Whether or not to skip installing Pypi packages when loading the - * environment's state. - * @param {boolean} request.skipEnvironmentVariablesSetting - * Whether or not to skip setting environment variables when loading the - * environment's state. - * @param {boolean} request.skipAirflowOverridesSetting - * Whether or not to skip setting Airflow overrides when loading the - * environment's state. - * @param {boolean} request.skipGcsDataCopying - * Whether or not to skip copying Cloud Storage data when loading the - * environment's state. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.load_snapshot.js - * region_tag:composer_v1beta1_generated_Environments_LoadSnapshot_async - */ - loadSnapshot( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.ILoadSnapshotRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - loadSnapshot( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.ILoadSnapshotRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - loadSnapshot( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.ILoadSnapshotRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - loadSnapshot( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.ILoadSnapshotRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'environment': request.environment ?? '', - }); - this.initialize(); - return this.innerApiCalls.loadSnapshot(request, options, callback); - } -/** - * Check the status of the long running operation returned by `loadSnapshot()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.load_snapshot.js - * region_tag:composer_v1beta1_generated_Environments_LoadSnapshot_async - */ - async checkLoadSnapshotProgress(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.loadSnapshot, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Triggers database failover (only for highly resilient environments). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.environment - * Target environment: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.database_failover.js - * region_tag:composer_v1beta1_generated_Environments_DatabaseFailover_async - */ - databaseFailover( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IDatabaseFailoverRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - databaseFailover( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IDatabaseFailoverRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - databaseFailover( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IDatabaseFailoverRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - databaseFailover( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IDatabaseFailoverRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'environment': request.environment ?? '', - }); - this.initialize(); - return this.innerApiCalls.databaseFailover(request, options, callback); - } -/** - * Check the status of the long running operation returned by `databaseFailover()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.database_failover.js - * region_tag:composer_v1beta1_generated_Environments_DatabaseFailover_async - */ - async checkDatabaseFailoverProgress(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.databaseFailover, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * List environments. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * List environments in the given project and location, in the form: - * "projects/{projectId}/locations/{locationId}" - * @param {number} request.pageSize - * The maximum number of environments to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.orchestration.airflow.service.v1beta1.Environment|Environment}. - * 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 `listEnvironmentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listEnvironments( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment[], - protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest|null, - protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsResponse - ]>; - listEnvironments( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest, - protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment>): void; - listEnvironments( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest, - callback: PaginationCallback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest, - protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment>): void; - listEnvironments( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest, - protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment>, - callback?: PaginationCallback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest, - protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment>): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment[], - protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest|null, - protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listEnvironments(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 - * List environments in the given project and location, in the form: - * "projects/{projectId}/locations/{locationId}" - * @param {number} request.pageSize - * The maximum number of environments to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.orchestration.airflow.service.v1beta1.Environment|Environment} 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 `listEnvironmentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listEnvironmentsStream( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest, - 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['listEnvironments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listEnvironments.createStream( - this.innerApiCalls.listEnvironments as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listEnvironments`, 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 - * List environments in the given project and location, in the form: - * "projects/{projectId}/locations/{locationId}" - * @param {number} request.pageSize - * The maximum number of environments to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.orchestration.airflow.service.v1beta1.Environment|Environment}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/environments.list_environments.js - * region_tag:composer_v1beta1_generated_Environments_ListEnvironments_async - */ - listEnvironmentsAsync( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IListEnvironmentsRequest, - 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['listEnvironments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listEnvironments.asyncIterate( - this.innerApiCalls['listEnvironments'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * 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 environment resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} environment - * @returns {string} Resource name string. - */ - environmentPath(project:string,location:string,environment:string) { - return this.pathTemplates.environmentPathTemplate.render({ - project: project, - location: location, - environment: environment, - }); - } - - /** - * Parse the project from Environment resource. - * - * @param {string} environmentName - * A fully-qualified path representing Environment resource. - * @returns {string} A string representing the project. - */ - matchProjectFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).project; - } - - /** - * Parse the location from Environment resource. - * - * @param {string} environmentName - * A fully-qualified path representing Environment resource. - * @returns {string} A string representing the location. - */ - matchLocationFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).location; - } - - /** - * Parse the environment from Environment resource. - * - * @param {string} environmentName - * A fully-qualified path representing Environment resource. - * @returns {string} A string representing the environment. - */ - matchEnvironmentFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).environment; - } - - /** - * 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.environmentsStub && !this._terminated) { - return this.environmentsStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_client_config.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_client_config.json deleted file mode 100644 index 2e42d5f6001..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_client_config.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "interfaces": { - "google.cloud.orchestration.airflow.service.v1beta1.Environments": { - "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": { - "CreateEnvironment": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetEnvironment": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListEnvironments": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateEnvironment": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteEnvironment": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RestartWebServer": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CheckUpgrade": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ExecuteAirflowCommand": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "StopAirflowCommand": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "PollAirflowCommand": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "SaveSnapshot": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "LoadSnapshot": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DatabaseFailover": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "FetchDatabaseProperties": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_proto_list.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_proto_list.json deleted file mode 100644 index c854c306722..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/environments_proto_list.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - "../../protos/google/cloud/orchestration/airflow/service/v1beta1/environments.proto", - "../../protos/google/cloud/orchestration/airflow/service/v1beta1/image_versions.proto", - "../../protos/google/cloud/orchestration/airflow/service/v1beta1/operations.proto" -] diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/gapic_metadata.json deleted file mode 100644 index 2271ff732a2..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/gapic_metadata.json +++ /dev/null @@ -1,195 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.orchestration.airflow.service.v1beta1", - "libraryPackage": "@google-cloud/orchestration-airflow", - "services": { - "Environments": { - "clients": { - "grpc": { - "libraryClient": "EnvironmentsClient", - "rpcs": { - "GetEnvironment": { - "methods": [ - "getEnvironment" - ] - }, - "ExecuteAirflowCommand": { - "methods": [ - "executeAirflowCommand" - ] - }, - "StopAirflowCommand": { - "methods": [ - "stopAirflowCommand" - ] - }, - "PollAirflowCommand": { - "methods": [ - "pollAirflowCommand" - ] - }, - "FetchDatabaseProperties": { - "methods": [ - "fetchDatabaseProperties" - ] - }, - "CreateEnvironment": { - "methods": [ - "createEnvironment" - ] - }, - "UpdateEnvironment": { - "methods": [ - "updateEnvironment" - ] - }, - "DeleteEnvironment": { - "methods": [ - "deleteEnvironment" - ] - }, - "RestartWebServer": { - "methods": [ - "restartWebServer" - ] - }, - "CheckUpgrade": { - "methods": [ - "checkUpgrade" - ] - }, - "SaveSnapshot": { - "methods": [ - "saveSnapshot" - ] - }, - "LoadSnapshot": { - "methods": [ - "loadSnapshot" - ] - }, - "DatabaseFailover": { - "methods": [ - "databaseFailover" - ] - }, - "ListEnvironments": { - "methods": [ - "listEnvironments", - "listEnvironmentsStream", - "listEnvironmentsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "EnvironmentsClient", - "rpcs": { - "GetEnvironment": { - "methods": [ - "getEnvironment" - ] - }, - "ExecuteAirflowCommand": { - "methods": [ - "executeAirflowCommand" - ] - }, - "StopAirflowCommand": { - "methods": [ - "stopAirflowCommand" - ] - }, - "PollAirflowCommand": { - "methods": [ - "pollAirflowCommand" - ] - }, - "FetchDatabaseProperties": { - "methods": [ - "fetchDatabaseProperties" - ] - }, - "CreateEnvironment": { - "methods": [ - "createEnvironment" - ] - }, - "UpdateEnvironment": { - "methods": [ - "updateEnvironment" - ] - }, - "DeleteEnvironment": { - "methods": [ - "deleteEnvironment" - ] - }, - "RestartWebServer": { - "methods": [ - "restartWebServer" - ] - }, - "CheckUpgrade": { - "methods": [ - "checkUpgrade" - ] - }, - "SaveSnapshot": { - "methods": [ - "saveSnapshot" - ] - }, - "LoadSnapshot": { - "methods": [ - "loadSnapshot" - ] - }, - "DatabaseFailover": { - "methods": [ - "databaseFailover" - ] - }, - "ListEnvironments": { - "methods": [ - "listEnvironments", - "listEnvironmentsStream", - "listEnvironmentsAsync" - ] - } - } - } - } - }, - "ImageVersions": { - "clients": { - "grpc": { - "libraryClient": "ImageVersionsClient", - "rpcs": { - "ListImageVersions": { - "methods": [ - "listImageVersions", - "listImageVersionsStream", - "listImageVersionsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageVersionsClient", - "rpcs": { - "ListImageVersions": { - "methods": [ - "listImageVersions", - "listImageVersionsStream", - "listImageVersionsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_client.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_client.ts deleted file mode 100644 index 21c51427c21..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_client.ts +++ /dev/null @@ -1,556 +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, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta1/image_versions_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_versions_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Readonly service to query available ImageVersions. - * @class - * @memberof v1beta1 - */ -export class ImageVersionsClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - imageVersionsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageVersionsClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 ImageVersionsClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ImageVersionsClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - environmentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/environments/{environment}' - ), - }; - - // 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 = { - listImageVersions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'imageVersions') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.orchestration.airflow.service.v1beta1.ImageVersions', 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.imageVersionsStub) { - return this.imageVersionsStub; - } - - // Put together the "service stub" for - // google.cloud.orchestration.airflow.service.v1beta1.ImageVersions. - this.imageVersionsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.orchestration.airflow.service.v1beta1.ImageVersions') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.orchestration.airflow.service.v1beta1.ImageVersions, - 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 imageVersionsStubMethods = - ['listImageVersions']; - for (const methodName of imageVersionsStubMethods) { - const callPromise = this.imageVersionsStub.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.imageVersionsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'composer.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 'composer.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 -- - // ------------------- - - /** - * List ImageVersions for provided location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * List ImageVersions in the given project and location, in the form: - * "projects/{projectId}/locations/{locationId}" - * @param {number} request.pageSize - * The maximum number of image_versions to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {boolean} request.includePastReleases - * Whether or not image versions from old releases should be included. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion|ImageVersion}. - * 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 `listImageVersionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listImageVersions( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1beta1.IImageVersion[], - protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest|null, - protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsResponse - ]>; - listImageVersions( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest, - protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsResponse|null|undefined, - protos.google.cloud.orchestration.airflow.service.v1beta1.IImageVersion>): void; - listImageVersions( - request: protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest, - callback: PaginationCallback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest, - protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsResponse|null|undefined, - protos.google.cloud.orchestration.airflow.service.v1beta1.IImageVersion>): void; - listImageVersions( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest, - protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsResponse|null|undefined, - protos.google.cloud.orchestration.airflow.service.v1beta1.IImageVersion>, - callback?: PaginationCallback< - protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest, - protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsResponse|null|undefined, - protos.google.cloud.orchestration.airflow.service.v1beta1.IImageVersion>): - Promise<[ - protos.google.cloud.orchestration.airflow.service.v1beta1.IImageVersion[], - protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest|null, - protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listImageVersions(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 - * List ImageVersions in the given project and location, in the form: - * "projects/{projectId}/locations/{locationId}" - * @param {number} request.pageSize - * The maximum number of image_versions to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {boolean} request.includePastReleases - * Whether or not image versions from old releases should be included. - * @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 protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion|ImageVersion} 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 `listImageVersionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listImageVersionsStream( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest, - 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['listImageVersions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listImageVersions.createStream( - this.innerApiCalls.listImageVersions as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listImageVersions`, 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 - * List ImageVersions in the given project and location, in the form: - * "projects/{projectId}/locations/{locationId}" - * @param {number} request.pageSize - * The maximum number of image_versions to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {boolean} request.includePastReleases - * Whether or not image versions from old releases should be included. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion|ImageVersion}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/image_versions.list_image_versions.js - * region_tag:composer_v1beta1_generated_ImageVersions_ListImageVersions_async - */ - listImageVersionsAsync( - request?: protos.google.cloud.orchestration.airflow.service.v1beta1.IListImageVersionsRequest, - 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['listImageVersions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listImageVersions.asyncIterate( - this.innerApiCalls['listImageVersions'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified environment resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} environment - * @returns {string} Resource name string. - */ - environmentPath(project:string,location:string,environment:string) { - return this.pathTemplates.environmentPathTemplate.render({ - project: project, - location: location, - environment: environment, - }); - } - - /** - * Parse the project from Environment resource. - * - * @param {string} environmentName - * A fully-qualified path representing Environment resource. - * @returns {string} A string representing the project. - */ - matchProjectFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).project; - } - - /** - * Parse the location from Environment resource. - * - * @param {string} environmentName - * A fully-qualified path representing Environment resource. - * @returns {string} A string representing the location. - */ - matchLocationFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).location; - } - - /** - * Parse the environment from Environment resource. - * - * @param {string} environmentName - * A fully-qualified path representing Environment resource. - * @returns {string} A string representing the environment. - */ - matchEnvironmentFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).environment; - } - - /** - * 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.imageVersionsStub && !this._terminated) { - return this.imageVersionsStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_client_config.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_client_config.json deleted file mode 100644 index 9db3275858a..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_client_config.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "interfaces": { - "google.cloud.orchestration.airflow.service.v1beta1.ImageVersions": { - "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": { - "ListImageVersions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_proto_list.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_proto_list.json deleted file mode 100644 index c854c306722..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/image_versions_proto_list.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - "../../protos/google/cloud/orchestration/airflow/service/v1beta1/environments.proto", - "../../protos/google/cloud/orchestration/airflow/service/v1beta1/image_versions.proto", - "../../protos/google/cloud/orchestration/airflow/service/v1beta1/operations.proto" -] diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/index.ts deleted file mode 100644 index f861aaef0c3..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/src/v1beta1/index.ts +++ /dev/null @@ -1,20 +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 {EnvironmentsClient} from './environments_client'; -export {ImageVersionsClient} from './image_versions_client'; diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 6621821e725..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const service = require('@google-cloud/orchestration-airflow'); - -function main() { - const environmentsClient = new service.EnvironmentsClient(); - const imageVersionsClient = new service.ImageVersionsClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index fe7224b8add..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +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 {EnvironmentsClient, ImageVersionsClient} from '@google-cloud/orchestration-airflow'; - -// check that the client class type name can be used -function doStuffWithEnvironmentsClient(client: EnvironmentsClient) { - client.close(); -} -function doStuffWithImageVersionsClient(client: ImageVersionsClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const environmentsClient = new EnvironmentsClient(); - doStuffWithEnvironmentsClient(environmentsClient); - // check that the client instance can be created - const imageVersionsClient = new ImageVersionsClient(); - doStuffWithImageVersionsClient(imageVersionsClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/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-orchestration-airflow-service/v1beta1/test/gapic_environments_v1beta1.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/test/gapic_environments_v1beta1.ts deleted file mode 100644 index 579b45d1bd6..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/test/gapic_environments_v1beta1.ts +++ /dev/null @@ -1,2534 +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 environmentsModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1beta1.EnvironmentsClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = environmentsModule.v1beta1.EnvironmentsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = environmentsModule.v1beta1.EnvironmentsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = environmentsModule.v1beta1.EnvironmentsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.environmentsStub, undefined); - await client.initialize(); - assert(client.environmentsStub); - }); - - it('has close method for the initialized client', done => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.environmentsStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.environmentsStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - 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 environmentsModule.v1beta1.EnvironmentsClient({ - 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('getEnvironment', () => { - it('invokes getEnvironment without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment() - ); - client.innerApiCalls.getEnvironment = stubSimpleCall(expectedResponse); - const [response] = await client.getEnvironment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEnvironment without error using callback', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment() - ); - client.innerApiCalls.getEnvironment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getEnvironment( - request, - (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEnvironment with error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getEnvironment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEnvironment with closed client', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getEnvironment(request), expectedError); - }); - }); - - describe('executeAirflowCommand', () => { - it('invokes executeAirflowCommand without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandResponse() - ); - client.innerApiCalls.executeAirflowCommand = stubSimpleCall(expectedResponse); - const [response] = await client.executeAirflowCommand(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeAirflowCommand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeAirflowCommand as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executeAirflowCommand without error using callback', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandResponse() - ); - client.innerApiCalls.executeAirflowCommand = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.executeAirflowCommand( - request, - (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1beta1.IExecuteAirflowCommandResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeAirflowCommand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeAirflowCommand as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executeAirflowCommand with error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.executeAirflowCommand = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.executeAirflowCommand(request), expectedError); - const actualRequest = (client.innerApiCalls.executeAirflowCommand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeAirflowCommand as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executeAirflowCommand with closed client', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.executeAirflowCommand(request), expectedError); - }); - }); - - describe('stopAirflowCommand', () => { - it('invokes stopAirflowCommand without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandResponse() - ); - client.innerApiCalls.stopAirflowCommand = stubSimpleCall(expectedResponse); - const [response] = await client.stopAirflowCommand(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopAirflowCommand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopAirflowCommand as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopAirflowCommand without error using callback', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandResponse() - ); - client.innerApiCalls.stopAirflowCommand = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.stopAirflowCommand( - request, - (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1beta1.IStopAirflowCommandResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopAirflowCommand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopAirflowCommand as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopAirflowCommand with error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopAirflowCommand = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.stopAirflowCommand(request), expectedError); - const actualRequest = (client.innerApiCalls.stopAirflowCommand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopAirflowCommand as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopAirflowCommand with closed client', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.stopAirflowCommand(request), expectedError); - }); - }); - - describe('pollAirflowCommand', () => { - it('invokes pollAirflowCommand without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandResponse() - ); - client.innerApiCalls.pollAirflowCommand = stubSimpleCall(expectedResponse); - const [response] = await client.pollAirflowCommand(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pollAirflowCommand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pollAirflowCommand as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pollAirflowCommand without error using callback', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandResponse() - ); - client.innerApiCalls.pollAirflowCommand = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.pollAirflowCommand( - request, - (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1beta1.IPollAirflowCommandResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pollAirflowCommand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pollAirflowCommand as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pollAirflowCommand with error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.pollAirflowCommand = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.pollAirflowCommand(request), expectedError); - const actualRequest = (client.innerApiCalls.pollAirflowCommand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pollAirflowCommand as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pollAirflowCommand with closed client', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandRequest', ['environment']); - request.environment = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.pollAirflowCommand(request), expectedError); - }); - }); - - describe('fetchDatabaseProperties', () => { - it('invokes fetchDatabaseProperties without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesResponse() - ); - client.innerApiCalls.fetchDatabaseProperties = stubSimpleCall(expectedResponse); - const [response] = await client.fetchDatabaseProperties(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes fetchDatabaseProperties without error using callback', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesResponse() - ); - client.innerApiCalls.fetchDatabaseProperties = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.fetchDatabaseProperties( - request, - (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1beta1.IFetchDatabasePropertiesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes fetchDatabaseProperties with error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.fetchDatabaseProperties = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.fetchDatabaseProperties(request), expectedError); - const actualRequest = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.fetchDatabaseProperties as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes fetchDatabaseProperties with closed client', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesRequest', ['environment']); - request.environment = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.fetchDatabaseProperties(request), expectedError); - }); - }); - - describe('createEnvironment', () => { - it('invokes createEnvironment without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createEnvironment = stubLongRunningCall(expectedResponse); - const [operation] = await client.createEnvironment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createEnvironment without error using callback', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createEnvironment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createEnvironment( - request, - (err?: Error|null, - result?: 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.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createEnvironment with call error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEnvironment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createEnvironment with LRO error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEnvironment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createEnvironment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateEnvironmentProgress without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateEnvironmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateEnvironmentProgress with error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateEnvironmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateEnvironment', () => { - it('invokes updateEnvironment without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.UpdateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.UpdateEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateEnvironment = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateEnvironment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateEnvironment without error using callback', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.UpdateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.UpdateEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateEnvironment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateEnvironment( - request, - (err?: Error|null, - result?: 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.updateEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateEnvironment with call error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.UpdateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.UpdateEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateEnvironment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.updateEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateEnvironment with LRO error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.UpdateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.UpdateEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateEnvironment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateEnvironment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateEnvironmentProgress without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateEnvironmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateEnvironmentProgress with error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateEnvironmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteEnvironment', () => { - it('invokes deleteEnvironment without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteEnvironment = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteEnvironment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteEnvironment without error using callback', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteEnvironment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteEnvironment( - request, - (err?: Error|null, - result?: 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.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteEnvironment with call error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteEnvironment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteEnvironment with LRO error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteEnvironment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteEnvironment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteEnvironmentProgress without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteEnvironmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteEnvironmentProgress with error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteEnvironmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('restartWebServer', () => { - it('invokes restartWebServer without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.RestartWebServerRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.RestartWebServerRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.restartWebServer = stubLongRunningCall(expectedResponse); - const [operation] = await client.restartWebServer(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restartWebServer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restartWebServer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restartWebServer without error using callback', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.RestartWebServerRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.RestartWebServerRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.restartWebServer = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.restartWebServer( - request, - (err?: Error|null, - result?: 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.restartWebServer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restartWebServer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restartWebServer with call error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.RestartWebServerRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.RestartWebServerRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.restartWebServer = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.restartWebServer(request), expectedError); - const actualRequest = (client.innerApiCalls.restartWebServer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restartWebServer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restartWebServer with LRO error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.RestartWebServerRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.RestartWebServerRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.restartWebServer = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.restartWebServer(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.restartWebServer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restartWebServer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkRestartWebServerProgress without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRestartWebServerProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRestartWebServerProgress with error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRestartWebServerProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('checkUpgrade', () => { - it('invokes checkUpgrade without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.checkUpgrade = stubLongRunningCall(expectedResponse); - const [operation] = await client.checkUpgrade(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.checkUpgrade as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.checkUpgrade as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpgrade without error using callback', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.checkUpgrade = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.checkUpgrade( - request, - (err?: Error|null, - result?: 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.checkUpgrade as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.checkUpgrade as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpgrade with call error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.checkUpgrade = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.checkUpgrade(request), expectedError); - const actualRequest = (client.innerApiCalls.checkUpgrade as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.checkUpgrade as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpgrade with LRO error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.checkUpgrade = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.checkUpgrade(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.checkUpgrade as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.checkUpgrade as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCheckUpgradeProgress without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCheckUpgradeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCheckUpgradeProgress with error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCheckUpgradeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('saveSnapshot', () => { - it('invokes saveSnapshot without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.SaveSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.SaveSnapshotRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.saveSnapshot = stubLongRunningCall(expectedResponse); - const [operation] = await client.saveSnapshot(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.saveSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.saveSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes saveSnapshot without error using callback', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.SaveSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.SaveSnapshotRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.saveSnapshot = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.saveSnapshot( - request, - (err?: Error|null, - result?: 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.saveSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.saveSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes saveSnapshot with call error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.SaveSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.SaveSnapshotRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.saveSnapshot = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.saveSnapshot(request), expectedError); - const actualRequest = (client.innerApiCalls.saveSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.saveSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes saveSnapshot with LRO error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.SaveSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.SaveSnapshotRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.saveSnapshot = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.saveSnapshot(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.saveSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.saveSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkSaveSnapshotProgress without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkSaveSnapshotProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkSaveSnapshotProgress with error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSaveSnapshotProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('loadSnapshot', () => { - it('invokes loadSnapshot without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.LoadSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.LoadSnapshotRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.loadSnapshot = stubLongRunningCall(expectedResponse); - const [operation] = await client.loadSnapshot(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.loadSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.loadSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes loadSnapshot without error using callback', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.LoadSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.LoadSnapshotRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.loadSnapshot = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.loadSnapshot( - request, - (err?: Error|null, - result?: 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.loadSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.loadSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes loadSnapshot with call error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.LoadSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.LoadSnapshotRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.loadSnapshot = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.loadSnapshot(request), expectedError); - const actualRequest = (client.innerApiCalls.loadSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.loadSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes loadSnapshot with LRO error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.LoadSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.LoadSnapshotRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.loadSnapshot = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.loadSnapshot(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.loadSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.loadSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkLoadSnapshotProgress without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkLoadSnapshotProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkLoadSnapshotProgress with error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkLoadSnapshotProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('databaseFailover', () => { - it('invokes databaseFailover without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.databaseFailover = stubLongRunningCall(expectedResponse); - const [operation] = await client.databaseFailover(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.databaseFailover as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.databaseFailover as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes databaseFailover without error using callback', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.databaseFailover = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.databaseFailover( - request, - (err?: Error|null, - result?: 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.databaseFailover as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.databaseFailover as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes databaseFailover with call error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.databaseFailover = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.databaseFailover(request), expectedError); - const actualRequest = (client.innerApiCalls.databaseFailover as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.databaseFailover as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes databaseFailover with LRO error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.databaseFailover = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.databaseFailover(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.databaseFailover as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.databaseFailover as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDatabaseFailoverProgress without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDatabaseFailoverProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDatabaseFailoverProgress with error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDatabaseFailoverProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listEnvironments', () => { - it('invokes listEnvironments without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), - ]; - client.innerApiCalls.listEnvironments = stubSimpleCall(expectedResponse); - const [response] = await client.listEnvironments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEnvironments without error using callback', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), - ]; - client.innerApiCalls.listEnvironments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listEnvironments( - request, - (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEnvironments with error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listEnvironments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listEnvironments(request), expectedError); - const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEnvironmentsStream without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), - ]; - client.descriptors.page.listEnvironments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listEnvironmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.orchestration.airflow.service.v1beta1.Environment[] = []; - stream.on('data', (response: protos.google.cloud.orchestration.airflow.service.v1beta1.Environment) => { - 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.listEnvironments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEnvironments, request)); - assert( - (client.descriptors.page.listEnvironments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listEnvironmentsStream with error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listEnvironments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listEnvironmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.orchestration.airflow.service.v1beta1.Environment[] = []; - stream.on('data', (response: protos.google.cloud.orchestration.airflow.service.v1beta1.Environment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listEnvironments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEnvironments, request)); - assert( - (client.descriptors.page.listEnvironments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listEnvironments without error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.Environment()), - ]; - client.descriptors.page.listEnvironments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment[] = []; - const iterable = client.listEnvironmentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listEnvironments with error', async () => { - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listEnvironments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listEnvironmentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.orchestration.airflow.service.v1beta1.IEnvironment[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEnvironments.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 environmentsModule.v1beta1.EnvironmentsClient({ - 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 environmentsModule.v1beta1.EnvironmentsClient({ - 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 environmentsModule.v1beta1.EnvironmentsClient({ - 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 environmentsModule.v1beta1.EnvironmentsClient({ - 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 environmentsModule.v1beta1.EnvironmentsClient({ - 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 environmentsModule.v1beta1.EnvironmentsClient({ - 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 environmentsModule.v1beta1.EnvironmentsClient({ - 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 environmentsModule.v1beta1.EnvironmentsClient({ - 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 environmentsModule.v1beta1.EnvironmentsClient({ - 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 environmentsModule.v1beta1.EnvironmentsClient({ - 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 environmentsModule.v1beta1.EnvironmentsClient({ - 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('environment', () => { - const fakePath = "/rendered/path/environment"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - environment: "environmentValue", - }; - const client = new environmentsModule.v1beta1.EnvironmentsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.environmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.environmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('environmentPath', () => { - const result = client.environmentPath("projectValue", "locationValue", "environmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.environmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEnvironmentName', () => { - const result = client.matchProjectFromEnvironmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEnvironmentName', () => { - const result = client.matchLocationFromEnvironmentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEnvironmentFromEnvironmentName', () => { - const result = client.matchEnvironmentFromEnvironmentName(fakePath); - assert.strictEqual(result, "environmentValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/test/gapic_image_versions_v1beta1.ts b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/test/gapic_image_versions_v1beta1.ts deleted file mode 100644 index 43138056002..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/test/gapic_image_versions_v1beta1.ts +++ /dev/null @@ -1,491 +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 imageversionsModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -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('v1beta1.ImageVersionsClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageversionsModule.v1beta1.ImageVersionsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageversionsModule.v1beta1.ImageVersionsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageversionsModule.v1beta1.ImageVersionsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageversionsModule.v1beta1.ImageVersionsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageversionsModule.v1beta1.ImageVersionsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageversionsModule.v1beta1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageVersionsStub, undefined); - await client.initialize(); - assert(client.imageVersionsStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageversionsModule.v1beta1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageVersionsStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageversionsModule.v1beta1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageVersionsStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageversionsModule.v1beta1.ImageVersionsClient({ - 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 imageversionsModule.v1beta1.ImageVersionsClient({ - 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('listImageVersions', () => { - it('invokes listImageVersions without error', async () => { - const client = new imageversionsModule.v1beta1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), - ]; - client.innerApiCalls.listImageVersions = stubSimpleCall(expectedResponse); - const [response] = await client.listImageVersions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listImageVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listImageVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listImageVersions without error using callback', async () => { - const client = new imageversionsModule.v1beta1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), - ]; - client.innerApiCalls.listImageVersions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listImageVersions( - request, - (err?: Error|null, result?: protos.google.cloud.orchestration.airflow.service.v1beta1.IImageVersion[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listImageVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listImageVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listImageVersions with error', async () => { - const client = new imageversionsModule.v1beta1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listImageVersions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listImageVersions(request), expectedError); - const actualRequest = (client.innerApiCalls.listImageVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listImageVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listImageVersionsStream without error', async () => { - const client = new imageversionsModule.v1beta1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), - ]; - client.descriptors.page.listImageVersions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listImageVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion[] = []; - stream.on('data', (response: protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion) => { - 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.listImageVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listImageVersions, request)); - assert( - (client.descriptors.page.listImageVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listImageVersionsStream with error', async () => { - const client = new imageversionsModule.v1beta1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listImageVersions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listImageVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion[] = []; - stream.on('data', (response: protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listImageVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listImageVersions, request)); - assert( - (client.descriptors.page.listImageVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listImageVersions without error', async () => { - const client = new imageversionsModule.v1beta1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), - generateSampleMessage(new protos.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion()), - ]; - client.descriptors.page.listImageVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.orchestration.airflow.service.v1beta1.IImageVersion[] = []; - const iterable = client.listImageVersionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listImageVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listImageVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listImageVersions with error', async () => { - const client = new imageversionsModule.v1beta1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listImageVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listImageVersionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.orchestration.airflow.service.v1beta1.IImageVersion[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listImageVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listImageVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('environment', () => { - const fakePath = "/rendered/path/environment"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - environment: "environmentValue", - }; - const client = new imageversionsModule.v1beta1.ImageVersionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.environmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.environmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('environmentPath', () => { - const result = client.environmentPath("projectValue", "locationValue", "environmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.environmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEnvironmentName', () => { - const result = client.matchProjectFromEnvironmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEnvironmentName', () => { - const result = client.matchLocationFromEnvironmentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEnvironmentFromEnvironmentName', () => { - const result = client.matchEnvironmentFromEnvironmentName(fakePath); - assert.strictEqual(result, "environmentValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/webpack.config.js deleted file mode 100644 index 9b7becac60a..00000000000 --- a/owl-bot-staging/google-cloud-orchestration-airflow-service/v1beta1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'Environments', - filename: './environments.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-orgpolicy/v2/.eslintignore b/owl-bot-staging/google-cloud-orgpolicy/v2/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/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-orgpolicy/v2/.eslintrc.json b/owl-bot-staging/google-cloud-orgpolicy/v2/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/.gitignore b/owl-bot-staging/google-cloud-orgpolicy/v2/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/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-orgpolicy/v2/.jsdoc.js b/owl-bot-staging/google-cloud-orgpolicy/v2/.jsdoc.js deleted file mode 100644 index 3a6f96b968e..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/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/org-policy', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/.mocharc.js b/owl-bot-staging/google-cloud-orgpolicy/v2/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/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-orgpolicy/v2/.prettierrc.js b/owl-bot-staging/google-cloud-orgpolicy/v2/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/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-orgpolicy/v2/README.md b/owl-bot-staging/google-cloud-orgpolicy/v2/README.md deleted file mode 100644 index 1c081c68780..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/README.md +++ /dev/null @@ -1 +0,0 @@ -Orgpolicy: Nodejs Client diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/package.json b/owl-bot-staging/google-cloud-orgpolicy/v2/package.json deleted file mode 100644 index b824cf8d9cd..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/org-policy", - "version": "0.1.0", - "description": "Orgpolicy client for Node.js", - "repository": "googleapis/nodejs-orgpolicy", - "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 orgpolicy", - "orgpolicy", - "org policy" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/protos/google/cloud/orgpolicy/v2/constraint.proto b/owl-bot-staging/google-cloud-orgpolicy/v2/protos/google/cloud/orgpolicy/v2/constraint.proto deleted file mode 100644 index 9a14e93fa87..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/protos/google/cloud/orgpolicy/v2/constraint.proto +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.orgpolicy.v2; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.OrgPolicy.V2"; -option go_package = "cloud.google.com/go/orgpolicy/apiv2/orgpolicypb;orgpolicypb"; -option java_multiple_files = true; -option java_outer_classname = "ConstraintProto"; -option java_package = "com.google.cloud.orgpolicy.v2"; -option php_namespace = "Google\\Cloud\\OrgPolicy\\V2"; -option ruby_package = "Google::Cloud::OrgPolicy::V2"; - -// A `constraint` describes a way to restrict resource's configuration. For -// example, you could enforce a constraint that controls which cloud services -// can be activated across an organization, or whether a Compute Engine instance -// can have serial port connections established. `Constraints` can be configured -// by the organization's policy administrator to fit the needs of the -// organization by setting a `policy` that includes `constraints` at different -// locations in the organization's resource hierarchy. Policies are inherited -// down the resource hierarchy from higher levels, but can also be overridden. -// For details about the inheritance rules please read about -// [`policies`][google.cloud.OrgPolicy.v2.Policy]. -// -// `Constraints` have a default behavior determined by the `constraint_default` -// field, which is the enforcement behavior that is used in the absence of a -// `policy` being defined or inherited for the resource in question. -message Constraint { - option (google.api.resource) = { - type: "orgpolicy.googleapis.com/Constraint" - pattern: "projects/{project}/constraints/{constraint}" - pattern: "folders/{folder}/constraints/{constraint}" - pattern: "organizations/{organization}/constraints/{constraint}" - }; - - // Specifies the default behavior in the absence of any `Policy` for the - // `Constraint`. This must not be `CONSTRAINT_DEFAULT_UNSPECIFIED`. - // - // Immutable after creation. - enum ConstraintDefault { - // This is only used for distinguishing unset values and should never be - // used. - CONSTRAINT_DEFAULT_UNSPECIFIED = 0; - - // Indicate that all values are allowed for list constraints. - // Indicate that enforcement is off for boolean constraints. - ALLOW = 1; - - // Indicate that all values are denied for list constraints. - // Indicate that enforcement is on for boolean constraints. - DENY = 2; - } - - // A `Constraint` that allows or disallows a list of string values, which are - // configured by an Organization's policy administrator with a `Policy`. - message ListConstraint { - // Indicates whether values grouped into categories can be used in - // `Policy.allowed_values` and `Policy.denied_values`. For example, - // `"in:Python"` would match any value in the 'Python' group. - bool supports_in = 1; - - // Indicates whether subtrees of Cloud Resource Manager resource hierarchy - // can be used in `Policy.allowed_values` and `Policy.denied_values`. For - // example, `"under:folders/123"` would match any resource under the - // 'folders/123' folder. - bool supports_under = 2; - } - - // A `Constraint` that is either enforced or not. - // - // For example a constraint `constraints/compute.disableSerialPortAccess`. - // If it is enforced on a VM instance, serial port connections will not be - // opened to that instance. - message BooleanConstraint {} - - // Immutable. The resource name of the Constraint. Must be in one of - // the following forms: - // * `projects/{project_number}/constraints/{constraint_name}` - // * `folders/{folder_id}/constraints/{constraint_name}` - // * `organizations/{organization_id}/constraints/{constraint_name}` - // - // For example, "/projects/123/constraints/compute.disableSerialPortAccess". - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // The human readable name. - // - // Mutable. - string display_name = 2; - - // Detailed description of what this `Constraint` controls as well as how and - // where it is enforced. - // - // Mutable. - string description = 3; - - // The evaluation behavior of this constraint in the absence of 'Policy'. - ConstraintDefault constraint_default = 4; - - // The type of restrictions for this `Constraint`. - // - // Immutable after creation. - oneof constraint_type { - // Defines this constraint as being a ListConstraint. - ListConstraint list_constraint = 5; - - // Defines this constraint as being a BooleanConstraint. - BooleanConstraint boolean_constraint = 6; - } -} diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/protos/google/cloud/orgpolicy/v2/orgpolicy.proto b/owl-bot-staging/google-cloud-orgpolicy/v2/protos/google/cloud/orgpolicy/v2/orgpolicy.proto deleted file mode 100644 index 0504d074824..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/protos/google/cloud/orgpolicy/v2/orgpolicy.proto +++ /dev/null @@ -1,478 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.orgpolicy.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/orgpolicy/v2/constraint.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/type/expr.proto"; - -option csharp_namespace = "Google.Cloud.OrgPolicy.V2"; -option go_package = "cloud.google.com/go/orgpolicy/apiv2/orgpolicypb;orgpolicypb"; -option java_multiple_files = true; -option java_outer_classname = "OrgPolicyProto"; -option java_package = "com.google.cloud.orgpolicy.v2"; -option php_namespace = "Google\\Cloud\\OrgPolicy\\V2"; -option ruby_package = "Google::Cloud::OrgPolicy::V2"; - -// An interface for managing organization policies. -// -// The Cloud Org Policy service provides a simple mechanism for organizations to -// restrict the allowed configurations across their entire Cloud Resource -// hierarchy. -// -// You can use a `policy` to configure restrictions in Cloud resources. For -// example, you can enforce a `policy` that restricts which Google -// Cloud Platform APIs can be activated in a certain part of your resource -// hierarchy, or prevents serial port access to VM instances in a particular -// folder. -// -// `Policies` are inherited down through the resource hierarchy. A `policy` -// applied to a parent resource automatically applies to all its child resources -// unless overridden with a `policy` lower in the hierarchy. -// -// A `constraint` defines an aspect of a resource's configuration that can be -// controlled by an organization's policy administrator. `Policies` are a -// collection of `constraints` that defines their allowable configuration on a -// particular resource and its child resources. -service OrgPolicy { - option (google.api.default_host) = "orgpolicy.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Lists `Constraints` that could be applied on the specified resource. - rpc ListConstraints(ListConstraintsRequest) - returns (ListConstraintsResponse) { - option (google.api.http) = { - get: "/v2/{parent=projects/*}/constraints" - additional_bindings { get: "/v2/{parent=folders/*}/constraints" } - additional_bindings { get: "/v2/{parent=organizations/*}/constraints" } - }; - option (google.api.method_signature) = "parent"; - } - - // Retrieves all of the `Policies` that exist on a particular resource. - rpc ListPolicies(ListPoliciesRequest) returns (ListPoliciesResponse) { - option (google.api.http) = { - get: "/v2/{parent=projects/*}/policies" - additional_bindings { get: "/v2/{parent=folders/*}/policies" } - additional_bindings { get: "/v2/{parent=organizations/*}/policies" } - }; - option (google.api.method_signature) = "parent"; - } - - // Gets a `Policy` on a resource. - // - // If no `Policy` is set on the resource, NOT_FOUND is returned. The - // `etag` value can be used with `UpdatePolicy()` to update a - // `Policy` during read-modify-write. - rpc GetPolicy(GetPolicyRequest) returns (Policy) { - option (google.api.http) = { - get: "/v2/{name=projects/*/policies/*}" - additional_bindings { get: "/v2/{name=folders/*/policies/*}" } - additional_bindings { get: "/v2/{name=organizations/*/policies/*}" } - }; - option (google.api.method_signature) = "name"; - } - - // Gets the effective `Policy` on a resource. This is the result of merging - // `Policies` in the resource hierarchy and evaluating conditions. The - // returned `Policy` will not have an `etag` or `condition` set because it is - // a computed `Policy` across multiple resources. - // Subtrees of Resource Manager resource hierarchy with 'under:' prefix will - // not be expanded. - rpc GetEffectivePolicy(GetEffectivePolicyRequest) returns (Policy) { - option (google.api.http) = { - get: "/v2/{name=projects/*/policies/*}:getEffectivePolicy" - additional_bindings { - get: "/v2/{name=folders/*/policies/*}:getEffectivePolicy" - } - additional_bindings { - get: "/v2/{name=organizations/*/policies/*}:getEffectivePolicy" - } - }; - option (google.api.method_signature) = "name"; - } - - // Creates a Policy. - // - // Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the - // constraint does not exist. - // Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the - // policy already exists on the given Cloud resource. - rpc CreatePolicy(CreatePolicyRequest) returns (Policy) { - option (google.api.http) = { - post: "/v2/{parent=projects/*}/policies" - body: "policy" - additional_bindings { - post: "/v2/{parent=folders/*}/policies" - body: "policy" - } - additional_bindings { - post: "/v2/{parent=organizations/*}/policies" - body: "policy" - } - }; - option (google.api.method_signature) = "parent,policy"; - } - - // Updates a Policy. - // - // Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the - // constraint or the policy do not exist. - // Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag - // supplied in the request does not match the persisted etag of the policy - // - // Note: the supplied policy will perform a full overwrite of all - // fields. - rpc UpdatePolicy(UpdatePolicyRequest) returns (Policy) { - option (google.api.http) = { - patch: "/v2/{policy.name=projects/*/policies/*}" - body: "policy" - additional_bindings { - patch: "/v2/{policy.name=folders/*/policies/*}" - body: "policy" - } - additional_bindings { - patch: "/v2/{policy.name=organizations/*/policies/*}" - body: "policy" - } - }; - option (google.api.method_signature) = "policy"; - } - - // Deletes a Policy. - // - // Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the - // constraint or Org Policy does not exist. - rpc DeletePolicy(DeletePolicyRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v2/{name=projects/*/policies/*}" - additional_bindings { delete: "/v2/{name=folders/*/policies/*}" } - additional_bindings { delete: "/v2/{name=organizations/*/policies/*}" } - }; - option (google.api.method_signature) = "name"; - } -} - -// Defines a Cloud Organization `Policy` which is used to specify `Constraints` -// for configurations of Cloud Platform resources. -message Policy { - option (google.api.resource) = { - type: "orgpolicy.googleapis.com/Policy" - pattern: "projects/{project}/policies/{policy}" - pattern: "folders/{folder}/policies/{policy}" - pattern: "organizations/{organization}/policies/{policy}" - }; - - // Immutable. The resource name of the Policy. Must be one of the following - // forms, where constraint_name is the name of the constraint which this - // Policy configures: - // * `projects/{project_number}/policies/{constraint_name}` - // * `folders/{folder_id}/policies/{constraint_name}` - // * `organizations/{organization_id}/policies/{constraint_name}` - // - // For example, "projects/123/policies/compute.disableSerialPortAccess". - // - // Note: `projects/{project_id}/policies/{constraint_name}` is also an - // acceptable name for API requests, but responses will return the name using - // the equivalent project number. - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Basic information about the Organization Policy. - PolicySpec spec = 2; - - // Deprecated. - AlternatePolicySpec alternate = 3 [deprecated = true]; - - // dry-run policy. - // Audit-only policy, can be used to monitor how the policy would have - // impacted the existing and future resources if it's enforced. - PolicySpec dry_run_spec = 4; -} - -// Similar to PolicySpec but with an extra 'launch' field for launch reference. -// The PolicySpec here is specific for dry-run/darklaunch. -message AlternatePolicySpec { - // Reference to the launch that will be used while audit logging and to - // control the launch. - // Should be set only in the alternate policy. - string launch = 1; - - // Specify `Constraint` for configurations of Cloud Platform resources. - PolicySpec spec = 2; -} - -// Defines a Cloud Organization `PolicySpec` which is used to specify -// `Constraints` for configurations of Cloud Platform resources. -message PolicySpec { - // A rule used to express this policy. - message PolicyRule { - // A message that holds specific allowed and denied values. - // This message can define specific values and subtrees of Cloud Resource - // Manager resource hierarchy (`Organizations`, `Folders`, `Projects`) that - // are allowed or denied. This is achieved by using the `under:` and - // optional `is:` prefixes. - // The `under:` prefix is used to denote resource subtree values. - // The `is:` prefix is used to denote specific values, and is required only - // if the value contains a ":". Values prefixed with "is:" are treated the - // same as values with no prefix. - // Ancestry subtrees must be in one of the following formats: - // - "projects/", e.g. "projects/tokyo-rain-123" - // - "folders/", e.g. "folders/1234" - // - "organizations/", e.g. "organizations/1234" - // The `supports_under` field of the associated `Constraint` defines - // whether ancestry prefixes can be used. - message StringValues { - // List of values allowed at this resource. - repeated string allowed_values = 1; - - // List of values denied at this resource. - repeated string denied_values = 2; - } - - oneof kind { - // List of values to be used for this PolicyRule. This field can be set - // only in Policies for list constraints. - StringValues values = 1; - - // Setting this to true means that all values are allowed. This field can - // be set only in Policies for list constraints. - bool allow_all = 2; - - // Setting this to true means that all values are denied. This field can - // be set only in Policies for list constraints. - bool deny_all = 3; - - // If `true`, then the `Policy` is enforced. If `false`, then any - // configuration is acceptable. - // This field can be set only in Policies for boolean constraints. - bool enforce = 4; - } - - // A condition which determines whether this rule is used - // in the evaluation of the policy. When set, the `expression` field in - // the `Expr' must include from 1 to 10 subexpressions, joined by the "||" - // or "&&" operators. Each subexpression must be of the form - // "resource.matchTag('/tag_key_short_name, - // 'tag_value_short_name')". or "resource.matchTagId('tagKeys/key_id', - // 'tagValues/value_id')". where key_name and value_name are the resource - // names for Label Keys and Values. These names are available from the Tag - // Manager Service. An example expression is: - // "resource.matchTag('123456789/environment, - // 'prod')". or "resource.matchTagId('tagKeys/123', - // 'tagValues/456')". - google.type.Expr condition = 5; - } - - // An opaque tag indicating the current version of the `Policy`, used for - // concurrency control. - // - // This field is ignored if used in a `CreatePolicy` request. - // - // When the `Policy` is returned from either a `GetPolicy` or a - // `ListPolicies` request, this `etag` indicates the version of the - // current `Policy` to use when executing a read-modify-write loop. - // - // When the `Policy` is returned from a `GetEffectivePolicy` request, the - // `etag` will be unset. - string etag = 1; - - // Output only. The time stamp this was previously updated. This - // represents the last time a call to `CreatePolicy` or `UpdatePolicy` was - // made for that `Policy`. - google.protobuf.Timestamp update_time = 2 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Up to 10 PolicyRules are allowed. - // - // In Policies for boolean constraints, the following requirements apply: - // - There must be one and only one PolicyRule where condition is unset. - // - BooleanPolicyRules with conditions must set `enforced` to the opposite - // of the PolicyRule without a condition. - // - During policy evaluation, PolicyRules with conditions that are - // true for a target resource take precedence. - repeated PolicyRule rules = 3; - - // Determines the inheritance behavior for this `Policy`. - // - // If `inherit_from_parent` is true, PolicyRules set higher up in the - // hierarchy (up to the closest root) are inherited and present in the - // effective policy. If it is false, then no rules are inherited, and this - // Policy becomes the new root for evaluation. - // This field can be set only for Policies which configure list constraints. - bool inherit_from_parent = 4; - - // Ignores policies set above this resource and restores the - // `constraint_default` enforcement behavior of the specific `Constraint` at - // this resource. - // This field can be set in policies for either list or boolean - // constraints. If set, `rules` must be empty and `inherit_from_parent` - // must be set to false. - bool reset = 5; -} - -// The request sent to the [ListConstraints] -// [google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints] method. -message ListConstraintsRequest { - // Required. The Cloud resource that parents the constraint. Must be in one of - // the following forms: - // * `projects/{project_number}` - // * `projects/{project_id}` - // * `folders/{folder_id}` - // * `organizations/{organization_id}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "orgpolicy.googleapis.com/Constraint" - } - ]; - - // Size of the pages to be returned. This is currently unsupported and will - // be ignored. The server may at any point start using this field to limit - // page size. - int32 page_size = 2; - - // Page token used to retrieve the next page. This is currently unsupported - // and will be ignored. The server may at any point start using this field. - string page_token = 3; -} - -// The response returned from the [ListConstraints] -// [google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints] method. -message ListConstraintsResponse { - // The collection of constraints that are available on the targeted resource. - repeated Constraint constraints = 1; - - // Page token used to retrieve the next page. This is currently not used. - string next_page_token = 2; -} - -// The request sent to the [ListPolicies] -// [google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies] method. -message ListPoliciesRequest { - // Required. The target Cloud resource that parents the set of constraints and - // policies that will be returned from this call. Must be in one of the - // following forms: - // * `projects/{project_number}` - // * `projects/{project_id}` - // * `folders/{folder_id}` - // * `organizations/{organization_id}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "orgpolicy.googleapis.com/Policy" - } - ]; - - // Size of the pages to be returned. This is currently unsupported and will - // be ignored. The server may at any point start using this field to limit - // page size. - int32 page_size = 2; - - // Page token used to retrieve the next page. This is currently unsupported - // and will be ignored. The server may at any point start using this field. - string page_token = 3; -} - -// The response returned from the [ListPolicies] -// [google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies] method. It will be empty -// if no `Policies` are set on the resource. -message ListPoliciesResponse { - // All `Policies` that exist on the resource. It will be empty if no - // `Policies` are set. - repeated Policy policies = 1; - - // Page token used to retrieve the next page. This is currently not used, but - // the server may at any point start supplying a valid token. - string next_page_token = 2; -} - -// The request sent to the [GetPolicy] -// [google.cloud.orgpolicy.v2.OrgPolicy.GetPolicy] method. -message GetPolicyRequest { - // Required. Resource name of the policy. See `Policy` for naming - // requirements. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "orgpolicy.googleapis.com/Policy" - } - ]; -} - -// The request sent to the [GetEffectivePolicy] -// [google.cloud.orgpolicy.v2.OrgPolicy.GetEffectivePolicy] method. -message GetEffectivePolicyRequest { - // Required. The effective policy to compute. See `Policy` for naming rules. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "orgpolicy.googleapis.com/Policy" - } - ]; -} - -// The request sent to the [CreatePolicyRequest] -// [google.cloud.orgpolicy.v2.OrgPolicy.CreatePolicy] method. -message CreatePolicyRequest { - // Required. The Cloud resource that will parent the new Policy. Must be in - // one of the following forms: - // * `projects/{project_number}` - // * `projects/{project_id}` - // * `folders/{folder_id}` - // * `organizations/{organization_id}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "orgpolicy.googleapis.com/Policy" - } - ]; - - // Required. `Policy` to create. - Policy policy = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// The request sent to the [UpdatePolicyRequest] -// [google.cloud.orgpolicy.v2.OrgPolicy.UpdatePolicy] method. -message UpdatePolicyRequest { - // Required. `Policy` to update. - Policy policy = 1 [(google.api.field_behavior) = REQUIRED]; - - // Field mask used to specify the fields to be overwritten in the policy - // by the set. The fields specified in the update_mask are relative to the - // policy, not the full request. - google.protobuf.FieldMask update_mask = 3; -} - -// The request sent to the [DeletePolicy] -// [google.cloud.orgpolicy.v2.OrgPolicy.DeletePolicy] method. -message DeletePolicyRequest { - // Required. Name of the policy to delete. - // See `Policy` for naming rules. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "orgpolicy.googleapis.com/Policy" - } - ]; -} diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.create_policy.js b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.create_policy.js deleted file mode 100644 index 9332ceeffea..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.create_policy.js +++ /dev/null @@ -1,71 +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, policy) { - // [START orgpolicy_v2_generated_OrgPolicy_CreatePolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Cloud resource that will parent the new Policy. Must be in - * one of the following forms: - * * `projects/{project_number}` - * * `projects/{project_id}` - * * `folders/{folder_id}` - * * `organizations/{organization_id}` - */ - // const parent = 'abc123' - /** - * Required. `Policy` to create. - */ - // const policy = {} - - // Imports the Orgpolicy library - const {OrgPolicyClient} = require('@google-cloud/org-policy').v2; - - // Instantiates a client - const orgpolicyClient = new OrgPolicyClient(); - - async function callCreatePolicy() { - // Construct request - const request = { - parent, - policy, - }; - - // Run request - const response = await orgpolicyClient.createPolicy(request); - console.log(response); - } - - callCreatePolicy(); - // [END orgpolicy_v2_generated_OrgPolicy_CreatePolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.delete_policy.js b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.delete_policy.js deleted file mode 100644 index 412ca7ab8d6..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.delete_policy.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 orgpolicy_v2_generated_OrgPolicy_DeletePolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the policy to delete. - * See `Policy` for naming rules. - */ - // const name = 'abc123' - - // Imports the Orgpolicy library - const {OrgPolicyClient} = require('@google-cloud/org-policy').v2; - - // Instantiates a client - const orgpolicyClient = new OrgPolicyClient(); - - async function callDeletePolicy() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await orgpolicyClient.deletePolicy(request); - console.log(response); - } - - callDeletePolicy(); - // [END orgpolicy_v2_generated_OrgPolicy_DeletePolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.get_effective_policy.js b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.get_effective_policy.js deleted file mode 100644 index 395162c82ef..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.get_effective_policy.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(name) { - // [START orgpolicy_v2_generated_OrgPolicy_GetEffectivePolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The effective policy to compute. See `Policy` for naming rules. - */ - // const name = 'abc123' - - // Imports the Orgpolicy library - const {OrgPolicyClient} = require('@google-cloud/org-policy').v2; - - // Instantiates a client - const orgpolicyClient = new OrgPolicyClient(); - - async function callGetEffectivePolicy() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await orgpolicyClient.getEffectivePolicy(request); - console.log(response); - } - - callGetEffectivePolicy(); - // [END orgpolicy_v2_generated_OrgPolicy_GetEffectivePolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.get_policy.js b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.get_policy.js deleted file mode 100644 index 532fe0441f7..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.get_policy.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 orgpolicy_v2_generated_OrgPolicy_GetPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the policy. See `Policy` for naming - * requirements. - */ - // const name = 'abc123' - - // Imports the Orgpolicy library - const {OrgPolicyClient} = require('@google-cloud/org-policy').v2; - - // Instantiates a client - const orgpolicyClient = new OrgPolicyClient(); - - async function callGetPolicy() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await orgpolicyClient.getPolicy(request); - console.log(response); - } - - callGetPolicy(); - // [END orgpolicy_v2_generated_OrgPolicy_GetPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.list_constraints.js b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.list_constraints.js deleted file mode 100644 index c65243b9610..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.list_constraints.js +++ /dev/null @@ -1,79 +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 orgpolicy_v2_generated_OrgPolicy_ListConstraints_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Cloud resource that parents the constraint. Must be in one of - * the following forms: - * * `projects/{project_number}` - * * `projects/{project_id}` - * * `folders/{folder_id}` - * * `organizations/{organization_id}` - */ - // const parent = 'abc123' - /** - * Size of the pages to be returned. This is currently unsupported and will - * be ignored. The server may at any point start using this field to limit - * page size. - */ - // const pageSize = 1234 - /** - * Page token used to retrieve the next page. This is currently unsupported - * and will be ignored. The server may at any point start using this field. - */ - // const pageToken = 'abc123' - - // Imports the Orgpolicy library - const {OrgPolicyClient} = require('@google-cloud/org-policy').v2; - - // Instantiates a client - const orgpolicyClient = new OrgPolicyClient(); - - async function callListConstraints() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await orgpolicyClient.listConstraintsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListConstraints(); - // [END orgpolicy_v2_generated_OrgPolicy_ListConstraints_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.list_policies.js b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.list_policies.js deleted file mode 100644 index 37256b96f4f..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.list_policies.js +++ /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. ** - - - -'use strict'; - -function main(parent) { - // [START orgpolicy_v2_generated_OrgPolicy_ListPolicies_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The target Cloud resource that parents the set of constraints and - * policies that will be returned from this call. Must be in one of the - * following forms: - * * `projects/{project_number}` - * * `projects/{project_id}` - * * `folders/{folder_id}` - * * `organizations/{organization_id}` - */ - // const parent = 'abc123' - /** - * Size of the pages to be returned. This is currently unsupported and will - * be ignored. The server may at any point start using this field to limit - * page size. - */ - // const pageSize = 1234 - /** - * Page token used to retrieve the next page. This is currently unsupported - * and will be ignored. The server may at any point start using this field. - */ - // const pageToken = 'abc123' - - // Imports the Orgpolicy library - const {OrgPolicyClient} = require('@google-cloud/org-policy').v2; - - // Instantiates a client - const orgpolicyClient = new OrgPolicyClient(); - - async function callListPolicies() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await orgpolicyClient.listPoliciesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListPolicies(); - // [END orgpolicy_v2_generated_OrgPolicy_ListPolicies_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.update_policy.js b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.update_policy.js deleted file mode 100644 index 3b91bf0d04a..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/org_policy.update_policy.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(policy) { - // [START orgpolicy_v2_generated_OrgPolicy_UpdatePolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. `Policy` to update. - */ - // const policy = {} - /** - * Field mask used to specify the fields to be overwritten in the policy - * by the set. The fields specified in the update_mask are relative to the - * policy, not the full request. - */ - // const updateMask = {} - - // Imports the Orgpolicy library - const {OrgPolicyClient} = require('@google-cloud/org-policy').v2; - - // Instantiates a client - const orgpolicyClient = new OrgPolicyClient(); - - async function callUpdatePolicy() { - // Construct request - const request = { - policy, - }; - - // Run request - const response = await orgpolicyClient.updatePolicy(request); - console.log(response); - } - - callUpdatePolicy(); - // [END orgpolicy_v2_generated_OrgPolicy_UpdatePolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/snippet_metadata_google.cloud.orgpolicy.v2.json b/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/snippet_metadata_google.cloud.orgpolicy.v2.json deleted file mode 100644 index 8863c861327..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/samples/generated/v2/snippet_metadata_google.cloud.orgpolicy.v2.json +++ /dev/null @@ -1,319 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-orgpolicy", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.orgpolicy.v2", - "version": "v2" - } - ] - }, - "snippets": [ - { - "regionTag": "orgpolicy_v2_generated_OrgPolicy_ListConstraints_async", - "title": "OrgPolicy listConstraints Sample", - "origin": "API_DEFINITION", - "description": " Lists `Constraints` that could be applied on the specified resource.", - "canonical": true, - "file": "org_policy.list_constraints.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListConstraints", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.orgpolicy.v2.ListConstraintsResponse", - "client": { - "shortName": "OrgPolicyClient", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicyClient" - }, - "method": { - "shortName": "ListConstraints", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints", - "service": { - "shortName": "OrgPolicy", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicy" - } - } - } - }, - { - "regionTag": "orgpolicy_v2_generated_OrgPolicy_ListPolicies_async", - "title": "OrgPolicy listPolicies Sample", - "origin": "API_DEFINITION", - "description": " Retrieves all of the `Policies` that exist on a particular resource.", - "canonical": true, - "file": "org_policy.list_policies.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListPolicies", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.orgpolicy.v2.ListPoliciesResponse", - "client": { - "shortName": "OrgPolicyClient", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicyClient" - }, - "method": { - "shortName": "ListPolicies", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies", - "service": { - "shortName": "OrgPolicy", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicy" - } - } - } - }, - { - "regionTag": "orgpolicy_v2_generated_OrgPolicy_GetPolicy_async", - "title": "OrgPolicy getPolicy Sample", - "origin": "API_DEFINITION", - "description": " Gets a `Policy` on a resource. If no `Policy` is set on the resource, NOT_FOUND is returned. The `etag` value can be used with `UpdatePolicy()` to update a `Policy` during read-modify-write.", - "canonical": true, - "file": "org_policy.get_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetPolicy", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.GetPolicy", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.orgpolicy.v2.Policy", - "client": { - "shortName": "OrgPolicyClient", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicyClient" - }, - "method": { - "shortName": "GetPolicy", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.GetPolicy", - "service": { - "shortName": "OrgPolicy", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicy" - } - } - } - }, - { - "regionTag": "orgpolicy_v2_generated_OrgPolicy_GetEffectivePolicy_async", - "title": "OrgPolicy getEffectivePolicy Sample", - "origin": "API_DEFINITION", - "description": " Gets the effective `Policy` on a resource. This is the result of merging `Policies` in the resource hierarchy and evaluating conditions. The returned `Policy` will not have an `etag` or `condition` set because it is a computed `Policy` across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.", - "canonical": true, - "file": "org_policy.get_effective_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetEffectivePolicy", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.GetEffectivePolicy", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.orgpolicy.v2.Policy", - "client": { - "shortName": "OrgPolicyClient", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicyClient" - }, - "method": { - "shortName": "GetEffectivePolicy", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.GetEffectivePolicy", - "service": { - "shortName": "OrgPolicy", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicy" - } - } - } - }, - { - "regionTag": "orgpolicy_v2_generated_OrgPolicy_CreatePolicy_async", - "title": "OrgPolicy createPolicy Sample", - "origin": "API_DEFINITION", - "description": " Creates a Policy. Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint does not exist. Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the policy already exists on the given Cloud resource.", - "canonical": true, - "file": "org_policy.create_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreatePolicy", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.CreatePolicy", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "policy", - "type": ".google.cloud.orgpolicy.v2.Policy" - } - ], - "resultType": ".google.cloud.orgpolicy.v2.Policy", - "client": { - "shortName": "OrgPolicyClient", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicyClient" - }, - "method": { - "shortName": "CreatePolicy", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.CreatePolicy", - "service": { - "shortName": "OrgPolicy", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicy" - } - } - } - }, - { - "regionTag": "orgpolicy_v2_generated_OrgPolicy_UpdatePolicy_async", - "title": "OrgPolicy updatePolicy Sample", - "origin": "API_DEFINITION", - "description": " Updates a Policy. Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or the policy do not exist. Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag supplied in the request does not match the persisted etag of the policy Note: the supplied policy will perform a full overwrite of all fields.", - "canonical": true, - "file": "org_policy.update_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdatePolicy", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.UpdatePolicy", - "async": true, - "parameters": [ - { - "name": "policy", - "type": ".google.cloud.orgpolicy.v2.Policy" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.orgpolicy.v2.Policy", - "client": { - "shortName": "OrgPolicyClient", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicyClient" - }, - "method": { - "shortName": "UpdatePolicy", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.UpdatePolicy", - "service": { - "shortName": "OrgPolicy", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicy" - } - } - } - }, - { - "regionTag": "orgpolicy_v2_generated_OrgPolicy_DeletePolicy_async", - "title": "OrgPolicy deletePolicy Sample", - "origin": "API_DEFINITION", - "description": " Deletes a Policy. Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or Org Policy does not exist.", - "canonical": true, - "file": "org_policy.delete_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeletePolicy", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.DeletePolicy", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "OrgPolicyClient", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicyClient" - }, - "method": { - "shortName": "DeletePolicy", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicy.DeletePolicy", - "service": { - "shortName": "OrgPolicy", - "fullName": "google.cloud.orgpolicy.v2.OrgPolicy" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/src/index.ts b/owl-bot-staging/google-cloud-orgpolicy/v2/src/index.ts deleted file mode 100644 index cc6385df5ae..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/src/index.ts +++ /dev/null @@ -1,25 +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 OrgPolicyClient = v2.OrgPolicyClient; -type OrgPolicyClient = v2.OrgPolicyClient; -export {v2, OrgPolicyClient}; -export default {v2, OrgPolicyClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/gapic_metadata.json b/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/gapic_metadata.json deleted file mode 100644 index 3fd440b8082..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/gapic_metadata.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.orgpolicy.v2", - "libraryPackage": "@google-cloud/org-policy", - "services": { - "OrgPolicy": { - "clients": { - "grpc": { - "libraryClient": "OrgPolicyClient", - "rpcs": { - "GetPolicy": { - "methods": [ - "getPolicy" - ] - }, - "GetEffectivePolicy": { - "methods": [ - "getEffectivePolicy" - ] - }, - "CreatePolicy": { - "methods": [ - "createPolicy" - ] - }, - "UpdatePolicy": { - "methods": [ - "updatePolicy" - ] - }, - "DeletePolicy": { - "methods": [ - "deletePolicy" - ] - }, - "ListConstraints": { - "methods": [ - "listConstraints", - "listConstraintsStream", - "listConstraintsAsync" - ] - }, - "ListPolicies": { - "methods": [ - "listPolicies", - "listPoliciesStream", - "listPoliciesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "OrgPolicyClient", - "rpcs": { - "GetPolicy": { - "methods": [ - "getPolicy" - ] - }, - "GetEffectivePolicy": { - "methods": [ - "getEffectivePolicy" - ] - }, - "CreatePolicy": { - "methods": [ - "createPolicy" - ] - }, - "UpdatePolicy": { - "methods": [ - "updatePolicy" - ] - }, - "DeletePolicy": { - "methods": [ - "deletePolicy" - ] - }, - "ListConstraints": { - "methods": [ - "listConstraints", - "listConstraintsStream", - "listConstraintsAsync" - ] - }, - "ListPolicies": { - "methods": [ - "listPolicies", - "listPoliciesStream", - "listPoliciesAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/index.ts b/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/index.ts deleted file mode 100644 index 3b20fe25840..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/index.ts +++ /dev/null @@ -1,19 +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 {OrgPolicyClient} from './org_policy_client'; diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_client.ts b/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_client.ts deleted file mode 100644 index 8a0e6a89edf..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_client.ts +++ /dev/null @@ -1,1385 +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, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2/org_policy_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './org_policy_client_config.json'; -const version = require('../../../package.json').version; - -/** - * An interface for managing organization policies. - * - * The Cloud Org Policy service provides a simple mechanism for organizations to - * restrict the allowed configurations across their entire Cloud Resource - * hierarchy. - * - * You can use a `policy` to configure restrictions in Cloud resources. For - * example, you can enforce a `policy` that restricts which Google - * Cloud Platform APIs can be activated in a certain part of your resource - * hierarchy, or prevents serial port access to VM instances in a particular - * folder. - * - * `Policies` are inherited down through the resource hierarchy. A `policy` - * applied to a parent resource automatically applies to all its child resources - * unless overridden with a `policy` lower in the hierarchy. - * - * A `constraint` defines an aspect of a resource's configuration that can be - * controlled by an organization's policy administrator. `Policies` are a - * collection of `constraints` that defines their allowable configuration on a - * particular resource and its child resources. - * @class - * @memberof v2 - */ -export class OrgPolicyClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - orgPolicyStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of OrgPolicyClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 OrgPolicyClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof OrgPolicyClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - folderConstraintPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}/constraints/{constraint}' - ), - folderPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}/policies/{policy}' - ), - organizationConstraintPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/constraints/{constraint}' - ), - organizationPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/policies/{policy}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - projectConstraintPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/constraints/{constraint}' - ), - projectPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/policies/{policy}' - ), - }; - - // 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 = { - listConstraints: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'constraints'), - listPolicies: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'policies') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.orgpolicy.v2.OrgPolicy', 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.orgPolicyStub) { - return this.orgPolicyStub; - } - - // Put together the "service stub" for - // google.cloud.orgpolicy.v2.OrgPolicy. - this.orgPolicyStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.orgpolicy.v2.OrgPolicy') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.orgpolicy.v2.OrgPolicy, - 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 orgPolicyStubMethods = - ['listConstraints', 'listPolicies', 'getPolicy', 'getEffectivePolicy', 'createPolicy', 'updatePolicy', 'deletePolicy']; - for (const methodName of orgPolicyStubMethods) { - const callPromise = this.orgPolicyStub.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.orgPolicyStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'orgpolicy.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 'orgpolicy.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 `Policy` on a resource. - * - * If no `Policy` is set on the resource, NOT_FOUND is returned. The - * `etag` value can be used with `UpdatePolicy()` to update a - * `Policy` during read-modify-write. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the policy. See `Policy` for naming - * requirements. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.orgpolicy.v2.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/org_policy.get_policy.js - * region_tag:orgpolicy_v2_generated_OrgPolicy_GetPolicy_async - */ - getPolicy( - request?: protos.google.cloud.orgpolicy.v2.IGetPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.IGetPolicyRequest|undefined, {}|undefined - ]>; - getPolicy( - request: protos.google.cloud.orgpolicy.v2.IGetPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.IGetPolicyRequest|null|undefined, - {}|null|undefined>): void; - getPolicy( - request: protos.google.cloud.orgpolicy.v2.IGetPolicyRequest, - callback: Callback< - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.IGetPolicyRequest|null|undefined, - {}|null|undefined>): void; - getPolicy( - request?: protos.google.cloud.orgpolicy.v2.IGetPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.IGetPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.IGetPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.IGetPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getPolicy(request, options, callback); - } -/** - * Gets the effective `Policy` on a resource. This is the result of merging - * `Policies` in the resource hierarchy and evaluating conditions. The - * returned `Policy` will not have an `etag` or `condition` set because it is - * a computed `Policy` across multiple resources. - * Subtrees of Resource Manager resource hierarchy with 'under:' prefix will - * not be expanded. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The effective policy to compute. See `Policy` for naming rules. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.orgpolicy.v2.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/org_policy.get_effective_policy.js - * region_tag:orgpolicy_v2_generated_OrgPolicy_GetEffectivePolicy_async - */ - getEffectivePolicy( - request?: protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest|undefined, {}|undefined - ]>; - getEffectivePolicy( - request: protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest|null|undefined, - {}|null|undefined>): void; - getEffectivePolicy( - request: protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest, - callback: Callback< - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest|null|undefined, - {}|null|undefined>): void; - getEffectivePolicy( - request?: protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getEffectivePolicy(request, options, callback); - } -/** - * Creates a Policy. - * - * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the - * constraint does not exist. - * Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the - * policy already exists on the given Cloud resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The Cloud resource that will parent the new Policy. Must be in - * one of the following forms: - * * `projects/{project_number}` - * * `projects/{project_id}` - * * `folders/{folder_id}` - * * `organizations/{organization_id}` - * @param {google.cloud.orgpolicy.v2.Policy} request.policy - * Required. `Policy` to create. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.orgpolicy.v2.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/org_policy.create_policy.js - * region_tag:orgpolicy_v2_generated_OrgPolicy_CreatePolicy_async - */ - createPolicy( - request?: protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest|undefined, {}|undefined - ]>; - createPolicy( - request: protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest|null|undefined, - {}|null|undefined>): void; - createPolicy( - request: protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest, - callback: Callback< - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest|null|undefined, - {}|null|undefined>): void; - createPolicy( - request?: protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createPolicy(request, options, callback); - } -/** - * Updates a Policy. - * - * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the - * constraint or the policy do not exist. - * Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag - * supplied in the request does not match the persisted etag of the policy - * - * Note: the supplied policy will perform a full overwrite of all - * fields. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.orgpolicy.v2.Policy} request.policy - * Required. `Policy` to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Field mask used to specify the fields to be overwritten in the policy - * by the set. The fields specified in the update_mask are relative to the - * policy, not the full request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.orgpolicy.v2.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/org_policy.update_policy.js - * region_tag:orgpolicy_v2_generated_OrgPolicy_UpdatePolicy_async - */ - updatePolicy( - request?: protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest|undefined, {}|undefined - ]>; - updatePolicy( - request: protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest|null|undefined, - {}|null|undefined>): void; - updatePolicy( - request: protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest, - callback: Callback< - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest|null|undefined, - {}|null|undefined>): void; - updatePolicy( - request?: protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.orgpolicy.v2.IPolicy, - protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'policy.name': request.policy!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updatePolicy(request, options, callback); - } -/** - * Deletes a Policy. - * - * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the - * constraint or Org Policy does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the policy to delete. - * See `Policy` for naming rules. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/org_policy.delete_policy.js - * region_tag:orgpolicy_v2_generated_OrgPolicy_DeletePolicy_async - */ - deletePolicy( - request?: protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest|undefined, {}|undefined - ]>; - deletePolicy( - request: protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest|null|undefined, - {}|null|undefined>): void; - deletePolicy( - request: protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest|null|undefined, - {}|null|undefined>): void; - deletePolicy( - request?: protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deletePolicy(request, options, callback); - } - - /** - * Lists `Constraints` that could be applied on the specified resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The Cloud resource that parents the constraint. Must be in one of - * the following forms: - * * `projects/{project_number}` - * * `projects/{project_id}` - * * `folders/{folder_id}` - * * `organizations/{organization_id}` - * @param {number} request.pageSize - * Size of the pages to be returned. This is currently unsupported and will - * be ignored. The server may at any point start using this field to limit - * page size. - * @param {string} request.pageToken - * Page token used to retrieve the next page. This is currently unsupported - * and will be ignored. The server may at any point start using this field. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.orgpolicy.v2.Constraint|Constraint}. - * 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 `listConstraintsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listConstraints( - request?: protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.orgpolicy.v2.IConstraint[], - protos.google.cloud.orgpolicy.v2.IListConstraintsRequest|null, - protos.google.cloud.orgpolicy.v2.IListConstraintsResponse - ]>; - listConstraints( - request: protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, - protos.google.cloud.orgpolicy.v2.IListConstraintsResponse|null|undefined, - protos.google.cloud.orgpolicy.v2.IConstraint>): void; - listConstraints( - request: protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, - callback: PaginationCallback< - protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, - protos.google.cloud.orgpolicy.v2.IListConstraintsResponse|null|undefined, - protos.google.cloud.orgpolicy.v2.IConstraint>): void; - listConstraints( - request?: protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, - protos.google.cloud.orgpolicy.v2.IListConstraintsResponse|null|undefined, - protos.google.cloud.orgpolicy.v2.IConstraint>, - callback?: PaginationCallback< - protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, - protos.google.cloud.orgpolicy.v2.IListConstraintsResponse|null|undefined, - protos.google.cloud.orgpolicy.v2.IConstraint>): - Promise<[ - protos.google.cloud.orgpolicy.v2.IConstraint[], - protos.google.cloud.orgpolicy.v2.IListConstraintsRequest|null, - protos.google.cloud.orgpolicy.v2.IListConstraintsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listConstraints(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 Cloud resource that parents the constraint. Must be in one of - * the following forms: - * * `projects/{project_number}` - * * `projects/{project_id}` - * * `folders/{folder_id}` - * * `organizations/{organization_id}` - * @param {number} request.pageSize - * Size of the pages to be returned. This is currently unsupported and will - * be ignored. The server may at any point start using this field to limit - * page size. - * @param {string} request.pageToken - * Page token used to retrieve the next page. This is currently unsupported - * and will be ignored. The server may at any point start using this field. - * @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 protos.google.cloud.orgpolicy.v2.Constraint|Constraint} 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 `listConstraintsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listConstraintsStream( - request?: protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, - 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['listConstraints']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listConstraints.createStream( - this.innerApiCalls.listConstraints as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listConstraints`, 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 Cloud resource that parents the constraint. Must be in one of - * the following forms: - * * `projects/{project_number}` - * * `projects/{project_id}` - * * `folders/{folder_id}` - * * `organizations/{organization_id}` - * @param {number} request.pageSize - * Size of the pages to be returned. This is currently unsupported and will - * be ignored. The server may at any point start using this field to limit - * page size. - * @param {string} request.pageToken - * Page token used to retrieve the next page. This is currently unsupported - * and will be ignored. The server may at any point start using this field. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.orgpolicy.v2.Constraint|Constraint}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v2/org_policy.list_constraints.js - * region_tag:orgpolicy_v2_generated_OrgPolicy_ListConstraints_async - */ - listConstraintsAsync( - request?: protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, - 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['listConstraints']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listConstraints.asyncIterate( - this.innerApiCalls['listConstraints'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Retrieves all of the `Policies` that exist on a particular resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The target Cloud resource that parents the set of constraints and - * policies that will be returned from this call. Must be in one of the - * following forms: - * * `projects/{project_number}` - * * `projects/{project_id}` - * * `folders/{folder_id}` - * * `organizations/{organization_id}` - * @param {number} request.pageSize - * Size of the pages to be returned. This is currently unsupported and will - * be ignored. The server may at any point start using this field to limit - * page size. - * @param {string} request.pageToken - * Page token used to retrieve the next page. This is currently unsupported - * and will be ignored. The server may at any point start using this field. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.orgpolicy.v2.Policy|Policy}. - * 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 `listPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listPolicies( - request?: protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.orgpolicy.v2.IPolicy[], - protos.google.cloud.orgpolicy.v2.IListPoliciesRequest|null, - protos.google.cloud.orgpolicy.v2.IListPoliciesResponse - ]>; - listPolicies( - request: protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, - protos.google.cloud.orgpolicy.v2.IListPoliciesResponse|null|undefined, - protos.google.cloud.orgpolicy.v2.IPolicy>): void; - listPolicies( - request: protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, - callback: PaginationCallback< - protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, - protos.google.cloud.orgpolicy.v2.IListPoliciesResponse|null|undefined, - protos.google.cloud.orgpolicy.v2.IPolicy>): void; - listPolicies( - request?: protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, - protos.google.cloud.orgpolicy.v2.IListPoliciesResponse|null|undefined, - protos.google.cloud.orgpolicy.v2.IPolicy>, - callback?: PaginationCallback< - protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, - protos.google.cloud.orgpolicy.v2.IListPoliciesResponse|null|undefined, - protos.google.cloud.orgpolicy.v2.IPolicy>): - Promise<[ - protos.google.cloud.orgpolicy.v2.IPolicy[], - protos.google.cloud.orgpolicy.v2.IListPoliciesRequest|null, - protos.google.cloud.orgpolicy.v2.IListPoliciesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listPolicies(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 target Cloud resource that parents the set of constraints and - * policies that will be returned from this call. Must be in one of the - * following forms: - * * `projects/{project_number}` - * * `projects/{project_id}` - * * `folders/{folder_id}` - * * `organizations/{organization_id}` - * @param {number} request.pageSize - * Size of the pages to be returned. This is currently unsupported and will - * be ignored. The server may at any point start using this field to limit - * page size. - * @param {string} request.pageToken - * Page token used to retrieve the next page. This is currently unsupported - * and will be ignored. The server may at any point start using this field. - * @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 protos.google.cloud.orgpolicy.v2.Policy|Policy} 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 `listPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listPoliciesStream( - request?: protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, - 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['listPolicies']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listPolicies.createStream( - this.innerApiCalls.listPolicies as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listPolicies`, 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 target Cloud resource that parents the set of constraints and - * policies that will be returned from this call. Must be in one of the - * following forms: - * * `projects/{project_number}` - * * `projects/{project_id}` - * * `folders/{folder_id}` - * * `organizations/{organization_id}` - * @param {number} request.pageSize - * Size of the pages to be returned. This is currently unsupported and will - * be ignored. The server may at any point start using this field to limit - * page size. - * @param {string} request.pageToken - * Page token used to retrieve the next page. This is currently unsupported - * and will be ignored. The server may at any point start using this field. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.orgpolicy.v2.Policy|Policy}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v2/org_policy.list_policies.js - * region_tag:orgpolicy_v2_generated_OrgPolicy_ListPolicies_async - */ - listPoliciesAsync( - request?: protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, - 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['listPolicies']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listPolicies.asyncIterate( - this.innerApiCalls['listPolicies'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified folderConstraint resource name string. - * - * @param {string} folder - * @param {string} constraint - * @returns {string} Resource name string. - */ - folderConstraintPath(folder:string,constraint:string) { - return this.pathTemplates.folderConstraintPathTemplate.render({ - folder: folder, - constraint: constraint, - }); - } - - /** - * Parse the folder from FolderConstraint resource. - * - * @param {string} folderConstraintName - * A fully-qualified path representing folder_constraint resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderConstraintName(folderConstraintName: string) { - return this.pathTemplates.folderConstraintPathTemplate.match(folderConstraintName).folder; - } - - /** - * Parse the constraint from FolderConstraint resource. - * - * @param {string} folderConstraintName - * A fully-qualified path representing folder_constraint resource. - * @returns {string} A string representing the constraint. - */ - matchConstraintFromFolderConstraintName(folderConstraintName: string) { - return this.pathTemplates.folderConstraintPathTemplate.match(folderConstraintName).constraint; - } - - /** - * Return a fully-qualified folderPolicy resource name string. - * - * @param {string} folder - * @param {string} policy - * @returns {string} Resource name string. - */ - folderPolicyPath(folder:string,policy:string) { - return this.pathTemplates.folderPolicyPathTemplate.render({ - folder: folder, - policy: policy, - }); - } - - /** - * Parse the folder from FolderPolicy resource. - * - * @param {string} folderPolicyName - * A fully-qualified path representing folder_policy resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderPolicyName(folderPolicyName: string) { - return this.pathTemplates.folderPolicyPathTemplate.match(folderPolicyName).folder; - } - - /** - * Parse the policy from FolderPolicy resource. - * - * @param {string} folderPolicyName - * A fully-qualified path representing folder_policy resource. - * @returns {string} A string representing the policy. - */ - matchPolicyFromFolderPolicyName(folderPolicyName: string) { - return this.pathTemplates.folderPolicyPathTemplate.match(folderPolicyName).policy; - } - - /** - * Return a fully-qualified organizationConstraint resource name string. - * - * @param {string} organization - * @param {string} constraint - * @returns {string} Resource name string. - */ - organizationConstraintPath(organization:string,constraint:string) { - return this.pathTemplates.organizationConstraintPathTemplate.render({ - organization: organization, - constraint: constraint, - }); - } - - /** - * Parse the organization from OrganizationConstraint resource. - * - * @param {string} organizationConstraintName - * A fully-qualified path representing organization_constraint resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationConstraintName(organizationConstraintName: string) { - return this.pathTemplates.organizationConstraintPathTemplate.match(organizationConstraintName).organization; - } - - /** - * Parse the constraint from OrganizationConstraint resource. - * - * @param {string} organizationConstraintName - * A fully-qualified path representing organization_constraint resource. - * @returns {string} A string representing the constraint. - */ - matchConstraintFromOrganizationConstraintName(organizationConstraintName: string) { - return this.pathTemplates.organizationConstraintPathTemplate.match(organizationConstraintName).constraint; - } - - /** - * Return a fully-qualified organizationPolicy resource name string. - * - * @param {string} organization - * @param {string} policy - * @returns {string} Resource name string. - */ - organizationPolicyPath(organization:string,policy:string) { - return this.pathTemplates.organizationPolicyPathTemplate.render({ - organization: organization, - policy: policy, - }); - } - - /** - * Parse the organization from OrganizationPolicy resource. - * - * @param {string} organizationPolicyName - * A fully-qualified path representing organization_policy resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationPolicyName(organizationPolicyName: string) { - return this.pathTemplates.organizationPolicyPathTemplate.match(organizationPolicyName).organization; - } - - /** - * Parse the policy from OrganizationPolicy resource. - * - * @param {string} organizationPolicyName - * A fully-qualified path representing organization_policy resource. - * @returns {string} A string representing the policy. - */ - matchPolicyFromOrganizationPolicyName(organizationPolicyName: string) { - return this.pathTemplates.organizationPolicyPathTemplate.match(organizationPolicyName).policy; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified projectConstraint resource name string. - * - * @param {string} project - * @param {string} constraint - * @returns {string} Resource name string. - */ - projectConstraintPath(project:string,constraint:string) { - return this.pathTemplates.projectConstraintPathTemplate.render({ - project: project, - constraint: constraint, - }); - } - - /** - * Parse the project from ProjectConstraint resource. - * - * @param {string} projectConstraintName - * A fully-qualified path representing project_constraint resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectConstraintName(projectConstraintName: string) { - return this.pathTemplates.projectConstraintPathTemplate.match(projectConstraintName).project; - } - - /** - * Parse the constraint from ProjectConstraint resource. - * - * @param {string} projectConstraintName - * A fully-qualified path representing project_constraint resource. - * @returns {string} A string representing the constraint. - */ - matchConstraintFromProjectConstraintName(projectConstraintName: string) { - return this.pathTemplates.projectConstraintPathTemplate.match(projectConstraintName).constraint; - } - - /** - * Return a fully-qualified projectPolicy resource name string. - * - * @param {string} project - * @param {string} policy - * @returns {string} Resource name string. - */ - projectPolicyPath(project:string,policy:string) { - return this.pathTemplates.projectPolicyPathTemplate.render({ - project: project, - policy: policy, - }); - } - - /** - * Parse the project from ProjectPolicy resource. - * - * @param {string} projectPolicyName - * A fully-qualified path representing project_policy resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectPolicyName(projectPolicyName: string) { - return this.pathTemplates.projectPolicyPathTemplate.match(projectPolicyName).project; - } - - /** - * Parse the policy from ProjectPolicy resource. - * - * @param {string} projectPolicyName - * A fully-qualified path representing project_policy resource. - * @returns {string} A string representing the policy. - */ - matchPolicyFromProjectPolicyName(projectPolicyName: string) { - return this.pathTemplates.projectPolicyPathTemplate.match(projectPolicyName).policy; - } - - /** - * 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.orgPolicyStub && !this._terminated) { - return this.orgPolicyStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_client_config.json b/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_client_config.json deleted file mode 100644 index 330aa9baa83..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_client_config.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "interfaces": { - "google.cloud.orgpolicy.v2.OrgPolicy": { - "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 - }, - "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListConstraints": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "ListPolicies": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "GetPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "GetEffectivePolicy": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "CreatePolicy": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "UpdatePolicy": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "DeletePolicy": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_proto_list.json b/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_proto_list.json deleted file mode 100644 index ad104eccb77..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/src/v2/org_policy_proto_list.json +++ /dev/null @@ -1,4 +0,0 @@ -[ - "../../protos/google/cloud/orgpolicy/v2/constraint.proto", - "../../protos/google/cloud/orgpolicy/v2/orgpolicy.proto" -] diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-orgpolicy/v2/system-test/fixtures/sample/src/index.js deleted file mode 100644 index b2765310f0a..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const orgpolicy = require('@google-cloud/org-policy'); - -function main() { - const orgPolicyClient = new orgpolicy.OrgPolicyClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-orgpolicy/v2/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index ee617ef74fa..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {OrgPolicyClient} from '@google-cloud/org-policy'; - -// check that the client class type name can be used -function doStuffWithOrgPolicyClient(client: OrgPolicyClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const orgPolicyClient = new OrgPolicyClient(); - doStuffWithOrgPolicyClient(orgPolicyClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/system-test/install.ts b/owl-bot-staging/google-cloud-orgpolicy/v2/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/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-orgpolicy/v2/test/gapic_org_policy_v2.ts b/owl-bot-staging/google-cloud-orgpolicy/v2/test/gapic_org_policy_v2.ts deleted file mode 100644 index 7e90a59df46..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/v2/test/gapic_org_policy_v2.ts +++ /dev/null @@ -1,1492 +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 orgpolicyModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -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.OrgPolicyClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = orgpolicyModule.v2.OrgPolicyClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = orgpolicyModule.v2.OrgPolicyClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = orgpolicyModule.v2.OrgPolicyClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new orgpolicyModule.v2.OrgPolicyClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.orgPolicyStub, undefined); - await client.initialize(); - assert(client.orgPolicyStub); - }); - - it('has close method for the initialized client', done => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.orgPolicyStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.orgPolicyStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new orgpolicyModule.v2.OrgPolicyClient({ - 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 orgpolicyModule.v2.OrgPolicyClient({ - 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('getPolicy', () => { - it('invokes getPolicy without error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.GetPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.GetPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.Policy() - ); - client.innerApiCalls.getPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPolicy without error using callback', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.GetPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.GetPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.Policy() - ); - client.innerApiCalls.getPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.orgpolicy.v2.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPolicy with error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.GetPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.GetPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPolicy with closed client', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.GetPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.GetPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getPolicy(request), expectedError); - }); - }); - - describe('getEffectivePolicy', () => { - it('invokes getEffectivePolicy without error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.Policy() - ); - client.innerApiCalls.getEffectivePolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getEffectivePolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEffectivePolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEffectivePolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEffectivePolicy without error using callback', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.Policy() - ); - client.innerApiCalls.getEffectivePolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getEffectivePolicy( - request, - (err?: Error|null, result?: protos.google.cloud.orgpolicy.v2.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEffectivePolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEffectivePolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEffectivePolicy with error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getEffectivePolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getEffectivePolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getEffectivePolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEffectivePolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEffectivePolicy with closed client', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getEffectivePolicy(request), expectedError); - }); - }); - - describe('createPolicy', () => { - it('invokes createPolicy without error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.CreatePolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.CreatePolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.Policy() - ); - client.innerApiCalls.createPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.createPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createPolicy without error using callback', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.CreatePolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.CreatePolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.Policy() - ); - client.innerApiCalls.createPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.orgpolicy.v2.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createPolicy with error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.CreatePolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.CreatePolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.createPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createPolicy with closed client', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.CreatePolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.CreatePolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createPolicy(request), expectedError); - }); - }); - - describe('updatePolicy', () => { - it('invokes updatePolicy without error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.UpdatePolicyRequest() - ); - request.policy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.UpdatePolicyRequest', ['policy', 'name']); - request.policy.name = defaultValue1; - const expectedHeaderRequestParams = `policy.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.Policy() - ); - client.innerApiCalls.updatePolicy = stubSimpleCall(expectedResponse); - const [response] = await client.updatePolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updatePolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updatePolicy without error using callback', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.UpdatePolicyRequest() - ); - request.policy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.UpdatePolicyRequest', ['policy', 'name']); - request.policy.name = defaultValue1; - const expectedHeaderRequestParams = `policy.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.Policy() - ); - client.innerApiCalls.updatePolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updatePolicy( - request, - (err?: Error|null, result?: protos.google.cloud.orgpolicy.v2.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updatePolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updatePolicy with error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.UpdatePolicyRequest() - ); - request.policy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.UpdatePolicyRequest', ['policy', 'name']); - request.policy.name = defaultValue1; - const expectedHeaderRequestParams = `policy.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updatePolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updatePolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.updatePolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updatePolicy with closed client', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.UpdatePolicyRequest() - ); - request.policy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.UpdatePolicyRequest', ['policy', 'name']); - request.policy.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updatePolicy(request), expectedError); - }); - }); - - describe('deletePolicy', () => { - it('invokes deletePolicy without error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.DeletePolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.DeletePolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePolicy = stubSimpleCall(expectedResponse); - const [response] = await client.deletePolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deletePolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePolicy without error using callback', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.DeletePolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.DeletePolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deletePolicy( - 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.deletePolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePolicy with error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.DeletePolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.DeletePolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deletePolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deletePolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.deletePolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePolicy with closed client', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.DeletePolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.DeletePolicyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deletePolicy(request), expectedError); - }); - }); - - describe('listConstraints', () => { - it('invokes listConstraints without error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.ListConstraintsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListConstraintsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), - ]; - client.innerApiCalls.listConstraints = stubSimpleCall(expectedResponse); - const [response] = await client.listConstraints(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listConstraints as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listConstraints as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listConstraints without error using callback', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.ListConstraintsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListConstraintsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), - ]; - client.innerApiCalls.listConstraints = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listConstraints( - request, - (err?: Error|null, result?: protos.google.cloud.orgpolicy.v2.IConstraint[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listConstraints as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listConstraints as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listConstraints with error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.ListConstraintsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListConstraintsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listConstraints = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listConstraints(request), expectedError); - const actualRequest = (client.innerApiCalls.listConstraints as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listConstraints as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listConstraintsStream without error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.ListConstraintsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListConstraintsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), - ]; - client.descriptors.page.listConstraints.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listConstraintsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.orgpolicy.v2.Constraint[] = []; - stream.on('data', (response: protos.google.cloud.orgpolicy.v2.Constraint) => { - 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.listConstraints.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listConstraints, request)); - assert( - (client.descriptors.page.listConstraints.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listConstraintsStream with error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.ListConstraintsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListConstraintsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listConstraints.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listConstraintsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.orgpolicy.v2.Constraint[] = []; - stream.on('data', (response: protos.google.cloud.orgpolicy.v2.Constraint) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listConstraints.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listConstraints, request)); - assert( - (client.descriptors.page.listConstraints.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listConstraints without error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.ListConstraintsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListConstraintsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Constraint()), - ]; - client.descriptors.page.listConstraints.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.orgpolicy.v2.IConstraint[] = []; - const iterable = client.listConstraintsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listConstraints.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listConstraints.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listConstraints with error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.ListConstraintsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListConstraintsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listConstraints.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listConstraintsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.orgpolicy.v2.IConstraint[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listConstraints.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listConstraints.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listPolicies', () => { - it('invokes listPolicies without error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.ListPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), - ]; - client.innerApiCalls.listPolicies = stubSimpleCall(expectedResponse); - const [response] = await client.listPolicies(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPolicies without error using callback', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.ListPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), - ]; - client.innerApiCalls.listPolicies = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listPolicies( - request, - (err?: Error|null, result?: protos.google.cloud.orgpolicy.v2.IPolicy[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPolicies with error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.ListPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listPolicies = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listPolicies(request), expectedError); - const actualRequest = (client.innerApiCalls.listPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPoliciesStream without error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.ListPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), - ]; - client.descriptors.page.listPolicies.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.orgpolicy.v2.Policy[] = []; - stream.on('data', (response: protos.google.cloud.orgpolicy.v2.Policy) => { - 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.listPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPolicies, request)); - assert( - (client.descriptors.page.listPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listPoliciesStream with error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.ListPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listPolicies.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.orgpolicy.v2.Policy[] = []; - stream.on('data', (response: protos.google.cloud.orgpolicy.v2.Policy) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPolicies, request)); - assert( - (client.descriptors.page.listPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPolicies without error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.ListPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), - generateSampleMessage(new protos.google.cloud.orgpolicy.v2.Policy()), - ]; - client.descriptors.page.listPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.orgpolicy.v2.IPolicy[] = []; - const iterable = client.listPoliciesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPolicies with error', async () => { - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.orgpolicy.v2.ListPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.orgpolicy.v2.ListPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listPoliciesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.orgpolicy.v2.IPolicy[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('folderConstraint', () => { - const fakePath = "/rendered/path/folderConstraint"; - const expectedParameters = { - folder: "folderValue", - constraint: "constraintValue", - }; - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderConstraintPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderConstraintPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderConstraintPath', () => { - const result = client.folderConstraintPath("folderValue", "constraintValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderConstraintPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderConstraintName', () => { - const result = client.matchFolderFromFolderConstraintName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderConstraintPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchConstraintFromFolderConstraintName', () => { - const result = client.matchConstraintFromFolderConstraintName(fakePath); - assert.strictEqual(result, "constraintValue"); - assert((client.pathTemplates.folderConstraintPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('folderPolicy', () => { - const fakePath = "/rendered/path/folderPolicy"; - const expectedParameters = { - folder: "folderValue", - policy: "policyValue", - }; - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderPolicyPath', () => { - const result = client.folderPolicyPath("folderValue", "policyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderPolicyName', () => { - const result = client.matchFolderFromFolderPolicyName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPolicyFromFolderPolicyName', () => { - const result = client.matchPolicyFromFolderPolicyName(fakePath); - assert.strictEqual(result, "policyValue"); - assert((client.pathTemplates.folderPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organizationConstraint', () => { - const fakePath = "/rendered/path/organizationConstraint"; - const expectedParameters = { - organization: "organizationValue", - constraint: "constraintValue", - }; - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationConstraintPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationConstraintPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationConstraintPath', () => { - const result = client.organizationConstraintPath("organizationValue", "constraintValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationConstraintPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationConstraintName', () => { - const result = client.matchOrganizationFromOrganizationConstraintName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationConstraintPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchConstraintFromOrganizationConstraintName', () => { - const result = client.matchConstraintFromOrganizationConstraintName(fakePath); - assert.strictEqual(result, "constraintValue"); - assert((client.pathTemplates.organizationConstraintPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organizationPolicy', () => { - const fakePath = "/rendered/path/organizationPolicy"; - const expectedParameters = { - organization: "organizationValue", - policy: "policyValue", - }; - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationPolicyPath', () => { - const result = client.organizationPolicyPath("organizationValue", "policyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationPolicyName', () => { - const result = client.matchOrganizationFromOrganizationPolicyName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPolicyFromOrganizationPolicyName', () => { - const result = client.matchPolicyFromOrganizationPolicyName(fakePath); - assert.strictEqual(result, "policyValue"); - assert((client.pathTemplates.organizationPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectConstraint', () => { - const fakePath = "/rendered/path/projectConstraint"; - const expectedParameters = { - project: "projectValue", - constraint: "constraintValue", - }; - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectConstraintPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectConstraintPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectConstraintPath', () => { - const result = client.projectConstraintPath("projectValue", "constraintValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectConstraintPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectConstraintName', () => { - const result = client.matchProjectFromProjectConstraintName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectConstraintPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchConstraintFromProjectConstraintName', () => { - const result = client.matchConstraintFromProjectConstraintName(fakePath); - assert.strictEqual(result, "constraintValue"); - assert((client.pathTemplates.projectConstraintPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectPolicy', () => { - const fakePath = "/rendered/path/projectPolicy"; - const expectedParameters = { - project: "projectValue", - policy: "policyValue", - }; - const client = new orgpolicyModule.v2.OrgPolicyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPolicyPath', () => { - const result = client.projectPolicyPath("projectValue", "policyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectPolicyName', () => { - const result = client.matchProjectFromProjectPolicyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPolicyFromProjectPolicyName', () => { - const result = client.matchPolicyFromProjectPolicyName(fakePath); - assert.strictEqual(result, "policyValue"); - assert((client.pathTemplates.projectPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-orgpolicy/v2/tsconfig.json b/owl-bot-staging/google-cloud-orgpolicy/v2/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/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-orgpolicy/v2/webpack.config.js b/owl-bot-staging/google-cloud-orgpolicy/v2/webpack.config.js deleted file mode 100644 index 52ea261a3a1..00000000000 --- a/owl-bot-staging/google-cloud-orgpolicy/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: 'OrgPolicy', - filename: './org-policy.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-osconfig/v1/.eslintignore b/owl-bot-staging/google-cloud-osconfig/v1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-osconfig/v1/.eslintrc.json b/owl-bot-staging/google-cloud-osconfig/v1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/.gitignore b/owl-bot-staging/google-cloud-osconfig/v1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-osconfig/v1/.jsdoc.js b/owl-bot-staging/google-cloud-osconfig/v1/.jsdoc.js deleted file mode 100644 index 8b2a0523a45..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/.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/os-config', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-osconfig/v1/.mocharc.js b/owl-bot-staging/google-cloud-osconfig/v1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/.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-osconfig/v1/.prettierrc.js b/owl-bot-staging/google-cloud-osconfig/v1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/.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-osconfig/v1/README.md b/owl-bot-staging/google-cloud-osconfig/v1/README.md deleted file mode 100644 index 94de5ca4cff..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Osconfig: Nodejs Client diff --git a/owl-bot-staging/google-cloud-osconfig/v1/package.json b/owl-bot-staging/google-cloud-osconfig/v1/package.json deleted file mode 100644 index 0c81d6e675d..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/package.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "name": "@google-cloud/os-config", - "version": "0.1.0", - "description": "Osconfig client for Node.js", - "repository": "googleapis/nodejs-osconfig", - "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 osconfig", - "osconfig", - "os config service", - "os config zonal service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/inventory.proto b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/inventory.proto deleted file mode 100644 index 2807b85cb59..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/inventory.proto +++ /dev/null @@ -1,384 +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.osconfig.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; -import "google/type/date.proto"; - -option csharp_namespace = "Google.Cloud.OsConfig.V1"; -option go_package = "cloud.google.com/go/osconfig/apiv1/osconfigpb;osconfigpb"; -option java_multiple_files = true; -option java_outer_classname = "Inventories"; -option java_package = "com.google.cloud.osconfig.v1"; -option php_namespace = "Google\\Cloud\\OsConfig\\V1"; -option ruby_package = "Google::Cloud::OsConfig::V1"; - -// OS Config Inventory is a service for collecting and reporting operating -// system and package information on VM instances. - -// This API resource represents the available inventory data for a -// Compute Engine virtual machine (VM) instance at a given point in time. -// -// You can use this API resource to determine the inventory data of your VM. -// -// For more information, see [Information provided by OS inventory -// management](https://cloud.google.com/compute/docs/instances/os-inventory-management#data-collected). -message Inventory { - option (google.api.resource) = { - type: "osconfig.googleapis.com/Inventory" - pattern: "projects/{project}/locations/{location}/instances/{instance}/inventory" - }; - - // Operating system information for the VM. - message OsInfo { - // The VM hostname. - string hostname = 9; - - // The operating system long name. - // For example 'Debian GNU/Linux 9' or 'Microsoft Window Server 2019 - // Datacenter'. - string long_name = 2; - - // The operating system short name. - // For example, 'windows' or 'debian'. - string short_name = 3; - - // The version of the operating system. - string version = 4; - - // The system architecture of the operating system. - string architecture = 5; - - // The kernel version of the operating system. - string kernel_version = 6; - - // The kernel release of the operating system. - string kernel_release = 7; - - // The current version of the OS Config agent running on the VM. - string osconfig_agent_version = 8; - } - - // A single piece of inventory on a VM. - message Item { - // The origin of a specific inventory item. - enum OriginType { - // Invalid. An origin type must be specified. - ORIGIN_TYPE_UNSPECIFIED = 0; - - // This inventory item was discovered as the result of the agent - // reporting inventory via the reporting API. - INVENTORY_REPORT = 1; - } - - // The different types of inventory that are tracked on a VM. - enum Type { - // Invalid. An type must be specified. - TYPE_UNSPECIFIED = 0; - - // This represents a package that is installed on the VM. - INSTALLED_PACKAGE = 1; - - // This represents an update that is available for a package. - AVAILABLE_PACKAGE = 2; - } - - // Identifier for this item, unique across items for this VM. - string id = 1; - - // The origin of this inventory item. - OriginType origin_type = 2; - - // When this inventory item was first detected. - google.protobuf.Timestamp create_time = 8; - - // When this inventory item was last modified. - google.protobuf.Timestamp update_time = 9; - - // The specific type of inventory, correlating to its specific details. - Type type = 5; - - // Specific details of this inventory item based on its type. - oneof details { - // Software package present on the VM instance. - SoftwarePackage installed_package = 6; - - // Software package available to be installed on the VM instance. - SoftwarePackage available_package = 7; - } - } - - // Software package information of the operating system. - message SoftwarePackage { - // Information about the different types of software packages. - oneof details { - // Yum package info. - // For details about the yum package manager, see - // https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/ch-yum. - VersionedPackage yum_package = 1; - - // Details of an APT package. - // For details about the apt package manager, see - // https://wiki.debian.org/Apt. - VersionedPackage apt_package = 2; - - // Details of a Zypper package. - // For details about the Zypper package manager, see - // https://en.opensuse.org/SDB:Zypper_manual. - VersionedPackage zypper_package = 3; - - // Details of a Googet package. - // For details about the googet package manager, see - // https://github.com/google/googet. - VersionedPackage googet_package = 4; - - // Details of a Zypper patch. - // For details about the Zypper package manager, see - // https://en.opensuse.org/SDB:Zypper_manual. - ZypperPatch zypper_patch = 5; - - // Details of a Windows Update package. - // See https://docs.microsoft.com/en-us/windows/win32/api/_wua/ for - // information about Windows Update. - WindowsUpdatePackage wua_package = 6; - - // Details of a Windows Quick Fix engineering package. - // See - // https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-quickfixengineering - // for info in Windows Quick Fix Engineering. - WindowsQuickFixEngineeringPackage qfe_package = 7; - - // Details of a COS package. - VersionedPackage cos_package = 8; - - // Details of Windows Application. - WindowsApplication windows_application = 9; - } - } - - // Information related to the a standard versioned package. This includes - // package info for APT, Yum, Zypper, and Googet package managers. - message VersionedPackage { - // The name of the package. - string package_name = 4; - - // The system architecture this package is intended for. - string architecture = 2; - - // The version of the package. - string version = 3; - } - - // Details related to a Zypper Patch. - message ZypperPatch { - // The name of the patch. - string patch_name = 5; - - // The category of the patch. - string category = 2; - - // The severity specified for this patch - string severity = 3; - - // Any summary information provided about this patch. - string summary = 4; - } - - // Details related to a Windows Update package. - // Field data and names are taken from Windows Update API IUpdate Interface: - // https://docs.microsoft.com/en-us/windows/win32/api/_wua/ - // Descriptive fields like title, and description are localized based on - // the locale of the VM being updated. - message WindowsUpdatePackage { - // Categories specified by the Windows Update. - message WindowsUpdateCategory { - // The identifier of the windows update category. - string id = 1; - - // The name of the windows update category. - string name = 2; - } - - // The localized title of the update package. - string title = 1; - - // The localized description of the update package. - string description = 2; - - // The categories that are associated with this update package. - repeated WindowsUpdateCategory categories = 3; - - // A collection of Microsoft Knowledge Base article IDs that are associated - // with the update package. - repeated string kb_article_ids = 4; - - // A hyperlink to the language-specific support information for the update. - string support_url = 11; - - // A collection of URLs that provide more information about the update - // package. - repeated string more_info_urls = 5; - - // Gets the identifier of an update package. Stays the same across - // revisions. - string update_id = 6; - - // The revision number of this update package. - int32 revision_number = 7; - - // The last published date of the update, in (UTC) date and time. - google.protobuf.Timestamp last_deployment_change_time = 10; - } - - // Information related to a Quick Fix Engineering package. - // Fields are taken from Windows QuickFixEngineering Interface and match - // the source names: - // https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-quickfixengineering - message WindowsQuickFixEngineeringPackage { - // A short textual description of the QFE update. - string caption = 1; - - // A textual description of the QFE update. - string description = 2; - - // Unique identifier associated with a particular QFE update. - string hot_fix_id = 3; - - // Date that the QFE update was installed. Mapped from installed_on field. - google.protobuf.Timestamp install_time = 5; - } - - // Contains information about a Windows application that is retrieved from the - // Windows Registry. For more information about these fields, see: - // https://docs.microsoft.com/en-us/windows/win32/msi/uninstall-registry-key - message WindowsApplication { - // The name of the application or product. - string display_name = 1; - - // The version of the product or application in string format. - string display_version = 2; - - // The name of the manufacturer for the product or application. - string publisher = 3; - - // The last time this product received service. The value of this property - // is replaced each time a patch is applied or removed from the product or - // the command-line option is used to repair the product. - google.type.Date install_date = 4; - - // The internet address for technical support. - string help_link = 5; - } - - // Output only. The `Inventory` API resource name. - // - // Format: - // `projects/{project_number}/locations/{location}/instances/{instance_id}/inventory` - string name = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Base level operating system information for the VM. - OsInfo os_info = 1; - - // Inventory items related to the VM keyed by an opaque unique identifier for - // each inventory item. The identifier is unique to each distinct and - // addressable inventory item and will change, when there is a new package - // version. - map items = 2; - - // Output only. Timestamp of the last reported inventory for the VM. - google.protobuf.Timestamp update_time = 4 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A request message for getting inventory data for the specified VM. -message GetInventoryRequest { - // Required. API resource name for inventory resource. - // - // Format: - // `projects/{project}/locations/{location}/instances/{instance}/inventory` - // - // For `{project}`, either `project-number` or `project-id` can be provided. - // For `{instance}`, either Compute Engine `instance-id` or `instance-name` - // can be provided. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/Inventory" - } - ]; - - // Inventory view indicating what information should be included in the - // inventory resource. If unspecified, the default view is BASIC. - InventoryView view = 2; -} - -// A request message for listing inventory data for all VMs in the specified -// location. -message ListInventoriesRequest { - // Required. The parent resource name. - // - // Format: `projects/{project}/locations/{location}/instances/-` - // - // For `{project}`, either `project-number` or `project-id` can be provided. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "compute.googleapis.com/Instance" - } - ]; - - // Inventory view indicating what information should be included in the - // inventory resource. If unspecified, the default view is BASIC. - InventoryView view = 2; - - // The maximum number of results to return. - int32 page_size = 3; - - // A pagination token returned from a previous call to - // `ListInventories` that indicates where this listing - // should continue from. - string page_token = 4; - - // If provided, this field specifies the criteria that must be met by a - // `Inventory` API resource to be included in the response. - string filter = 5; -} - -// A response message for listing inventory data for all VMs in a specified -// location. -message ListInventoriesResponse { - // List of inventory objects. - repeated Inventory inventories = 1; - - // The pagination token to retrieve the next page of inventory objects. - string next_page_token = 2; -} - -// The view for inventory objects. -enum InventoryView { - // The default value. - // The API defaults to the BASIC view. - INVENTORY_VIEW_UNSPECIFIED = 0; - - // Returns the basic inventory information that includes `os_info`. - BASIC = 1; - - // Returns all fields. - FULL = 2; -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy.proto b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy.proto deleted file mode 100644 index f1911199686..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy.proto +++ /dev/null @@ -1,548 +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.osconfig.v1; - -import "google/api/field_behavior.proto"; - -option csharp_namespace = "Google.Cloud.OsConfig.V1"; -option go_package = "cloud.google.com/go/osconfig/apiv1/osconfigpb;osconfigpb"; -option java_multiple_files = true; -option java_outer_classname = "OsPolicyProto"; -option java_package = "com.google.cloud.osconfig.v1"; -option php_namespace = "Google\\Cloud\\OsConfig\\V1"; -option ruby_package = "Google::Cloud::OsConfig::V1"; - -// An OS policy defines the desired state configuration for a VM. -message OSPolicy { - // Policy mode - enum Mode { - // Invalid mode - MODE_UNSPECIFIED = 0; - - // This mode checks if the configuration resources in the policy are in - // their desired state. No actions are performed if they are not in the - // desired state. This mode is used for reporting purposes. - VALIDATION = 1; - - // This mode checks if the configuration resources in the policy are in - // their desired state, and if not, enforces the desired state. - ENFORCEMENT = 2; - } - - // Filtering criteria to select VMs based on inventory details. - message InventoryFilter { - // Required. The OS short name - string os_short_name = 1 [(google.api.field_behavior) = REQUIRED]; - - // The OS version - // - // Prefix matches are supported if asterisk(*) is provided as the - // last character. For example, to match all versions with a major - // version of `7`, specify the following value for this field `7.*` - // - // An empty string matches all OS versions. - string os_version = 2; - } - - // An OS policy resource is used to define the desired state configuration - // and provides a specific functionality like installing/removing packages, - // executing a script etc. - // - // The system ensures that resources are always in their desired state by - // taking necessary actions if they have drifted from their desired state. - message Resource { - // A remote or local file. - message File { - // Specifies a file available via some URI. - message Remote { - // Required. URI from which to fetch the object. It should contain both - // the protocol and path following the format `{protocol}://{location}`. - string uri = 1 [(google.api.field_behavior) = REQUIRED]; - - // SHA256 checksum of the remote file. - string sha256_checksum = 2; - } - - // Specifies a file available as a Cloud Storage Object. - message Gcs { - // Required. Bucket of the Cloud Storage object. - string bucket = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Name of the Cloud Storage object. - string object = 2 [(google.api.field_behavior) = REQUIRED]; - - // Generation number of the Cloud Storage object. - int64 generation = 3; - } - - // A specific type of file. - oneof type { - // A generic remote file. - Remote remote = 1; - - // A Cloud Storage object. - Gcs gcs = 2; - - // A local path within the VM to use. - string local_path = 3; - } - - // Defaults to false. When false, files are subject to validations - // based on the file type: - // - // Remote: A checksum must be specified. - // Cloud Storage: An object generation number must be specified. - bool allow_insecure = 4; - } - - // A resource that manages a system package. - message PackageResource { - // The desired state that the OS Config agent maintains on the VM. - enum DesiredState { - // Unspecified is invalid. - DESIRED_STATE_UNSPECIFIED = 0; - - // Ensure that the package is installed. - INSTALLED = 1; - - // The agent ensures that the package is not installed and - // uninstalls it if detected. - REMOVED = 2; - } - - // A deb package file. dpkg packages only support INSTALLED state. - message Deb { - // Required. A deb package. - File source = 1 [(google.api.field_behavior) = REQUIRED]; - - // Whether dependencies should also be installed. - // - install when false: `dpkg -i package` - // - install when true: `apt-get update && apt-get -y install - // package.deb` - bool pull_deps = 2; - } - - // A package managed by APT. - // - install: `apt-get update && apt-get -y install [name]` - // - remove: `apt-get -y remove [name]` - message APT { - // Required. Package name. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - } - - // An RPM package file. RPM packages only support INSTALLED state. - message RPM { - // Required. An rpm package. - File source = 1 [(google.api.field_behavior) = REQUIRED]; - - // Whether dependencies should also be installed. - // - install when false: `rpm --upgrade --replacepkgs package.rpm` - // - install when true: `yum -y install package.rpm` or - // `zypper -y install package.rpm` - bool pull_deps = 2; - } - - // A package managed by YUM. - // - install: `yum -y install package` - // - remove: `yum -y remove package` - message YUM { - // Required. Package name. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - } - - // A package managed by Zypper. - // - install: `zypper -y install package` - // - remove: `zypper -y rm package` - message Zypper { - // Required. Package name. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - } - - // A package managed by GooGet. - // - install: `googet -noconfirm install package` - // - remove: `googet -noconfirm remove package` - message GooGet { - // Required. Package name. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - } - - // An MSI package. MSI packages only support INSTALLED state. - message MSI { - // Required. The MSI package. - File source = 1 [(google.api.field_behavior) = REQUIRED]; - - // Additional properties to use during installation. - // This should be in the format of Property=Setting. - // Appended to the defaults of `ACTION=INSTALL - // REBOOT=ReallySuppress`. - repeated string properties = 2; - } - - // Required. The desired state the agent should maintain for this package. - DesiredState desired_state = 1 [(google.api.field_behavior) = REQUIRED]; - - // A system package. - oneof system_package { - // A package managed by Apt. - APT apt = 2; - - // A deb package file. - Deb deb = 3; - - // A package managed by YUM. - YUM yum = 4; - - // A package managed by Zypper. - Zypper zypper = 5; - - // An rpm package file. - RPM rpm = 6; - - // A package managed by GooGet. - GooGet googet = 7; - - // An MSI package. - MSI msi = 8; - } - } - - // A resource that manages a package repository. - message RepositoryResource { - // Represents a single apt package repository. These will be added to - // a repo file that will be managed at - // `/etc/apt/sources.list.d/google_osconfig.list`. - message AptRepository { - // Type of archive. - enum ArchiveType { - // Unspecified is invalid. - ARCHIVE_TYPE_UNSPECIFIED = 0; - - // Deb indicates that the archive contains binary files. - DEB = 1; - - // Deb-src indicates that the archive contains source files. - DEB_SRC = 2; - } - - // Required. Type of archive files in this repository. - ArchiveType archive_type = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. URI for this repository. - string uri = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. Distribution of this repository. - string distribution = 3 [(google.api.field_behavior) = REQUIRED]; - - // Required. List of components for this repository. Must contain at - // least one item. - repeated string components = 4 [(google.api.field_behavior) = REQUIRED]; - - // URI of the key file for this repository. The agent maintains a - // keyring at `/etc/apt/trusted.gpg.d/osconfig_agent_managed.gpg`. - string gpg_key = 5; - } - - // Represents a single yum package repository. These are added to a - // repo file that is managed at - // `/etc/yum.repos.d/google_osconfig.repo`. - message YumRepository { - // Required. A one word, unique name for this repository. This is the - // `repo id` in the yum config file and also the `display_name` if - // `display_name` is omitted. This id is also used as the unique - // identifier when checking for resource conflicts. - string id = 1 [(google.api.field_behavior) = REQUIRED]; - - // The display name of the repository. - string display_name = 2; - - // Required. The location of the repository directory. - string base_url = 3 [(google.api.field_behavior) = REQUIRED]; - - // URIs of GPG keys. - repeated string gpg_keys = 4; - } - - // Represents a single zypper package repository. These are added to a - // repo file that is managed at - // `/etc/zypp/repos.d/google_osconfig.repo`. - message ZypperRepository { - // Required. A one word, unique name for this repository. This is the - // `repo id` in the zypper config file and also the `display_name` if - // `display_name` is omitted. This id is also used as the unique - // identifier when checking for GuestPolicy conflicts. - string id = 1 [(google.api.field_behavior) = REQUIRED]; - - // The display name of the repository. - string display_name = 2; - - // Required. The location of the repository directory. - string base_url = 3 [(google.api.field_behavior) = REQUIRED]; - - // URIs of GPG keys. - repeated string gpg_keys = 4; - } - - // Represents a Goo package repository. These are added to a repo file - // that is managed at - // `C:/ProgramData/GooGet/repos/google_osconfig.repo`. - message GooRepository { - // Required. The name of the repository. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The url of the repository. - string url = 2 [(google.api.field_behavior) = REQUIRED]; - } - - // A specific type of repository. - oneof repository { - // An Apt Repository. - AptRepository apt = 1; - - // A Yum Repository. - YumRepository yum = 2; - - // A Zypper Repository. - ZypperRepository zypper = 3; - - // A Goo Repository. - GooRepository goo = 4; - } - } - - // A resource that allows executing scripts on the VM. - // - // The `ExecResource` has 2 stages: `validate` and `enforce` and both stages - // accept a script as an argument to execute. - // - // When the `ExecResource` is applied by the agent, it first executes the - // script in the `validate` stage. The `validate` stage can signal that the - // `ExecResource` is already in the desired state by returning an exit code - // of `100`. If the `ExecResource` is not in the desired state, it should - // return an exit code of `101`. Any other exit code returned by this stage - // is considered an error. - // - // If the `ExecResource` is not in the desired state based on the exit code - // from the `validate` stage, the agent proceeds to execute the script from - // the `enforce` stage. If the `ExecResource` is already in the desired - // state, the `enforce` stage will not be run. - // Similar to `validate` stage, the `enforce` stage should return an exit - // code of `100` to indicate that the resource in now in its desired state. - // Any other exit code is considered an error. - // - // NOTE: An exit code of `100` was chosen over `0` (and `101` vs `1`) to - // have an explicit indicator of `in desired state`, `not in desired state` - // and errors. Because, for example, Powershell will always return an exit - // code of `0` unless an `exit` statement is provided in the script. So, for - // reasons of consistency and being explicit, exit codes `100` and `101` - // were chosen. - message ExecResource { - // A file or script to execute. - message Exec { - // The interpreter to use. - enum Interpreter { - // Invalid value, the request will return validation error. - INTERPRETER_UNSPECIFIED = 0; - - // If an interpreter is not specified, the - // source is executed directly. This execution, without an - // interpreter, only succeeds for executables and scripts that have shebang lines. - NONE = 1; - - // Indicates that the script runs with `/bin/sh` on Linux and - // `cmd.exe` on Windows. - SHELL = 2; - - // Indicates that the script runs with PowerShell. - POWERSHELL = 3; - } - - // What to execute. - oneof source { - // A remote or local file. - File file = 1; - - // An inline script. - // The size of the script is limited to 1024 characters. - string script = 2; - } - - // Optional arguments to pass to the source during execution. - repeated string args = 3; - - // Required. The script interpreter to use. - Interpreter interpreter = 4 [(google.api.field_behavior) = REQUIRED]; - - // Only recorded for enforce Exec. - // Path to an output file (that is created by this Exec) whose - // content will be recorded in OSPolicyResourceCompliance after a - // successful run. Absence or failure to read this file will result in - // this ExecResource being non-compliant. Output file size is limited to - // 100K bytes. - string output_file_path = 5; - } - - // Required. What to run to validate this resource is in the desired - // state. An exit code of 100 indicates "in desired state", and exit code - // of 101 indicates "not in desired state". Any other exit code indicates - // a failure running validate. - Exec validate = 1 [(google.api.field_behavior) = REQUIRED]; - - // What to run to bring this resource into the desired state. - // An exit code of 100 indicates "success", any other exit code indicates - // a failure running enforce. - Exec enforce = 2; - } - - // A resource that manages the state of a file. - message FileResource { - // Desired state of the file. - enum DesiredState { - // Unspecified is invalid. - DESIRED_STATE_UNSPECIFIED = 0; - - // Ensure file at path is present. - PRESENT = 1; - - // Ensure file at path is absent. - ABSENT = 2; - - // Ensure the contents of the file at path matches. If the file does - // not exist it will be created. - CONTENTS_MATCH = 3; - } - - // The source for the contents of the file. - oneof source { - // A remote or local source. - File file = 1; - - // A a file with this content. - // The size of the content is limited to 1024 characters. - string content = 2; - } - - // Required. The absolute path of the file within the VM. - string path = 3 [(google.api.field_behavior) = REQUIRED]; - - // Required. Desired state of the file. - DesiredState state = 4 [(google.api.field_behavior) = REQUIRED]; - - // Consists of three octal digits which represent, in - // order, the permissions of the owner, group, and other users for the - // file (similarly to the numeric mode used in the linux chmod - // utility). Each digit represents a three bit number with the 4 bit - // corresponding to the read permissions, the 2 bit corresponds to the - // write bit, and the one bit corresponds to the execute permission. - // Default behavior is 755. - // - // Below are some examples of permissions and their associated values: - // read, write, and execute: 7 - // read and execute: 5 - // read and write: 6 - // read only: 4 - string permissions = 5; - } - - // Required. The id of the resource with the following restrictions: - // - // * Must contain only lowercase letters, numbers, and hyphens. - // * Must start with a letter. - // * Must be between 1-63 characters. - // * Must end with a number or a letter. - // * Must be unique within the OS policy. - string id = 1 [(google.api.field_behavior) = REQUIRED]; - - // Resource type. - oneof resource_type { - // Package resource - PackageResource pkg = 2; - - // Package repository resource - RepositoryResource repository = 3; - - // Exec resource - ExecResource exec = 4; - - // File resource - FileResource file = 5; - } - } - - // Resource groups provide a mechanism to group OS policy resources. - // - // Resource groups enable OS policy authors to create a single OS policy - // to be applied to VMs running different operating Systems. - // - // When the OS policy is applied to a target VM, the appropriate resource - // group within the OS policy is selected based on the `OSFilter` specified - // within the resource group. - message ResourceGroup { - // List of inventory filters for the resource group. - // - // The resources in this resource group are applied to the target VM if it - // satisfies at least one of the following inventory filters. - // - // For example, to apply this resource group to VMs running either `RHEL` or - // `CentOS` operating systems, specify 2 items for the list with following - // values: - // inventory_filters[0].os_short_name='rhel' and - // inventory_filters[1].os_short_name='centos' - // - // If the list is empty, this resource group will be applied to the target - // VM unconditionally. - repeated InventoryFilter inventory_filters = 1; - - // Required. List of resources configured for this resource group. - // The resources are executed in the exact order specified here. - repeated Resource resources = 2 [(google.api.field_behavior) = REQUIRED]; - } - - // Required. The id of the OS policy with the following restrictions: - // - // * Must contain only lowercase letters, numbers, and hyphens. - // * Must start with a letter. - // * Must be between 1-63 characters. - // * Must end with a number or a letter. - // * Must be unique within the assignment. - string id = 1 [(google.api.field_behavior) = REQUIRED]; - - // Policy description. - // Length of the description is limited to 1024 characters. - string description = 2; - - // Required. Policy mode - Mode mode = 3 [(google.api.field_behavior) = REQUIRED]; - - // Required. List of resource groups for the policy. - // For a particular VM, resource groups are evaluated in the order specified - // and the first resource group that is applicable is selected and the rest - // are ignored. - // - // If none of the resource groups are applicable for a VM, the VM is - // considered to be non-compliant w.r.t this policy. This behavior can be - // toggled by the flag `allow_no_resource_group_match` - repeated ResourceGroup resource_groups = 4 - [(google.api.field_behavior) = REQUIRED]; - - // This flag determines the OS policy compliance status when none of the - // resource groups within the policy are applicable for a VM. Set this value - // to `true` if the policy needs to be reported as compliant even if the - // policy has nothing to validate or enforce. - bool allow_no_resource_group_match = 5; -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy_assignment_reports.proto b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy_assignment_reports.proto deleted file mode 100644 index c7f102b2d67..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy_assignment_reports.proto +++ /dev/null @@ -1,296 +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.osconfig.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.OsConfig.V1"; -option go_package = "cloud.google.com/go/osconfig/apiv1/osconfigpb;osconfigpb"; -option java_multiple_files = true; -option java_outer_classname = "OSPolicyAssignmentReportsProto"; -option java_package = "com.google.cloud.osconfig.v1"; -option php_namespace = "Google\\Cloud\\OsConfig\\V1"; -option ruby_package = "Google::Cloud::OsConfig::V1"; -option (google.api.resource_definition) = { - type: "osconfig.googleapis.com/InstanceOSPolicyAssignment" - pattern: "projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}" -}; - -// Get a report of the OS policy assignment for a VM instance. -message GetOSPolicyAssignmentReportRequest { - // Required. API resource name for OS policy assignment report. - // - // Format: - // `/projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report` - // - // For `{project}`, either `project-number` or `project-id` can be provided. - // For `{instance_id}`, either Compute Engine `instance-id` or `instance-name` - // can be provided. - // For `{assignment_id}`, the OSPolicyAssignment id must be provided. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/OSPolicyAssignmentReport" - } - ]; -} - -// List the OS policy assignment reports for VM instances. -message ListOSPolicyAssignmentReportsRequest { - // Required. The parent resource name. - // - // Format: - // `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/reports` - // - // For `{project}`, either `project-number` or `project-id` can be provided. - // For `{instance}`, either `instance-name`, `instance-id`, or `-` can be - // provided. If '-' is provided, the response will include - // OSPolicyAssignmentReports for all instances in the project/location. - // For `{assignment}`, either `assignment-id` or `-` can be provided. If '-' - // is provided, the response will include OSPolicyAssignmentReports for all - // OSPolicyAssignments in the project/location. - // Either {instance} or {assignment} must be `-`. - // - // For example: - // `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/-/reports` - // returns all reports for the instance - // `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/{assignment-id}/reports` - // returns all the reports for the given assignment across all instances. - // `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/-/reports` - // returns all the reports for all assignments across all instances. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/InstanceOSPolicyAssignment" - } - ]; - - // The maximum number of results to return. - int32 page_size = 2; - - // If provided, this field specifies the criteria that must be met by the - // `OSPolicyAssignmentReport` API resource that is included in the response. - string filter = 3; - - // A pagination token returned from a previous call to the - // `ListOSPolicyAssignmentReports` method that indicates where this listing - // should continue from. - string page_token = 4; -} - -// A response message for listing OS Policy assignment reports including the -// page of results and page token. -message ListOSPolicyAssignmentReportsResponse { - // List of OS policy assignment reports. - repeated OSPolicyAssignmentReport os_policy_assignment_reports = 1; - - // The pagination token to retrieve the next page of OS policy assignment - // report objects. - string next_page_token = 2; -} - -// A report of the OS policy assignment status for a given instance. -message OSPolicyAssignmentReport { - option (google.api.resource) = { - type: "osconfig.googleapis.com/OSPolicyAssignmentReport" - pattern: "projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report" - }; - - // Compliance data for an OS policy - message OSPolicyCompliance { - // Possible compliance states for an os policy. - enum ComplianceState { - // The policy is in an unknown compliance state. - // - // Refer to the field `compliance_state_reason` to learn the exact reason - // for the policy to be in this compliance state. - UNKNOWN = 0; - - // Policy is compliant. - // - // The policy is compliant if all the underlying resources are also - // compliant. - COMPLIANT = 1; - - // Policy is non-compliant. - // - // The policy is non-compliant if one or more underlying resources are - // non-compliant. - NON_COMPLIANT = 2; - } - - // Compliance data for an OS policy resource. - message OSPolicyResourceCompliance { - // Step performed by the OS Config agent for configuring an - // `OSPolicy` resource to its desired state. - message OSPolicyResourceConfigStep { - // Supported configuration step types - enum Type { - // Default value. This value is unused. - TYPE_UNSPECIFIED = 0; - - // Checks for resource conflicts such as schema errors. - VALIDATION = 1; - - // Checks the current status of the desired state for a resource. - DESIRED_STATE_CHECK = 2; - - // Enforces the desired state for a resource that is not in desired - // state. - DESIRED_STATE_ENFORCEMENT = 3; - - // Re-checks the status of the desired state. This check is done - // for a resource after the enforcement of all OS policies. - // - // This step is used to determine the final desired state status for - // the resource. It accounts for any resources that might have drifted - // from their desired state due to side effects from executing other - // resources. - DESIRED_STATE_CHECK_POST_ENFORCEMENT = 4; - } - - // Configuration step type. - Type type = 1; - - // An error message recorded during the execution of this step. - // Only populated if errors were encountered during this step execution. - string error_message = 2; - } - - // Possible compliance states for a resource. - enum ComplianceState { - // The resource is in an unknown compliance state. - // - // To get more details about why the policy is in this state, review - // the output of the `compliance_state_reason` field. - UNKNOWN = 0; - - // Resource is compliant. - COMPLIANT = 1; - - // Resource is non-compliant. - NON_COMPLIANT = 2; - } - - // ExecResource specific output. - message ExecResourceOutput { - // Output from enforcement phase output file (if run). - // Output size is limited to 100K bytes. - bytes enforcement_output = 2; - } - - // The ID of the OS policy resource. - string os_policy_resource_id = 1; - - // Ordered list of configuration completed by the agent for the OS policy - // resource. - repeated OSPolicyResourceConfigStep config_steps = 2; - - // The compliance state of the resource. - ComplianceState compliance_state = 3; - - // A reason for the resource to be in the given compliance state. - // This field is always populated when `compliance_state` is `UNKNOWN`. - // - // The following values are supported when `compliance_state == UNKNOWN` - // - // * `execution-errors`: Errors were encountered by the agent while - // executing the resource and the compliance state couldn't be - // determined. - // * `execution-skipped-by-agent`: Resource execution was skipped by the - // agent because errors were encountered while executing prior resources - // in the OS policy. - // * `os-policy-execution-attempt-failed`: The execution of the OS policy - // containing this resource failed and the compliance state couldn't be - // determined. - string compliance_state_reason = 4; - - // Resource specific output. - oneof output { - // ExecResource specific output. - ExecResourceOutput exec_resource_output = 5; - } - } - - // The OS policy id - string os_policy_id = 1; - - // The compliance state of the OS policy. - ComplianceState compliance_state = 2; - - // The reason for the OS policy to be in an unknown compliance state. - // This field is always populated when `compliance_state` is `UNKNOWN`. - // - // If populated, the field can contain one of the following values: - // - // * `vm-not-running`: The VM was not running. - // * `os-policies-not-supported-by-agent`: The version of the OS Config - // agent running on the VM does not support running OS policies. - // * `no-agent-detected`: The OS Config agent is not detected for the VM. - // * `resource-execution-errors`: The OS Config agent encountered errors - // while executing one or more resources in the policy. See - // `os_policy_resource_compliances` for details. - // * `task-timeout`: The task sent to the agent to apply the policy timed - // out. - // * `unexpected-agent-state`: The OS Config agent did not report the final - // status of the task that attempted to apply the policy. Instead, the agent - // unexpectedly started working on a different task. This mostly happens - // when the agent or VM unexpectedly restarts while applying OS policies. - // * `internal-service-errors`: Internal service errors were encountered - // while attempting to apply the policy. - string compliance_state_reason = 3; - - // Compliance data for each resource within the policy that is applied to - // the VM. - repeated OSPolicyResourceCompliance os_policy_resource_compliances = 4; - } - - // The `OSPolicyAssignmentReport` API resource name. - // - // Format: - // `projects/{project_number}/locations/{location}/instances/{instance_id}/osPolicyAssignments/{os_policy_assignment_id}/report` - string name = 1; - - // The Compute Engine VM instance name. - string instance = 2; - - // Reference to the `OSPolicyAssignment` API resource that the `OSPolicy` - // belongs to. - // - // Format: - // `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id@revision_id}` - string os_policy_assignment = 3 [(google.api.resource_reference) = { - type: "osconfig.googleapis.com/OSPolicyAssignment" - }]; - - // Compliance data for each `OSPolicy` that is applied to the VM. - repeated OSPolicyCompliance os_policy_compliances = 4; - - // Timestamp for when the report was last generated. - google.protobuf.Timestamp update_time = 5; - - // Unique identifier of the last attempted run to apply the OS policies - // associated with this assignment on the VM. - // - // This ID is logged by the OS Config agent while applying the OS - // policies associated with this assignment on the VM. - // NOTE: If the service is unable to successfully connect to the agent for - // this run, then this id will not be available in the agent logs. - string last_run_id = 6; -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy_assignments.proto b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy_assignments.proto deleted file mode 100644 index 73e10aeb6a3..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/os_policy_assignments.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.osconfig.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/osconfig/v1/os_policy.proto"; -import "google/cloud/osconfig/v1/osconfig_common.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.OsConfig.V1"; -option go_package = "cloud.google.com/go/osconfig/apiv1/osconfigpb;osconfigpb"; -option java_multiple_files = true; -option java_outer_classname = "OsPolicyAssignmentsProto"; -option java_package = "com.google.cloud.osconfig.v1"; -option php_namespace = "Google\\Cloud\\OsConfig\\V1"; -option ruby_package = "Google::Cloud::OsConfig::V1"; - -// OS policy assignment is an API resource that is used to -// apply a set of OS policies to a dynamically targeted group of Compute Engine -// VM instances. -// -// An OS policy is used to define the desired state configuration for a -// Compute Engine VM instance through a set of configuration resources that -// provide capabilities such as installing or removing software packages, or -// executing a script. -// -// For more information, see [OS policy and OS policy -// assignment](https://cloud.google.com/compute/docs/os-configuration-management/working-with-os-policies). -message OSPolicyAssignment { - option (google.api.resource) = { - type: "osconfig.googleapis.com/OSPolicyAssignment" - pattern: "projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}" - }; - - // Message representing label set. - // * A label is a key value pair set for a VM. - // * A LabelSet is a set of labels. - // * Labels within a LabelSet are ANDed. In other words, a LabelSet is - // applicable for a VM only if it matches all the labels in the - // LabelSet. - // * Example: A LabelSet with 2 labels: `env=prod` and `type=webserver` will - // only be applicable for those VMs with both labels - // present. - message LabelSet { - // Labels are identified by key/value pairs in this map. - // A VM should contain all the key/value pairs specified in this - // map to be selected. - map labels = 1; - } - - // Filters to select target VMs for an assignment. - // - // If more than one filter criteria is specified below, a VM will be selected - // if and only if it satisfies all of them. - message InstanceFilter { - // VM inventory details. - message Inventory { - // Required. The OS short name - string os_short_name = 1 [(google.api.field_behavior) = REQUIRED]; - - // The OS version - // - // Prefix matches are supported if asterisk(*) is provided as the - // last character. For example, to match all versions with a major - // version of `7`, specify the following value for this field `7.*` - // - // An empty string matches all OS versions. - string os_version = 2; - } - - // Target all VMs in the project. If true, no other criteria is - // permitted. - bool all = 1; - - // List of label sets used for VM inclusion. - // - // If the list has more than one `LabelSet`, the VM is included if any - // of the label sets are applicable for the VM. - repeated LabelSet inclusion_labels = 2; - - // List of label sets used for VM exclusion. - // - // If the list has more than one label set, the VM is excluded if any - // of the label sets are applicable for the VM. - repeated LabelSet exclusion_labels = 3; - - // List of inventories to select VMs. - // - // A VM is selected if its inventory data matches at least one of the - // following inventories. - repeated Inventory inventories = 4; - } - - // Message to configure the rollout at the zonal level for the OS policy - // assignment. - message Rollout { - // Required. The maximum number (or percentage) of VMs per zone to disrupt - // at any given moment. - FixedOrPercent disruption_budget = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. This determines the minimum duration of time to wait after the - // configuration changes are applied through the current rollout. A - // VM continues to count towards the `disruption_budget` at least - // until this duration of time has passed after configuration changes are - // applied. - google.protobuf.Duration min_wait_duration = 2 - [(google.api.field_behavior) = REQUIRED]; - } - - // OS policy assignment rollout state - enum RolloutState { - // Invalid value - ROLLOUT_STATE_UNSPECIFIED = 0; - - // The rollout is in progress. - IN_PROGRESS = 1; - - // The rollout is being cancelled. - CANCELLING = 2; - - // The rollout is cancelled. - CANCELLED = 3; - - // The rollout has completed successfully. - SUCCEEDED = 4; - } - - // Resource name. - // - // Format: - // `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id}` - // - // This field is ignored when you create an OS policy assignment. - string name = 1; - - // OS policy assignment description. - // Length of the description is limited to 1024 characters. - string description = 2; - - // Required. List of OS policies to be applied to the VMs. - repeated OSPolicy os_policies = 3 [(google.api.field_behavior) = REQUIRED]; - - // Required. Filter to select VMs. - InstanceFilter instance_filter = 4 [(google.api.field_behavior) = REQUIRED]; - - // Required. Rollout to deploy the OS policy assignment. - // A rollout is triggered in the following situations: - // 1) OSPolicyAssignment is created. - // 2) OSPolicyAssignment is updated and the update contains changes to one of - // the following fields: - // - instance_filter - // - os_policies - // 3) OSPolicyAssignment is deleted. - Rollout rollout = 5 [(google.api.field_behavior) = REQUIRED]; - - // Output only. The assignment revision ID - // A new revision is committed whenever a rollout is triggered for a OS policy - // assignment - string revision_id = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The timestamp that the revision was created. - google.protobuf.Timestamp revision_create_time = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The etag for this OS policy assignment. - // If this is provided on update, it must match the server's etag. - string etag = 8; - - // Output only. OS policy assignment rollout state - RolloutState rollout_state = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Indicates that this revision has been successfully rolled out - // in this zone and new VMs will be assigned OS policies from this revision. - // - // For a given OS policy assignment, there is only one revision with a value - // of `true` for this field. - bool baseline = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Indicates that this revision deletes the OS policy assignment. - bool deleted = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Indicates that reconciliation is in progress for the revision. - // This value is `true` when the `rollout_state` is one of: - // * IN_PROGRESS - // * CANCELLING - bool reconciling = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Server generated unique id for the OS policy assignment - // resource. - string uid = 13 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// OS policy assignment operation metadata provided by OS policy assignment API -// methods that return long running operations. -message OSPolicyAssignmentOperationMetadata { - // The OS policy assignment API method. - enum APIMethod { - // Invalid value - API_METHOD_UNSPECIFIED = 0; - - // Create OS policy assignment API method - CREATE = 1; - - // Update OS policy assignment API method - UPDATE = 2; - - // Delete OS policy assignment API method - DELETE = 3; - } - - // State of the rollout - enum RolloutState { - // Invalid value - ROLLOUT_STATE_UNSPECIFIED = 0; - - // The rollout is in progress. - IN_PROGRESS = 1; - - // The rollout is being cancelled. - CANCELLING = 2; - - // The rollout is cancelled. - CANCELLED = 3; - - // The rollout has completed successfully. - SUCCEEDED = 4; - } - - // Reference to the `OSPolicyAssignment` API resource. - // - // Format: - // `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id@revision_id}` - string os_policy_assignment = 1 [(google.api.resource_reference) = { - type: "osconfig.googleapis.com/OSPolicyAssignment" - }]; - - // The OS policy assignment API method. - APIMethod api_method = 2; - - // State of the rollout - RolloutState rollout_state = 3; - - // Rollout start time - google.protobuf.Timestamp rollout_start_time = 4; - - // Rollout update time - google.protobuf.Timestamp rollout_update_time = 5; -} - -// A request message to create an OS policy assignment -message CreateOSPolicyAssignmentRequest { - // Required. The parent resource name in the form: - // projects/{project}/locations/{location} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The OS policy assignment to be created. - OSPolicyAssignment os_policy_assignment = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Required. The logical name of the OS policy assignment in the project - // with the following restrictions: - // - // * Must contain only lowercase letters, numbers, and hyphens. - // * Must start with a letter. - // * Must be between 1-63 characters. - // * Must end with a number or a letter. - // * Must be unique within the project. - string os_policy_assignment_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// A request message to update an OS policy assignment -message UpdateOSPolicyAssignmentRequest { - // Required. The updated OS policy assignment. - OSPolicyAssignment os_policy_assignment = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Optional. Field mask that controls which fields of the assignment should be - // updated. - google.protobuf.FieldMask update_mask = 2 - [(google.api.field_behavior) = OPTIONAL]; -} - -// A request message to get an OS policy assignment -message GetOSPolicyAssignmentRequest { - // Required. The resource name of OS policy assignment. - // - // Format: - // `projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}@{revisionId}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/OSPolicyAssignment" - } - ]; -} - -// A request message to list OS policy assignments for a parent resource -message ListOSPolicyAssignmentsRequest { - // Required. The parent resource name. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of assignments to return. - int32 page_size = 2; - - // A pagination token returned from a previous call to - // `ListOSPolicyAssignments` that indicates where this listing should continue - // from. - string page_token = 3; -} - -// A response message for listing all assignments under given parent. -message ListOSPolicyAssignmentsResponse { - // The list of assignments - repeated OSPolicyAssignment os_policy_assignments = 1; - - // The pagination token to retrieve the next page of OS policy assignments. - string next_page_token = 2; -} - -// A request message to list revisions for a OS policy assignment -message ListOSPolicyAssignmentRevisionsRequest { - // Required. The name of the OS policy assignment to list revisions for. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/OSPolicyAssignment" - } - ]; - - // The maximum number of revisions to return. - int32 page_size = 2; - - // A pagination token returned from a previous call to - // `ListOSPolicyAssignmentRevisions` that indicates where this listing should - // continue from. - string page_token = 3; -} - -// A response message for listing all revisions for a OS policy assignment. -message ListOSPolicyAssignmentRevisionsResponse { - // The OS policy assignment revisions - repeated OSPolicyAssignment os_policy_assignments = 1; - - // The pagination token to retrieve the next page of OS policy assignment - // revisions. - string next_page_token = 2; -} - -// A request message for deleting a OS policy assignment. -message DeleteOSPolicyAssignmentRequest { - // Required. The name of the OS policy assignment to be deleted - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/OSPolicyAssignment" - } - ]; -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_common.proto b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_common.proto deleted file mode 100644 index baa6e37294b..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_common.proto +++ /dev/null @@ -1,38 +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.osconfig.v1; - -option csharp_namespace = "Google.Cloud.OsConfig.V1"; -option go_package = "cloud.google.com/go/osconfig/apiv1/osconfigpb;osconfigpb"; -option java_outer_classname = "Common"; -option java_package = "com.google.cloud.osconfig.v1"; -option php_namespace = "Google\\Cloud\\OsConfig\\V1"; -option ruby_package = "Google::Cloud::OsConfig::V1"; - -// Message encapsulating a value that can be either absolute ("fixed") or -// relative ("percent") to a value. -message FixedOrPercent { - // Type of the value. - oneof mode { - // Specifies a fixed value. - int32 fixed = 1; - - // Specifies the relative value defined as a percentage, which will be - // multiplied by a reference value. - int32 percent = 2; - } -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_service.proto b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_service.proto deleted file mode 100644 index c6afe3fa5b6..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_service.proto +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.osconfig.v1; - -import "google/api/client.proto"; -import "google/api/resource.proto"; -import "google/cloud/osconfig/v1/patch_deployments.proto"; -import "google/cloud/osconfig/v1/patch_jobs.proto"; -import "google/protobuf/empty.proto"; -import "google/api/annotations.proto"; - -option csharp_namespace = "Google.Cloud.OsConfig.V1"; -option go_package = "cloud.google.com/go/osconfig/apiv1/osconfigpb;osconfigpb"; -option java_outer_classname = "OsConfigProto"; -option java_package = "com.google.cloud.osconfig.v1"; -option php_namespace = "Google\\Cloud\\OsConfig\\V1"; -option ruby_package = "Google::Cloud::OsConfig::V1"; -option (google.api.resource_definition) = { - type: "compute.googleapis.com/Instance" - pattern: "projects/{project}/zones/{zone}/instances/{instance}" - pattern: "projects/{project}/locations/{location}/instances/{instance}" -}; - -// OS Config API -// -// The OS Config service is a server-side component that you can use to -// manage package installations and patch jobs for virtual machine instances. -service OsConfigService { - option (google.api.default_host) = "osconfig.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Patch VM instances by creating and running a patch job. - rpc ExecutePatchJob(ExecutePatchJobRequest) returns (PatchJob) { - option (google.api.http) = { - post: "/v1/{parent=projects/*}/patchJobs:execute" - body: "*" - }; - } - - // Get the patch job. This can be used to track the progress of an - // ongoing patch job or review the details of completed jobs. - rpc GetPatchJob(GetPatchJobRequest) returns (PatchJob) { - option (google.api.http) = { - get: "/v1/{name=projects/*/patchJobs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Cancel a patch job. The patch job must be active. Canceled patch jobs - // cannot be restarted. - rpc CancelPatchJob(CancelPatchJobRequest) returns (PatchJob) { - option (google.api.http) = { - post: "/v1/{name=projects/*/patchJobs/*}:cancel" - body: "*" - }; - } - - // Get a list of patch jobs. - rpc ListPatchJobs(ListPatchJobsRequest) returns (ListPatchJobsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*}/patchJobs" - }; - option (google.api.method_signature) = "parent"; - } - - // Get a list of instance details for a given patch job. - rpc ListPatchJobInstanceDetails(ListPatchJobInstanceDetailsRequest) - returns (ListPatchJobInstanceDetailsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/patchJobs/*}/instanceDetails" - }; - option (google.api.method_signature) = "parent"; - } - - // Create an OS Config patch deployment. - rpc CreatePatchDeployment(CreatePatchDeploymentRequest) - returns (PatchDeployment) { - option (google.api.http) = { - post: "/v1/{parent=projects/*}/patchDeployments" - body: "patch_deployment" - }; - option (google.api.method_signature) = - "parent,patch_deployment,patch_deployment_id"; - } - - // Get an OS Config patch deployment. - rpc GetPatchDeployment(GetPatchDeploymentRequest) returns (PatchDeployment) { - option (google.api.http) = { - get: "/v1/{name=projects/*/patchDeployments/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Get a page of OS Config patch deployments. - rpc ListPatchDeployments(ListPatchDeploymentsRequest) - returns (ListPatchDeploymentsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*}/patchDeployments" - }; - option (google.api.method_signature) = "parent"; - } - - // Delete an OS Config patch deployment. - rpc DeletePatchDeployment(DeletePatchDeploymentRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/patchDeployments/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Update an OS Config patch deployment. - rpc UpdatePatchDeployment(UpdatePatchDeploymentRequest) - returns (PatchDeployment) { - option (google.api.http) = { - patch: "/v1/{patch_deployment.name=projects/*/patchDeployments/*}" - body: "patch_deployment" - }; - option (google.api.method_signature) = "patch_deployment,update_mask"; - } - - // Change state of patch deployment to "PAUSED". - // Patch deployment in paused state doesn't generate patch jobs. - rpc PausePatchDeployment(PausePatchDeploymentRequest) - returns (PatchDeployment) { - option (google.api.http) = { - post: "/v1/{name=projects/*/patchDeployments/*}:pause" - body: "*" - }; - option (google.api.method_signature) = "name"; - } - - // Change state of patch deployment back to "ACTIVE". - // Patch deployment in active state continues to generate patch jobs. - rpc ResumePatchDeployment(ResumePatchDeploymentRequest) - returns (PatchDeployment) { - option (google.api.http) = { - post: "/v1/{name=projects/*/patchDeployments/*}:resume" - body: "*" - }; - option (google.api.method_signature) = "name"; - } -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_zonal_service.proto b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_zonal_service.proto deleted file mode 100644 index 671ed3c0d93..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/osconfig_zonal_service.proto +++ /dev/null @@ -1,202 +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.osconfig.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/cloud/osconfig/v1/inventory.proto"; -import "google/cloud/osconfig/v1/os_policy_assignment_reports.proto"; -import "google/cloud/osconfig/v1/os_policy_assignments.proto"; -import "google/cloud/osconfig/v1/vulnerability.proto"; -import "google/longrunning/operations.proto"; - -option csharp_namespace = "Google.Cloud.OsConfig.V1"; -option go_package = "cloud.google.com/go/osconfig/apiv1/osconfigpb;osconfigpb"; -option java_multiple_files = true; -option java_outer_classname = "OsConfigZonalServiceProto"; -option java_package = "com.google.cloud.osconfig.v1"; -option php_namespace = "Google\\Cloud\\OsConfig\\V1"; -option ruby_package = "Google::Cloud::OsConfig::V1"; - -// Zonal OS Config API -// -// The OS Config service is the server-side component that allows users to -// manage package installations and patch jobs for Compute Engine VM instances. -service OsConfigZonalService { - option (google.api.default_host) = "osconfig.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Create an OS policy assignment. - // - // This method also creates the first revision of the OS policy assignment. - // - // This method returns a long running operation (LRO) that contains the - // rollout details. The rollout can be cancelled by cancelling the LRO. - // - // For more information, see [Method: - // projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel). - rpc CreateOSPolicyAssignment(CreateOSPolicyAssignmentRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/osPolicyAssignments" - body: "os_policy_assignment" - }; - option (google.api.method_signature) = - "parent,os_policy_assignment,os_policy_assignment_id"; - option (google.longrunning.operation_info) = { - response_type: "OSPolicyAssignment" - metadata_type: "OSPolicyAssignmentOperationMetadata" - }; - } - - // Update an existing OS policy assignment. - // - // This method creates a new revision of the OS policy assignment. - // - // This method returns a long running operation (LRO) that contains the - // rollout details. The rollout can be cancelled by cancelling the LRO. - // - // For more information, see [Method: - // projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel). - rpc UpdateOSPolicyAssignment(UpdateOSPolicyAssignmentRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1/{os_policy_assignment.name=projects/*/locations/*/osPolicyAssignments/*}" - body: "os_policy_assignment" - }; - option (google.api.method_signature) = "os_policy_assignment,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "OSPolicyAssignment" - metadata_type: "OSPolicyAssignmentOperationMetadata" - }; - } - - // Retrieve an existing OS policy assignment. - // - // This method always returns the latest revision. In order to retrieve a - // previous revision of the assignment, also provide the revision ID in the - // `name` parameter. - rpc GetOSPolicyAssignment(GetOSPolicyAssignmentRequest) - returns (OSPolicyAssignment) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/osPolicyAssignments/*}" - }; - option (google.api.method_signature) = "name"; - } - - // List the OS policy assignments under the parent resource. - // - // For each OS policy assignment, the latest revision is returned. - rpc ListOSPolicyAssignments(ListOSPolicyAssignmentsRequest) - returns (ListOSPolicyAssignmentsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/osPolicyAssignments" - }; - option (google.api.method_signature) = "parent"; - } - - // List the OS policy assignment revisions for a given OS policy assignment. - rpc ListOSPolicyAssignmentRevisions(ListOSPolicyAssignmentRevisionsRequest) - returns (ListOSPolicyAssignmentRevisionsResponse) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/osPolicyAssignments/*}:listRevisions" - }; - option (google.api.method_signature) = "name"; - } - - // Delete the OS policy assignment. - // - // This method creates a new revision of the OS policy assignment. - // - // This method returns a long running operation (LRO) that contains the - // rollout details. The rollout can be cancelled by cancelling the LRO. - // - // If the LRO completes and is not cancelled, all revisions associated with - // the OS policy assignment are deleted. - // - // For more information, see [Method: - // projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel). - rpc DeleteOSPolicyAssignment(DeleteOSPolicyAssignmentRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/osPolicyAssignments/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "OSPolicyAssignmentOperationMetadata" - }; - } - - // Get the OS policy asssignment report for the specified Compute Engine VM - // instance. - rpc GetOSPolicyAssignmentReport(GetOSPolicyAssignmentReportRequest) - returns (OSPolicyAssignmentReport) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/instances/*/osPolicyAssignments/*/report}" - }; - option (google.api.method_signature) = "name"; - } - - // List OS policy asssignment reports for all Compute Engine VM instances in - // the specified zone. - rpc ListOSPolicyAssignmentReports(ListOSPolicyAssignmentReportsRequest) - returns (ListOSPolicyAssignmentReportsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*/instances/*/osPolicyAssignments/*}/reports" - }; - option (google.api.method_signature) = "parent"; - } - - // Get inventory data for the specified VM instance. If the VM has no - // associated inventory, the message `NOT_FOUND` is returned. - rpc GetInventory(GetInventoryRequest) returns (Inventory) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/instances/*/inventory}" - }; - option (google.api.method_signature) = "name"; - } - - // List inventory data for all VM instances in the specified zone. - rpc ListInventories(ListInventoriesRequest) - returns (ListInventoriesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*/instances/*}/inventories" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets the vulnerability report for the specified VM instance. Only VMs with - // inventory data have vulnerability reports associated with them. - rpc GetVulnerabilityReport(GetVulnerabilityReportRequest) - returns (VulnerabilityReport) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/instances/*/vulnerabilityReport}" - }; - option (google.api.method_signature) = "name"; - } - - // List vulnerability reports for all VM instances in the specified zone. - rpc ListVulnerabilityReports(ListVulnerabilityReportsRequest) - returns (ListVulnerabilityReportsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*/instances/*}/vulnerabilityReports" - }; - option (google.api.method_signature) = "parent"; - } -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/patch_deployments.proto b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/patch_deployments.proto deleted file mode 100644 index ac45652d9d7..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/patch_deployments.proto +++ /dev/null @@ -1,339 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.osconfig.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/osconfig/v1/patch_jobs.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/type/datetime.proto"; -import "google/type/dayofweek.proto"; -import "google/type/timeofday.proto"; - -option csharp_namespace = "Google.Cloud.OsConfig.V1"; -option go_package = "cloud.google.com/go/osconfig/apiv1/osconfigpb;osconfigpb"; -option java_outer_classname = "PatchDeployments"; -option java_package = "com.google.cloud.osconfig.v1"; -option php_namespace = "Google\\Cloud\\OsConfig\\V1"; -option ruby_package = "Google::Cloud::OsConfig::V1"; - -// Patch deployments are configurations that individual patch jobs use to -// complete a patch. These configurations include instance filter, package -// repository settings, and a schedule. For more information about creating and -// managing patch deployments, see [Scheduling patch -// jobs](https://cloud.google.com/compute/docs/os-patch-management/schedule-patch-jobs). -message PatchDeployment { - option (google.api.resource) = { - type: "osconfig.googleapis.com/PatchDeployment" - pattern: "projects/{project}/patchDeployments/{patch_deployment}" - }; - - // Represents state of patch peployment. - enum State { - // The default value. This value is used if the state is omitted. - STATE_UNSPECIFIED = 0; - - // Active value means that patch deployment generates Patch Jobs. - ACTIVE = 1; - - // Paused value means that patch deployment does not generate - // Patch jobs. Requires user action to move in and out from this state. - PAUSED = 2; - } - - // Unique name for the patch deployment resource in a project. The patch - // deployment name is in the form: - // `projects/{project_id}/patchDeployments/{patch_deployment_id}`. - // This field is ignored when you create a new patch deployment. - string name = 1; - - // Optional. Description of the patch deployment. Length of the description is - // limited to 1024 characters. - string description = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Required. VM instances to patch. - PatchInstanceFilter instance_filter = 3 - [(google.api.field_behavior) = REQUIRED]; - - // Optional. Patch configuration that is applied. - PatchConfig patch_config = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Duration of the patch. After the duration ends, the patch times - // out. - google.protobuf.Duration duration = 5 - [(google.api.field_behavior) = OPTIONAL]; - - // Schedule for the patch. - oneof schedule { - // Required. Schedule a one-time execution. - OneTimeSchedule one_time_schedule = 6 - [(google.api.field_behavior) = REQUIRED]; - - // Required. Schedule recurring executions. - RecurringSchedule recurring_schedule = 7 - [(google.api.field_behavior) = REQUIRED]; - } - - // Output only. Time the patch deployment was created. Timestamp is in - // [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text format. - google.protobuf.Timestamp create_time = 8 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Time the patch deployment was last updated. Timestamp is in - // [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text format. - google.protobuf.Timestamp update_time = 9 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The last time a patch job was started by this deployment. - // Timestamp is in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text - // format. - google.protobuf.Timestamp last_execute_time = 10 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Rollout strategy of the patch job. - PatchRollout rollout = 11 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. Current state of the patch deployment. - State state = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Sets the time for a one time patch deployment. Timestamp is in -// [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text format. -message OneTimeSchedule { - // Required. The desired patch job execution time. - google.protobuf.Timestamp execute_time = 1 - [(google.api.field_behavior) = REQUIRED]; -} - -// Sets the time for recurring patch deployments. -message RecurringSchedule { - // Specifies the frequency of the recurring patch deployments. - enum Frequency { - // Invalid. A frequency must be specified. - FREQUENCY_UNSPECIFIED = 0; - - // Indicates that the frequency of recurrence should be expressed in terms - // of weeks. - WEEKLY = 1; - - // Indicates that the frequency of recurrence should be expressed in terms - // of months. - MONTHLY = 2; - - // Indicates that the frequency of recurrence should be expressed in terms - // of days. - DAILY = 3; - } - - // Required. Defines the time zone that `time_of_day` is relative to. - // The rules for daylight saving time are determined by the chosen time zone. - google.type.TimeZone time_zone = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The time that the recurring schedule becomes effective. - // Defaults to `create_time` of the patch deployment. - google.protobuf.Timestamp start_time = 2 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The end time at which a recurring patch deployment schedule is no - // longer active. - google.protobuf.Timestamp end_time = 3 - [(google.api.field_behavior) = OPTIONAL]; - - // Required. Time of the day to run a recurring deployment. - google.type.TimeOfDay time_of_day = 4 - [(google.api.field_behavior) = REQUIRED]; - - // Required. The frequency unit of this recurring schedule. - Frequency frequency = 5 [(google.api.field_behavior) = REQUIRED]; - - // Configurations for this recurring schedule. - // Configurations must match frequency. - oneof schedule_config { - // Required. Schedule with weekly executions. - WeeklySchedule weekly = 6 [(google.api.field_behavior) = REQUIRED]; - - // Required. Schedule with monthly executions. - MonthlySchedule monthly = 7 [(google.api.field_behavior) = REQUIRED]; - } - - // Output only. The time the last patch job ran successfully. - google.protobuf.Timestamp last_execute_time = 9 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time the next patch job is scheduled to run. - google.protobuf.Timestamp next_execute_time = 10 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Represents a weekly schedule. -message WeeklySchedule { - // Required. Day of the week. - google.type.DayOfWeek day_of_week = 1 - [(google.api.field_behavior) = REQUIRED]; -} - -// Represents a monthly schedule. An example of a valid monthly schedule is -// "on the third Tuesday of the month" or "on the 15th of the month". -message MonthlySchedule { - // One day in a month. - oneof day_of_month { - // Required. Week day in a month. - WeekDayOfMonth week_day_of_month = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. One day of the month. 1-31 indicates the 1st to the 31st day. - // -1 indicates the last day of the month. Months without the target day - // will be skipped. For example, a schedule to run "every month on the 31st" - // will not run in February, April, June, etc. - int32 month_day = 2 [(google.api.field_behavior) = REQUIRED]; - } -} - -// Represents one week day in a month. An example is "the 4th Sunday". -message WeekDayOfMonth { - // Required. Week number in a month. 1-4 indicates the 1st to 4th week of the - // month. -1 indicates the last week of the month. - int32 week_ordinal = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. A day of the week. - google.type.DayOfWeek day_of_week = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Optional. Represents the number of days before or after the given week day - // of month that the patch deployment is scheduled for. For example if - // `week_ordinal` and `day_of_week` values point to the second day of the - // month and this `day_offset` value is set to `3`, the patch deployment takes - // place three days after the second Tuesday of the month. If this value is - // negative, for example -5, the patches are deployed five days before before - // the second Tuesday of the month. Allowed values are in range [-30, 30]. - int32 day_offset = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// A request message for creating a patch deployment. -message CreatePatchDeploymentRequest { - // Required. The project to apply this patch deployment to in the form - // `projects/*`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Required. A name for the patch deployment in the project. When creating a - // name the following rules apply: - // * Must contain only lowercase letters, numbers, and hyphens. - // * Must start with a letter. - // * Must be between 1-63 characters. - // * Must end with a number or a letter. - // * Must be unique within the project. - string patch_deployment_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The patch deployment to create. - PatchDeployment patch_deployment = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// A request message for retrieving a patch deployment. -message GetPatchDeploymentRequest { - // Required. The resource name of the patch deployment in the form - // `projects/*/patchDeployments/*`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/PatchDeployment" - } - ]; -} - -// A request message for listing patch deployments. -message ListPatchDeploymentsRequest { - // Required. The resource name of the parent in the form `projects/*`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Optional. The maximum number of patch deployments to return. Default is - // 100. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A pagination token returned from a previous call to - // ListPatchDeployments that indicates where this listing should continue - // from. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// A response message for listing patch deployments. -message ListPatchDeploymentsResponse { - // The list of patch deployments. - repeated PatchDeployment patch_deployments = 1; - - // A pagination token that can be used to get the next page of patch - // deployments. - string next_page_token = 2; -} - -// A request message for deleting a patch deployment. -message DeletePatchDeploymentRequest { - // Required. The resource name of the patch deployment in the form - // `projects/*/patchDeployments/*`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/PatchDeployment" - } - ]; -} - -// A request message for updating a patch deployment. -message UpdatePatchDeploymentRequest { - // Required. The patch deployment to Update. - PatchDeployment patch_deployment = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Field mask that controls which fields of the patch deployment - // should be updated. - google.protobuf.FieldMask update_mask = 2 - [(google.api.field_behavior) = OPTIONAL]; -} - -// A request message for pausing a patch deployment. -message PausePatchDeploymentRequest { - // Required. The resource name of the patch deployment in the form - // `projects/*/patchDeployments/*`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/PatchDeployment" - } - ]; -} - -// A request message for resuming a patch deployment. -message ResumePatchDeploymentRequest { - // Required. The resource name of the patch deployment in the form - // `projects/*/patchDeployments/*`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/PatchDeployment" - } - ]; -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/patch_jobs.proto b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/patch_jobs.proto deleted file mode 100644 index 7c0b3400713..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/patch_jobs.proto +++ /dev/null @@ -1,742 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.osconfig.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/osconfig/v1/osconfig_common.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.OsConfig.V1"; -option go_package = "cloud.google.com/go/osconfig/apiv1/osconfigpb;osconfigpb"; -option java_outer_classname = "PatchJobs"; -option java_package = "com.google.cloud.osconfig.v1"; -option php_namespace = "Google\\Cloud\\OsConfig\\V1"; -option ruby_package = "Google::Cloud::OsConfig::V1"; - -// A request message to initiate patching across Compute Engine -// instances. -message ExecutePatchJobRequest { - // Required. The project in which to run this patch in the form `projects/*` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Description of the patch job. Length of the description is limited - // to 1024 characters. - string description = 2; - - // Required. Instances to patch, either explicitly or filtered by some - // criteria such as zone or labels. - PatchInstanceFilter instance_filter = 7 - [(google.api.field_behavior) = REQUIRED]; - - // Patch configuration being applied. If omitted, instances are - // patched using the default configurations. - PatchConfig patch_config = 4; - - // Duration of the patch job. After the duration ends, the patch job - // times out. - google.protobuf.Duration duration = 5; - - // If this patch is a dry-run only, instances are contacted but - // will do nothing. - bool dry_run = 6; - - // Display name for this patch job. This does not have to be unique. - string display_name = 8; - - // Rollout strategy of the patch job. - PatchRollout rollout = 9; -} - -// Request to get an active or completed patch job. -message GetPatchJobRequest { - // Required. Name of the patch in the form `projects/*/patchJobs/*` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/PatchJob" - } - ]; -} - -// Request to list details for all instances that are part of a patch job. -message ListPatchJobInstanceDetailsRequest { - // Required. The parent for the instances are in the form of - // `projects/*/patchJobs/*`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/PatchJob" - } - ]; - - // The maximum number of instance details records to return. Default is 100. - int32 page_size = 2; - - // A pagination token returned from a previous call - // that indicates where this listing should continue from. - string page_token = 3; - - // A filter expression that filters results listed in the response. This - // field supports filtering results by instance zone, name, state, or - // `failure_reason`. - string filter = 4; -} - -// A response message for listing the instances details for a patch job. -message ListPatchJobInstanceDetailsResponse { - // A list of instance status. - repeated PatchJobInstanceDetails patch_job_instance_details = 1; - - // A pagination token that can be used to get the next page of results. - string next_page_token = 2; -} - -// Patch details for a VM instance. For more information about reviewing VM -// instance details, see -// [Listing all VM instance details for a specific patch -// job](https://cloud.google.com/compute/docs/os-patch-management/manage-patch-jobs#list-instance-details). -message PatchJobInstanceDetails { - // The instance name in the form `projects/*/zones/*/instances/*` - string name = 1 [(google.api.resource_reference) = { - type: "compute.googleapis.com/Instance" - }]; - - // The unique identifier for the instance. This identifier is - // defined by the server. - string instance_system_id = 2; - - // Current state of instance patch. - Instance.PatchState state = 3; - - // If the patch fails, this field provides the reason. - string failure_reason = 4; - - // The number of times the agent that the agent attempts to apply the patch. - int64 attempt_count = 5; -} - -// A request message for listing patch jobs. -message ListPatchJobsRequest { - // Required. In the form of `projects/*` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // The maximum number of instance status to return. - int32 page_size = 2; - - // A pagination token returned from a previous call - // that indicates where this listing should continue from. - string page_token = 3; - - // If provided, this field specifies the criteria that must be met by patch - // jobs to be included in the response. - // Currently, filtering is only available on the patch_deployment field. - string filter = 4; -} - -// A response message for listing patch jobs. -message ListPatchJobsResponse { - // The list of patch jobs. - repeated PatchJob patch_jobs = 1; - - // A pagination token that can be used to get the next page of results. - string next_page_token = 2; -} - -// A high level representation of a patch job that is either in progress -// or has completed. -// -// Instance details are not included in the job. To paginate through instance -// details, use ListPatchJobInstanceDetails. -// -// For more information about patch jobs, see -// [Creating patch -// jobs](https://cloud.google.com/compute/docs/os-patch-management/create-patch-job). -message PatchJob { - option (google.api.resource) = { - type: "osconfig.googleapis.com/PatchJob" - pattern: "projects/{project}/patchJobs/{patch_job}" - }; - - // Enumeration of the various states a patch job passes through as it - // executes. - enum State { - // State must be specified. - STATE_UNSPECIFIED = 0; - - // The patch job was successfully initiated. - STARTED = 1; - - // The patch job is looking up instances to run the patch on. - INSTANCE_LOOKUP = 2; - - // Instances are being patched. - PATCHING = 3; - - // Patch job completed successfully. - SUCCEEDED = 4; - - // Patch job completed but there were errors. - COMPLETED_WITH_ERRORS = 5; - - // The patch job was canceled. - CANCELED = 6; - - // The patch job timed out. - TIMED_OUT = 7; - } - - // A summary of the current patch state across all instances that this patch - // job affects. Contains counts of instances in different states. These states - // map to `InstancePatchState`. List patch job instance details to see the - // specific states of each instance. - message InstanceDetailsSummary { - // Number of instances pending patch job. - int64 pending_instance_count = 1; - - // Number of instances that are inactive. - int64 inactive_instance_count = 2; - - // Number of instances notified about patch job. - int64 notified_instance_count = 3; - - // Number of instances that have started. - int64 started_instance_count = 4; - - // Number of instances that are downloading patches. - int64 downloading_patches_instance_count = 5; - - // Number of instances that are applying patches. - int64 applying_patches_instance_count = 6; - - // Number of instances rebooting. - int64 rebooting_instance_count = 7; - - // Number of instances that have completed successfully. - int64 succeeded_instance_count = 8; - - // Number of instances that require reboot. - int64 succeeded_reboot_required_instance_count = 9; - - // Number of instances that failed. - int64 failed_instance_count = 10; - - // Number of instances that have acked and will start shortly. - int64 acked_instance_count = 11; - - // Number of instances that exceeded the time out while applying the patch. - int64 timed_out_instance_count = 12; - - // Number of instances that are running the pre-patch step. - int64 pre_patch_step_instance_count = 13; - - // Number of instances that are running the post-patch step. - int64 post_patch_step_instance_count = 14; - - // Number of instances that do not appear to be running the agent. Check to - // ensure that the agent is installed, running, and able to communicate with - // the service. - int64 no_agent_detected_instance_count = 15; - } - - // Unique identifier for this patch job in the form - // `projects/*/patchJobs/*` - string name = 1; - - // Display name for this patch job. This is not a unique identifier. - string display_name = 14; - - // Description of the patch job. Length of the description is limited - // to 1024 characters. - string description = 2; - - // Time this patch job was created. - google.protobuf.Timestamp create_time = 3; - - // Last time this patch job was updated. - google.protobuf.Timestamp update_time = 4; - - // The current state of the PatchJob. - State state = 5; - - // Instances to patch. - PatchInstanceFilter instance_filter = 13; - - // Patch configuration being applied. - PatchConfig patch_config = 7; - - // Duration of the patch job. After the duration ends, the - // patch job times out. - google.protobuf.Duration duration = 8; - - // Summary of instance details. - InstanceDetailsSummary instance_details_summary = 9; - - // If this patch job is a dry run, the agent reports that it has - // finished without running any updates on the VM instance. - bool dry_run = 10; - - // If this patch job failed, this message provides information about the - // failure. - string error_message = 11; - - // Reflects the overall progress of the patch job in the range of - // 0.0 being no progress to 100.0 being complete. - double percent_complete = 12; - - // Output only. Name of the patch deployment that created this patch job. - string patch_deployment = 15 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/PatchDeployment" - } - ]; - - // Rollout strategy being applied. - PatchRollout rollout = 16; -} - -// Patch configuration specifications. Contains details on how to apply the -// patch(es) to a VM instance. -message PatchConfig { - // Post-patch reboot settings. - enum RebootConfig { - // The default behavior is DEFAULT. - REBOOT_CONFIG_UNSPECIFIED = 0; - - // The agent decides if a reboot is necessary by checking signals such as - // registry keys on Windows or `/var/run/reboot-required` on APT based - // systems. On RPM based systems, a set of core system package install times - // are compared with system boot time. - DEFAULT = 1; - - // Always reboot the machine after the update completes. - ALWAYS = 2; - - // Never reboot the machine after the update completes. - NEVER = 3; - } - - // Post-patch reboot settings. - RebootConfig reboot_config = 1; - - // Apt update settings. Use this setting to override the default `apt` patch - // rules. - AptSettings apt = 3; - - // Yum update settings. Use this setting to override the default `yum` patch - // rules. - YumSettings yum = 4; - - // Goo update settings. Use this setting to override the default `goo` patch - // rules. - GooSettings goo = 5; - - // Zypper update settings. Use this setting to override the default `zypper` - // patch rules. - ZypperSettings zypper = 6; - - // Windows update settings. Use this override the default windows patch rules. - WindowsUpdateSettings windows_update = 7; - - // The `ExecStep` to run before the patch update. - ExecStep pre_step = 8; - - // The `ExecStep` to run after the patch update. - ExecStep post_step = 9; - - // Allows the patch job to run on Managed instance groups (MIGs). - bool mig_instances_allowed = 10; -} - -// Namespace for instance state enums. -message Instance { - // Patch state of an instance. - enum PatchState { - // Unspecified. - PATCH_STATE_UNSPECIFIED = 0; - - // The instance is not yet notified. - PENDING = 1; - - // Instance is inactive and cannot be patched. - INACTIVE = 2; - - // The instance is notified that it should be patched. - NOTIFIED = 3; - - // The instance has started the patching process. - STARTED = 4; - - // The instance is downloading patches. - DOWNLOADING_PATCHES = 5; - - // The instance is applying patches. - APPLYING_PATCHES = 6; - - // The instance is rebooting. - REBOOTING = 7; - - // The instance has completed applying patches. - SUCCEEDED = 8; - - // The instance has completed applying patches but a reboot is required. - SUCCEEDED_REBOOT_REQUIRED = 9; - - // The instance has failed to apply the patch. - FAILED = 10; - - // The instance acked the notification and will start shortly. - ACKED = 11; - - // The instance exceeded the time out while applying the patch. - TIMED_OUT = 12; - - // The instance is running the pre-patch step. - RUNNING_PRE_PATCH_STEP = 13; - - // The instance is running the post-patch step. - RUNNING_POST_PATCH_STEP = 14; - - // The service could not detect the presence of the agent. Check to ensure - // that the agent is installed, running, and able to communicate with the - // service. - NO_AGENT_DETECTED = 15; - } -} - -// Message for canceling a patch job. -message CancelPatchJobRequest { - // Required. Name of the patch in the form `projects/*/patchJobs/*` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/PatchJob" - } - ]; -} - -// Apt patching is completed by executing `apt-get update && apt-get -// upgrade`. Additional options can be set to control how this is executed. -message AptSettings { - // Apt patch type. - enum Type { - // By default, upgrade will be performed. - TYPE_UNSPECIFIED = 0; - - // Runs `apt-get dist-upgrade`. - DIST = 1; - - // Runs `apt-get upgrade`. - UPGRADE = 2; - } - - // By changing the type to DIST, the patching is performed - // using `apt-get dist-upgrade` instead. - Type type = 1; - - // List of packages to exclude from update. These packages will be excluded - repeated string excludes = 2; - - // An exclusive list of packages to be updated. These are the only packages - // that will be updated. If these packages are not installed, they will be - // ignored. This field cannot be specified with any other patch configuration - // fields. - repeated string exclusive_packages = 3; -} - -// Yum patching is performed by executing `yum update`. Additional options -// can be set to control how this is executed. -// -// Note that not all settings are supported on all platforms. -message YumSettings { - // Adds the `--security` flag to `yum update`. Not supported on - // all platforms. - bool security = 1; - - // Will cause patch to run `yum update-minimal` instead. - bool minimal = 2; - - // List of packages to exclude from update. These packages are excluded by - // using the yum `--exclude` flag. - repeated string excludes = 3; - - // An exclusive list of packages to be updated. These are the only packages - // that will be updated. If these packages are not installed, they will be - // ignored. This field must not be specified with any other patch - // configuration fields. - repeated string exclusive_packages = 4; -} - -// Googet patching is performed by running `googet update`. -message GooSettings {} - -// Zypper patching is performed by running `zypper patch`. -// See also https://en.opensuse.org/SDB:Zypper_manual. -message ZypperSettings { - // Adds the `--with-optional` flag to `zypper patch`. - bool with_optional = 1; - - // Adds the `--with-update` flag, to `zypper patch`. - bool with_update = 2; - - // Install only patches with these categories. - // Common categories include security, recommended, and feature. - repeated string categories = 3; - - // Install only patches with these severities. - // Common severities include critical, important, moderate, and low. - repeated string severities = 4; - - // List of patches to exclude from update. - repeated string excludes = 5; - - // An exclusive list of patches to be updated. These are the only patches - // that will be installed using 'zypper patch patch:' command. - // This field must not be used with any other patch configuration fields. - repeated string exclusive_patches = 6; -} - -// Windows patching is performed using the Windows Update Agent. -message WindowsUpdateSettings { - // Microsoft Windows update classifications as defined in - // [1] - // https://support.microsoft.com/en-us/help/824684/description-of-the-standard-terminology-that-is-used-to-describe-micro - enum Classification { - // Invalid. If classifications are included, they must be specified. - CLASSIFICATION_UNSPECIFIED = 0; - - // "A widely released fix for a specific problem that addresses a critical, - // non-security-related bug." [1] - CRITICAL = 1; - - // "A widely released fix for a product-specific, security-related - // vulnerability. Security vulnerabilities are rated by their severity. The - // severity rating is indicated in the Microsoft security bulletin as - // critical, important, moderate, or low." [1] - SECURITY = 2; - - // "A widely released and frequent software update that contains additions - // to a product's definition database. Definition databases are often used - // to detect objects that have specific attributes, such as malicious code, - // phishing websites, or junk mail." [1] - DEFINITION = 3; - - // "Software that controls the input and output of a device." [1] - DRIVER = 4; - - // "New product functionality that is first distributed outside the context - // of a product release and that is typically included in the next full - // product release." [1] - FEATURE_PACK = 5; - - // "A tested, cumulative set of all hotfixes, security updates, critical - // updates, and updates. Additionally, service packs may contain additional - // fixes for problems that are found internally since the release of the - // product. Service packs my also contain a limited number of - // customer-requested design changes or features." [1] - SERVICE_PACK = 6; - - // "A utility or feature that helps complete a task or set of tasks." [1] - TOOL = 7; - - // "A tested, cumulative set of hotfixes, security updates, critical - // updates, and updates that are packaged together for easy deployment. A - // rollup generally targets a specific area, such as security, or a - // component of a product, such as Internet Information Services (IIS)." [1] - UPDATE_ROLLUP = 8; - - // "A widely released fix for a specific problem. An update addresses a - // noncritical, non-security-related bug." [1] - UPDATE = 9; - } - - // Only apply updates of these windows update classifications. If empty, all - // updates are applied. - repeated Classification classifications = 1; - - // List of KBs to exclude from update. - repeated string excludes = 2; - - // An exclusive list of kbs to be updated. These are the only patches - // that will be updated. This field must not be used with other - // patch configurations. - repeated string exclusive_patches = 3; -} - -// A step that runs an executable for a PatchJob. -message ExecStep { - // The ExecStepConfig for all Linux VMs targeted by the PatchJob. - ExecStepConfig linux_exec_step_config = 1; - - // The ExecStepConfig for all Windows VMs targeted by the PatchJob. - ExecStepConfig windows_exec_step_config = 2; -} - -// Common configurations for an ExecStep. -message ExecStepConfig { - // The interpreter used to execute the a file. - enum Interpreter { - // Invalid for a Windows ExecStepConfig. For a Linux ExecStepConfig, the - // interpreter will be parsed from the shebang line of the script if - // unspecified. - INTERPRETER_UNSPECIFIED = 0; - - // Indicates that the script is run with `/bin/sh` on Linux and `cmd` - // on Windows. - SHELL = 1; - - // Indicates that the file is run with PowerShell flags - // `-NonInteractive`, `-NoProfile`, and `-ExecutionPolicy Bypass`. - POWERSHELL = 2; - } - - // Location of the executable. - oneof executable { - // An absolute path to the executable on the VM. - string local_path = 1; - - // A Cloud Storage object containing the executable. - GcsObject gcs_object = 2; - } - - // Defaults to [0]. A list of possible return values that the - // execution can return to indicate a success. - repeated int32 allowed_success_codes = 3; - - // The script interpreter to use to run the script. If no interpreter is - // specified the script will be executed directly, which will likely - // only succeed for scripts with [shebang lines] - // (https://en.wikipedia.org/wiki/Shebang_\(Unix\)). - Interpreter interpreter = 4; -} - -// Cloud Storage object representation. -message GcsObject { - // Required. Bucket of the Cloud Storage object. - string bucket = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Name of the Cloud Storage object. - string object = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. Generation number of the Cloud Storage object. This is used to - // ensure that the ExecStep specified by this PatchJob does not change. - int64 generation_number = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// A filter to target VM instances for patching. The targeted -// VMs must meet all criteria specified. So if both labels and zones are -// specified, the patch job targets only VMs with those labels and in those -// zones. -message PatchInstanceFilter { - // Targets a group of VM instances by using their [assigned - // labels](https://cloud.google.com/compute/docs/labeling-resources). Labels - // are key-value pairs. A `GroupLabel` is a combination of labels - // that is used to target VMs for a patch job. - // - // For example, a patch job can target VMs that have the following - // `GroupLabel`: `{"env":"test", "app":"web"}`. This means that the patch job - // is applied to VMs that have both the labels `env=test` and `app=web`. - message GroupLabel { - // Compute Engine instance labels that must be present for a VM - // instance to be targeted by this filter. - map labels = 1; - } - - // Target all VM instances in the project. If true, no other criteria is - // permitted. - bool all = 1; - - // Targets VM instances matching ANY of these GroupLabels. This allows - // targeting of disparate groups of VM instances. - repeated GroupLabel group_labels = 2; - - // Targets VM instances in ANY of these zones. Leave empty to target VM - // instances in any zone. - repeated string zones = 3; - - // Targets any of the VM instances specified. Instances are specified by their - // URI in the form `zones/[ZONE]/instances/[INSTANCE_NAME]`, - // `projects/[PROJECT_ID]/zones/[ZONE]/instances/[INSTANCE_NAME]`, or - // `https://www.googleapis.com/compute/v1/projects/[PROJECT_ID]/zones/[ZONE]/instances/[INSTANCE_NAME]` - repeated string instances = 4; - - // Targets VMs whose name starts with one of these prefixes. Similar to - // labels, this is another way to group VMs when targeting configs, for - // example prefix="prod-". - repeated string instance_name_prefixes = 5; -} - -// Patch rollout configuration specifications. Contains details on the -// concurrency control when applying patch(es) to all targeted VMs. -message PatchRollout { - // Type of the rollout. - enum Mode { - // Mode must be specified. - MODE_UNSPECIFIED = 0; - - // Patches are applied one zone at a time. The patch job begins in the - // region with the lowest number of targeted VMs. Within the region, - // patching begins in the zone with the lowest number of targeted VMs. If - // multiple regions (or zones within a region) have the same number of - // targeted VMs, a tie-breaker is achieved by sorting the regions or zones - // in alphabetical order. - ZONE_BY_ZONE = 1; - - // Patches are applied to VMs in all zones at the same time. - CONCURRENT_ZONES = 2; - } - - // Mode of the patch rollout. - Mode mode = 1; - - // The maximum number (or percentage) of VMs per zone to disrupt at any given - // moment. The number of VMs calculated from multiplying the percentage by the - // total number of VMs in a zone is rounded up. - // - // During patching, a VM is considered disrupted from the time the agent is - // notified to begin until patching has completed. This disruption time - // includes the time to complete reboot and any post-patch steps. - // - // A VM contributes to the disruption budget if its patching operation fails - // either when applying the patches, running pre or post patch steps, or if it - // fails to respond with a success notification before timing out. VMs that - // are not running or do not have an active agent do not count toward this - // disruption budget. - // - // For zone-by-zone rollouts, if the disruption budget in a zone is exceeded, - // the patch job stops, because continuing to the next zone requires - // completion of the patch process in the previous zone. - // - // For example, if the disruption budget has a fixed value of `10`, and 8 VMs - // fail to patch in the current zone, the patch job continues to patch 2 VMs - // at a time until the zone is completed. When that zone is completed - // successfully, patching begins with 10 VMs at a time in the next zone. If 10 - // VMs in the next zone fail to patch, the patch job stops. - FixedOrPercent disruption_budget = 2; -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/vulnerability.proto b/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/vulnerability.proto deleted file mode 100644 index b758df3bad0..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/protos/google/cloud/osconfig/v1/vulnerability.proto +++ /dev/null @@ -1,365 +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.osconfig.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.OsConfig.V1"; -option go_package = "cloud.google.com/go/osconfig/apiv1/osconfigpb;osconfigpb"; -option java_multiple_files = true; -option java_outer_classname = "VulnerabilityProto"; -option java_package = "com.google.cloud.osconfig.v1"; -option php_namespace = "Google\\Cloud\\OsConfig\\V1"; -option ruby_package = "Google::Cloud::OsConfig::V1"; - -// This API resource represents the vulnerability report for a specified -// Compute Engine virtual machine (VM) instance at a given point in time. -// -// For more information, see [Vulnerability -// reports](https://cloud.google.com/compute/docs/instances/os-inventory-management#vulnerability-reports). -message VulnerabilityReport { - option (google.api.resource) = { - type: "osconfig.googleapis.com/VulnerabilityReport" - pattern: "projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport" - }; - - // A vulnerability affecting the VM instance. - message Vulnerability { - // Contains metadata information for the vulnerability. This information is - // collected from the upstream feed of the operating system. - message Details { - // A reference for this vulnerability. - message Reference { - // The url of the reference. - string url = 1; - - // The source of the reference e.g. NVD. - string source = 2; - } - - // The CVE of the vulnerability. CVE cannot be - // empty and the combination of should be unique - // across vulnerabilities for a VM. - string cve = 1; - - // The CVSS V2 score of this vulnerability. CVSS V2 score is on a scale of - // 0 - 10 where 0 indicates low severity and 10 indicates high severity. - float cvss_v2_score = 2; - - // The full description of the CVSSv3 for this vulnerability from NVD. - CVSSv3 cvss_v3 = 3; - - // Assigned severity/impact ranking from the distro. - string severity = 4; - - // The note or description describing the vulnerability from the distro. - string description = 5; - - // Corresponds to the references attached to the `VulnerabilityDetails`. - repeated Reference references = 6; - } - - // OS inventory item that is affected by a vulnerability or fixed as a - // result of a vulnerability. - message Item { - // Corresponds to the `INSTALLED_PACKAGE` inventory item on the VM. - // This field displays the inventory items affected by this vulnerability. - // If the vulnerability report was not updated after the VM inventory - // update, these values might not display in VM inventory. For some - // operating systems, this field might be empty. - string installed_inventory_item_id = 1; - - // Corresponds to the `AVAILABLE_PACKAGE` inventory item on the VM. - // If the vulnerability report was not updated after the VM inventory - // update, these values might not display in VM inventory. If there is no - // available fix, the field is empty. The `inventory_item` value specifies - // the latest `SoftwarePackage` available to the VM that fixes the - // vulnerability. - string available_inventory_item_id = 2; - - // The recommended [CPE URI](https://cpe.mitre.org/specification/) update - // that contains a fix for this vulnerability. - string fixed_cpe_uri = 3; - - // The upstream OS patch, packages or KB that fixes the vulnerability. - string upstream_fix = 4; - } - - // Contains metadata as per the upstream feed of the operating system and - // NVD. - Details details = 1; - - // Corresponds to the `INSTALLED_PACKAGE` inventory item on the VM. - // This field displays the inventory items affected by this vulnerability. - // If the vulnerability report was not updated after the VM inventory - // update, these values might not display in VM inventory. For some distros, - // this field may be empty. - repeated string installed_inventory_item_ids = 2 [deprecated = true]; - - // Corresponds to the `AVAILABLE_PACKAGE` inventory item on the VM. - // If the vulnerability report was not updated after the VM inventory - // update, these values might not display in VM inventory. If there is no - // available fix, the field is empty. The `inventory_item` value specifies - // the latest `SoftwarePackage` available to the VM that fixes the - // vulnerability. - repeated string available_inventory_item_ids = 3 [deprecated = true]; - - // The timestamp for when the vulnerability was first detected. - google.protobuf.Timestamp create_time = 4; - - // The timestamp for when the vulnerability was last modified. - google.protobuf.Timestamp update_time = 5; - - // List of items affected by the vulnerability. - repeated Item items = 6; - } - - // Output only. The `vulnerabilityReport` API resource name. - // - // Format: - // `projects/{project_number}/locations/{location}/instances/{instance_id}/vulnerabilityReport` - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. List of vulnerabilities affecting the VM. - repeated Vulnerability vulnerabilities = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The timestamp for when the last vulnerability report was generated for the - // VM. - google.protobuf.Timestamp update_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A request message for getting the vulnerability report for the specified VM. -message GetVulnerabilityReportRequest { - // Required. API resource name for vulnerability resource. - // - // Format: - // `projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport` - // - // For `{project}`, either `project-number` or `project-id` can be provided. - // For `{instance}`, either Compute Engine `instance-id` or `instance-name` - // can be provided. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/VulnerabilityReport" - } - ]; -} - -// A request message for listing vulnerability reports for all VM instances in -// the specified location. -message ListVulnerabilityReportsRequest { - // Required. The parent resource name. - // - // Format: `projects/{project}/locations/{location}/instances/-` - // - // For `{project}`, either `project-number` or `project-id` can be provided. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "compute.googleapis.com/Instance" - } - ]; - - // The maximum number of results to return. - int32 page_size = 2; - - // A pagination token returned from a previous call to - // `ListVulnerabilityReports` that indicates where this listing - // should continue from. - string page_token = 3; - - // If provided, this field specifies the criteria that must be met by a - // `vulnerabilityReport` API resource to be included in the response. - string filter = 4; -} - -// A response message for listing vulnerability reports for all VM instances in -// the specified location. -message ListVulnerabilityReportsResponse { - // List of vulnerabilityReport objects. - repeated VulnerabilityReport vulnerability_reports = 1; - - // The pagination token to retrieve the next page of vulnerabilityReports - // object. - string next_page_token = 2; -} - -// Common Vulnerability Scoring System version 3. -// For details, see https://www.first.org/cvss/specification-document -message CVSSv3 { - // This metric reflects the context by which vulnerability exploitation is - // possible. - enum AttackVector { - // Invalid value. - ATTACK_VECTOR_UNSPECIFIED = 0; - - // The vulnerable component is bound to the network stack and the set of - // possible attackers extends beyond the other options listed below, up to - // and including the entire Internet. - ATTACK_VECTOR_NETWORK = 1; - - // The vulnerable component is bound to the network stack, but the attack is - // limited at the protocol level to a logically adjacent topology. - ATTACK_VECTOR_ADJACENT = 2; - - // The vulnerable component is not bound to the network stack and the - // attacker's path is via read/write/execute capabilities. - ATTACK_VECTOR_LOCAL = 3; - - // The attack requires the attacker to physically touch or manipulate the - // vulnerable component. - ATTACK_VECTOR_PHYSICAL = 4; - } - - // This metric describes the conditions beyond the attacker's control that - // must exist in order to exploit the vulnerability. - enum AttackComplexity { - // Invalid value. - ATTACK_COMPLEXITY_UNSPECIFIED = 0; - - // Specialized access conditions or extenuating circumstances do not exist. - // An attacker can expect repeatable success when attacking the vulnerable - // component. - ATTACK_COMPLEXITY_LOW = 1; - - // A successful attack depends on conditions beyond the attacker's control. - // That is, a successful attack cannot be accomplished at will, but requires - // the attacker to invest in some measurable amount of effort in preparation - // or execution against the vulnerable component before a successful attack - // can be expected. - ATTACK_COMPLEXITY_HIGH = 2; - } - - // This metric describes the level of privileges an attacker must possess - // before successfully exploiting the vulnerability. - enum PrivilegesRequired { - // Invalid value. - PRIVILEGES_REQUIRED_UNSPECIFIED = 0; - - // The attacker is unauthorized prior to attack, and therefore does not - // require any access to settings or files of the vulnerable system to - // carry out an attack. - PRIVILEGES_REQUIRED_NONE = 1; - - // The attacker requires privileges that provide basic user capabilities - // that could normally affect only settings and files owned by a user. - // Alternatively, an attacker with Low privileges has the ability to access - // only non-sensitive resources. - PRIVILEGES_REQUIRED_LOW = 2; - - // The attacker requires privileges that provide significant (e.g., - // administrative) control over the vulnerable component allowing access to - // component-wide settings and files. - PRIVILEGES_REQUIRED_HIGH = 3; - } - - // This metric captures the requirement for a human user, other than the - // attacker, to participate in the successful compromise of the vulnerable - // component. - enum UserInteraction { - // Invalid value. - USER_INTERACTION_UNSPECIFIED = 0; - - // The vulnerable system can be exploited without interaction from any user. - USER_INTERACTION_NONE = 1; - - // Successful exploitation of this vulnerability requires a user to take - // some action before the vulnerability can be exploited. - USER_INTERACTION_REQUIRED = 2; - } - - // The Scope metric captures whether a vulnerability in one vulnerable - // component impacts resources in components beyond its security scope. - enum Scope { - // Invalid value. - SCOPE_UNSPECIFIED = 0; - - // An exploited vulnerability can only affect resources managed by the same - // security authority. - SCOPE_UNCHANGED = 1; - - // An exploited vulnerability can affect resources beyond the security scope - // managed by the security authority of the vulnerable component. - SCOPE_CHANGED = 2; - } - - // The Impact metrics capture the effects of a successfully exploited - // vulnerability on the component that suffers the worst outcome that is most - // directly and predictably associated with the attack. - enum Impact { - // Invalid value. - IMPACT_UNSPECIFIED = 0; - - // High impact. - IMPACT_HIGH = 1; - - // Low impact. - IMPACT_LOW = 2; - - // No impact. - IMPACT_NONE = 3; - } - - // The base score is a function of the base metric scores. - // https://www.first.org/cvss/specification-document#Base-Metrics - float base_score = 1; - - // The Exploitability sub-score equation is derived from the Base - // Exploitability metrics. - // https://www.first.org/cvss/specification-document#2-1-Exploitability-Metrics - float exploitability_score = 2; - - // The Impact sub-score equation is derived from the Base Impact metrics. - float impact_score = 3; - - // This metric reflects the context by which vulnerability exploitation is - // possible. - AttackVector attack_vector = 5; - - // This metric describes the conditions beyond the attacker's control that - // must exist in order to exploit the vulnerability. - AttackComplexity attack_complexity = 6; - - // This metric describes the level of privileges an attacker must possess - // before successfully exploiting the vulnerability. - PrivilegesRequired privileges_required = 7; - - // This metric captures the requirement for a human user, other than the - // attacker, to participate in the successful compromise of the vulnerable - // component. - UserInteraction user_interaction = 8; - - // The Scope metric captures whether a vulnerability in one vulnerable - // component impacts resources in components beyond its security scope. - Scope scope = 9; - - // This metric measures the impact to the confidentiality of the information - // resources managed by a software component due to a successfully exploited - // vulnerability. - Impact confidentiality_impact = 10; - - // This metric measures the impact to integrity of a successfully exploited - // vulnerability. - Impact integrity_impact = 11; - - // This metric measures the impact to the availability of the impacted - // component resulting from a successfully exploited vulnerability. - Impact availability_impact = 12; -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.cancel_patch_job.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.cancel_patch_job.js deleted file mode 100644 index b9d729c0c60..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.cancel_patch_job.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(name) { - // [START osconfig_v1_generated_OsConfigService_CancelPatchJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the patch in the form `projects/* /patchJobs/*` - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callCancelPatchJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.cancelPatchJob(request); - console.log(response); - } - - callCancelPatchJob(); - // [END osconfig_v1_generated_OsConfigService_CancelPatchJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.create_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.create_patch_deployment.js deleted file mode 100644 index 7fcba165f80..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.create_patch_deployment.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(parent, patchDeploymentId, patchDeployment) { - // [START osconfig_v1_generated_OsConfigService_CreatePatchDeployment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project to apply this patch deployment to in the form - * `projects/*`. - */ - // const parent = 'abc123' - /** - * Required. A name for the patch deployment in the project. When creating a - * name the following rules apply: - * * Must contain only lowercase letters, numbers, and hyphens. - * * Must start with a letter. - * * Must be between 1-63 characters. - * * Must end with a number or a letter. - * * Must be unique within the project. - */ - // const patchDeploymentId = 'abc123' - /** - * Required. The patch deployment to create. - */ - // const patchDeployment = {} - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callCreatePatchDeployment() { - // Construct request - const request = { - parent, - patchDeploymentId, - patchDeployment, - }; - - // Run request - const response = await osconfigClient.createPatchDeployment(request); - console.log(response); - } - - callCreatePatchDeployment(); - // [END osconfig_v1_generated_OsConfigService_CreatePatchDeployment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.delete_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.delete_patch_deployment.js deleted file mode 100644 index 537f6e48d7c..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.delete_patch_deployment.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 osconfig_v1_generated_OsConfigService_DeletePatchDeployment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 patch deployment in the form - * `projects/* /patchDeployments/*`. - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callDeletePatchDeployment() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.deletePatchDeployment(request); - console.log(response); - } - - callDeletePatchDeployment(); - // [END osconfig_v1_generated_OsConfigService_DeletePatchDeployment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.execute_patch_job.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.execute_patch_job.js deleted file mode 100644 index 2a8842423d3..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.execute_patch_job.js +++ /dev/null @@ -1,95 +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, instanceFilter) { - // [START osconfig_v1_generated_OsConfigService_ExecutePatchJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project in which to run this patch in the form `projects/*` - */ - // const parent = 'abc123' - /** - * Description of the patch job. Length of the description is limited - * to 1024 characters. - */ - // const description = 'abc123' - /** - * Required. Instances to patch, either explicitly or filtered by some - * criteria such as zone or labels. - */ - // const instanceFilter = {} - /** - * Patch configuration being applied. If omitted, instances are - * patched using the default configurations. - */ - // const patchConfig = {} - /** - * Duration of the patch job. After the duration ends, the patch job - * times out. - */ - // const duration = {} - /** - * If this patch is a dry-run only, instances are contacted but - * will do nothing. - */ - // const dryRun = true - /** - * Display name for this patch job. This does not have to be unique. - */ - // const displayName = 'abc123' - /** - * Rollout strategy of the patch job. - */ - // const rollout = {} - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callExecutePatchJob() { - // Construct request - const request = { - parent, - instanceFilter, - }; - - // Run request - const response = await osconfigClient.executePatchJob(request); - console.log(response); - } - - callExecutePatchJob(); - // [END osconfig_v1_generated_OsConfigService_ExecutePatchJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.get_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.get_patch_deployment.js deleted file mode 100644 index 15ed3690f68..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.get_patch_deployment.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 osconfig_v1_generated_OsConfigService_GetPatchDeployment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 patch deployment in the form - * `projects/* /patchDeployments/*`. - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callGetPatchDeployment() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.getPatchDeployment(request); - console.log(response); - } - - callGetPatchDeployment(); - // [END osconfig_v1_generated_OsConfigService_GetPatchDeployment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.get_patch_job.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.get_patch_job.js deleted file mode 100644 index 84e912df0f3..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.get_patch_job.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(name) { - // [START osconfig_v1_generated_OsConfigService_GetPatchJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the patch in the form `projects/* /patchJobs/*` - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callGetPatchJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.getPatchJob(request); - console.log(response); - } - - callGetPatchJob(); - // [END osconfig_v1_generated_OsConfigService_GetPatchJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_deployments.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_deployments.js deleted file mode 100644 index a989ab56e49..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_deployments.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) { - // [START osconfig_v1_generated_OsConfigService_ListPatchDeployments_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 parent in the form `projects/*`. - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of patch deployments to return. Default is - * 100. - */ - // const pageSize = 1234 - /** - * Optional. A pagination token returned from a previous call to - * ListPatchDeployments that indicates where this listing should continue - * from. - */ - // const pageToken = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callListPatchDeployments() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await osconfigClient.listPatchDeploymentsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListPatchDeployments(); - // [END osconfig_v1_generated_OsConfigService_ListPatchDeployments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_job_instance_details.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_job_instance_details.js deleted file mode 100644 index a4917b249e2..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_job_instance_details.js +++ /dev/null @@ -1,79 +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 osconfig_v1_generated_OsConfigService_ListPatchJobInstanceDetails_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 the instances are in the form of - * `projects/* /patchJobs/*`. - */ - // const parent = 'abc123' - /** - * The maximum number of instance details records to return. Default is 100. - */ - // const pageSize = 1234 - /** - * A pagination token returned from a previous call - * that indicates where this listing should continue from. - */ - // const pageToken = 'abc123' - /** - * A filter expression that filters results listed in the response. This - * field supports filtering results by instance zone, name, state, or - * `failure_reason`. - */ - // const filter = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callListPatchJobInstanceDetails() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await osconfigClient.listPatchJobInstanceDetailsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListPatchJobInstanceDetails(); - // [END osconfig_v1_generated_OsConfigService_ListPatchJobInstanceDetails_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_jobs.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_jobs.js deleted file mode 100644 index 58b11f4f54e..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.list_patch_jobs.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(parent) { - // [START osconfig_v1_generated_OsConfigService_ListPatchJobs_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. In the form of `projects/*` - */ - // const parent = 'abc123' - /** - * The maximum number of instance status to return. - */ - // const pageSize = 1234 - /** - * A pagination token returned from a previous call - * that indicates where this listing should continue from. - */ - // const pageToken = 'abc123' - /** - * If provided, this field specifies the criteria that must be met by patch - * jobs to be included in the response. - * Currently, filtering is only available on the patch_deployment field. - */ - // const filter = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callListPatchJobs() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await osconfigClient.listPatchJobsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListPatchJobs(); - // [END osconfig_v1_generated_OsConfigService_ListPatchJobs_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.pause_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.pause_patch_deployment.js deleted file mode 100644 index a88e66cc65b..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.pause_patch_deployment.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 osconfig_v1_generated_OsConfigService_PausePatchDeployment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 patch deployment in the form - * `projects/* /patchDeployments/*`. - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callPausePatchDeployment() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.pausePatchDeployment(request); - console.log(response); - } - - callPausePatchDeployment(); - // [END osconfig_v1_generated_OsConfigService_PausePatchDeployment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.resume_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.resume_patch_deployment.js deleted file mode 100644 index 83c2f051d49..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.resume_patch_deployment.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 osconfig_v1_generated_OsConfigService_ResumePatchDeployment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 patch deployment in the form - * `projects/* /patchDeployments/*`. - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callResumePatchDeployment() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.resumePatchDeployment(request); - console.log(response); - } - - callResumePatchDeployment(); - // [END osconfig_v1_generated_OsConfigService_ResumePatchDeployment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.update_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.update_patch_deployment.js deleted file mode 100644 index e32fa998d9c..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_service.update_patch_deployment.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(patchDeployment) { - // [START osconfig_v1_generated_OsConfigService_UpdatePatchDeployment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The patch deployment to Update. - */ - // const patchDeployment = {} - /** - * Optional. Field mask that controls which fields of the patch deployment - * should be updated. - */ - // const updateMask = {} - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callUpdatePatchDeployment() { - // Construct request - const request = { - patchDeployment, - }; - - // Run request - const response = await osconfigClient.updatePatchDeployment(request); - console.log(response); - } - - callUpdatePatchDeployment(); - // [END osconfig_v1_generated_OsConfigService_UpdatePatchDeployment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.create_o_s_policy_assignment.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.create_o_s_policy_assignment.js deleted file mode 100644 index 3c3df85f187..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.create_o_s_policy_assignment.js +++ /dev/null @@ -1,79 +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, osPolicyAssignment, osPolicyAssignmentId) { - // [START osconfig_v1_generated_OsConfigZonalService_CreateOSPolicyAssignment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 name in the form: - * projects/{project}/locations/{location} - */ - // const parent = 'abc123' - /** - * Required. The OS policy assignment to be created. - */ - // const osPolicyAssignment = {} - /** - * Required. The logical name of the OS policy assignment in the project - * with the following restrictions: - * * Must contain only lowercase letters, numbers, and hyphens. - * * Must start with a letter. - * * Must be between 1-63 characters. - * * Must end with a number or a letter. - * * Must be unique within the project. - */ - // const osPolicyAssignmentId = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callCreateOSPolicyAssignment() { - // Construct request - const request = { - parent, - osPolicyAssignment, - osPolicyAssignmentId, - }; - - // Run request - const [operation] = await osconfigClient.createOSPolicyAssignment(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateOSPolicyAssignment(); - // [END osconfig_v1_generated_OsConfigZonalService_CreateOSPolicyAssignment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.delete_o_s_policy_assignment.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.delete_o_s_policy_assignment.js deleted file mode 100644 index 76c61ae929c..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.delete_o_s_policy_assignment.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 osconfig_v1_generated_OsConfigZonalService_DeleteOSPolicyAssignment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 OS policy assignment to be deleted - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callDeleteOSPolicyAssignment() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await osconfigClient.deleteOSPolicyAssignment(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteOSPolicyAssignment(); - // [END osconfig_v1_generated_OsConfigZonalService_DeleteOSPolicyAssignment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_inventory.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_inventory.js deleted file mode 100644 index 328ffd61766..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_inventory.js +++ /dev/null @@ -1,71 +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 osconfig_v1_generated_OsConfigZonalService_GetInventory_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. API resource name for inventory resource. - * Format: - * `projects/{project}/locations/{location}/instances/{instance}/inventory` - * For `{project}`, either `project-number` or `project-id` can be provided. - * For `{instance}`, either Compute Engine `instance-id` or `instance-name` - * can be provided. - */ - // const name = 'abc123' - /** - * Inventory view indicating what information should be included in the - * inventory resource. If unspecified, the default view is BASIC. - */ - // const view = {} - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callGetInventory() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.getInventory(request); - console.log(response); - } - - callGetInventory(); - // [END osconfig_v1_generated_OsConfigZonalService_GetInventory_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_o_s_policy_assignment.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_o_s_policy_assignment.js deleted file mode 100644 index 8e63c0b595f..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_o_s_policy_assignment.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 osconfig_v1_generated_OsConfigZonalService_GetOSPolicyAssignment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 OS policy assignment. - * Format: - * `projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}@{revisionId}` - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callGetOSPolicyAssignment() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.getOSPolicyAssignment(request); - console.log(response); - } - - callGetOSPolicyAssignment(); - // [END osconfig_v1_generated_OsConfigZonalService_GetOSPolicyAssignment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_o_s_policy_assignment_report.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_o_s_policy_assignment_report.js deleted file mode 100644 index 40a48f03380..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_o_s_policy_assignment_report.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(name) { - // [START osconfig_v1_generated_OsConfigZonalService_GetOSPolicyAssignmentReport_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. API resource name for OS policy assignment report. - * Format: - * `/projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report` - * For `{project}`, either `project-number` or `project-id` can be provided. - * For `{instance_id}`, either Compute Engine `instance-id` or `instance-name` - * can be provided. - * For `{assignment_id}`, the OSPolicyAssignment id must be provided. - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callGetOSPolicyAssignmentReport() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.getOSPolicyAssignmentReport(request); - console.log(response); - } - - callGetOSPolicyAssignmentReport(); - // [END osconfig_v1_generated_OsConfigZonalService_GetOSPolicyAssignmentReport_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_vulnerability_report.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_vulnerability_report.js deleted file mode 100644 index c66f01a4e4a..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.get_vulnerability_report.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(name) { - // [START osconfig_v1_generated_OsConfigZonalService_GetVulnerabilityReport_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. API resource name for vulnerability resource. - * Format: - * `projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport` - * For `{project}`, either `project-number` or `project-id` can be provided. - * For `{instance}`, either Compute Engine `instance-id` or `instance-name` - * can be provided. - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callGetVulnerabilityReport() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.getVulnerabilityReport(request); - console.log(response); - } - - callGetVulnerabilityReport(); - // [END osconfig_v1_generated_OsConfigZonalService_GetVulnerabilityReport_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_inventories.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_inventories.js deleted file mode 100644 index 06e9b90425e..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_inventories.js +++ /dev/null @@ -1,85 +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 osconfig_v1_generated_OsConfigZonalService_ListInventories_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 name. - * Format: `projects/{project}/locations/{location}/instances/-` - * For `{project}`, either `project-number` or `project-id` can be provided. - */ - // const parent = 'abc123' - /** - * Inventory view indicating what information should be included in the - * inventory resource. If unspecified, the default view is BASIC. - */ - // const view = {} - /** - * The maximum number of results to return. - */ - // const pageSize = 1234 - /** - * A pagination token returned from a previous call to - * `ListInventories` that indicates where this listing - * should continue from. - */ - // const pageToken = 'abc123' - /** - * If provided, this field specifies the criteria that must be met by a - * `Inventory` API resource to be included in the response. - */ - // const filter = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callListInventories() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await osconfigClient.listInventoriesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListInventories(); - // [END osconfig_v1_generated_OsConfigZonalService_ListInventories_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignment_reports.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignment_reports.js deleted file mode 100644 index e144aa4e272..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignment_reports.js +++ /dev/null @@ -1,95 +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 osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignmentReports_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 name. - * Format: - * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/reports` - * For `{project}`, either `project-number` or `project-id` can be provided. - * For `{instance}`, either `instance-name`, `instance-id`, or `-` can be - * provided. If '-' is provided, the response will include - * OSPolicyAssignmentReports for all instances in the project/location. - * For `{assignment}`, either `assignment-id` or `-` can be provided. If '-' - * is provided, the response will include OSPolicyAssignmentReports for all - * OSPolicyAssignments in the project/location. - * Either {instance} or {assignment} must be `-`. - * For example: - * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/-/reports` - * returns all reports for the instance - * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/{assignment-id}/reports` - * returns all the reports for the given assignment across all instances. - * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/-/reports` - * returns all the reports for all assignments across all instances. - */ - // const parent = 'abc123' - /** - * The maximum number of results to return. - */ - // const pageSize = 1234 - /** - * If provided, this field specifies the criteria that must be met by the - * `OSPolicyAssignmentReport` API resource that is included in the response. - */ - // const filter = 'abc123' - /** - * A pagination token returned from a previous call to the - * `ListOSPolicyAssignmentReports` method that indicates where this listing - * should continue from. - */ - // const pageToken = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callListOSPolicyAssignmentReports() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await osconfigClient.listOSPolicyAssignmentReportsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListOSPolicyAssignmentReports(); - // [END osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignmentReports_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignment_revisions.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignment_revisions.js deleted file mode 100644 index a09e5e812ed..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignment_revisions.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(name) { - // [START osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignmentRevisions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 OS policy assignment to list revisions for. - */ - // const name = 'abc123' - /** - * The maximum number of revisions to return. - */ - // const pageSize = 1234 - /** - * A pagination token returned from a previous call to - * `ListOSPolicyAssignmentRevisions` that indicates where this listing should - * continue from. - */ - // const pageToken = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callListOSPolicyAssignmentRevisions() { - // Construct request - const request = { - name, - }; - - // Run request - const iterable = await osconfigClient.listOSPolicyAssignmentRevisionsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListOSPolicyAssignmentRevisions(); - // [END osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignmentRevisions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignments.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignments.js deleted file mode 100644 index 7e18fc2ba10..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignments.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(parent) { - // [START osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignments_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 name. - */ - // const parent = 'abc123' - /** - * The maximum number of assignments to return. - */ - // const pageSize = 1234 - /** - * A pagination token returned from a previous call to - * `ListOSPolicyAssignments` that indicates where this listing should continue - * from. - */ - // const pageToken = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callListOSPolicyAssignments() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await osconfigClient.listOSPolicyAssignmentsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListOSPolicyAssignments(); - // [END osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_vulnerability_reports.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_vulnerability_reports.js deleted file mode 100644 index 869997ad2d3..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.list_vulnerability_reports.js +++ /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. ** - - - -'use strict'; - -function main(parent) { - // [START osconfig_v1_generated_OsConfigZonalService_ListVulnerabilityReports_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 name. - * Format: `projects/{project}/locations/{location}/instances/-` - * For `{project}`, either `project-number` or `project-id` can be provided. - */ - // const parent = 'abc123' - /** - * The maximum number of results to return. - */ - // const pageSize = 1234 - /** - * A pagination token returned from a previous call to - * `ListVulnerabilityReports` that indicates where this listing - * should continue from. - */ - // const pageToken = 'abc123' - /** - * If provided, this field specifies the criteria that must be met by a - * `vulnerabilityReport` API resource to be included in the response. - */ - // const filter = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callListVulnerabilityReports() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await osconfigClient.listVulnerabilityReportsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListVulnerabilityReports(); - // [END osconfig_v1_generated_OsConfigZonalService_ListVulnerabilityReports_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.update_o_s_policy_assignment.js b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.update_o_s_policy_assignment.js deleted file mode 100644 index bc2d193410d..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/os_config_zonal_service.update_o_s_policy_assignment.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(osPolicyAssignment) { - // [START osconfig_v1_generated_OsConfigZonalService_UpdateOSPolicyAssignment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The updated OS policy assignment. - */ - // const osPolicyAssignment = {} - /** - * Optional. Field mask that controls which fields of the assignment should be - * updated. - */ - // const updateMask = {} - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callUpdateOSPolicyAssignment() { - // Construct request - const request = { - osPolicyAssignment, - }; - - // Run request - const [operation] = await osconfigClient.updateOSPolicyAssignment(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateOSPolicyAssignment(); - // [END osconfig_v1_generated_OsConfigZonalService_UpdateOSPolicyAssignment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/snippet_metadata_google.cloud.osconfig.v1.json b/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/snippet_metadata_google.cloud.osconfig.v1.json deleted file mode 100644 index e874ee38a66..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/samples/generated/v1/snippet_metadata_google.cloud.osconfig.v1.json +++ /dev/null @@ -1,1119 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-osconfig", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.osconfig.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "osconfig_v1_generated_OsConfigService_ExecutePatchJob_async", - "title": "OsConfigServiceClient executePatchJob Sample", - "origin": "API_DEFINITION", - "description": " Patch VM instances by creating and running a patch job.", - "canonical": true, - "file": "os_config_service.execute_patch_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 87, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ExecutePatchJob", - "fullName": "google.cloud.osconfig.v1.OsConfigService.ExecutePatchJob", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "description", - "type": "TYPE_STRING" - }, - { - "name": "instance_filter", - "type": ".google.cloud.osconfig.v1.PatchInstanceFilter" - }, - { - "name": "patch_config", - "type": ".google.cloud.osconfig.v1.PatchConfig" - }, - { - "name": "duration", - "type": ".google.protobuf.Duration" - }, - { - "name": "dry_run", - "type": "TYPE_BOOL" - }, - { - "name": "display_name", - "type": "TYPE_STRING" - }, - { - "name": "rollout", - "type": ".google.cloud.osconfig.v1.PatchRollout" - } - ], - "resultType": ".google.cloud.osconfig.v1.PatchJob", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" - }, - "method": { - "shortName": "ExecutePatchJob", - "fullName": "google.cloud.osconfig.v1.OsConfigService.ExecutePatchJob", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigService_GetPatchJob_async", - "title": "OsConfigServiceClient getPatchJob Sample", - "origin": "API_DEFINITION", - "description": " Get the patch job. This can be used to track the progress of an ongoing patch job or review the details of completed jobs.", - "canonical": true, - "file": "os_config_service.get_patch_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetPatchJob", - "fullName": "google.cloud.osconfig.v1.OsConfigService.GetPatchJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1.PatchJob", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" - }, - "method": { - "shortName": "GetPatchJob", - "fullName": "google.cloud.osconfig.v1.OsConfigService.GetPatchJob", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigService_CancelPatchJob_async", - "title": "OsConfigServiceClient cancelPatchJob Sample", - "origin": "API_DEFINITION", - "description": " Cancel a patch job. The patch job must be active. Canceled patch jobs cannot be restarted.", - "canonical": true, - "file": "os_config_service.cancel_patch_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CancelPatchJob", - "fullName": "google.cloud.osconfig.v1.OsConfigService.CancelPatchJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1.PatchJob", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" - }, - "method": { - "shortName": "CancelPatchJob", - "fullName": "google.cloud.osconfig.v1.OsConfigService.CancelPatchJob", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigService_ListPatchJobs_async", - "title": "OsConfigServiceClient listPatchJobs Sample", - "origin": "API_DEFINITION", - "description": " Get a list of patch jobs.", - "canonical": true, - "file": "os_config_service.list_patch_jobs.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListPatchJobs", - "fullName": "google.cloud.osconfig.v1.OsConfigService.ListPatchJobs", - "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.osconfig.v1.ListPatchJobsResponse", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" - }, - "method": { - "shortName": "ListPatchJobs", - "fullName": "google.cloud.osconfig.v1.OsConfigService.ListPatchJobs", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigService_ListPatchJobInstanceDetails_async", - "title": "OsConfigServiceClient listPatchJobInstanceDetails Sample", - "origin": "API_DEFINITION", - "description": " Get a list of instance details for a given patch job.", - "canonical": true, - "file": "os_config_service.list_patch_job_instance_details.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListPatchJobInstanceDetails", - "fullName": "google.cloud.osconfig.v1.OsConfigService.ListPatchJobInstanceDetails", - "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.osconfig.v1.ListPatchJobInstanceDetailsResponse", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" - }, - "method": { - "shortName": "ListPatchJobInstanceDetails", - "fullName": "google.cloud.osconfig.v1.OsConfigService.ListPatchJobInstanceDetails", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigService_CreatePatchDeployment_async", - "title": "OsConfigServiceClient createPatchDeployment Sample", - "origin": "API_DEFINITION", - "description": " Create an OS Config patch deployment.", - "canonical": true, - "file": "os_config_service.create_patch_deployment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreatePatchDeployment", - "fullName": "google.cloud.osconfig.v1.OsConfigService.CreatePatchDeployment", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "patch_deployment_id", - "type": "TYPE_STRING" - }, - { - "name": "patch_deployment", - "type": ".google.cloud.osconfig.v1.PatchDeployment" - } - ], - "resultType": ".google.cloud.osconfig.v1.PatchDeployment", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" - }, - "method": { - "shortName": "CreatePatchDeployment", - "fullName": "google.cloud.osconfig.v1.OsConfigService.CreatePatchDeployment", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigService_GetPatchDeployment_async", - "title": "OsConfigServiceClient getPatchDeployment Sample", - "origin": "API_DEFINITION", - "description": " Get an OS Config patch deployment.", - "canonical": true, - "file": "os_config_service.get_patch_deployment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetPatchDeployment", - "fullName": "google.cloud.osconfig.v1.OsConfigService.GetPatchDeployment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1.PatchDeployment", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" - }, - "method": { - "shortName": "GetPatchDeployment", - "fullName": "google.cloud.osconfig.v1.OsConfigService.GetPatchDeployment", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigService_ListPatchDeployments_async", - "title": "OsConfigServiceClient listPatchDeployments Sample", - "origin": "API_DEFINITION", - "description": " Get a page of OS Config patch deployments.", - "canonical": true, - "file": "os_config_service.list_patch_deployments.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListPatchDeployments", - "fullName": "google.cloud.osconfig.v1.OsConfigService.ListPatchDeployments", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1.ListPatchDeploymentsResponse", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" - }, - "method": { - "shortName": "ListPatchDeployments", - "fullName": "google.cloud.osconfig.v1.OsConfigService.ListPatchDeployments", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigService_DeletePatchDeployment_async", - "title": "OsConfigServiceClient deletePatchDeployment Sample", - "origin": "API_DEFINITION", - "description": " Delete an OS Config patch deployment.", - "canonical": true, - "file": "os_config_service.delete_patch_deployment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeletePatchDeployment", - "fullName": "google.cloud.osconfig.v1.OsConfigService.DeletePatchDeployment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" - }, - "method": { - "shortName": "DeletePatchDeployment", - "fullName": "google.cloud.osconfig.v1.OsConfigService.DeletePatchDeployment", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigService_UpdatePatchDeployment_async", - "title": "OsConfigServiceClient updatePatchDeployment Sample", - "origin": "API_DEFINITION", - "description": " Update an OS Config patch deployment.", - "canonical": true, - "file": "os_config_service.update_patch_deployment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdatePatchDeployment", - "fullName": "google.cloud.osconfig.v1.OsConfigService.UpdatePatchDeployment", - "async": true, - "parameters": [ - { - "name": "patch_deployment", - "type": ".google.cloud.osconfig.v1.PatchDeployment" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.osconfig.v1.PatchDeployment", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" - }, - "method": { - "shortName": "UpdatePatchDeployment", - "fullName": "google.cloud.osconfig.v1.OsConfigService.UpdatePatchDeployment", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigService_PausePatchDeployment_async", - "title": "OsConfigServiceClient pausePatchDeployment Sample", - "origin": "API_DEFINITION", - "description": " Change state of patch deployment to \"PAUSED\". Patch deployment in paused state doesn't generate patch jobs.", - "canonical": true, - "file": "os_config_service.pause_patch_deployment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PausePatchDeployment", - "fullName": "google.cloud.osconfig.v1.OsConfigService.PausePatchDeployment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1.PatchDeployment", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" - }, - "method": { - "shortName": "PausePatchDeployment", - "fullName": "google.cloud.osconfig.v1.OsConfigService.PausePatchDeployment", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigService_ResumePatchDeployment_async", - "title": "OsConfigServiceClient resumePatchDeployment Sample", - "origin": "API_DEFINITION", - "description": " Change state of patch deployment back to \"ACTIVE\". Patch deployment in active state continues to generate patch jobs.", - "canonical": true, - "file": "os_config_service.resume_patch_deployment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ResumePatchDeployment", - "fullName": "google.cloud.osconfig.v1.OsConfigService.ResumePatchDeployment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1.PatchDeployment", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigServiceClient" - }, - "method": { - "shortName": "ResumePatchDeployment", - "fullName": "google.cloud.osconfig.v1.OsConfigService.ResumePatchDeployment", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigZonalService_CreateOSPolicyAssignment_async", - "title": "OsConfigServiceClient createOSPolicyAssignment Sample", - "origin": "API_DEFINITION", - "description": " Create an OS policy assignment. This method also creates the first revision of the OS policy assignment. This method returns a long running operation (LRO) that contains the rollout details. The rollout can be cancelled by cancelling the LRO. For more information, see [Method: projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel).", - "canonical": true, - "file": "os_config_zonal_service.create_o_s_policy_assignment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateOSPolicyAssignment", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.CreateOSPolicyAssignment", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "os_policy_assignment", - "type": ".google.cloud.osconfig.v1.OSPolicyAssignment" - }, - { - "name": "os_policy_assignment_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "CreateOSPolicyAssignment", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.CreateOSPolicyAssignment", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigZonalService_UpdateOSPolicyAssignment_async", - "title": "OsConfigServiceClient updateOSPolicyAssignment Sample", - "origin": "API_DEFINITION", - "description": " Update an existing OS policy assignment. This method creates a new revision of the OS policy assignment. This method returns a long running operation (LRO) that contains the rollout details. The rollout can be cancelled by cancelling the LRO. For more information, see [Method: projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel).", - "canonical": true, - "file": "os_config_zonal_service.update_o_s_policy_assignment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateOSPolicyAssignment", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.UpdateOSPolicyAssignment", - "async": true, - "parameters": [ - { - "name": "os_policy_assignment", - "type": ".google.cloud.osconfig.v1.OSPolicyAssignment" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "UpdateOSPolicyAssignment", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.UpdateOSPolicyAssignment", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigZonalService_GetOSPolicyAssignment_async", - "title": "OsConfigServiceClient getOSPolicyAssignment Sample", - "origin": "API_DEFINITION", - "description": " Retrieve an existing OS policy assignment. This method always returns the latest revision. In order to retrieve a previous revision of the assignment, also provide the revision ID in the `name` parameter.", - "canonical": true, - "file": "os_config_zonal_service.get_o_s_policy_assignment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetOSPolicyAssignment", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.GetOSPolicyAssignment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1.OSPolicyAssignment", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "GetOSPolicyAssignment", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.GetOSPolicyAssignment", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignments_async", - "title": "OsConfigServiceClient listOSPolicyAssignments Sample", - "origin": "API_DEFINITION", - "description": " List the OS policy assignments under the parent resource. For each OS policy assignment, the latest revision is returned.", - "canonical": true, - "file": "os_config_zonal_service.list_o_s_policy_assignments.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListOSPolicyAssignments", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.ListOSPolicyAssignments", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1.ListOSPolicyAssignmentsResponse", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "ListOSPolicyAssignments", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.ListOSPolicyAssignments", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignmentRevisions_async", - "title": "OsConfigServiceClient listOSPolicyAssignmentRevisions Sample", - "origin": "API_DEFINITION", - "description": " List the OS policy assignment revisions for a given OS policy assignment.", - "canonical": true, - "file": "os_config_zonal_service.list_o_s_policy_assignment_revisions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListOSPolicyAssignmentRevisions", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.ListOSPolicyAssignmentRevisions", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsResponse", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "ListOSPolicyAssignmentRevisions", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.ListOSPolicyAssignmentRevisions", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigZonalService_DeleteOSPolicyAssignment_async", - "title": "OsConfigServiceClient deleteOSPolicyAssignment Sample", - "origin": "API_DEFINITION", - "description": " Delete the OS policy assignment. This method creates a new revision of the OS policy assignment. This method returns a long running operation (LRO) that contains the rollout details. The rollout can be cancelled by cancelling the LRO. If the LRO completes and is not cancelled, all revisions associated with the OS policy assignment are deleted. For more information, see [Method: projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel).", - "canonical": true, - "file": "os_config_zonal_service.delete_o_s_policy_assignment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteOSPolicyAssignment", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.DeleteOSPolicyAssignment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "DeleteOSPolicyAssignment", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.DeleteOSPolicyAssignment", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigZonalService_GetOSPolicyAssignmentReport_async", - "title": "OsConfigServiceClient getOSPolicyAssignmentReport Sample", - "origin": "API_DEFINITION", - "description": " Get the OS policy asssignment report for the specified Compute Engine VM instance.", - "canonical": true, - "file": "os_config_zonal_service.get_o_s_policy_assignment_report.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetOSPolicyAssignmentReport", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.GetOSPolicyAssignmentReport", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1.OSPolicyAssignmentReport", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "GetOSPolicyAssignmentReport", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.GetOSPolicyAssignmentReport", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignmentReports_async", - "title": "OsConfigServiceClient listOSPolicyAssignmentReports Sample", - "origin": "API_DEFINITION", - "description": " List OS policy asssignment reports for all Compute Engine VM instances in the specified zone.", - "canonical": true, - "file": "os_config_zonal_service.list_o_s_policy_assignment_reports.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 87, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListOSPolicyAssignmentReports", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.ListOSPolicyAssignmentReports", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsResponse", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "ListOSPolicyAssignmentReports", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.ListOSPolicyAssignmentReports", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigZonalService_GetInventory_async", - "title": "OsConfigServiceClient getInventory Sample", - "origin": "API_DEFINITION", - "description": " Get inventory data for the specified VM instance. If the VM has no associated inventory, the message `NOT_FOUND` is returned.", - "canonical": true, - "file": "os_config_zonal_service.get_inventory.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetInventory", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.GetInventory", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "view", - "type": ".google.cloud.osconfig.v1.InventoryView" - } - ], - "resultType": ".google.cloud.osconfig.v1.Inventory", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "GetInventory", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.GetInventory", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigZonalService_ListInventories_async", - "title": "OsConfigServiceClient listInventories Sample", - "origin": "API_DEFINITION", - "description": " List inventory data for all VM instances in the specified zone.", - "canonical": true, - "file": "os_config_zonal_service.list_inventories.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 77, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListInventories", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.ListInventories", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "view", - "type": ".google.cloud.osconfig.v1.InventoryView" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1.ListInventoriesResponse", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "ListInventories", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.ListInventories", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigZonalService_GetVulnerabilityReport_async", - "title": "OsConfigServiceClient getVulnerabilityReport Sample", - "origin": "API_DEFINITION", - "description": " Gets the vulnerability report for the specified VM instance. Only VMs with inventory data have vulnerability reports associated with them.", - "canonical": true, - "file": "os_config_zonal_service.get_vulnerability_report.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetVulnerabilityReport", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.GetVulnerabilityReport", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1.VulnerabilityReport", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "GetVulnerabilityReport", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.GetVulnerabilityReport", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1_generated_OsConfigZonalService_ListVulnerabilityReports_async", - "title": "OsConfigServiceClient listVulnerabilityReports Sample", - "origin": "API_DEFINITION", - "description": " List vulnerability reports for all VM instances in the specified zone.", - "canonical": true, - "file": "os_config_zonal_service.list_vulnerability_reports.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListVulnerabilityReports", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.ListVulnerabilityReports", - "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.osconfig.v1.ListVulnerabilityReportsResponse", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "ListVulnerabilityReports", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService.ListVulnerabilityReports", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1.OsConfigZonalService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/src/index.ts b/owl-bot-staging/google-cloud-osconfig/v1/src/index.ts deleted file mode 100644 index 47ed963f2d6..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/src/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. ** - -import * as v1 from './v1'; -const OsConfigServiceClient = v1.OsConfigServiceClient; -type OsConfigServiceClient = v1.OsConfigServiceClient; -const OsConfigZonalServiceClient = v1.OsConfigZonalServiceClient; -type OsConfigZonalServiceClient = v1.OsConfigZonalServiceClient; -export {v1, OsConfigServiceClient, OsConfigZonalServiceClient}; -export default {v1, OsConfigServiceClient, OsConfigZonalServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/gapic_metadata.json deleted file mode 100644 index f65f75e1fb0..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,309 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.osconfig.v1", - "libraryPackage": "@google-cloud/os-config", - "services": { - "OsConfigService": { - "clients": { - "grpc": { - "libraryClient": "OsConfigServiceClient", - "rpcs": { - "ExecutePatchJob": { - "methods": [ - "executePatchJob" - ] - }, - "GetPatchJob": { - "methods": [ - "getPatchJob" - ] - }, - "CancelPatchJob": { - "methods": [ - "cancelPatchJob" - ] - }, - "CreatePatchDeployment": { - "methods": [ - "createPatchDeployment" - ] - }, - "GetPatchDeployment": { - "methods": [ - "getPatchDeployment" - ] - }, - "DeletePatchDeployment": { - "methods": [ - "deletePatchDeployment" - ] - }, - "UpdatePatchDeployment": { - "methods": [ - "updatePatchDeployment" - ] - }, - "PausePatchDeployment": { - "methods": [ - "pausePatchDeployment" - ] - }, - "ResumePatchDeployment": { - "methods": [ - "resumePatchDeployment" - ] - }, - "ListPatchJobs": { - "methods": [ - "listPatchJobs", - "listPatchJobsStream", - "listPatchJobsAsync" - ] - }, - "ListPatchJobInstanceDetails": { - "methods": [ - "listPatchJobInstanceDetails", - "listPatchJobInstanceDetailsStream", - "listPatchJobInstanceDetailsAsync" - ] - }, - "ListPatchDeployments": { - "methods": [ - "listPatchDeployments", - "listPatchDeploymentsStream", - "listPatchDeploymentsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "OsConfigServiceClient", - "rpcs": { - "ExecutePatchJob": { - "methods": [ - "executePatchJob" - ] - }, - "GetPatchJob": { - "methods": [ - "getPatchJob" - ] - }, - "CancelPatchJob": { - "methods": [ - "cancelPatchJob" - ] - }, - "CreatePatchDeployment": { - "methods": [ - "createPatchDeployment" - ] - }, - "GetPatchDeployment": { - "methods": [ - "getPatchDeployment" - ] - }, - "DeletePatchDeployment": { - "methods": [ - "deletePatchDeployment" - ] - }, - "UpdatePatchDeployment": { - "methods": [ - "updatePatchDeployment" - ] - }, - "PausePatchDeployment": { - "methods": [ - "pausePatchDeployment" - ] - }, - "ResumePatchDeployment": { - "methods": [ - "resumePatchDeployment" - ] - }, - "ListPatchJobs": { - "methods": [ - "listPatchJobs", - "listPatchJobsStream", - "listPatchJobsAsync" - ] - }, - "ListPatchJobInstanceDetails": { - "methods": [ - "listPatchJobInstanceDetails", - "listPatchJobInstanceDetailsStream", - "listPatchJobInstanceDetailsAsync" - ] - }, - "ListPatchDeployments": { - "methods": [ - "listPatchDeployments", - "listPatchDeploymentsStream", - "listPatchDeploymentsAsync" - ] - } - } - } - } - }, - "OsConfigZonalService": { - "clients": { - "grpc": { - "libraryClient": "OsConfigZonalServiceClient", - "rpcs": { - "GetOSPolicyAssignment": { - "methods": [ - "getOSPolicyAssignment" - ] - }, - "GetOSPolicyAssignmentReport": { - "methods": [ - "getOSPolicyAssignmentReport" - ] - }, - "GetInventory": { - "methods": [ - "getInventory" - ] - }, - "GetVulnerabilityReport": { - "methods": [ - "getVulnerabilityReport" - ] - }, - "CreateOSPolicyAssignment": { - "methods": [ - "createOSPolicyAssignment" - ] - }, - "UpdateOSPolicyAssignment": { - "methods": [ - "updateOSPolicyAssignment" - ] - }, - "DeleteOSPolicyAssignment": { - "methods": [ - "deleteOSPolicyAssignment" - ] - }, - "ListOSPolicyAssignments": { - "methods": [ - "listOSPolicyAssignments", - "listOSPolicyAssignmentsStream", - "listOSPolicyAssignmentsAsync" - ] - }, - "ListOSPolicyAssignmentRevisions": { - "methods": [ - "listOSPolicyAssignmentRevisions", - "listOSPolicyAssignmentRevisionsStream", - "listOSPolicyAssignmentRevisionsAsync" - ] - }, - "ListOSPolicyAssignmentReports": { - "methods": [ - "listOSPolicyAssignmentReports", - "listOSPolicyAssignmentReportsStream", - "listOSPolicyAssignmentReportsAsync" - ] - }, - "ListInventories": { - "methods": [ - "listInventories", - "listInventoriesStream", - "listInventoriesAsync" - ] - }, - "ListVulnerabilityReports": { - "methods": [ - "listVulnerabilityReports", - "listVulnerabilityReportsStream", - "listVulnerabilityReportsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "OsConfigZonalServiceClient", - "rpcs": { - "GetOSPolicyAssignment": { - "methods": [ - "getOSPolicyAssignment" - ] - }, - "GetOSPolicyAssignmentReport": { - "methods": [ - "getOSPolicyAssignmentReport" - ] - }, - "GetInventory": { - "methods": [ - "getInventory" - ] - }, - "GetVulnerabilityReport": { - "methods": [ - "getVulnerabilityReport" - ] - }, - "CreateOSPolicyAssignment": { - "methods": [ - "createOSPolicyAssignment" - ] - }, - "UpdateOSPolicyAssignment": { - "methods": [ - "updateOSPolicyAssignment" - ] - }, - "DeleteOSPolicyAssignment": { - "methods": [ - "deleteOSPolicyAssignment" - ] - }, - "ListOSPolicyAssignments": { - "methods": [ - "listOSPolicyAssignments", - "listOSPolicyAssignmentsStream", - "listOSPolicyAssignmentsAsync" - ] - }, - "ListOSPolicyAssignmentRevisions": { - "methods": [ - "listOSPolicyAssignmentRevisions", - "listOSPolicyAssignmentRevisionsStream", - "listOSPolicyAssignmentRevisionsAsync" - ] - }, - "ListOSPolicyAssignmentReports": { - "methods": [ - "listOSPolicyAssignmentReports", - "listOSPolicyAssignmentReportsStream", - "listOSPolicyAssignmentReportsAsync" - ] - }, - "ListInventories": { - "methods": [ - "listInventories", - "listInventoriesStream", - "listInventoriesAsync" - ] - }, - "ListVulnerabilityReports": { - "methods": [ - "listVulnerabilityReports", - "listVulnerabilityReportsStream", - "listVulnerabilityReportsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/index.ts deleted file mode 100644 index db855abce5c..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/index.ts +++ /dev/null @@ -1,20 +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 {OsConfigServiceClient} from './os_config_service_client'; -export {OsConfigZonalServiceClient} from './os_config_zonal_service_client'; diff --git a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_client.ts b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_client.ts deleted file mode 100644 index 561a2a62224..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_client.ts +++ /dev/null @@ -1,1854 +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, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/os_config_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './os_config_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * OS Config API - * - * The OS Config service is a server-side component that you can use to - * manage package installations and patch jobs for virtual machine instances. - * @class - * @memberof v1 - */ -export class OsConfigServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - osConfigServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of OsConfigServiceClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 OsConfigServiceClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof OsConfigServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - inventoryPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}/inventory' - ), - oSPolicyAssignmentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}' - ), - oSPolicyAssignmentReportPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report' - ), - patchDeploymentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/patchDeployments/{patch_deployment}' - ), - patchJobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/patchJobs/{patch_job}' - ), - vulnerabilityReportPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport' - ), - }; - - // 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 = { - listPatchJobs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'patchJobs'), - listPatchJobInstanceDetails: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'patchJobInstanceDetails'), - listPatchDeployments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'patchDeployments') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.osconfig.v1.OsConfigService', 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.osConfigServiceStub) { - return this.osConfigServiceStub; - } - - // Put together the "service stub" for - // google.cloud.osconfig.v1.OsConfigService. - this.osConfigServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.osconfig.v1.OsConfigService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.osconfig.v1.OsConfigService, - 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 osConfigServiceStubMethods = - ['executePatchJob', 'getPatchJob', 'cancelPatchJob', 'listPatchJobs', 'listPatchJobInstanceDetails', 'createPatchDeployment', 'getPatchDeployment', 'listPatchDeployments', 'deletePatchDeployment', 'updatePatchDeployment', 'pausePatchDeployment', 'resumePatchDeployment']; - for (const methodName of osConfigServiceStubMethods) { - const callPromise = this.osConfigServiceStub.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.osConfigServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'osconfig.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 'osconfig.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 -- - // ------------------- -/** - * Patch VM instances by creating and running a patch job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which to run this patch in the form `projects/*` - * @param {string} request.description - * Description of the patch job. Length of the description is limited - * to 1024 characters. - * @param {google.cloud.osconfig.v1.PatchInstanceFilter} request.instanceFilter - * Required. Instances to patch, either explicitly or filtered by some - * criteria such as zone or labels. - * @param {google.cloud.osconfig.v1.PatchConfig} request.patchConfig - * Patch configuration being applied. If omitted, instances are - * patched using the default configurations. - * @param {google.protobuf.Duration} request.duration - * Duration of the patch job. After the duration ends, the patch job - * times out. - * @param {boolean} request.dryRun - * If this patch is a dry-run only, instances are contacted but - * will do nothing. - * @param {string} request.displayName - * Display name for this patch job. This does not have to be unique. - * @param {google.cloud.osconfig.v1.PatchRollout} request.rollout - * Rollout strategy of the patch job. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.PatchJob|PatchJob}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_service.execute_patch_job.js - * region_tag:osconfig_v1_generated_OsConfigService_ExecutePatchJob_async - */ - executePatchJob( - request?: protos.google.cloud.osconfig.v1.IExecutePatchJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchJob, - protos.google.cloud.osconfig.v1.IExecutePatchJobRequest|undefined, {}|undefined - ]>; - executePatchJob( - request: protos.google.cloud.osconfig.v1.IExecutePatchJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1.IPatchJob, - protos.google.cloud.osconfig.v1.IExecutePatchJobRequest|null|undefined, - {}|null|undefined>): void; - executePatchJob( - request: protos.google.cloud.osconfig.v1.IExecutePatchJobRequest, - callback: Callback< - protos.google.cloud.osconfig.v1.IPatchJob, - protos.google.cloud.osconfig.v1.IExecutePatchJobRequest|null|undefined, - {}|null|undefined>): void; - executePatchJob( - request?: protos.google.cloud.osconfig.v1.IExecutePatchJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1.IPatchJob, - protos.google.cloud.osconfig.v1.IExecutePatchJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1.IPatchJob, - protos.google.cloud.osconfig.v1.IExecutePatchJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchJob, - protos.google.cloud.osconfig.v1.IExecutePatchJobRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.executePatchJob(request, options, callback); - } -/** - * Get the patch job. This can be used to track the progress of an - * ongoing patch job or review the details of completed jobs. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the patch in the form `projects/* /patchJobs/*` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.PatchJob|PatchJob}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_service.get_patch_job.js - * region_tag:osconfig_v1_generated_OsConfigService_GetPatchJob_async - */ - getPatchJob( - request?: protos.google.cloud.osconfig.v1.IGetPatchJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchJob, - protos.google.cloud.osconfig.v1.IGetPatchJobRequest|undefined, {}|undefined - ]>; - getPatchJob( - request: protos.google.cloud.osconfig.v1.IGetPatchJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1.IPatchJob, - protos.google.cloud.osconfig.v1.IGetPatchJobRequest|null|undefined, - {}|null|undefined>): void; - getPatchJob( - request: protos.google.cloud.osconfig.v1.IGetPatchJobRequest, - callback: Callback< - protos.google.cloud.osconfig.v1.IPatchJob, - protos.google.cloud.osconfig.v1.IGetPatchJobRequest|null|undefined, - {}|null|undefined>): void; - getPatchJob( - request?: protos.google.cloud.osconfig.v1.IGetPatchJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1.IPatchJob, - protos.google.cloud.osconfig.v1.IGetPatchJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1.IPatchJob, - protos.google.cloud.osconfig.v1.IGetPatchJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchJob, - protos.google.cloud.osconfig.v1.IGetPatchJobRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getPatchJob(request, options, callback); - } -/** - * Cancel a patch job. The patch job must be active. Canceled patch jobs - * cannot be restarted. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the patch in the form `projects/* /patchJobs/*` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.PatchJob|PatchJob}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_service.cancel_patch_job.js - * region_tag:osconfig_v1_generated_OsConfigService_CancelPatchJob_async - */ - cancelPatchJob( - request?: protos.google.cloud.osconfig.v1.ICancelPatchJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchJob, - protos.google.cloud.osconfig.v1.ICancelPatchJobRequest|undefined, {}|undefined - ]>; - cancelPatchJob( - request: protos.google.cloud.osconfig.v1.ICancelPatchJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1.IPatchJob, - protos.google.cloud.osconfig.v1.ICancelPatchJobRequest|null|undefined, - {}|null|undefined>): void; - cancelPatchJob( - request: protos.google.cloud.osconfig.v1.ICancelPatchJobRequest, - callback: Callback< - protos.google.cloud.osconfig.v1.IPatchJob, - protos.google.cloud.osconfig.v1.ICancelPatchJobRequest|null|undefined, - {}|null|undefined>): void; - cancelPatchJob( - request?: protos.google.cloud.osconfig.v1.ICancelPatchJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1.IPatchJob, - protos.google.cloud.osconfig.v1.ICancelPatchJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1.IPatchJob, - protos.google.cloud.osconfig.v1.ICancelPatchJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchJob, - protos.google.cloud.osconfig.v1.ICancelPatchJobRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.cancelPatchJob(request, options, callback); - } -/** - * Create an OS Config patch deployment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project to apply this patch deployment to in the form - * `projects/*`. - * @param {string} request.patchDeploymentId - * Required. A name for the patch deployment in the project. When creating a - * name the following rules apply: - * * Must contain only lowercase letters, numbers, and hyphens. - * * Must start with a letter. - * * Must be between 1-63 characters. - * * Must end with a number or a letter. - * * Must be unique within the project. - * @param {google.cloud.osconfig.v1.PatchDeployment} request.patchDeployment - * Required. The patch deployment to create. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.PatchDeployment|PatchDeployment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_service.create_patch_deployment.js - * region_tag:osconfig_v1_generated_OsConfigService_CreatePatchDeployment_async - */ - createPatchDeployment( - request?: protos.google.cloud.osconfig.v1.ICreatePatchDeploymentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.ICreatePatchDeploymentRequest|undefined, {}|undefined - ]>; - createPatchDeployment( - request: protos.google.cloud.osconfig.v1.ICreatePatchDeploymentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.ICreatePatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - createPatchDeployment( - request: protos.google.cloud.osconfig.v1.ICreatePatchDeploymentRequest, - callback: Callback< - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.ICreatePatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - createPatchDeployment( - request?: protos.google.cloud.osconfig.v1.ICreatePatchDeploymentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.ICreatePatchDeploymentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.ICreatePatchDeploymentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.ICreatePatchDeploymentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createPatchDeployment(request, options, callback); - } -/** - * Get an OS Config patch deployment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the patch deployment in the form - * `projects/* /patchDeployments/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.PatchDeployment|PatchDeployment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_service.get_patch_deployment.js - * region_tag:osconfig_v1_generated_OsConfigService_GetPatchDeployment_async - */ - getPatchDeployment( - request?: protos.google.cloud.osconfig.v1.IGetPatchDeploymentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IGetPatchDeploymentRequest|undefined, {}|undefined - ]>; - getPatchDeployment( - request: protos.google.cloud.osconfig.v1.IGetPatchDeploymentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IGetPatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - getPatchDeployment( - request: protos.google.cloud.osconfig.v1.IGetPatchDeploymentRequest, - callback: Callback< - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IGetPatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - getPatchDeployment( - request?: protos.google.cloud.osconfig.v1.IGetPatchDeploymentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IGetPatchDeploymentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IGetPatchDeploymentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IGetPatchDeploymentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getPatchDeployment(request, options, callback); - } -/** - * Delete an OS Config patch deployment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the patch deployment in the form - * `projects/* /patchDeployments/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_service.delete_patch_deployment.js - * region_tag:osconfig_v1_generated_OsConfigService_DeletePatchDeployment_async - */ - deletePatchDeployment( - request?: protos.google.cloud.osconfig.v1.IDeletePatchDeploymentRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.osconfig.v1.IDeletePatchDeploymentRequest|undefined, {}|undefined - ]>; - deletePatchDeployment( - request: protos.google.cloud.osconfig.v1.IDeletePatchDeploymentRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.osconfig.v1.IDeletePatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - deletePatchDeployment( - request: protos.google.cloud.osconfig.v1.IDeletePatchDeploymentRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.osconfig.v1.IDeletePatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - deletePatchDeployment( - request?: protos.google.cloud.osconfig.v1.IDeletePatchDeploymentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.osconfig.v1.IDeletePatchDeploymentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.osconfig.v1.IDeletePatchDeploymentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.osconfig.v1.IDeletePatchDeploymentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deletePatchDeployment(request, options, callback); - } -/** - * Update an OS Config patch deployment. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.osconfig.v1.PatchDeployment} request.patchDeployment - * Required. The patch deployment to Update. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask that controls which fields of the patch deployment - * should be 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 protos.google.cloud.osconfig.v1.PatchDeployment|PatchDeployment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_service.update_patch_deployment.js - * region_tag:osconfig_v1_generated_OsConfigService_UpdatePatchDeployment_async - */ - updatePatchDeployment( - request?: protos.google.cloud.osconfig.v1.IUpdatePatchDeploymentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IUpdatePatchDeploymentRequest|undefined, {}|undefined - ]>; - updatePatchDeployment( - request: protos.google.cloud.osconfig.v1.IUpdatePatchDeploymentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IUpdatePatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - updatePatchDeployment( - request: protos.google.cloud.osconfig.v1.IUpdatePatchDeploymentRequest, - callback: Callback< - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IUpdatePatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - updatePatchDeployment( - request?: protos.google.cloud.osconfig.v1.IUpdatePatchDeploymentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IUpdatePatchDeploymentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IUpdatePatchDeploymentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IUpdatePatchDeploymentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'patch_deployment.name': request.patchDeployment!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updatePatchDeployment(request, options, callback); - } -/** - * Change state of patch deployment to "PAUSED". - * Patch deployment in paused state doesn't generate patch jobs. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the patch deployment in the form - * `projects/* /patchDeployments/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.PatchDeployment|PatchDeployment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_service.pause_patch_deployment.js - * region_tag:osconfig_v1_generated_OsConfigService_PausePatchDeployment_async - */ - pausePatchDeployment( - request?: protos.google.cloud.osconfig.v1.IPausePatchDeploymentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IPausePatchDeploymentRequest|undefined, {}|undefined - ]>; - pausePatchDeployment( - request: protos.google.cloud.osconfig.v1.IPausePatchDeploymentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IPausePatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - pausePatchDeployment( - request: protos.google.cloud.osconfig.v1.IPausePatchDeploymentRequest, - callback: Callback< - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IPausePatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - pausePatchDeployment( - request?: protos.google.cloud.osconfig.v1.IPausePatchDeploymentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IPausePatchDeploymentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IPausePatchDeploymentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IPausePatchDeploymentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.pausePatchDeployment(request, options, callback); - } -/** - * Change state of patch deployment back to "ACTIVE". - * Patch deployment in active state continues to generate patch jobs. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the patch deployment in the form - * `projects/* /patchDeployments/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.PatchDeployment|PatchDeployment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_service.resume_patch_deployment.js - * region_tag:osconfig_v1_generated_OsConfigService_ResumePatchDeployment_async - */ - resumePatchDeployment( - request?: protos.google.cloud.osconfig.v1.IResumePatchDeploymentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IResumePatchDeploymentRequest|undefined, {}|undefined - ]>; - resumePatchDeployment( - request: protos.google.cloud.osconfig.v1.IResumePatchDeploymentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IResumePatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - resumePatchDeployment( - request: protos.google.cloud.osconfig.v1.IResumePatchDeploymentRequest, - callback: Callback< - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IResumePatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - resumePatchDeployment( - request?: protos.google.cloud.osconfig.v1.IResumePatchDeploymentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IResumePatchDeploymentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IResumePatchDeploymentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchDeployment, - protos.google.cloud.osconfig.v1.IResumePatchDeploymentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.resumePatchDeployment(request, options, callback); - } - - /** - * Get a list of patch jobs. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. In the form of `projects/*` - * @param {number} request.pageSize - * The maximum number of instance status to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call - * that indicates where this listing should continue from. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by patch - * jobs to be included in the response. - * Currently, filtering is only available on the patch_deployment field. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1.PatchJob|PatchJob}. - * 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 `listPatchJobsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listPatchJobs( - request?: protos.google.cloud.osconfig.v1.IListPatchJobsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchJob[], - protos.google.cloud.osconfig.v1.IListPatchJobsRequest|null, - protos.google.cloud.osconfig.v1.IListPatchJobsResponse - ]>; - listPatchJobs( - request: protos.google.cloud.osconfig.v1.IListPatchJobsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1.IListPatchJobsRequest, - protos.google.cloud.osconfig.v1.IListPatchJobsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IPatchJob>): void; - listPatchJobs( - request: protos.google.cloud.osconfig.v1.IListPatchJobsRequest, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1.IListPatchJobsRequest, - protos.google.cloud.osconfig.v1.IListPatchJobsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IPatchJob>): void; - listPatchJobs( - request?: protos.google.cloud.osconfig.v1.IListPatchJobsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.osconfig.v1.IListPatchJobsRequest, - protos.google.cloud.osconfig.v1.IListPatchJobsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IPatchJob>, - callback?: PaginationCallback< - protos.google.cloud.osconfig.v1.IListPatchJobsRequest, - protos.google.cloud.osconfig.v1.IListPatchJobsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IPatchJob>): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchJob[], - protos.google.cloud.osconfig.v1.IListPatchJobsRequest|null, - protos.google.cloud.osconfig.v1.IListPatchJobsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listPatchJobs(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. In the form of `projects/*` - * @param {number} request.pageSize - * The maximum number of instance status to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call - * that indicates where this listing should continue from. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by patch - * jobs to be included in the response. - * Currently, filtering is only available on the patch_deployment field. - * @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 protos.google.cloud.osconfig.v1.PatchJob|PatchJob} 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 `listPatchJobsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listPatchJobsStream( - request?: protos.google.cloud.osconfig.v1.IListPatchJobsRequest, - 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['listPatchJobs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listPatchJobs.createStream( - this.innerApiCalls.listPatchJobs as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listPatchJobs`, 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. In the form of `projects/*` - * @param {number} request.pageSize - * The maximum number of instance status to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call - * that indicates where this listing should continue from. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by patch - * jobs to be included in the response. - * Currently, filtering is only available on the patch_deployment field. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.osconfig.v1.PatchJob|PatchJob}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_service.list_patch_jobs.js - * region_tag:osconfig_v1_generated_OsConfigService_ListPatchJobs_async - */ - listPatchJobsAsync( - request?: protos.google.cloud.osconfig.v1.IListPatchJobsRequest, - 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['listPatchJobs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listPatchJobs.asyncIterate( - this.innerApiCalls['listPatchJobs'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Get a list of instance details for a given patch job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent for the instances are in the form of - * `projects/* /patchJobs/*`. - * @param {number} request.pageSize - * The maximum number of instance details records to return. Default is 100. - * @param {string} request.pageToken - * A pagination token returned from a previous call - * that indicates where this listing should continue from. - * @param {string} request.filter - * A filter expression that filters results listed in the response. This - * field supports filtering results by instance zone, name, state, or - * `failure_reason`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1.PatchJobInstanceDetails|PatchJobInstanceDetails}. - * 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 `listPatchJobInstanceDetailsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listPatchJobInstanceDetails( - request?: protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchJobInstanceDetails[], - protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest|null, - protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsResponse - ]>; - listPatchJobInstanceDetails( - request: protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest, - protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IPatchJobInstanceDetails>): void; - listPatchJobInstanceDetails( - request: protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest, - protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IPatchJobInstanceDetails>): void; - listPatchJobInstanceDetails( - request?: protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest, - protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IPatchJobInstanceDetails>, - callback?: PaginationCallback< - protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest, - protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IPatchJobInstanceDetails>): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchJobInstanceDetails[], - protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest|null, - protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listPatchJobInstanceDetails(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 the instances are in the form of - * `projects/* /patchJobs/*`. - * @param {number} request.pageSize - * The maximum number of instance details records to return. Default is 100. - * @param {string} request.pageToken - * A pagination token returned from a previous call - * that indicates where this listing should continue from. - * @param {string} request.filter - * A filter expression that filters results listed in the response. This - * field supports filtering results by instance zone, name, state, or - * `failure_reason`. - * @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 protos.google.cloud.osconfig.v1.PatchJobInstanceDetails|PatchJobInstanceDetails} 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 `listPatchJobInstanceDetailsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listPatchJobInstanceDetailsStream( - request?: protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest, - 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['listPatchJobInstanceDetails']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listPatchJobInstanceDetails.createStream( - this.innerApiCalls.listPatchJobInstanceDetails as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listPatchJobInstanceDetails`, 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 the instances are in the form of - * `projects/* /patchJobs/*`. - * @param {number} request.pageSize - * The maximum number of instance details records to return. Default is 100. - * @param {string} request.pageToken - * A pagination token returned from a previous call - * that indicates where this listing should continue from. - * @param {string} request.filter - * A filter expression that filters results listed in the response. This - * field supports filtering results by instance zone, name, state, or - * `failure_reason`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.osconfig.v1.PatchJobInstanceDetails|PatchJobInstanceDetails}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_service.list_patch_job_instance_details.js - * region_tag:osconfig_v1_generated_OsConfigService_ListPatchJobInstanceDetails_async - */ - listPatchJobInstanceDetailsAsync( - request?: protos.google.cloud.osconfig.v1.IListPatchJobInstanceDetailsRequest, - 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['listPatchJobInstanceDetails']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listPatchJobInstanceDetails.asyncIterate( - this.innerApiCalls['listPatchJobInstanceDetails'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Get a page of OS Config patch deployments. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the parent in the form `projects/*`. - * @param {number} [request.pageSize] - * Optional. The maximum number of patch deployments to return. Default is - * 100. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * ListPatchDeployments that indicates where this listing should continue - * from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1.PatchDeployment|PatchDeployment}. - * 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 `listPatchDeploymentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listPatchDeployments( - request?: protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchDeployment[], - protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest|null, - protos.google.cloud.osconfig.v1.IListPatchDeploymentsResponse - ]>; - listPatchDeployments( - request: protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest, - protos.google.cloud.osconfig.v1.IListPatchDeploymentsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IPatchDeployment>): void; - listPatchDeployments( - request: protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest, - protos.google.cloud.osconfig.v1.IListPatchDeploymentsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IPatchDeployment>): void; - listPatchDeployments( - request?: protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest, - protos.google.cloud.osconfig.v1.IListPatchDeploymentsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IPatchDeployment>, - callback?: PaginationCallback< - protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest, - protos.google.cloud.osconfig.v1.IListPatchDeploymentsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IPatchDeployment>): - Promise<[ - protos.google.cloud.osconfig.v1.IPatchDeployment[], - protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest|null, - protos.google.cloud.osconfig.v1.IListPatchDeploymentsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listPatchDeployments(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the parent in the form `projects/*`. - * @param {number} [request.pageSize] - * Optional. The maximum number of patch deployments to return. Default is - * 100. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * ListPatchDeployments that indicates where this listing should continue - * from. - * @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 protos.google.cloud.osconfig.v1.PatchDeployment|PatchDeployment} 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 `listPatchDeploymentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listPatchDeploymentsStream( - request?: protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest, - 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['listPatchDeployments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listPatchDeployments.createStream( - this.innerApiCalls.listPatchDeployments as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listPatchDeployments`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the parent in the form `projects/*`. - * @param {number} [request.pageSize] - * Optional. The maximum number of patch deployments to return. Default is - * 100. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * ListPatchDeployments that indicates where this listing should continue - * from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.osconfig.v1.PatchDeployment|PatchDeployment}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_service.list_patch_deployments.js - * region_tag:osconfig_v1_generated_OsConfigService_ListPatchDeployments_async - */ - listPatchDeploymentsAsync( - request?: protos.google.cloud.osconfig.v1.IListPatchDeploymentsRequest, - 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['listPatchDeployments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listPatchDeployments.asyncIterate( - this.innerApiCalls['listPatchDeployments'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified inventory resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} instance - * @returns {string} Resource name string. - */ - inventoryPath(project:string,location:string,instance:string) { - return this.pathTemplates.inventoryPathTemplate.render({ - project: project, - location: location, - instance: instance, - }); - } - - /** - * Parse the project from Inventory resource. - * - * @param {string} inventoryName - * A fully-qualified path representing Inventory resource. - * @returns {string} A string representing the project. - */ - matchProjectFromInventoryName(inventoryName: string) { - return this.pathTemplates.inventoryPathTemplate.match(inventoryName).project; - } - - /** - * Parse the location from Inventory resource. - * - * @param {string} inventoryName - * A fully-qualified path representing Inventory resource. - * @returns {string} A string representing the location. - */ - matchLocationFromInventoryName(inventoryName: string) { - return this.pathTemplates.inventoryPathTemplate.match(inventoryName).location; - } - - /** - * Parse the instance from Inventory resource. - * - * @param {string} inventoryName - * A fully-qualified path representing Inventory resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromInventoryName(inventoryName: string) { - return this.pathTemplates.inventoryPathTemplate.match(inventoryName).instance; - } - - /** - * Return a fully-qualified oSPolicyAssignment resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} os_policy_assignment - * @returns {string} Resource name string. - */ - oSPolicyAssignmentPath(project:string,location:string,osPolicyAssignment:string) { - return this.pathTemplates.oSPolicyAssignmentPathTemplate.render({ - project: project, - location: location, - os_policy_assignment: osPolicyAssignment, - }); - } - - /** - * Parse the project from OSPolicyAssignment resource. - * - * @param {string} oSPolicyAssignmentName - * A fully-qualified path representing OSPolicyAssignment resource. - * @returns {string} A string representing the project. - */ - matchProjectFromOSPolicyAssignmentName(oSPolicyAssignmentName: string) { - return this.pathTemplates.oSPolicyAssignmentPathTemplate.match(oSPolicyAssignmentName).project; - } - - /** - * Parse the location from OSPolicyAssignment resource. - * - * @param {string} oSPolicyAssignmentName - * A fully-qualified path representing OSPolicyAssignment resource. - * @returns {string} A string representing the location. - */ - matchLocationFromOSPolicyAssignmentName(oSPolicyAssignmentName: string) { - return this.pathTemplates.oSPolicyAssignmentPathTemplate.match(oSPolicyAssignmentName).location; - } - - /** - * Parse the os_policy_assignment from OSPolicyAssignment resource. - * - * @param {string} oSPolicyAssignmentName - * A fully-qualified path representing OSPolicyAssignment resource. - * @returns {string} A string representing the os_policy_assignment. - */ - matchOsPolicyAssignmentFromOSPolicyAssignmentName(oSPolicyAssignmentName: string) { - return this.pathTemplates.oSPolicyAssignmentPathTemplate.match(oSPolicyAssignmentName).os_policy_assignment; - } - - /** - * Return a fully-qualified oSPolicyAssignmentReport resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} instance - * @param {string} assignment - * @returns {string} Resource name string. - */ - oSPolicyAssignmentReportPath(project:string,location:string,instance:string,assignment:string) { - return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.render({ - project: project, - location: location, - instance: instance, - assignment: assignment, - }); - } - - /** - * Parse the project from OSPolicyAssignmentReport resource. - * - * @param {string} oSPolicyAssignmentReportName - * A fully-qualified path representing OSPolicyAssignmentReport resource. - * @returns {string} A string representing the project. - */ - matchProjectFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { - return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).project; - } - - /** - * Parse the location from OSPolicyAssignmentReport resource. - * - * @param {string} oSPolicyAssignmentReportName - * A fully-qualified path representing OSPolicyAssignmentReport resource. - * @returns {string} A string representing the location. - */ - matchLocationFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { - return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).location; - } - - /** - * Parse the instance from OSPolicyAssignmentReport resource. - * - * @param {string} oSPolicyAssignmentReportName - * A fully-qualified path representing OSPolicyAssignmentReport resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { - return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).instance; - } - - /** - * Parse the assignment from OSPolicyAssignmentReport resource. - * - * @param {string} oSPolicyAssignmentReportName - * A fully-qualified path representing OSPolicyAssignmentReport resource. - * @returns {string} A string representing the assignment. - */ - matchAssignmentFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { - return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).assignment; - } - - /** - * Return a fully-qualified patchDeployment resource name string. - * - * @param {string} project - * @param {string} patch_deployment - * @returns {string} Resource name string. - */ - patchDeploymentPath(project:string,patchDeployment:string) { - return this.pathTemplates.patchDeploymentPathTemplate.render({ - project: project, - patch_deployment: patchDeployment, - }); - } - - /** - * Parse the project from PatchDeployment resource. - * - * @param {string} patchDeploymentName - * A fully-qualified path representing PatchDeployment resource. - * @returns {string} A string representing the project. - */ - matchProjectFromPatchDeploymentName(patchDeploymentName: string) { - return this.pathTemplates.patchDeploymentPathTemplate.match(patchDeploymentName).project; - } - - /** - * Parse the patch_deployment from PatchDeployment resource. - * - * @param {string} patchDeploymentName - * A fully-qualified path representing PatchDeployment resource. - * @returns {string} A string representing the patch_deployment. - */ - matchPatchDeploymentFromPatchDeploymentName(patchDeploymentName: string) { - return this.pathTemplates.patchDeploymentPathTemplate.match(patchDeploymentName).patch_deployment; - } - - /** - * Return a fully-qualified patchJob resource name string. - * - * @param {string} project - * @param {string} patch_job - * @returns {string} Resource name string. - */ - patchJobPath(project:string,patchJob:string) { - return this.pathTemplates.patchJobPathTemplate.render({ - project: project, - patch_job: patchJob, - }); - } - - /** - * Parse the project from PatchJob resource. - * - * @param {string} patchJobName - * A fully-qualified path representing PatchJob resource. - * @returns {string} A string representing the project. - */ - matchProjectFromPatchJobName(patchJobName: string) { - return this.pathTemplates.patchJobPathTemplate.match(patchJobName).project; - } - - /** - * Parse the patch_job from PatchJob resource. - * - * @param {string} patchJobName - * A fully-qualified path representing PatchJob resource. - * @returns {string} A string representing the patch_job. - */ - matchPatchJobFromPatchJobName(patchJobName: string) { - return this.pathTemplates.patchJobPathTemplate.match(patchJobName).patch_job; - } - - /** - * Return a fully-qualified vulnerabilityReport resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} instance - * @returns {string} Resource name string. - */ - vulnerabilityReportPath(project:string,location:string,instance:string) { - return this.pathTemplates.vulnerabilityReportPathTemplate.render({ - project: project, - location: location, - instance: instance, - }); - } - - /** - * Parse the project from VulnerabilityReport resource. - * - * @param {string} vulnerabilityReportName - * A fully-qualified path representing VulnerabilityReport resource. - * @returns {string} A string representing the project. - */ - matchProjectFromVulnerabilityReportName(vulnerabilityReportName: string) { - return this.pathTemplates.vulnerabilityReportPathTemplate.match(vulnerabilityReportName).project; - } - - /** - * Parse the location from VulnerabilityReport resource. - * - * @param {string} vulnerabilityReportName - * A fully-qualified path representing VulnerabilityReport resource. - * @returns {string} A string representing the location. - */ - matchLocationFromVulnerabilityReportName(vulnerabilityReportName: string) { - return this.pathTemplates.vulnerabilityReportPathTemplate.match(vulnerabilityReportName).location; - } - - /** - * Parse the instance from VulnerabilityReport resource. - * - * @param {string} vulnerabilityReportName - * A fully-qualified path representing VulnerabilityReport resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromVulnerabilityReportName(vulnerabilityReportName: string) { - return this.pathTemplates.vulnerabilityReportPathTemplate.match(vulnerabilityReportName).instance; - } - - /** - * 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.osConfigServiceStub && !this._terminated) { - return this.osConfigServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_client_config.json b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_client_config.json deleted file mode 100644 index 49ac0b9b644..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_client_config.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "interfaces": { - "google.cloud.osconfig.v1.OsConfigService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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 - }, - "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c": { - "initial_retry_delay_millis": 1000, - "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": { - "ExecutePatchJob": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "GetPatchJob": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "CancelPatchJob": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "ListPatchJobs": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "ListPatchJobInstanceDetails": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "CreatePatchDeployment": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "GetPatchDeployment": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "ListPatchDeployments": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "DeletePatchDeployment": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "UpdatePatchDeployment": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "PausePatchDeployment": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "ResumePatchDeployment": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_proto_list.json b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_proto_list.json deleted file mode 100644 index e074f70ca02..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_service_proto_list.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - "../../protos/google/cloud/osconfig/v1/inventory.proto", - "../../protos/google/cloud/osconfig/v1/os_policy.proto", - "../../protos/google/cloud/osconfig/v1/os_policy_assignment_reports.proto", - "../../protos/google/cloud/osconfig/v1/os_policy_assignments.proto", - "../../protos/google/cloud/osconfig/v1/osconfig_common.proto", - "../../protos/google/cloud/osconfig/v1/osconfig_service.proto", - "../../protos/google/cloud/osconfig/v1/osconfig_zonal_service.proto", - "../../protos/google/cloud/osconfig/v1/patch_deployments.proto", - "../../protos/google/cloud/osconfig/v1/patch_jobs.proto", - "../../protos/google/cloud/osconfig/v1/vulnerability.proto" -] diff --git a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_client.ts b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_client.ts deleted file mode 100644 index 0057e11204d..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_client.ts +++ /dev/null @@ -1,2306 +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} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/os_config_zonal_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './os_config_zonal_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Zonal OS Config API - * - * The OS Config service is the server-side component that allows users to - * manage package installations and patch jobs for Compute Engine VM instances. - * @class - * @memberof v1 - */ -export class OsConfigZonalServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - osConfigZonalServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of OsConfigZonalServiceClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 OsConfigZonalServiceClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof OsConfigZonalServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - inventoryPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}/inventory' - ), - oSPolicyAssignmentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}' - ), - oSPolicyAssignmentReportPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report' - ), - patchDeploymentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/patchDeployments/{patch_deployment}' - ), - patchJobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/patchJobs/{patch_job}' - ), - vulnerabilityReportPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport' - ), - }; - - // 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 = { - listOSPolicyAssignments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'osPolicyAssignments'), - listOSPolicyAssignmentRevisions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'osPolicyAssignments'), - listOSPolicyAssignmentReports: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'osPolicyAssignmentReports'), - listInventories: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'inventories'), - listVulnerabilityReports: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'vulnerabilityReports') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/osPolicyAssignments/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/osPolicyAssignments/*/operations/*}',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createOSPolicyAssignmentResponse = protoFilesRoot.lookup( - '.google.cloud.osconfig.v1.OSPolicyAssignment') as gax.protobuf.Type; - const createOSPolicyAssignmentMetadata = protoFilesRoot.lookup( - '.google.cloud.osconfig.v1.OSPolicyAssignmentOperationMetadata') as gax.protobuf.Type; - const updateOSPolicyAssignmentResponse = protoFilesRoot.lookup( - '.google.cloud.osconfig.v1.OSPolicyAssignment') as gax.protobuf.Type; - const updateOSPolicyAssignmentMetadata = protoFilesRoot.lookup( - '.google.cloud.osconfig.v1.OSPolicyAssignmentOperationMetadata') as gax.protobuf.Type; - const deleteOSPolicyAssignmentResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteOSPolicyAssignmentMetadata = protoFilesRoot.lookup( - '.google.cloud.osconfig.v1.OSPolicyAssignmentOperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createOSPolicyAssignment: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createOSPolicyAssignmentResponse.decode.bind(createOSPolicyAssignmentResponse), - createOSPolicyAssignmentMetadata.decode.bind(createOSPolicyAssignmentMetadata)), - updateOSPolicyAssignment: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateOSPolicyAssignmentResponse.decode.bind(updateOSPolicyAssignmentResponse), - updateOSPolicyAssignmentMetadata.decode.bind(updateOSPolicyAssignmentMetadata)), - deleteOSPolicyAssignment: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteOSPolicyAssignmentResponse.decode.bind(deleteOSPolicyAssignmentResponse), - deleteOSPolicyAssignmentMetadata.decode.bind(deleteOSPolicyAssignmentMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.osconfig.v1.OsConfigZonalService', 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.osConfigZonalServiceStub) { - return this.osConfigZonalServiceStub; - } - - // Put together the "service stub" for - // google.cloud.osconfig.v1.OsConfigZonalService. - this.osConfigZonalServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.osconfig.v1.OsConfigZonalService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.osconfig.v1.OsConfigZonalService, - 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 osConfigZonalServiceStubMethods = - ['createOsPolicyAssignment', 'updateOsPolicyAssignment', 'getOsPolicyAssignment', 'listOsPolicyAssignments', 'listOsPolicyAssignmentRevisions', 'deleteOsPolicyAssignment', 'getOsPolicyAssignmentReport', 'listOsPolicyAssignmentReports', 'getInventory', 'listInventories', 'getVulnerabilityReport', 'listVulnerabilityReports']; - for (const methodName of osConfigZonalServiceStubMethods) { - const callPromise = this.osConfigZonalServiceStub.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.osConfigZonalServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'osconfig.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 'osconfig.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 -- - // ------------------- -/** - * Retrieve an existing OS policy assignment. - * - * This method always returns the latest revision. In order to retrieve a - * previous revision of the assignment, also provide the revision ID in the - * `name` parameter. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of OS policy assignment. - * - * Format: - * `projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}@{revisionId}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.OSPolicyAssignment|OSPolicyAssignment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_zonal_service.get_o_s_policy_assignment.js - * region_tag:osconfig_v1_generated_OsConfigZonalService_GetOSPolicyAssignment_async - */ - getOSPolicyAssignment( - request?: protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1.IOSPolicyAssignment, - protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentRequest|undefined, {}|undefined - ]>; - getOSPolicyAssignment( - request: protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1.IOSPolicyAssignment, - protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentRequest|null|undefined, - {}|null|undefined>): void; - getOSPolicyAssignment( - request: protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentRequest, - callback: Callback< - protos.google.cloud.osconfig.v1.IOSPolicyAssignment, - protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentRequest|null|undefined, - {}|null|undefined>): void; - getOSPolicyAssignment( - request?: protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1.IOSPolicyAssignment, - protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1.IOSPolicyAssignment, - protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1.IOSPolicyAssignment, - protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getOsPolicyAssignment(request, options, callback); - } -/** - * Get the OS policy asssignment report for the specified Compute Engine VM - * instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. API resource name for OS policy assignment report. - * - * Format: - * `/projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * For `{instance_id}`, either Compute Engine `instance-id` or `instance-name` - * can be provided. - * For `{assignment_id}`, the OSPolicyAssignment id must be provided. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport|OSPolicyAssignmentReport}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_zonal_service.get_o_s_policy_assignment_report.js - * region_tag:osconfig_v1_generated_OsConfigZonalService_GetOSPolicyAssignmentReport_async - */ - getOSPolicyAssignmentReport( - request?: protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentReportRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport, - protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentReportRequest|undefined, {}|undefined - ]>; - getOSPolicyAssignmentReport( - request: protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentReportRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport, - protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentReportRequest|null|undefined, - {}|null|undefined>): void; - getOSPolicyAssignmentReport( - request: protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentReportRequest, - callback: Callback< - protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport, - protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentReportRequest|null|undefined, - {}|null|undefined>): void; - getOSPolicyAssignmentReport( - request?: protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentReportRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport, - protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentReportRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport, - protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentReportRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport, - protos.google.cloud.osconfig.v1.IGetOSPolicyAssignmentReportRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getOsPolicyAssignmentReport(request, options, callback); - } -/** - * Get inventory data for the specified VM instance. If the VM has no - * associated inventory, the message `NOT_FOUND` is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. API resource name for inventory resource. - * - * Format: - * `projects/{project}/locations/{location}/instances/{instance}/inventory` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * For `{instance}`, either Compute Engine `instance-id` or `instance-name` - * can be provided. - * @param {google.cloud.osconfig.v1.InventoryView} request.view - * Inventory view indicating what information should be included in the - * inventory resource. If unspecified, the default view is BASIC. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.Inventory|Inventory}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_zonal_service.get_inventory.js - * region_tag:osconfig_v1_generated_OsConfigZonalService_GetInventory_async - */ - getInventory( - request?: protos.google.cloud.osconfig.v1.IGetInventoryRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1.IInventory, - protos.google.cloud.osconfig.v1.IGetInventoryRequest|undefined, {}|undefined - ]>; - getInventory( - request: protos.google.cloud.osconfig.v1.IGetInventoryRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1.IInventory, - protos.google.cloud.osconfig.v1.IGetInventoryRequest|null|undefined, - {}|null|undefined>): void; - getInventory( - request: protos.google.cloud.osconfig.v1.IGetInventoryRequest, - callback: Callback< - protos.google.cloud.osconfig.v1.IInventory, - protos.google.cloud.osconfig.v1.IGetInventoryRequest|null|undefined, - {}|null|undefined>): void; - getInventory( - request?: protos.google.cloud.osconfig.v1.IGetInventoryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1.IInventory, - protos.google.cloud.osconfig.v1.IGetInventoryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1.IInventory, - protos.google.cloud.osconfig.v1.IGetInventoryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1.IInventory, - protos.google.cloud.osconfig.v1.IGetInventoryRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getInventory(request, options, callback); - } -/** - * Gets the vulnerability report for the specified VM instance. Only VMs with - * inventory data have vulnerability reports associated with them. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. API resource name for vulnerability resource. - * - * Format: - * `projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * For `{instance}`, either Compute Engine `instance-id` or `instance-name` - * can be provided. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1.VulnerabilityReport|VulnerabilityReport}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_zonal_service.get_vulnerability_report.js - * region_tag:osconfig_v1_generated_OsConfigZonalService_GetVulnerabilityReport_async - */ - getVulnerabilityReport( - request?: protos.google.cloud.osconfig.v1.IGetVulnerabilityReportRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1.IVulnerabilityReport, - protos.google.cloud.osconfig.v1.IGetVulnerabilityReportRequest|undefined, {}|undefined - ]>; - getVulnerabilityReport( - request: protos.google.cloud.osconfig.v1.IGetVulnerabilityReportRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1.IVulnerabilityReport, - protos.google.cloud.osconfig.v1.IGetVulnerabilityReportRequest|null|undefined, - {}|null|undefined>): void; - getVulnerabilityReport( - request: protos.google.cloud.osconfig.v1.IGetVulnerabilityReportRequest, - callback: Callback< - protos.google.cloud.osconfig.v1.IVulnerabilityReport, - protos.google.cloud.osconfig.v1.IGetVulnerabilityReportRequest|null|undefined, - {}|null|undefined>): void; - getVulnerabilityReport( - request?: protos.google.cloud.osconfig.v1.IGetVulnerabilityReportRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1.IVulnerabilityReport, - protos.google.cloud.osconfig.v1.IGetVulnerabilityReportRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1.IVulnerabilityReport, - protos.google.cloud.osconfig.v1.IGetVulnerabilityReportRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1.IVulnerabilityReport, - protos.google.cloud.osconfig.v1.IGetVulnerabilityReportRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getVulnerabilityReport(request, options, callback); - } - -/** - * Create an OS policy assignment. - * - * This method also creates the first revision of the OS policy assignment. - * - * This method returns a long running operation (LRO) that contains the - * rollout details. The rollout can be cancelled by cancelling the LRO. - * - * For more information, see [Method: - * projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name in the form: - * projects/{project}/locations/{location} - * @param {google.cloud.osconfig.v1.OSPolicyAssignment} request.osPolicyAssignment - * Required. The OS policy assignment to be created. - * @param {string} request.osPolicyAssignmentId - * Required. The logical name of the OS policy assignment in the project - * with the following restrictions: - * - * * Must contain only lowercase letters, numbers, and hyphens. - * * Must start with a letter. - * * Must be between 1-63 characters. - * * Must end with a number or a letter. - * * Must be unique within the project. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_zonal_service.create_o_s_policy_assignment.js - * region_tag:osconfig_v1_generated_OsConfigZonalService_CreateOSPolicyAssignment_async - */ - createOSPolicyAssignment( - request?: protos.google.cloud.osconfig.v1.ICreateOSPolicyAssignmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createOSPolicyAssignment( - request: protos.google.cloud.osconfig.v1.ICreateOSPolicyAssignmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createOSPolicyAssignment( - request: protos.google.cloud.osconfig.v1.ICreateOSPolicyAssignmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createOSPolicyAssignment( - request?: protos.google.cloud.osconfig.v1.ICreateOSPolicyAssignmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createOsPolicyAssignment(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createOSPolicyAssignment()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_zonal_service.create_o_s_policy_assignment.js - * region_tag:osconfig_v1_generated_OsConfigZonalService_CreateOSPolicyAssignment_async - */ - async checkCreateOSPolicyAssignmentProgress(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.createOSPolicyAssignment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Update an existing OS policy assignment. - * - * This method creates a new revision of the OS policy assignment. - * - * This method returns a long running operation (LRO) that contains the - * rollout details. The rollout can be cancelled by cancelling the LRO. - * - * For more information, see [Method: - * projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel). - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.osconfig.v1.OSPolicyAssignment} request.osPolicyAssignment - * Required. The updated OS policy assignment. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask that controls which fields of the assignment should be - * 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_zonal_service.update_o_s_policy_assignment.js - * region_tag:osconfig_v1_generated_OsConfigZonalService_UpdateOSPolicyAssignment_async - */ - updateOSPolicyAssignment( - request?: protos.google.cloud.osconfig.v1.IUpdateOSPolicyAssignmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateOSPolicyAssignment( - request: protos.google.cloud.osconfig.v1.IUpdateOSPolicyAssignmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateOSPolicyAssignment( - request: protos.google.cloud.osconfig.v1.IUpdateOSPolicyAssignmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateOSPolicyAssignment( - request?: protos.google.cloud.osconfig.v1.IUpdateOSPolicyAssignmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'os_policy_assignment.name': request.osPolicyAssignment!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateOsPolicyAssignment(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateOSPolicyAssignment()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_zonal_service.update_o_s_policy_assignment.js - * region_tag:osconfig_v1_generated_OsConfigZonalService_UpdateOSPolicyAssignment_async - */ - async checkUpdateOSPolicyAssignmentProgress(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.updateOSPolicyAssignment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Delete the OS policy assignment. - * - * This method creates a new revision of the OS policy assignment. - * - * This method returns a long running operation (LRO) that contains the - * rollout details. The rollout can be cancelled by cancelling the LRO. - * - * If the LRO completes and is not cancelled, all revisions associated with - * the OS policy assignment are deleted. - * - * For more information, see [Method: - * projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the OS policy assignment to be deleted - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_zonal_service.delete_o_s_policy_assignment.js - * region_tag:osconfig_v1_generated_OsConfigZonalService_DeleteOSPolicyAssignment_async - */ - deleteOSPolicyAssignment( - request?: protos.google.cloud.osconfig.v1.IDeleteOSPolicyAssignmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteOSPolicyAssignment( - request: protos.google.cloud.osconfig.v1.IDeleteOSPolicyAssignmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteOSPolicyAssignment( - request: protos.google.cloud.osconfig.v1.IDeleteOSPolicyAssignmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteOSPolicyAssignment( - request?: protos.google.cloud.osconfig.v1.IDeleteOSPolicyAssignmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteOsPolicyAssignment(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteOSPolicyAssignment()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_zonal_service.delete_o_s_policy_assignment.js - * region_tag:osconfig_v1_generated_OsConfigZonalService_DeleteOSPolicyAssignment_async - */ - async checkDeleteOSPolicyAssignmentProgress(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.deleteOSPolicyAssignment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * List the OS policy assignments under the parent resource. - * - * For each OS policy assignment, the latest revision is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {number} request.pageSize - * The maximum number of assignments to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListOSPolicyAssignments` that indicates where this listing should continue - * from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1.OSPolicyAssignment|OSPolicyAssignment}. - * 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 `listOSPolicyAssignmentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listOSPolicyAssignments( - request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1.IOSPolicyAssignment[], - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest|null, - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsResponse - ]>; - listOSPolicyAssignments( - request: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest, - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IOSPolicyAssignment>): void; - listOSPolicyAssignments( - request: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest, - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IOSPolicyAssignment>): void; - listOSPolicyAssignments( - request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest, - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IOSPolicyAssignment>, - callback?: PaginationCallback< - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest, - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IOSPolicyAssignment>): - Promise<[ - protos.google.cloud.osconfig.v1.IOSPolicyAssignment[], - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest|null, - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listOsPolicyAssignments(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 resource name. - * @param {number} request.pageSize - * The maximum number of assignments to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListOSPolicyAssignments` that indicates where this listing should continue - * from. - * @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 protos.google.cloud.osconfig.v1.OSPolicyAssignment|OSPolicyAssignment} 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 `listOSPolicyAssignmentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listOSPolicyAssignmentsStream( - request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest, - 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['listOsPolicyAssignments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listOSPolicyAssignments.createStream( - this.innerApiCalls.listOsPolicyAssignments as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listOSPolicyAssignments`, 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 resource name. - * @param {number} request.pageSize - * The maximum number of assignments to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListOSPolicyAssignments` that indicates where this listing should continue - * from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.osconfig.v1.OSPolicyAssignment|OSPolicyAssignment}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignments.js - * region_tag:osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignments_async - */ - listOSPolicyAssignmentsAsync( - request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentsRequest, - 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['listOsPolicyAssignments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listOSPolicyAssignments.asyncIterate( - this.innerApiCalls['listOsPolicyAssignments'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * List the OS policy assignment revisions for a given OS policy assignment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the OS policy assignment to list revisions for. - * @param {number} request.pageSize - * The maximum number of revisions to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListOSPolicyAssignmentRevisions` that indicates where this listing should - * continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1.OSPolicyAssignment|OSPolicyAssignment}. - * 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 `listOSPolicyAssignmentRevisionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listOSPolicyAssignmentRevisions( - request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1.IOSPolicyAssignment[], - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest|null, - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsResponse - ]>; - listOSPolicyAssignmentRevisions( - request: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest, - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IOSPolicyAssignment>): void; - listOSPolicyAssignmentRevisions( - request: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest, - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IOSPolicyAssignment>): void; - listOSPolicyAssignmentRevisions( - request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest, - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IOSPolicyAssignment>, - callback?: PaginationCallback< - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest, - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IOSPolicyAssignment>): - Promise<[ - protos.google.cloud.osconfig.v1.IOSPolicyAssignment[], - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest|null, - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.listOsPolicyAssignmentRevisions(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the OS policy assignment to list revisions for. - * @param {number} request.pageSize - * The maximum number of revisions to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListOSPolicyAssignmentRevisions` that indicates where this listing should - * continue from. - * @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 protos.google.cloud.osconfig.v1.OSPolicyAssignment|OSPolicyAssignment} 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 `listOSPolicyAssignmentRevisionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listOSPolicyAssignmentRevisionsStream( - request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - const defaultCallSettings = this._defaults['listOsPolicyAssignmentRevisions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listOSPolicyAssignmentRevisions.createStream( - this.innerApiCalls.listOsPolicyAssignmentRevisions as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listOSPolicyAssignmentRevisions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the OS policy assignment to list revisions for. - * @param {number} request.pageSize - * The maximum number of revisions to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListOSPolicyAssignmentRevisions` that indicates where this listing should - * continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.osconfig.v1.OSPolicyAssignment|OSPolicyAssignment}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignment_revisions.js - * region_tag:osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignmentRevisions_async - */ - listOSPolicyAssignmentRevisionsAsync( - request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentRevisionsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - const defaultCallSettings = this._defaults['listOsPolicyAssignmentRevisions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate( - this.innerApiCalls['listOsPolicyAssignmentRevisions'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * List OS policy asssignment reports for all Compute Engine VM instances in - * the specified zone. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * - * Format: - * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/reports` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * For `{instance}`, either `instance-name`, `instance-id`, or `-` can be - * provided. If '-' is provided, the response will include - * OSPolicyAssignmentReports for all instances in the project/location. - * For `{assignment}`, either `assignment-id` or `-` can be provided. If '-' - * is provided, the response will include OSPolicyAssignmentReports for all - * OSPolicyAssignments in the project/location. - * Either {instance} or {assignment} must be `-`. - * - * For example: - * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/-/reports` - * returns all reports for the instance - * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/{assignment-id}/reports` - * returns all the reports for the given assignment across all instances. - * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/-/reports` - * returns all the reports for all assignments across all instances. - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by the - * `OSPolicyAssignmentReport` API resource that is included in the response. - * @param {string} request.pageToken - * A pagination token returned from a previous call to the - * `ListOSPolicyAssignmentReports` method that indicates where this listing - * should continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport|OSPolicyAssignmentReport}. - * 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 `listOSPolicyAssignmentReportsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listOSPolicyAssignmentReports( - request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport[], - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest|null, - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsResponse - ]>; - listOSPolicyAssignmentReports( - request: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest, - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport>): void; - listOSPolicyAssignmentReports( - request: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest, - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport>): void; - listOSPolicyAssignmentReports( - request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest, - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport>, - callback?: PaginationCallback< - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest, - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport>): - Promise<[ - protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport[], - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest|null, - protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listOsPolicyAssignmentReports(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 resource name. - * - * Format: - * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/reports` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * For `{instance}`, either `instance-name`, `instance-id`, or `-` can be - * provided. If '-' is provided, the response will include - * OSPolicyAssignmentReports for all instances in the project/location. - * For `{assignment}`, either `assignment-id` or `-` can be provided. If '-' - * is provided, the response will include OSPolicyAssignmentReports for all - * OSPolicyAssignments in the project/location. - * Either {instance} or {assignment} must be `-`. - * - * For example: - * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/-/reports` - * returns all reports for the instance - * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/{assignment-id}/reports` - * returns all the reports for the given assignment across all instances. - * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/-/reports` - * returns all the reports for all assignments across all instances. - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by the - * `OSPolicyAssignmentReport` API resource that is included in the response. - * @param {string} request.pageToken - * A pagination token returned from a previous call to the - * `ListOSPolicyAssignmentReports` method that indicates where this listing - * should continue from. - * @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 protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport|OSPolicyAssignmentReport} 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 `listOSPolicyAssignmentReportsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listOSPolicyAssignmentReportsStream( - request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest, - 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['listOsPolicyAssignmentReports']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listOSPolicyAssignmentReports.createStream( - this.innerApiCalls.listOsPolicyAssignmentReports as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listOSPolicyAssignmentReports`, 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 resource name. - * - * Format: - * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/reports` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * For `{instance}`, either `instance-name`, `instance-id`, or `-` can be - * provided. If '-' is provided, the response will include - * OSPolicyAssignmentReports for all instances in the project/location. - * For `{assignment}`, either `assignment-id` or `-` can be provided. If '-' - * is provided, the response will include OSPolicyAssignmentReports for all - * OSPolicyAssignments in the project/location. - * Either {instance} or {assignment} must be `-`. - * - * For example: - * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/-/reports` - * returns all reports for the instance - * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/{assignment-id}/reports` - * returns all the reports for the given assignment across all instances. - * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/-/reports` - * returns all the reports for all assignments across all instances. - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by the - * `OSPolicyAssignmentReport` API resource that is included in the response. - * @param {string} request.pageToken - * A pagination token returned from a previous call to the - * `ListOSPolicyAssignmentReports` method that indicates where this listing - * should continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport|OSPolicyAssignmentReport}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_zonal_service.list_o_s_policy_assignment_reports.js - * region_tag:osconfig_v1_generated_OsConfigZonalService_ListOSPolicyAssignmentReports_async - */ - listOSPolicyAssignmentReportsAsync( - request?: protos.google.cloud.osconfig.v1.IListOSPolicyAssignmentReportsRequest, - 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['listOsPolicyAssignmentReports']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listOSPolicyAssignmentReports.asyncIterate( - this.innerApiCalls['listOsPolicyAssignmentReports'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * List inventory data for all VM instances in the specified zone. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * - * Format: `projects/{project}/locations/{location}/instances/-` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * @param {google.cloud.osconfig.v1.InventoryView} request.view - * Inventory view indicating what information should be included in the - * inventory resource. If unspecified, the default view is BASIC. - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListInventories` that indicates where this listing - * should continue from. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by a - * `Inventory` API resource to be included in the response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1.Inventory|Inventory}. - * 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 `listInventoriesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listInventories( - request?: protos.google.cloud.osconfig.v1.IListInventoriesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1.IInventory[], - protos.google.cloud.osconfig.v1.IListInventoriesRequest|null, - protos.google.cloud.osconfig.v1.IListInventoriesResponse - ]>; - listInventories( - request: protos.google.cloud.osconfig.v1.IListInventoriesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1.IListInventoriesRequest, - protos.google.cloud.osconfig.v1.IListInventoriesResponse|null|undefined, - protos.google.cloud.osconfig.v1.IInventory>): void; - listInventories( - request: protos.google.cloud.osconfig.v1.IListInventoriesRequest, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1.IListInventoriesRequest, - protos.google.cloud.osconfig.v1.IListInventoriesResponse|null|undefined, - protos.google.cloud.osconfig.v1.IInventory>): void; - listInventories( - request?: protos.google.cloud.osconfig.v1.IListInventoriesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.osconfig.v1.IListInventoriesRequest, - protos.google.cloud.osconfig.v1.IListInventoriesResponse|null|undefined, - protos.google.cloud.osconfig.v1.IInventory>, - callback?: PaginationCallback< - protos.google.cloud.osconfig.v1.IListInventoriesRequest, - protos.google.cloud.osconfig.v1.IListInventoriesResponse|null|undefined, - protos.google.cloud.osconfig.v1.IInventory>): - Promise<[ - protos.google.cloud.osconfig.v1.IInventory[], - protos.google.cloud.osconfig.v1.IListInventoriesRequest|null, - protos.google.cloud.osconfig.v1.IListInventoriesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listInventories(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 resource name. - * - * Format: `projects/{project}/locations/{location}/instances/-` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * @param {google.cloud.osconfig.v1.InventoryView} request.view - * Inventory view indicating what information should be included in the - * inventory resource. If unspecified, the default view is BASIC. - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListInventories` that indicates where this listing - * should continue from. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by a - * `Inventory` API resource to be included in the response. - * @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 protos.google.cloud.osconfig.v1.Inventory|Inventory} 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 `listInventoriesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listInventoriesStream( - request?: protos.google.cloud.osconfig.v1.IListInventoriesRequest, - 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['listInventories']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInventories.createStream( - this.innerApiCalls.listInventories as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listInventories`, 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 resource name. - * - * Format: `projects/{project}/locations/{location}/instances/-` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * @param {google.cloud.osconfig.v1.InventoryView} request.view - * Inventory view indicating what information should be included in the - * inventory resource. If unspecified, the default view is BASIC. - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListInventories` that indicates where this listing - * should continue from. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by a - * `Inventory` API resource to be included in the response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.osconfig.v1.Inventory|Inventory}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_zonal_service.list_inventories.js - * region_tag:osconfig_v1_generated_OsConfigZonalService_ListInventories_async - */ - listInventoriesAsync( - request?: protos.google.cloud.osconfig.v1.IListInventoriesRequest, - 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['listInventories']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInventories.asyncIterate( - this.innerApiCalls['listInventories'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * List vulnerability reports for all VM instances in the specified zone. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * - * Format: `projects/{project}/locations/{location}/instances/-` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListVulnerabilityReports` that indicates where this listing - * should continue from. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by a - * `vulnerabilityReport` API resource to be included in the response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1.VulnerabilityReport|VulnerabilityReport}. - * 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 `listVulnerabilityReportsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listVulnerabilityReports( - request?: protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1.IVulnerabilityReport[], - protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest|null, - protos.google.cloud.osconfig.v1.IListVulnerabilityReportsResponse - ]>; - listVulnerabilityReports( - request: protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest, - protos.google.cloud.osconfig.v1.IListVulnerabilityReportsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IVulnerabilityReport>): void; - listVulnerabilityReports( - request: protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest, - protos.google.cloud.osconfig.v1.IListVulnerabilityReportsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IVulnerabilityReport>): void; - listVulnerabilityReports( - request?: protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest, - protos.google.cloud.osconfig.v1.IListVulnerabilityReportsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IVulnerabilityReport>, - callback?: PaginationCallback< - protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest, - protos.google.cloud.osconfig.v1.IListVulnerabilityReportsResponse|null|undefined, - protos.google.cloud.osconfig.v1.IVulnerabilityReport>): - Promise<[ - protos.google.cloud.osconfig.v1.IVulnerabilityReport[], - protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest|null, - protos.google.cloud.osconfig.v1.IListVulnerabilityReportsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listVulnerabilityReports(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 resource name. - * - * Format: `projects/{project}/locations/{location}/instances/-` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListVulnerabilityReports` that indicates where this listing - * should continue from. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by a - * `vulnerabilityReport` API resource to be included in the response. - * @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 protos.google.cloud.osconfig.v1.VulnerabilityReport|VulnerabilityReport} 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 `listVulnerabilityReportsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listVulnerabilityReportsStream( - request?: protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest, - 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['listVulnerabilityReports']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listVulnerabilityReports.createStream( - this.innerApiCalls.listVulnerabilityReports as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listVulnerabilityReports`, 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 resource name. - * - * Format: `projects/{project}/locations/{location}/instances/-` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListVulnerabilityReports` that indicates where this listing - * should continue from. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by a - * `vulnerabilityReport` API resource to be included in the response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.osconfig.v1.VulnerabilityReport|VulnerabilityReport}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_config_zonal_service.list_vulnerability_reports.js - * region_tag:osconfig_v1_generated_OsConfigZonalService_ListVulnerabilityReports_async - */ - listVulnerabilityReportsAsync( - request?: protos.google.cloud.osconfig.v1.IListVulnerabilityReportsRequest, - 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['listVulnerabilityReports']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listVulnerabilityReports.asyncIterate( - this.innerApiCalls['listVulnerabilityReports'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified inventory resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} instance - * @returns {string} Resource name string. - */ - inventoryPath(project:string,location:string,instance:string) { - return this.pathTemplates.inventoryPathTemplate.render({ - project: project, - location: location, - instance: instance, - }); - } - - /** - * Parse the project from Inventory resource. - * - * @param {string} inventoryName - * A fully-qualified path representing Inventory resource. - * @returns {string} A string representing the project. - */ - matchProjectFromInventoryName(inventoryName: string) { - return this.pathTemplates.inventoryPathTemplate.match(inventoryName).project; - } - - /** - * Parse the location from Inventory resource. - * - * @param {string} inventoryName - * A fully-qualified path representing Inventory resource. - * @returns {string} A string representing the location. - */ - matchLocationFromInventoryName(inventoryName: string) { - return this.pathTemplates.inventoryPathTemplate.match(inventoryName).location; - } - - /** - * Parse the instance from Inventory resource. - * - * @param {string} inventoryName - * A fully-qualified path representing Inventory resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromInventoryName(inventoryName: string) { - return this.pathTemplates.inventoryPathTemplate.match(inventoryName).instance; - } - - /** - * Return a fully-qualified oSPolicyAssignment resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} os_policy_assignment - * @returns {string} Resource name string. - */ - oSPolicyAssignmentPath(project:string,location:string,osPolicyAssignment:string) { - return this.pathTemplates.oSPolicyAssignmentPathTemplate.render({ - project: project, - location: location, - os_policy_assignment: osPolicyAssignment, - }); - } - - /** - * Parse the project from OSPolicyAssignment resource. - * - * @param {string} oSPolicyAssignmentName - * A fully-qualified path representing OSPolicyAssignment resource. - * @returns {string} A string representing the project. - */ - matchProjectFromOSPolicyAssignmentName(oSPolicyAssignmentName: string) { - return this.pathTemplates.oSPolicyAssignmentPathTemplate.match(oSPolicyAssignmentName).project; - } - - /** - * Parse the location from OSPolicyAssignment resource. - * - * @param {string} oSPolicyAssignmentName - * A fully-qualified path representing OSPolicyAssignment resource. - * @returns {string} A string representing the location. - */ - matchLocationFromOSPolicyAssignmentName(oSPolicyAssignmentName: string) { - return this.pathTemplates.oSPolicyAssignmentPathTemplate.match(oSPolicyAssignmentName).location; - } - - /** - * Parse the os_policy_assignment from OSPolicyAssignment resource. - * - * @param {string} oSPolicyAssignmentName - * A fully-qualified path representing OSPolicyAssignment resource. - * @returns {string} A string representing the os_policy_assignment. - */ - matchOsPolicyAssignmentFromOSPolicyAssignmentName(oSPolicyAssignmentName: string) { - return this.pathTemplates.oSPolicyAssignmentPathTemplate.match(oSPolicyAssignmentName).os_policy_assignment; - } - - /** - * Return a fully-qualified oSPolicyAssignmentReport resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} instance - * @param {string} assignment - * @returns {string} Resource name string. - */ - oSPolicyAssignmentReportPath(project:string,location:string,instance:string,assignment:string) { - return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.render({ - project: project, - location: location, - instance: instance, - assignment: assignment, - }); - } - - /** - * Parse the project from OSPolicyAssignmentReport resource. - * - * @param {string} oSPolicyAssignmentReportName - * A fully-qualified path representing OSPolicyAssignmentReport resource. - * @returns {string} A string representing the project. - */ - matchProjectFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { - return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).project; - } - - /** - * Parse the location from OSPolicyAssignmentReport resource. - * - * @param {string} oSPolicyAssignmentReportName - * A fully-qualified path representing OSPolicyAssignmentReport resource. - * @returns {string} A string representing the location. - */ - matchLocationFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { - return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).location; - } - - /** - * Parse the instance from OSPolicyAssignmentReport resource. - * - * @param {string} oSPolicyAssignmentReportName - * A fully-qualified path representing OSPolicyAssignmentReport resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { - return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).instance; - } - - /** - * Parse the assignment from OSPolicyAssignmentReport resource. - * - * @param {string} oSPolicyAssignmentReportName - * A fully-qualified path representing OSPolicyAssignmentReport resource. - * @returns {string} A string representing the assignment. - */ - matchAssignmentFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { - return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).assignment; - } - - /** - * Return a fully-qualified patchDeployment resource name string. - * - * @param {string} project - * @param {string} patch_deployment - * @returns {string} Resource name string. - */ - patchDeploymentPath(project:string,patchDeployment:string) { - return this.pathTemplates.patchDeploymentPathTemplate.render({ - project: project, - patch_deployment: patchDeployment, - }); - } - - /** - * Parse the project from PatchDeployment resource. - * - * @param {string} patchDeploymentName - * A fully-qualified path representing PatchDeployment resource. - * @returns {string} A string representing the project. - */ - matchProjectFromPatchDeploymentName(patchDeploymentName: string) { - return this.pathTemplates.patchDeploymentPathTemplate.match(patchDeploymentName).project; - } - - /** - * Parse the patch_deployment from PatchDeployment resource. - * - * @param {string} patchDeploymentName - * A fully-qualified path representing PatchDeployment resource. - * @returns {string} A string representing the patch_deployment. - */ - matchPatchDeploymentFromPatchDeploymentName(patchDeploymentName: string) { - return this.pathTemplates.patchDeploymentPathTemplate.match(patchDeploymentName).patch_deployment; - } - - /** - * Return a fully-qualified patchJob resource name string. - * - * @param {string} project - * @param {string} patch_job - * @returns {string} Resource name string. - */ - patchJobPath(project:string,patchJob:string) { - return this.pathTemplates.patchJobPathTemplate.render({ - project: project, - patch_job: patchJob, - }); - } - - /** - * Parse the project from PatchJob resource. - * - * @param {string} patchJobName - * A fully-qualified path representing PatchJob resource. - * @returns {string} A string representing the project. - */ - matchProjectFromPatchJobName(patchJobName: string) { - return this.pathTemplates.patchJobPathTemplate.match(patchJobName).project; - } - - /** - * Parse the patch_job from PatchJob resource. - * - * @param {string} patchJobName - * A fully-qualified path representing PatchJob resource. - * @returns {string} A string representing the patch_job. - */ - matchPatchJobFromPatchJobName(patchJobName: string) { - return this.pathTemplates.patchJobPathTemplate.match(patchJobName).patch_job; - } - - /** - * Return a fully-qualified vulnerabilityReport resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} instance - * @returns {string} Resource name string. - */ - vulnerabilityReportPath(project:string,location:string,instance:string) { - return this.pathTemplates.vulnerabilityReportPathTemplate.render({ - project: project, - location: location, - instance: instance, - }); - } - - /** - * Parse the project from VulnerabilityReport resource. - * - * @param {string} vulnerabilityReportName - * A fully-qualified path representing VulnerabilityReport resource. - * @returns {string} A string representing the project. - */ - matchProjectFromVulnerabilityReportName(vulnerabilityReportName: string) { - return this.pathTemplates.vulnerabilityReportPathTemplate.match(vulnerabilityReportName).project; - } - - /** - * Parse the location from VulnerabilityReport resource. - * - * @param {string} vulnerabilityReportName - * A fully-qualified path representing VulnerabilityReport resource. - * @returns {string} A string representing the location. - */ - matchLocationFromVulnerabilityReportName(vulnerabilityReportName: string) { - return this.pathTemplates.vulnerabilityReportPathTemplate.match(vulnerabilityReportName).location; - } - - /** - * Parse the instance from VulnerabilityReport resource. - * - * @param {string} vulnerabilityReportName - * A fully-qualified path representing VulnerabilityReport resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromVulnerabilityReportName(vulnerabilityReportName: string) { - return this.pathTemplates.vulnerabilityReportPathTemplate.match(vulnerabilityReportName).instance; - } - - /** - * 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.osConfigZonalServiceStub && !this._terminated) { - return this.osConfigZonalServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_client_config.json b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_client_config.json deleted file mode 100644 index bb97e593101..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_client_config.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "interfaces": { - "google.cloud.osconfig.v1.OsConfigZonalService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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 - }, - "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c": { - "initial_retry_delay_millis": 1000, - "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": { - "CreateOSPolicyAssignment": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "UpdateOSPolicyAssignment": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "GetOSPolicyAssignment": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "ListOSPolicyAssignments": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "ListOSPolicyAssignmentRevisions": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "DeleteOSPolicyAssignment": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "GetOSPolicyAssignmentReport": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "ListOSPolicyAssignmentReports": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "GetInventory": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "ListInventories": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "GetVulnerabilityReport": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "ListVulnerabilityReports": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_proto_list.json b/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_proto_list.json deleted file mode 100644 index e074f70ca02..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/src/v1/os_config_zonal_service_proto_list.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - "../../protos/google/cloud/osconfig/v1/inventory.proto", - "../../protos/google/cloud/osconfig/v1/os_policy.proto", - "../../protos/google/cloud/osconfig/v1/os_policy_assignment_reports.proto", - "../../protos/google/cloud/osconfig/v1/os_policy_assignments.proto", - "../../protos/google/cloud/osconfig/v1/osconfig_common.proto", - "../../protos/google/cloud/osconfig/v1/osconfig_service.proto", - "../../protos/google/cloud/osconfig/v1/osconfig_zonal_service.proto", - "../../protos/google/cloud/osconfig/v1/patch_deployments.proto", - "../../protos/google/cloud/osconfig/v1/patch_jobs.proto", - "../../protos/google/cloud/osconfig/v1/vulnerability.proto" -] diff --git a/owl-bot-staging/google-cloud-osconfig/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-osconfig/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index d31b72946ae..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const osconfig = require('@google-cloud/os-config'); - -function main() { - const osConfigServiceClient = new osconfig.OsConfigServiceClient(); - const osConfigZonalServiceClient = new osconfig.OsConfigZonalServiceClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-osconfig/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index bcff84a935f..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +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 {OsConfigServiceClient, OsConfigZonalServiceClient} from '@google-cloud/os-config'; - -// check that the client class type name can be used -function doStuffWithOsConfigServiceClient(client: OsConfigServiceClient) { - client.close(); -} -function doStuffWithOsConfigZonalServiceClient(client: OsConfigZonalServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const osConfigServiceClient = new OsConfigServiceClient(); - doStuffWithOsConfigServiceClient(osConfigServiceClient); - // check that the client instance can be created - const osConfigZonalServiceClient = new OsConfigZonalServiceClient(); - doStuffWithOsConfigZonalServiceClient(osConfigZonalServiceClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/system-test/install.ts b/owl-bot-staging/google-cloud-osconfig/v1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/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-osconfig/v1/test/gapic_os_config_service_v1.ts b/owl-bot-staging/google-cloud-osconfig/v1/test/gapic_os_config_service_v1.ts deleted file mode 100644 index 8cc6e4641d6..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/test/gapic_os_config_service_v1.ts +++ /dev/null @@ -1,2179 +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 osconfigserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.OsConfigServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = osconfigserviceModule.v1.OsConfigServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = osconfigserviceModule.v1.OsConfigServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = osconfigserviceModule.v1.OsConfigServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.osConfigServiceStub, undefined); - await client.initialize(); - assert(client.osConfigServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.osConfigServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.osConfigServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - 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 osconfigserviceModule.v1.OsConfigServiceClient({ - 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('executePatchJob', () => { - it('invokes executePatchJob without error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ExecutePatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ExecutePatchJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.PatchJob() - ); - client.innerApiCalls.executePatchJob = stubSimpleCall(expectedResponse); - const [response] = await client.executePatchJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executePatchJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executePatchJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executePatchJob without error using callback', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ExecutePatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ExecutePatchJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.PatchJob() - ); - client.innerApiCalls.executePatchJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.executePatchJob( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executePatchJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executePatchJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executePatchJob with error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ExecutePatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ExecutePatchJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.executePatchJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.executePatchJob(request), expectedError); - const actualRequest = (client.innerApiCalls.executePatchJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executePatchJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executePatchJob with closed client', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ExecutePatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ExecutePatchJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.executePatchJob(request), expectedError); - }); - }); - - describe('getPatchJob', () => { - it('invokes getPatchJob without error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetPatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetPatchJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.PatchJob() - ); - client.innerApiCalls.getPatchJob = stubSimpleCall(expectedResponse); - const [response] = await client.getPatchJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPatchJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPatchJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPatchJob without error using callback', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetPatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetPatchJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.PatchJob() - ); - client.innerApiCalls.getPatchJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getPatchJob( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPatchJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPatchJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPatchJob with error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetPatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetPatchJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getPatchJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getPatchJob(request), expectedError); - const actualRequest = (client.innerApiCalls.getPatchJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPatchJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPatchJob with closed client', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetPatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetPatchJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getPatchJob(request), expectedError); - }); - }); - - describe('cancelPatchJob', () => { - it('invokes cancelPatchJob without error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.CancelPatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.CancelPatchJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.PatchJob() - ); - client.innerApiCalls.cancelPatchJob = stubSimpleCall(expectedResponse); - const [response] = await client.cancelPatchJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.cancelPatchJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.cancelPatchJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes cancelPatchJob without error using callback', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.CancelPatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.CancelPatchJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.PatchJob() - ); - client.innerApiCalls.cancelPatchJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.cancelPatchJob( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.cancelPatchJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.cancelPatchJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes cancelPatchJob with error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.CancelPatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.CancelPatchJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.cancelPatchJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.cancelPatchJob(request), expectedError); - const actualRequest = (client.innerApiCalls.cancelPatchJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.cancelPatchJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes cancelPatchJob with closed client', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.CancelPatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.CancelPatchJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.cancelPatchJob(request), expectedError); - }); - }); - - describe('createPatchDeployment', () => { - it('invokes createPatchDeployment without error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.CreatePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.CreatePatchDeploymentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.PatchDeployment() - ); - client.innerApiCalls.createPatchDeployment = stubSimpleCall(expectedResponse); - const [response] = await client.createPatchDeployment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createPatchDeployment without error using callback', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.CreatePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.CreatePatchDeploymentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.PatchDeployment() - ); - client.innerApiCalls.createPatchDeployment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createPatchDeployment( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchDeployment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createPatchDeployment with error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.CreatePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.CreatePatchDeploymentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createPatchDeployment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createPatchDeployment(request), expectedError); - const actualRequest = (client.innerApiCalls.createPatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createPatchDeployment with closed client', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.CreatePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.CreatePatchDeploymentRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createPatchDeployment(request), expectedError); - }); - }); - - describe('getPatchDeployment', () => { - it('invokes getPatchDeployment without error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetPatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetPatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.PatchDeployment() - ); - client.innerApiCalls.getPatchDeployment = stubSimpleCall(expectedResponse); - const [response] = await client.getPatchDeployment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPatchDeployment without error using callback', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetPatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetPatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.PatchDeployment() - ); - client.innerApiCalls.getPatchDeployment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getPatchDeployment( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchDeployment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPatchDeployment with error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetPatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetPatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getPatchDeployment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getPatchDeployment(request), expectedError); - const actualRequest = (client.innerApiCalls.getPatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPatchDeployment with closed client', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetPatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetPatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getPatchDeployment(request), expectedError); - }); - }); - - describe('deletePatchDeployment', () => { - it('invokes deletePatchDeployment without error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.DeletePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.DeletePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePatchDeployment = stubSimpleCall(expectedResponse); - const [response] = await client.deletePatchDeployment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deletePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePatchDeployment without error using callback', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.DeletePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.DeletePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePatchDeployment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deletePatchDeployment( - 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.deletePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePatchDeployment with error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.DeletePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.DeletePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deletePatchDeployment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deletePatchDeployment(request), expectedError); - const actualRequest = (client.innerApiCalls.deletePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePatchDeployment with closed client', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.DeletePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.DeletePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deletePatchDeployment(request), expectedError); - }); - }); - - describe('updatePatchDeployment', () => { - it('invokes updatePatchDeployment without error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.UpdatePatchDeploymentRequest() - ); - request.patchDeployment ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.UpdatePatchDeploymentRequest', ['patchDeployment', 'name']); - request.patchDeployment.name = defaultValue1; - const expectedHeaderRequestParams = `patch_deployment.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.PatchDeployment() - ); - client.innerApiCalls.updatePatchDeployment = stubSimpleCall(expectedResponse); - const [response] = await client.updatePatchDeployment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updatePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updatePatchDeployment without error using callback', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.UpdatePatchDeploymentRequest() - ); - request.patchDeployment ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.UpdatePatchDeploymentRequest', ['patchDeployment', 'name']); - request.patchDeployment.name = defaultValue1; - const expectedHeaderRequestParams = `patch_deployment.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.PatchDeployment() - ); - client.innerApiCalls.updatePatchDeployment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updatePatchDeployment( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchDeployment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updatePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updatePatchDeployment with error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.UpdatePatchDeploymentRequest() - ); - request.patchDeployment ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.UpdatePatchDeploymentRequest', ['patchDeployment', 'name']); - request.patchDeployment.name = defaultValue1; - const expectedHeaderRequestParams = `patch_deployment.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updatePatchDeployment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updatePatchDeployment(request), expectedError); - const actualRequest = (client.innerApiCalls.updatePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updatePatchDeployment with closed client', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.UpdatePatchDeploymentRequest() - ); - request.patchDeployment ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.UpdatePatchDeploymentRequest', ['patchDeployment', 'name']); - request.patchDeployment.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updatePatchDeployment(request), expectedError); - }); - }); - - describe('pausePatchDeployment', () => { - it('invokes pausePatchDeployment without error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.PausePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.PausePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.PatchDeployment() - ); - client.innerApiCalls.pausePatchDeployment = stubSimpleCall(expectedResponse); - const [response] = await client.pausePatchDeployment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pausePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pausePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pausePatchDeployment without error using callback', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.PausePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.PausePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.PatchDeployment() - ); - client.innerApiCalls.pausePatchDeployment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.pausePatchDeployment( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchDeployment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pausePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pausePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pausePatchDeployment with error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.PausePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.PausePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.pausePatchDeployment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.pausePatchDeployment(request), expectedError); - const actualRequest = (client.innerApiCalls.pausePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pausePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pausePatchDeployment with closed client', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.PausePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.PausePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.pausePatchDeployment(request), expectedError); - }); - }); - - describe('resumePatchDeployment', () => { - it('invokes resumePatchDeployment without error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ResumePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ResumePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.PatchDeployment() - ); - client.innerApiCalls.resumePatchDeployment = stubSimpleCall(expectedResponse); - const [response] = await client.resumePatchDeployment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumePatchDeployment without error using callback', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ResumePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ResumePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.PatchDeployment() - ); - client.innerApiCalls.resumePatchDeployment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resumePatchDeployment( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchDeployment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumePatchDeployment with error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ResumePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ResumePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.resumePatchDeployment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.resumePatchDeployment(request), expectedError); - const actualRequest = (client.innerApiCalls.resumePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumePatchDeployment with closed client', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ResumePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ResumePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.resumePatchDeployment(request), expectedError); - }); - }); - - describe('listPatchJobs', () => { - it('invokes listPatchJobs without error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListPatchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), - ]; - client.innerApiCalls.listPatchJobs = stubSimpleCall(expectedResponse); - const [response] = await client.listPatchJobs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPatchJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPatchJobs without error using callback', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListPatchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), - ]; - client.innerApiCalls.listPatchJobs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listPatchJobs( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchJob[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPatchJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPatchJobs with error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListPatchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listPatchJobs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listPatchJobs(request), expectedError); - const actualRequest = (client.innerApiCalls.listPatchJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPatchJobsStream without error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListPatchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), - ]; - client.descriptors.page.listPatchJobs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listPatchJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1.PatchJob[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1.PatchJob) => { - 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.listPatchJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPatchJobs, request)); - assert( - (client.descriptors.page.listPatchJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listPatchJobsStream with error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListPatchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listPatchJobs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listPatchJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1.PatchJob[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1.PatchJob) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listPatchJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPatchJobs, request)); - assert( - (client.descriptors.page.listPatchJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPatchJobs without error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListPatchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJob()), - ]; - client.descriptors.page.listPatchJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.osconfig.v1.IPatchJob[] = []; - const iterable = client.listPatchJobsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listPatchJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPatchJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPatchJobs with error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListPatchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listPatchJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listPatchJobsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.osconfig.v1.IPatchJob[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listPatchJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPatchJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listPatchJobInstanceDetails', () => { - it('invokes listPatchJobInstanceDetails without error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), - ]; - client.innerApiCalls.listPatchJobInstanceDetails = stubSimpleCall(expectedResponse); - const [response] = await client.listPatchJobInstanceDetails(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPatchJobInstanceDetails without error using callback', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), - ]; - client.innerApiCalls.listPatchJobInstanceDetails = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listPatchJobInstanceDetails( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchJobInstanceDetails[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPatchJobInstanceDetails with error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listPatchJobInstanceDetails = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listPatchJobInstanceDetails(request), expectedError); - const actualRequest = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPatchJobInstanceDetailsStream without error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), - ]; - client.descriptors.page.listPatchJobInstanceDetails.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listPatchJobInstanceDetailsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1.PatchJobInstanceDetails[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1.PatchJobInstanceDetails) => { - 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.listPatchJobInstanceDetails.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPatchJobInstanceDetails, request)); - assert( - (client.descriptors.page.listPatchJobInstanceDetails.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listPatchJobInstanceDetailsStream with error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listPatchJobInstanceDetails.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listPatchJobInstanceDetailsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1.PatchJobInstanceDetails[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1.PatchJobInstanceDetails) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listPatchJobInstanceDetails.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPatchJobInstanceDetails, request)); - assert( - (client.descriptors.page.listPatchJobInstanceDetails.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPatchJobInstanceDetails without error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchJobInstanceDetails()), - ]; - client.descriptors.page.listPatchJobInstanceDetails.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.osconfig.v1.IPatchJobInstanceDetails[] = []; - const iterable = client.listPatchJobInstanceDetailsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listPatchJobInstanceDetails.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPatchJobInstanceDetails.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPatchJobInstanceDetails with error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchJobInstanceDetailsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listPatchJobInstanceDetails.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listPatchJobInstanceDetailsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.osconfig.v1.IPatchJobInstanceDetails[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listPatchJobInstanceDetails.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPatchJobInstanceDetails.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listPatchDeployments', () => { - it('invokes listPatchDeployments without error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListPatchDeploymentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchDeploymentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), - ]; - client.innerApiCalls.listPatchDeployments = stubSimpleCall(expectedResponse); - const [response] = await client.listPatchDeployments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPatchDeployments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPatchDeployments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPatchDeployments without error using callback', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListPatchDeploymentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchDeploymentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), - ]; - client.innerApiCalls.listPatchDeployments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listPatchDeployments( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IPatchDeployment[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPatchDeployments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPatchDeployments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPatchDeployments with error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListPatchDeploymentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchDeploymentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listPatchDeployments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listPatchDeployments(request), expectedError); - const actualRequest = (client.innerApiCalls.listPatchDeployments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPatchDeployments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPatchDeploymentsStream without error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListPatchDeploymentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchDeploymentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), - ]; - client.descriptors.page.listPatchDeployments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listPatchDeploymentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1.PatchDeployment[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1.PatchDeployment) => { - 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.listPatchDeployments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPatchDeployments, request)); - assert( - (client.descriptors.page.listPatchDeployments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listPatchDeploymentsStream with error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListPatchDeploymentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchDeploymentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listPatchDeployments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listPatchDeploymentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1.PatchDeployment[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1.PatchDeployment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listPatchDeployments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPatchDeployments, request)); - assert( - (client.descriptors.page.listPatchDeployments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPatchDeployments without error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListPatchDeploymentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchDeploymentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.PatchDeployment()), - ]; - client.descriptors.page.listPatchDeployments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.osconfig.v1.IPatchDeployment[] = []; - const iterable = client.listPatchDeploymentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listPatchDeployments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPatchDeployments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPatchDeployments with error', async () => { - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListPatchDeploymentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListPatchDeploymentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listPatchDeployments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listPatchDeploymentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.osconfig.v1.IPatchDeployment[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listPatchDeployments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPatchDeployments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('inventory', () => { - const fakePath = "/rendered/path/inventory"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - }; - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.inventoryPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.inventoryPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('inventoryPath', () => { - const result = client.inventoryPath("projectValue", "locationValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.inventoryPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInventoryName', () => { - const result = client.matchProjectFromInventoryName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.inventoryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromInventoryName', () => { - const result = client.matchLocationFromInventoryName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.inventoryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInventoryName', () => { - const result = client.matchInstanceFromInventoryName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.inventoryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('oSPolicyAssignment', () => { - const fakePath = "/rendered/path/oSPolicyAssignment"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - os_policy_assignment: "osPolicyAssignmentValue", - }; - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.oSPolicyAssignmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.oSPolicyAssignmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('oSPolicyAssignmentPath', () => { - const result = client.oSPolicyAssignmentPath("projectValue", "locationValue", "osPolicyAssignmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromOSPolicyAssignmentName', () => { - const result = client.matchProjectFromOSPolicyAssignmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOSPolicyAssignmentName', () => { - const result = client.matchLocationFromOSPolicyAssignmentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchOsPolicyAssignmentFromOSPolicyAssignmentName', () => { - const result = client.matchOsPolicyAssignmentFromOSPolicyAssignmentName(fakePath); - assert.strictEqual(result, "osPolicyAssignmentValue"); - assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('oSPolicyAssignmentReport', () => { - const fakePath = "/rendered/path/oSPolicyAssignmentReport"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - assignment: "assignmentValue", - }; - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.oSPolicyAssignmentReportPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('oSPolicyAssignmentReportPath', () => { - const result = client.oSPolicyAssignmentReportPath("projectValue", "locationValue", "instanceValue", "assignmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromOSPolicyAssignmentReportName', () => { - const result = client.matchProjectFromOSPolicyAssignmentReportName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOSPolicyAssignmentReportName', () => { - const result = client.matchLocationFromOSPolicyAssignmentReportName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromOSPolicyAssignmentReportName', () => { - const result = client.matchInstanceFromOSPolicyAssignmentReportName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAssignmentFromOSPolicyAssignmentReportName', () => { - const result = client.matchAssignmentFromOSPolicyAssignmentReportName(fakePath); - assert.strictEqual(result, "assignmentValue"); - assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('patchDeployment', () => { - const fakePath = "/rendered/path/patchDeployment"; - const expectedParameters = { - project: "projectValue", - patch_deployment: "patchDeploymentValue", - }; - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.patchDeploymentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.patchDeploymentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('patchDeploymentPath', () => { - const result = client.patchDeploymentPath("projectValue", "patchDeploymentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.patchDeploymentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPatchDeploymentName', () => { - const result = client.matchProjectFromPatchDeploymentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.patchDeploymentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPatchDeploymentFromPatchDeploymentName', () => { - const result = client.matchPatchDeploymentFromPatchDeploymentName(fakePath); - assert.strictEqual(result, "patchDeploymentValue"); - assert((client.pathTemplates.patchDeploymentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('patchJob', () => { - const fakePath = "/rendered/path/patchJob"; - const expectedParameters = { - project: "projectValue", - patch_job: "patchJobValue", - }; - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.patchJobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.patchJobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('patchJobPath', () => { - const result = client.patchJobPath("projectValue", "patchJobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.patchJobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPatchJobName', () => { - const result = client.matchProjectFromPatchJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.patchJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPatchJobFromPatchJobName', () => { - const result = client.matchPatchJobFromPatchJobName(fakePath); - assert.strictEqual(result, "patchJobValue"); - assert((client.pathTemplates.patchJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('vulnerabilityReport', () => { - const fakePath = "/rendered/path/vulnerabilityReport"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - }; - const client = new osconfigserviceModule.v1.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.vulnerabilityReportPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.vulnerabilityReportPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('vulnerabilityReportPath', () => { - const result = client.vulnerabilityReportPath("projectValue", "locationValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.vulnerabilityReportPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromVulnerabilityReportName', () => { - const result = client.matchProjectFromVulnerabilityReportName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.vulnerabilityReportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromVulnerabilityReportName', () => { - const result = client.matchLocationFromVulnerabilityReportName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.vulnerabilityReportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromVulnerabilityReportName', () => { - const result = client.matchInstanceFromVulnerabilityReportName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.vulnerabilityReportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/test/gapic_os_config_zonal_service_v1.ts b/owl-bot-staging/google-cloud-osconfig/v1/test/gapic_os_config_zonal_service_v1.ts deleted file mode 100644 index 5c3524e7112..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/test/gapic_os_config_zonal_service_v1.ts +++ /dev/null @@ -1,2607 +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 osconfigzonalserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.OsConfigZonalServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = osconfigzonalserviceModule.v1.OsConfigZonalServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = osconfigzonalserviceModule.v1.OsConfigZonalServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = osconfigzonalserviceModule.v1.OsConfigZonalServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.osConfigZonalServiceStub, undefined); - await client.initialize(); - assert(client.osConfigZonalServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.osConfigZonalServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.osConfigZonalServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - 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 osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - 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('getOSPolicyAssignment', () => { - it('invokes getOSPolicyAssignment without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.OSPolicyAssignment() - ); - client.innerApiCalls.getOsPolicyAssignment = stubSimpleCall(expectedResponse); - const [response] = await client.getOSPolicyAssignment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getOSPolicyAssignment without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.OSPolicyAssignment() - ); - client.innerApiCalls.getOsPolicyAssignment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getOSPolicyAssignment( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IOSPolicyAssignment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getOSPolicyAssignment with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getOsPolicyAssignment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getOSPolicyAssignment(request), expectedError); - const actualRequest = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getOSPolicyAssignment with closed client', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getOSPolicyAssignment(request), expectedError); - }); - }); - - describe('getOSPolicyAssignmentReport', () => { - it('invokes getOSPolicyAssignmentReport without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport() - ); - client.innerApiCalls.getOsPolicyAssignmentReport = stubSimpleCall(expectedResponse); - const [response] = await client.getOSPolicyAssignmentReport(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getOSPolicyAssignmentReport without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport() - ); - client.innerApiCalls.getOsPolicyAssignmentReport = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getOSPolicyAssignmentReport( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getOSPolicyAssignmentReport with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getOsPolicyAssignmentReport = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getOSPolicyAssignmentReport(request), expectedError); - const actualRequest = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getOSPolicyAssignmentReport with closed client', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getOSPolicyAssignmentReport(request), expectedError); - }); - }); - - describe('getInventory', () => { - it('invokes getInventory without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetInventoryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetInventoryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.Inventory() - ); - client.innerApiCalls.getInventory = stubSimpleCall(expectedResponse); - const [response] = await client.getInventory(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInventory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInventory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInventory without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetInventoryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetInventoryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.Inventory() - ); - client.innerApiCalls.getInventory = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInventory( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IInventory|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInventory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInventory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInventory with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetInventoryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetInventoryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInventory = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInventory(request), expectedError); - const actualRequest = (client.innerApiCalls.getInventory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInventory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInventory with closed client', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetInventoryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetInventoryRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getInventory(request), expectedError); - }); - }); - - describe('getVulnerabilityReport', () => { - it('invokes getVulnerabilityReport without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetVulnerabilityReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetVulnerabilityReportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.VulnerabilityReport() - ); - client.innerApiCalls.getVulnerabilityReport = stubSimpleCall(expectedResponse); - const [response] = await client.getVulnerabilityReport(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getVulnerabilityReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getVulnerabilityReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getVulnerabilityReport without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetVulnerabilityReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetVulnerabilityReportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1.VulnerabilityReport() - ); - client.innerApiCalls.getVulnerabilityReport = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getVulnerabilityReport( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IVulnerabilityReport|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getVulnerabilityReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getVulnerabilityReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getVulnerabilityReport with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetVulnerabilityReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetVulnerabilityReportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getVulnerabilityReport = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getVulnerabilityReport(request), expectedError); - const actualRequest = (client.innerApiCalls.getVulnerabilityReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getVulnerabilityReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getVulnerabilityReport with closed client', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.GetVulnerabilityReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.GetVulnerabilityReportRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getVulnerabilityReport(request), expectedError); - }); - }); - - describe('createOSPolicyAssignment', () => { - it('invokes createOSPolicyAssignment without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createOsPolicyAssignment = stubLongRunningCall(expectedResponse); - const [operation] = await client.createOSPolicyAssignment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createOSPolicyAssignment without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createOsPolicyAssignment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createOSPolicyAssignment( - request, - (err?: Error|null, - result?: 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.createOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createOSPolicyAssignment with call error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createOsPolicyAssignment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createOSPolicyAssignment(request), expectedError); - const actualRequest = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createOSPolicyAssignment with LRO error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createOsPolicyAssignment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createOSPolicyAssignment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateOSPolicyAssignmentProgress without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateOSPolicyAssignmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateOSPolicyAssignmentProgress with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateOSPolicyAssignmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateOSPolicyAssignment', () => { - it('invokes updateOSPolicyAssignment without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest() - ); - request.osPolicyAssignment ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest', ['osPolicyAssignment', 'name']); - request.osPolicyAssignment.name = defaultValue1; - const expectedHeaderRequestParams = `os_policy_assignment.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateOsPolicyAssignment = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateOSPolicyAssignment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateOSPolicyAssignment without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest() - ); - request.osPolicyAssignment ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest', ['osPolicyAssignment', 'name']); - request.osPolicyAssignment.name = defaultValue1; - const expectedHeaderRequestParams = `os_policy_assignment.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateOsPolicyAssignment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateOSPolicyAssignment( - request, - (err?: Error|null, - result?: 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.updateOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateOSPolicyAssignment with call error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest() - ); - request.osPolicyAssignment ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest', ['osPolicyAssignment', 'name']); - request.osPolicyAssignment.name = defaultValue1; - const expectedHeaderRequestParams = `os_policy_assignment.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateOsPolicyAssignment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateOSPolicyAssignment(request), expectedError); - const actualRequest = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateOSPolicyAssignment with LRO error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest() - ); - request.osPolicyAssignment ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest', ['osPolicyAssignment', 'name']); - request.osPolicyAssignment.name = defaultValue1; - const expectedHeaderRequestParams = `os_policy_assignment.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateOsPolicyAssignment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateOSPolicyAssignment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateOSPolicyAssignmentProgress without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateOSPolicyAssignmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateOSPolicyAssignmentProgress with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateOSPolicyAssignmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteOSPolicyAssignment', () => { - it('invokes deleteOSPolicyAssignment without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteOsPolicyAssignment = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteOSPolicyAssignment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteOSPolicyAssignment without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteOsPolicyAssignment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteOSPolicyAssignment( - request, - (err?: Error|null, - result?: 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.deleteOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteOSPolicyAssignment with call error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteOsPolicyAssignment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteOSPolicyAssignment(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteOSPolicyAssignment with LRO error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteOsPolicyAssignment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteOSPolicyAssignment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteOSPolicyAssignmentProgress without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteOSPolicyAssignmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteOSPolicyAssignmentProgress with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteOSPolicyAssignmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listOSPolicyAssignments', () => { - it('invokes listOSPolicyAssignments without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - ]; - client.innerApiCalls.listOsPolicyAssignments = stubSimpleCall(expectedResponse); - const [response] = await client.listOSPolicyAssignments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listOSPolicyAssignments without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - ]; - client.innerApiCalls.listOsPolicyAssignments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listOSPolicyAssignments( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IOSPolicyAssignment[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listOSPolicyAssignments with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listOsPolicyAssignments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listOSPolicyAssignments(request), expectedError); - const actualRequest = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listOSPolicyAssignmentsStream without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - ]; - client.descriptors.page.listOSPolicyAssignments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listOSPolicyAssignmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1.OSPolicyAssignment[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1.OSPolicyAssignment) => { - 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.listOSPolicyAssignments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignments, request)); - assert( - (client.descriptors.page.listOSPolicyAssignments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listOSPolicyAssignmentsStream with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listOSPolicyAssignments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listOSPolicyAssignmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1.OSPolicyAssignment[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1.OSPolicyAssignment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listOSPolicyAssignments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignments, request)); - assert( - (client.descriptors.page.listOSPolicyAssignments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listOSPolicyAssignments without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - ]; - client.descriptors.page.listOSPolicyAssignments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.osconfig.v1.IOSPolicyAssignment[] = []; - const iterable = client.listOSPolicyAssignmentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listOSPolicyAssignments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listOSPolicyAssignments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listOSPolicyAssignments with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listOSPolicyAssignments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listOSPolicyAssignmentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.osconfig.v1.IOSPolicyAssignment[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listOSPolicyAssignments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listOSPolicyAssignments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listOSPolicyAssignmentRevisions', () => { - it('invokes listOSPolicyAssignmentRevisions without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - ]; - client.innerApiCalls.listOsPolicyAssignmentRevisions = stubSimpleCall(expectedResponse); - const [response] = await client.listOSPolicyAssignmentRevisions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listOSPolicyAssignmentRevisions without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - ]; - client.innerApiCalls.listOsPolicyAssignmentRevisions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listOSPolicyAssignmentRevisions( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IOSPolicyAssignment[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listOSPolicyAssignmentRevisions with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listOsPolicyAssignmentRevisions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listOSPolicyAssignmentRevisions(request), expectedError); - const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listOSPolicyAssignmentRevisionsStream without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - ]; - client.descriptors.page.listOSPolicyAssignmentRevisions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listOSPolicyAssignmentRevisionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1.OSPolicyAssignment[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1.OSPolicyAssignment) => { - 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.listOSPolicyAssignmentRevisions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignmentRevisions, request)); - assert( - (client.descriptors.page.listOSPolicyAssignmentRevisions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listOSPolicyAssignmentRevisionsStream with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listOSPolicyAssignmentRevisions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listOSPolicyAssignmentRevisionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1.OSPolicyAssignment[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1.OSPolicyAssignment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listOSPolicyAssignmentRevisions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignmentRevisions, request)); - assert( - (client.descriptors.page.listOSPolicyAssignmentRevisions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listOSPolicyAssignmentRevisions without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignment()), - ]; - client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.osconfig.v1.IOSPolicyAssignment[] = []; - const iterable = client.listOSPolicyAssignmentRevisionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listOSPolicyAssignmentRevisions with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listOSPolicyAssignmentRevisionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.osconfig.v1.IOSPolicyAssignment[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listOSPolicyAssignmentReports', () => { - it('invokes listOSPolicyAssignmentReports without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), - ]; - client.innerApiCalls.listOsPolicyAssignmentReports = stubSimpleCall(expectedResponse); - const [response] = await client.listOSPolicyAssignmentReports(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listOSPolicyAssignmentReports without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), - ]; - client.innerApiCalls.listOsPolicyAssignmentReports = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listOSPolicyAssignmentReports( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listOSPolicyAssignmentReports with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listOsPolicyAssignmentReports = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listOSPolicyAssignmentReports(request), expectedError); - const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listOSPolicyAssignmentReportsStream without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), - ]; - client.descriptors.page.listOSPolicyAssignmentReports.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listOSPolicyAssignmentReportsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport) => { - 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.listOSPolicyAssignmentReports.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignmentReports, request)); - assert( - (client.descriptors.page.listOSPolicyAssignmentReports.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listOSPolicyAssignmentReportsStream with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listOSPolicyAssignmentReports.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listOSPolicyAssignmentReportsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listOSPolicyAssignmentReports.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignmentReports, request)); - assert( - (client.descriptors.page.listOSPolicyAssignmentReports.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listOSPolicyAssignmentReports without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.OSPolicyAssignmentReport()), - ]; - client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport[] = []; - const iterable = client.listOSPolicyAssignmentReportsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listOSPolicyAssignmentReports with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listOSPolicyAssignmentReportsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.osconfig.v1.IOSPolicyAssignmentReport[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listInventories', () => { - it('invokes listInventories without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListInventoriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListInventoriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), - ]; - client.innerApiCalls.listInventories = stubSimpleCall(expectedResponse); - const [response] = await client.listInventories(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInventories without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListInventoriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListInventoriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), - ]; - client.innerApiCalls.listInventories = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInventories( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IInventory[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInventories with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListInventoriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListInventoriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInventories = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInventories(request), expectedError); - const actualRequest = (client.innerApiCalls.listInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInventoriesStream without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListInventoriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListInventoriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), - ]; - client.descriptors.page.listInventories.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInventoriesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1.Inventory[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1.Inventory) => { - 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.listInventories.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInventories, request)); - assert( - (client.descriptors.page.listInventories.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listInventoriesStream with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListInventoriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListInventoriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInventories.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInventoriesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1.Inventory[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1.Inventory) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listInventories.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInventories, request)); - assert( - (client.descriptors.page.listInventories.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInventories without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListInventoriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListInventoriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.Inventory()), - ]; - client.descriptors.page.listInventories.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.osconfig.v1.IInventory[] = []; - const iterable = client.listInventoriesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInventories.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInventories.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInventories with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListInventoriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListInventoriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInventories.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInventoriesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.osconfig.v1.IInventory[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listInventories.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInventories.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listVulnerabilityReports', () => { - it('invokes listVulnerabilityReports without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), - ]; - client.innerApiCalls.listVulnerabilityReports = stubSimpleCall(expectedResponse); - const [response] = await client.listVulnerabilityReports(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listVulnerabilityReports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listVulnerabilityReports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listVulnerabilityReports without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), - ]; - client.innerApiCalls.listVulnerabilityReports = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listVulnerabilityReports( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1.IVulnerabilityReport[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listVulnerabilityReports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listVulnerabilityReports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listVulnerabilityReports with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listVulnerabilityReports = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listVulnerabilityReports(request), expectedError); - const actualRequest = (client.innerApiCalls.listVulnerabilityReports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listVulnerabilityReports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listVulnerabilityReportsStream without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), - ]; - client.descriptors.page.listVulnerabilityReports.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listVulnerabilityReportsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1.VulnerabilityReport[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1.VulnerabilityReport) => { - 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.listVulnerabilityReports.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listVulnerabilityReports, request)); - assert( - (client.descriptors.page.listVulnerabilityReports.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listVulnerabilityReportsStream with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listVulnerabilityReports.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listVulnerabilityReportsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1.VulnerabilityReport[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1.VulnerabilityReport) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listVulnerabilityReports.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listVulnerabilityReports, request)); - assert( - (client.descriptors.page.listVulnerabilityReports.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listVulnerabilityReports without error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1.VulnerabilityReport()), - ]; - client.descriptors.page.listVulnerabilityReports.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.osconfig.v1.IVulnerabilityReport[] = []; - const iterable = client.listVulnerabilityReportsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listVulnerabilityReports.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listVulnerabilityReports.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listVulnerabilityReports with error', async () => { - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listVulnerabilityReports.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listVulnerabilityReportsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.osconfig.v1.IVulnerabilityReport[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listVulnerabilityReports.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listVulnerabilityReports.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('inventory', () => { - const fakePath = "/rendered/path/inventory"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - }; - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.inventoryPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.inventoryPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('inventoryPath', () => { - const result = client.inventoryPath("projectValue", "locationValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.inventoryPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInventoryName', () => { - const result = client.matchProjectFromInventoryName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.inventoryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromInventoryName', () => { - const result = client.matchLocationFromInventoryName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.inventoryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInventoryName', () => { - const result = client.matchInstanceFromInventoryName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.inventoryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('oSPolicyAssignment', () => { - const fakePath = "/rendered/path/oSPolicyAssignment"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - os_policy_assignment: "osPolicyAssignmentValue", - }; - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.oSPolicyAssignmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.oSPolicyAssignmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('oSPolicyAssignmentPath', () => { - const result = client.oSPolicyAssignmentPath("projectValue", "locationValue", "osPolicyAssignmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromOSPolicyAssignmentName', () => { - const result = client.matchProjectFromOSPolicyAssignmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOSPolicyAssignmentName', () => { - const result = client.matchLocationFromOSPolicyAssignmentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchOsPolicyAssignmentFromOSPolicyAssignmentName', () => { - const result = client.matchOsPolicyAssignmentFromOSPolicyAssignmentName(fakePath); - assert.strictEqual(result, "osPolicyAssignmentValue"); - assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('oSPolicyAssignmentReport', () => { - const fakePath = "/rendered/path/oSPolicyAssignmentReport"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - assignment: "assignmentValue", - }; - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.oSPolicyAssignmentReportPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('oSPolicyAssignmentReportPath', () => { - const result = client.oSPolicyAssignmentReportPath("projectValue", "locationValue", "instanceValue", "assignmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromOSPolicyAssignmentReportName', () => { - const result = client.matchProjectFromOSPolicyAssignmentReportName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOSPolicyAssignmentReportName', () => { - const result = client.matchLocationFromOSPolicyAssignmentReportName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromOSPolicyAssignmentReportName', () => { - const result = client.matchInstanceFromOSPolicyAssignmentReportName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAssignmentFromOSPolicyAssignmentReportName', () => { - const result = client.matchAssignmentFromOSPolicyAssignmentReportName(fakePath); - assert.strictEqual(result, "assignmentValue"); - assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('patchDeployment', () => { - const fakePath = "/rendered/path/patchDeployment"; - const expectedParameters = { - project: "projectValue", - patch_deployment: "patchDeploymentValue", - }; - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.patchDeploymentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.patchDeploymentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('patchDeploymentPath', () => { - const result = client.patchDeploymentPath("projectValue", "patchDeploymentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.patchDeploymentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPatchDeploymentName', () => { - const result = client.matchProjectFromPatchDeploymentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.patchDeploymentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPatchDeploymentFromPatchDeploymentName', () => { - const result = client.matchPatchDeploymentFromPatchDeploymentName(fakePath); - assert.strictEqual(result, "patchDeploymentValue"); - assert((client.pathTemplates.patchDeploymentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('patchJob', () => { - const fakePath = "/rendered/path/patchJob"; - const expectedParameters = { - project: "projectValue", - patch_job: "patchJobValue", - }; - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.patchJobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.patchJobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('patchJobPath', () => { - const result = client.patchJobPath("projectValue", "patchJobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.patchJobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPatchJobName', () => { - const result = client.matchProjectFromPatchJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.patchJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPatchJobFromPatchJobName', () => { - const result = client.matchPatchJobFromPatchJobName(fakePath); - assert.strictEqual(result, "patchJobValue"); - assert((client.pathTemplates.patchJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('vulnerabilityReport', () => { - const fakePath = "/rendered/path/vulnerabilityReport"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - }; - const client = new osconfigzonalserviceModule.v1.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.vulnerabilityReportPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.vulnerabilityReportPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('vulnerabilityReportPath', () => { - const result = client.vulnerabilityReportPath("projectValue", "locationValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.vulnerabilityReportPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromVulnerabilityReportName', () => { - const result = client.matchProjectFromVulnerabilityReportName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.vulnerabilityReportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromVulnerabilityReportName', () => { - const result = client.matchLocationFromVulnerabilityReportName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.vulnerabilityReportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromVulnerabilityReportName', () => { - const result = client.matchInstanceFromVulnerabilityReportName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.vulnerabilityReportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-osconfig/v1/tsconfig.json b/owl-bot-staging/google-cloud-osconfig/v1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1/webpack.config.js b/owl-bot-staging/google-cloud-osconfig/v1/webpack.config.js deleted file mode 100644 index 72e295d47e7..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'OsConfigServiceClient', - filename: './os-config-service-client.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-osconfig/v1alpha/.eslintignore b/owl-bot-staging/google-cloud-osconfig/v1alpha/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/.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-osconfig/v1alpha/.eslintrc.json b/owl-bot-staging/google-cloud-osconfig/v1alpha/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/.gitignore b/owl-bot-staging/google-cloud-osconfig/v1alpha/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/.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-osconfig/v1alpha/.jsdoc.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/.jsdoc.js deleted file mode 100644 index 8b2a0523a45..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/.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/os-config', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/.mocharc.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/.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-osconfig/v1alpha/.prettierrc.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/.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-osconfig/v1alpha/README.md b/owl-bot-staging/google-cloud-osconfig/v1alpha/README.md deleted file mode 100644 index 94de5ca4cff..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/README.md +++ /dev/null @@ -1 +0,0 @@ -Osconfig: Nodejs Client diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/package.json b/owl-bot-staging/google-cloud-osconfig/v1alpha/package.json deleted file mode 100644 index d826e86c7ee..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/os-config", - "version": "0.1.0", - "description": "Osconfig client for Node.js", - "repository": "googleapis/nodejs-osconfig", - "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 osconfig", - "osconfig", - "os config zonal service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/config_common.proto b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/config_common.proto deleted file mode 100644 index 2fe52e14a66..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/config_common.proto +++ /dev/null @@ -1,133 +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.osconfig.v1alpha; - - -option csharp_namespace = "Google.Cloud.OsConfig.V1Alpha"; -option go_package = "cloud.google.com/go/osconfig/apiv1alpha/osconfigpb;osconfigpb"; -option java_multiple_files = true; -option java_outer_classname = "ConfigCommonProto"; -option java_package = "com.google.cloud.osconfig.v1alpha"; -option php_namespace = "Google\\Cloud\\OsConfig\\V1alpha"; -option ruby_package = "Google::Cloud::OsConfig::V1alpha"; - -// Step performed by the OS Config agent for configuring an `OSPolicyResource` -// to its desired state. -message OSPolicyResourceConfigStep { - option deprecated = true; - - // Supported configuration step types - enum Type { - option deprecated = true; - - // Default value. This value is unused. - TYPE_UNSPECIFIED = 0; - - // Validation to detect resource conflicts, schema errors, etc. - VALIDATION = 1; - - // Check the current desired state status of the resource. - DESIRED_STATE_CHECK = 2; - - // Enforce the desired state for a resource that is not in desired state. - DESIRED_STATE_ENFORCEMENT = 3; - - // Re-check desired state status for a resource after enforcement of all - // resources in the current configuration run. - // - // This step is used to determine the final desired state status for the - // resource. It accounts for any resources that might have drifted from - // their desired state due to side effects from configuring other resources - // during the current configuration run. - DESIRED_STATE_CHECK_POST_ENFORCEMENT = 4; - } - - // Supported outcomes for a configuration step. - enum Outcome { - option deprecated = true; - - // Default value. This value is unused. - OUTCOME_UNSPECIFIED = 0; - - // The step succeeded. - SUCCEEDED = 1; - - // The step failed. - FAILED = 2; - } - - // Configuration step type. - Type type = 1; - - // Outcome of the configuration step. - Outcome outcome = 2; - - // An error message recorded during the execution of this step. - // Only populated when outcome is FAILED. - string error_message = 3; -} - -// Compliance data for an OS policy resource. -message OSPolicyResourceCompliance { - option deprecated = true; - - // ExecResource specific output. - message ExecResourceOutput { - option deprecated = true; - - // Output from Enforcement phase output file (if run). - // Output size is limited to 100K bytes. - bytes enforcement_output = 2; - } - - // The id of the OS policy resource. - string os_policy_resource_id = 1; - - // Ordered list of configuration steps taken by the agent for the OS policy - // resource. - repeated OSPolicyResourceConfigStep config_steps = 2; - - // Compliance state of the OS policy resource. - OSPolicyComplianceState state = 3; - - // Resource specific output. - oneof output { - // ExecResource specific output. - ExecResourceOutput exec_resource_output = 4; - } -} - -// Supported OSPolicy compliance states. -enum OSPolicyComplianceState { - option deprecated = true; - - // Default value. This value is unused. - OS_POLICY_COMPLIANCE_STATE_UNSPECIFIED = 0; - - // Compliant state. - COMPLIANT = 1; - - // Non-compliant state - NON_COMPLIANT = 2; - - // Unknown compliance state. - UNKNOWN = 3; - - // No applicable OS policies were found for the instance. - // This state is only applicable to the instance. - NO_OS_POLICIES_APPLICABLE = 4; -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/instance_os_policies_compliance.proto b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/instance_os_policies_compliance.proto deleted file mode 100644 index 0d6eafc7fa2..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/instance_os_policies_compliance.proto +++ /dev/null @@ -1,182 +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.osconfig.v1alpha; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/osconfig/v1alpha/config_common.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.OsConfig.V1Alpha"; -option go_package = "cloud.google.com/go/osconfig/apiv1alpha/osconfigpb;osconfigpb"; -option java_multiple_files = true; -option java_outer_classname = "InstanceOSPoliciesComplianceProto"; -option java_package = "com.google.cloud.osconfig.v1alpha"; -option php_namespace = "Google\\Cloud\\OsConfig\\V1alpha"; -option ruby_package = "Google::Cloud::OsConfig::V1alpha"; - -// This API resource represents the OS policies compliance data for a Compute -// Engine virtual machine (VM) instance at a given point in time. -// -// A Compute Engine VM can have multiple OS policy assignments, and each -// assignment can have multiple OS policies. As a result, multiple OS policies -// could be applied to a single VM. -// -// You can use this API resource to determine both the compliance state of your -// VM as well as the compliance state of an individual OS policy. -// -// For more information, see [View -// compliance](https://cloud.google.com/compute/docs/os-configuration-management/view-compliance). -message InstanceOSPoliciesCompliance { - option deprecated = true; - option (google.api.resource) = { - type: "osconfig.googleapis.com/InstanceOSPoliciesCompliance" - pattern: "projects/{project}/locations/{location}/instanceOSPoliciesCompliances/{instance}" - }; - - // Compliance data for an OS policy - message OSPolicyCompliance { - option deprecated = true; - - // The OS policy id - string os_policy_id = 1; - - // Reference to the `OSPolicyAssignment` API resource that the `OSPolicy` - // belongs to. - // - // Format: - // `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id@revision_id}` - string os_policy_assignment = 2 [(google.api.resource_reference) = { - type: "osconfig.googleapis.com/OSPolicyAssignment" - }]; - - // Compliance state of the OS policy. - OSPolicyComplianceState state = 4; - - // Compliance data for each `OSPolicyResource` that is applied to the - // VM. - repeated OSPolicyResourceCompliance os_policy_resource_compliances = 5; - } - - // Output only. The `InstanceOSPoliciesCompliance` API resource name. - // - // Format: - // `projects/{project_number}/locations/{location}/instanceOSPoliciesCompliances/{instance_id}` - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The Compute Engine VM instance name. - string instance = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Compliance state of the VM. - OSPolicyComplianceState state = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Detailed compliance state of the VM. - // This field is populated only when compliance state is `UNKNOWN`. - // - // It may contain one of the following values: - // - // * `no-compliance-data`: Compliance data is not available for this VM. - // * `no-agent-detected`: OS Config agent is not detected for this VM. - // * `config-not-supported-by-agent`: The version of the OS Config agent - // running on this VM does not support configuration management. - // * `inactive`: VM is not running. - // * `internal-service-errors`: There were internal service errors encountered - // while enforcing compliance. - // * `agent-errors`: OS config agent encountered errors while enforcing - // compliance. - string detailed_state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The reason for the `detailed_state` of the VM (if any). - string detailed_state_reason = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Compliance data for each `OSPolicy` that is applied to the VM. - repeated OSPolicyCompliance os_policy_compliances = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Timestamp of the last compliance check for the VM. - google.protobuf.Timestamp last_compliance_check_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Unique identifier for the last compliance run. - // This id will be logged by the OS config agent during a compliance run and - // can be used for debugging and tracing purpose. - string last_compliance_run_id = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A request message for getting OS policies compliance data for the given -// Compute Engine VM instance. -message GetInstanceOSPoliciesComplianceRequest { - option deprecated = true; - - // Required. API resource name for instance OS policies compliance resource. - // - // Format: - // `projects/{project}/locations/{location}/instanceOSPoliciesCompliances/{instance}` - // - // For `{project}`, either Compute Engine project-number or project-id can be - // provided. - // For `{instance}`, either Compute Engine VM instance-id or instance-name can - // be provided. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/InstanceOSPoliciesCompliance" - } - ]; -} - -// A request message for listing OS policies compliance data for all Compute -// Engine VMs in the given location. -message ListInstanceOSPoliciesCompliancesRequest { - option deprecated = true; - - // Required. The parent resource name. - // - // Format: `projects/{project}/locations/{location}` - // - // For `{project}`, either Compute Engine project-number or project-id can be - // provided. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of results to return. - int32 page_size = 2; - - // A pagination token returned from a previous call to - // `ListInstanceOSPoliciesCompliances` that indicates where this listing - // should continue from. - string page_token = 3; - - // If provided, this field specifies the criteria that must be met by a - // `InstanceOSPoliciesCompliance` API resource to be included in the response. - string filter = 4; -} - -// A response message for listing OS policies compliance data for all Compute -// Engine VMs in the given location. -message ListInstanceOSPoliciesCompliancesResponse { - option deprecated = true; - - // List of instance OS policies compliance objects. - repeated InstanceOSPoliciesCompliance instance_os_policies_compliances = 1; - - // The pagination token to retrieve the next page of instance OS policies - // compliance objects. - string next_page_token = 2; -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/inventory.proto b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/inventory.proto deleted file mode 100644 index a63416ae1a6..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/inventory.proto +++ /dev/null @@ -1,383 +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.osconfig.v1alpha; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; -import "google/type/date.proto"; - -option csharp_namespace = "Google.Cloud.OsConfig.V1Alpha"; -option go_package = "cloud.google.com/go/osconfig/apiv1alpha/osconfigpb;osconfigpb"; -option java_multiple_files = true; -option java_outer_classname = "Inventories"; -option java_package = "com.google.cloud.osconfig.v1alpha"; -option php_namespace = "Google\\Cloud\\OsConfig\\V1alpha"; -option ruby_package = "Google::Cloud::OsConfig::V1alpha"; - -// OS Inventory is a service for collecting and reporting operating -// system and package information on VM instances. - -// This API resource represents the available inventory data for a -// Compute Engine virtual machine (VM) instance at a given point in time. -// -// You can use this API resource to determine the inventory data of your VM. -// -// For more information, see [Information provided by OS inventory -// management](https://cloud.google.com/compute/docs/instances/os-inventory-management#data-collected). -message Inventory { - option (google.api.resource) = { - type: "osconfig.googleapis.com/Inventory" - pattern: "projects/{project}/locations/{location}/instances/{instance}/inventory" - }; - - // Operating system information for the VM. - message OsInfo { - // The VM hostname. - string hostname = 9; - - // The operating system long name. - // For example 'Debian GNU/Linux 9' or 'Microsoft Window Server 2019 - // Datacenter'. - string long_name = 2; - - // The operating system short name. - // For example, 'windows' or 'debian'. - string short_name = 3; - - // The version of the operating system. - string version = 4; - - // The system architecture of the operating system. - string architecture = 5; - - // The kernel version of the operating system. - string kernel_version = 6; - - // The kernel release of the operating system. - string kernel_release = 7; - - // The current version of the OS Config agent running on the VM. - string osconfig_agent_version = 8; - } - - // A single piece of inventory on a VM. - message Item { - // The origin of a specific inventory item. - enum OriginType { - // Invalid. An origin type must be specified. - ORIGIN_TYPE_UNSPECIFIED = 0; - - // This inventory item was discovered as the result of the agent - // reporting inventory via the reporting API. - INVENTORY_REPORT = 1; - } - - // The different types of inventory that are tracked on a VM. - enum Type { - // Invalid. An type must be specified. - TYPE_UNSPECIFIED = 0; - - // This represents a package that is installed on the VM. - INSTALLED_PACKAGE = 1; - - // This represents an update that is available for a package. - AVAILABLE_PACKAGE = 2; - } - - // Identifier for this item, unique across items for this VM. - string id = 1; - - // The origin of this inventory item. - OriginType origin_type = 2; - - // When this inventory item was first detected. - google.protobuf.Timestamp create_time = 8; - - // When this inventory item was last modified. - google.protobuf.Timestamp update_time = 9; - - // The specific type of inventory, correlating to its specific details. - Type type = 5; - - // Specific details of this inventory item based on its type. - oneof details { - // Software package present on the VM instance. - SoftwarePackage installed_package = 6; - - // Software package available to be installed on the VM instance. - SoftwarePackage available_package = 7; - } - } - - // Software package information of the operating system. - message SoftwarePackage { - // Information about the different types of software packages. - oneof details { - // Yum package info. - // For details about the yum package manager, see - // https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/ch-yum. - VersionedPackage yum_package = 1; - - // Details of an APT package. - // For details about the apt package manager, see - // https://wiki.debian.org/Apt. - VersionedPackage apt_package = 2; - - // Details of a Zypper package. - // For details about the Zypper package manager, see - // https://en.opensuse.org/SDB:Zypper_manual. - VersionedPackage zypper_package = 3; - - // Details of a Googet package. - // For details about the googet package manager, see - // https://github.com/google/googet. - VersionedPackage googet_package = 4; - - // Details of a Zypper patch. - // For details about the Zypper package manager, see - // https://en.opensuse.org/SDB:Zypper_manual. - ZypperPatch zypper_patch = 5; - - // Details of a Windows Update package. - // See https://docs.microsoft.com/en-us/windows/win32/api/_wua/ for - // information about Windows Update. - WindowsUpdatePackage wua_package = 6; - - // Details of a Windows Quick Fix engineering package. - // See - // https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-quickfixengineering - // for info in Windows Quick Fix Engineering. - WindowsQuickFixEngineeringPackage qfe_package = 7; - - // Details of a COS package. - VersionedPackage cos_package = 8; - - // Details of Windows Application. - WindowsApplication windows_application = 9; - } - } - - // Information related to the a standard versioned package. This includes - // package info for APT, Yum, Zypper, and Googet package managers. - message VersionedPackage { - // The name of the package. - string package_name = 4; - - // The system architecture this package is intended for. - string architecture = 2; - - // The version of the package. - string version = 3; - } - - // Details related to a Zypper Patch. - message ZypperPatch { - // The name of the patch. - string patch_name = 5; - - // The category of the patch. - string category = 2; - - // The severity specified for this patch - string severity = 3; - - // Any summary information provided about this patch. - string summary = 4; - } - - // Details related to a Windows Update package. - // Field data and names are taken from Windows Update API IUpdate Interface: - // https://docs.microsoft.com/en-us/windows/win32/api/_wua/ - // Descriptive fields like title, and description are localized based on - // the locale of the VM being updated. - message WindowsUpdatePackage { - // Categories specified by the Windows Update. - message WindowsUpdateCategory { - // The identifier of the windows update category. - string id = 1; - - // The name of the windows update category. - string name = 2; - } - - // The localized title of the update package. - string title = 1; - - // The localized description of the update package. - string description = 2; - - // The categories that are associated with this update package. - repeated WindowsUpdateCategory categories = 3; - - // A collection of Microsoft Knowledge Base article IDs that are associated - // with the update package. - repeated string kb_article_ids = 4; - - // A hyperlink to the language-specific support information for the update. - string support_url = 11; - - // A collection of URLs that provide more information about the update - // package. - repeated string more_info_urls = 5; - - // Gets the identifier of an update package. Stays the same across - // revisions. - string update_id = 6; - - // The revision number of this update package. - int32 revision_number = 7; - - // The last published date of the update, in (UTC) date and time. - google.protobuf.Timestamp last_deployment_change_time = 10; - } - - // Information related to a Quick Fix Engineering package. - // Fields are taken from Windows QuickFixEngineering Interface and match - // the source names: - // https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-quickfixengineering - message WindowsQuickFixEngineeringPackage { - // A short textual description of the QFE update. - string caption = 1; - - // A textual description of the QFE update. - string description = 2; - - // Unique identifier associated with a particular QFE update. - string hot_fix_id = 3; - - // Date that the QFE update was installed. Mapped from installed_on field. - google.protobuf.Timestamp install_time = 5; - } - - // Contains information about a Windows application that is retrieved from the - // Windows Registry. For more information about these fields, see: - // https://docs.microsoft.com/en-us/windows/win32/msi/uninstall-registry-key - message WindowsApplication { - // The name of the application or product. - string display_name = 1; - - // The version of the product or application in string format. - string display_version = 2; - - // The name of the manufacturer for the product or application. - string publisher = 3; - - // The last time this product received service. The value of this property - // is replaced each time a patch is applied or removed from the product or - // the command-line option is used to repair the product. - google.type.Date install_date = 4; - - // The internet address for technical support. - string help_link = 5; - } - - // Output only. The `Inventory` API resource name. - // - // Format: - // `projects/{project_number}/locations/{location}/instances/{instance_id}/inventory` - string name = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Base level operating system information for the VM. - OsInfo os_info = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Inventory items related to the VM keyed by an opaque unique identifier for - // each inventory item. The identifier is unique to each distinct and - // addressable inventory item and will change, when there is a new package - // version. - map items = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Timestamp of the last reported inventory for the VM. - google.protobuf.Timestamp update_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A request message for getting inventory data for the specified VM. -message GetInventoryRequest { - // Required. API resource name for inventory resource. - // - // Format: - // `projects/{project}/locations/{location}/instances/{instance}/inventory` - // - // For `{project}`, either `project-number` or `project-id` can be provided. - // For `{instance}`, either Compute Engine `instance-id` or `instance-name` - // can be provided. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/Inventory" - } - ]; - - // Inventory view indicating what information should be included in the - // inventory resource. If unspecified, the default view is BASIC. - InventoryView view = 2; -} - -// A request message for listing inventory data for all VMs in the specified -// location. -message ListInventoriesRequest { - // Required. The parent resource name. - // - // Format: `projects/{project}/locations/{location}/instances/-` - // - // For `{project}`, either `project-number` or `project-id` can be provided. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "compute.googleapis.com/Instance" - } - ]; - - // Inventory view indicating what information should be included in the - // inventory resource. If unspecified, the default view is BASIC. - InventoryView view = 2; - - // The maximum number of results to return. - int32 page_size = 3; - - // A pagination token returned from a previous call to - // `ListInventories` that indicates where this listing - // should continue from. - string page_token = 4; - - // If provided, this field specifies the criteria that must be met by a - // `Inventory` API resource to be included in the response. - string filter = 5; -} - -// A response message for listing inventory data for all VMs in a specified -// location. -message ListInventoriesResponse { - // List of inventory objects. - repeated Inventory inventories = 1; - - // The pagination token to retrieve the next page of inventory objects. - string next_page_token = 2; -} - -// The view for inventory objects. -enum InventoryView { - // The default value. - // The API defaults to the BASIC view. - INVENTORY_VIEW_UNSPECIFIED = 0; - - // Returns the basic inventory information that includes `os_info`. - BASIC = 1; - - // Returns all fields. - FULL = 2; -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy.proto b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy.proto deleted file mode 100644 index f822ecb4cee..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy.proto +++ /dev/null @@ -1,565 +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.osconfig.v1alpha; - -import "google/api/field_behavior.proto"; - -option csharp_namespace = "Google.Cloud.OsConfig.V1Alpha"; -option go_package = "cloud.google.com/go/osconfig/apiv1alpha/osconfigpb;osconfigpb"; -option java_multiple_files = true; -option java_outer_classname = "OsPolicyProto"; -option java_package = "com.google.cloud.osconfig.v1alpha"; -option php_namespace = "Google\\Cloud\\OsConfig\\V1alpha"; -option ruby_package = "Google::Cloud::OsConfig::V1alpha"; - -// An OS policy defines the desired state configuration for a VM. -message OSPolicy { - // Policy mode - enum Mode { - // Invalid mode - MODE_UNSPECIFIED = 0; - - // This mode checks if the configuration resources in the policy are in - // their desired state. No actions are performed if they are not in the - // desired state. This mode is used for reporting purposes. - VALIDATION = 1; - - // This mode checks if the configuration resources in the policy are in - // their desired state, and if not, enforces the desired state. - ENFORCEMENT = 2; - } - - // Filtering criteria to select VMs based on OS details. - message OSFilter { - // This should match OS short name emitted by the OS inventory agent. - // An empty value matches any OS. - string os_short_name = 1; - - // This value should match the version emitted by the OS inventory - // agent. - // Prefix matches are supported if asterisk(*) is provided as the - // last character. For example, to match all versions with a major - // version of `7`, specify the following value for this field `7.*` - string os_version = 2; - } - - // Filtering criteria to select VMs based on inventory details. - message InventoryFilter { - // Required. The OS short name - string os_short_name = 1 [(google.api.field_behavior) = REQUIRED]; - - // The OS version - // - // Prefix matches are supported if asterisk(*) is provided as the - // last character. For example, to match all versions with a major - // version of `7`, specify the following value for this field `7.*` - // - // An empty string matches all OS versions. - string os_version = 2; - } - - // An OS policy resource is used to define the desired state configuration - // and provides a specific functionality like installing/removing packages, - // executing a script etc. - // - // The system ensures that resources are always in their desired state by - // taking necessary actions if they have drifted from their desired state. - message Resource { - // A remote or local file. - message File { - // Specifies a file available via some URI. - message Remote { - // Required. URI from which to fetch the object. It should contain both the - // protocol and path following the format `{protocol}://{location}`. - string uri = 1 [(google.api.field_behavior) = REQUIRED]; - - // SHA256 checksum of the remote file. - string sha256_checksum = 2; - } - - // Specifies a file available as a Cloud Storage Object. - message Gcs { - // Required. Bucket of the Cloud Storage object. - string bucket = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Name of the Cloud Storage object. - string object = 2 [(google.api.field_behavior) = REQUIRED]; - - // Generation number of the Cloud Storage object. - int64 generation = 3; - } - - // A specific type of file. - oneof type { - // A generic remote file. - Remote remote = 1; - - // A Cloud Storage object. - Gcs gcs = 2; - - // A local path within the VM to use. - string local_path = 3; - } - - // Defaults to false. When false, files are subject to validations - // based on the file type: - // - // Remote: A checksum must be specified. - // Cloud Storage: An object generation number must be specified. - bool allow_insecure = 4; - } - - // A resource that manages a system package. - message PackageResource { - // The desired state that the OS Config agent maintains on the VM. - enum DesiredState { - // Unspecified is invalid. - DESIRED_STATE_UNSPECIFIED = 0; - - // Ensure that the package is installed. - INSTALLED = 1; - - // The agent ensures that the package is not installed and - // uninstalls it if detected. - REMOVED = 2; - } - - // A deb package file. dpkg packages only support INSTALLED state. - message Deb { - // Required. A deb package. - File source = 1 [(google.api.field_behavior) = REQUIRED]; - - // Whether dependencies should also be installed. - // - install when false: `dpkg -i package` - // - install when true: `apt-get update && apt-get -y install - // package.deb` - bool pull_deps = 2; - } - - // A package managed by APT. - // - install: `apt-get update && apt-get -y install [name]` - // - remove: `apt-get -y remove [name]` - message APT { - // Required. Package name. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - } - - // An RPM package file. RPM packages only support INSTALLED state. - message RPM { - // Required. An rpm package. - File source = 1 [(google.api.field_behavior) = REQUIRED]; - - // Whether dependencies should also be installed. - // - install when false: `rpm --upgrade --replacepkgs package.rpm` - // - install when true: `yum -y install package.rpm` or - // `zypper -y install package.rpm` - bool pull_deps = 2; - } - - // A package managed by YUM. - // - install: `yum -y install package` - // - remove: `yum -y remove package` - message YUM { - // Required. Package name. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - } - - // A package managed by Zypper. - // - install: `zypper -y install package` - // - remove: `zypper -y rm package` - message Zypper { - // Required. Package name. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - } - - // A package managed by GooGet. - // - install: `googet -noconfirm install package` - // - remove: `googet -noconfirm remove package` - message GooGet { - // Required. Package name. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - } - - // An MSI package. MSI packages only support INSTALLED state. - message MSI { - // Required. The MSI package. - File source = 1 [(google.api.field_behavior) = REQUIRED]; - - // Additional properties to use during installation. - // This should be in the format of Property=Setting. - // Appended to the defaults of `ACTION=INSTALL - // REBOOT=ReallySuppress`. - repeated string properties = 2; - } - - // Required. The desired state the agent should maintain for this package. - DesiredState desired_state = 1 [(google.api.field_behavior) = REQUIRED]; - - // A system package. - oneof system_package { - // A package managed by Apt. - APT apt = 2; - - // A deb package file. - Deb deb = 3; - - // A package managed by YUM. - YUM yum = 4; - - // A package managed by Zypper. - Zypper zypper = 5; - - // An rpm package file. - RPM rpm = 6; - - // A package managed by GooGet. - GooGet googet = 7; - - // An MSI package. - MSI msi = 8; - } - } - - // A resource that manages a package repository. - message RepositoryResource { - // Represents a single apt package repository. These will be added to - // a repo file that will be managed at - // `/etc/apt/sources.list.d/google_osconfig.list`. - message AptRepository { - // Type of archive. - enum ArchiveType { - // Unspecified is invalid. - ARCHIVE_TYPE_UNSPECIFIED = 0; - - // Deb indicates that the archive contains binary files. - DEB = 1; - - // Deb-src indicates that the archive contains source files. - DEB_SRC = 2; - } - - // Required. Type of archive files in this repository. - ArchiveType archive_type = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. URI for this repository. - string uri = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. Distribution of this repository. - string distribution = 3 [(google.api.field_behavior) = REQUIRED]; - - // Required. List of components for this repository. Must contain at least one - // item. - repeated string components = 4 [(google.api.field_behavior) = REQUIRED]; - - // URI of the key file for this repository. The agent maintains a - // keyring at `/etc/apt/trusted.gpg.d/osconfig_agent_managed.gpg`. - string gpg_key = 5; - } - - // Represents a single yum package repository. These are added to a - // repo file that is managed at - // `/etc/yum.repos.d/google_osconfig.repo`. - message YumRepository { - // Required. A one word, unique name for this repository. This is the `repo - // id` in the yum config file and also the `display_name` if - // `display_name` is omitted. This id is also used as the unique - // identifier when checking for resource conflicts. - string id = 1 [(google.api.field_behavior) = REQUIRED]; - - // The display name of the repository. - string display_name = 2; - - // Required. The location of the repository directory. - string base_url = 3 [(google.api.field_behavior) = REQUIRED]; - - // URIs of GPG keys. - repeated string gpg_keys = 4; - } - - // Represents a single zypper package repository. These are added to a - // repo file that is managed at - // `/etc/zypp/repos.d/google_osconfig.repo`. - message ZypperRepository { - // Required. A one word, unique name for this repository. This is the `repo - // id` in the zypper config file and also the `display_name` if - // `display_name` is omitted. This id is also used as the unique - // identifier when checking for GuestPolicy conflicts. - string id = 1 [(google.api.field_behavior) = REQUIRED]; - - // The display name of the repository. - string display_name = 2; - - // Required. The location of the repository directory. - string base_url = 3 [(google.api.field_behavior) = REQUIRED]; - - // URIs of GPG keys. - repeated string gpg_keys = 4; - } - - // Represents a Goo package repository. These are added to a repo file - // that is managed at - // `C:/ProgramData/GooGet/repos/google_osconfig.repo`. - message GooRepository { - // Required. The name of the repository. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The url of the repository. - string url = 2 [(google.api.field_behavior) = REQUIRED]; - } - - // A specific type of repository. - oneof repository { - // An Apt Repository. - AptRepository apt = 1; - - // A Yum Repository. - YumRepository yum = 2; - - // A Zypper Repository. - ZypperRepository zypper = 3; - - // A Goo Repository. - GooRepository goo = 4; - } - } - - // A resource that allows executing scripts on the VM. - // - // The `ExecResource` has 2 stages: `validate` and `enforce` and both stages - // accept a script as an argument to execute. - // - // When the `ExecResource` is applied by the agent, it first executes the - // script in the `validate` stage. The `validate` stage can signal that the - // `ExecResource` is already in the desired state by returning an exit code - // of `100`. If the `ExecResource` is not in the desired state, it should - // return an exit code of `101`. Any other exit code returned by this stage - // is considered an error. - // - // If the `ExecResource` is not in the desired state based on the exit code - // from the `validate` stage, the agent proceeds to execute the script from - // the `enforce` stage. If the `ExecResource` is already in the desired - // state, the `enforce` stage will not be run. - // Similar to `validate` stage, the `enforce` stage should return an exit - // code of `100` to indicate that the resource in now in its desired state. - // Any other exit code is considered an error. - // - // NOTE: An exit code of `100` was chosen over `0` (and `101` vs `1`) to - // have an explicit indicator of `in desired state`, `not in desired state` - // and errors. Because, for example, Powershell will always return an exit - // code of `0` unless an `exit` statement is provided in the script. So, for - // reasons of consistency and being explicit, exit codes `100` and `101` - // were chosen. - message ExecResource { - // A file or script to execute. - message Exec { - // The interpreter to use. - enum Interpreter { - // Invalid value, the request will return validation error. - INTERPRETER_UNSPECIFIED = 0; - - // If an interpreter is not specified, the - // source is executed directly. This execution, without an - // interpreter, only succeeds for executables and scripts that have shebang lines. - NONE = 1; - - // Indicates that the script runs with `/bin/sh` on Linux and - // `cmd.exe` on Windows. - SHELL = 2; - - // Indicates that the script runs with PowerShell. - POWERSHELL = 3; - } - - // What to execute. - oneof source { - // A remote or local file. - File file = 1; - - // An inline script. - // The size of the script is limited to 1024 characters. - string script = 2; - } - - // Optional arguments to pass to the source during execution. - repeated string args = 3; - - // Required. The script interpreter to use. - Interpreter interpreter = 4 [(google.api.field_behavior) = REQUIRED]; - - // Only recorded for enforce Exec. - // Path to an output file (that is created by this Exec) whose - // content will be recorded in OSPolicyResourceCompliance after a - // successful run. Absence or failure to read this file will result in - // this ExecResource being non-compliant. Output file size is limited to - // 100K bytes. - string output_file_path = 5; - } - - // Required. What to run to validate this resource is in the desired state. - // An exit code of 100 indicates "in desired state", and exit code of 101 - // indicates "not in desired state". Any other exit code indicates a - // failure running validate. - Exec validate = 1 [(google.api.field_behavior) = REQUIRED]; - - // What to run to bring this resource into the desired state. - // An exit code of 100 indicates "success", any other exit code indicates - // a failure running enforce. - Exec enforce = 2; - } - - // A resource that manages the state of a file. - message FileResource { - // Desired state of the file. - enum DesiredState { - // Unspecified is invalid. - DESIRED_STATE_UNSPECIFIED = 0; - - // Ensure file at path is present. - PRESENT = 1; - - // Ensure file at path is absent. - ABSENT = 2; - - // Ensure the contents of the file at path matches. If the file does - // not exist it will be created. - CONTENTS_MATCH = 3; - } - - // The source for the contents of the file. - oneof source { - // A remote or local source. - File file = 1; - - // A a file with this content. - // The size of the content is limited to 1024 characters. - string content = 2; - } - - // Required. The absolute path of the file within the VM. - string path = 3 [(google.api.field_behavior) = REQUIRED]; - - // Required. Desired state of the file. - DesiredState state = 4 [(google.api.field_behavior) = REQUIRED]; - - // Consists of three octal digits which represent, in - // order, the permissions of the owner, group, and other users for the - // file (similarly to the numeric mode used in the linux chmod - // utility). Each digit represents a three bit number with the 4 bit - // corresponding to the read permissions, the 2 bit corresponds to the - // write bit, and the one bit corresponds to the execute permission. - // Default behavior is 755. - // - // Below are some examples of permissions and their associated values: - // read, write, and execute: 7 - // read and execute: 5 - // read and write: 6 - // read only: 4 - string permissions = 5; - } - - // Required. The id of the resource with the following restrictions: - // - // * Must contain only lowercase letters, numbers, and hyphens. - // * Must start with a letter. - // * Must be between 1-63 characters. - // * Must end with a number or a letter. - // * Must be unique within the OS policy. - string id = 1 [(google.api.field_behavior) = REQUIRED]; - - // Resource type. - oneof resource_type { - // Package resource - PackageResource pkg = 2; - - // Package repository resource - RepositoryResource repository = 3; - - // Exec resource - ExecResource exec = 4; - - // File resource - FileResource file = 5; - } - } - - // Resource groups provide a mechanism to group OS policy resources. - // - // Resource groups enable OS policy authors to create a single OS policy - // to be applied to VMs running different operating Systems. - // - // When the OS policy is applied to a target VM, the appropriate resource - // group within the OS policy is selected based on the `OSFilter` specified - // within the resource group. - message ResourceGroup { - // Deprecated. Use the `inventory_filters` field instead. - // Used to specify the OS filter for a resource group - OSFilter os_filter = 1 [deprecated = true]; - - // List of inventory filters for the resource group. - // - // The resources in this resource group are applied to the target VM if it - // satisfies at least one of the following inventory filters. - // - // For example, to apply this resource group to VMs running either `RHEL` or - // `CentOS` operating systems, specify 2 items for the list with following - // values: - // inventory_filters[0].os_short_name='rhel' and - // inventory_filters[1].os_short_name='centos' - // - // If the list is empty, this resource group will be applied to the target - // VM unconditionally. - repeated InventoryFilter inventory_filters = 3; - - // Required. List of resources configured for this resource group. - // The resources are executed in the exact order specified here. - repeated Resource resources = 2 [(google.api.field_behavior) = REQUIRED]; - } - - // Required. The id of the OS policy with the following restrictions: - // - // * Must contain only lowercase letters, numbers, and hyphens. - // * Must start with a letter. - // * Must be between 1-63 characters. - // * Must end with a number or a letter. - // * Must be unique within the assignment. - string id = 1 [(google.api.field_behavior) = REQUIRED]; - - // Policy description. - // Length of the description is limited to 1024 characters. - string description = 2; - - // Required. Policy mode - Mode mode = 3 [(google.api.field_behavior) = REQUIRED]; - - // Required. List of resource groups for the policy. - // For a particular VM, resource groups are evaluated in the order specified - // and the first resource group that is applicable is selected and the rest - // are ignored. - // - // If none of the resource groups are applicable for a VM, the VM is - // considered to be non-compliant w.r.t this policy. This behavior can be - // toggled by the flag `allow_no_resource_group_match` - repeated ResourceGroup resource_groups = 4 [(google.api.field_behavior) = REQUIRED]; - - // This flag determines the OS policy compliance status when none of the - // resource groups within the policy are applicable for a VM. Set this value - // to `true` if the policy needs to be reported as compliant even if the - // policy has nothing to validate or enforce. - bool allow_no_resource_group_match = 5; -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy_assignment_reports.proto b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy_assignment_reports.proto deleted file mode 100644 index 6b00fb9e0ca..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy_assignment_reports.proto +++ /dev/null @@ -1,296 +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.osconfig.v1alpha; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.OsConfig.V1Alpha"; -option go_package = "cloud.google.com/go/osconfig/apiv1alpha/osconfigpb;osconfigpb"; -option java_multiple_files = true; -option java_outer_classname = "OSPolicyAssignmentReportsProto"; -option java_package = "com.google.cloud.osconfig.v1alpha"; -option php_namespace = "Google\\Cloud\\OsConfig\\V1alpha"; -option ruby_package = "Google::Cloud::OsConfig::V1alpha"; -option (google.api.resource_definition) = { - type: "compute.googleapis.com/InstanceOSPolicyAssignment" - pattern: "projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}" -}; - -// Get a report of the OS policy assignment for a VM instance. -message GetOSPolicyAssignmentReportRequest { - // Required. API resource name for OS policy assignment report. - // - // Format: - // `/projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report` - // - // For `{project}`, either `project-number` or `project-id` can be provided. - // For `{instance_id}`, either Compute Engine `instance-id` or `instance-name` - // can be provided. - // For `{assignment_id}`, the OSPolicyAssignment id must be provided. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/OSPolicyAssignmentReport" - } - ]; -} - -// List the OS policy assignment reports for VM instances. -message ListOSPolicyAssignmentReportsRequest { - // Required. The parent resource name. - // - // Format: - // `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/reports` - // - // For `{project}`, either `project-number` or `project-id` can be provided. - // For `{instance}`, either `instance-name`, `instance-id`, or `-` can be - // provided. If '-' is provided, the response will include - // OSPolicyAssignmentReports for all instances in the project/location. - // For `{assignment}`, either `assignment-id` or `-` can be provided. If '-' - // is provided, the response will include OSPolicyAssignmentReports for all - // OSPolicyAssignments in the project/location. - // Either {instance} or {assignment} must be `-`. - // - // For example: - // `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/-/reports` - // returns all reports for the instance - // `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/{assignment-id}/reports` - // returns all the reports for the given assignment across all instances. - // `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/-/reports` - // returns all the reports for all assignments across all instances. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "compute.googleapis.com/InstanceOSPolicyAssignment" - } - ]; - - // The maximum number of results to return. - int32 page_size = 2; - - // If provided, this field specifies the criteria that must be met by the - // `OSPolicyAssignmentReport` API resource that is included in the response. - string filter = 3; - - // A pagination token returned from a previous call to the - // `ListOSPolicyAssignmentReports` method that indicates where this listing - // should continue from. - string page_token = 4; -} - -// A response message for listing OS Policy assignment reports including the -// page of results and page token. -message ListOSPolicyAssignmentReportsResponse { - // List of OS policy assignment reports. - repeated OSPolicyAssignmentReport os_policy_assignment_reports = 1; - - // The pagination token to retrieve the next page of OS policy assignment - // report objects. - string next_page_token = 2; -} - -// A report of the OS policy assignment status for a given instance. -message OSPolicyAssignmentReport { - option (google.api.resource) = { - type: "osconfig.googleapis.com/OSPolicyAssignmentReport" - pattern: "projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report" - }; - - // Compliance data for an OS policy - message OSPolicyCompliance { - // Possible compliance states for an os policy. - enum ComplianceState { - // The policy is in an unknown compliance state. - // - // Refer to the field `compliance_state_reason` to learn the exact reason - // for the policy to be in this compliance state. - UNKNOWN = 0; - - // Policy is compliant. - // - // The policy is compliant if all the underlying resources are also - // compliant. - COMPLIANT = 1; - - // Policy is non-compliant. - // - // The policy is non-compliant if one or more underlying resources are - // non-compliant. - NON_COMPLIANT = 2; - } - - // Compliance data for an OS policy resource. - message OSPolicyResourceCompliance { - // Step performed by the OS Config agent for configuring an - // `OSPolicy` resource to its desired state. - message OSPolicyResourceConfigStep { - // Supported configuration step types - enum Type { - // Default value. This value is unused. - TYPE_UNSPECIFIED = 0; - - // Checks for resource conflicts such as schema errors. - VALIDATION = 1; - - // Checks the current status of the desired state for a resource. - DESIRED_STATE_CHECK = 2; - - // Enforces the desired state for a resource that is not in desired - // state. - DESIRED_STATE_ENFORCEMENT = 3; - - // Re-checks the status of the desired state. This check is done - // for a resource after the enforcement of all OS policies. - // - // This step is used to determine the final desired state status for - // the resource. It accounts for any resources that might have drifted - // from their desired state due to side effects from executing other - // resources. - DESIRED_STATE_CHECK_POST_ENFORCEMENT = 4; - } - - // Configuration step type. - Type type = 1; - - // An error message recorded during the execution of this step. - // Only populated if errors were encountered during this step execution. - string error_message = 2; - } - - // Possible compliance states for a resource. - enum ComplianceState { - // The resource is in an unknown compliance state. - // - // To get more details about why the policy is in this state, review - // the output of the `compliance_state_reason` field. - UNKNOWN = 0; - - // Resource is compliant. - COMPLIANT = 1; - - // Resource is non-compliant. - NON_COMPLIANT = 2; - } - - // ExecResource specific output. - message ExecResourceOutput { - // Output from enforcement phase output file (if run). - // Output size is limited to 100K bytes. - bytes enforcement_output = 2; - } - - // The ID of the OS policy resource. - string os_policy_resource_id = 1; - - // Ordered list of configuration completed by the agent for the OS policy - // resource. - repeated OSPolicyResourceConfigStep config_steps = 2; - - // The compliance state of the resource. - ComplianceState compliance_state = 3; - - // A reason for the resource to be in the given compliance state. - // This field is always populated when `compliance_state` is `UNKNOWN`. - // - // The following values are supported when `compliance_state == UNKNOWN` - // - // * `execution-errors`: Errors were encountered by the agent while - // executing the resource and the compliance state couldn't be - // determined. - // * `execution-skipped-by-agent`: Resource execution was skipped by the - // agent because errors were encountered while executing prior resources - // in the OS policy. - // * `os-policy-execution-attempt-failed`: The execution of the OS policy - // containing this resource failed and the compliance state couldn't be - // determined. - string compliance_state_reason = 4; - - // Resource specific output. - oneof output { - // ExecResource specific output. - ExecResourceOutput exec_resource_output = 5; - } - } - - // The OS policy id - string os_policy_id = 1; - - // The compliance state of the OS policy. - ComplianceState compliance_state = 2; - - // The reason for the OS policy to be in an unknown compliance state. - // This field is always populated when `compliance_state` is `UNKNOWN`. - // - // If populated, the field can contain one of the following values: - // - // * `vm-not-running`: The VM was not running. - // * `os-policies-not-supported-by-agent`: The version of the OS Config - // agent running on the VM does not support running OS policies. - // * `no-agent-detected`: The OS Config agent is not detected for the VM. - // * `resource-execution-errors`: The OS Config agent encountered errors - // while executing one or more resources in the policy. See - // `os_policy_resource_compliances` for details. - // * `task-timeout`: The task sent to the agent to apply the policy timed - // out. - // * `unexpected-agent-state`: The OS Config agent did not report the final - // status of the task that attempted to apply the policy. Instead, the agent - // unexpectedly started working on a different task. This mostly happens - // when the agent or VM unexpectedly restarts while applying OS policies. - // * `internal-service-errors`: Internal service errors were encountered - // while attempting to apply the policy. - string compliance_state_reason = 3; - - // Compliance data for each resource within the policy that is applied to - // the VM. - repeated OSPolicyResourceCompliance os_policy_resource_compliances = 4; - } - - // The `OSPolicyAssignmentReport` API resource name. - // - // Format: - // `projects/{project_number}/locations/{location}/instances/{instance_id}/osPolicyAssignments/{os_policy_assignment_id}/report` - string name = 1; - - // The Compute Engine VM instance name. - string instance = 2; - - // Reference to the `OSPolicyAssignment` API resource that the `OSPolicy` - // belongs to. - // - // Format: - // `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id@revision_id}` - string os_policy_assignment = 3 [(google.api.resource_reference) = { - type: "osconfig.googleapis.com/OSPolicyAssignment" - }]; - - // Compliance data for each `OSPolicy` that is applied to the VM. - repeated OSPolicyCompliance os_policy_compliances = 4; - - // Timestamp for when the report was last generated. - google.protobuf.Timestamp update_time = 5; - - // Unique identifier of the last attempted run to apply the OS policies - // associated with this assignment on the VM. - // - // This ID is logged by the OS Config agent while applying the OS - // policies associated with this assignment on the VM. - // NOTE: If the service is unable to successfully connect to the agent for - // this run, then this id will not be available in the agent logs. - string last_run_id = 6; -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy_assignments.proto b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy_assignments.proto deleted file mode 100644 index 86b0cbb88d1..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/os_policy_assignments.proto +++ /dev/null @@ -1,383 +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.osconfig.v1alpha; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/osconfig/v1alpha/os_policy.proto"; -import "google/cloud/osconfig/v1alpha/osconfig_common.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.OsConfig.V1Alpha"; -option go_package = "cloud.google.com/go/osconfig/apiv1alpha/osconfigpb;osconfigpb"; -option java_multiple_files = true; -option java_outer_classname = "OsPolicyAssignmentsProto"; -option java_package = "com.google.cloud.osconfig.v1alpha"; -option php_namespace = "Google\\Cloud\\OsConfig\\V1alpha"; -option ruby_package = "Google::Cloud::OsConfig::V1alpha"; - -// OS policy assignment is an API resource that is used to -// apply a set of OS policies to a dynamically targeted group of Compute Engine -// VM instances. -// -// An OS policy is used to define the desired state configuration for a -// Compute Engine VM instance through a set of configuration resources that -// provide capabilities such as installing or removing software packages, or -// executing a script. -// -// For more information, see [OS policy and OS policy -// assignment](https://cloud.google.com/compute/docs/os-configuration-management/working-with-os-policies). -message OSPolicyAssignment { - option (google.api.resource) = { - type: "osconfig.googleapis.com/OSPolicyAssignment" - pattern: "projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}" - }; - - // Message representing label set. - // * A label is a key value pair set for a VM. - // * A LabelSet is a set of labels. - // * Labels within a LabelSet are ANDed. In other words, a LabelSet is - // applicable for a VM only if it matches all the labels in the - // LabelSet. - // * Example: A LabelSet with 2 labels: `env=prod` and `type=webserver` will - // only be applicable for those VMs with both labels - // present. - message LabelSet { - // Labels are identified by key/value pairs in this map. - // A VM should contain all the key/value pairs specified in this - // map to be selected. - map labels = 1; - } - - // Filters to select target VMs for an assignment. - // - // If more than one filter criteria is specified below, a VM will be selected - // if and only if it satisfies all of them. - message InstanceFilter { - // VM inventory details. - message Inventory { - // Required. The OS short name - string os_short_name = 1 [(google.api.field_behavior) = REQUIRED]; - - // The OS version - // - // Prefix matches are supported if asterisk(*) is provided as the - // last character. For example, to match all versions with a major - // version of `7`, specify the following value for this field `7.*` - // - // An empty string matches all OS versions. - string os_version = 2; - } - - // Target all VMs in the project. If true, no other criteria is - // permitted. - bool all = 1; - - // Deprecated. Use the `inventories` field instead. - // A VM is selected if it's OS short name matches with any of the - // values provided in this list. - repeated string os_short_names = 2 [deprecated = true]; - - // List of label sets used for VM inclusion. - // - // If the list has more than one `LabelSet`, the VM is included if any - // of the label sets are applicable for the VM. - repeated LabelSet inclusion_labels = 3; - - // List of label sets used for VM exclusion. - // - // If the list has more than one label set, the VM is excluded if any - // of the label sets are applicable for the VM. - repeated LabelSet exclusion_labels = 4; - - // List of inventories to select VMs. - // - // A VM is selected if its inventory data matches at least one of the - // following inventories. - repeated Inventory inventories = 5; - } - - // Message to configure the rollout at the zonal level for the OS policy - // assignment. - message Rollout { - // Required. The maximum number (or percentage) of VMs per zone to disrupt at - // any given moment. - FixedOrPercent disruption_budget = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. This determines the minimum duration of time to wait after the - // configuration changes are applied through the current rollout. A - // VM continues to count towards the `disruption_budget` at least - // until this duration of time has passed after configuration changes are - // applied. - google.protobuf.Duration min_wait_duration = 2 [(google.api.field_behavior) = REQUIRED]; - } - - // OS policy assignment rollout state - enum RolloutState { - // Invalid value - ROLLOUT_STATE_UNSPECIFIED = 0; - - // The rollout is in progress. - IN_PROGRESS = 1; - - // The rollout is being cancelled. - CANCELLING = 2; - - // The rollout is cancelled. - CANCELLED = 3; - - // The rollout has completed successfully. - SUCCEEDED = 4; - } - - // Resource name. - // - // Format: - // `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id}` - // - // This field is ignored when you create an OS policy assignment. - string name = 1; - - // OS policy assignment description. - // Length of the description is limited to 1024 characters. - string description = 2; - - // Required. List of OS policies to be applied to the VMs. - repeated OSPolicy os_policies = 3 [(google.api.field_behavior) = REQUIRED]; - - // Required. Filter to select VMs. - InstanceFilter instance_filter = 4 [(google.api.field_behavior) = REQUIRED]; - - // Required. Rollout to deploy the OS policy assignment. - // A rollout is triggered in the following situations: - // 1) OSPolicyAssignment is created. - // 2) OSPolicyAssignment is updated and the update contains changes to one of - // the following fields: - // - instance_filter - // - os_policies - // 3) OSPolicyAssignment is deleted. - Rollout rollout = 5 [(google.api.field_behavior) = REQUIRED]; - - // Output only. The assignment revision ID - // A new revision is committed whenever a rollout is triggered for a OS policy - // assignment - string revision_id = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The timestamp that the revision was created. - google.protobuf.Timestamp revision_create_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The etag for this OS policy assignment. - // If this is provided on update, it must match the server's etag. - string etag = 8; - - // Output only. OS policy assignment rollout state - RolloutState rollout_state = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Indicates that this revision has been successfully rolled out in this zone - // and new VMs will be assigned OS policies from this revision. - // - // For a given OS policy assignment, there is only one revision with a value - // of `true` for this field. - bool baseline = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Indicates that this revision deletes the OS policy assignment. - bool deleted = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Indicates that reconciliation is in progress for the revision. - // This value is `true` when the `rollout_state` is one of: - // * IN_PROGRESS - // * CANCELLING - bool reconciling = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Server generated unique id for the OS policy assignment resource. - string uid = 13 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// OS policy assignment operation metadata provided by OS policy assignment API -// methods that return long running operations. -message OSPolicyAssignmentOperationMetadata { - // The OS policy assignment API method. - enum APIMethod { - // Invalid value - API_METHOD_UNSPECIFIED = 0; - - // Create OS policy assignment API method - CREATE = 1; - - // Update OS policy assignment API method - UPDATE = 2; - - // Delete OS policy assignment API method - DELETE = 3; - } - - // State of the rollout - enum RolloutState { - // Invalid value - ROLLOUT_STATE_UNSPECIFIED = 0; - - // The rollout is in progress. - IN_PROGRESS = 1; - - // The rollout is being cancelled. - CANCELLING = 2; - - // The rollout is cancelled. - CANCELLED = 3; - - // The rollout has completed successfully. - SUCCEEDED = 4; - } - - // Reference to the `OSPolicyAssignment` API resource. - // - // Format: - // `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id@revision_id}` - string os_policy_assignment = 1 [(google.api.resource_reference) = { - type: "osconfig.googleapis.com/OSPolicyAssignment" - }]; - - // The OS policy assignment API method. - APIMethod api_method = 2; - - // State of the rollout - RolloutState rollout_state = 3; - - // Rollout start time - google.protobuf.Timestamp rollout_start_time = 4; - - // Rollout update time - google.protobuf.Timestamp rollout_update_time = 5; -} - -// A request message to create an OS policy assignment -message CreateOSPolicyAssignmentRequest { - // Required. The parent resource name in the form: - // projects/{project}/locations/{location} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The OS policy assignment to be created. - OSPolicyAssignment os_policy_assignment = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The logical name of the OS policy assignment in the project - // with the following restrictions: - // - // * Must contain only lowercase letters, numbers, and hyphens. - // * Must start with a letter. - // * Must be between 1-63 characters. - // * Must end with a number or a letter. - // * Must be unique within the project. - string os_policy_assignment_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// A request message to update an OS policy assignment -message UpdateOSPolicyAssignmentRequest { - // Required. The updated OS policy assignment. - OSPolicyAssignment os_policy_assignment = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Field mask that controls which fields of the assignment should be updated. - google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// A request message to get an OS policy assignment -message GetOSPolicyAssignmentRequest { - // Required. The resource name of OS policy assignment. - // - // Format: - // `projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}@{revisionId}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/OSPolicyAssignment" - } - ]; -} - -// A request message to list OS policy assignments for a parent resource -message ListOSPolicyAssignmentsRequest { - // Required. The parent resource name. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of assignments to return. - int32 page_size = 2; - - // A pagination token returned from a previous call to - // `ListOSPolicyAssignments` that indicates where this listing should continue - // from. - string page_token = 3; -} - -// A response message for listing all assignments under given parent. -message ListOSPolicyAssignmentsResponse { - // The list of assignments - repeated OSPolicyAssignment os_policy_assignments = 1; - - // The pagination token to retrieve the next page of OS policy assignments. - string next_page_token = 2; -} - -// A request message to list revisions for a OS policy assignment -message ListOSPolicyAssignmentRevisionsRequest { - // Required. The name of the OS policy assignment to list revisions for. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/OSPolicyAssignment" - } - ]; - - // The maximum number of revisions to return. - int32 page_size = 2; - - // A pagination token returned from a previous call to - // `ListOSPolicyAssignmentRevisions` that indicates where this listing should - // continue from. - string page_token = 3; -} - -// A response message for listing all revisions for a OS policy assignment. -message ListOSPolicyAssignmentRevisionsResponse { - // The OS policy assignment revisions - repeated OSPolicyAssignment os_policy_assignments = 1; - - // The pagination token to retrieve the next page of OS policy assignment - // revisions. - string next_page_token = 2; -} - -// A request message for deleting a OS policy assignment. -message DeleteOSPolicyAssignmentRequest { - // Required. The name of the OS policy assignment to be deleted - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/OSPolicyAssignment" - } - ]; -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/osconfig_common.proto b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/osconfig_common.proto deleted file mode 100644 index 49bfeca0c34..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/osconfig_common.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.osconfig.v1alpha; - - -option csharp_namespace = "Google.Cloud.OsConfig.V1Alpha"; -option go_package = "cloud.google.com/go/osconfig/apiv1alpha/osconfigpb;osconfigpb"; -option java_multiple_files = true; -option java_outer_classname = "Common"; -option java_package = "com.google.cloud.osconfig.v1alpha"; -option php_namespace = "Google\\Cloud\\OsConfig\\V1alpha"; -option ruby_package = "Google::Cloud::OsConfig::V1alpha"; - -// Message encapsulating a value that can be either absolute ("fixed") or -// relative ("percent") to a value. -message FixedOrPercent { - // Type of the value. - oneof mode { - // Specifies a fixed value. - int32 fixed = 1; - - // Specifies the relative value defined as a percentage, which will be - // multiplied by a reference value. - int32 percent = 2; - } -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/osconfig_zonal_service.proto b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/osconfig_zonal_service.proto deleted file mode 100644 index 439efa9d78f..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/osconfig_zonal_service.proto +++ /dev/null @@ -1,215 +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.osconfig.v1alpha; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/resource.proto"; -import "google/cloud/osconfig/v1alpha/instance_os_policies_compliance.proto"; -import "google/cloud/osconfig/v1alpha/inventory.proto"; -import "google/cloud/osconfig/v1alpha/os_policy_assignment_reports.proto"; -import "google/cloud/osconfig/v1alpha/os_policy_assignments.proto"; -import "google/cloud/osconfig/v1alpha/vulnerability.proto"; -import "google/longrunning/operations.proto"; - -option csharp_namespace = "Google.Cloud.OsConfig.V1Alpha"; -option go_package = "cloud.google.com/go/osconfig/apiv1alpha/osconfigpb;osconfigpb"; -option java_multiple_files = true; -option java_outer_classname = "OsConfigZonalServiceProto"; -option java_package = "com.google.cloud.osconfig.v1alpha"; -option php_namespace = "Google\\Cloud\\OsConfig\\V1alpha"; -option ruby_package = "Google::Cloud::OsConfig::V1alpha"; -option (google.api.resource_definition) = { - type: "compute.googleapis.com/Instance" - pattern: "projects/{project}/locations/{location}/instances/{instance}" -}; - -// Zonal OS Config API -// -// The OS Config service is the server-side component that allows users to -// manage package installations and patch jobs for Compute Engine VM instances. -service OsConfigZonalService { - option (google.api.default_host) = "osconfig.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Create an OS policy assignment. - // - // This method also creates the first revision of the OS policy assignment. - // - // This method returns a long running operation (LRO) that contains the - // rollout details. The rollout can be cancelled by cancelling the LRO. - // - // For more information, see [Method: - // projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1alpha/projects.locations.osPolicyAssignments.operations/cancel). - rpc CreateOSPolicyAssignment(CreateOSPolicyAssignmentRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1alpha/{parent=projects/*/locations/*}/osPolicyAssignments" - body: "os_policy_assignment" - }; - option (google.api.method_signature) = "parent,os_policy_assignment,os_policy_assignment_id"; - option (google.longrunning.operation_info) = { - response_type: "OSPolicyAssignment" - metadata_type: "OSPolicyAssignmentOperationMetadata" - }; - } - - // Update an existing OS policy assignment. - // - // This method creates a new revision of the OS policy assignment. - // - // This method returns a long running operation (LRO) that contains the - // rollout details. The rollout can be cancelled by cancelling the LRO. - // - // For more information, see [Method: - // projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1alpha/projects.locations.osPolicyAssignments.operations/cancel). - rpc UpdateOSPolicyAssignment(UpdateOSPolicyAssignmentRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1alpha/{os_policy_assignment.name=projects/*/locations/*/osPolicyAssignments/*}" - body: "os_policy_assignment" - }; - option (google.api.method_signature) = "os_policy_assignment,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "OSPolicyAssignment" - metadata_type: "OSPolicyAssignmentOperationMetadata" - }; - } - - // Retrieve an existing OS policy assignment. - // - // This method always returns the latest revision. In order to retrieve a - // previous revision of the assignment, also provide the revision ID in the - // `name` parameter. - rpc GetOSPolicyAssignment(GetOSPolicyAssignmentRequest) returns (OSPolicyAssignment) { - option (google.api.http) = { - get: "/v1alpha/{name=projects/*/locations/*/osPolicyAssignments/*}" - }; - option (google.api.method_signature) = "name"; - } - - // List the OS policy assignments under the parent resource. - // - // For each OS policy assignment, the latest revision is returned. - rpc ListOSPolicyAssignments(ListOSPolicyAssignmentsRequest) returns (ListOSPolicyAssignmentsResponse) { - option (google.api.http) = { - get: "/v1alpha/{parent=projects/*/locations/*}/osPolicyAssignments" - }; - option (google.api.method_signature) = "parent"; - } - - // List the OS policy assignment revisions for a given OS policy assignment. - rpc ListOSPolicyAssignmentRevisions(ListOSPolicyAssignmentRevisionsRequest) returns (ListOSPolicyAssignmentRevisionsResponse) { - option (google.api.http) = { - get: "/v1alpha/{name=projects/*/locations/*/osPolicyAssignments/*}:listRevisions" - }; - option (google.api.method_signature) = "name"; - } - - // Delete the OS policy assignment. - // - // This method creates a new revision of the OS policy assignment. - // - // This method returns a long running operation (LRO) that contains the - // rollout details. The rollout can be cancelled by cancelling the LRO. - // - // If the LRO completes and is not cancelled, all revisions associated with - // the OS policy assignment are deleted. - // - // For more information, see [Method: - // projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1alpha/projects.locations.osPolicyAssignments.operations/cancel). - rpc DeleteOSPolicyAssignment(DeleteOSPolicyAssignmentRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1alpha/{name=projects/*/locations/*/osPolicyAssignments/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "OSPolicyAssignmentOperationMetadata" - }; - } - - // Get OS policies compliance data for the specified Compute Engine VM - // instance. - rpc GetInstanceOSPoliciesCompliance(GetInstanceOSPoliciesComplianceRequest) returns (InstanceOSPoliciesCompliance) { - option deprecated = true; - option (google.api.http) = { - get: "/v1alpha/{name=projects/*/locations/*/instanceOSPoliciesCompliances/*}" - }; - option (google.api.method_signature) = "name"; - } - - // List OS policies compliance data for all Compute Engine VM instances in the - // specified zone. - rpc ListInstanceOSPoliciesCompliances(ListInstanceOSPoliciesCompliancesRequest) returns (ListInstanceOSPoliciesCompliancesResponse) { - option deprecated = true; - option (google.api.http) = { - get: "/v1alpha/{parent=projects/*/locations/*}/instanceOSPoliciesCompliances" - }; - option (google.api.method_signature) = "parent"; - } - - // Get the OS policy asssignment report for the specified Compute Engine VM - // instance. - rpc GetOSPolicyAssignmentReport(GetOSPolicyAssignmentReportRequest) returns (OSPolicyAssignmentReport) { - option (google.api.http) = { - get: "/v1alpha/{name=projects/*/locations/*/instances/*/osPolicyAssignments/*/report}" - }; - option (google.api.method_signature) = "name"; - } - - // List OS policy asssignment reports for all Compute Engine VM instances in - // the specified zone. - rpc ListOSPolicyAssignmentReports(ListOSPolicyAssignmentReportsRequest) returns (ListOSPolicyAssignmentReportsResponse) { - option (google.api.http) = { - get: "/v1alpha/{parent=projects/*/locations/*/instances/*/osPolicyAssignments/*}/reports" - }; - option (google.api.method_signature) = "parent"; - } - - // Get inventory data for the specified VM instance. If the VM has no - // associated inventory, the message `NOT_FOUND` is returned. - rpc GetInventory(GetInventoryRequest) returns (Inventory) { - option (google.api.http) = { - get: "/v1alpha/{name=projects/*/locations/*/instances/*/inventory}" - }; - option (google.api.method_signature) = "name"; - } - - // List inventory data for all VM instances in the specified zone. - rpc ListInventories(ListInventoriesRequest) returns (ListInventoriesResponse) { - option (google.api.http) = { - get: "/v1alpha/{parent=projects/*/locations/*/instances/*}/inventories" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets the vulnerability report for the specified VM instance. Only VMs with - // inventory data have vulnerability reports associated with them. - rpc GetVulnerabilityReport(GetVulnerabilityReportRequest) returns (VulnerabilityReport) { - option (google.api.http) = { - get: "/v1alpha/{name=projects/*/locations/*/instances/*/vulnerabilityReport}" - }; - option (google.api.method_signature) = "name"; - } - - // List vulnerability reports for all VM instances in the specified zone. - rpc ListVulnerabilityReports(ListVulnerabilityReportsRequest) returns (ListVulnerabilityReportsResponse) { - option (google.api.http) = { - get: "/v1alpha/{parent=projects/*/locations/*/instances/*}/vulnerabilityReports" - }; - option (google.api.method_signature) = "parent"; - } -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/vulnerability.proto b/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/vulnerability.proto deleted file mode 100644 index 2ea9784fd85..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/protos/google/cloud/osconfig/v1alpha/vulnerability.proto +++ /dev/null @@ -1,365 +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.osconfig.v1alpha; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.OsConfig.V1Alpha"; -option go_package = "cloud.google.com/go/osconfig/apiv1alpha/osconfigpb;osconfigpb"; -option java_multiple_files = true; -option java_outer_classname = "VulnerabilityProto"; -option java_package = "com.google.cloud.osconfig.v1alpha"; -option php_namespace = "Google\\Cloud\\OsConfig\\V1alpha"; -option ruby_package = "Google::Cloud::OsConfig::V1alpha"; - -// This API resource represents the vulnerability report for a specified -// Compute Engine virtual machine (VM) instance at a given point in time. -// -// For more information, see [Vulnerability -// reports](https://cloud.google.com/compute/docs/instances/os-inventory-management#vulnerability-reports). -message VulnerabilityReport { - option (google.api.resource) = { - type: "osconfig.googleapis.com/VulnerabilityReport" - pattern: "projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport" - }; - - // A vulnerability affecting the VM instance. - message Vulnerability { - // Contains metadata information for the vulnerability. This information is - // collected from the upstream feed of the operating system. - message Details { - // A reference for this vulnerability. - message Reference { - // The url of the reference. - string url = 1; - - // The source of the reference e.g. NVD. - string source = 2; - } - - // The CVE of the vulnerability. CVE cannot be - // empty and the combination of should be unique - // across vulnerabilities for a VM. - string cve = 1; - - // The CVSS V2 score of this vulnerability. CVSS V2 score is on a scale of - // 0 - 10 where 0 indicates low severity and 10 indicates high severity. - float cvss_v2_score = 2; - - // The full description of the CVSSv3 for this vulnerability from NVD. - CVSSv3 cvss_v3 = 3; - - // Assigned severity/impact ranking from the distro. - string severity = 4; - - // The note or description describing the vulnerability from the distro. - string description = 5; - - // Corresponds to the references attached to the `VulnerabilityDetails`. - repeated Reference references = 6; - } - - // OS inventory item that is affected by a vulnerability or fixed as a - // result of a vulnerability. - message Item { - // Corresponds to the `INSTALLED_PACKAGE` inventory item on the VM. - // This field displays the inventory items affected by this vulnerability. - // If the vulnerability report was not updated after the VM inventory - // update, these values might not display in VM inventory. For some - // operating systems, this field might be empty. - string installed_inventory_item_id = 1; - - // Corresponds to the `AVAILABLE_PACKAGE` inventory item on the VM. - // If the vulnerability report was not updated after the VM inventory - // update, these values might not display in VM inventory. If there is no - // available fix, the field is empty. The `inventory_item` value specifies - // the latest `SoftwarePackage` available to the VM that fixes the - // vulnerability. - string available_inventory_item_id = 2; - - // The recommended [CPE URI](https://cpe.mitre.org/specification/) update - // that contains a fix for this vulnerability. - string fixed_cpe_uri = 3; - - // The upstream OS patch, packages or KB that fixes the vulnerability. - string upstream_fix = 4; - } - - // Contains metadata as per the upstream feed of the operating system and - // NVD. - Details details = 1; - - // Corresponds to the `INSTALLED_PACKAGE` inventory item on the VM. - // This field displays the inventory items affected by this vulnerability. - // If the vulnerability report was not updated after the VM inventory - // update, these values might not display in VM inventory. For some distros, - // this field may be empty. - repeated string installed_inventory_item_ids = 2 [deprecated = true]; - - // Corresponds to the `AVAILABLE_PACKAGE` inventory item on the VM. - // If the vulnerability report was not updated after the VM inventory - // update, these values might not display in VM inventory. If there is no - // available fix, the field is empty. The `inventory_item` value specifies - // the latest `SoftwarePackage` available to the VM that fixes the - // vulnerability. - repeated string available_inventory_item_ids = 3 [deprecated = true]; - - // The timestamp for when the vulnerability was first detected. - google.protobuf.Timestamp create_time = 4; - - // The timestamp for when the vulnerability was last modified. - google.protobuf.Timestamp update_time = 5; - - // List of items affected by the vulnerability. - repeated Item items = 6; - } - - // Output only. The `vulnerabilityReport` API resource name. - // - // Format: - // `projects/{project_number}/locations/{location}/instances/{instance_id}/vulnerabilityReport` - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. List of vulnerabilities affecting the VM. - repeated Vulnerability vulnerabilities = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The timestamp for when the last vulnerability report was generated for the - // VM. - google.protobuf.Timestamp update_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A request message for getting the vulnerability report for the specified VM. -message GetVulnerabilityReportRequest { - // Required. API resource name for vulnerability resource. - // - // Format: - // `projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport` - // - // For `{project}`, either `project-number` or `project-id` can be provided. - // For `{instance}`, either Compute Engine `instance-id` or `instance-name` - // can be provided. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/VulnerabilityReport" - } - ]; -} - -// A request message for listing vulnerability reports for all VM instances in -// the specified location. -message ListVulnerabilityReportsRequest { - // Required. The parent resource name. - // - // Format: `projects/{project}/locations/{location}/instances/-` - // - // For `{project}`, either `project-number` or `project-id` can be provided. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "compute.googleapis.com/Instance" - } - ]; - - // The maximum number of results to return. - int32 page_size = 2; - - // A pagination token returned from a previous call to - // `ListVulnerabilityReports` that indicates where this listing - // should continue from. - string page_token = 3; - - // If provided, this field specifies the criteria that must be met by a - // `vulnerabilityReport` API resource to be included in the response. - string filter = 4; -} - -// A response message for listing vulnerability reports for all VM instances in -// the specified location. -message ListVulnerabilityReportsResponse { - // List of vulnerabilityReport objects. - repeated VulnerabilityReport vulnerability_reports = 1; - - // The pagination token to retrieve the next page of vulnerabilityReports - // object. - string next_page_token = 2; -} - -// Common Vulnerability Scoring System version 3. -// For details, see https://www.first.org/cvss/specification-document -message CVSSv3 { - // This metric reflects the context by which vulnerability exploitation is - // possible. - enum AttackVector { - // Invalid value. - ATTACK_VECTOR_UNSPECIFIED = 0; - - // The vulnerable component is bound to the network stack and the set of - // possible attackers extends beyond the other options listed below, up to - // and including the entire Internet. - ATTACK_VECTOR_NETWORK = 1; - - // The vulnerable component is bound to the network stack, but the attack is - // limited at the protocol level to a logically adjacent topology. - ATTACK_VECTOR_ADJACENT = 2; - - // The vulnerable component is not bound to the network stack and the - // attacker's path is via read/write/execute capabilities. - ATTACK_VECTOR_LOCAL = 3; - - // The attack requires the attacker to physically touch or manipulate the - // vulnerable component. - ATTACK_VECTOR_PHYSICAL = 4; - } - - // This metric describes the conditions beyond the attacker's control that - // must exist in order to exploit the vulnerability. - enum AttackComplexity { - // Invalid value. - ATTACK_COMPLEXITY_UNSPECIFIED = 0; - - // Specialized access conditions or extenuating circumstances do not exist. - // An attacker can expect repeatable success when attacking the vulnerable - // component. - ATTACK_COMPLEXITY_LOW = 1; - - // A successful attack depends on conditions beyond the attacker's control. - // That is, a successful attack cannot be accomplished at will, but requires - // the attacker to invest in some measurable amount of effort in preparation - // or execution against the vulnerable component before a successful attack - // can be expected. - ATTACK_COMPLEXITY_HIGH = 2; - } - - // This metric describes the level of privileges an attacker must possess - // before successfully exploiting the vulnerability. - enum PrivilegesRequired { - // Invalid value. - PRIVILEGES_REQUIRED_UNSPECIFIED = 0; - - // The attacker is unauthorized prior to attack, and therefore does not - // require any access to settings or files of the vulnerable system to - // carry out an attack. - PRIVILEGES_REQUIRED_NONE = 1; - - // The attacker requires privileges that provide basic user capabilities - // that could normally affect only settings and files owned by a user. - // Alternatively, an attacker with Low privileges has the ability to access - // only non-sensitive resources. - PRIVILEGES_REQUIRED_LOW = 2; - - // The attacker requires privileges that provide significant (e.g., - // administrative) control over the vulnerable component allowing access to - // component-wide settings and files. - PRIVILEGES_REQUIRED_HIGH = 3; - } - - // This metric captures the requirement for a human user, other than the - // attacker, to participate in the successful compromise of the vulnerable - // component. - enum UserInteraction { - // Invalid value. - USER_INTERACTION_UNSPECIFIED = 0; - - // The vulnerable system can be exploited without interaction from any user. - USER_INTERACTION_NONE = 1; - - // Successful exploitation of this vulnerability requires a user to take - // some action before the vulnerability can be exploited. - USER_INTERACTION_REQUIRED = 2; - } - - // The Scope metric captures whether a vulnerability in one vulnerable - // component impacts resources in components beyond its security scope. - enum Scope { - // Invalid value. - SCOPE_UNSPECIFIED = 0; - - // An exploited vulnerability can only affect resources managed by the same - // security authority. - SCOPE_UNCHANGED = 1; - - // An exploited vulnerability can affect resources beyond the security scope - // managed by the security authority of the vulnerable component. - SCOPE_CHANGED = 2; - } - - // The Impact metrics capture the effects of a successfully exploited - // vulnerability on the component that suffers the worst outcome that is most - // directly and predictably associated with the attack. - enum Impact { - // Invalid value. - IMPACT_UNSPECIFIED = 0; - - // High impact. - IMPACT_HIGH = 1; - - // Low impact. - IMPACT_LOW = 2; - - // No impact. - IMPACT_NONE = 3; - } - - // The base score is a function of the base metric scores. - // https://www.first.org/cvss/specification-document#Base-Metrics - float base_score = 1; - - // The Exploitability sub-score equation is derived from the Base - // Exploitability metrics. - // https://www.first.org/cvss/specification-document#2-1-Exploitability-Metrics - float exploitability_score = 2; - - // The Impact sub-score equation is derived from the Base Impact metrics. - float impact_score = 3; - - // This metric reflects the context by which vulnerability exploitation is - // possible. - AttackVector attack_vector = 5; - - // This metric describes the conditions beyond the attacker's control that - // must exist in order to exploit the vulnerability. - AttackComplexity attack_complexity = 6; - - // This metric describes the level of privileges an attacker must possess - // before successfully exploiting the vulnerability. - PrivilegesRequired privileges_required = 7; - - // This metric captures the requirement for a human user, other than the - // attacker, to participate in the successful compromise of the vulnerable - // component. - UserInteraction user_interaction = 8; - - // The Scope metric captures whether a vulnerability in one vulnerable - // component impacts resources in components beyond its security scope. - Scope scope = 9; - - // This metric measures the impact to the confidentiality of the information - // resources managed by a software component due to a successfully exploited - // vulnerability. - Impact confidentiality_impact = 10; - - // This metric measures the impact to integrity of a successfully exploited - // vulnerability. - Impact integrity_impact = 11; - - // This metric measures the impact to the availability of the impacted - // component resulting from a successfully exploited vulnerability. - Impact availability_impact = 12; -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.create_o_s_policy_assignment.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.create_o_s_policy_assignment.js deleted file mode 100644 index 7646ded6809..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.create_o_s_policy_assignment.js +++ /dev/null @@ -1,79 +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, osPolicyAssignment, osPolicyAssignmentId) { - // [START osconfig_v1alpha_generated_OsConfigZonalService_CreateOSPolicyAssignment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 name in the form: - * projects/{project}/locations/{location} - */ - // const parent = 'abc123' - /** - * Required. The OS policy assignment to be created. - */ - // const osPolicyAssignment = {} - /** - * Required. The logical name of the OS policy assignment in the project - * with the following restrictions: - * * Must contain only lowercase letters, numbers, and hyphens. - * * Must start with a letter. - * * Must be between 1-63 characters. - * * Must end with a number or a letter. - * * Must be unique within the project. - */ - // const osPolicyAssignmentId = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callCreateOSPolicyAssignment() { - // Construct request - const request = { - parent, - osPolicyAssignment, - osPolicyAssignmentId, - }; - - // Run request - const [operation] = await osconfigClient.createOSPolicyAssignment(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateOSPolicyAssignment(); - // [END osconfig_v1alpha_generated_OsConfigZonalService_CreateOSPolicyAssignment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.delete_o_s_policy_assignment.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.delete_o_s_policy_assignment.js deleted file mode 100644 index 3b4e222de3b..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.delete_o_s_policy_assignment.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 osconfig_v1alpha_generated_OsConfigZonalService_DeleteOSPolicyAssignment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 OS policy assignment to be deleted - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callDeleteOSPolicyAssignment() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await osconfigClient.deleteOSPolicyAssignment(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteOSPolicyAssignment(); - // [END osconfig_v1alpha_generated_OsConfigZonalService_DeleteOSPolicyAssignment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_instance_o_s_policies_compliance.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_instance_o_s_policies_compliance.js deleted file mode 100644 index f12054ce1ca..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_instance_o_s_policies_compliance.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(name) { - // [START osconfig_v1alpha_generated_OsConfigZonalService_GetInstanceOSPoliciesCompliance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. API resource name for instance OS policies compliance resource. - * Format: - * `projects/{project}/locations/{location}/instanceOSPoliciesCompliances/{instance}` - * For `{project}`, either Compute Engine project-number or project-id can be - * provided. - * For `{instance}`, either Compute Engine VM instance-id or instance-name can - * be provided. - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callGetInstanceOSPoliciesCompliance() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.getInstanceOSPoliciesCompliance(request); - console.log(response); - } - - callGetInstanceOSPoliciesCompliance(); - // [END osconfig_v1alpha_generated_OsConfigZonalService_GetInstanceOSPoliciesCompliance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_inventory.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_inventory.js deleted file mode 100644 index 76184efb4e6..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_inventory.js +++ /dev/null @@ -1,71 +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 osconfig_v1alpha_generated_OsConfigZonalService_GetInventory_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. API resource name for inventory resource. - * Format: - * `projects/{project}/locations/{location}/instances/{instance}/inventory` - * For `{project}`, either `project-number` or `project-id` can be provided. - * For `{instance}`, either Compute Engine `instance-id` or `instance-name` - * can be provided. - */ - // const name = 'abc123' - /** - * Inventory view indicating what information should be included in the - * inventory resource. If unspecified, the default view is BASIC. - */ - // const view = {} - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callGetInventory() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.getInventory(request); - console.log(response); - } - - callGetInventory(); - // [END osconfig_v1alpha_generated_OsConfigZonalService_GetInventory_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_o_s_policy_assignment.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_o_s_policy_assignment.js deleted file mode 100644 index 47f7f786a0e..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_o_s_policy_assignment.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 osconfig_v1alpha_generated_OsConfigZonalService_GetOSPolicyAssignment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 OS policy assignment. - * Format: - * `projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}@{revisionId}` - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callGetOSPolicyAssignment() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.getOSPolicyAssignment(request); - console.log(response); - } - - callGetOSPolicyAssignment(); - // [END osconfig_v1alpha_generated_OsConfigZonalService_GetOSPolicyAssignment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_o_s_policy_assignment_report.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_o_s_policy_assignment_report.js deleted file mode 100644 index bce36f54492..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_o_s_policy_assignment_report.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(name) { - // [START osconfig_v1alpha_generated_OsConfigZonalService_GetOSPolicyAssignmentReport_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. API resource name for OS policy assignment report. - * Format: - * `/projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report` - * For `{project}`, either `project-number` or `project-id` can be provided. - * For `{instance_id}`, either Compute Engine `instance-id` or `instance-name` - * can be provided. - * For `{assignment_id}`, the OSPolicyAssignment id must be provided. - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callGetOSPolicyAssignmentReport() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.getOSPolicyAssignmentReport(request); - console.log(response); - } - - callGetOSPolicyAssignmentReport(); - // [END osconfig_v1alpha_generated_OsConfigZonalService_GetOSPolicyAssignmentReport_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_vulnerability_report.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_vulnerability_report.js deleted file mode 100644 index b1623dc2e95..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.get_vulnerability_report.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(name) { - // [START osconfig_v1alpha_generated_OsConfigZonalService_GetVulnerabilityReport_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. API resource name for vulnerability resource. - * Format: - * `projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport` - * For `{project}`, either `project-number` or `project-id` can be provided. - * For `{instance}`, either Compute Engine `instance-id` or `instance-name` - * can be provided. - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callGetVulnerabilityReport() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.getVulnerabilityReport(request); - console.log(response); - } - - callGetVulnerabilityReport(); - // [END osconfig_v1alpha_generated_OsConfigZonalService_GetVulnerabilityReport_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_instance_o_s_policies_compliances.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_instance_o_s_policies_compliances.js deleted file mode 100644 index 6e6dd476e87..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_instance_o_s_policies_compliances.js +++ /dev/null @@ -1,81 +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 osconfig_v1alpha_generated_OsConfigZonalService_ListInstanceOSPoliciesCompliances_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 name. - * Format: `projects/{project}/locations/{location}` - * For `{project}`, either Compute Engine project-number or project-id can be - * provided. - */ - // const parent = 'abc123' - /** - * The maximum number of results to return. - */ - // const pageSize = 1234 - /** - * A pagination token returned from a previous call to - * `ListInstanceOSPoliciesCompliances` that indicates where this listing - * should continue from. - */ - // const pageToken = 'abc123' - /** - * If provided, this field specifies the criteria that must be met by a - * `InstanceOSPoliciesCompliance` API resource to be included in the response. - */ - // const filter = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callListInstanceOSPoliciesCompliances() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await osconfigClient.listInstanceOSPoliciesCompliancesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListInstanceOSPoliciesCompliances(); - // [END osconfig_v1alpha_generated_OsConfigZonalService_ListInstanceOSPoliciesCompliances_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_inventories.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_inventories.js deleted file mode 100644 index f894670e4a2..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_inventories.js +++ /dev/null @@ -1,85 +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 osconfig_v1alpha_generated_OsConfigZonalService_ListInventories_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 name. - * Format: `projects/{project}/locations/{location}/instances/-` - * For `{project}`, either `project-number` or `project-id` can be provided. - */ - // const parent = 'abc123' - /** - * Inventory view indicating what information should be included in the - * inventory resource. If unspecified, the default view is BASIC. - */ - // const view = {} - /** - * The maximum number of results to return. - */ - // const pageSize = 1234 - /** - * A pagination token returned from a previous call to - * `ListInventories` that indicates where this listing - * should continue from. - */ - // const pageToken = 'abc123' - /** - * If provided, this field specifies the criteria that must be met by a - * `Inventory` API resource to be included in the response. - */ - // const filter = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callListInventories() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await osconfigClient.listInventoriesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListInventories(); - // [END osconfig_v1alpha_generated_OsConfigZonalService_ListInventories_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignment_reports.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignment_reports.js deleted file mode 100644 index f0554660729..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignment_reports.js +++ /dev/null @@ -1,95 +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 osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignmentReports_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 name. - * Format: - * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/reports` - * For `{project}`, either `project-number` or `project-id` can be provided. - * For `{instance}`, either `instance-name`, `instance-id`, or `-` can be - * provided. If '-' is provided, the response will include - * OSPolicyAssignmentReports for all instances in the project/location. - * For `{assignment}`, either `assignment-id` or `-` can be provided. If '-' - * is provided, the response will include OSPolicyAssignmentReports for all - * OSPolicyAssignments in the project/location. - * Either {instance} or {assignment} must be `-`. - * For example: - * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/-/reports` - * returns all reports for the instance - * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/{assignment-id}/reports` - * returns all the reports for the given assignment across all instances. - * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/-/reports` - * returns all the reports for all assignments across all instances. - */ - // const parent = 'abc123' - /** - * The maximum number of results to return. - */ - // const pageSize = 1234 - /** - * If provided, this field specifies the criteria that must be met by the - * `OSPolicyAssignmentReport` API resource that is included in the response. - */ - // const filter = 'abc123' - /** - * A pagination token returned from a previous call to the - * `ListOSPolicyAssignmentReports` method that indicates where this listing - * should continue from. - */ - // const pageToken = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callListOSPolicyAssignmentReports() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await osconfigClient.listOSPolicyAssignmentReportsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListOSPolicyAssignmentReports(); - // [END osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignmentReports_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignment_revisions.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignment_revisions.js deleted file mode 100644 index 74735c6c8db..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignment_revisions.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(name) { - // [START osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignmentRevisions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 OS policy assignment to list revisions for. - */ - // const name = 'abc123' - /** - * The maximum number of revisions to return. - */ - // const pageSize = 1234 - /** - * A pagination token returned from a previous call to - * `ListOSPolicyAssignmentRevisions` that indicates where this listing should - * continue from. - */ - // const pageToken = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callListOSPolicyAssignmentRevisions() { - // Construct request - const request = { - name, - }; - - // Run request - const iterable = await osconfigClient.listOSPolicyAssignmentRevisionsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListOSPolicyAssignmentRevisions(); - // [END osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignmentRevisions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignments.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignments.js deleted file mode 100644 index d5e7b75adf8..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignments.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(parent) { - // [START osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignments_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 name. - */ - // const parent = 'abc123' - /** - * The maximum number of assignments to return. - */ - // const pageSize = 1234 - /** - * A pagination token returned from a previous call to - * `ListOSPolicyAssignments` that indicates where this listing should continue - * from. - */ - // const pageToken = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callListOSPolicyAssignments() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await osconfigClient.listOSPolicyAssignmentsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListOSPolicyAssignments(); - // [END osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_vulnerability_reports.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_vulnerability_reports.js deleted file mode 100644 index a59010acbb5..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.list_vulnerability_reports.js +++ /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. ** - - - -'use strict'; - -function main(parent) { - // [START osconfig_v1alpha_generated_OsConfigZonalService_ListVulnerabilityReports_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 name. - * Format: `projects/{project}/locations/{location}/instances/-` - * For `{project}`, either `project-number` or `project-id` can be provided. - */ - // const parent = 'abc123' - /** - * The maximum number of results to return. - */ - // const pageSize = 1234 - /** - * A pagination token returned from a previous call to - * `ListVulnerabilityReports` that indicates where this listing - * should continue from. - */ - // const pageToken = 'abc123' - /** - * If provided, this field specifies the criteria that must be met by a - * `vulnerabilityReport` API resource to be included in the response. - */ - // const filter = 'abc123' - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callListVulnerabilityReports() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await osconfigClient.listVulnerabilityReportsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListVulnerabilityReports(); - // [END osconfig_v1alpha_generated_OsConfigZonalService_ListVulnerabilityReports_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.update_o_s_policy_assignment.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.update_o_s_policy_assignment.js deleted file mode 100644 index 0c54f433ccb..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/os_config_zonal_service.update_o_s_policy_assignment.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(osPolicyAssignment) { - // [START osconfig_v1alpha_generated_OsConfigZonalService_UpdateOSPolicyAssignment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The updated OS policy assignment. - */ - // const osPolicyAssignment = {} - /** - * Optional. Field mask that controls which fields of the assignment should be updated. - */ - // const updateMask = {} - - // Imports the Osconfig library - const {OsConfigZonalServiceClient} = require('@google-cloud/os-config').v1alpha; - - // Instantiates a client - const osconfigClient = new OsConfigZonalServiceClient(); - - async function callUpdateOSPolicyAssignment() { - // Construct request - const request = { - osPolicyAssignment, - }; - - // Run request - const [operation] = await osconfigClient.updateOSPolicyAssignment(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateOSPolicyAssignment(); - // [END osconfig_v1alpha_generated_OsConfigZonalService_UpdateOSPolicyAssignment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/snippet_metadata_google.cloud.osconfig.v1alpha.json b/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/snippet_metadata_google.cloud.osconfig.v1alpha.json deleted file mode 100644 index b0be93478a9..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/samples/generated/v1alpha/snippet_metadata_google.cloud.osconfig.v1alpha.json +++ /dev/null @@ -1,659 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-osconfig", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.osconfig.v1alpha", - "version": "v1alpha" - } - ] - }, - "snippets": [ - { - "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_CreateOSPolicyAssignment_async", - "title": "OsConfigZonalService createOSPolicyAssignment Sample", - "origin": "API_DEFINITION", - "description": " Create an OS policy assignment. This method also creates the first revision of the OS policy assignment. This method returns a long running operation (LRO) that contains the rollout details. The rollout can be cancelled by cancelling the LRO. For more information, see [Method: projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1alpha/projects.locations.osPolicyAssignments.operations/cancel).", - "canonical": true, - "file": "os_config_zonal_service.create_o_s_policy_assignment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateOSPolicyAssignment", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.CreateOSPolicyAssignment", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "os_policy_assignment", - "type": ".google.cloud.osconfig.v1alpha.OSPolicyAssignment" - }, - { - "name": "os_policy_assignment_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "CreateOSPolicyAssignment", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.CreateOSPolicyAssignment", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_UpdateOSPolicyAssignment_async", - "title": "OsConfigZonalService updateOSPolicyAssignment Sample", - "origin": "API_DEFINITION", - "description": " Update an existing OS policy assignment. This method creates a new revision of the OS policy assignment. This method returns a long running operation (LRO) that contains the rollout details. The rollout can be cancelled by cancelling the LRO. For more information, see [Method: projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1alpha/projects.locations.osPolicyAssignments.operations/cancel).", - "canonical": true, - "file": "os_config_zonal_service.update_o_s_policy_assignment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateOSPolicyAssignment", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.UpdateOSPolicyAssignment", - "async": true, - "parameters": [ - { - "name": "os_policy_assignment", - "type": ".google.cloud.osconfig.v1alpha.OSPolicyAssignment" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "UpdateOSPolicyAssignment", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.UpdateOSPolicyAssignment", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_GetOSPolicyAssignment_async", - "title": "OsConfigZonalService getOSPolicyAssignment Sample", - "origin": "API_DEFINITION", - "description": " Retrieve an existing OS policy assignment. This method always returns the latest revision. In order to retrieve a previous revision of the assignment, also provide the revision ID in the `name` parameter.", - "canonical": true, - "file": "os_config_zonal_service.get_o_s_policy_assignment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetOSPolicyAssignment", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.GetOSPolicyAssignment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1alpha.OSPolicyAssignment", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "GetOSPolicyAssignment", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.GetOSPolicyAssignment", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignments_async", - "title": "OsConfigZonalService listOSPolicyAssignments Sample", - "origin": "API_DEFINITION", - "description": " List the OS policy assignments under the parent resource. For each OS policy assignment, the latest revision is returned.", - "canonical": true, - "file": "os_config_zonal_service.list_o_s_policy_assignments.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListOSPolicyAssignments", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListOSPolicyAssignments", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsResponse", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "ListOSPolicyAssignments", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListOSPolicyAssignments", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignmentRevisions_async", - "title": "OsConfigZonalService listOSPolicyAssignmentRevisions Sample", - "origin": "API_DEFINITION", - "description": " List the OS policy assignment revisions for a given OS policy assignment.", - "canonical": true, - "file": "os_config_zonal_service.list_o_s_policy_assignment_revisions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListOSPolicyAssignmentRevisions", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListOSPolicyAssignmentRevisions", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsResponse", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "ListOSPolicyAssignmentRevisions", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListOSPolicyAssignmentRevisions", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_DeleteOSPolicyAssignment_async", - "title": "OsConfigZonalService deleteOSPolicyAssignment Sample", - "origin": "API_DEFINITION", - "description": " Delete the OS policy assignment. This method creates a new revision of the OS policy assignment. This method returns a long running operation (LRO) that contains the rollout details. The rollout can be cancelled by cancelling the LRO. If the LRO completes and is not cancelled, all revisions associated with the OS policy assignment are deleted. For more information, see [Method: projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1alpha/projects.locations.osPolicyAssignments.operations/cancel).", - "canonical": true, - "file": "os_config_zonal_service.delete_o_s_policy_assignment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteOSPolicyAssignment", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.DeleteOSPolicyAssignment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "DeleteOSPolicyAssignment", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.DeleteOSPolicyAssignment", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_GetInstanceOSPoliciesCompliance_async", - "title": "OsConfigZonalService getInstanceOSPoliciesCompliance Sample", - "origin": "API_DEFINITION", - "description": " Get OS policies compliance data for the specified Compute Engine VM instance.", - "canonical": true, - "file": "os_config_zonal_service.get_instance_o_s_policies_compliance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetInstanceOSPoliciesCompliance", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.GetInstanceOSPoliciesCompliance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "GetInstanceOSPoliciesCompliance", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.GetInstanceOSPoliciesCompliance", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_ListInstanceOSPoliciesCompliances_async", - "title": "OsConfigZonalService listInstanceOSPoliciesCompliances Sample", - "origin": "API_DEFINITION", - "description": " List OS policies compliance data for all Compute Engine VM instances in the specified zone.", - "canonical": true, - "file": "os_config_zonal_service.list_instance_o_s_policies_compliances.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 73, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListInstanceOSPoliciesCompliances", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListInstanceOSPoliciesCompliances", - "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.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesResponse", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "ListInstanceOSPoliciesCompliances", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListInstanceOSPoliciesCompliances", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_GetOSPolicyAssignmentReport_async", - "title": "OsConfigZonalService getOSPolicyAssignmentReport Sample", - "origin": "API_DEFINITION", - "description": " Get the OS policy asssignment report for the specified Compute Engine VM instance.", - "canonical": true, - "file": "os_config_zonal_service.get_o_s_policy_assignment_report.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetOSPolicyAssignmentReport", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.GetOSPolicyAssignmentReport", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "GetOSPolicyAssignmentReport", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.GetOSPolicyAssignmentReport", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignmentReports_async", - "title": "OsConfigZonalService listOSPolicyAssignmentReports Sample", - "origin": "API_DEFINITION", - "description": " List OS policy asssignment reports for all Compute Engine VM instances in the specified zone.", - "canonical": true, - "file": "os_config_zonal_service.list_o_s_policy_assignment_reports.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 87, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListOSPolicyAssignmentReports", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListOSPolicyAssignmentReports", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsResponse", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "ListOSPolicyAssignmentReports", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListOSPolicyAssignmentReports", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_GetInventory_async", - "title": "OsConfigZonalService getInventory Sample", - "origin": "API_DEFINITION", - "description": " Get inventory data for the specified VM instance. If the VM has no associated inventory, the message `NOT_FOUND` is returned.", - "canonical": true, - "file": "os_config_zonal_service.get_inventory.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetInventory", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.GetInventory", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "view", - "type": ".google.cloud.osconfig.v1alpha.InventoryView" - } - ], - "resultType": ".google.cloud.osconfig.v1alpha.Inventory", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "GetInventory", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.GetInventory", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_ListInventories_async", - "title": "OsConfigZonalService listInventories Sample", - "origin": "API_DEFINITION", - "description": " List inventory data for all VM instances in the specified zone.", - "canonical": true, - "file": "os_config_zonal_service.list_inventories.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 77, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListInventories", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListInventories", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "view", - "type": ".google.cloud.osconfig.v1alpha.InventoryView" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1alpha.ListInventoriesResponse", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "ListInventories", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListInventories", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_GetVulnerabilityReport_async", - "title": "OsConfigZonalService getVulnerabilityReport Sample", - "origin": "API_DEFINITION", - "description": " Gets the vulnerability report for the specified VM instance. Only VMs with inventory data have vulnerability reports associated with them.", - "canonical": true, - "file": "os_config_zonal_service.get_vulnerability_report.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetVulnerabilityReport", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.GetVulnerabilityReport", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1alpha.VulnerabilityReport", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "GetVulnerabilityReport", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.GetVulnerabilityReport", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" - } - } - } - }, - { - "regionTag": "osconfig_v1alpha_generated_OsConfigZonalService_ListVulnerabilityReports_async", - "title": "OsConfigZonalService listVulnerabilityReports Sample", - "origin": "API_DEFINITION", - "description": " List vulnerability reports for all VM instances in the specified zone.", - "canonical": true, - "file": "os_config_zonal_service.list_vulnerability_reports.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListVulnerabilityReports", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListVulnerabilityReports", - "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.osconfig.v1alpha.ListVulnerabilityReportsResponse", - "client": { - "shortName": "OsConfigZonalServiceClient", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient" - }, - "method": { - "shortName": "ListVulnerabilityReports", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService.ListVulnerabilityReports", - "service": { - "shortName": "OsConfigZonalService", - "fullName": "google.cloud.osconfig.v1alpha.OsConfigZonalService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/src/index.ts b/owl-bot-staging/google-cloud-osconfig/v1alpha/src/index.ts deleted file mode 100644 index 92937ca2d3c..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/src/index.ts +++ /dev/null @@ -1,25 +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 v1alpha from './v1alpha'; -const OsConfigZonalServiceClient = v1alpha.OsConfigZonalServiceClient; -type OsConfigZonalServiceClient = v1alpha.OsConfigZonalServiceClient; -export {v1alpha, OsConfigZonalServiceClient}; -export default {v1alpha, OsConfigZonalServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/gapic_metadata.json b/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/gapic_metadata.json deleted file mode 100644 index 014b66375b8..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/gapic_metadata.json +++ /dev/null @@ -1,187 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.osconfig.v1alpha", - "libraryPackage": "@google-cloud/os-config", - "services": { - "OsConfigZonalService": { - "clients": { - "grpc": { - "libraryClient": "OsConfigZonalServiceClient", - "rpcs": { - "GetOSPolicyAssignment": { - "methods": [ - "getOSPolicyAssignment" - ] - }, - "GetInstanceOSPoliciesCompliance": { - "methods": [ - "getInstanceOSPoliciesCompliance" - ] - }, - "GetOSPolicyAssignmentReport": { - "methods": [ - "getOSPolicyAssignmentReport" - ] - }, - "GetInventory": { - "methods": [ - "getInventory" - ] - }, - "GetVulnerabilityReport": { - "methods": [ - "getVulnerabilityReport" - ] - }, - "CreateOSPolicyAssignment": { - "methods": [ - "createOSPolicyAssignment" - ] - }, - "UpdateOSPolicyAssignment": { - "methods": [ - "updateOSPolicyAssignment" - ] - }, - "DeleteOSPolicyAssignment": { - "methods": [ - "deleteOSPolicyAssignment" - ] - }, - "ListOSPolicyAssignments": { - "methods": [ - "listOSPolicyAssignments", - "listOSPolicyAssignmentsStream", - "listOSPolicyAssignmentsAsync" - ] - }, - "ListOSPolicyAssignmentRevisions": { - "methods": [ - "listOSPolicyAssignmentRevisions", - "listOSPolicyAssignmentRevisionsStream", - "listOSPolicyAssignmentRevisionsAsync" - ] - }, - "ListInstanceOSPoliciesCompliances": { - "methods": [ - "listInstanceOSPoliciesCompliances", - "listInstanceOSPoliciesCompliancesStream", - "listInstanceOSPoliciesCompliancesAsync" - ] - }, - "ListOSPolicyAssignmentReports": { - "methods": [ - "listOSPolicyAssignmentReports", - "listOSPolicyAssignmentReportsStream", - "listOSPolicyAssignmentReportsAsync" - ] - }, - "ListInventories": { - "methods": [ - "listInventories", - "listInventoriesStream", - "listInventoriesAsync" - ] - }, - "ListVulnerabilityReports": { - "methods": [ - "listVulnerabilityReports", - "listVulnerabilityReportsStream", - "listVulnerabilityReportsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "OsConfigZonalServiceClient", - "rpcs": { - "GetOSPolicyAssignment": { - "methods": [ - "getOSPolicyAssignment" - ] - }, - "GetInstanceOSPoliciesCompliance": { - "methods": [ - "getInstanceOSPoliciesCompliance" - ] - }, - "GetOSPolicyAssignmentReport": { - "methods": [ - "getOSPolicyAssignmentReport" - ] - }, - "GetInventory": { - "methods": [ - "getInventory" - ] - }, - "GetVulnerabilityReport": { - "methods": [ - "getVulnerabilityReport" - ] - }, - "CreateOSPolicyAssignment": { - "methods": [ - "createOSPolicyAssignment" - ] - }, - "UpdateOSPolicyAssignment": { - "methods": [ - "updateOSPolicyAssignment" - ] - }, - "DeleteOSPolicyAssignment": { - "methods": [ - "deleteOSPolicyAssignment" - ] - }, - "ListOSPolicyAssignments": { - "methods": [ - "listOSPolicyAssignments", - "listOSPolicyAssignmentsStream", - "listOSPolicyAssignmentsAsync" - ] - }, - "ListOSPolicyAssignmentRevisions": { - "methods": [ - "listOSPolicyAssignmentRevisions", - "listOSPolicyAssignmentRevisionsStream", - "listOSPolicyAssignmentRevisionsAsync" - ] - }, - "ListInstanceOSPoliciesCompliances": { - "methods": [ - "listInstanceOSPoliciesCompliances", - "listInstanceOSPoliciesCompliancesStream", - "listInstanceOSPoliciesCompliancesAsync" - ] - }, - "ListOSPolicyAssignmentReports": { - "methods": [ - "listOSPolicyAssignmentReports", - "listOSPolicyAssignmentReportsStream", - "listOSPolicyAssignmentReportsAsync" - ] - }, - "ListInventories": { - "methods": [ - "listInventories", - "listInventoriesStream", - "listInventoriesAsync" - ] - }, - "ListVulnerabilityReports": { - "methods": [ - "listVulnerabilityReports", - "listVulnerabilityReportsStream", - "listVulnerabilityReportsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/index.ts b/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/index.ts deleted file mode 100644 index 953da1ab403..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/index.ts +++ /dev/null @@ -1,19 +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 {OsConfigZonalServiceClient} from './os_config_zonal_service_client'; diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_client.ts b/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_client.ts deleted file mode 100644 index 3e9c71c4260..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_client.ts +++ /dev/null @@ -1,2569 +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} 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/v1alpha/os_config_zonal_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './os_config_zonal_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Zonal OS Config API - * - * The OS Config service is the server-side component that allows users to - * manage package installations and patch jobs for Compute Engine VM instances. - * @class - * @memberof v1alpha - */ -export class OsConfigZonalServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - osConfigZonalServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of OsConfigZonalServiceClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 OsConfigZonalServiceClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof OsConfigZonalServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - instanceOSPoliciesCompliancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instanceOSPoliciesCompliances/{instance}' - ), - inventoryPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}/inventory' - ), - oSPolicyAssignmentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}' - ), - oSPolicyAssignmentReportPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report' - ), - vulnerabilityReportPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport' - ), - }; - - // 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 = { - listOSPolicyAssignments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'osPolicyAssignments'), - listOSPolicyAssignmentRevisions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'osPolicyAssignments'), - listInstanceOSPoliciesCompliances: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instanceOsPoliciesCompliances'), - listOSPolicyAssignmentReports: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'osPolicyAssignmentReports'), - listInventories: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'inventories'), - listVulnerabilityReports: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'vulnerabilityReports') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1alpha/{name=projects/*/locations/*/osPolicyAssignments/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1alpha/{name=projects/*/locations/*/osPolicyAssignments/*/operations/*}',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createOSPolicyAssignmentResponse = protoFilesRoot.lookup( - '.google.cloud.osconfig.v1alpha.OSPolicyAssignment') as gax.protobuf.Type; - const createOSPolicyAssignmentMetadata = protoFilesRoot.lookup( - '.google.cloud.osconfig.v1alpha.OSPolicyAssignmentOperationMetadata') as gax.protobuf.Type; - const updateOSPolicyAssignmentResponse = protoFilesRoot.lookup( - '.google.cloud.osconfig.v1alpha.OSPolicyAssignment') as gax.protobuf.Type; - const updateOSPolicyAssignmentMetadata = protoFilesRoot.lookup( - '.google.cloud.osconfig.v1alpha.OSPolicyAssignmentOperationMetadata') as gax.protobuf.Type; - const deleteOSPolicyAssignmentResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteOSPolicyAssignmentMetadata = protoFilesRoot.lookup( - '.google.cloud.osconfig.v1alpha.OSPolicyAssignmentOperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createOSPolicyAssignment: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createOSPolicyAssignmentResponse.decode.bind(createOSPolicyAssignmentResponse), - createOSPolicyAssignmentMetadata.decode.bind(createOSPolicyAssignmentMetadata)), - updateOSPolicyAssignment: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateOSPolicyAssignmentResponse.decode.bind(updateOSPolicyAssignmentResponse), - updateOSPolicyAssignmentMetadata.decode.bind(updateOSPolicyAssignmentMetadata)), - deleteOSPolicyAssignment: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteOSPolicyAssignmentResponse.decode.bind(deleteOSPolicyAssignmentResponse), - deleteOSPolicyAssignmentMetadata.decode.bind(deleteOSPolicyAssignmentMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.osconfig.v1alpha.OsConfigZonalService', 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.osConfigZonalServiceStub) { - return this.osConfigZonalServiceStub; - } - - // Put together the "service stub" for - // google.cloud.osconfig.v1alpha.OsConfigZonalService. - this.osConfigZonalServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.osconfig.v1alpha.OsConfigZonalService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.osconfig.v1alpha.OsConfigZonalService, - 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 osConfigZonalServiceStubMethods = - ['createOsPolicyAssignment', 'updateOsPolicyAssignment', 'getOsPolicyAssignment', 'listOsPolicyAssignments', 'listOsPolicyAssignmentRevisions', 'deleteOsPolicyAssignment', 'getInstanceOsPoliciesCompliance', 'listInstanceOsPoliciesCompliances', 'getOsPolicyAssignmentReport', 'listOsPolicyAssignmentReports', 'getInventory', 'listInventories', 'getVulnerabilityReport', 'listVulnerabilityReports']; - for (const methodName of osConfigZonalServiceStubMethods) { - const callPromise = this.osConfigZonalServiceStub.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.osConfigZonalServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'osconfig.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 'osconfig.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 -- - // ------------------- -/** - * Retrieve an existing OS policy assignment. - * - * This method always returns the latest revision. In order to retrieve a - * previous revision of the assignment, also provide the revision ID in the - * `name` parameter. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of OS policy assignment. - * - * Format: - * `projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}@{revisionId}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment|OSPolicyAssignment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/os_config_zonal_service.get_o_s_policy_assignment.js - * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_GetOSPolicyAssignment_async - */ - getOSPolicyAssignment( - request?: protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment, - protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentRequest|undefined, {}|undefined - ]>; - getOSPolicyAssignment( - request: protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment, - protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentRequest|null|undefined, - {}|null|undefined>): void; - getOSPolicyAssignment( - request: protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentRequest, - callback: Callback< - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment, - protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentRequest|null|undefined, - {}|null|undefined>): void; - getOSPolicyAssignment( - request?: protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment, - protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment, - protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment, - protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getOsPolicyAssignment(request, options, callback); - } -/** - * Get OS policies compliance data for the specified Compute Engine VM - * instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. API resource name for instance OS policies compliance resource. - * - * Format: - * `projects/{project}/locations/{location}/instanceOSPoliciesCompliances/{instance}` - * - * For `{project}`, either Compute Engine project-number or project-id can be - * provided. - * For `{instance}`, either Compute Engine VM instance-id or instance-name can - * be provided. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance|InstanceOSPoliciesCompliance}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/os_config_zonal_service.get_instance_o_s_policies_compliance.js - * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_GetInstanceOSPoliciesCompliance_async - * @deprecated GetInstanceOSPoliciesCompliance is deprecated and may be removed in a future version. - */ - getInstanceOSPoliciesCompliance( - request?: protos.google.cloud.osconfig.v1alpha.IGetInstanceOSPoliciesComplianceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance, - protos.google.cloud.osconfig.v1alpha.IGetInstanceOSPoliciesComplianceRequest|undefined, {}|undefined - ]>; - getInstanceOSPoliciesCompliance( - request: protos.google.cloud.osconfig.v1alpha.IGetInstanceOSPoliciesComplianceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance, - protos.google.cloud.osconfig.v1alpha.IGetInstanceOSPoliciesComplianceRequest|null|undefined, - {}|null|undefined>): void; - getInstanceOSPoliciesCompliance( - request: protos.google.cloud.osconfig.v1alpha.IGetInstanceOSPoliciesComplianceRequest, - callback: Callback< - protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance, - protos.google.cloud.osconfig.v1alpha.IGetInstanceOSPoliciesComplianceRequest|null|undefined, - {}|null|undefined>): void; - getInstanceOSPoliciesCompliance( - request?: protos.google.cloud.osconfig.v1alpha.IGetInstanceOSPoliciesComplianceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance, - protos.google.cloud.osconfig.v1alpha.IGetInstanceOSPoliciesComplianceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance, - protos.google.cloud.osconfig.v1alpha.IGetInstanceOSPoliciesComplianceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance, - protos.google.cloud.osconfig.v1alpha.IGetInstanceOSPoliciesComplianceRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - this.warn('DEP$OsConfigZonalService-$GetInstanceOSPoliciesCompliance','GetInstanceOSPoliciesCompliance is deprecated and may be removed in a future version.', 'DeprecationWarning'); - return this.innerApiCalls.getInstanceOsPoliciesCompliance(request, options, callback); - } -/** - * Get the OS policy asssignment report for the specified Compute Engine VM - * instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. API resource name for OS policy assignment report. - * - * Format: - * `/projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * For `{instance_id}`, either Compute Engine `instance-id` or `instance-name` - * can be provided. - * For `{assignment_id}`, the OSPolicyAssignment id must be provided. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport|OSPolicyAssignmentReport}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/os_config_zonal_service.get_o_s_policy_assignment_report.js - * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_GetOSPolicyAssignmentReport_async - */ - getOSPolicyAssignmentReport( - request?: protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentReportRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport, - protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentReportRequest|undefined, {}|undefined - ]>; - getOSPolicyAssignmentReport( - request: protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentReportRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport, - protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentReportRequest|null|undefined, - {}|null|undefined>): void; - getOSPolicyAssignmentReport( - request: protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentReportRequest, - callback: Callback< - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport, - protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentReportRequest|null|undefined, - {}|null|undefined>): void; - getOSPolicyAssignmentReport( - request?: protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentReportRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport, - protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentReportRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport, - protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentReportRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport, - protos.google.cloud.osconfig.v1alpha.IGetOSPolicyAssignmentReportRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getOsPolicyAssignmentReport(request, options, callback); - } -/** - * Get inventory data for the specified VM instance. If the VM has no - * associated inventory, the message `NOT_FOUND` is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. API resource name for inventory resource. - * - * Format: - * `projects/{project}/locations/{location}/instances/{instance}/inventory` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * For `{instance}`, either Compute Engine `instance-id` or `instance-name` - * can be provided. - * @param {google.cloud.osconfig.v1alpha.InventoryView} request.view - * Inventory view indicating what information should be included in the - * inventory resource. If unspecified, the default view is BASIC. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1alpha.Inventory|Inventory}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/os_config_zonal_service.get_inventory.js - * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_GetInventory_async - */ - getInventory( - request?: protos.google.cloud.osconfig.v1alpha.IGetInventoryRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IInventory, - protos.google.cloud.osconfig.v1alpha.IGetInventoryRequest|undefined, {}|undefined - ]>; - getInventory( - request: protos.google.cloud.osconfig.v1alpha.IGetInventoryRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1alpha.IInventory, - protos.google.cloud.osconfig.v1alpha.IGetInventoryRequest|null|undefined, - {}|null|undefined>): void; - getInventory( - request: protos.google.cloud.osconfig.v1alpha.IGetInventoryRequest, - callback: Callback< - protos.google.cloud.osconfig.v1alpha.IInventory, - protos.google.cloud.osconfig.v1alpha.IGetInventoryRequest|null|undefined, - {}|null|undefined>): void; - getInventory( - request?: protos.google.cloud.osconfig.v1alpha.IGetInventoryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1alpha.IInventory, - protos.google.cloud.osconfig.v1alpha.IGetInventoryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1alpha.IInventory, - protos.google.cloud.osconfig.v1alpha.IGetInventoryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IInventory, - protos.google.cloud.osconfig.v1alpha.IGetInventoryRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getInventory(request, options, callback); - } -/** - * Gets the vulnerability report for the specified VM instance. Only VMs with - * inventory data have vulnerability reports associated with them. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. API resource name for vulnerability resource. - * - * Format: - * `projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * For `{instance}`, either Compute Engine `instance-id` or `instance-name` - * can be provided. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1alpha.VulnerabilityReport|VulnerabilityReport}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/os_config_zonal_service.get_vulnerability_report.js - * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_GetVulnerabilityReport_async - */ - getVulnerabilityReport( - request?: protos.google.cloud.osconfig.v1alpha.IGetVulnerabilityReportRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport, - protos.google.cloud.osconfig.v1alpha.IGetVulnerabilityReportRequest|undefined, {}|undefined - ]>; - getVulnerabilityReport( - request: protos.google.cloud.osconfig.v1alpha.IGetVulnerabilityReportRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport, - protos.google.cloud.osconfig.v1alpha.IGetVulnerabilityReportRequest|null|undefined, - {}|null|undefined>): void; - getVulnerabilityReport( - request: protos.google.cloud.osconfig.v1alpha.IGetVulnerabilityReportRequest, - callback: Callback< - protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport, - protos.google.cloud.osconfig.v1alpha.IGetVulnerabilityReportRequest|null|undefined, - {}|null|undefined>): void; - getVulnerabilityReport( - request?: protos.google.cloud.osconfig.v1alpha.IGetVulnerabilityReportRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport, - protos.google.cloud.osconfig.v1alpha.IGetVulnerabilityReportRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport, - protos.google.cloud.osconfig.v1alpha.IGetVulnerabilityReportRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport, - protos.google.cloud.osconfig.v1alpha.IGetVulnerabilityReportRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getVulnerabilityReport(request, options, callback); - } - -/** - * Create an OS policy assignment. - * - * This method also creates the first revision of the OS policy assignment. - * - * This method returns a long running operation (LRO) that contains the - * rollout details. The rollout can be cancelled by cancelling the LRO. - * - * For more information, see [Method: - * projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1alpha/projects.locations.osPolicyAssignments.operations/cancel). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name in the form: - * projects/{project}/locations/{location} - * @param {google.cloud.osconfig.v1alpha.OSPolicyAssignment} request.osPolicyAssignment - * Required. The OS policy assignment to be created. - * @param {string} request.osPolicyAssignmentId - * Required. The logical name of the OS policy assignment in the project - * with the following restrictions: - * - * * Must contain only lowercase letters, numbers, and hyphens. - * * Must start with a letter. - * * Must be between 1-63 characters. - * * Must end with a number or a letter. - * * Must be unique within the project. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/os_config_zonal_service.create_o_s_policy_assignment.js - * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_CreateOSPolicyAssignment_async - */ - createOSPolicyAssignment( - request?: protos.google.cloud.osconfig.v1alpha.ICreateOSPolicyAssignmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createOSPolicyAssignment( - request: protos.google.cloud.osconfig.v1alpha.ICreateOSPolicyAssignmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createOSPolicyAssignment( - request: protos.google.cloud.osconfig.v1alpha.ICreateOSPolicyAssignmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createOSPolicyAssignment( - request?: protos.google.cloud.osconfig.v1alpha.ICreateOSPolicyAssignmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createOsPolicyAssignment(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createOSPolicyAssignment()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/os_config_zonal_service.create_o_s_policy_assignment.js - * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_CreateOSPolicyAssignment_async - */ - async checkCreateOSPolicyAssignmentProgress(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.createOSPolicyAssignment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Update an existing OS policy assignment. - * - * This method creates a new revision of the OS policy assignment. - * - * This method returns a long running operation (LRO) that contains the - * rollout details. The rollout can be cancelled by cancelling the LRO. - * - * For more information, see [Method: - * projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1alpha/projects.locations.osPolicyAssignments.operations/cancel). - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.osconfig.v1alpha.OSPolicyAssignment} request.osPolicyAssignment - * Required. The updated OS policy assignment. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask that controls which fields of the assignment should be 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/os_config_zonal_service.update_o_s_policy_assignment.js - * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_UpdateOSPolicyAssignment_async - */ - updateOSPolicyAssignment( - request?: protos.google.cloud.osconfig.v1alpha.IUpdateOSPolicyAssignmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateOSPolicyAssignment( - request: protos.google.cloud.osconfig.v1alpha.IUpdateOSPolicyAssignmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateOSPolicyAssignment( - request: protos.google.cloud.osconfig.v1alpha.IUpdateOSPolicyAssignmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateOSPolicyAssignment( - request?: protos.google.cloud.osconfig.v1alpha.IUpdateOSPolicyAssignmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'os_policy_assignment.name': request.osPolicyAssignment!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateOsPolicyAssignment(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateOSPolicyAssignment()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/os_config_zonal_service.update_o_s_policy_assignment.js - * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_UpdateOSPolicyAssignment_async - */ - async checkUpdateOSPolicyAssignmentProgress(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.updateOSPolicyAssignment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Delete the OS policy assignment. - * - * This method creates a new revision of the OS policy assignment. - * - * This method returns a long running operation (LRO) that contains the - * rollout details. The rollout can be cancelled by cancelling the LRO. - * - * If the LRO completes and is not cancelled, all revisions associated with - * the OS policy assignment are deleted. - * - * For more information, see [Method: - * projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1alpha/projects.locations.osPolicyAssignments.operations/cancel). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the OS policy assignment to be deleted - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/os_config_zonal_service.delete_o_s_policy_assignment.js - * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_DeleteOSPolicyAssignment_async - */ - deleteOSPolicyAssignment( - request?: protos.google.cloud.osconfig.v1alpha.IDeleteOSPolicyAssignmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteOSPolicyAssignment( - request: protos.google.cloud.osconfig.v1alpha.IDeleteOSPolicyAssignmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteOSPolicyAssignment( - request: protos.google.cloud.osconfig.v1alpha.IDeleteOSPolicyAssignmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteOSPolicyAssignment( - request?: protos.google.cloud.osconfig.v1alpha.IDeleteOSPolicyAssignmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteOsPolicyAssignment(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteOSPolicyAssignment()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/os_config_zonal_service.delete_o_s_policy_assignment.js - * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_DeleteOSPolicyAssignment_async - */ - async checkDeleteOSPolicyAssignmentProgress(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.deleteOSPolicyAssignment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * List the OS policy assignments under the parent resource. - * - * For each OS policy assignment, the latest revision is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {number} request.pageSize - * The maximum number of assignments to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListOSPolicyAssignments` that indicates where this listing should continue - * from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment|OSPolicyAssignment}. - * 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 `listOSPolicyAssignmentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listOSPolicyAssignments( - request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment[], - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest|null, - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsResponse - ]>; - listOSPolicyAssignments( - request: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest, - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment>): void; - listOSPolicyAssignments( - request: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest, - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment>): void; - listOSPolicyAssignments( - request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest, - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment>, - callback?: PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest, - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment>): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment[], - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest|null, - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listOsPolicyAssignments(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 resource name. - * @param {number} request.pageSize - * The maximum number of assignments to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListOSPolicyAssignments` that indicates where this listing should continue - * from. - * @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 protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment|OSPolicyAssignment} 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 `listOSPolicyAssignmentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listOSPolicyAssignmentsStream( - request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest, - 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['listOsPolicyAssignments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listOSPolicyAssignments.createStream( - this.innerApiCalls.listOsPolicyAssignments as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listOSPolicyAssignments`, 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 resource name. - * @param {number} request.pageSize - * The maximum number of assignments to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListOSPolicyAssignments` that indicates where this listing should continue - * from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment|OSPolicyAssignment}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignments.js - * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignments_async - */ - listOSPolicyAssignmentsAsync( - request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentsRequest, - 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['listOsPolicyAssignments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listOSPolicyAssignments.asyncIterate( - this.innerApiCalls['listOsPolicyAssignments'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * List the OS policy assignment revisions for a given OS policy assignment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the OS policy assignment to list revisions for. - * @param {number} request.pageSize - * The maximum number of revisions to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListOSPolicyAssignmentRevisions` that indicates where this listing should - * continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment|OSPolicyAssignment}. - * 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 `listOSPolicyAssignmentRevisionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listOSPolicyAssignmentRevisions( - request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment[], - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest|null, - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsResponse - ]>; - listOSPolicyAssignmentRevisions( - request: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest, - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment>): void; - listOSPolicyAssignmentRevisions( - request: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest, - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment>): void; - listOSPolicyAssignmentRevisions( - request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest, - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment>, - callback?: PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest, - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment>): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment[], - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest|null, - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.listOsPolicyAssignmentRevisions(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the OS policy assignment to list revisions for. - * @param {number} request.pageSize - * The maximum number of revisions to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListOSPolicyAssignmentRevisions` that indicates where this listing should - * continue from. - * @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 protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment|OSPolicyAssignment} 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 `listOSPolicyAssignmentRevisionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listOSPolicyAssignmentRevisionsStream( - request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - const defaultCallSettings = this._defaults['listOsPolicyAssignmentRevisions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listOSPolicyAssignmentRevisions.createStream( - this.innerApiCalls.listOsPolicyAssignmentRevisions as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listOSPolicyAssignmentRevisions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the OS policy assignment to list revisions for. - * @param {number} request.pageSize - * The maximum number of revisions to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListOSPolicyAssignmentRevisions` that indicates where this listing should - * continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment|OSPolicyAssignment}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignment_revisions.js - * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignmentRevisions_async - */ - listOSPolicyAssignmentRevisionsAsync( - request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentRevisionsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - const defaultCallSettings = this._defaults['listOsPolicyAssignmentRevisions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate( - this.innerApiCalls['listOsPolicyAssignmentRevisions'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * List OS policies compliance data for all Compute Engine VM instances in the - * specified zone. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * - * Format: `projects/{project}/locations/{location}` - * - * For `{project}`, either Compute Engine project-number or project-id can be - * provided. - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListInstanceOSPoliciesCompliances` that indicates where this listing - * should continue from. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by a - * `InstanceOSPoliciesCompliance` API resource to be included in the response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance|InstanceOSPoliciesCompliance}. - * 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 `listInstanceOSPoliciesCompliancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @deprecated ListInstanceOSPoliciesCompliances is deprecated and may be removed in a future version. - */ - listInstanceOSPoliciesCompliances( - request?: protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance[], - protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest|null, - protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesResponse - ]>; - listInstanceOSPoliciesCompliances( - request: protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest, - protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance>): void; - listInstanceOSPoliciesCompliances( - request: protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest, - protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance>): void; - listInstanceOSPoliciesCompliances( - request?: protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest, - protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance>, - callback?: PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest, - protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance>): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance[], - protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest|null, - protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - this.warn('DEP$OsConfigZonalService-$ListInstanceOSPoliciesCompliances','ListInstanceOSPoliciesCompliances is deprecated and may be removed in a future version.', 'DeprecationWarning'); - return this.innerApiCalls.listInstanceOsPoliciesCompliances(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 resource name. - * - * Format: `projects/{project}/locations/{location}` - * - * For `{project}`, either Compute Engine project-number or project-id can be - * provided. - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListInstanceOSPoliciesCompliances` that indicates where this listing - * should continue from. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by a - * `InstanceOSPoliciesCompliance` API resource to be included in the response. - * @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 protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance|InstanceOSPoliciesCompliance} 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 `listInstanceOSPoliciesCompliancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @deprecated ListInstanceOSPoliciesCompliances is deprecated and may be removed in a future version. - */ - listInstanceOSPoliciesCompliancesStream( - request?: protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest, - 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['listInstanceOsPoliciesCompliances']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - this.warn('DEP$OsConfigZonalService-$ListInstanceOSPoliciesCompliances','ListInstanceOSPoliciesCompliances is deprecated and may be removed in a future version.', 'DeprecationWarning'); - return this.descriptors.page.listInstanceOSPoliciesCompliances.createStream( - this.innerApiCalls.listInstanceOsPoliciesCompliances as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listInstanceOSPoliciesCompliances`, 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 resource name. - * - * Format: `projects/{project}/locations/{location}` - * - * For `{project}`, either Compute Engine project-number or project-id can be - * provided. - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListInstanceOSPoliciesCompliances` that indicates where this listing - * should continue from. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by a - * `InstanceOSPoliciesCompliance` API resource to be included in the response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance|InstanceOSPoliciesCompliance}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/os_config_zonal_service.list_instance_o_s_policies_compliances.js - * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_ListInstanceOSPoliciesCompliances_async - * @deprecated ListInstanceOSPoliciesCompliances is deprecated and may be removed in a future version. - */ - listInstanceOSPoliciesCompliancesAsync( - request?: protos.google.cloud.osconfig.v1alpha.IListInstanceOSPoliciesCompliancesRequest, - 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['listInstanceOsPoliciesCompliances']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - this.warn('DEP$OsConfigZonalService-$ListInstanceOSPoliciesCompliances','ListInstanceOSPoliciesCompliances is deprecated and may be removed in a future version.', 'DeprecationWarning'); - return this.descriptors.page.listInstanceOSPoliciesCompliances.asyncIterate( - this.innerApiCalls['listInstanceOsPoliciesCompliances'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * List OS policy asssignment reports for all Compute Engine VM instances in - * the specified zone. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * - * Format: - * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/reports` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * For `{instance}`, either `instance-name`, `instance-id`, or `-` can be - * provided. If '-' is provided, the response will include - * OSPolicyAssignmentReports for all instances in the project/location. - * For `{assignment}`, either `assignment-id` or `-` can be provided. If '-' - * is provided, the response will include OSPolicyAssignmentReports for all - * OSPolicyAssignments in the project/location. - * Either {instance} or {assignment} must be `-`. - * - * For example: - * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/-/reports` - * returns all reports for the instance - * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/{assignment-id}/reports` - * returns all the reports for the given assignment across all instances. - * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/-/reports` - * returns all the reports for all assignments across all instances. - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by the - * `OSPolicyAssignmentReport` API resource that is included in the response. - * @param {string} request.pageToken - * A pagination token returned from a previous call to the - * `ListOSPolicyAssignmentReports` method that indicates where this listing - * should continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport|OSPolicyAssignmentReport}. - * 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 `listOSPolicyAssignmentReportsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listOSPolicyAssignmentReports( - request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport[], - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest|null, - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsResponse - ]>; - listOSPolicyAssignmentReports( - request: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest, - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport>): void; - listOSPolicyAssignmentReports( - request: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest, - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport>): void; - listOSPolicyAssignmentReports( - request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest, - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport>, - callback?: PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest, - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport>): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport[], - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest|null, - protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listOsPolicyAssignmentReports(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 resource name. - * - * Format: - * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/reports` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * For `{instance}`, either `instance-name`, `instance-id`, or `-` can be - * provided. If '-' is provided, the response will include - * OSPolicyAssignmentReports for all instances in the project/location. - * For `{assignment}`, either `assignment-id` or `-` can be provided. If '-' - * is provided, the response will include OSPolicyAssignmentReports for all - * OSPolicyAssignments in the project/location. - * Either {instance} or {assignment} must be `-`. - * - * For example: - * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/-/reports` - * returns all reports for the instance - * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/{assignment-id}/reports` - * returns all the reports for the given assignment across all instances. - * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/-/reports` - * returns all the reports for all assignments across all instances. - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by the - * `OSPolicyAssignmentReport` API resource that is included in the response. - * @param {string} request.pageToken - * A pagination token returned from a previous call to the - * `ListOSPolicyAssignmentReports` method that indicates where this listing - * should continue from. - * @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 protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport|OSPolicyAssignmentReport} 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 `listOSPolicyAssignmentReportsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listOSPolicyAssignmentReportsStream( - request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest, - 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['listOsPolicyAssignmentReports']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listOSPolicyAssignmentReports.createStream( - this.innerApiCalls.listOsPolicyAssignmentReports as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listOSPolicyAssignmentReports`, 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 resource name. - * - * Format: - * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/reports` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * For `{instance}`, either `instance-name`, `instance-id`, or `-` can be - * provided. If '-' is provided, the response will include - * OSPolicyAssignmentReports for all instances in the project/location. - * For `{assignment}`, either `assignment-id` or `-` can be provided. If '-' - * is provided, the response will include OSPolicyAssignmentReports for all - * OSPolicyAssignments in the project/location. - * Either {instance} or {assignment} must be `-`. - * - * For example: - * `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/-/reports` - * returns all reports for the instance - * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/{assignment-id}/reports` - * returns all the reports for the given assignment across all instances. - * `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/-/reports` - * returns all the reports for all assignments across all instances. - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by the - * `OSPolicyAssignmentReport` API resource that is included in the response. - * @param {string} request.pageToken - * A pagination token returned from a previous call to the - * `ListOSPolicyAssignmentReports` method that indicates where this listing - * should continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport|OSPolicyAssignmentReport}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/os_config_zonal_service.list_o_s_policy_assignment_reports.js - * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_ListOSPolicyAssignmentReports_async - */ - listOSPolicyAssignmentReportsAsync( - request?: protos.google.cloud.osconfig.v1alpha.IListOSPolicyAssignmentReportsRequest, - 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['listOsPolicyAssignmentReports']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listOSPolicyAssignmentReports.asyncIterate( - this.innerApiCalls['listOsPolicyAssignmentReports'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * List inventory data for all VM instances in the specified zone. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * - * Format: `projects/{project}/locations/{location}/instances/-` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * @param {google.cloud.osconfig.v1alpha.InventoryView} request.view - * Inventory view indicating what information should be included in the - * inventory resource. If unspecified, the default view is BASIC. - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListInventories` that indicates where this listing - * should continue from. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by a - * `Inventory` API resource to be included in the response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1alpha.Inventory|Inventory}. - * 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 `listInventoriesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listInventories( - request?: protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IInventory[], - protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest|null, - protos.google.cloud.osconfig.v1alpha.IListInventoriesResponse - ]>; - listInventories( - request: protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest, - protos.google.cloud.osconfig.v1alpha.IListInventoriesResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IInventory>): void; - listInventories( - request: protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest, - protos.google.cloud.osconfig.v1alpha.IListInventoriesResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IInventory>): void; - listInventories( - request?: protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest, - protos.google.cloud.osconfig.v1alpha.IListInventoriesResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IInventory>, - callback?: PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest, - protos.google.cloud.osconfig.v1alpha.IListInventoriesResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IInventory>): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IInventory[], - protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest|null, - protos.google.cloud.osconfig.v1alpha.IListInventoriesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listInventories(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 resource name. - * - * Format: `projects/{project}/locations/{location}/instances/-` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * @param {google.cloud.osconfig.v1alpha.InventoryView} request.view - * Inventory view indicating what information should be included in the - * inventory resource. If unspecified, the default view is BASIC. - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListInventories` that indicates where this listing - * should continue from. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by a - * `Inventory` API resource to be included in the response. - * @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 protos.google.cloud.osconfig.v1alpha.Inventory|Inventory} 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 `listInventoriesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listInventoriesStream( - request?: protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest, - 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['listInventories']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInventories.createStream( - this.innerApiCalls.listInventories as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listInventories`, 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 resource name. - * - * Format: `projects/{project}/locations/{location}/instances/-` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * @param {google.cloud.osconfig.v1alpha.InventoryView} request.view - * Inventory view indicating what information should be included in the - * inventory resource. If unspecified, the default view is BASIC. - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListInventories` that indicates where this listing - * should continue from. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by a - * `Inventory` API resource to be included in the response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.osconfig.v1alpha.Inventory|Inventory}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/os_config_zonal_service.list_inventories.js - * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_ListInventories_async - */ - listInventoriesAsync( - request?: protos.google.cloud.osconfig.v1alpha.IListInventoriesRequest, - 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['listInventories']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInventories.asyncIterate( - this.innerApiCalls['listInventories'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * List vulnerability reports for all VM instances in the specified zone. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * - * Format: `projects/{project}/locations/{location}/instances/-` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListVulnerabilityReports` that indicates where this listing - * should continue from. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by a - * `vulnerabilityReport` API resource to be included in the response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1alpha.VulnerabilityReport|VulnerabilityReport}. - * 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 `listVulnerabilityReportsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listVulnerabilityReports( - request?: protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport[], - protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest|null, - protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsResponse - ]>; - listVulnerabilityReports( - request: protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest, - protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport>): void; - listVulnerabilityReports( - request: protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest, - protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport>): void; - listVulnerabilityReports( - request?: protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest, - protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport>, - callback?: PaginationCallback< - protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest, - protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsResponse|null|undefined, - protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport>): - Promise<[ - protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport[], - protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest|null, - protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listVulnerabilityReports(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 resource name. - * - * Format: `projects/{project}/locations/{location}/instances/-` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListVulnerabilityReports` that indicates where this listing - * should continue from. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by a - * `vulnerabilityReport` API resource to be included in the response. - * @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 protos.google.cloud.osconfig.v1alpha.VulnerabilityReport|VulnerabilityReport} 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 `listVulnerabilityReportsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listVulnerabilityReportsStream( - request?: protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest, - 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['listVulnerabilityReports']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listVulnerabilityReports.createStream( - this.innerApiCalls.listVulnerabilityReports as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listVulnerabilityReports`, 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 resource name. - * - * Format: `projects/{project}/locations/{location}/instances/-` - * - * For `{project}`, either `project-number` or `project-id` can be provided. - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to - * `ListVulnerabilityReports` that indicates where this listing - * should continue from. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by a - * `vulnerabilityReport` API resource to be included in the response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.osconfig.v1alpha.VulnerabilityReport|VulnerabilityReport}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/os_config_zonal_service.list_vulnerability_reports.js - * region_tag:osconfig_v1alpha_generated_OsConfigZonalService_ListVulnerabilityReports_async - */ - listVulnerabilityReportsAsync( - request?: protos.google.cloud.osconfig.v1alpha.IListVulnerabilityReportsRequest, - 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['listVulnerabilityReports']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listVulnerabilityReports.asyncIterate( - this.innerApiCalls['listVulnerabilityReports'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified instanceOSPoliciesCompliance resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} instance - * @returns {string} Resource name string. - */ - instanceOSPoliciesCompliancePath(project:string,location:string,instance:string) { - return this.pathTemplates.instanceOSPoliciesCompliancePathTemplate.render({ - project: project, - location: location, - instance: instance, - }); - } - - /** - * Parse the project from InstanceOSPoliciesCompliance resource. - * - * @param {string} instanceOSPoliciesComplianceName - * A fully-qualified path representing InstanceOSPoliciesCompliance resource. - * @returns {string} A string representing the project. - */ - matchProjectFromInstanceOSPoliciesComplianceName(instanceOSPoliciesComplianceName: string) { - return this.pathTemplates.instanceOSPoliciesCompliancePathTemplate.match(instanceOSPoliciesComplianceName).project; - } - - /** - * Parse the location from InstanceOSPoliciesCompliance resource. - * - * @param {string} instanceOSPoliciesComplianceName - * A fully-qualified path representing InstanceOSPoliciesCompliance resource. - * @returns {string} A string representing the location. - */ - matchLocationFromInstanceOSPoliciesComplianceName(instanceOSPoliciesComplianceName: string) { - return this.pathTemplates.instanceOSPoliciesCompliancePathTemplate.match(instanceOSPoliciesComplianceName).location; - } - - /** - * Parse the instance from InstanceOSPoliciesCompliance resource. - * - * @param {string} instanceOSPoliciesComplianceName - * A fully-qualified path representing InstanceOSPoliciesCompliance resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromInstanceOSPoliciesComplianceName(instanceOSPoliciesComplianceName: string) { - return this.pathTemplates.instanceOSPoliciesCompliancePathTemplate.match(instanceOSPoliciesComplianceName).instance; - } - - /** - * Return a fully-qualified inventory resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} instance - * @returns {string} Resource name string. - */ - inventoryPath(project:string,location:string,instance:string) { - return this.pathTemplates.inventoryPathTemplate.render({ - project: project, - location: location, - instance: instance, - }); - } - - /** - * Parse the project from Inventory resource. - * - * @param {string} inventoryName - * A fully-qualified path representing Inventory resource. - * @returns {string} A string representing the project. - */ - matchProjectFromInventoryName(inventoryName: string) { - return this.pathTemplates.inventoryPathTemplate.match(inventoryName).project; - } - - /** - * Parse the location from Inventory resource. - * - * @param {string} inventoryName - * A fully-qualified path representing Inventory resource. - * @returns {string} A string representing the location. - */ - matchLocationFromInventoryName(inventoryName: string) { - return this.pathTemplates.inventoryPathTemplate.match(inventoryName).location; - } - - /** - * Parse the instance from Inventory resource. - * - * @param {string} inventoryName - * A fully-qualified path representing Inventory resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromInventoryName(inventoryName: string) { - return this.pathTemplates.inventoryPathTemplate.match(inventoryName).instance; - } - - /** - * Return a fully-qualified oSPolicyAssignment resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} os_policy_assignment - * @returns {string} Resource name string. - */ - oSPolicyAssignmentPath(project:string,location:string,osPolicyAssignment:string) { - return this.pathTemplates.oSPolicyAssignmentPathTemplate.render({ - project: project, - location: location, - os_policy_assignment: osPolicyAssignment, - }); - } - - /** - * Parse the project from OSPolicyAssignment resource. - * - * @param {string} oSPolicyAssignmentName - * A fully-qualified path representing OSPolicyAssignment resource. - * @returns {string} A string representing the project. - */ - matchProjectFromOSPolicyAssignmentName(oSPolicyAssignmentName: string) { - return this.pathTemplates.oSPolicyAssignmentPathTemplate.match(oSPolicyAssignmentName).project; - } - - /** - * Parse the location from OSPolicyAssignment resource. - * - * @param {string} oSPolicyAssignmentName - * A fully-qualified path representing OSPolicyAssignment resource. - * @returns {string} A string representing the location. - */ - matchLocationFromOSPolicyAssignmentName(oSPolicyAssignmentName: string) { - return this.pathTemplates.oSPolicyAssignmentPathTemplate.match(oSPolicyAssignmentName).location; - } - - /** - * Parse the os_policy_assignment from OSPolicyAssignment resource. - * - * @param {string} oSPolicyAssignmentName - * A fully-qualified path representing OSPolicyAssignment resource. - * @returns {string} A string representing the os_policy_assignment. - */ - matchOsPolicyAssignmentFromOSPolicyAssignmentName(oSPolicyAssignmentName: string) { - return this.pathTemplates.oSPolicyAssignmentPathTemplate.match(oSPolicyAssignmentName).os_policy_assignment; - } - - /** - * Return a fully-qualified oSPolicyAssignmentReport resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} instance - * @param {string} assignment - * @returns {string} Resource name string. - */ - oSPolicyAssignmentReportPath(project:string,location:string,instance:string,assignment:string) { - return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.render({ - project: project, - location: location, - instance: instance, - assignment: assignment, - }); - } - - /** - * Parse the project from OSPolicyAssignmentReport resource. - * - * @param {string} oSPolicyAssignmentReportName - * A fully-qualified path representing OSPolicyAssignmentReport resource. - * @returns {string} A string representing the project. - */ - matchProjectFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { - return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).project; - } - - /** - * Parse the location from OSPolicyAssignmentReport resource. - * - * @param {string} oSPolicyAssignmentReportName - * A fully-qualified path representing OSPolicyAssignmentReport resource. - * @returns {string} A string representing the location. - */ - matchLocationFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { - return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).location; - } - - /** - * Parse the instance from OSPolicyAssignmentReport resource. - * - * @param {string} oSPolicyAssignmentReportName - * A fully-qualified path representing OSPolicyAssignmentReport resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { - return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).instance; - } - - /** - * Parse the assignment from OSPolicyAssignmentReport resource. - * - * @param {string} oSPolicyAssignmentReportName - * A fully-qualified path representing OSPolicyAssignmentReport resource. - * @returns {string} A string representing the assignment. - */ - matchAssignmentFromOSPolicyAssignmentReportName(oSPolicyAssignmentReportName: string) { - return this.pathTemplates.oSPolicyAssignmentReportPathTemplate.match(oSPolicyAssignmentReportName).assignment; - } - - /** - * Return a fully-qualified vulnerabilityReport resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} instance - * @returns {string} Resource name string. - */ - vulnerabilityReportPath(project:string,location:string,instance:string) { - return this.pathTemplates.vulnerabilityReportPathTemplate.render({ - project: project, - location: location, - instance: instance, - }); - } - - /** - * Parse the project from VulnerabilityReport resource. - * - * @param {string} vulnerabilityReportName - * A fully-qualified path representing VulnerabilityReport resource. - * @returns {string} A string representing the project. - */ - matchProjectFromVulnerabilityReportName(vulnerabilityReportName: string) { - return this.pathTemplates.vulnerabilityReportPathTemplate.match(vulnerabilityReportName).project; - } - - /** - * Parse the location from VulnerabilityReport resource. - * - * @param {string} vulnerabilityReportName - * A fully-qualified path representing VulnerabilityReport resource. - * @returns {string} A string representing the location. - */ - matchLocationFromVulnerabilityReportName(vulnerabilityReportName: string) { - return this.pathTemplates.vulnerabilityReportPathTemplate.match(vulnerabilityReportName).location; - } - - /** - * Parse the instance from VulnerabilityReport resource. - * - * @param {string} vulnerabilityReportName - * A fully-qualified path representing VulnerabilityReport resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromVulnerabilityReportName(vulnerabilityReportName: string) { - return this.pathTemplates.vulnerabilityReportPathTemplate.match(vulnerabilityReportName).instance; - } - - /** - * 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.osConfigZonalServiceStub && !this._terminated) { - return this.osConfigZonalServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_client_config.json b/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_client_config.json deleted file mode 100644 index 130d4b4af17..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_client_config.json +++ /dev/null @@ -1,108 +0,0 @@ -{ - "interfaces": { - "google.cloud.osconfig.v1alpha.OsConfigZonalService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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 - }, - "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c": { - "initial_retry_delay_millis": 1000, - "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": { - "CreateOSPolicyAssignment": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "UpdateOSPolicyAssignment": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "GetOSPolicyAssignment": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "ListOSPolicyAssignments": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "ListOSPolicyAssignmentRevisions": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "DeleteOSPolicyAssignment": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "GetInstanceOSPoliciesCompliance": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "ListInstanceOSPoliciesCompliances": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "GetOSPolicyAssignmentReport": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "ListOSPolicyAssignmentReports": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "GetInventory": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "ListInventories": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "GetVulnerabilityReport": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "ListVulnerabilityReports": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_proto_list.json b/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_proto_list.json deleted file mode 100644 index 8cf88654436..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/src/v1alpha/os_config_zonal_service_proto_list.json +++ /dev/null @@ -1,11 +0,0 @@ -[ - "../../protos/google/cloud/osconfig/v1alpha/config_common.proto", - "../../protos/google/cloud/osconfig/v1alpha/instance_os_policies_compliance.proto", - "../../protos/google/cloud/osconfig/v1alpha/inventory.proto", - "../../protos/google/cloud/osconfig/v1alpha/os_policy.proto", - "../../protos/google/cloud/osconfig/v1alpha/os_policy_assignment_reports.proto", - "../../protos/google/cloud/osconfig/v1alpha/os_policy_assignments.proto", - "../../protos/google/cloud/osconfig/v1alpha/osconfig_common.proto", - "../../protos/google/cloud/osconfig/v1alpha/osconfig_zonal_service.proto", - "../../protos/google/cloud/osconfig/v1alpha/vulnerability.proto" -] diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/fixtures/sample/src/index.js deleted file mode 100644 index e75225b1b68..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const osconfig = require('@google-cloud/os-config'); - -function main() { - const osConfigZonalServiceClient = new osconfig.OsConfigZonalServiceClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index b1559446972..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {OsConfigZonalServiceClient} from '@google-cloud/os-config'; - -// check that the client class type name can be used -function doStuffWithOsConfigZonalServiceClient(client: OsConfigZonalServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const osConfigZonalServiceClient = new OsConfigZonalServiceClient(); - doStuffWithOsConfigZonalServiceClient(osConfigZonalServiceClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/install.ts b/owl-bot-staging/google-cloud-osconfig/v1alpha/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/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-osconfig/v1alpha/test/gapic_os_config_zonal_service_v1alpha.ts b/owl-bot-staging/google-cloud-osconfig/v1alpha/test/gapic_os_config_zonal_service_v1alpha.ts deleted file mode 100644 index 83fe79116a9..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/test/gapic_os_config_zonal_service_v1alpha.ts +++ /dev/null @@ -1,2952 +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 osconfigzonalserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1alpha.OsConfigZonalServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.osConfigZonalServiceStub, undefined); - await client.initialize(); - assert(client.osConfigZonalServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.osConfigZonalServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.osConfigZonalServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - 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 osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - 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('getOSPolicyAssignment', () => { - it('invokes getOSPolicyAssignment without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment() - ); - client.innerApiCalls.getOsPolicyAssignment = stubSimpleCall(expectedResponse); - const [response] = await client.getOSPolicyAssignment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getOSPolicyAssignment without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment() - ); - client.innerApiCalls.getOsPolicyAssignment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getOSPolicyAssignment( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getOSPolicyAssignment with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getOsPolicyAssignment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getOSPolicyAssignment(request), expectedError); - const actualRequest = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getOSPolicyAssignment with closed client', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getOSPolicyAssignment(request), expectedError); - }); - }); - - describe('getInstanceOSPoliciesCompliance', () => { - it('invokes getInstanceOSPoliciesCompliance without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance() - ); - client.innerApiCalls.getInstanceOsPoliciesCompliance = stubSimpleCall(expectedResponse); - const [response] = await client.getInstanceOSPoliciesCompliance(request); - assert(stub.calledOnce); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstanceOsPoliciesCompliance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstanceOsPoliciesCompliance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstanceOSPoliciesCompliance without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance() - ); - client.innerApiCalls.getInstanceOsPoliciesCompliance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstanceOSPoliciesCompliance( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert(stub.calledOnce); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstanceOsPoliciesCompliance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstanceOsPoliciesCompliance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstanceOSPoliciesCompliance with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstanceOsPoliciesCompliance = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstanceOSPoliciesCompliance(request), expectedError); - assert(stub.calledOnce); - const actualRequest = (client.innerApiCalls.getInstanceOsPoliciesCompliance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstanceOsPoliciesCompliance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstanceOSPoliciesCompliance with closed client', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getInstanceOSPoliciesCompliance(request), expectedError); - assert(stub.calledOnce); - }); - }); - - describe('getOSPolicyAssignmentReport', () => { - it('invokes getOSPolicyAssignmentReport without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport() - ); - client.innerApiCalls.getOsPolicyAssignmentReport = stubSimpleCall(expectedResponse); - const [response] = await client.getOSPolicyAssignmentReport(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getOSPolicyAssignmentReport without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport() - ); - client.innerApiCalls.getOsPolicyAssignmentReport = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getOSPolicyAssignmentReport( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getOSPolicyAssignmentReport with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getOsPolicyAssignmentReport = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getOSPolicyAssignmentReport(request), expectedError); - const actualRequest = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOsPolicyAssignmentReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getOSPolicyAssignmentReport with closed client', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getOSPolicyAssignmentReport(request), expectedError); - }); - }); - - describe('getInventory', () => { - it('invokes getInventory without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.GetInventoryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetInventoryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.Inventory() - ); - client.innerApiCalls.getInventory = stubSimpleCall(expectedResponse); - const [response] = await client.getInventory(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInventory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInventory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInventory without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.GetInventoryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetInventoryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.Inventory() - ); - client.innerApiCalls.getInventory = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInventory( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IInventory|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInventory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInventory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInventory with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.GetInventoryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetInventoryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInventory = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInventory(request), expectedError); - const actualRequest = (client.innerApiCalls.getInventory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInventory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInventory with closed client', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.GetInventoryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetInventoryRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getInventory(request), expectedError); - }); - }); - - describe('getVulnerabilityReport', () => { - it('invokes getVulnerabilityReport without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport() - ); - client.innerApiCalls.getVulnerabilityReport = stubSimpleCall(expectedResponse); - const [response] = await client.getVulnerabilityReport(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getVulnerabilityReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getVulnerabilityReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getVulnerabilityReport without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport() - ); - client.innerApiCalls.getVulnerabilityReport = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getVulnerabilityReport( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getVulnerabilityReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getVulnerabilityReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getVulnerabilityReport with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getVulnerabilityReport = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getVulnerabilityReport(request), expectedError); - const actualRequest = (client.innerApiCalls.getVulnerabilityReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getVulnerabilityReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getVulnerabilityReport with closed client', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getVulnerabilityReport(request), expectedError); - }); - }); - - describe('createOSPolicyAssignment', () => { - it('invokes createOSPolicyAssignment without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createOsPolicyAssignment = stubLongRunningCall(expectedResponse); - const [operation] = await client.createOSPolicyAssignment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createOSPolicyAssignment without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createOsPolicyAssignment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createOSPolicyAssignment( - request, - (err?: Error|null, - result?: 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.createOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createOSPolicyAssignment with call error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createOsPolicyAssignment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createOSPolicyAssignment(request), expectedError); - const actualRequest = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createOSPolicyAssignment with LRO error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createOsPolicyAssignment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createOSPolicyAssignment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateOSPolicyAssignmentProgress without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateOSPolicyAssignmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateOSPolicyAssignmentProgress with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateOSPolicyAssignmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateOSPolicyAssignment', () => { - it('invokes updateOSPolicyAssignment without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest() - ); - request.osPolicyAssignment ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest', ['osPolicyAssignment', 'name']); - request.osPolicyAssignment.name = defaultValue1; - const expectedHeaderRequestParams = `os_policy_assignment.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateOsPolicyAssignment = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateOSPolicyAssignment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateOSPolicyAssignment without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest() - ); - request.osPolicyAssignment ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest', ['osPolicyAssignment', 'name']); - request.osPolicyAssignment.name = defaultValue1; - const expectedHeaderRequestParams = `os_policy_assignment.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateOsPolicyAssignment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateOSPolicyAssignment( - request, - (err?: Error|null, - result?: 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.updateOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateOSPolicyAssignment with call error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest() - ); - request.osPolicyAssignment ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest', ['osPolicyAssignment', 'name']); - request.osPolicyAssignment.name = defaultValue1; - const expectedHeaderRequestParams = `os_policy_assignment.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateOsPolicyAssignment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateOSPolicyAssignment(request), expectedError); - const actualRequest = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateOSPolicyAssignment with LRO error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest() - ); - request.osPolicyAssignment ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest', ['osPolicyAssignment', 'name']); - request.osPolicyAssignment.name = defaultValue1; - const expectedHeaderRequestParams = `os_policy_assignment.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateOsPolicyAssignment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateOSPolicyAssignment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateOSPolicyAssignmentProgress without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateOSPolicyAssignmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateOSPolicyAssignmentProgress with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateOSPolicyAssignmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteOSPolicyAssignment', () => { - it('invokes deleteOSPolicyAssignment without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteOsPolicyAssignment = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteOSPolicyAssignment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteOSPolicyAssignment without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteOsPolicyAssignment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteOSPolicyAssignment( - request, - (err?: Error|null, - result?: 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.deleteOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteOSPolicyAssignment with call error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteOsPolicyAssignment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteOSPolicyAssignment(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteOSPolicyAssignment with LRO error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteOsPolicyAssignment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteOSPolicyAssignment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteOsPolicyAssignment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteOSPolicyAssignmentProgress without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteOSPolicyAssignmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteOSPolicyAssignmentProgress with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteOSPolicyAssignmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listOSPolicyAssignments', () => { - it('invokes listOSPolicyAssignments without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - ]; - client.innerApiCalls.listOsPolicyAssignments = stubSimpleCall(expectedResponse); - const [response] = await client.listOSPolicyAssignments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listOSPolicyAssignments without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - ]; - client.innerApiCalls.listOsPolicyAssignments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listOSPolicyAssignments( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listOSPolicyAssignments with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listOsPolicyAssignments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listOSPolicyAssignments(request), expectedError); - const actualRequest = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listOSPolicyAssignmentsStream without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - ]; - client.descriptors.page.listOSPolicyAssignments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listOSPolicyAssignmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment) => { - 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.listOSPolicyAssignments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignments, request)); - assert( - (client.descriptors.page.listOSPolicyAssignments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listOSPolicyAssignmentsStream with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listOSPolicyAssignments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listOSPolicyAssignmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listOSPolicyAssignments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignments, request)); - assert( - (client.descriptors.page.listOSPolicyAssignments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listOSPolicyAssignments without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - ]; - client.descriptors.page.listOSPolicyAssignments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment[] = []; - const iterable = client.listOSPolicyAssignmentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listOSPolicyAssignments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listOSPolicyAssignments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listOSPolicyAssignments with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listOSPolicyAssignments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listOSPolicyAssignmentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listOSPolicyAssignments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listOSPolicyAssignments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listOSPolicyAssignmentRevisions', () => { - it('invokes listOSPolicyAssignmentRevisions without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - ]; - client.innerApiCalls.listOsPolicyAssignmentRevisions = stubSimpleCall(expectedResponse); - const [response] = await client.listOSPolicyAssignmentRevisions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listOSPolicyAssignmentRevisions without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - ]; - client.innerApiCalls.listOsPolicyAssignmentRevisions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listOSPolicyAssignmentRevisions( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listOSPolicyAssignmentRevisions with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listOsPolicyAssignmentRevisions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listOSPolicyAssignmentRevisions(request), expectedError); - const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentRevisions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listOSPolicyAssignmentRevisionsStream without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - ]; - client.descriptors.page.listOSPolicyAssignmentRevisions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listOSPolicyAssignmentRevisionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment) => { - 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.listOSPolicyAssignmentRevisions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignmentRevisions, request)); - assert( - (client.descriptors.page.listOSPolicyAssignmentRevisions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listOSPolicyAssignmentRevisionsStream with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listOSPolicyAssignmentRevisions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listOSPolicyAssignmentRevisionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listOSPolicyAssignmentRevisions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignmentRevisions, request)); - assert( - (client.descriptors.page.listOSPolicyAssignmentRevisions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listOSPolicyAssignmentRevisions without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignment()), - ]; - client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment[] = []; - const iterable = client.listOSPolicyAssignmentRevisionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listOSPolicyAssignmentRevisions with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listOSPolicyAssignmentRevisionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignment[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listOSPolicyAssignmentRevisions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listInstanceOSPoliciesCompliances', () => { - it('invokes listInstanceOSPoliciesCompliances without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), - ]; - client.innerApiCalls.listInstanceOsPoliciesCompliances = stubSimpleCall(expectedResponse); - const [response] = await client.listInstanceOSPoliciesCompliances(request); - assert(stub.calledOnce); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstanceOsPoliciesCompliances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstanceOsPoliciesCompliances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstanceOSPoliciesCompliances without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), - ]; - client.innerApiCalls.listInstanceOsPoliciesCompliances = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInstanceOSPoliciesCompliances( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert(stub.calledOnce); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstanceOsPoliciesCompliances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstanceOsPoliciesCompliances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstanceOSPoliciesCompliances with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInstanceOsPoliciesCompliances = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInstanceOSPoliciesCompliances(request), expectedError); - assert(stub.calledOnce); - const actualRequest = (client.innerApiCalls.listInstanceOsPoliciesCompliances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstanceOsPoliciesCompliances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstanceOSPoliciesCompliancesStream without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), - ]; - client.descriptors.page.listInstanceOSPoliciesCompliances.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInstanceOSPoliciesCompliancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert(stub.calledOnce); - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listInstanceOSPoliciesCompliances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstanceOsPoliciesCompliances, request)); - assert( - (client.descriptors.page.listInstanceOSPoliciesCompliances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listInstanceOSPoliciesCompliancesStream with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstanceOSPoliciesCompliances.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInstanceOSPoliciesCompliancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert(stub.calledOnce); - assert((client.descriptors.page.listInstanceOSPoliciesCompliances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstanceOsPoliciesCompliances, request)); - assert( - (client.descriptors.page.listInstanceOSPoliciesCompliances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInstanceOSPoliciesCompliances without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance()), - ]; - client.descriptors.page.listInstanceOSPoliciesCompliances.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance[] = []; - const iterable = client.listInstanceOSPoliciesCompliancesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert(stub.calledOnce); - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInstanceOSPoliciesCompliances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstanceOSPoliciesCompliances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInstanceOSPoliciesCompliances with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstanceOSPoliciesCompliances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInstanceOSPoliciesCompliancesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.osconfig.v1alpha.IInstanceOSPoliciesCompliance[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert(stub.calledOnce); - assert.deepStrictEqual( - (client.descriptors.page.listInstanceOSPoliciesCompliances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstanceOSPoliciesCompliances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listOSPolicyAssignmentReports', () => { - it('invokes listOSPolicyAssignmentReports without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), - ]; - client.innerApiCalls.listOsPolicyAssignmentReports = stubSimpleCall(expectedResponse); - const [response] = await client.listOSPolicyAssignmentReports(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listOSPolicyAssignmentReports without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), - ]; - client.innerApiCalls.listOsPolicyAssignmentReports = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listOSPolicyAssignmentReports( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listOSPolicyAssignmentReports with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listOsPolicyAssignmentReports = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listOSPolicyAssignmentReports(request), expectedError); - const actualRequest = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOsPolicyAssignmentReports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listOSPolicyAssignmentReportsStream without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), - ]; - client.descriptors.page.listOSPolicyAssignmentReports.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listOSPolicyAssignmentReportsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport) => { - 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.listOSPolicyAssignmentReports.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignmentReports, request)); - assert( - (client.descriptors.page.listOSPolicyAssignmentReports.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listOSPolicyAssignmentReportsStream with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listOSPolicyAssignmentReports.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listOSPolicyAssignmentReportsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listOSPolicyAssignmentReports.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOsPolicyAssignmentReports, request)); - assert( - (client.descriptors.page.listOSPolicyAssignmentReports.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listOSPolicyAssignmentReports without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport()), - ]; - client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport[] = []; - const iterable = client.listOSPolicyAssignmentReportsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listOSPolicyAssignmentReports with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listOSPolicyAssignmentReportsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.osconfig.v1alpha.IOSPolicyAssignmentReport[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listOSPolicyAssignmentReports.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listInventories', () => { - it('invokes listInventories without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListInventoriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInventoriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), - ]; - client.innerApiCalls.listInventories = stubSimpleCall(expectedResponse); - const [response] = await client.listInventories(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInventories without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListInventoriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInventoriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), - ]; - client.innerApiCalls.listInventories = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInventories( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IInventory[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInventories with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListInventoriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInventoriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInventories = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInventories(request), expectedError); - const actualRequest = (client.innerApiCalls.listInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInventoriesStream without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListInventoriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInventoriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), - ]; - client.descriptors.page.listInventories.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInventoriesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1alpha.Inventory[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.Inventory) => { - 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.listInventories.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInventories, request)); - assert( - (client.descriptors.page.listInventories.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listInventoriesStream with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListInventoriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInventoriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInventories.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInventoriesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1alpha.Inventory[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.Inventory) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listInventories.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInventories, request)); - assert( - (client.descriptors.page.listInventories.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInventories without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListInventoriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInventoriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.Inventory()), - ]; - client.descriptors.page.listInventories.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.osconfig.v1alpha.IInventory[] = []; - const iterable = client.listInventoriesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInventories.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInventories.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInventories with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListInventoriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListInventoriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInventories.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInventoriesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.osconfig.v1alpha.IInventory[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listInventories.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInventories.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listVulnerabilityReports', () => { - it('invokes listVulnerabilityReports without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), - ]; - client.innerApiCalls.listVulnerabilityReports = stubSimpleCall(expectedResponse); - const [response] = await client.listVulnerabilityReports(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listVulnerabilityReports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listVulnerabilityReports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listVulnerabilityReports without error using callback', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), - ]; - client.innerApiCalls.listVulnerabilityReports = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listVulnerabilityReports( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listVulnerabilityReports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listVulnerabilityReports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listVulnerabilityReports with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listVulnerabilityReports = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listVulnerabilityReports(request), expectedError); - const actualRequest = (client.innerApiCalls.listVulnerabilityReports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listVulnerabilityReports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listVulnerabilityReportsStream without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), - ]; - client.descriptors.page.listVulnerabilityReports.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listVulnerabilityReportsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1alpha.VulnerabilityReport[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.VulnerabilityReport) => { - 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.listVulnerabilityReports.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listVulnerabilityReports, request)); - assert( - (client.descriptors.page.listVulnerabilityReports.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listVulnerabilityReportsStream with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listVulnerabilityReports.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listVulnerabilityReportsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1alpha.VulnerabilityReport[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1alpha.VulnerabilityReport) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listVulnerabilityReports.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listVulnerabilityReports, request)); - assert( - (client.descriptors.page.listVulnerabilityReports.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listVulnerabilityReports without error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), - generateSampleMessage(new protos.google.cloud.osconfig.v1alpha.VulnerabilityReport()), - ]; - client.descriptors.page.listVulnerabilityReports.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport[] = []; - const iterable = client.listVulnerabilityReportsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listVulnerabilityReports.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listVulnerabilityReports.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listVulnerabilityReports with error', async () => { - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listVulnerabilityReports.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listVulnerabilityReportsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.osconfig.v1alpha.IVulnerabilityReport[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listVulnerabilityReports.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listVulnerabilityReports.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('instanceOSPoliciesCompliance', () => { - const fakePath = "/rendered/path/instanceOSPoliciesCompliance"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - }; - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.instanceOSPoliciesCompliancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instanceOSPoliciesCompliancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instanceOSPoliciesCompliancePath', () => { - const result = client.instanceOSPoliciesCompliancePath("projectValue", "locationValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instanceOSPoliciesCompliancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceOSPoliciesComplianceName', () => { - const result = client.matchProjectFromInstanceOSPoliciesComplianceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instanceOSPoliciesCompliancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromInstanceOSPoliciesComplianceName', () => { - const result = client.matchLocationFromInstanceOSPoliciesComplianceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.instanceOSPoliciesCompliancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceOSPoliciesComplianceName', () => { - const result = client.matchInstanceFromInstanceOSPoliciesComplianceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instanceOSPoliciesCompliancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('inventory', () => { - const fakePath = "/rendered/path/inventory"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - }; - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.inventoryPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.inventoryPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('inventoryPath', () => { - const result = client.inventoryPath("projectValue", "locationValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.inventoryPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInventoryName', () => { - const result = client.matchProjectFromInventoryName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.inventoryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromInventoryName', () => { - const result = client.matchLocationFromInventoryName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.inventoryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInventoryName', () => { - const result = client.matchInstanceFromInventoryName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.inventoryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('oSPolicyAssignment', () => { - const fakePath = "/rendered/path/oSPolicyAssignment"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - os_policy_assignment: "osPolicyAssignmentValue", - }; - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.oSPolicyAssignmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.oSPolicyAssignmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('oSPolicyAssignmentPath', () => { - const result = client.oSPolicyAssignmentPath("projectValue", "locationValue", "osPolicyAssignmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromOSPolicyAssignmentName', () => { - const result = client.matchProjectFromOSPolicyAssignmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOSPolicyAssignmentName', () => { - const result = client.matchLocationFromOSPolicyAssignmentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchOsPolicyAssignmentFromOSPolicyAssignmentName', () => { - const result = client.matchOsPolicyAssignmentFromOSPolicyAssignmentName(fakePath); - assert.strictEqual(result, "osPolicyAssignmentValue"); - assert((client.pathTemplates.oSPolicyAssignmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('oSPolicyAssignmentReport', () => { - const fakePath = "/rendered/path/oSPolicyAssignmentReport"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - assignment: "assignmentValue", - }; - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.oSPolicyAssignmentReportPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('oSPolicyAssignmentReportPath', () => { - const result = client.oSPolicyAssignmentReportPath("projectValue", "locationValue", "instanceValue", "assignmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromOSPolicyAssignmentReportName', () => { - const result = client.matchProjectFromOSPolicyAssignmentReportName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOSPolicyAssignmentReportName', () => { - const result = client.matchLocationFromOSPolicyAssignmentReportName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromOSPolicyAssignmentReportName', () => { - const result = client.matchInstanceFromOSPolicyAssignmentReportName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAssignmentFromOSPolicyAssignmentReportName', () => { - const result = client.matchAssignmentFromOSPolicyAssignmentReportName(fakePath); - assert.strictEqual(result, "assignmentValue"); - assert((client.pathTemplates.oSPolicyAssignmentReportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('vulnerabilityReport', () => { - const fakePath = "/rendered/path/vulnerabilityReport"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - }; - const client = new osconfigzonalserviceModule.v1alpha.OsConfigZonalServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.vulnerabilityReportPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.vulnerabilityReportPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('vulnerabilityReportPath', () => { - const result = client.vulnerabilityReportPath("projectValue", "locationValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.vulnerabilityReportPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromVulnerabilityReportName', () => { - const result = client.matchProjectFromVulnerabilityReportName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.vulnerabilityReportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromVulnerabilityReportName', () => { - const result = client.matchLocationFromVulnerabilityReportName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.vulnerabilityReportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromVulnerabilityReportName', () => { - const result = client.matchInstanceFromVulnerabilityReportName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.vulnerabilityReportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-osconfig/v1alpha/tsconfig.json b/owl-bot-staging/google-cloud-osconfig/v1alpha/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/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-osconfig/v1alpha/webpack.config.js b/owl-bot-staging/google-cloud-osconfig/v1alpha/webpack.config.js deleted file mode 100644 index 3b39c422834..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1alpha/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: 'OsConfigZonalService', - filename: './os-config-zonal-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-osconfig/v1beta/.eslintignore b/owl-bot-staging/google-cloud-osconfig/v1beta/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/.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-osconfig/v1beta/.eslintrc.json b/owl-bot-staging/google-cloud-osconfig/v1beta/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/.gitignore b/owl-bot-staging/google-cloud-osconfig/v1beta/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/.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-osconfig/v1beta/.jsdoc.js b/owl-bot-staging/google-cloud-osconfig/v1beta/.jsdoc.js deleted file mode 100644 index 7889031cbe8..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/.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/osconfig', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/.mocharc.js b/owl-bot-staging/google-cloud-osconfig/v1beta/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/.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-osconfig/v1beta/.prettierrc.js b/owl-bot-staging/google-cloud-osconfig/v1beta/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/.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-osconfig/v1beta/README.md b/owl-bot-staging/google-cloud-osconfig/v1beta/README.md deleted file mode 100644 index 94de5ca4cff..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/README.md +++ /dev/null @@ -1 +0,0 @@ -Osconfig: Nodejs Client diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/package.json b/owl-bot-staging/google-cloud-osconfig/v1beta/package.json deleted file mode 100644 index b88b28ee578..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/osconfig", - "version": "0.1.0", - "description": "Osconfig client for Node.js", - "repository": "googleapis/nodejs-osconfig", - "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 osconfig", - "osconfig", - "os config service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/guest_policies.proto b/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/guest_policies.proto deleted file mode 100644 index 5534bb9d89f..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/guest_policies.proto +++ /dev/null @@ -1,772 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.osconfig.v1beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "cloud.google.com/go/osconfig/apiv1beta/osconfigpb;osconfigpb"; -option java_outer_classname = "GuestPolicies"; -option java_package = "com.google.cloud.osconfig.v1beta"; - -// An OS Config resource representing a guest configuration policy. These -// policies represent the desired state for VM instance guest environments -// including packages to install or remove, package repository configurations, -// and software to install. -message GuestPolicy { - option (google.api.resource) = { - type: "osconfig.googleapis.com/GuestPolicy" - pattern: "projects/{project}/guestPolicies/{guest_policy}" - }; - - // Required. Unique name of the resource in this project using one of the following - // forms: - // `projects/{project_number}/guestPolicies/{guest_policy_id}`. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Description of the guest policy. Length of the description is limited - // to 1024 characters. - string description = 2; - - // Output only. Time this guest policy was created. - google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Last time this guest policy was updated. - google.protobuf.Timestamp update_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Required. Specifies the VM instances that are assigned to this policy. This allows - // you to target sets or groups of VM instances by different parameters such - // as labels, names, OS, or zones. - // - // If left empty, all VM instances underneath this policy are targeted. - // - // At the same level in the resource hierarchy (that is within a project), the - // service prevents the creation of multiple policies that conflict with - // each other. For more information, see how the service [handles assignment - // conflicts](/compute/docs/os-config-management/create-guest-policy#handle-conflicts). - Assignment assignment = 6 [(google.api.field_behavior) = REQUIRED]; - - // The software packages to be managed by this policy. - repeated Package packages = 7; - - // A list of package repositories to configure on the VM instance. This is - // done before any other configs are applied so they can use these repos. - // Package repositories are only configured if the corresponding package - // manager(s) are available. - repeated PackageRepository package_repositories = 8; - - // A list of Recipes to install on the VM instance. - repeated SoftwareRecipe recipes = 9; - - // The etag for this guest policy. - // If this is provided on update, it must match the server's etag. - string etag = 10; -} - -// An assignment represents the group or groups of VM instances that the policy -// applies to. -// -// If an assignment is empty, it applies to all VM instances. Otherwise, the -// targeted VM instances must meet all the criteria specified. So if both -// labels and zones are specified, the policy applies to VM instances with those -// labels and in those zones. -message Assignment { - // Represents a group of VM intances that can be identified as having all - // these labels, for example "env=prod and app=web". - message GroupLabel { - // Google Compute Engine instance labels that must be present for an - // instance to be included in this assignment group. - map labels = 1; - } - - // Defines the criteria for selecting VM Instances by OS type. - message OsType { - // Targets VM instances with OS Inventory enabled and having the following - // OS short name, for example "debian" or "windows". - string os_short_name = 1; - - // Targets VM instances with OS Inventory enabled and having the following - // following OS version. - string os_version = 2; - - // Targets VM instances with OS Inventory enabled and having the following - // OS architecture. - string os_architecture = 3; - } - - // Targets instances matching at least one of these label sets. This allows - // an assignment to target disparate groups, for example "env=prod or - // env=staging". - repeated GroupLabel group_labels = 1; - - // Targets instances in any of these zones. Leave empty to target instances - // in any zone. - // - // Zonal targeting is uncommon and is supported to facilitate the management - // of changes by zone. - repeated string zones = 2; - - // Targets any of the instances specified. Instances are specified by their - // URI in the form `zones/[ZONE]/instances/[INSTANCE_NAME]`. - // - // Instance targeting is uncommon and is supported to facilitate the - // management of changes by the instance or to target specific VM instances - // for development and testing. - // - // Only supported for project-level policies and must reference instances - // within this project. - repeated string instances = 3; - - // Targets VM instances whose name starts with one of these prefixes. - // - // Like labels, this is another way to group VM instances when targeting - // configs, for example prefix="prod-". - // - // Only supported for project-level policies. - repeated string instance_name_prefixes = 4; - - // Targets VM instances matching at least one of the following OS types. - // - // VM instances must match all supplied criteria for a given OsType to be - // included. - repeated OsType os_types = 5; -} - -// The desired state that the OS Config agent maintains on the VM instance. -enum DesiredState { - // The default is to ensure the package is installed. - DESIRED_STATE_UNSPECIFIED = 0; - - // The agent ensures that the package is installed. - INSTALLED = 1; - - // The agent ensures that the package is installed and - // periodically checks for and install any updates. - UPDATED = 2; - - // The agent ensures that the package is not installed and uninstall it - // if detected. - REMOVED = 3; -} - -// Package is a reference to the software package to be installed or removed. -// The agent on the VM instance uses the system package manager to apply the -// config. -// -// -// These are the commands that the agent uses to install or remove -// packages. -// -// Apt -// install: `apt-get update && apt-get -y install package1 package2 package3` -// remove: `apt-get -y remove package1 package2 package3` -// -// Yum -// install: `yum -y install package1 package2 package3` -// remove: `yum -y remove package1 package2 package3` -// -// Zypper -// install: `zypper install package1 package2 package3` -// remove: `zypper rm package1 package2` -// -// Googet -// install: `googet -noconfirm install package1 package2 package3` -// remove: `googet -noconfirm remove package1 package2 package3` -message Package { - // Types of package managers that may be used to manage this package. - enum Manager { - // The default behavior is ANY. - MANAGER_UNSPECIFIED = 0; - - // Apply this package config using the default system package manager. - ANY = 1; - - // Apply this package config only if Apt is available on the system. - APT = 2; - - // Apply this package config only if Yum is available on the system. - YUM = 3; - - // Apply this package config only if Zypper is available on the system. - ZYPPER = 4; - - // Apply this package config only if GooGet is available on the system. - GOO = 5; - } - - // Required. The name of the package. A package is uniquely identified for conflict - // validation by checking the package name and the manager(s) that the - // package targets. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // The desired_state the agent should maintain for this package. The - // default is to ensure the package is installed. - DesiredState desired_state = 2; - - // Type of package manager that can be used to install this package. - // If a system does not have the package manager, the package is not - // installed or removed no error message is returned. By default, - // or if you specify `ANY`, - // the agent attempts to install and remove this package using the default - // package manager. This is useful when creating a policy that applies to - // different types of systems. - // - // The default behavior is ANY. - Manager manager = 3; -} - -// Represents a single Apt package repository. This repository is added to -// a repo file that is stored at -// `/etc/apt/sources.list.d/google_osconfig.list`. -message AptRepository { - // Type of archive. - enum ArchiveType { - // Unspecified. - ARCHIVE_TYPE_UNSPECIFIED = 0; - - // DEB indicates that the archive contains binary files. - DEB = 1; - - // DEB_SRC indicates that the archive contains source files. - DEB_SRC = 2; - } - - // Type of archive files in this repository. The default behavior is DEB. - ArchiveType archive_type = 1; - - // Required. URI for this repository. - string uri = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. Distribution of this repository. - string distribution = 3 [(google.api.field_behavior) = REQUIRED]; - - // Required. List of components for this repository. Must contain at least one item. - repeated string components = 4 [(google.api.field_behavior) = REQUIRED]; - - // URI of the key file for this repository. The agent maintains - // a keyring at `/etc/apt/trusted.gpg.d/osconfig_agent_managed.gpg` containing - // all the keys in any applied guest policy. - string gpg_key = 5; -} - -// Represents a single Yum package repository. This repository is added to a -// repo file that is stored at `/etc/yum.repos.d/google_osconfig.repo`. -message YumRepository { - // Required. A one word, unique name for this repository. This is - // the `repo id` in the Yum config file and also the `display_name` if - // `display_name` is omitted. This id is also used as the unique identifier - // when checking for guest policy conflicts. - string id = 1 [(google.api.field_behavior) = REQUIRED]; - - // The display name of the repository. - string display_name = 2; - - // Required. The location of the repository directory. - string base_url = 3 [(google.api.field_behavior) = REQUIRED]; - - // URIs of GPG keys. - repeated string gpg_keys = 4; -} - -// Represents a single Zypper package repository. This repository is added to a -// repo file that is stored at `/etc/zypp/repos.d/google_osconfig.repo`. -message ZypperRepository { - // Required. A one word, unique name for this repository. This is - // the `repo id` in the zypper config file and also the `display_name` if - // `display_name` is omitted. This id is also used as the unique identifier - // when checking for guest policy conflicts. - string id = 1 [(google.api.field_behavior) = REQUIRED]; - - // The display name of the repository. - string display_name = 2; - - // Required. The location of the repository directory. - string base_url = 3 [(google.api.field_behavior) = REQUIRED]; - - // URIs of GPG keys. - repeated string gpg_keys = 4; -} - -// Represents a Goo package repository. These is added to a repo file -// that is stored at C:/ProgramData/GooGet/repos/google_osconfig.repo. -message GooRepository { - // Required. The name of the repository. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The url of the repository. - string url = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// A package repository. -message PackageRepository { - // A specific type of repository. - oneof repository { - // An Apt Repository. - AptRepository apt = 1; - - // A Yum Repository. - YumRepository yum = 2; - - // A Zypper Repository. - ZypperRepository zypper = 3; - - // A Goo Repository. - GooRepository goo = 4; - } -} - -// A software recipe is a set of instructions for installing and configuring a -// piece of software. It consists of a set of artifacts that are -// downloaded, and a set of steps that install, configure, and/or update the -// software. -// -// Recipes support installing and updating software from artifacts in the -// following formats: -// Zip archive, Tar archive, Windows MSI, Debian package, and RPM package. -// -// Additionally, recipes support executing a script (either defined in a file or -// directly in this api) in bash, sh, cmd, and powershell. -// -// Updating a software recipe -// -// If a recipe is assigned to an instance and there is a recipe with the same -// name but a lower version already installed and the assigned state -// of the recipe is `UPDATED`, then the recipe is updated to -// the new version. -// -// Script Working Directories -// -// Each script or execution step is run in its own temporary directory which -// is deleted after completing the step. -message SoftwareRecipe { - // Specifies a resource to be used in the recipe. - message Artifact { - // Specifies an artifact available via some URI. - message Remote { - // URI from which to fetch the object. It should contain both the protocol - // and path following the format {protocol}://{location}. - string uri = 1; - - // Must be provided if `allow_insecure` is `false`. - // SHA256 checksum in hex format, to compare to the checksum of the - // artifact. If the checksum is not empty and it doesn't match the - // artifact then the recipe installation fails before running any of the - // steps. - string checksum = 2; - } - - // Specifies an artifact available as a Google Cloud Storage object. - message Gcs { - // Bucket of the Google Cloud Storage object. - // Given an example URL: - // `https://storage.googleapis.com/my-bucket/foo/bar#1234567` - // this value would be `my-bucket`. - string bucket = 1; - - // Name of the Google Cloud Storage object. - // As specified [here] - // (https://cloud.google.com/storage/docs/naming#objectnames) - // Given an example URL: - // `https://storage.googleapis.com/my-bucket/foo/bar#1234567` - // this value would be `foo/bar`. - string object = 2; - - // Must be provided if allow_insecure is false. - // Generation number of the Google Cloud Storage object. - // `https://storage.googleapis.com/my-bucket/foo/bar#1234567` - // this value would be `1234567`. - int64 generation = 3; - } - - // Required. Id of the artifact, which the installation and update steps of this - // recipe can reference. Artifacts in a recipe cannot have the same id. - string id = 1 [(google.api.field_behavior) = REQUIRED]; - - // A specific type of artifact. - oneof artifact { - // A generic remote artifact. - Remote remote = 2; - - // A Google Cloud Storage artifact. - Gcs gcs = 3; - } - - // Defaults to false. When false, recipes are subject to validations - // based on the artifact type: - // - // Remote: A checksum must be specified, and only protocols with - // transport-layer security are permitted. - // GCS: An object generation number must be specified. - bool allow_insecure = 4; - } - - // An action that can be taken as part of installing or updating a recipe. - message Step { - // Copies the artifact to the specified path on the instance. - message CopyFile { - // Required. The id of the relevant artifact in the recipe. - string artifact_id = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The absolute path on the instance to put the file. - string destination = 2 [(google.api.field_behavior) = REQUIRED]; - - // Whether to allow this step to overwrite existing files. If this is - // false and the file already exists the file is not overwritten - // and the step is considered a success. Defaults to false. - bool overwrite = 3; - - // Consists of three octal digits which represent, in - // order, the permissions of the owner, group, and other users for the - // file (similarly to the numeric mode used in the linux chmod utility). - // Each digit represents a three bit number with the 4 bit - // corresponding to the read permissions, the 2 bit corresponds to the - // write bit, and the one bit corresponds to the execute permission. - // Default behavior is 755. - // - // Below are some examples of permissions and their associated values: - // read, write, and execute: 7 - // read and execute: 5 - // read and write: 6 - // read only: 4 - string permissions = 4; - } - - // Extracts an archive of the type specified in the specified directory. - message ExtractArchive { - // Specifying the type of archive. - enum ArchiveType { - // Indicates that the archive type isn't specified. - ARCHIVE_TYPE_UNSPECIFIED = 0; - - // Indicates that the archive is a tar archive with no encryption. - TAR = 1; - - // Indicates that the archive is a tar archive with gzip encryption. - TAR_GZIP = 2; - - // Indicates that the archive is a tar archive with bzip encryption. - TAR_BZIP = 3; - - // Indicates that the archive is a tar archive with lzma encryption. - TAR_LZMA = 4; - - // Indicates that the archive is a tar archive with xz encryption. - TAR_XZ = 5; - - // Indicates that the archive is a zip archive. - ZIP = 11; - } - - // Required. The id of the relevant artifact in the recipe. - string artifact_id = 1 [(google.api.field_behavior) = REQUIRED]; - - // Directory to extract archive to. - // Defaults to `/` on Linux or `C:\` on Windows. - string destination = 2; - - // Required. The type of the archive to extract. - ArchiveType type = 3 [(google.api.field_behavior) = REQUIRED]; - } - - // Installs an MSI file. - message InstallMsi { - // Required. The id of the relevant artifact in the recipe. - string artifact_id = 1 [(google.api.field_behavior) = REQUIRED]; - - // The flags to use when installing the MSI - // defaults to ["/i"] (i.e. the install flag). - repeated string flags = 2; - - // Return codes that indicate that the software installed or updated - // successfully. Behaviour defaults to [0] - repeated int32 allowed_exit_codes = 3; - } - - // Installs a deb via dpkg. - message InstallDpkg { - // Required. The id of the relevant artifact in the recipe. - string artifact_id = 1 [(google.api.field_behavior) = REQUIRED]; - } - - // Installs an rpm file via the rpm utility. - message InstallRpm { - // Required. The id of the relevant artifact in the recipe. - string artifact_id = 1 [(google.api.field_behavior) = REQUIRED]; - } - - // Executes an artifact or local file. - message ExecFile { - // Location of the file to execute. - oneof location_type { - // The id of the relevant artifact in the recipe. - string artifact_id = 1; - - // The absolute path of the file on the local filesystem. - string local_path = 2; - } - - // Arguments to be passed to the provided executable. - repeated string args = 3; - - // Defaults to [0]. A list of possible return values that the program - // can return to indicate a success. - repeated int32 allowed_exit_codes = 4; - } - - // Runs a script through an interpreter. - message RunScript { - // The interpreter used to execute a script. - enum Interpreter { - // Default value for ScriptType. - INTERPRETER_UNSPECIFIED = 0; - - // Indicates that the script is run with `/bin/sh` on Linux and `cmd` - // on windows. - SHELL = 1; - - // Indicates that the script is run with powershell. - POWERSHELL = 3; - } - - // Required. The shell script to be executed. - string script = 1 [(google.api.field_behavior) = REQUIRED]; - - // Return codes that indicate that the software installed or updated - // successfully. Behaviour defaults to [0] - repeated int32 allowed_exit_codes = 2; - - // The script interpreter to use to run the script. If no interpreter is - // specified the script is executed directly, which likely - // only succeed for scripts with - // [shebang lines](https://en.wikipedia.org/wiki/Shebang_\(Unix\)). - Interpreter interpreter = 3; - } - - // A specific type of step. - oneof step { - // Copies a file onto the instance. - CopyFile file_copy = 1; - - // Extracts an archive into the specified directory. - ExtractArchive archive_extraction = 2; - - // Installs an MSI file. - InstallMsi msi_installation = 3; - - // Installs a deb file via dpkg. - InstallDpkg dpkg_installation = 4; - - // Installs an rpm file via the rpm utility. - InstallRpm rpm_installation = 5; - - // Executes an artifact or local file. - ExecFile file_exec = 6; - - // Runs commands in a shell. - RunScript script_run = 7; - } - } - - // Required. Unique identifier for the recipe. Only one recipe with a given name is - // installed on an instance. - // - // Names are also used to identify resources which helps to determine whether - // guest policies have conflicts. This means that requests to create multiple - // recipes with the same name and version are rejected since they - // could potentially have conflicting assignments. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // The version of this software recipe. Version can be up to 4 period - // separated numbers (e.g. 12.34.56.78). - string version = 2; - - // Resources available to be used in the steps in the recipe. - repeated Artifact artifacts = 3; - - // Actions to be taken for installing this recipe. On failure it stops - // executing steps and does not attempt another installation. Any steps taken - // (including partially completed steps) are not rolled back. - repeated Step install_steps = 4; - - // Actions to be taken for updating this recipe. On failure it stops - // executing steps and does not attempt another update for this recipe. Any - // steps taken (including partially completed steps) are not rolled back. - repeated Step update_steps = 5; - - // Default is INSTALLED. The desired state the agent should maintain for this - // recipe. - // - // INSTALLED: The software recipe is installed on the instance but - // won't be updated to new versions. - // UPDATED: The software recipe is installed on the instance. The recipe is - // updated to a higher version, if a higher version of the recipe is - // assigned to this instance. - // REMOVE: Remove is unsupported for software recipes and attempts to - // create or update a recipe to the REMOVE state is rejected. - DesiredState desired_state = 6; -} - -// A request message for creating a guest policy. -message CreateGuestPolicyRequest { - // Required. The resource name of the parent using one of the following forms: - // `projects/{project_number}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "osconfig.googleapis.com/GuestPolicy" - } - ]; - - // Required. The logical name of the guest policy in the project - // with the following restrictions: - // - // * Must contain only lowercase letters, numbers, and hyphens. - // * Must start with a letter. - // * Must be between 1-63 characters. - // * Must end with a number or a letter. - // * Must be unique within the project. - string guest_policy_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The GuestPolicy to create. - GuestPolicy guest_policy = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// A request message for retrieving a guest policy. -message GetGuestPolicyRequest { - // Required. The resource name of the guest policy using one of the following forms: - // `projects/{project_number}/guestPolicies/{guest_policy_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/GuestPolicy" - } - ]; -} - -// A request message for listing guest policies. -message ListGuestPoliciesRequest { - // Required. The resource name of the parent using one of the following forms: - // `projects/{project_number}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "osconfig.googleapis.com/GuestPolicy" - } - ]; - - // The maximum number of guest policies to return. - int32 page_size = 2; - - // A pagination token returned from a previous call to `ListGuestPolicies` - // that indicates where this listing should continue from. - string page_token = 3; -} - -// A response message for listing guest policies. -message ListGuestPoliciesResponse { - // The list of GuestPolicies. - repeated GuestPolicy guest_policies = 1; - - // A pagination token that can be used to get the next page - // of guest policies. - string next_page_token = 2; -} - -// A request message for updating a guest policy. -message UpdateGuestPolicyRequest { - // Required. The updated GuestPolicy. - GuestPolicy guest_policy = 1 [(google.api.field_behavior) = REQUIRED]; - - // Field mask that controls which fields of the guest policy should be - // updated. - google.protobuf.FieldMask update_mask = 2; -} - -// A request message for deleting a guest policy. -message DeleteGuestPolicyRequest { - // Required. The resource name of the guest policy using one of the following forms: - // `projects/{project_number}/guestPolicies/{guest_policy_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/GuestPolicy" - } - ]; -} - -// A request message for getting the effective guest policy assigned to the -// instance. -message LookupEffectiveGuestPolicyRequest { - // Required. The VM instance whose policies are being looked up. - string instance = 1 [(google.api.field_behavior) = REQUIRED]; - - // Short name of the OS running on the instance. The OS Config agent only - // provides this field for targeting if OS Inventory is enabled for that - // instance. - string os_short_name = 2; - - // Version of the OS running on the instance. The OS Config agent only - // provides this field for targeting if OS Inventory is enabled for that - // VM instance. - string os_version = 3; - - // Architecture of OS running on the instance. The OS Config agent only - // provides this field for targeting if OS Inventory is enabled for that - // instance. - string os_architecture = 4; -} - -// The effective guest policy that applies to a VM instance. -message EffectiveGuestPolicy { - // A guest policy package including its source. - message SourcedPackage { - // Name of the guest policy providing this config. - string source = 1; - - // A software package to configure on the VM instance. - Package package = 2; - } - - // A guest policy package repository including its source. - message SourcedPackageRepository { - // Name of the guest policy providing this config. - string source = 1; - - // A software package repository to configure on the VM instance. - PackageRepository package_repository = 2; - } - - // A guest policy recipe including its source. - message SourcedSoftwareRecipe { - // Name of the guest policy providing this config. - string source = 1; - - // A software recipe to configure on the VM instance. - SoftwareRecipe software_recipe = 2; - } - - // List of package configurations assigned to the VM instance. - repeated SourcedPackage packages = 1; - - // List of package repository configurations assigned to the VM instance. - repeated SourcedPackageRepository package_repositories = 2; - - // List of recipes assigned to the VM instance. - repeated SourcedSoftwareRecipe software_recipes = 3; -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/osconfig_common.proto b/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/osconfig_common.proto deleted file mode 100644 index 959b39c51fb..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/osconfig_common.proto +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.osconfig.v1beta; - - -option go_package = "cloud.google.com/go/osconfig/apiv1beta/osconfigpb;osconfigpb"; -option java_outer_classname = "Common"; -option java_package = "com.google.cloud.osconfig.v1beta"; - -// Message encapsulating a value that can be either absolute ("fixed") or -// relative ("percent") to a value. -message FixedOrPercent { - // Type of the value. - oneof mode { - // Specifies a fixed value. - int32 fixed = 1; - - // Specifies the relative value defined as a percentage, which will be - // multiplied by a reference value. - int32 percent = 2; - } -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/osconfig_service.proto b/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/osconfig_service.proto deleted file mode 100644 index 8882f2314d6..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/osconfig_service.proto +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.osconfig.v1beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/cloud/osconfig/v1beta/guest_policies.proto"; -import "google/cloud/osconfig/v1beta/patch_deployments.proto"; -import "google/cloud/osconfig/v1beta/patch_jobs.proto"; -import "google/protobuf/empty.proto"; - -option go_package = "cloud.google.com/go/osconfig/apiv1beta/osconfigpb;osconfigpb"; -option java_outer_classname = "OsConfigProto"; -option java_package = "com.google.cloud.osconfig.v1beta"; - -// OS Config API -// -// The OS Config service is a server-side component that you can use to -// manage package installations and patch jobs for virtual machine instances. -service OsConfigService { - option (google.api.default_host) = "osconfig.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Patch VM instances by creating and running a patch job. - rpc ExecutePatchJob(ExecutePatchJobRequest) returns (PatchJob) { - option (google.api.http) = { - post: "/v1beta/{parent=projects/*}/patchJobs:execute" - body: "*" - }; - } - - // Get the patch job. This can be used to track the progress of an - // ongoing patch job or review the details of completed jobs. - rpc GetPatchJob(GetPatchJobRequest) returns (PatchJob) { - option (google.api.http) = { - get: "/v1beta/{name=projects/*/patchJobs/*}" - }; - } - - // Cancel a patch job. The patch job must be active. Canceled patch jobs - // cannot be restarted. - rpc CancelPatchJob(CancelPatchJobRequest) returns (PatchJob) { - option (google.api.http) = { - post: "/v1beta/{name=projects/*/patchJobs/*}:cancel" - body: "*" - }; - } - - // Get a list of patch jobs. - rpc ListPatchJobs(ListPatchJobsRequest) returns (ListPatchJobsResponse) { - option (google.api.http) = { - get: "/v1beta/{parent=projects/*}/patchJobs" - }; - } - - // Get a list of instance details for a given patch job. - rpc ListPatchJobInstanceDetails(ListPatchJobInstanceDetailsRequest) returns (ListPatchJobInstanceDetailsResponse) { - option (google.api.http) = { - get: "/v1beta/{parent=projects/*/patchJobs/*}/instanceDetails" - }; - option (google.api.method_signature) = "parent"; - } - - // Create an OS Config patch deployment. - rpc CreatePatchDeployment(CreatePatchDeploymentRequest) returns (PatchDeployment) { - option (google.api.http) = { - post: "/v1beta/{parent=projects/*}/patchDeployments" - body: "patch_deployment" - }; - } - - // Get an OS Config patch deployment. - rpc GetPatchDeployment(GetPatchDeploymentRequest) returns (PatchDeployment) { - option (google.api.http) = { - get: "/v1beta/{name=projects/*/patchDeployments/*}" - }; - } - - // Get a page of OS Config patch deployments. - rpc ListPatchDeployments(ListPatchDeploymentsRequest) returns (ListPatchDeploymentsResponse) { - option (google.api.http) = { - get: "/v1beta/{parent=projects/*}/patchDeployments" - }; - } - - // Delete an OS Config patch deployment. - rpc DeletePatchDeployment(DeletePatchDeploymentRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1beta/{name=projects/*/patchDeployments/*}" - }; - } - - // Update an OS Config patch deployment. - rpc UpdatePatchDeployment(UpdatePatchDeploymentRequest) returns (PatchDeployment) { - option (google.api.http) = { - patch: "/v1beta/{patch_deployment.name=projects/*/patchDeployments/*}" - body: "patch_deployment" - }; - option (google.api.method_signature) = "patch_deployment,update_mask"; - } - - // Change state of patch deployment to "PAUSED". - // Patch deployment in paused state doesn't generate patch jobs. - rpc PausePatchDeployment(PausePatchDeploymentRequest) returns (PatchDeployment) { - option (google.api.http) = { - post: "/v1beta/{name=projects/*/patchDeployments/*}:pause" - body: "*" - }; - option (google.api.method_signature) = "name"; - } - - // Change state of patch deployment back to "ACTIVE". - // Patch deployment in active state continues to generate patch jobs. - rpc ResumePatchDeployment(ResumePatchDeploymentRequest) returns (PatchDeployment) { - option (google.api.http) = { - post: "/v1beta/{name=projects/*/patchDeployments/*}:resume" - body: "*" - }; - option (google.api.method_signature) = "name"; - } - - // Create an OS Config guest policy. - rpc CreateGuestPolicy(CreateGuestPolicyRequest) returns (GuestPolicy) { - option (google.api.http) = { - post: "/v1beta/{parent=projects/*}/guestPolicies" - body: "guest_policy" - }; - option (google.api.method_signature) = "parent, guest_policy"; - } - - // Get an OS Config guest policy. - rpc GetGuestPolicy(GetGuestPolicyRequest) returns (GuestPolicy) { - option (google.api.http) = { - get: "/v1beta/{name=projects/*/guestPolicies/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Get a page of OS Config guest policies. - rpc ListGuestPolicies(ListGuestPoliciesRequest) returns (ListGuestPoliciesResponse) { - option (google.api.http) = { - get: "/v1beta/{parent=projects/*}/guestPolicies" - }; - option (google.api.method_signature) = "parent"; - } - - // Update an OS Config guest policy. - rpc UpdateGuestPolicy(UpdateGuestPolicyRequest) returns (GuestPolicy) { - option (google.api.http) = { - patch: "/v1beta/{guest_policy.name=projects/*/guestPolicies/*}" - body: "guest_policy" - }; - option (google.api.method_signature) = "guest_policy,update_mask"; - } - - // Delete an OS Config guest policy. - rpc DeleteGuestPolicy(DeleteGuestPolicyRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1beta/{name=projects/*/guestPolicies/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lookup the effective guest policy that applies to a VM instance. This - // lookup merges all policies that are assigned to the instance ancestry. - rpc LookupEffectiveGuestPolicy(LookupEffectiveGuestPolicyRequest) returns (EffectiveGuestPolicy) { - option (google.api.http) = { - post: "/v1beta/{instance=projects/*/zones/*/instances/*}:lookupEffectiveGuestPolicy" - body: "*" - }; - } -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/patch_deployments.proto b/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/patch_deployments.proto deleted file mode 100644 index 127cc6a2c42..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/patch_deployments.proto +++ /dev/null @@ -1,295 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.osconfig.v1beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/osconfig/v1beta/patch_jobs.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/type/datetime.proto"; -import "google/type/dayofweek.proto"; -import "google/type/timeofday.proto"; - -option go_package = "cloud.google.com/go/osconfig/apiv1beta/osconfigpb;osconfigpb"; -option java_outer_classname = "PatchDeployments"; -option java_package = "com.google.cloud.osconfig.v1beta"; - -// Patch deployments are configurations that individual patch jobs use to -// complete a patch. These configurations include instance filter, package -// repository settings, and a schedule. For more information about creating and -// managing patch deployments, see [Scheduling patch -// jobs](https://cloud.google.com/compute/docs/os-patch-management/schedule-patch-jobs). -message PatchDeployment { - option (google.api.resource) = { - type: "osconfig.googleapis.com/PatchDeployment" - pattern: "projects/{project}/patchDeployments/{patch_deployment}" - }; - - // Represents state of patch peployment. - enum State { - // The default value. This value is used if the state is omitted. - STATE_UNSPECIFIED = 0; - - // Active value means that patch deployment generates Patch Jobs. - ACTIVE = 1; - - // Paused value means that patch deployment does not generate - // Patch jobs. Requires user action to move in and out from this state. - PAUSED = 2; - } - - // Unique name for the patch deployment resource in a project. The patch - // deployment name is in the form: - // `projects/{project_id}/patchDeployments/{patch_deployment_id}`. - // This field is ignored when you create a new patch deployment. - string name = 1; - - // Optional. Description of the patch deployment. Length of the description is limited - // to 1024 characters. - string description = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Required. VM instances to patch. - PatchInstanceFilter instance_filter = 3 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Patch configuration that is applied. - PatchConfig patch_config = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Duration of the patch. After the duration ends, the patch times out. - google.protobuf.Duration duration = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Schedule for the patch. - oneof schedule { - // Required. Schedule a one-time execution. - OneTimeSchedule one_time_schedule = 6 [(google.api.field_behavior) = REQUIRED]; - - // Required. Schedule recurring executions. - RecurringSchedule recurring_schedule = 7 [(google.api.field_behavior) = REQUIRED]; - } - - // Output only. Time the patch deployment was created. Timestamp is in - // [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text format. - google.protobuf.Timestamp create_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Time the patch deployment was last updated. Timestamp is in - // [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text format. - google.protobuf.Timestamp update_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The last time a patch job was started by this deployment. - // Timestamp is in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text - // format. - google.protobuf.Timestamp last_execute_time = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Rollout strategy of the patch job. - PatchRollout rollout = 11 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. Current state of the patch deployment. - State state = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Sets the time for a one time patch deployment. Timestamp is in -// [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text format. -message OneTimeSchedule { - // Required. The desired patch job execution time. - google.protobuf.Timestamp execute_time = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Sets the time for recurring patch deployments. -message RecurringSchedule { - // Specifies the frequency of the recurring patch deployments. - enum Frequency { - // Invalid. A frequency must be specified. - FREQUENCY_UNSPECIFIED = 0; - - // Indicates that the frequency of recurrence should be expressed in terms - // of weeks. - WEEKLY = 1; - - // Indicates that the frequency of recurrence should be expressed in terms - // of months. - MONTHLY = 2; - - // Indicates that the frequency of recurrence should be expressed in terms - // of days. - DAILY = 3; - } - - // Required. Defines the time zone that `time_of_day` is relative to. - // The rules for daylight saving time are determined by the chosen time zone. - google.type.TimeZone time_zone = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The time that the recurring schedule becomes effective. - // Defaults to `create_time` of the patch deployment. - google.protobuf.Timestamp start_time = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The end time at which a recurring patch deployment schedule is no longer - // active. - google.protobuf.Timestamp end_time = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Required. Time of the day to run a recurring deployment. - google.type.TimeOfDay time_of_day = 4 [(google.api.field_behavior) = REQUIRED]; - - // Required. The frequency unit of this recurring schedule. - Frequency frequency = 5 [(google.api.field_behavior) = REQUIRED]; - - // Configurations for this recurring schedule. - // Configurations must match frequency. - oneof schedule_config { - // Required. Schedule with weekly executions. - WeeklySchedule weekly = 6 [(google.api.field_behavior) = REQUIRED]; - - // Required. Schedule with monthly executions. - MonthlySchedule monthly = 7 [(google.api.field_behavior) = REQUIRED]; - } - - // Output only. The time the last patch job ran successfully. - google.protobuf.Timestamp last_execute_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time the next patch job is scheduled to run. - google.protobuf.Timestamp next_execute_time = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Represents a weekly schedule. -message WeeklySchedule { - // Required. Day of the week. - google.type.DayOfWeek day_of_week = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Represents a monthly schedule. An example of a valid monthly schedule is -// "on the third Tuesday of the month" or "on the 15th of the month". -message MonthlySchedule { - // One day in a month. - oneof day_of_month { - // Required. Week day in a month. - WeekDayOfMonth week_day_of_month = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. One day of the month. 1-31 indicates the 1st to the 31st day. -1 - // indicates the last day of the month. - // Months without the target day will be skipped. For example, a schedule to - // run "every month on the 31st" will not run in February, April, June, etc. - int32 month_day = 2 [(google.api.field_behavior) = REQUIRED]; - } -} - -// Represents one week day in a month. An example is "the 4th Sunday". -message WeekDayOfMonth { - // Required. Week number in a month. 1-4 indicates the 1st to 4th week of the month. -1 - // indicates the last week of the month. - int32 week_ordinal = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. A day of the week. - google.type.DayOfWeek day_of_week = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Represents the number of days before or after the given week day of month - // that the patch deployment is scheduled for. For example if `week_ordinal` - // and `day_of_week` values point to the second day of the month and this - // `day_offset` value is set to `3`, the patch deployment takes place three - // days after the second Tuesday of the month. If this value is negative, for - // example -5, the patches are deployed five days before before the second - // Tuesday of the month. Allowed values are in range `[-30, 30]`. - int32 day_offset = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// A request message for creating a patch deployment. -message CreatePatchDeploymentRequest { - // Required. The project to apply this patch deployment to in the form `projects/*`. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. A name for the patch deployment in the project. When creating a name - // the following rules apply: - // * Must contain only lowercase letters, numbers, and hyphens. - // * Must start with a letter. - // * Must be between 1-63 characters. - // * Must end with a number or a letter. - // * Must be unique within the project. - string patch_deployment_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The patch deployment to create. - PatchDeployment patch_deployment = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// A request message for retrieving a patch deployment. -message GetPatchDeploymentRequest { - // Required. The resource name of the patch deployment in the form - // `projects/*/patchDeployments/*`. - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// A request message for listing patch deployments. -message ListPatchDeploymentsRequest { - // Required. The resource name of the parent in the form `projects/*`. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The maximum number of patch deployments to return. Default is 100. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A pagination token returned from a previous call to ListPatchDeployments - // that indicates where this listing should continue from. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// A response message for listing patch deployments. -message ListPatchDeploymentsResponse { - // The list of patch deployments. - repeated PatchDeployment patch_deployments = 1; - - // A pagination token that can be used to get the next page of patch - // deployments. - string next_page_token = 2; -} - -// A request message for deleting a patch deployment. -message DeletePatchDeploymentRequest { - // Required. The resource name of the patch deployment in the form - // `projects/*/patchDeployments/*`. - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// A request message for updating a patch deployment. -message UpdatePatchDeploymentRequest { - // Required. The patch deployment to Update. - PatchDeployment patch_deployment = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Field mask that controls which fields of the patch deployment should be - // updated. - google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// A request message for pausing a patch deployment. -message PausePatchDeploymentRequest { - // Required. The resource name of the patch deployment in the form - // `projects/*/patchDeployments/*`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/PatchDeployment" - } - ]; -} - -// A request message for resuming a patch deployment. -message ResumePatchDeploymentRequest { - // Required. The resource name of the patch deployment in the form - // `projects/*/patchDeployments/*`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "osconfig.googleapis.com/PatchDeployment" - } - ]; -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/patch_jobs.proto b/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/patch_jobs.proto deleted file mode 100644 index c691bc7e6a7..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/protos/google/cloud/osconfig/v1beta/patch_jobs.proto +++ /dev/null @@ -1,702 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.osconfig.v1beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/osconfig/v1beta/osconfig_common.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "cloud.google.com/go/osconfig/apiv1beta/osconfigpb;osconfigpb"; -option java_outer_classname = "PatchJobs"; -option java_package = "com.google.cloud.osconfig.v1beta"; - -// A request message to initiate patching across Compute Engine instances. -message ExecutePatchJobRequest { - // Required. The project in which to run this patch in the form `projects/*` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Description of the patch job. Length of the description is limited - // to 1024 characters. - string description = 2; - - // Required. Instances to patch, either explicitly or filtered by some criteria such - // as zone or labels. - PatchInstanceFilter instance_filter = 7 [(google.api.field_behavior) = REQUIRED]; - - // Patch configuration being applied. If omitted, instances are - // patched using the default configurations. - PatchConfig patch_config = 4; - - // Duration of the patch job. After the duration ends, the patch job - // times out. - google.protobuf.Duration duration = 5; - - // If this patch is a dry-run only, instances are contacted but - // will do nothing. - bool dry_run = 6; - - // Display name for this patch job. This does not have to be unique. - string display_name = 8; - - // Rollout strategy of the patch job. - PatchRollout rollout = 9; -} - -// Request to get an active or completed patch job. -message GetPatchJobRequest { - // Required. Name of the patch in the form `projects/*/patchJobs/*` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request to list details for all instances that are part of a patch job. -message ListPatchJobInstanceDetailsRequest { - // Required. The parent for the instances are in the form of `projects/*/patchJobs/*`. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // The maximum number of instance details records to return. Default is 100. - int32 page_size = 2; - - // A pagination token returned from a previous call - // that indicates where this listing should continue from. - string page_token = 3; - - // A filter expression that filters results listed in the response. This - // field supports filtering results by instance zone, name, state, or - // `failure_reason`. - string filter = 4; -} - -// A response message for listing the instances details for a patch job. -message ListPatchJobInstanceDetailsResponse { - // A list of instance status. - repeated PatchJobInstanceDetails patch_job_instance_details = 1; - - // A pagination token that can be used to get the next page of results. - string next_page_token = 2; -} - -// Patch details for a VM instance. For more information about reviewing VM -// instance details, see -// [Listing all VM instance details for a specific patch -// job](https://cloud.google.com/compute/docs/os-patch-management/manage-patch-jobs#list-instance-details). -message PatchJobInstanceDetails { - // The instance name in the form `projects/*/zones/*/instances/*` - string name = 1; - - // The unique identifier for the instance. This identifier is - // defined by the server. - string instance_system_id = 2; - - // Current state of instance patch. - Instance.PatchState state = 3; - - // If the patch fails, this field provides the reason. - string failure_reason = 4; - - // The number of times the agent that the agent attempts to apply the patch. - int64 attempt_count = 5; -} - -// A request message for listing patch jobs. -message ListPatchJobsRequest { - // Required. In the form of `projects/*` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // The maximum number of instance status to return. - int32 page_size = 2; - - // A pagination token returned from a previous call - // that indicates where this listing should continue from. - string page_token = 3; - - // If provided, this field specifies the criteria that must be met by patch - // jobs to be included in the response. - // Currently, filtering is only available on the patch_deployment field. - string filter = 4; -} - -// A response message for listing patch jobs. -message ListPatchJobsResponse { - // The list of patch jobs. - repeated PatchJob patch_jobs = 1; - - // A pagination token that can be used to get the next page of results. - string next_page_token = 2; -} - -// A high level representation of a patch job that is either in progress -// or has completed. -// -// Instance details are not included in the job. To paginate through instance -// details, use `ListPatchJobInstanceDetails`. -// -// For more information about patch jobs, see -// [Creating patch -// jobs](https://cloud.google.com/compute/docs/os-patch-management/create-patch-job). -message PatchJob { - option (google.api.resource) = { - type: "osconfig.googleapis.com/PatchJob" - pattern: "projects/{project}/patchJobs/{patch_job}" - }; - - // Enumeration of the various states a patch job passes through as it - // executes. - enum State { - // State must be specified. - STATE_UNSPECIFIED = 0; - - // The patch job was successfully initiated. - STARTED = 1; - - // The patch job is looking up instances to run the patch on. - INSTANCE_LOOKUP = 2; - - // Instances are being patched. - PATCHING = 3; - - // Patch job completed successfully. - SUCCEEDED = 4; - - // Patch job completed but there were errors. - COMPLETED_WITH_ERRORS = 5; - - // The patch job was canceled. - CANCELED = 6; - - // The patch job timed out. - TIMED_OUT = 7; - } - - // A summary of the current patch state across all instances that this patch - // job affects. Contains counts of instances in different states. These states - // map to `InstancePatchState`. List patch job instance details to see the - // specific states of each instance. - message InstanceDetailsSummary { - // Number of instances pending patch job. - int64 pending_instance_count = 1; - - // Number of instances that are inactive. - int64 inactive_instance_count = 2; - - // Number of instances notified about patch job. - int64 notified_instance_count = 3; - - // Number of instances that have started. - int64 started_instance_count = 4; - - // Number of instances that are downloading patches. - int64 downloading_patches_instance_count = 5; - - // Number of instances that are applying patches. - int64 applying_patches_instance_count = 6; - - // Number of instances rebooting. - int64 rebooting_instance_count = 7; - - // Number of instances that have completed successfully. - int64 succeeded_instance_count = 8; - - // Number of instances that require reboot. - int64 succeeded_reboot_required_instance_count = 9; - - // Number of instances that failed. - int64 failed_instance_count = 10; - - // Number of instances that have acked and will start shortly. - int64 acked_instance_count = 11; - - // Number of instances that exceeded the time out while applying the patch. - int64 timed_out_instance_count = 12; - - // Number of instances that are running the pre-patch step. - int64 pre_patch_step_instance_count = 13; - - // Number of instances that are running the post-patch step. - int64 post_patch_step_instance_count = 14; - - // Number of instances that do not appear to be running the agent. Check to - // ensure that the agent is installed, running, and able to communicate with - // the service. - int64 no_agent_detected_instance_count = 15; - } - - // Unique identifier for this patch job in the form - // `projects/*/patchJobs/*` - string name = 1; - - // Display name for this patch job. This is not a unique identifier. - string display_name = 14; - - // Description of the patch job. Length of the description is limited - // to 1024 characters. - string description = 2; - - // Time this patch job was created. - google.protobuf.Timestamp create_time = 3; - - // Last time this patch job was updated. - google.protobuf.Timestamp update_time = 4; - - // The current state of the PatchJob. - State state = 5; - - // Instances to patch. - PatchInstanceFilter instance_filter = 13; - - // Patch configuration being applied. - PatchConfig patch_config = 7; - - // Duration of the patch job. After the duration ends, the - // patch job times out. - google.protobuf.Duration duration = 8; - - // Summary of instance details. - InstanceDetailsSummary instance_details_summary = 9; - - // If this patch job is a dry run, the agent reports that it has - // finished without running any updates on the VM instance. - bool dry_run = 10; - - // If this patch job failed, this message provides information about the - // failure. - string error_message = 11; - - // Reflects the overall progress of the patch job in the range of - // 0.0 being no progress to 100.0 being complete. - double percent_complete = 12; - - // Output only. Name of the patch deployment that created this patch job. - string patch_deployment = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Rollout strategy being applied. - PatchRollout rollout = 16; -} - -// Patch configuration specifications. Contains details on how to apply the -// patch(es) to a VM instance. -message PatchConfig { - // Post-patch reboot settings. - enum RebootConfig { - // The default behavior is DEFAULT. - REBOOT_CONFIG_UNSPECIFIED = 0; - - // The agent decides if a reboot is necessary by checking signals such as - // registry keys on Windows or `/var/run/reboot-required` on APT based - // systems. On RPM based systems, a set of core system package install times - // are compared with system boot time. - DEFAULT = 1; - - // Always reboot the machine after the update completes. - ALWAYS = 2; - - // Never reboot the machine after the update completes. - NEVER = 3; - } - - // Post-patch reboot settings. - RebootConfig reboot_config = 1; - - // Apt update settings. Use this setting to override the default `apt` patch - // rules. - AptSettings apt = 3; - - // Yum update settings. Use this setting to override the default `yum` patch - // rules. - YumSettings yum = 4; - - // Goo update settings. Use this setting to override the default `goo` patch - // rules. - GooSettings goo = 5; - - // Zypper update settings. Use this setting to override the default `zypper` - // patch rules. - ZypperSettings zypper = 6; - - // Windows update settings. Use this override the default windows patch rules. - WindowsUpdateSettings windows_update = 7; - - // The `ExecStep` to run before the patch update. - ExecStep pre_step = 8; - - // The `ExecStep` to run after the patch update. - ExecStep post_step = 9; - - // Allows the patch job to run on Managed instance groups (MIGs). - bool mig_instances_allowed = 10; -} - -// Namespace for instance state enums. -message Instance { - // Patch state of an instance. - enum PatchState { - // Unspecified. - PATCH_STATE_UNSPECIFIED = 0; - - // The instance is not yet notified. - PENDING = 1; - - // Instance is inactive and cannot be patched. - INACTIVE = 2; - - // The instance is notified that it should be patched. - NOTIFIED = 3; - - // The instance has started the patching process. - STARTED = 4; - - // The instance is downloading patches. - DOWNLOADING_PATCHES = 5; - - // The instance is applying patches. - APPLYING_PATCHES = 6; - - // The instance is rebooting. - REBOOTING = 7; - - // The instance has completed applying patches. - SUCCEEDED = 8; - - // The instance has completed applying patches but a reboot is required. - SUCCEEDED_REBOOT_REQUIRED = 9; - - // The instance has failed to apply the patch. - FAILED = 10; - - // The instance acked the notification and will start shortly. - ACKED = 11; - - // The instance exceeded the time out while applying the patch. - TIMED_OUT = 12; - - // The instance is running the pre-patch step. - RUNNING_PRE_PATCH_STEP = 13; - - // The instance is running the post-patch step. - RUNNING_POST_PATCH_STEP = 14; - - // The service could not detect the presence of the agent. Check to ensure - // that the agent is installed, running, and able to communicate with the - // service. - NO_AGENT_DETECTED = 15; - } - - -} - -// Message for canceling a patch job. -message CancelPatchJobRequest { - // Required. Name of the patch in the form `projects/*/patchJobs/*` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Apt patching is completed by executing `apt-get update && apt-get -// upgrade`. Additional options can be set to control how this is executed. -message AptSettings { - // Apt patch type. - enum Type { - // By default, upgrade will be performed. - TYPE_UNSPECIFIED = 0; - - // Runs `apt-get dist-upgrade`. - DIST = 1; - - // Runs `apt-get upgrade`. - UPGRADE = 2; - } - - // By changing the type to DIST, the patching is performed - // using `apt-get dist-upgrade` instead. - Type type = 1; - - // List of packages to exclude from update. These packages will be excluded - repeated string excludes = 2; - - // An exclusive list of packages to be updated. These are the only packages - // that will be updated. If these packages are not installed, they will be - // ignored. This field cannot be specified with any other patch configuration - // fields. - repeated string exclusive_packages = 3; -} - -// Yum patching is performed by executing `yum update`. Additional options -// can be set to control how this is executed. -// -// Note that not all settings are supported on all platforms. -message YumSettings { - // Adds the `--security` flag to `yum update`. Not supported on - // all platforms. - bool security = 1; - - // Will cause patch to run `yum update-minimal` instead. - bool minimal = 2; - - // List of packages to exclude from update. These packages are excluded by - // using the yum `--exclude` flag. - repeated string excludes = 3; - - // An exclusive list of packages to be updated. These are the only packages - // that will be updated. If these packages are not installed, they will be - // ignored. This field must not be specified with any other patch - // configuration fields. - repeated string exclusive_packages = 4; -} - -// Googet patching is performed by running `googet update`. -message GooSettings { - -} - -// Zypper patching is performed by running `zypper patch`. -// See also https://en.opensuse.org/SDB:Zypper_manual. -message ZypperSettings { - // Adds the `--with-optional` flag to `zypper patch`. - bool with_optional = 1; - - // Adds the `--with-update` flag, to `zypper patch`. - bool with_update = 2; - - // Install only patches with these categories. - // Common categories include security, recommended, and feature. - repeated string categories = 3; - - // Install only patches with these severities. - // Common severities include critical, important, moderate, and low. - repeated string severities = 4; - - // List of patches to exclude from update. - repeated string excludes = 5; - - // An exclusive list of patches to be updated. These are the only patches - // that will be installed using 'zypper patch patch:' command. - // This field must not be used with any other patch configuration fields. - repeated string exclusive_patches = 6; -} - -// Windows patching is performed using the Windows Update Agent. -message WindowsUpdateSettings { - // Microsoft Windows update classifications as defined in - // [1] - // https://support.microsoft.com/en-us/help/824684/description-of-the-standard-terminology-that-is-used-to-describe-micro - enum Classification { - // Invalid. If classifications are included, they must be specified. - CLASSIFICATION_UNSPECIFIED = 0; - - // "A widely released fix for a specific problem that addresses a critical, - // non-security-related bug." [1] - CRITICAL = 1; - - // "A widely released fix for a product-specific, security-related - // vulnerability. Security vulnerabilities are rated by their severity. The - // severity rating is indicated in the Microsoft security bulletin as - // critical, important, moderate, or low." [1] - SECURITY = 2; - - // "A widely released and frequent software update that contains additions - // to a product's definition database. Definition databases are often used - // to detect objects that have specific attributes, such as malicious code, - // phishing websites, or junk mail." [1] - DEFINITION = 3; - - // "Software that controls the input and output of a device." [1] - DRIVER = 4; - - // "New product functionality that is first distributed outside the context - // of a product release and that is typically included in the next full - // product release." [1] - FEATURE_PACK = 5; - - // "A tested, cumulative set of all hotfixes, security updates, critical - // updates, and updates. Additionally, service packs may contain additional - // fixes for problems that are found internally since the release of the - // product. Service packs my also contain a limited number of - // customer-requested design changes or features." [1] - SERVICE_PACK = 6; - - // "A utility or feature that helps complete a task or set of tasks." [1] - TOOL = 7; - - // "A tested, cumulative set of hotfixes, security updates, critical - // updates, and updates that are packaged together for easy deployment. A - // rollup generally targets a specific area, such as security, or a - // component of a product, such as Internet Information Services (IIS)." [1] - UPDATE_ROLLUP = 8; - - // "A widely released fix for a specific problem. An update addresses a - // noncritical, non-security-related bug." [1] - UPDATE = 9; - } - - // Only apply updates of these windows update classifications. If empty, all - // updates are applied. - repeated Classification classifications = 1; - - // List of KBs to exclude from update. - repeated string excludes = 2; - - // An exclusive list of kbs to be updated. These are the only patches - // that will be updated. This field must not be used with other - // patch configurations. - repeated string exclusive_patches = 3; -} - -// A step that runs an executable for a PatchJob. -message ExecStep { - // The ExecStepConfig for all Linux VMs targeted by the PatchJob. - ExecStepConfig linux_exec_step_config = 1; - - // The ExecStepConfig for all Windows VMs targeted by the PatchJob. - ExecStepConfig windows_exec_step_config = 2; -} - -// Common configurations for an ExecStep. -message ExecStepConfig { - // The interpreter used to execute the a file. - enum Interpreter { - // Invalid for a Windows ExecStepConfig. For a Linux ExecStepConfig, the - // interpreter will be parsed from the shebang line of the script if - // unspecified. - INTERPRETER_UNSPECIFIED = 0; - - // Indicates that the script is run with `/bin/sh` on Linux and `cmd` - // on Windows. - SHELL = 1; - - // Indicates that the file is run with PowerShell flags - // `-NonInteractive`, `-NoProfile`, and `-ExecutionPolicy Bypass`. - POWERSHELL = 2; - } - - // Location of the executable. - oneof executable { - // An absolute path to the executable on the VM. - string local_path = 1; - - // A Google Cloud Storage object containing the executable. - GcsObject gcs_object = 2; - } - - // Defaults to [0]. A list of possible return values that the - // execution can return to indicate a success. - repeated int32 allowed_success_codes = 3; - - // The script interpreter to use to run the script. If no interpreter is - // specified the script will be executed directly, which will likely - // only succeed for scripts with [shebang lines] - // (https://en.wikipedia.org/wiki/Shebang_\(Unix\)). - Interpreter interpreter = 4; -} - -// Google Cloud Storage object representation. -message GcsObject { - // Required. Bucket of the Google Cloud Storage object. - string bucket = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Name of the Google Cloud Storage object. - string object = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. Generation number of the Google Cloud Storage object. This is used to - // ensure that the ExecStep specified by this PatchJob does not change. - int64 generation_number = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// A filter to target VM instances for patching. The targeted -// VMs must meet all criteria specified. So if both labels and zones are -// specified, the patch job targets only VMs with those labels and in those -// zones. -message PatchInstanceFilter { - // Represents a group of VMs that can be identified as having all these - // labels, for example "env=prod and app=web". - message GroupLabel { - // Compute Engine instance labels that must be present for a VM instance to - // be targeted by this filter. - map labels = 1; - } - - // Target all VM instances in the project. If true, no other criteria is - // permitted. - bool all = 1; - - // Targets VM instances matching at least one of these label sets. This allows - // targeting of disparate groups, for example "env=prod or env=staging". - repeated GroupLabel group_labels = 2; - - // Targets VM instances in ANY of these zones. Leave empty to target VM - // instances in any zone. - repeated string zones = 3; - - // Targets any of the VM instances specified. Instances are specified by their - // URI in the form `zones/[ZONE]/instances/[INSTANCE_NAME]`, - // `projects/[PROJECT_ID]/zones/[ZONE]/instances/[INSTANCE_NAME]`, or - // `https://www.googleapis.com/compute/v1/projects/[PROJECT_ID]/zones/[ZONE]/instances/[INSTANCE_NAME]` - repeated string instances = 4; - - // Targets VMs whose name starts with one of these prefixes. Similar to - // labels, this is another way to group VMs when targeting configs, for - // example prefix="prod-". - repeated string instance_name_prefixes = 5; -} - -// Patch rollout configuration specifications. Contains details on the -// concurrency control when applying patch(es) to all targeted VMs. -message PatchRollout { - // Type of the rollout. - enum Mode { - // Mode must be specified. - MODE_UNSPECIFIED = 0; - - // Patches are applied one zone at a time. The patch job begins in the - // region with the lowest number of targeted VMs. Within the region, - // patching begins in the zone with the lowest number of targeted VMs. If - // multiple regions (or zones within a region) have the same number of - // targeted VMs, a tie-breaker is achieved by sorting the regions or zones - // in alphabetical order. - ZONE_BY_ZONE = 1; - - // Patches are applied to VMs in all zones at the same time. - CONCURRENT_ZONES = 2; - } - - // Mode of the patch rollout. - Mode mode = 1; - - // The maximum number (or percentage) of VMs per zone to disrupt at any given - // moment. The number of VMs calculated from multiplying the percentage by the - // total number of VMs in a zone is rounded up. - // - // During patching, a VM is considered disrupted from the time the agent is - // notified to begin until patching has completed. This disruption time - // includes the time to complete reboot and any post-patch steps. - // - // A VM contributes to the disruption budget if its patching operation fails - // either when applying the patches, running pre or post patch steps, or if it - // fails to respond with a success notification before timing out. VMs that - // are not running or do not have an active agent do not count toward this - // disruption budget. - // - // For zone-by-zone rollouts, if the disruption budget in a zone is exceeded, - // the patch job stops, because continuing to the next zone requires - // completion of the patch process in the previous zone. - // - // For example, if the disruption budget has a fixed value of `10`, and 8 VMs - // fail to patch in the current zone, the patch job continues to patch 2 VMs - // at a time until the zone is completed. When that zone is completed - // successfully, patching begins with 10 VMs at a time in the next zone. If 10 - // VMs in the next zone fail to patch, the patch job stops. - FixedOrPercent disruption_budget = 2; -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.cancel_patch_job.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.cancel_patch_job.js deleted file mode 100644 index f416929f363..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.cancel_patch_job.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(name) { - // [START osconfig_v1beta_generated_OsConfigService_CancelPatchJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the patch in the form `projects/* /patchJobs/*` - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callCancelPatchJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.cancelPatchJob(request); - console.log(response); - } - - callCancelPatchJob(); - // [END osconfig_v1beta_generated_OsConfigService_CancelPatchJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.create_guest_policy.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.create_guest_policy.js deleted file mode 100644 index 2ef34afce6f..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.create_guest_policy.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(parent, guestPolicyId, guestPolicy) { - // [START osconfig_v1beta_generated_OsConfigService_CreateGuestPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 parent using one of the following forms: - * `projects/{project_number}`. - */ - // const parent = 'abc123' - /** - * Required. The logical name of the guest policy in the project - * with the following restrictions: - * * Must contain only lowercase letters, numbers, and hyphens. - * * Must start with a letter. - * * Must be between 1-63 characters. - * * Must end with a number or a letter. - * * Must be unique within the project. - */ - // const guestPolicyId = 'abc123' - /** - * Required. The GuestPolicy to create. - */ - // const guestPolicy = {} - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callCreateGuestPolicy() { - // Construct request - const request = { - parent, - guestPolicyId, - guestPolicy, - }; - - // Run request - const response = await osconfigClient.createGuestPolicy(request); - console.log(response); - } - - callCreateGuestPolicy(); - // [END osconfig_v1beta_generated_OsConfigService_CreateGuestPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.create_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.create_patch_deployment.js deleted file mode 100644 index a072db41e61..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.create_patch_deployment.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(parent, patchDeploymentId, patchDeployment) { - // [START osconfig_v1beta_generated_OsConfigService_CreatePatchDeployment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project to apply this patch deployment to in the form `projects/*`. - */ - // const parent = 'abc123' - /** - * Required. A name for the patch deployment in the project. When creating a name - * the following rules apply: - * * Must contain only lowercase letters, numbers, and hyphens. - * * Must start with a letter. - * * Must be between 1-63 characters. - * * Must end with a number or a letter. - * * Must be unique within the project. - */ - // const patchDeploymentId = 'abc123' - /** - * Required. The patch deployment to create. - */ - // const patchDeployment = {} - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callCreatePatchDeployment() { - // Construct request - const request = { - parent, - patchDeploymentId, - patchDeployment, - }; - - // Run request - const response = await osconfigClient.createPatchDeployment(request); - console.log(response); - } - - callCreatePatchDeployment(); - // [END osconfig_v1beta_generated_OsConfigService_CreatePatchDeployment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.delete_guest_policy.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.delete_guest_policy.js deleted file mode 100644 index 6166760d8b7..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.delete_guest_policy.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 osconfig_v1beta_generated_OsConfigService_DeleteGuestPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 guest policy using one of the following forms: - * `projects/{project_number}/guestPolicies/{guest_policy_id}`. - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callDeleteGuestPolicy() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.deleteGuestPolicy(request); - console.log(response); - } - - callDeleteGuestPolicy(); - // [END osconfig_v1beta_generated_OsConfigService_DeleteGuestPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.delete_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.delete_patch_deployment.js deleted file mode 100644 index 9cd6977fc63..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.delete_patch_deployment.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 osconfig_v1beta_generated_OsConfigService_DeletePatchDeployment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 patch deployment in the form - * `projects/* /patchDeployments/*`. - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callDeletePatchDeployment() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.deletePatchDeployment(request); - console.log(response); - } - - callDeletePatchDeployment(); - // [END osconfig_v1beta_generated_OsConfigService_DeletePatchDeployment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.execute_patch_job.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.execute_patch_job.js deleted file mode 100644 index e7960e492b5..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.execute_patch_job.js +++ /dev/null @@ -1,95 +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, instanceFilter) { - // [START osconfig_v1beta_generated_OsConfigService_ExecutePatchJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project in which to run this patch in the form `projects/*` - */ - // const parent = 'abc123' - /** - * Description of the patch job. Length of the description is limited - * to 1024 characters. - */ - // const description = 'abc123' - /** - * Required. Instances to patch, either explicitly or filtered by some criteria such - * as zone or labels. - */ - // const instanceFilter = {} - /** - * Patch configuration being applied. If omitted, instances are - * patched using the default configurations. - */ - // const patchConfig = {} - /** - * Duration of the patch job. After the duration ends, the patch job - * times out. - */ - // const duration = {} - /** - * If this patch is a dry-run only, instances are contacted but - * will do nothing. - */ - // const dryRun = true - /** - * Display name for this patch job. This does not have to be unique. - */ - // const displayName = 'abc123' - /** - * Rollout strategy of the patch job. - */ - // const rollout = {} - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callExecutePatchJob() { - // Construct request - const request = { - parent, - instanceFilter, - }; - - // Run request - const response = await osconfigClient.executePatchJob(request); - console.log(response); - } - - callExecutePatchJob(); - // [END osconfig_v1beta_generated_OsConfigService_ExecutePatchJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_guest_policy.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_guest_policy.js deleted file mode 100644 index 08fac67b889..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_guest_policy.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 osconfig_v1beta_generated_OsConfigService_GetGuestPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 guest policy using one of the following forms: - * `projects/{project_number}/guestPolicies/{guest_policy_id}`. - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callGetGuestPolicy() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.getGuestPolicy(request); - console.log(response); - } - - callGetGuestPolicy(); - // [END osconfig_v1beta_generated_OsConfigService_GetGuestPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_patch_deployment.js deleted file mode 100644 index 8e8b7411017..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_patch_deployment.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 osconfig_v1beta_generated_OsConfigService_GetPatchDeployment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 patch deployment in the form - * `projects/* /patchDeployments/*`. - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callGetPatchDeployment() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.getPatchDeployment(request); - console.log(response); - } - - callGetPatchDeployment(); - // [END osconfig_v1beta_generated_OsConfigService_GetPatchDeployment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_patch_job.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_patch_job.js deleted file mode 100644 index c5f93158ce3..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.get_patch_job.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(name) { - // [START osconfig_v1beta_generated_OsConfigService_GetPatchJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the patch in the form `projects/* /patchJobs/*` - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callGetPatchJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.getPatchJob(request); - console.log(response); - } - - callGetPatchJob(); - // [END osconfig_v1beta_generated_OsConfigService_GetPatchJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_guest_policies.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_guest_policies.js deleted file mode 100644 index 4a740ddd7ce..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_guest_policies.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(parent) { - // [START osconfig_v1beta_generated_OsConfigService_ListGuestPolicies_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 parent using one of the following forms: - * `projects/{project_number}`. - */ - // const parent = 'abc123' - /** - * The maximum number of guest policies to return. - */ - // const pageSize = 1234 - /** - * A pagination token returned from a previous call to `ListGuestPolicies` - * that indicates where this listing should continue from. - */ - // const pageToken = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callListGuestPolicies() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await osconfigClient.listGuestPoliciesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListGuestPolicies(); - // [END osconfig_v1beta_generated_OsConfigService_ListGuestPolicies_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_deployments.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_deployments.js deleted file mode 100644 index cf3091a217c..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_deployments.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) { - // [START osconfig_v1beta_generated_OsConfigService_ListPatchDeployments_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 parent in the form `projects/*`. - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of patch deployments to return. Default is 100. - */ - // const pageSize = 1234 - /** - * Optional. A pagination token returned from a previous call to ListPatchDeployments - * that indicates where this listing should continue from. - */ - // const pageToken = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callListPatchDeployments() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await osconfigClient.listPatchDeploymentsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListPatchDeployments(); - // [END osconfig_v1beta_generated_OsConfigService_ListPatchDeployments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_job_instance_details.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_job_instance_details.js deleted file mode 100644 index 1e8432ab112..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_job_instance_details.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(parent) { - // [START osconfig_v1beta_generated_OsConfigService_ListPatchJobInstanceDetails_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 the instances are in the form of `projects/* /patchJobs/*`. - */ - // const parent = 'abc123' - /** - * The maximum number of instance details records to return. Default is 100. - */ - // const pageSize = 1234 - /** - * A pagination token returned from a previous call - * that indicates where this listing should continue from. - */ - // const pageToken = 'abc123' - /** - * A filter expression that filters results listed in the response. This - * field supports filtering results by instance zone, name, state, or - * `failure_reason`. - */ - // const filter = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callListPatchJobInstanceDetails() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await osconfigClient.listPatchJobInstanceDetailsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListPatchJobInstanceDetails(); - // [END osconfig_v1beta_generated_OsConfigService_ListPatchJobInstanceDetails_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_jobs.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_jobs.js deleted file mode 100644 index e98fe909908..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.list_patch_jobs.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(parent) { - // [START osconfig_v1beta_generated_OsConfigService_ListPatchJobs_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. In the form of `projects/*` - */ - // const parent = 'abc123' - /** - * The maximum number of instance status to return. - */ - // const pageSize = 1234 - /** - * A pagination token returned from a previous call - * that indicates where this listing should continue from. - */ - // const pageToken = 'abc123' - /** - * If provided, this field specifies the criteria that must be met by patch - * jobs to be included in the response. - * Currently, filtering is only available on the patch_deployment field. - */ - // const filter = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callListPatchJobs() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await osconfigClient.listPatchJobsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListPatchJobs(); - // [END osconfig_v1beta_generated_OsConfigService_ListPatchJobs_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.lookup_effective_guest_policy.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.lookup_effective_guest_policy.js deleted file mode 100644 index a5138559ad5..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.lookup_effective_guest_policy.js +++ /dev/null @@ -1,79 +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(instance) { - // [START osconfig_v1beta_generated_OsConfigService_LookupEffectiveGuestPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The VM instance whose policies are being looked up. - */ - // const instance = 'abc123' - /** - * Short name of the OS running on the instance. The OS Config agent only - * provides this field for targeting if OS Inventory is enabled for that - * instance. - */ - // const osShortName = 'abc123' - /** - * Version of the OS running on the instance. The OS Config agent only - * provides this field for targeting if OS Inventory is enabled for that - * VM instance. - */ - // const osVersion = 'abc123' - /** - * Architecture of OS running on the instance. The OS Config agent only - * provides this field for targeting if OS Inventory is enabled for that - * instance. - */ - // const osArchitecture = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callLookupEffectiveGuestPolicy() { - // Construct request - const request = { - instance, - }; - - // Run request - const response = await osconfigClient.lookupEffectiveGuestPolicy(request); - console.log(response); - } - - callLookupEffectiveGuestPolicy(); - // [END osconfig_v1beta_generated_OsConfigService_LookupEffectiveGuestPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.pause_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.pause_patch_deployment.js deleted file mode 100644 index 753963b0889..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.pause_patch_deployment.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 osconfig_v1beta_generated_OsConfigService_PausePatchDeployment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 patch deployment in the form - * `projects/* /patchDeployments/*`. - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callPausePatchDeployment() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.pausePatchDeployment(request); - console.log(response); - } - - callPausePatchDeployment(); - // [END osconfig_v1beta_generated_OsConfigService_PausePatchDeployment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.resume_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.resume_patch_deployment.js deleted file mode 100644 index b5931c32425..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.resume_patch_deployment.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 osconfig_v1beta_generated_OsConfigService_ResumePatchDeployment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 patch deployment in the form - * `projects/* /patchDeployments/*`. - */ - // const name = 'abc123' - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callResumePatchDeployment() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osconfigClient.resumePatchDeployment(request); - console.log(response); - } - - callResumePatchDeployment(); - // [END osconfig_v1beta_generated_OsConfigService_ResumePatchDeployment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.update_guest_policy.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.update_guest_policy.js deleted file mode 100644 index 9401f59c262..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.update_guest_policy.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(guestPolicy) { - // [START osconfig_v1beta_generated_OsConfigService_UpdateGuestPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The updated GuestPolicy. - */ - // const guestPolicy = {} - /** - * Field mask that controls which fields of the guest policy should be - * updated. - */ - // const updateMask = {} - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callUpdateGuestPolicy() { - // Construct request - const request = { - guestPolicy, - }; - - // Run request - const response = await osconfigClient.updateGuestPolicy(request); - console.log(response); - } - - callUpdateGuestPolicy(); - // [END osconfig_v1beta_generated_OsConfigService_UpdateGuestPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.update_patch_deployment.js b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.update_patch_deployment.js deleted file mode 100644 index 25038517953..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/os_config_service.update_patch_deployment.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(patchDeployment) { - // [START osconfig_v1beta_generated_OsConfigService_UpdatePatchDeployment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The patch deployment to Update. - */ - // const patchDeployment = {} - /** - * Optional. Field mask that controls which fields of the patch deployment should be - * updated. - */ - // const updateMask = {} - - // Imports the Osconfig library - const {OsConfigServiceClient} = require('@google-cloud/osconfig').v1beta; - - // Instantiates a client - const osconfigClient = new OsConfigServiceClient(); - - async function callUpdatePatchDeployment() { - // Construct request - const request = { - patchDeployment, - }; - - // Run request - const response = await osconfigClient.updatePatchDeployment(request); - console.log(response); - } - - callUpdatePatchDeployment(); - // [END osconfig_v1beta_generated_OsConfigService_UpdatePatchDeployment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/snippet_metadata_google.cloud.osconfig.v1beta.json b/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/snippet_metadata_google.cloud.osconfig.v1beta.json deleted file mode 100644 index d845a650eac..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/samples/generated/v1beta/snippet_metadata_google.cloud.osconfig.v1beta.json +++ /dev/null @@ -1,839 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-osconfig", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.osconfig.v1beta", - "version": "v1beta" - } - ] - }, - "snippets": [ - { - "regionTag": "osconfig_v1beta_generated_OsConfigService_ExecutePatchJob_async", - "title": "OsConfigService executePatchJob Sample", - "origin": "API_DEFINITION", - "description": " Patch VM instances by creating and running a patch job.", - "canonical": true, - "file": "os_config_service.execute_patch_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 87, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ExecutePatchJob", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ExecutePatchJob", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "description", - "type": "TYPE_STRING" - }, - { - "name": "instance_filter", - "type": ".google.cloud.osconfig.v1beta.PatchInstanceFilter" - }, - { - "name": "patch_config", - "type": ".google.cloud.osconfig.v1beta.PatchConfig" - }, - { - "name": "duration", - "type": ".google.protobuf.Duration" - }, - { - "name": "dry_run", - "type": "TYPE_BOOL" - }, - { - "name": "display_name", - "type": "TYPE_STRING" - }, - { - "name": "rollout", - "type": ".google.cloud.osconfig.v1beta.PatchRollout" - } - ], - "resultType": ".google.cloud.osconfig.v1beta.PatchJob", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" - }, - "method": { - "shortName": "ExecutePatchJob", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ExecutePatchJob", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1beta_generated_OsConfigService_GetPatchJob_async", - "title": "OsConfigService getPatchJob Sample", - "origin": "API_DEFINITION", - "description": " Get the patch job. This can be used to track the progress of an ongoing patch job or review the details of completed jobs.", - "canonical": true, - "file": "os_config_service.get_patch_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetPatchJob", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.GetPatchJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1beta.PatchJob", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" - }, - "method": { - "shortName": "GetPatchJob", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.GetPatchJob", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1beta_generated_OsConfigService_CancelPatchJob_async", - "title": "OsConfigService cancelPatchJob Sample", - "origin": "API_DEFINITION", - "description": " Cancel a patch job. The patch job must be active. Canceled patch jobs cannot be restarted.", - "canonical": true, - "file": "os_config_service.cancel_patch_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CancelPatchJob", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.CancelPatchJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1beta.PatchJob", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" - }, - "method": { - "shortName": "CancelPatchJob", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.CancelPatchJob", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1beta_generated_OsConfigService_ListPatchJobs_async", - "title": "OsConfigService listPatchJobs Sample", - "origin": "API_DEFINITION", - "description": " Get a list of patch jobs.", - "canonical": true, - "file": "os_config_service.list_patch_jobs.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListPatchJobs", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ListPatchJobs", - "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.osconfig.v1beta.ListPatchJobsResponse", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" - }, - "method": { - "shortName": "ListPatchJobs", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ListPatchJobs", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1beta_generated_OsConfigService_ListPatchJobInstanceDetails_async", - "title": "OsConfigService listPatchJobInstanceDetails Sample", - "origin": "API_DEFINITION", - "description": " Get a list of instance details for a given patch job.", - "canonical": true, - "file": "os_config_service.list_patch_job_instance_details.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListPatchJobInstanceDetails", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ListPatchJobInstanceDetails", - "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.osconfig.v1beta.ListPatchJobInstanceDetailsResponse", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" - }, - "method": { - "shortName": "ListPatchJobInstanceDetails", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ListPatchJobInstanceDetails", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1beta_generated_OsConfigService_CreatePatchDeployment_async", - "title": "OsConfigService createPatchDeployment Sample", - "origin": "API_DEFINITION", - "description": " Create an OS Config patch deployment.", - "canonical": true, - "file": "os_config_service.create_patch_deployment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreatePatchDeployment", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.CreatePatchDeployment", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "patch_deployment_id", - "type": "TYPE_STRING" - }, - { - "name": "patch_deployment", - "type": ".google.cloud.osconfig.v1beta.PatchDeployment" - } - ], - "resultType": ".google.cloud.osconfig.v1beta.PatchDeployment", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" - }, - "method": { - "shortName": "CreatePatchDeployment", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.CreatePatchDeployment", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1beta_generated_OsConfigService_GetPatchDeployment_async", - "title": "OsConfigService getPatchDeployment Sample", - "origin": "API_DEFINITION", - "description": " Get an OS Config patch deployment.", - "canonical": true, - "file": "os_config_service.get_patch_deployment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetPatchDeployment", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.GetPatchDeployment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1beta.PatchDeployment", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" - }, - "method": { - "shortName": "GetPatchDeployment", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.GetPatchDeployment", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1beta_generated_OsConfigService_ListPatchDeployments_async", - "title": "OsConfigService listPatchDeployments Sample", - "origin": "API_DEFINITION", - "description": " Get a page of OS Config patch deployments.", - "canonical": true, - "file": "os_config_service.list_patch_deployments.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListPatchDeployments", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ListPatchDeployments", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1beta.ListPatchDeploymentsResponse", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" - }, - "method": { - "shortName": "ListPatchDeployments", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ListPatchDeployments", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1beta_generated_OsConfigService_DeletePatchDeployment_async", - "title": "OsConfigService deletePatchDeployment Sample", - "origin": "API_DEFINITION", - "description": " Delete an OS Config patch deployment.", - "canonical": true, - "file": "os_config_service.delete_patch_deployment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeletePatchDeployment", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.DeletePatchDeployment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" - }, - "method": { - "shortName": "DeletePatchDeployment", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.DeletePatchDeployment", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1beta_generated_OsConfigService_UpdatePatchDeployment_async", - "title": "OsConfigService updatePatchDeployment Sample", - "origin": "API_DEFINITION", - "description": " Update an OS Config patch deployment.", - "canonical": true, - "file": "os_config_service.update_patch_deployment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdatePatchDeployment", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.UpdatePatchDeployment", - "async": true, - "parameters": [ - { - "name": "patch_deployment", - "type": ".google.cloud.osconfig.v1beta.PatchDeployment" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.osconfig.v1beta.PatchDeployment", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" - }, - "method": { - "shortName": "UpdatePatchDeployment", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.UpdatePatchDeployment", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1beta_generated_OsConfigService_PausePatchDeployment_async", - "title": "OsConfigService pausePatchDeployment Sample", - "origin": "API_DEFINITION", - "description": " Change state of patch deployment to \"PAUSED\". Patch deployment in paused state doesn't generate patch jobs.", - "canonical": true, - "file": "os_config_service.pause_patch_deployment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PausePatchDeployment", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.PausePatchDeployment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1beta.PatchDeployment", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" - }, - "method": { - "shortName": "PausePatchDeployment", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.PausePatchDeployment", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1beta_generated_OsConfigService_ResumePatchDeployment_async", - "title": "OsConfigService resumePatchDeployment Sample", - "origin": "API_DEFINITION", - "description": " Change state of patch deployment back to \"ACTIVE\". Patch deployment in active state continues to generate patch jobs.", - "canonical": true, - "file": "os_config_service.resume_patch_deployment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ResumePatchDeployment", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ResumePatchDeployment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1beta.PatchDeployment", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" - }, - "method": { - "shortName": "ResumePatchDeployment", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ResumePatchDeployment", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1beta_generated_OsConfigService_CreateGuestPolicy_async", - "title": "OsConfigService createGuestPolicy Sample", - "origin": "API_DEFINITION", - "description": " Create an OS Config guest policy.", - "canonical": true, - "file": "os_config_service.create_guest_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateGuestPolicy", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.CreateGuestPolicy", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "guest_policy_id", - "type": "TYPE_STRING" - }, - { - "name": "guest_policy", - "type": ".google.cloud.osconfig.v1beta.GuestPolicy" - } - ], - "resultType": ".google.cloud.osconfig.v1beta.GuestPolicy", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" - }, - "method": { - "shortName": "CreateGuestPolicy", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.CreateGuestPolicy", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1beta_generated_OsConfigService_GetGuestPolicy_async", - "title": "OsConfigService getGuestPolicy Sample", - "origin": "API_DEFINITION", - "description": " Get an OS Config guest policy.", - "canonical": true, - "file": "os_config_service.get_guest_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetGuestPolicy", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.GetGuestPolicy", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1beta.GuestPolicy", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" - }, - "method": { - "shortName": "GetGuestPolicy", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.GetGuestPolicy", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1beta_generated_OsConfigService_ListGuestPolicies_async", - "title": "OsConfigService listGuestPolicies Sample", - "origin": "API_DEFINITION", - "description": " Get a page of OS Config guest policies.", - "canonical": true, - "file": "os_config_service.list_guest_policies.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListGuestPolicies", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ListGuestPolicies", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1beta.ListGuestPoliciesResponse", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" - }, - "method": { - "shortName": "ListGuestPolicies", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.ListGuestPolicies", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1beta_generated_OsConfigService_UpdateGuestPolicy_async", - "title": "OsConfigService updateGuestPolicy Sample", - "origin": "API_DEFINITION", - "description": " Update an OS Config guest policy.", - "canonical": true, - "file": "os_config_service.update_guest_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateGuestPolicy", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.UpdateGuestPolicy", - "async": true, - "parameters": [ - { - "name": "guest_policy", - "type": ".google.cloud.osconfig.v1beta.GuestPolicy" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.osconfig.v1beta.GuestPolicy", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" - }, - "method": { - "shortName": "UpdateGuestPolicy", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.UpdateGuestPolicy", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1beta_generated_OsConfigService_DeleteGuestPolicy_async", - "title": "OsConfigService deleteGuestPolicy Sample", - "origin": "API_DEFINITION", - "description": " Delete an OS Config guest policy.", - "canonical": true, - "file": "os_config_service.delete_guest_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteGuestPolicy", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.DeleteGuestPolicy", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" - }, - "method": { - "shortName": "DeleteGuestPolicy", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.DeleteGuestPolicy", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService" - } - } - } - }, - { - "regionTag": "osconfig_v1beta_generated_OsConfigService_LookupEffectiveGuestPolicy_async", - "title": "OsConfigService lookupEffectiveGuestPolicy Sample", - "origin": "API_DEFINITION", - "description": " Lookup the effective guest policy that applies to a VM instance. This lookup merges all policies that are assigned to the instance ancestry.", - "canonical": true, - "file": "os_config_service.lookup_effective_guest_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "LookupEffectiveGuestPolicy", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.LookupEffectiveGuestPolicy", - "async": true, - "parameters": [ - { - "name": "instance", - "type": "TYPE_STRING" - }, - { - "name": "os_short_name", - "type": "TYPE_STRING" - }, - { - "name": "os_version", - "type": "TYPE_STRING" - }, - { - "name": "os_architecture", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.osconfig.v1beta.EffectiveGuestPolicy", - "client": { - "shortName": "OsConfigServiceClient", - "fullName": "google.cloud.osconfig.v1beta.OsConfigServiceClient" - }, - "method": { - "shortName": "LookupEffectiveGuestPolicy", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService.LookupEffectiveGuestPolicy", - "service": { - "shortName": "OsConfigService", - "fullName": "google.cloud.osconfig.v1beta.OsConfigService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/src/index.ts b/owl-bot-staging/google-cloud-osconfig/v1beta/src/index.ts deleted file mode 100644 index 4ed09a037fc..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/src/index.ts +++ /dev/null @@ -1,25 +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 v1beta from './v1beta'; -const OsConfigServiceClient = v1beta.OsConfigServiceClient; -type OsConfigServiceClient = v1beta.OsConfigServiceClient; -export {v1beta, OsConfigServiceClient}; -export default {v1beta, OsConfigServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/gapic_metadata.json b/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/gapic_metadata.json deleted file mode 100644 index 1a1c7998335..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/gapic_metadata.json +++ /dev/null @@ -1,219 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.osconfig.v1beta", - "libraryPackage": "@google-cloud/osconfig", - "services": { - "OsConfigService": { - "clients": { - "grpc": { - "libraryClient": "OsConfigServiceClient", - "rpcs": { - "ExecutePatchJob": { - "methods": [ - "executePatchJob" - ] - }, - "GetPatchJob": { - "methods": [ - "getPatchJob" - ] - }, - "CancelPatchJob": { - "methods": [ - "cancelPatchJob" - ] - }, - "CreatePatchDeployment": { - "methods": [ - "createPatchDeployment" - ] - }, - "GetPatchDeployment": { - "methods": [ - "getPatchDeployment" - ] - }, - "DeletePatchDeployment": { - "methods": [ - "deletePatchDeployment" - ] - }, - "UpdatePatchDeployment": { - "methods": [ - "updatePatchDeployment" - ] - }, - "PausePatchDeployment": { - "methods": [ - "pausePatchDeployment" - ] - }, - "ResumePatchDeployment": { - "methods": [ - "resumePatchDeployment" - ] - }, - "CreateGuestPolicy": { - "methods": [ - "createGuestPolicy" - ] - }, - "GetGuestPolicy": { - "methods": [ - "getGuestPolicy" - ] - }, - "UpdateGuestPolicy": { - "methods": [ - "updateGuestPolicy" - ] - }, - "DeleteGuestPolicy": { - "methods": [ - "deleteGuestPolicy" - ] - }, - "LookupEffectiveGuestPolicy": { - "methods": [ - "lookupEffectiveGuestPolicy" - ] - }, - "ListPatchJobs": { - "methods": [ - "listPatchJobs", - "listPatchJobsStream", - "listPatchJobsAsync" - ] - }, - "ListPatchJobInstanceDetails": { - "methods": [ - "listPatchJobInstanceDetails", - "listPatchJobInstanceDetailsStream", - "listPatchJobInstanceDetailsAsync" - ] - }, - "ListPatchDeployments": { - "methods": [ - "listPatchDeployments", - "listPatchDeploymentsStream", - "listPatchDeploymentsAsync" - ] - }, - "ListGuestPolicies": { - "methods": [ - "listGuestPolicies", - "listGuestPoliciesStream", - "listGuestPoliciesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "OsConfigServiceClient", - "rpcs": { - "ExecutePatchJob": { - "methods": [ - "executePatchJob" - ] - }, - "GetPatchJob": { - "methods": [ - "getPatchJob" - ] - }, - "CancelPatchJob": { - "methods": [ - "cancelPatchJob" - ] - }, - "CreatePatchDeployment": { - "methods": [ - "createPatchDeployment" - ] - }, - "GetPatchDeployment": { - "methods": [ - "getPatchDeployment" - ] - }, - "DeletePatchDeployment": { - "methods": [ - "deletePatchDeployment" - ] - }, - "UpdatePatchDeployment": { - "methods": [ - "updatePatchDeployment" - ] - }, - "PausePatchDeployment": { - "methods": [ - "pausePatchDeployment" - ] - }, - "ResumePatchDeployment": { - "methods": [ - "resumePatchDeployment" - ] - }, - "CreateGuestPolicy": { - "methods": [ - "createGuestPolicy" - ] - }, - "GetGuestPolicy": { - "methods": [ - "getGuestPolicy" - ] - }, - "UpdateGuestPolicy": { - "methods": [ - "updateGuestPolicy" - ] - }, - "DeleteGuestPolicy": { - "methods": [ - "deleteGuestPolicy" - ] - }, - "LookupEffectiveGuestPolicy": { - "methods": [ - "lookupEffectiveGuestPolicy" - ] - }, - "ListPatchJobs": { - "methods": [ - "listPatchJobs", - "listPatchJobsStream", - "listPatchJobsAsync" - ] - }, - "ListPatchJobInstanceDetails": { - "methods": [ - "listPatchJobInstanceDetails", - "listPatchJobInstanceDetailsStream", - "listPatchJobInstanceDetailsAsync" - ] - }, - "ListPatchDeployments": { - "methods": [ - "listPatchDeployments", - "listPatchDeploymentsStream", - "listPatchDeploymentsAsync" - ] - }, - "ListGuestPolicies": { - "methods": [ - "listGuestPolicies", - "listGuestPoliciesStream", - "listGuestPoliciesAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/index.ts b/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/index.ts deleted file mode 100644 index e16a0985eee..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/index.ts +++ /dev/null @@ -1,19 +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 {OsConfigServiceClient} from './os_config_service_client'; diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_client.ts b/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_client.ts deleted file mode 100644 index 4550aed1a0c..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_client.ts +++ /dev/null @@ -1,2220 +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, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta/os_config_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './os_config_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * OS Config API - * - * The OS Config service is a server-side component that you can use to - * manage package installations and patch jobs for virtual machine instances. - * @class - * @memberof v1beta - */ -export class OsConfigServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - osConfigServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of OsConfigServiceClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 OsConfigServiceClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof OsConfigServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - guestPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/guestPolicies/{guest_policy}' - ), - patchDeploymentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/patchDeployments/{patch_deployment}' - ), - patchJobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/patchJobs/{patch_job}' - ), - }; - - // 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 = { - listPatchJobs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'patchJobs'), - listPatchJobInstanceDetails: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'patchJobInstanceDetails'), - listPatchDeployments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'patchDeployments'), - listGuestPolicies: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'guestPolicies') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.osconfig.v1beta.OsConfigService', 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.osConfigServiceStub) { - return this.osConfigServiceStub; - } - - // Put together the "service stub" for - // google.cloud.osconfig.v1beta.OsConfigService. - this.osConfigServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.osconfig.v1beta.OsConfigService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.osconfig.v1beta.OsConfigService, - 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 osConfigServiceStubMethods = - ['executePatchJob', 'getPatchJob', 'cancelPatchJob', 'listPatchJobs', 'listPatchJobInstanceDetails', 'createPatchDeployment', 'getPatchDeployment', 'listPatchDeployments', 'deletePatchDeployment', 'updatePatchDeployment', 'pausePatchDeployment', 'resumePatchDeployment', 'createGuestPolicy', 'getGuestPolicy', 'listGuestPolicies', 'updateGuestPolicy', 'deleteGuestPolicy', 'lookupEffectiveGuestPolicy']; - for (const methodName of osConfigServiceStubMethods) { - const callPromise = this.osConfigServiceStub.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.osConfigServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'osconfig.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 'osconfig.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 -- - // ------------------- -/** - * Patch VM instances by creating and running a patch job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which to run this patch in the form `projects/*` - * @param {string} request.description - * Description of the patch job. Length of the description is limited - * to 1024 characters. - * @param {google.cloud.osconfig.v1beta.PatchInstanceFilter} request.instanceFilter - * Required. Instances to patch, either explicitly or filtered by some criteria such - * as zone or labels. - * @param {google.cloud.osconfig.v1beta.PatchConfig} request.patchConfig - * Patch configuration being applied. If omitted, instances are - * patched using the default configurations. - * @param {google.protobuf.Duration} request.duration - * Duration of the patch job. After the duration ends, the patch job - * times out. - * @param {boolean} request.dryRun - * If this patch is a dry-run only, instances are contacted but - * will do nothing. - * @param {string} request.displayName - * Display name for this patch job. This does not have to be unique. - * @param {google.cloud.osconfig.v1beta.PatchRollout} request.rollout - * Rollout strategy of the patch job. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1beta.PatchJob|PatchJob}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_config_service.execute_patch_job.js - * region_tag:osconfig_v1beta_generated_OsConfigService_ExecutePatchJob_async - */ - executePatchJob( - request?: protos.google.cloud.osconfig.v1beta.IExecutePatchJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchJob, - protos.google.cloud.osconfig.v1beta.IExecutePatchJobRequest|undefined, {}|undefined - ]>; - executePatchJob( - request: protos.google.cloud.osconfig.v1beta.IExecutePatchJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IPatchJob, - protos.google.cloud.osconfig.v1beta.IExecutePatchJobRequest|null|undefined, - {}|null|undefined>): void; - executePatchJob( - request: protos.google.cloud.osconfig.v1beta.IExecutePatchJobRequest, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IPatchJob, - protos.google.cloud.osconfig.v1beta.IExecutePatchJobRequest|null|undefined, - {}|null|undefined>): void; - executePatchJob( - request?: protos.google.cloud.osconfig.v1beta.IExecutePatchJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1beta.IPatchJob, - protos.google.cloud.osconfig.v1beta.IExecutePatchJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1beta.IPatchJob, - protos.google.cloud.osconfig.v1beta.IExecutePatchJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchJob, - protos.google.cloud.osconfig.v1beta.IExecutePatchJobRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.executePatchJob(request, options, callback); - } -/** - * Get the patch job. This can be used to track the progress of an - * ongoing patch job or review the details of completed jobs. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the patch in the form `projects/* /patchJobs/*` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1beta.PatchJob|PatchJob}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_config_service.get_patch_job.js - * region_tag:osconfig_v1beta_generated_OsConfigService_GetPatchJob_async - */ - getPatchJob( - request?: protos.google.cloud.osconfig.v1beta.IGetPatchJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchJob, - protos.google.cloud.osconfig.v1beta.IGetPatchJobRequest|undefined, {}|undefined - ]>; - getPatchJob( - request: protos.google.cloud.osconfig.v1beta.IGetPatchJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IPatchJob, - protos.google.cloud.osconfig.v1beta.IGetPatchJobRequest|null|undefined, - {}|null|undefined>): void; - getPatchJob( - request: protos.google.cloud.osconfig.v1beta.IGetPatchJobRequest, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IPatchJob, - protos.google.cloud.osconfig.v1beta.IGetPatchJobRequest|null|undefined, - {}|null|undefined>): void; - getPatchJob( - request?: protos.google.cloud.osconfig.v1beta.IGetPatchJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1beta.IPatchJob, - protos.google.cloud.osconfig.v1beta.IGetPatchJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1beta.IPatchJob, - protos.google.cloud.osconfig.v1beta.IGetPatchJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchJob, - protos.google.cloud.osconfig.v1beta.IGetPatchJobRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getPatchJob(request, options, callback); - } -/** - * Cancel a patch job. The patch job must be active. Canceled patch jobs - * cannot be restarted. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the patch in the form `projects/* /patchJobs/*` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1beta.PatchJob|PatchJob}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_config_service.cancel_patch_job.js - * region_tag:osconfig_v1beta_generated_OsConfigService_CancelPatchJob_async - */ - cancelPatchJob( - request?: protos.google.cloud.osconfig.v1beta.ICancelPatchJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchJob, - protos.google.cloud.osconfig.v1beta.ICancelPatchJobRequest|undefined, {}|undefined - ]>; - cancelPatchJob( - request: protos.google.cloud.osconfig.v1beta.ICancelPatchJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IPatchJob, - protos.google.cloud.osconfig.v1beta.ICancelPatchJobRequest|null|undefined, - {}|null|undefined>): void; - cancelPatchJob( - request: protos.google.cloud.osconfig.v1beta.ICancelPatchJobRequest, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IPatchJob, - protos.google.cloud.osconfig.v1beta.ICancelPatchJobRequest|null|undefined, - {}|null|undefined>): void; - cancelPatchJob( - request?: protos.google.cloud.osconfig.v1beta.ICancelPatchJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1beta.IPatchJob, - protos.google.cloud.osconfig.v1beta.ICancelPatchJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1beta.IPatchJob, - protos.google.cloud.osconfig.v1beta.ICancelPatchJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchJob, - protos.google.cloud.osconfig.v1beta.ICancelPatchJobRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.cancelPatchJob(request, options, callback); - } -/** - * Create an OS Config patch deployment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project to apply this patch deployment to in the form `projects/*`. - * @param {string} request.patchDeploymentId - * Required. A name for the patch deployment in the project. When creating a name - * the following rules apply: - * * Must contain only lowercase letters, numbers, and hyphens. - * * Must start with a letter. - * * Must be between 1-63 characters. - * * Must end with a number or a letter. - * * Must be unique within the project. - * @param {google.cloud.osconfig.v1beta.PatchDeployment} request.patchDeployment - * Required. The patch deployment to create. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1beta.PatchDeployment|PatchDeployment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_config_service.create_patch_deployment.js - * region_tag:osconfig_v1beta_generated_OsConfigService_CreatePatchDeployment_async - */ - createPatchDeployment( - request?: protos.google.cloud.osconfig.v1beta.ICreatePatchDeploymentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.ICreatePatchDeploymentRequest|undefined, {}|undefined - ]>; - createPatchDeployment( - request: protos.google.cloud.osconfig.v1beta.ICreatePatchDeploymentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.ICreatePatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - createPatchDeployment( - request: protos.google.cloud.osconfig.v1beta.ICreatePatchDeploymentRequest, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.ICreatePatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - createPatchDeployment( - request?: protos.google.cloud.osconfig.v1beta.ICreatePatchDeploymentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.ICreatePatchDeploymentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.ICreatePatchDeploymentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.ICreatePatchDeploymentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createPatchDeployment(request, options, callback); - } -/** - * Get an OS Config patch deployment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the patch deployment in the form - * `projects/* /patchDeployments/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1beta.PatchDeployment|PatchDeployment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_config_service.get_patch_deployment.js - * region_tag:osconfig_v1beta_generated_OsConfigService_GetPatchDeployment_async - */ - getPatchDeployment( - request?: protos.google.cloud.osconfig.v1beta.IGetPatchDeploymentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IGetPatchDeploymentRequest|undefined, {}|undefined - ]>; - getPatchDeployment( - request: protos.google.cloud.osconfig.v1beta.IGetPatchDeploymentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IGetPatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - getPatchDeployment( - request: protos.google.cloud.osconfig.v1beta.IGetPatchDeploymentRequest, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IGetPatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - getPatchDeployment( - request?: protos.google.cloud.osconfig.v1beta.IGetPatchDeploymentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IGetPatchDeploymentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IGetPatchDeploymentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IGetPatchDeploymentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getPatchDeployment(request, options, callback); - } -/** - * Delete an OS Config patch deployment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the patch deployment in the form - * `projects/* /patchDeployments/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_config_service.delete_patch_deployment.js - * region_tag:osconfig_v1beta_generated_OsConfigService_DeletePatchDeployment_async - */ - deletePatchDeployment( - request?: protos.google.cloud.osconfig.v1beta.IDeletePatchDeploymentRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.osconfig.v1beta.IDeletePatchDeploymentRequest|undefined, {}|undefined - ]>; - deletePatchDeployment( - request: protos.google.cloud.osconfig.v1beta.IDeletePatchDeploymentRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.osconfig.v1beta.IDeletePatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - deletePatchDeployment( - request: protos.google.cloud.osconfig.v1beta.IDeletePatchDeploymentRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.osconfig.v1beta.IDeletePatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - deletePatchDeployment( - request?: protos.google.cloud.osconfig.v1beta.IDeletePatchDeploymentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.osconfig.v1beta.IDeletePatchDeploymentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.osconfig.v1beta.IDeletePatchDeploymentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.osconfig.v1beta.IDeletePatchDeploymentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deletePatchDeployment(request, options, callback); - } -/** - * Update an OS Config patch deployment. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.osconfig.v1beta.PatchDeployment} request.patchDeployment - * Required. The patch deployment to Update. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask that controls which fields of the patch deployment should be - * 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 protos.google.cloud.osconfig.v1beta.PatchDeployment|PatchDeployment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_config_service.update_patch_deployment.js - * region_tag:osconfig_v1beta_generated_OsConfigService_UpdatePatchDeployment_async - */ - updatePatchDeployment( - request?: protos.google.cloud.osconfig.v1beta.IUpdatePatchDeploymentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IUpdatePatchDeploymentRequest|undefined, {}|undefined - ]>; - updatePatchDeployment( - request: protos.google.cloud.osconfig.v1beta.IUpdatePatchDeploymentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IUpdatePatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - updatePatchDeployment( - request: protos.google.cloud.osconfig.v1beta.IUpdatePatchDeploymentRequest, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IUpdatePatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - updatePatchDeployment( - request?: protos.google.cloud.osconfig.v1beta.IUpdatePatchDeploymentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IUpdatePatchDeploymentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IUpdatePatchDeploymentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IUpdatePatchDeploymentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'patch_deployment.name': request.patchDeployment!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updatePatchDeployment(request, options, callback); - } -/** - * Change state of patch deployment to "PAUSED". - * Patch deployment in paused state doesn't generate patch jobs. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the patch deployment in the form - * `projects/* /patchDeployments/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1beta.PatchDeployment|PatchDeployment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_config_service.pause_patch_deployment.js - * region_tag:osconfig_v1beta_generated_OsConfigService_PausePatchDeployment_async - */ - pausePatchDeployment( - request?: protos.google.cloud.osconfig.v1beta.IPausePatchDeploymentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IPausePatchDeploymentRequest|undefined, {}|undefined - ]>; - pausePatchDeployment( - request: protos.google.cloud.osconfig.v1beta.IPausePatchDeploymentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IPausePatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - pausePatchDeployment( - request: protos.google.cloud.osconfig.v1beta.IPausePatchDeploymentRequest, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IPausePatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - pausePatchDeployment( - request?: protos.google.cloud.osconfig.v1beta.IPausePatchDeploymentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IPausePatchDeploymentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IPausePatchDeploymentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IPausePatchDeploymentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.pausePatchDeployment(request, options, callback); - } -/** - * Change state of patch deployment back to "ACTIVE". - * Patch deployment in active state continues to generate patch jobs. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the patch deployment in the form - * `projects/* /patchDeployments/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1beta.PatchDeployment|PatchDeployment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_config_service.resume_patch_deployment.js - * region_tag:osconfig_v1beta_generated_OsConfigService_ResumePatchDeployment_async - */ - resumePatchDeployment( - request?: protos.google.cloud.osconfig.v1beta.IResumePatchDeploymentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IResumePatchDeploymentRequest|undefined, {}|undefined - ]>; - resumePatchDeployment( - request: protos.google.cloud.osconfig.v1beta.IResumePatchDeploymentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IResumePatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - resumePatchDeployment( - request: protos.google.cloud.osconfig.v1beta.IResumePatchDeploymentRequest, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IResumePatchDeploymentRequest|null|undefined, - {}|null|undefined>): void; - resumePatchDeployment( - request?: protos.google.cloud.osconfig.v1beta.IResumePatchDeploymentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IResumePatchDeploymentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IResumePatchDeploymentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchDeployment, - protos.google.cloud.osconfig.v1beta.IResumePatchDeploymentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.resumePatchDeployment(request, options, callback); - } -/** - * Create an OS Config guest policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the parent using one of the following forms: - * `projects/{project_number}`. - * @param {string} request.guestPolicyId - * Required. The logical name of the guest policy in the project - * with the following restrictions: - * - * * Must contain only lowercase letters, numbers, and hyphens. - * * Must start with a letter. - * * Must be between 1-63 characters. - * * Must end with a number or a letter. - * * Must be unique within the project. - * @param {google.cloud.osconfig.v1beta.GuestPolicy} request.guestPolicy - * Required. The GuestPolicy to create. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1beta.GuestPolicy|GuestPolicy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_config_service.create_guest_policy.js - * region_tag:osconfig_v1beta_generated_OsConfigService_CreateGuestPolicy_async - */ - createGuestPolicy( - request?: protos.google.cloud.osconfig.v1beta.ICreateGuestPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1beta.IGuestPolicy, - protos.google.cloud.osconfig.v1beta.ICreateGuestPolicyRequest|undefined, {}|undefined - ]>; - createGuestPolicy( - request: protos.google.cloud.osconfig.v1beta.ICreateGuestPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IGuestPolicy, - protos.google.cloud.osconfig.v1beta.ICreateGuestPolicyRequest|null|undefined, - {}|null|undefined>): void; - createGuestPolicy( - request: protos.google.cloud.osconfig.v1beta.ICreateGuestPolicyRequest, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IGuestPolicy, - protos.google.cloud.osconfig.v1beta.ICreateGuestPolicyRequest|null|undefined, - {}|null|undefined>): void; - createGuestPolicy( - request?: protos.google.cloud.osconfig.v1beta.ICreateGuestPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1beta.IGuestPolicy, - protos.google.cloud.osconfig.v1beta.ICreateGuestPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1beta.IGuestPolicy, - protos.google.cloud.osconfig.v1beta.ICreateGuestPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1beta.IGuestPolicy, - protos.google.cloud.osconfig.v1beta.ICreateGuestPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createGuestPolicy(request, options, callback); - } -/** - * Get an OS Config guest policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the guest policy using one of the following forms: - * `projects/{project_number}/guestPolicies/{guest_policy_id}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1beta.GuestPolicy|GuestPolicy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_config_service.get_guest_policy.js - * region_tag:osconfig_v1beta_generated_OsConfigService_GetGuestPolicy_async - */ - getGuestPolicy( - request?: protos.google.cloud.osconfig.v1beta.IGetGuestPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1beta.IGuestPolicy, - protos.google.cloud.osconfig.v1beta.IGetGuestPolicyRequest|undefined, {}|undefined - ]>; - getGuestPolicy( - request: protos.google.cloud.osconfig.v1beta.IGetGuestPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IGuestPolicy, - protos.google.cloud.osconfig.v1beta.IGetGuestPolicyRequest|null|undefined, - {}|null|undefined>): void; - getGuestPolicy( - request: protos.google.cloud.osconfig.v1beta.IGetGuestPolicyRequest, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IGuestPolicy, - protos.google.cloud.osconfig.v1beta.IGetGuestPolicyRequest|null|undefined, - {}|null|undefined>): void; - getGuestPolicy( - request?: protos.google.cloud.osconfig.v1beta.IGetGuestPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1beta.IGuestPolicy, - protos.google.cloud.osconfig.v1beta.IGetGuestPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1beta.IGuestPolicy, - protos.google.cloud.osconfig.v1beta.IGetGuestPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1beta.IGuestPolicy, - protos.google.cloud.osconfig.v1beta.IGetGuestPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getGuestPolicy(request, options, callback); - } -/** - * Update an OS Config guest policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.osconfig.v1beta.GuestPolicy} request.guestPolicy - * Required. The updated GuestPolicy. - * @param {google.protobuf.FieldMask} request.updateMask - * Field mask that controls which fields of the guest policy should be - * 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 protos.google.cloud.osconfig.v1beta.GuestPolicy|GuestPolicy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_config_service.update_guest_policy.js - * region_tag:osconfig_v1beta_generated_OsConfigService_UpdateGuestPolicy_async - */ - updateGuestPolicy( - request?: protos.google.cloud.osconfig.v1beta.IUpdateGuestPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1beta.IGuestPolicy, - protos.google.cloud.osconfig.v1beta.IUpdateGuestPolicyRequest|undefined, {}|undefined - ]>; - updateGuestPolicy( - request: protos.google.cloud.osconfig.v1beta.IUpdateGuestPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IGuestPolicy, - protos.google.cloud.osconfig.v1beta.IUpdateGuestPolicyRequest|null|undefined, - {}|null|undefined>): void; - updateGuestPolicy( - request: protos.google.cloud.osconfig.v1beta.IUpdateGuestPolicyRequest, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IGuestPolicy, - protos.google.cloud.osconfig.v1beta.IUpdateGuestPolicyRequest|null|undefined, - {}|null|undefined>): void; - updateGuestPolicy( - request?: protos.google.cloud.osconfig.v1beta.IUpdateGuestPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1beta.IGuestPolicy, - protos.google.cloud.osconfig.v1beta.IUpdateGuestPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1beta.IGuestPolicy, - protos.google.cloud.osconfig.v1beta.IUpdateGuestPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1beta.IGuestPolicy, - protos.google.cloud.osconfig.v1beta.IUpdateGuestPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'guest_policy.name': request.guestPolicy!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateGuestPolicy(request, options, callback); - } -/** - * Delete an OS Config guest policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the guest policy using one of the following forms: - * `projects/{project_number}/guestPolicies/{guest_policy_id}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_config_service.delete_guest_policy.js - * region_tag:osconfig_v1beta_generated_OsConfigService_DeleteGuestPolicy_async - */ - deleteGuestPolicy( - request?: protos.google.cloud.osconfig.v1beta.IDeleteGuestPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.osconfig.v1beta.IDeleteGuestPolicyRequest|undefined, {}|undefined - ]>; - deleteGuestPolicy( - request: protos.google.cloud.osconfig.v1beta.IDeleteGuestPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.osconfig.v1beta.IDeleteGuestPolicyRequest|null|undefined, - {}|null|undefined>): void; - deleteGuestPolicy( - request: protos.google.cloud.osconfig.v1beta.IDeleteGuestPolicyRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.osconfig.v1beta.IDeleteGuestPolicyRequest|null|undefined, - {}|null|undefined>): void; - deleteGuestPolicy( - request?: protos.google.cloud.osconfig.v1beta.IDeleteGuestPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.osconfig.v1beta.IDeleteGuestPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.osconfig.v1beta.IDeleteGuestPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.osconfig.v1beta.IDeleteGuestPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteGuestPolicy(request, options, callback); - } -/** - * Lookup the effective guest policy that applies to a VM instance. This - * lookup merges all policies that are assigned to the instance ancestry. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. The VM instance whose policies are being looked up. - * @param {string} request.osShortName - * Short name of the OS running on the instance. The OS Config agent only - * provides this field for targeting if OS Inventory is enabled for that - * instance. - * @param {string} request.osVersion - * Version of the OS running on the instance. The OS Config agent only - * provides this field for targeting if OS Inventory is enabled for that - * VM instance. - * @param {string} request.osArchitecture - * Architecture of OS running on the instance. The OS Config agent only - * provides this field for targeting if OS Inventory is enabled for that - * instance. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.osconfig.v1beta.EffectiveGuestPolicy|EffectiveGuestPolicy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_config_service.lookup_effective_guest_policy.js - * region_tag:osconfig_v1beta_generated_OsConfigService_LookupEffectiveGuestPolicy_async - */ - lookupEffectiveGuestPolicy( - request?: protos.google.cloud.osconfig.v1beta.ILookupEffectiveGuestPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1beta.IEffectiveGuestPolicy, - protos.google.cloud.osconfig.v1beta.ILookupEffectiveGuestPolicyRequest|undefined, {}|undefined - ]>; - lookupEffectiveGuestPolicy( - request: protos.google.cloud.osconfig.v1beta.ILookupEffectiveGuestPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IEffectiveGuestPolicy, - protos.google.cloud.osconfig.v1beta.ILookupEffectiveGuestPolicyRequest|null|undefined, - {}|null|undefined>): void; - lookupEffectiveGuestPolicy( - request: protos.google.cloud.osconfig.v1beta.ILookupEffectiveGuestPolicyRequest, - callback: Callback< - protos.google.cloud.osconfig.v1beta.IEffectiveGuestPolicy, - protos.google.cloud.osconfig.v1beta.ILookupEffectiveGuestPolicyRequest|null|undefined, - {}|null|undefined>): void; - lookupEffectiveGuestPolicy( - request?: protos.google.cloud.osconfig.v1beta.ILookupEffectiveGuestPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.osconfig.v1beta.IEffectiveGuestPolicy, - protos.google.cloud.osconfig.v1beta.ILookupEffectiveGuestPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.osconfig.v1beta.IEffectiveGuestPolicy, - protos.google.cloud.osconfig.v1beta.ILookupEffectiveGuestPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.osconfig.v1beta.IEffectiveGuestPolicy, - protos.google.cloud.osconfig.v1beta.ILookupEffectiveGuestPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'instance': request.instance ?? '', - }); - this.initialize(); - return this.innerApiCalls.lookupEffectiveGuestPolicy(request, options, callback); - } - - /** - * Get a list of patch jobs. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. In the form of `projects/*` - * @param {number} request.pageSize - * The maximum number of instance status to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call - * that indicates where this listing should continue from. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by patch - * jobs to be included in the response. - * Currently, filtering is only available on the patch_deployment field. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1beta.PatchJob|PatchJob}. - * 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 `listPatchJobsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listPatchJobs( - request?: protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchJob[], - protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest|null, - protos.google.cloud.osconfig.v1beta.IListPatchJobsResponse - ]>; - listPatchJobs( - request: protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest, - protos.google.cloud.osconfig.v1beta.IListPatchJobsResponse|null|undefined, - protos.google.cloud.osconfig.v1beta.IPatchJob>): void; - listPatchJobs( - request: protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest, - protos.google.cloud.osconfig.v1beta.IListPatchJobsResponse|null|undefined, - protos.google.cloud.osconfig.v1beta.IPatchJob>): void; - listPatchJobs( - request?: protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest, - protos.google.cloud.osconfig.v1beta.IListPatchJobsResponse|null|undefined, - protos.google.cloud.osconfig.v1beta.IPatchJob>, - callback?: PaginationCallback< - protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest, - protos.google.cloud.osconfig.v1beta.IListPatchJobsResponse|null|undefined, - protos.google.cloud.osconfig.v1beta.IPatchJob>): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchJob[], - protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest|null, - protos.google.cloud.osconfig.v1beta.IListPatchJobsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listPatchJobs(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. In the form of `projects/*` - * @param {number} request.pageSize - * The maximum number of instance status to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call - * that indicates where this listing should continue from. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by patch - * jobs to be included in the response. - * Currently, filtering is only available on the patch_deployment field. - * @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 protos.google.cloud.osconfig.v1beta.PatchJob|PatchJob} 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 `listPatchJobsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listPatchJobsStream( - request?: protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest, - 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['listPatchJobs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listPatchJobs.createStream( - this.innerApiCalls.listPatchJobs as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listPatchJobs`, 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. In the form of `projects/*` - * @param {number} request.pageSize - * The maximum number of instance status to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call - * that indicates where this listing should continue from. - * @param {string} request.filter - * If provided, this field specifies the criteria that must be met by patch - * jobs to be included in the response. - * Currently, filtering is only available on the patch_deployment field. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.osconfig.v1beta.PatchJob|PatchJob}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_config_service.list_patch_jobs.js - * region_tag:osconfig_v1beta_generated_OsConfigService_ListPatchJobs_async - */ - listPatchJobsAsync( - request?: protos.google.cloud.osconfig.v1beta.IListPatchJobsRequest, - 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['listPatchJobs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listPatchJobs.asyncIterate( - this.innerApiCalls['listPatchJobs'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Get a list of instance details for a given patch job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent for the instances are in the form of `projects/* /patchJobs/*`. - * @param {number} request.pageSize - * The maximum number of instance details records to return. Default is 100. - * @param {string} request.pageToken - * A pagination token returned from a previous call - * that indicates where this listing should continue from. - * @param {string} request.filter - * A filter expression that filters results listed in the response. This - * field supports filtering results by instance zone, name, state, or - * `failure_reason`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails|PatchJobInstanceDetails}. - * 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 `listPatchJobInstanceDetailsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listPatchJobInstanceDetails( - request?: protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchJobInstanceDetails[], - protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest|null, - protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsResponse - ]>; - listPatchJobInstanceDetails( - request: protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest, - protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsResponse|null|undefined, - protos.google.cloud.osconfig.v1beta.IPatchJobInstanceDetails>): void; - listPatchJobInstanceDetails( - request: protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest, - protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsResponse|null|undefined, - protos.google.cloud.osconfig.v1beta.IPatchJobInstanceDetails>): void; - listPatchJobInstanceDetails( - request?: protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest, - protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsResponse|null|undefined, - protos.google.cloud.osconfig.v1beta.IPatchJobInstanceDetails>, - callback?: PaginationCallback< - protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest, - protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsResponse|null|undefined, - protos.google.cloud.osconfig.v1beta.IPatchJobInstanceDetails>): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchJobInstanceDetails[], - protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest|null, - protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listPatchJobInstanceDetails(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 the instances are in the form of `projects/* /patchJobs/*`. - * @param {number} request.pageSize - * The maximum number of instance details records to return. Default is 100. - * @param {string} request.pageToken - * A pagination token returned from a previous call - * that indicates where this listing should continue from. - * @param {string} request.filter - * A filter expression that filters results listed in the response. This - * field supports filtering results by instance zone, name, state, or - * `failure_reason`. - * @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 protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails|PatchJobInstanceDetails} 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 `listPatchJobInstanceDetailsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listPatchJobInstanceDetailsStream( - request?: protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest, - 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['listPatchJobInstanceDetails']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listPatchJobInstanceDetails.createStream( - this.innerApiCalls.listPatchJobInstanceDetails as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listPatchJobInstanceDetails`, 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 the instances are in the form of `projects/* /patchJobs/*`. - * @param {number} request.pageSize - * The maximum number of instance details records to return. Default is 100. - * @param {string} request.pageToken - * A pagination token returned from a previous call - * that indicates where this listing should continue from. - * @param {string} request.filter - * A filter expression that filters results listed in the response. This - * field supports filtering results by instance zone, name, state, or - * `failure_reason`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails|PatchJobInstanceDetails}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_config_service.list_patch_job_instance_details.js - * region_tag:osconfig_v1beta_generated_OsConfigService_ListPatchJobInstanceDetails_async - */ - listPatchJobInstanceDetailsAsync( - request?: protos.google.cloud.osconfig.v1beta.IListPatchJobInstanceDetailsRequest, - 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['listPatchJobInstanceDetails']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listPatchJobInstanceDetails.asyncIterate( - this.innerApiCalls['listPatchJobInstanceDetails'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Get a page of OS Config patch deployments. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the parent in the form `projects/*`. - * @param {number} [request.pageSize] - * Optional. The maximum number of patch deployments to return. Default is 100. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to ListPatchDeployments - * that indicates where this listing should continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1beta.PatchDeployment|PatchDeployment}. - * 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 `listPatchDeploymentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listPatchDeployments( - request?: protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchDeployment[], - protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest|null, - protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsResponse - ]>; - listPatchDeployments( - request: protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest, - protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsResponse|null|undefined, - protos.google.cloud.osconfig.v1beta.IPatchDeployment>): void; - listPatchDeployments( - request: protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest, - protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsResponse|null|undefined, - protos.google.cloud.osconfig.v1beta.IPatchDeployment>): void; - listPatchDeployments( - request?: protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest, - protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsResponse|null|undefined, - protos.google.cloud.osconfig.v1beta.IPatchDeployment>, - callback?: PaginationCallback< - protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest, - protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsResponse|null|undefined, - protos.google.cloud.osconfig.v1beta.IPatchDeployment>): - Promise<[ - protos.google.cloud.osconfig.v1beta.IPatchDeployment[], - protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest|null, - protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listPatchDeployments(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the parent in the form `projects/*`. - * @param {number} [request.pageSize] - * Optional. The maximum number of patch deployments to return. Default is 100. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to ListPatchDeployments - * that indicates where this listing should continue from. - * @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 protos.google.cloud.osconfig.v1beta.PatchDeployment|PatchDeployment} 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 `listPatchDeploymentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listPatchDeploymentsStream( - request?: protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest, - 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['listPatchDeployments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listPatchDeployments.createStream( - this.innerApiCalls.listPatchDeployments as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listPatchDeployments`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the parent in the form `projects/*`. - * @param {number} [request.pageSize] - * Optional. The maximum number of patch deployments to return. Default is 100. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to ListPatchDeployments - * that indicates where this listing should continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.osconfig.v1beta.PatchDeployment|PatchDeployment}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_config_service.list_patch_deployments.js - * region_tag:osconfig_v1beta_generated_OsConfigService_ListPatchDeployments_async - */ - listPatchDeploymentsAsync( - request?: protos.google.cloud.osconfig.v1beta.IListPatchDeploymentsRequest, - 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['listPatchDeployments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listPatchDeployments.asyncIterate( - this.innerApiCalls['listPatchDeployments'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Get a page of OS Config guest policies. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the parent using one of the following forms: - * `projects/{project_number}`. - * @param {number} request.pageSize - * The maximum number of guest policies to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to `ListGuestPolicies` - * that indicates where this listing should continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.osconfig.v1beta.GuestPolicy|GuestPolicy}. - * 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 `listGuestPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listGuestPolicies( - request?: protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.osconfig.v1beta.IGuestPolicy[], - protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest|null, - protos.google.cloud.osconfig.v1beta.IListGuestPoliciesResponse - ]>; - listGuestPolicies( - request: protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest, - protos.google.cloud.osconfig.v1beta.IListGuestPoliciesResponse|null|undefined, - protos.google.cloud.osconfig.v1beta.IGuestPolicy>): void; - listGuestPolicies( - request: protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest, - callback: PaginationCallback< - protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest, - protos.google.cloud.osconfig.v1beta.IListGuestPoliciesResponse|null|undefined, - protos.google.cloud.osconfig.v1beta.IGuestPolicy>): void; - listGuestPolicies( - request?: protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest, - protos.google.cloud.osconfig.v1beta.IListGuestPoliciesResponse|null|undefined, - protos.google.cloud.osconfig.v1beta.IGuestPolicy>, - callback?: PaginationCallback< - protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest, - protos.google.cloud.osconfig.v1beta.IListGuestPoliciesResponse|null|undefined, - protos.google.cloud.osconfig.v1beta.IGuestPolicy>): - Promise<[ - protos.google.cloud.osconfig.v1beta.IGuestPolicy[], - protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest|null, - protos.google.cloud.osconfig.v1beta.IListGuestPoliciesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listGuestPolicies(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the parent using one of the following forms: - * `projects/{project_number}`. - * @param {number} request.pageSize - * The maximum number of guest policies to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to `ListGuestPolicies` - * that indicates where this listing should continue from. - * @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 protos.google.cloud.osconfig.v1beta.GuestPolicy|GuestPolicy} 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 `listGuestPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listGuestPoliciesStream( - request?: protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest, - 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['listGuestPolicies']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listGuestPolicies.createStream( - this.innerApiCalls.listGuestPolicies as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listGuestPolicies`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the parent using one of the following forms: - * `projects/{project_number}`. - * @param {number} request.pageSize - * The maximum number of guest policies to return. - * @param {string} request.pageToken - * A pagination token returned from a previous call to `ListGuestPolicies` - * that indicates where this listing should continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.osconfig.v1beta.GuestPolicy|GuestPolicy}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_config_service.list_guest_policies.js - * region_tag:osconfig_v1beta_generated_OsConfigService_ListGuestPolicies_async - */ - listGuestPoliciesAsync( - request?: protos.google.cloud.osconfig.v1beta.IListGuestPoliciesRequest, - 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['listGuestPolicies']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listGuestPolicies.asyncIterate( - this.innerApiCalls['listGuestPolicies'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified guestPolicy resource name string. - * - * @param {string} project - * @param {string} guest_policy - * @returns {string} Resource name string. - */ - guestPolicyPath(project:string,guestPolicy:string) { - return this.pathTemplates.guestPolicyPathTemplate.render({ - project: project, - guest_policy: guestPolicy, - }); - } - - /** - * Parse the project from GuestPolicy resource. - * - * @param {string} guestPolicyName - * A fully-qualified path representing GuestPolicy resource. - * @returns {string} A string representing the project. - */ - matchProjectFromGuestPolicyName(guestPolicyName: string) { - return this.pathTemplates.guestPolicyPathTemplate.match(guestPolicyName).project; - } - - /** - * Parse the guest_policy from GuestPolicy resource. - * - * @param {string} guestPolicyName - * A fully-qualified path representing GuestPolicy resource. - * @returns {string} A string representing the guest_policy. - */ - matchGuestPolicyFromGuestPolicyName(guestPolicyName: string) { - return this.pathTemplates.guestPolicyPathTemplate.match(guestPolicyName).guest_policy; - } - - /** - * Return a fully-qualified patchDeployment resource name string. - * - * @param {string} project - * @param {string} patch_deployment - * @returns {string} Resource name string. - */ - patchDeploymentPath(project:string,patchDeployment:string) { - return this.pathTemplates.patchDeploymentPathTemplate.render({ - project: project, - patch_deployment: patchDeployment, - }); - } - - /** - * Parse the project from PatchDeployment resource. - * - * @param {string} patchDeploymentName - * A fully-qualified path representing PatchDeployment resource. - * @returns {string} A string representing the project. - */ - matchProjectFromPatchDeploymentName(patchDeploymentName: string) { - return this.pathTemplates.patchDeploymentPathTemplate.match(patchDeploymentName).project; - } - - /** - * Parse the patch_deployment from PatchDeployment resource. - * - * @param {string} patchDeploymentName - * A fully-qualified path representing PatchDeployment resource. - * @returns {string} A string representing the patch_deployment. - */ - matchPatchDeploymentFromPatchDeploymentName(patchDeploymentName: string) { - return this.pathTemplates.patchDeploymentPathTemplate.match(patchDeploymentName).patch_deployment; - } - - /** - * Return a fully-qualified patchJob resource name string. - * - * @param {string} project - * @param {string} patch_job - * @returns {string} Resource name string. - */ - patchJobPath(project:string,patchJob:string) { - return this.pathTemplates.patchJobPathTemplate.render({ - project: project, - patch_job: patchJob, - }); - } - - /** - * Parse the project from PatchJob resource. - * - * @param {string} patchJobName - * A fully-qualified path representing PatchJob resource. - * @returns {string} A string representing the project. - */ - matchProjectFromPatchJobName(patchJobName: string) { - return this.pathTemplates.patchJobPathTemplate.match(patchJobName).project; - } - - /** - * Parse the patch_job from PatchJob resource. - * - * @param {string} patchJobName - * A fully-qualified path representing PatchJob resource. - * @returns {string} A string representing the patch_job. - */ - matchPatchJobFromPatchJobName(patchJobName: string) { - return this.pathTemplates.patchJobPathTemplate.match(patchJobName).patch_job; - } - - /** - * 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.osConfigServiceStub && !this._terminated) { - return this.osConfigServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_client_config.json b/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_client_config.json deleted file mode 100644 index 6e870f1df46..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_client_config.json +++ /dev/null @@ -1,128 +0,0 @@ -{ - "interfaces": { - "google.cloud.osconfig.v1beta.OsConfigService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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 - }, - "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c": { - "initial_retry_delay_millis": 1000, - "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": { - "ExecutePatchJob": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "GetPatchJob": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "CancelPatchJob": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "ListPatchJobs": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "ListPatchJobInstanceDetails": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "CreatePatchDeployment": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "GetPatchDeployment": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "ListPatchDeployments": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "DeletePatchDeployment": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "UpdatePatchDeployment": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "PausePatchDeployment": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "ResumePatchDeployment": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "CreateGuestPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "GetGuestPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "ListGuestPolicies": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "UpdateGuestPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "DeleteGuestPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "LookupEffectiveGuestPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_proto_list.json b/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_proto_list.json deleted file mode 100644 index 284bb75475e..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/src/v1beta/os_config_service_proto_list.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - "../../protos/google/cloud/osconfig/v1beta/guest_policies.proto", - "../../protos/google/cloud/osconfig/v1beta/osconfig_common.proto", - "../../protos/google/cloud/osconfig/v1beta/osconfig_service.proto", - "../../protos/google/cloud/osconfig/v1beta/patch_deployments.proto", - "../../protos/google/cloud/osconfig/v1beta/patch_jobs.proto" -] diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-osconfig/v1beta/system-test/fixtures/sample/src/index.js deleted file mode 100644 index f94ced51b90..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const osconfig = require('@google-cloud/osconfig'); - -function main() { - const osConfigServiceClient = new osconfig.OsConfigServiceClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-osconfig/v1beta/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 38bffb0af57..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {OsConfigServiceClient} from '@google-cloud/osconfig'; - -// check that the client class type name can be used -function doStuffWithOsConfigServiceClient(client: OsConfigServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const osConfigServiceClient = new OsConfigServiceClient(); - doStuffWithOsConfigServiceClient(osConfigServiceClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/system-test/install.ts b/owl-bot-staging/google-cloud-osconfig/v1beta/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/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-osconfig/v1beta/test/gapic_os_config_service_v1beta.ts b/owl-bot-staging/google-cloud-osconfig/v1beta/test/gapic_os_config_service_v1beta.ts deleted file mode 100644 index bc233a36428..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/test/gapic_os_config_service_v1beta.ts +++ /dev/null @@ -1,2814 +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 osconfigserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -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('v1beta.OsConfigServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = osconfigserviceModule.v1beta.OsConfigServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = osconfigserviceModule.v1beta.OsConfigServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = osconfigserviceModule.v1beta.OsConfigServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.osConfigServiceStub, undefined); - await client.initialize(); - assert(client.osConfigServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.osConfigServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.osConfigServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - 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 osconfigserviceModule.v1beta.OsConfigServiceClient({ - 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('executePatchJob', () => { - it('invokes executePatchJob without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ExecutePatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ExecutePatchJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.PatchJob() - ); - client.innerApiCalls.executePatchJob = stubSimpleCall(expectedResponse); - const [response] = await client.executePatchJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executePatchJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executePatchJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executePatchJob without error using callback', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ExecutePatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ExecutePatchJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.PatchJob() - ); - client.innerApiCalls.executePatchJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.executePatchJob( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executePatchJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executePatchJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executePatchJob with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ExecutePatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ExecutePatchJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.executePatchJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.executePatchJob(request), expectedError); - const actualRequest = (client.innerApiCalls.executePatchJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executePatchJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executePatchJob with closed client', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ExecutePatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ExecutePatchJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.executePatchJob(request), expectedError); - }); - }); - - describe('getPatchJob', () => { - it('invokes getPatchJob without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.GetPatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetPatchJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.PatchJob() - ); - client.innerApiCalls.getPatchJob = stubSimpleCall(expectedResponse); - const [response] = await client.getPatchJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPatchJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPatchJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPatchJob without error using callback', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.GetPatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetPatchJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.PatchJob() - ); - client.innerApiCalls.getPatchJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getPatchJob( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPatchJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPatchJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPatchJob with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.GetPatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetPatchJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getPatchJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getPatchJob(request), expectedError); - const actualRequest = (client.innerApiCalls.getPatchJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPatchJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPatchJob with closed client', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.GetPatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetPatchJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getPatchJob(request), expectedError); - }); - }); - - describe('cancelPatchJob', () => { - it('invokes cancelPatchJob without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.CancelPatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.CancelPatchJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.PatchJob() - ); - client.innerApiCalls.cancelPatchJob = stubSimpleCall(expectedResponse); - const [response] = await client.cancelPatchJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.cancelPatchJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.cancelPatchJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes cancelPatchJob without error using callback', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.CancelPatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.CancelPatchJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.PatchJob() - ); - client.innerApiCalls.cancelPatchJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.cancelPatchJob( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.cancelPatchJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.cancelPatchJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes cancelPatchJob with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.CancelPatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.CancelPatchJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.cancelPatchJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.cancelPatchJob(request), expectedError); - const actualRequest = (client.innerApiCalls.cancelPatchJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.cancelPatchJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes cancelPatchJob with closed client', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.CancelPatchJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.CancelPatchJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.cancelPatchJob(request), expectedError); - }); - }); - - describe('createPatchDeployment', () => { - it('invokes createPatchDeployment without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.CreatePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.CreatePatchDeploymentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.PatchDeployment() - ); - client.innerApiCalls.createPatchDeployment = stubSimpleCall(expectedResponse); - const [response] = await client.createPatchDeployment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createPatchDeployment without error using callback', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.CreatePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.CreatePatchDeploymentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.PatchDeployment() - ); - client.innerApiCalls.createPatchDeployment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createPatchDeployment( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchDeployment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createPatchDeployment with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.CreatePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.CreatePatchDeploymentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createPatchDeployment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createPatchDeployment(request), expectedError); - const actualRequest = (client.innerApiCalls.createPatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createPatchDeployment with closed client', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.CreatePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.CreatePatchDeploymentRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createPatchDeployment(request), expectedError); - }); - }); - - describe('getPatchDeployment', () => { - it('invokes getPatchDeployment without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.GetPatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetPatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.PatchDeployment() - ); - client.innerApiCalls.getPatchDeployment = stubSimpleCall(expectedResponse); - const [response] = await client.getPatchDeployment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPatchDeployment without error using callback', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.GetPatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetPatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.PatchDeployment() - ); - client.innerApiCalls.getPatchDeployment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getPatchDeployment( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchDeployment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPatchDeployment with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.GetPatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetPatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getPatchDeployment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getPatchDeployment(request), expectedError); - const actualRequest = (client.innerApiCalls.getPatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPatchDeployment with closed client', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.GetPatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetPatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getPatchDeployment(request), expectedError); - }); - }); - - describe('deletePatchDeployment', () => { - it('invokes deletePatchDeployment without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.DeletePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.DeletePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePatchDeployment = stubSimpleCall(expectedResponse); - const [response] = await client.deletePatchDeployment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deletePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePatchDeployment without error using callback', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.DeletePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.DeletePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePatchDeployment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deletePatchDeployment( - 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.deletePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePatchDeployment with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.DeletePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.DeletePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deletePatchDeployment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deletePatchDeployment(request), expectedError); - const actualRequest = (client.innerApiCalls.deletePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePatchDeployment with closed client', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.DeletePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.DeletePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deletePatchDeployment(request), expectedError); - }); - }); - - describe('updatePatchDeployment', () => { - it('invokes updatePatchDeployment without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.UpdatePatchDeploymentRequest() - ); - request.patchDeployment ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.UpdatePatchDeploymentRequest', ['patchDeployment', 'name']); - request.patchDeployment.name = defaultValue1; - const expectedHeaderRequestParams = `patch_deployment.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.PatchDeployment() - ); - client.innerApiCalls.updatePatchDeployment = stubSimpleCall(expectedResponse); - const [response] = await client.updatePatchDeployment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updatePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updatePatchDeployment without error using callback', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.UpdatePatchDeploymentRequest() - ); - request.patchDeployment ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.UpdatePatchDeploymentRequest', ['patchDeployment', 'name']); - request.patchDeployment.name = defaultValue1; - const expectedHeaderRequestParams = `patch_deployment.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.PatchDeployment() - ); - client.innerApiCalls.updatePatchDeployment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updatePatchDeployment( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchDeployment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updatePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updatePatchDeployment with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.UpdatePatchDeploymentRequest() - ); - request.patchDeployment ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.UpdatePatchDeploymentRequest', ['patchDeployment', 'name']); - request.patchDeployment.name = defaultValue1; - const expectedHeaderRequestParams = `patch_deployment.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updatePatchDeployment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updatePatchDeployment(request), expectedError); - const actualRequest = (client.innerApiCalls.updatePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updatePatchDeployment with closed client', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.UpdatePatchDeploymentRequest() - ); - request.patchDeployment ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.UpdatePatchDeploymentRequest', ['patchDeployment', 'name']); - request.patchDeployment.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updatePatchDeployment(request), expectedError); - }); - }); - - describe('pausePatchDeployment', () => { - it('invokes pausePatchDeployment without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.PausePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.PausePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.PatchDeployment() - ); - client.innerApiCalls.pausePatchDeployment = stubSimpleCall(expectedResponse); - const [response] = await client.pausePatchDeployment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pausePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pausePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pausePatchDeployment without error using callback', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.PausePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.PausePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.PatchDeployment() - ); - client.innerApiCalls.pausePatchDeployment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.pausePatchDeployment( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchDeployment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pausePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pausePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pausePatchDeployment with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.PausePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.PausePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.pausePatchDeployment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.pausePatchDeployment(request), expectedError); - const actualRequest = (client.innerApiCalls.pausePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pausePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pausePatchDeployment with closed client', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.PausePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.PausePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.pausePatchDeployment(request), expectedError); - }); - }); - - describe('resumePatchDeployment', () => { - it('invokes resumePatchDeployment without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ResumePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ResumePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.PatchDeployment() - ); - client.innerApiCalls.resumePatchDeployment = stubSimpleCall(expectedResponse); - const [response] = await client.resumePatchDeployment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumePatchDeployment without error using callback', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ResumePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ResumePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.PatchDeployment() - ); - client.innerApiCalls.resumePatchDeployment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resumePatchDeployment( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchDeployment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumePatchDeployment with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ResumePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ResumePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.resumePatchDeployment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.resumePatchDeployment(request), expectedError); - const actualRequest = (client.innerApiCalls.resumePatchDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumePatchDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumePatchDeployment with closed client', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ResumePatchDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ResumePatchDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.resumePatchDeployment(request), expectedError); - }); - }); - - describe('createGuestPolicy', () => { - it('invokes createGuestPolicy without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.CreateGuestPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.CreateGuestPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.GuestPolicy() - ); - client.innerApiCalls.createGuestPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.createGuestPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createGuestPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createGuestPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createGuestPolicy without error using callback', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.CreateGuestPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.CreateGuestPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.GuestPolicy() - ); - client.innerApiCalls.createGuestPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createGuestPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IGuestPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createGuestPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createGuestPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createGuestPolicy with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.CreateGuestPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.CreateGuestPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createGuestPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createGuestPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.createGuestPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createGuestPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createGuestPolicy with closed client', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.CreateGuestPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.CreateGuestPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createGuestPolicy(request), expectedError); - }); - }); - - describe('getGuestPolicy', () => { - it('invokes getGuestPolicy without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.GetGuestPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetGuestPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.GuestPolicy() - ); - client.innerApiCalls.getGuestPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getGuestPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getGuestPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGuestPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getGuestPolicy without error using callback', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.GetGuestPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetGuestPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.GuestPolicy() - ); - client.innerApiCalls.getGuestPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getGuestPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IGuestPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getGuestPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGuestPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getGuestPolicy with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.GetGuestPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetGuestPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getGuestPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getGuestPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getGuestPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGuestPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getGuestPolicy with closed client', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.GetGuestPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.GetGuestPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getGuestPolicy(request), expectedError); - }); - }); - - describe('updateGuestPolicy', () => { - it('invokes updateGuestPolicy without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.UpdateGuestPolicyRequest() - ); - request.guestPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.UpdateGuestPolicyRequest', ['guestPolicy', 'name']); - request.guestPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `guest_policy.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.GuestPolicy() - ); - client.innerApiCalls.updateGuestPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.updateGuestPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateGuestPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGuestPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateGuestPolicy without error using callback', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.UpdateGuestPolicyRequest() - ); - request.guestPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.UpdateGuestPolicyRequest', ['guestPolicy', 'name']); - request.guestPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `guest_policy.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.GuestPolicy() - ); - client.innerApiCalls.updateGuestPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateGuestPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IGuestPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateGuestPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGuestPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateGuestPolicy with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.UpdateGuestPolicyRequest() - ); - request.guestPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.UpdateGuestPolicyRequest', ['guestPolicy', 'name']); - request.guestPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `guest_policy.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateGuestPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateGuestPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.updateGuestPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGuestPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateGuestPolicy with closed client', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.UpdateGuestPolicyRequest() - ); - request.guestPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.UpdateGuestPolicyRequest', ['guestPolicy', 'name']); - request.guestPolicy.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateGuestPolicy(request), expectedError); - }); - }); - - describe('deleteGuestPolicy', () => { - it('invokes deleteGuestPolicy without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.DeleteGuestPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.DeleteGuestPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteGuestPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.deleteGuestPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteGuestPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteGuestPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteGuestPolicy without error using callback', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.DeleteGuestPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.DeleteGuestPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteGuestPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteGuestPolicy( - 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.deleteGuestPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteGuestPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteGuestPolicy with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.DeleteGuestPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.DeleteGuestPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteGuestPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteGuestPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteGuestPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteGuestPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteGuestPolicy with closed client', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.DeleteGuestPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.DeleteGuestPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteGuestPolicy(request), expectedError); - }); - }); - - describe('lookupEffectiveGuestPolicy', () => { - it('invokes lookupEffectiveGuestPolicy without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.LookupEffectiveGuestPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.LookupEffectiveGuestPolicyRequest', ['instance']); - request.instance = defaultValue1; - const expectedHeaderRequestParams = `instance=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.EffectiveGuestPolicy() - ); - client.innerApiCalls.lookupEffectiveGuestPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.lookupEffectiveGuestPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.lookupEffectiveGuestPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.lookupEffectiveGuestPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes lookupEffectiveGuestPolicy without error using callback', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.LookupEffectiveGuestPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.LookupEffectiveGuestPolicyRequest', ['instance']); - request.instance = defaultValue1; - const expectedHeaderRequestParams = `instance=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.EffectiveGuestPolicy() - ); - client.innerApiCalls.lookupEffectiveGuestPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.lookupEffectiveGuestPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IEffectiveGuestPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.lookupEffectiveGuestPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.lookupEffectiveGuestPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes lookupEffectiveGuestPolicy with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.LookupEffectiveGuestPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.LookupEffectiveGuestPolicyRequest', ['instance']); - request.instance = defaultValue1; - const expectedHeaderRequestParams = `instance=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.lookupEffectiveGuestPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.lookupEffectiveGuestPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.lookupEffectiveGuestPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.lookupEffectiveGuestPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes lookupEffectiveGuestPolicy with closed client', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.LookupEffectiveGuestPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.LookupEffectiveGuestPolicyRequest', ['instance']); - request.instance = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.lookupEffectiveGuestPolicy(request), expectedError); - }); - }); - - describe('listPatchJobs', () => { - it('invokes listPatchJobs without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListPatchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), - ]; - client.innerApiCalls.listPatchJobs = stubSimpleCall(expectedResponse); - const [response] = await client.listPatchJobs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPatchJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPatchJobs without error using callback', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListPatchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), - ]; - client.innerApiCalls.listPatchJobs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listPatchJobs( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchJob[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPatchJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPatchJobs with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListPatchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listPatchJobs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listPatchJobs(request), expectedError); - const actualRequest = (client.innerApiCalls.listPatchJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPatchJobsStream without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListPatchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), - ]; - client.descriptors.page.listPatchJobs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listPatchJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1beta.PatchJob[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1beta.PatchJob) => { - 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.listPatchJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPatchJobs, request)); - assert( - (client.descriptors.page.listPatchJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listPatchJobsStream with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListPatchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listPatchJobs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listPatchJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1beta.PatchJob[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1beta.PatchJob) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listPatchJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPatchJobs, request)); - assert( - (client.descriptors.page.listPatchJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPatchJobs without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListPatchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJob()), - ]; - client.descriptors.page.listPatchJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.osconfig.v1beta.IPatchJob[] = []; - const iterable = client.listPatchJobsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listPatchJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPatchJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPatchJobs with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListPatchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listPatchJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listPatchJobsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.osconfig.v1beta.IPatchJob[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listPatchJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPatchJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listPatchJobInstanceDetails', () => { - it('invokes listPatchJobInstanceDetails without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), - ]; - client.innerApiCalls.listPatchJobInstanceDetails = stubSimpleCall(expectedResponse); - const [response] = await client.listPatchJobInstanceDetails(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPatchJobInstanceDetails without error using callback', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), - ]; - client.innerApiCalls.listPatchJobInstanceDetails = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listPatchJobInstanceDetails( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchJobInstanceDetails[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPatchJobInstanceDetails with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listPatchJobInstanceDetails = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listPatchJobInstanceDetails(request), expectedError); - const actualRequest = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPatchJobInstanceDetails as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPatchJobInstanceDetailsStream without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), - ]; - client.descriptors.page.listPatchJobInstanceDetails.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listPatchJobInstanceDetailsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails) => { - 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.listPatchJobInstanceDetails.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPatchJobInstanceDetails, request)); - assert( - (client.descriptors.page.listPatchJobInstanceDetails.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listPatchJobInstanceDetailsStream with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listPatchJobInstanceDetails.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listPatchJobInstanceDetailsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listPatchJobInstanceDetails.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPatchJobInstanceDetails, request)); - assert( - (client.descriptors.page.listPatchJobInstanceDetails.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPatchJobInstanceDetails without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchJobInstanceDetails()), - ]; - client.descriptors.page.listPatchJobInstanceDetails.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.osconfig.v1beta.IPatchJobInstanceDetails[] = []; - const iterable = client.listPatchJobInstanceDetailsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listPatchJobInstanceDetails.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPatchJobInstanceDetails.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPatchJobInstanceDetails with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchJobInstanceDetailsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listPatchJobInstanceDetails.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listPatchJobInstanceDetailsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.osconfig.v1beta.IPatchJobInstanceDetails[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listPatchJobInstanceDetails.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPatchJobInstanceDetails.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listPatchDeployments', () => { - it('invokes listPatchDeployments without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), - ]; - client.innerApiCalls.listPatchDeployments = stubSimpleCall(expectedResponse); - const [response] = await client.listPatchDeployments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPatchDeployments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPatchDeployments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPatchDeployments without error using callback', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), - ]; - client.innerApiCalls.listPatchDeployments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listPatchDeployments( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IPatchDeployment[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPatchDeployments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPatchDeployments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPatchDeployments with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listPatchDeployments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listPatchDeployments(request), expectedError); - const actualRequest = (client.innerApiCalls.listPatchDeployments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPatchDeployments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPatchDeploymentsStream without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), - ]; - client.descriptors.page.listPatchDeployments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listPatchDeploymentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1beta.PatchDeployment[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1beta.PatchDeployment) => { - 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.listPatchDeployments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPatchDeployments, request)); - assert( - (client.descriptors.page.listPatchDeployments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listPatchDeploymentsStream with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listPatchDeployments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listPatchDeploymentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1beta.PatchDeployment[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1beta.PatchDeployment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listPatchDeployments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPatchDeployments, request)); - assert( - (client.descriptors.page.listPatchDeployments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPatchDeployments without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.PatchDeployment()), - ]; - client.descriptors.page.listPatchDeployments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.osconfig.v1beta.IPatchDeployment[] = []; - const iterable = client.listPatchDeploymentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listPatchDeployments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPatchDeployments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPatchDeployments with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListPatchDeploymentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listPatchDeployments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listPatchDeploymentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.osconfig.v1beta.IPatchDeployment[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listPatchDeployments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPatchDeployments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listGuestPolicies', () => { - it('invokes listGuestPolicies without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), - ]; - client.innerApiCalls.listGuestPolicies = stubSimpleCall(expectedResponse); - const [response] = await client.listGuestPolicies(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listGuestPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGuestPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listGuestPolicies without error using callback', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), - ]; - client.innerApiCalls.listGuestPolicies = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listGuestPolicies( - request, - (err?: Error|null, result?: protos.google.cloud.osconfig.v1beta.IGuestPolicy[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listGuestPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGuestPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listGuestPolicies with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listGuestPolicies = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listGuestPolicies(request), expectedError); - const actualRequest = (client.innerApiCalls.listGuestPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGuestPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listGuestPoliciesStream without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), - ]; - client.descriptors.page.listGuestPolicies.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listGuestPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1beta.GuestPolicy[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1beta.GuestPolicy) => { - 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.listGuestPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listGuestPolicies, request)); - assert( - (client.descriptors.page.listGuestPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listGuestPoliciesStream with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listGuestPolicies.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listGuestPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.osconfig.v1beta.GuestPolicy[] = []; - stream.on('data', (response: protos.google.cloud.osconfig.v1beta.GuestPolicy) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listGuestPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listGuestPolicies, request)); - assert( - (client.descriptors.page.listGuestPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listGuestPolicies without error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), - generateSampleMessage(new protos.google.cloud.osconfig.v1beta.GuestPolicy()), - ]; - client.descriptors.page.listGuestPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.osconfig.v1beta.IGuestPolicy[] = []; - const iterable = client.listGuestPoliciesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listGuestPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listGuestPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listGuestPolicies with error', async () => { - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.osconfig.v1beta.ListGuestPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listGuestPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listGuestPoliciesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.osconfig.v1beta.IGuestPolicy[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listGuestPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listGuestPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('guestPolicy', () => { - const fakePath = "/rendered/path/guestPolicy"; - const expectedParameters = { - project: "projectValue", - guest_policy: "guestPolicyValue", - }; - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.guestPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.guestPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('guestPolicyPath', () => { - const result = client.guestPolicyPath("projectValue", "guestPolicyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.guestPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromGuestPolicyName', () => { - const result = client.matchProjectFromGuestPolicyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.guestPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchGuestPolicyFromGuestPolicyName', () => { - const result = client.matchGuestPolicyFromGuestPolicyName(fakePath); - assert.strictEqual(result, "guestPolicyValue"); - assert((client.pathTemplates.guestPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('patchDeployment', () => { - const fakePath = "/rendered/path/patchDeployment"; - const expectedParameters = { - project: "projectValue", - patch_deployment: "patchDeploymentValue", - }; - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.patchDeploymentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.patchDeploymentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('patchDeploymentPath', () => { - const result = client.patchDeploymentPath("projectValue", "patchDeploymentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.patchDeploymentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPatchDeploymentName', () => { - const result = client.matchProjectFromPatchDeploymentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.patchDeploymentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPatchDeploymentFromPatchDeploymentName', () => { - const result = client.matchPatchDeploymentFromPatchDeploymentName(fakePath); - assert.strictEqual(result, "patchDeploymentValue"); - assert((client.pathTemplates.patchDeploymentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('patchJob', () => { - const fakePath = "/rendered/path/patchJob"; - const expectedParameters = { - project: "projectValue", - patch_job: "patchJobValue", - }; - const client = new osconfigserviceModule.v1beta.OsConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.patchJobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.patchJobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('patchJobPath', () => { - const result = client.patchJobPath("projectValue", "patchJobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.patchJobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPatchJobName', () => { - const result = client.matchProjectFromPatchJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.patchJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPatchJobFromPatchJobName', () => { - const result = client.matchPatchJobFromPatchJobName(fakePath); - assert.strictEqual(result, "patchJobValue"); - assert((client.pathTemplates.patchJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-osconfig/v1beta/tsconfig.json b/owl-bot-staging/google-cloud-osconfig/v1beta/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/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-osconfig/v1beta/webpack.config.js b/owl-bot-staging/google-cloud-osconfig/v1beta/webpack.config.js deleted file mode 100644 index def8ac29a1c..00000000000 --- a/owl-bot-staging/google-cloud-osconfig/v1beta/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: 'OsConfigService', - filename: './os-config-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-oslogin/v1/.eslintignore b/owl-bot-staging/google-cloud-oslogin/v1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-oslogin/v1/.eslintrc.json b/owl-bot-staging/google-cloud-oslogin/v1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-oslogin/v1/.gitignore b/owl-bot-staging/google-cloud-oslogin/v1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-oslogin/v1/.jsdoc.js b/owl-bot-staging/google-cloud-oslogin/v1/.jsdoc.js deleted file mode 100644 index f945dc1e9e4..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/.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/os-login', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-oslogin/v1/.mocharc.js b/owl-bot-staging/google-cloud-oslogin/v1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/.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-oslogin/v1/.prettierrc.js b/owl-bot-staging/google-cloud-oslogin/v1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/.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-oslogin/v1/README.md b/owl-bot-staging/google-cloud-oslogin/v1/README.md deleted file mode 100644 index f7acdc89a3a..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Oslogin: Nodejs Client diff --git a/owl-bot-staging/google-cloud-oslogin/v1/package.json b/owl-bot-staging/google-cloud-oslogin/v1/package.json deleted file mode 100644 index 7dc97d13da3..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/os-login", - "version": "0.1.0", - "description": "Oslogin client for Node.js", - "repository": "googleapis/nodejs-oslogin", - "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 oslogin", - "oslogin", - "os login service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-oslogin/v1/protos/google/cloud/oslogin/common/common.proto b/owl-bot-staging/google-cloud-oslogin/v1/protos/google/cloud/oslogin/common/common.proto deleted file mode 100644 index c0a15cc71fd..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/protos/google/cloud/oslogin/common/common.proto +++ /dev/null @@ -1,108 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.oslogin.common; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; - -option csharp_namespace = "Google.Cloud.OsLogin.Common"; -option go_package = "cloud.google.com/go/oslogin/common/commonpb;commonpb"; -option java_outer_classname = "OsLoginProto"; -option java_package = "com.google.cloud.oslogin.common"; -option php_namespace = "Google\\Cloud\\OsLogin\\Common"; -option ruby_package = "Google::Cloud::OsLogin::Common"; -option (google.api.resource_definition) = { - type: "oslogin.googleapis.com/User" - pattern: "users/{user}" -}; - -// The operating system options for account entries. -enum OperatingSystemType { - // The operating system type associated with the user account information is - // unspecified. - OPERATING_SYSTEM_TYPE_UNSPECIFIED = 0; - - // Linux user account information. - LINUX = 1; - - // Windows user account information. - WINDOWS = 2; -} - -// The POSIX account information associated with a Google account. -message PosixAccount { - option (google.api.resource) = { - type: "oslogin.googleapis.com/PosixAccount" - pattern: "users/{user}/projects/{project}" - }; - - // Only one POSIX account can be marked as primary. - bool primary = 1; - - // The username of the POSIX account. - string username = 2; - - // The user ID. - int64 uid = 3; - - // The default group ID. - int64 gid = 4; - - // The path to the home directory for this account. - string home_directory = 5; - - // The path to the logic shell for this account. - string shell = 6; - - // The GECOS (user information) entry for this account. - string gecos = 7; - - // System identifier for which account the username or uid applies to. - // By default, the empty value is used. - string system_id = 8; - - // Output only. A POSIX account identifier. - string account_id = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The operating system type where this account applies. - OperatingSystemType operating_system_type = 10; - - // Output only. The canonical resource name. - string name = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// The SSH public key information associated with a Google account. -message SshPublicKey { - option (google.api.resource) = { - type: "oslogin.googleapis.com/SshPublicKey" - pattern: "users/{user}/sshPublicKeys/{fingerprint}" - }; - - // Public key text in SSH format, defined by - // RFC4253 - // section 6.6. - string key = 1; - - // An expiration time in microseconds since epoch. - int64 expiration_time_usec = 2; - - // Output only. The SHA-256 fingerprint of the SSH public key. - string fingerprint = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The canonical resource name. - string name = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-oslogin/v1/protos/google/cloud/oslogin/v1/oslogin.proto b/owl-bot-staging/google-cloud-oslogin/v1/protos/google/cloud/oslogin/v1/oslogin.proto deleted file mode 100644 index ca890654b62..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/protos/google/cloud/oslogin/v1/oslogin.proto +++ /dev/null @@ -1,248 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.oslogin.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/oslogin/common/common.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option csharp_namespace = "Google.Cloud.OsLogin.V1"; -option go_package = "cloud.google.com/go/oslogin/apiv1/osloginpb;osloginpb"; -option java_multiple_files = true; -option java_outer_classname = "OsLoginProto"; -option java_package = "com.google.cloud.oslogin.v1"; -option php_namespace = "Google\\Cloud\\OsLogin\\V1"; -option ruby_package = "Google::Cloud::OsLogin::V1"; - -// Cloud OS Login API -// -// The Cloud OS Login API allows you to manage users and their associated SSH -// public keys for logging into virtual machines on Google Cloud Platform. -service OsLoginService { - option (google.api.default_host) = "oslogin.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-platform.read-only," - "https://www.googleapis.com/auth/compute," - "https://www.googleapis.com/auth/compute.readonly"; - - // Create an SSH public key - rpc CreateSshPublicKey(CreateSshPublicKeyRequest) - returns (google.cloud.oslogin.common.SshPublicKey) { - option (google.api.http) = { - post: "/v1/{parent=users/*}/sshPublicKeys" - body: "ssh_public_key" - }; - option (google.api.method_signature) = "parent,ssh_public_key"; - } - - // Deletes a POSIX account. - rpc DeletePosixAccount(DeletePosixAccountRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=users/*/projects/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Deletes an SSH public key. - rpc DeleteSshPublicKey(DeleteSshPublicKeyRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=users/*/sshPublicKeys/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Retrieves the profile information used for logging in to a virtual machine - // on Google Compute Engine. - rpc GetLoginProfile(GetLoginProfileRequest) returns (LoginProfile) { - option (google.api.http) = { - get: "/v1/{name=users/*}/loginProfile" - }; - option (google.api.method_signature) = "name"; - } - - // Retrieves an SSH public key. - rpc GetSshPublicKey(GetSshPublicKeyRequest) - returns (google.cloud.oslogin.common.SshPublicKey) { - option (google.api.http) = { - get: "/v1/{name=users/*/sshPublicKeys/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Adds an SSH public key and returns the profile information. Default POSIX - // account information is set when no username and UID exist as part of the - // login profile. - rpc ImportSshPublicKey(ImportSshPublicKeyRequest) - returns (ImportSshPublicKeyResponse) { - option (google.api.http) = { - post: "/v1/{parent=users/*}:importSshPublicKey" - body: "ssh_public_key" - }; - option (google.api.method_signature) = "parent,ssh_public_key"; - option (google.api.method_signature) = "parent,ssh_public_key,project_id"; - } - - // Updates an SSH public key and returns the profile information. This method - // supports patch semantics. - rpc UpdateSshPublicKey(UpdateSshPublicKeyRequest) - returns (google.cloud.oslogin.common.SshPublicKey) { - option (google.api.http) = { - patch: "/v1/{name=users/*/sshPublicKeys/*}" - body: "ssh_public_key" - }; - option (google.api.method_signature) = "name,ssh_public_key"; - option (google.api.method_signature) = "name,ssh_public_key,update_mask"; - } -} - -// The user profile information used for logging in to a virtual machine on -// Google Compute Engine. -message LoginProfile { - // Required. A unique user ID. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // The list of POSIX accounts associated with the user. - repeated google.cloud.oslogin.common.PosixAccount posix_accounts = 2; - - // A map from SSH public key fingerprint to the associated key object. - map ssh_public_keys = 3; -} - -// A request message for creating an SSH public key. -message CreateSshPublicKeyRequest { - // Required. The unique ID for the user in format `users/{user}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "oslogin.googleapis.com/SshPublicKey" - } - ]; - - // Required. The SSH public key and expiration time. - google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 - [(google.api.field_behavior) = REQUIRED]; -} - -// A request message for deleting a POSIX account entry. -message DeletePosixAccountRequest { - // Required. A reference to the POSIX account to update. POSIX accounts are - // identified by the project ID they are associated with. A reference to the - // POSIX account is in format `users/{user}/projects/{project}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "oslogin.googleapis.com/PosixAccount" - } - ]; -} - -// A request message for deleting an SSH public key. -message DeleteSshPublicKeyRequest { - // Required. The fingerprint of the public key to update. Public keys are - // identified by their SHA-256 fingerprint. The fingerprint of the public key - // is in format `users/{user}/sshPublicKeys/{fingerprint}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "oslogin.googleapis.com/SshPublicKey" - } - ]; -} - -// A request message for retrieving the login profile information for a user. -message GetLoginProfileRequest { - // Required. The unique ID for the user in format `users/{user}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "oslogin.googleapis.com/PosixAccount" - } - ]; - - // The project ID of the Google Cloud Platform project. - string project_id = 2; - - // A system ID for filtering the results of the request. - string system_id = 3; -} - -// A request message for retrieving an SSH public key. -message GetSshPublicKeyRequest { - // Required. The fingerprint of the public key to retrieve. Public keys are - // identified by their SHA-256 fingerprint. The fingerprint of the public key - // is in format `users/{user}/sshPublicKeys/{fingerprint}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "oslogin.googleapis.com/SshPublicKey" - } - ]; -} - -// A request message for importing an SSH public key. -message ImportSshPublicKeyRequest { - // Required. The unique ID for the user in format `users/{user}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "oslogin.googleapis.com/SshPublicKey" - } - ]; - - // Optional. The SSH public key and expiration time. - google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 - [(google.api.field_behavior) = OPTIONAL]; - - // The project ID of the Google Cloud Platform project. - string project_id = 3; -} - -// A response message for importing an SSH public key. -message ImportSshPublicKeyResponse { - // The login profile information for the user. - LoginProfile login_profile = 1; - - // Detailed information about import results. - string details = 2; -} - -// A request message for updating an SSH public key. -message UpdateSshPublicKeyRequest { - // Required. The fingerprint of the public key to update. Public keys are - // identified by their SHA-256 fingerprint. The fingerprint of the public key - // is in format `users/{user}/sshPublicKeys/{fingerprint}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "oslogin.googleapis.com/SshPublicKey" - } - ]; - - // Required. The SSH public key and expiration time. - google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Mask to control which fields get updated. Updates all if not present. - google.protobuf.FieldMask update_mask = 3; -} diff --git a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.create_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.create_ssh_public_key.js deleted file mode 100644 index cbf878d6847..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.create_ssh_public_key.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(parent, sshPublicKey) { - // [START oslogin_v1_generated_OsLoginService_CreateSshPublicKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The unique ID for the user in format `users/{user}`. - */ - // const parent = 'abc123' - /** - * Required. The SSH public key and expiration time. - */ - // const sshPublicKey = {} - - // Imports the Oslogin library - const {OsLoginServiceClient} = require('@google-cloud/os-login').v1; - - // Instantiates a client - const osloginClient = new OsLoginServiceClient(); - - async function callCreateSshPublicKey() { - // Construct request - const request = { - parent, - sshPublicKey, - }; - - // Run request - const response = await osloginClient.createSshPublicKey(request); - console.log(response); - } - - callCreateSshPublicKey(); - // [END oslogin_v1_generated_OsLoginService_CreateSshPublicKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.delete_posix_account.js b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.delete_posix_account.js deleted file mode 100644 index 3464e5836ba..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.delete_posix_account.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 oslogin_v1_generated_OsLoginService_DeletePosixAccount_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A reference to the POSIX account to update. POSIX accounts are - * identified by the project ID they are associated with. A reference to the - * POSIX account is in format `users/{user}/projects/{project}`. - */ - // const name = 'abc123' - - // Imports the Oslogin library - const {OsLoginServiceClient} = require('@google-cloud/os-login').v1; - - // Instantiates a client - const osloginClient = new OsLoginServiceClient(); - - async function callDeletePosixAccount() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osloginClient.deletePosixAccount(request); - console.log(response); - } - - callDeletePosixAccount(); - // [END oslogin_v1_generated_OsLoginService_DeletePosixAccount_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.delete_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.delete_ssh_public_key.js deleted file mode 100644 index 82cf1a60119..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.delete_ssh_public_key.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 oslogin_v1_generated_OsLoginService_DeleteSshPublicKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The fingerprint of the public key to update. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - */ - // const name = 'abc123' - - // Imports the Oslogin library - const {OsLoginServiceClient} = require('@google-cloud/os-login').v1; - - // Instantiates a client - const osloginClient = new OsLoginServiceClient(); - - async function callDeleteSshPublicKey() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osloginClient.deleteSshPublicKey(request); - console.log(response); - } - - callDeleteSshPublicKey(); - // [END oslogin_v1_generated_OsLoginService_DeleteSshPublicKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.get_login_profile.js b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.get_login_profile.js deleted file mode 100644 index 8f2ed7bcf29..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.get_login_profile.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(name) { - // [START oslogin_v1_generated_OsLoginService_GetLoginProfile_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The unique ID for the user in format `users/{user}`. - */ - // const name = 'abc123' - /** - * The project ID of the Google Cloud Platform project. - */ - // const projectId = 'abc123' - /** - * A system ID for filtering the results of the request. - */ - // const systemId = 'abc123' - - // Imports the Oslogin library - const {OsLoginServiceClient} = require('@google-cloud/os-login').v1; - - // Instantiates a client - const osloginClient = new OsLoginServiceClient(); - - async function callGetLoginProfile() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osloginClient.getLoginProfile(request); - console.log(response); - } - - callGetLoginProfile(); - // [END oslogin_v1_generated_OsLoginService_GetLoginProfile_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.get_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.get_ssh_public_key.js deleted file mode 100644 index 6654b51e38d..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.get_ssh_public_key.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 oslogin_v1_generated_OsLoginService_GetSshPublicKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The fingerprint of the public key to retrieve. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - */ - // const name = 'abc123' - - // Imports the Oslogin library - const {OsLoginServiceClient} = require('@google-cloud/os-login').v1; - - // Instantiates a client - const osloginClient = new OsLoginServiceClient(); - - async function callGetSshPublicKey() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osloginClient.getSshPublicKey(request); - console.log(response); - } - - callGetSshPublicKey(); - // [END oslogin_v1_generated_OsLoginService_GetSshPublicKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.import_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.import_ssh_public_key.js deleted file mode 100644 index 877e770826c..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.import_ssh_public_key.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(parent) { - // [START oslogin_v1_generated_OsLoginService_ImportSshPublicKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The unique ID for the user in format `users/{user}`. - */ - // const parent = 'abc123' - /** - * Optional. The SSH public key and expiration time. - */ - // const sshPublicKey = {} - /** - * The project ID of the Google Cloud Platform project. - */ - // const projectId = 'abc123' - - // Imports the Oslogin library - const {OsLoginServiceClient} = require('@google-cloud/os-login').v1; - - // Instantiates a client - const osloginClient = new OsLoginServiceClient(); - - async function callImportSshPublicKey() { - // Construct request - const request = { - parent, - }; - - // Run request - const response = await osloginClient.importSshPublicKey(request); - console.log(response); - } - - callImportSshPublicKey(); - // [END oslogin_v1_generated_OsLoginService_ImportSshPublicKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.update_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.update_ssh_public_key.js deleted file mode 100644 index 30898bb0441..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/os_login_service.update_ssh_public_key.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(name, sshPublicKey) { - // [START oslogin_v1_generated_OsLoginService_UpdateSshPublicKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The fingerprint of the public key to update. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - */ - // const name = 'abc123' - /** - * Required. The SSH public key and expiration time. - */ - // const sshPublicKey = {} - /** - * Mask to control which fields get updated. Updates all if not present. - */ - // const updateMask = {} - - // Imports the Oslogin library - const {OsLoginServiceClient} = require('@google-cloud/os-login').v1; - - // Instantiates a client - const osloginClient = new OsLoginServiceClient(); - - async function callUpdateSshPublicKey() { - // Construct request - const request = { - name, - sshPublicKey, - }; - - // Run request - const response = await osloginClient.updateSshPublicKey(request); - console.log(response); - } - - callUpdateSshPublicKey(); - // [END oslogin_v1_generated_OsLoginService_UpdateSshPublicKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/snippet_metadata_google.cloud.oslogin.v1.json b/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/snippet_metadata_google.cloud.oslogin.v1.json deleted file mode 100644 index 2c35446f956..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/samples/generated/v1/snippet_metadata_google.cloud.oslogin.v1.json +++ /dev/null @@ -1,323 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-oslogin", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.oslogin.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "oslogin_v1_generated_OsLoginService_CreateSshPublicKey_async", - "title": "OsLoginService createSshPublicKey Sample", - "origin": "API_DEFINITION", - "description": " Create an SSH public key", - "canonical": true, - "file": "os_login_service.create_ssh_public_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateSshPublicKey", - "fullName": "google.cloud.oslogin.v1.OsLoginService.CreateSshPublicKey", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "ssh_public_key", - "type": ".google.cloud.oslogin.common.SshPublicKey" - } - ], - "resultType": ".google.cloud.oslogin.common.SshPublicKey", - "client": { - "shortName": "OsLoginServiceClient", - "fullName": "google.cloud.oslogin.v1.OsLoginServiceClient" - }, - "method": { - "shortName": "CreateSshPublicKey", - "fullName": "google.cloud.oslogin.v1.OsLoginService.CreateSshPublicKey", - "service": { - "shortName": "OsLoginService", - "fullName": "google.cloud.oslogin.v1.OsLoginService" - } - } - } - }, - { - "regionTag": "oslogin_v1_generated_OsLoginService_DeletePosixAccount_async", - "title": "OsLoginService deletePosixAccount Sample", - "origin": "API_DEFINITION", - "description": " Deletes a POSIX account.", - "canonical": true, - "file": "os_login_service.delete_posix_account.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeletePosixAccount", - "fullName": "google.cloud.oslogin.v1.OsLoginService.DeletePosixAccount", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "OsLoginServiceClient", - "fullName": "google.cloud.oslogin.v1.OsLoginServiceClient" - }, - "method": { - "shortName": "DeletePosixAccount", - "fullName": "google.cloud.oslogin.v1.OsLoginService.DeletePosixAccount", - "service": { - "shortName": "OsLoginService", - "fullName": "google.cloud.oslogin.v1.OsLoginService" - } - } - } - }, - { - "regionTag": "oslogin_v1_generated_OsLoginService_DeleteSshPublicKey_async", - "title": "OsLoginService deleteSshPublicKey Sample", - "origin": "API_DEFINITION", - "description": " Deletes an SSH public key.", - "canonical": true, - "file": "os_login_service.delete_ssh_public_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteSshPublicKey", - "fullName": "google.cloud.oslogin.v1.OsLoginService.DeleteSshPublicKey", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "OsLoginServiceClient", - "fullName": "google.cloud.oslogin.v1.OsLoginServiceClient" - }, - "method": { - "shortName": "DeleteSshPublicKey", - "fullName": "google.cloud.oslogin.v1.OsLoginService.DeleteSshPublicKey", - "service": { - "shortName": "OsLoginService", - "fullName": "google.cloud.oslogin.v1.OsLoginService" - } - } - } - }, - { - "regionTag": "oslogin_v1_generated_OsLoginService_GetLoginProfile_async", - "title": "OsLoginService getLoginProfile Sample", - "origin": "API_DEFINITION", - "description": " Retrieves the profile information used for logging in to a virtual machine on Google Compute Engine.", - "canonical": true, - "file": "os_login_service.get_login_profile.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetLoginProfile", - "fullName": "google.cloud.oslogin.v1.OsLoginService.GetLoginProfile", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "project_id", - "type": "TYPE_STRING" - }, - { - "name": "system_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.oslogin.v1.LoginProfile", - "client": { - "shortName": "OsLoginServiceClient", - "fullName": "google.cloud.oslogin.v1.OsLoginServiceClient" - }, - "method": { - "shortName": "GetLoginProfile", - "fullName": "google.cloud.oslogin.v1.OsLoginService.GetLoginProfile", - "service": { - "shortName": "OsLoginService", - "fullName": "google.cloud.oslogin.v1.OsLoginService" - } - } - } - }, - { - "regionTag": "oslogin_v1_generated_OsLoginService_GetSshPublicKey_async", - "title": "OsLoginService getSshPublicKey Sample", - "origin": "API_DEFINITION", - "description": " Retrieves an SSH public key.", - "canonical": true, - "file": "os_login_service.get_ssh_public_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetSshPublicKey", - "fullName": "google.cloud.oslogin.v1.OsLoginService.GetSshPublicKey", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.oslogin.common.SshPublicKey", - "client": { - "shortName": "OsLoginServiceClient", - "fullName": "google.cloud.oslogin.v1.OsLoginServiceClient" - }, - "method": { - "shortName": "GetSshPublicKey", - "fullName": "google.cloud.oslogin.v1.OsLoginService.GetSshPublicKey", - "service": { - "shortName": "OsLoginService", - "fullName": "google.cloud.oslogin.v1.OsLoginService" - } - } - } - }, - { - "regionTag": "oslogin_v1_generated_OsLoginService_ImportSshPublicKey_async", - "title": "OsLoginService importSshPublicKey Sample", - "origin": "API_DEFINITION", - "description": " Adds an SSH public key and returns the profile information. Default POSIX account information is set when no username and UID exist as part of the login profile.", - "canonical": true, - "file": "os_login_service.import_ssh_public_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportSshPublicKey", - "fullName": "google.cloud.oslogin.v1.OsLoginService.ImportSshPublicKey", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "ssh_public_key", - "type": ".google.cloud.oslogin.common.SshPublicKey" - }, - { - "name": "project_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.oslogin.v1.ImportSshPublicKeyResponse", - "client": { - "shortName": "OsLoginServiceClient", - "fullName": "google.cloud.oslogin.v1.OsLoginServiceClient" - }, - "method": { - "shortName": "ImportSshPublicKey", - "fullName": "google.cloud.oslogin.v1.OsLoginService.ImportSshPublicKey", - "service": { - "shortName": "OsLoginService", - "fullName": "google.cloud.oslogin.v1.OsLoginService" - } - } - } - }, - { - "regionTag": "oslogin_v1_generated_OsLoginService_UpdateSshPublicKey_async", - "title": "OsLoginService updateSshPublicKey Sample", - "origin": "API_DEFINITION", - "description": " Updates an SSH public key and returns the profile information. This method supports patch semantics.", - "canonical": true, - "file": "os_login_service.update_ssh_public_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateSshPublicKey", - "fullName": "google.cloud.oslogin.v1.OsLoginService.UpdateSshPublicKey", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "ssh_public_key", - "type": ".google.cloud.oslogin.common.SshPublicKey" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.oslogin.common.SshPublicKey", - "client": { - "shortName": "OsLoginServiceClient", - "fullName": "google.cloud.oslogin.v1.OsLoginServiceClient" - }, - "method": { - "shortName": "UpdateSshPublicKey", - "fullName": "google.cloud.oslogin.v1.OsLoginService.UpdateSshPublicKey", - "service": { - "shortName": "OsLoginService", - "fullName": "google.cloud.oslogin.v1.OsLoginService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-oslogin/v1/src/index.ts b/owl-bot-staging/google-cloud-oslogin/v1/src/index.ts deleted file mode 100644 index 85e467c85f4..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/src/index.ts +++ /dev/null @@ -1,25 +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 v1 from './v1'; -const OsLoginServiceClient = v1.OsLoginServiceClient; -type OsLoginServiceClient = v1.OsLoginServiceClient; -export {v1, OsLoginServiceClient}; -export default {v1, OsLoginServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-oslogin/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-oslogin/v1/src/v1/gapic_metadata.json deleted file mode 100644 index fc08cf26063..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.oslogin.v1", - "libraryPackage": "@google-cloud/os-login", - "services": { - "OsLoginService": { - "clients": { - "grpc": { - "libraryClient": "OsLoginServiceClient", - "rpcs": { - "CreateSshPublicKey": { - "methods": [ - "createSshPublicKey" - ] - }, - "DeletePosixAccount": { - "methods": [ - "deletePosixAccount" - ] - }, - "DeleteSshPublicKey": { - "methods": [ - "deleteSshPublicKey" - ] - }, - "GetLoginProfile": { - "methods": [ - "getLoginProfile" - ] - }, - "GetSshPublicKey": { - "methods": [ - "getSshPublicKey" - ] - }, - "ImportSshPublicKey": { - "methods": [ - "importSshPublicKey" - ] - }, - "UpdateSshPublicKey": { - "methods": [ - "updateSshPublicKey" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "OsLoginServiceClient", - "rpcs": { - "CreateSshPublicKey": { - "methods": [ - "createSshPublicKey" - ] - }, - "DeletePosixAccount": { - "methods": [ - "deletePosixAccount" - ] - }, - "DeleteSshPublicKey": { - "methods": [ - "deleteSshPublicKey" - ] - }, - "GetLoginProfile": { - "methods": [ - "getLoginProfile" - ] - }, - "GetSshPublicKey": { - "methods": [ - "getSshPublicKey" - ] - }, - "ImportSshPublicKey": { - "methods": [ - "importSshPublicKey" - ] - }, - "UpdateSshPublicKey": { - "methods": [ - "updateSshPublicKey" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-oslogin/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-oslogin/v1/src/v1/index.ts deleted file mode 100644 index 477969ae393..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +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 {OsLoginServiceClient} from './os_login_service_client'; diff --git a/owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_client.ts b/owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_client.ts deleted file mode 100644 index 316a8263a1c..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_client.ts +++ /dev/null @@ -1,942 +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} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/os_login_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './os_login_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Cloud OS Login API - * - * The Cloud OS Login API allows you to manage users and their associated SSH - * public keys for logging into virtual machines on Google Cloud Platform. - * @class - * @memberof v1 - */ -export class OsLoginServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - osLoginServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of OsLoginServiceClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 OsLoginServiceClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof OsLoginServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - posixAccountPathTemplate: new this._gaxModule.PathTemplate( - 'users/{user}/projects/{project}' - ), - sshPublicKeyPathTemplate: new this._gaxModule.PathTemplate( - 'users/{user}/sshPublicKeys/{fingerprint}' - ), - userPathTemplate: new this._gaxModule.PathTemplate( - 'users/{user}' - ), - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.oslogin.v1.OsLoginService', 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.osLoginServiceStub) { - return this.osLoginServiceStub; - } - - // Put together the "service stub" for - // google.cloud.oslogin.v1.OsLoginService. - this.osLoginServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.oslogin.v1.OsLoginService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.oslogin.v1.OsLoginService, - 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 osLoginServiceStubMethods = - ['createSshPublicKey', 'deletePosixAccount', 'deleteSshPublicKey', 'getLoginProfile', 'getSshPublicKey', 'importSshPublicKey', 'updateSshPublicKey']; - for (const methodName of osLoginServiceStubMethods) { - const callPromise = this.osLoginServiceStub.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.osLoginServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'oslogin.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 'oslogin.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - 'https://www.googleapis.com/auth/compute', - 'https://www.googleapis.com/auth/compute.readonly' - ]; - } - - 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 -- - // ------------------- -/** - * Create an SSH public key - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The unique ID for the user in format `users/{user}`. - * @param {google.cloud.oslogin.common.SshPublicKey} request.sshPublicKey - * Required. The SSH public key and expiration time. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.oslogin.common.SshPublicKey|SshPublicKey}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_login_service.create_ssh_public_key.js - * region_tag:oslogin_v1_generated_OsLoginService_CreateSshPublicKey_async - */ - createSshPublicKey( - request?: protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest|undefined, {}|undefined - ]>; - createSshPublicKey( - request: protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - createSshPublicKey( - request: protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest, - callback: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - createSshPublicKey( - request?: protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createSshPublicKey(request, options, callback); - } -/** - * Deletes a POSIX account. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A reference to the POSIX account to update. POSIX accounts are - * identified by the project ID they are associated with. A reference to the - * POSIX account is in format `users/{user}/projects/{project}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_login_service.delete_posix_account.js - * region_tag:oslogin_v1_generated_OsLoginService_DeletePosixAccount_async - */ - deletePosixAccount( - request?: protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest|undefined, {}|undefined - ]>; - deletePosixAccount( - request: protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest|null|undefined, - {}|null|undefined>): void; - deletePosixAccount( - request: protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest|null|undefined, - {}|null|undefined>): void; - deletePosixAccount( - request?: protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deletePosixAccount(request, options, callback); - } -/** - * Deletes an SSH public key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The fingerprint of the public key to update. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_login_service.delete_ssh_public_key.js - * region_tag:oslogin_v1_generated_OsLoginService_DeleteSshPublicKey_async - */ - deleteSshPublicKey( - request?: protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest|undefined, {}|undefined - ]>; - deleteSshPublicKey( - request: protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - deleteSshPublicKey( - request: protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - deleteSshPublicKey( - request?: protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteSshPublicKey(request, options, callback); - } -/** - * Retrieves the profile information used for logging in to a virtual machine - * on Google Compute Engine. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The unique ID for the user in format `users/{user}`. - * @param {string} request.projectId - * The project ID of the Google Cloud Platform project. - * @param {string} request.systemId - * A system ID for filtering the results of the request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.oslogin.v1.LoginProfile|LoginProfile}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_login_service.get_login_profile.js - * region_tag:oslogin_v1_generated_OsLoginService_GetLoginProfile_async - */ - getLoginProfile( - request?: protos.google.cloud.oslogin.v1.IGetLoginProfileRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oslogin.v1.ILoginProfile, - protos.google.cloud.oslogin.v1.IGetLoginProfileRequest|undefined, {}|undefined - ]>; - getLoginProfile( - request: protos.google.cloud.oslogin.v1.IGetLoginProfileRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oslogin.v1.ILoginProfile, - protos.google.cloud.oslogin.v1.IGetLoginProfileRequest|null|undefined, - {}|null|undefined>): void; - getLoginProfile( - request: protos.google.cloud.oslogin.v1.IGetLoginProfileRequest, - callback: Callback< - protos.google.cloud.oslogin.v1.ILoginProfile, - protos.google.cloud.oslogin.v1.IGetLoginProfileRequest|null|undefined, - {}|null|undefined>): void; - getLoginProfile( - request?: protos.google.cloud.oslogin.v1.IGetLoginProfileRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oslogin.v1.ILoginProfile, - protos.google.cloud.oslogin.v1.IGetLoginProfileRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.oslogin.v1.ILoginProfile, - protos.google.cloud.oslogin.v1.IGetLoginProfileRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oslogin.v1.ILoginProfile, - protos.google.cloud.oslogin.v1.IGetLoginProfileRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getLoginProfile(request, options, callback); - } -/** - * Retrieves an SSH public key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The fingerprint of the public key to retrieve. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.oslogin.common.SshPublicKey|SshPublicKey}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_login_service.get_ssh_public_key.js - * region_tag:oslogin_v1_generated_OsLoginService_GetSshPublicKey_async - */ - getSshPublicKey( - request?: protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest|undefined, {}|undefined - ]>; - getSshPublicKey( - request: protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - getSshPublicKey( - request: protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest, - callback: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - getSshPublicKey( - request?: protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getSshPublicKey(request, options, callback); - } -/** - * Adds an SSH public key and returns the profile information. Default POSIX - * account information is set when no username and UID exist as part of the - * login profile. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The unique ID for the user in format `users/{user}`. - * @param {google.cloud.oslogin.common.SshPublicKey} [request.sshPublicKey] - * Optional. The SSH public key and expiration time. - * @param {string} request.projectId - * The project ID of the Google Cloud Platform project. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.oslogin.v1.ImportSshPublicKeyResponse|ImportSshPublicKeyResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_login_service.import_ssh_public_key.js - * region_tag:oslogin_v1_generated_OsLoginService_ImportSshPublicKey_async - */ - importSshPublicKey( - request?: protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, - protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest|undefined, {}|undefined - ]>; - importSshPublicKey( - request: protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, - protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - importSshPublicKey( - request: protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest, - callback: Callback< - protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, - protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - importSshPublicKey( - request?: protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, - protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, - protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, - protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.importSshPublicKey(request, options, callback); - } -/** - * Updates an SSH public key and returns the profile information. This method - * supports patch semantics. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The fingerprint of the public key to update. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * @param {google.cloud.oslogin.common.SshPublicKey} request.sshPublicKey - * Required. The SSH public key and expiration time. - * @param {google.protobuf.FieldMask} request.updateMask - * Mask to control which fields get updated. Updates all if not present. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.oslogin.common.SshPublicKey|SshPublicKey}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/os_login_service.update_ssh_public_key.js - * region_tag:oslogin_v1_generated_OsLoginService_UpdateSshPublicKey_async - */ - updateSshPublicKey( - request?: protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest|undefined, {}|undefined - ]>; - updateSshPublicKey( - request: protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - updateSshPublicKey( - request: protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest, - callback: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - updateSshPublicKey( - request?: protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateSshPublicKey(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified posixAccount resource name string. - * - * @param {string} user - * @param {string} project - * @returns {string} Resource name string. - */ - posixAccountPath(user:string,project:string) { - return this.pathTemplates.posixAccountPathTemplate.render({ - user: user, - project: project, - }); - } - - /** - * Parse the user from PosixAccount resource. - * - * @param {string} posixAccountName - * A fully-qualified path representing PosixAccount resource. - * @returns {string} A string representing the user. - */ - matchUserFromPosixAccountName(posixAccountName: string) { - return this.pathTemplates.posixAccountPathTemplate.match(posixAccountName).user; - } - - /** - * Parse the project from PosixAccount resource. - * - * @param {string} posixAccountName - * A fully-qualified path representing PosixAccount resource. - * @returns {string} A string representing the project. - */ - matchProjectFromPosixAccountName(posixAccountName: string) { - return this.pathTemplates.posixAccountPathTemplate.match(posixAccountName).project; - } - - /** - * Return a fully-qualified sshPublicKey resource name string. - * - * @param {string} user - * @param {string} fingerprint - * @returns {string} Resource name string. - */ - sshPublicKeyPath(user:string,fingerprint:string) { - return this.pathTemplates.sshPublicKeyPathTemplate.render({ - user: user, - fingerprint: fingerprint, - }); - } - - /** - * Parse the user from SshPublicKey resource. - * - * @param {string} sshPublicKeyName - * A fully-qualified path representing SshPublicKey resource. - * @returns {string} A string representing the user. - */ - matchUserFromSshPublicKeyName(sshPublicKeyName: string) { - return this.pathTemplates.sshPublicKeyPathTemplate.match(sshPublicKeyName).user; - } - - /** - * Parse the fingerprint from SshPublicKey resource. - * - * @param {string} sshPublicKeyName - * A fully-qualified path representing SshPublicKey resource. - * @returns {string} A string representing the fingerprint. - */ - matchFingerprintFromSshPublicKeyName(sshPublicKeyName: string) { - return this.pathTemplates.sshPublicKeyPathTemplate.match(sshPublicKeyName).fingerprint; - } - - /** - * Return a fully-qualified user resource name string. - * - * @param {string} user - * @returns {string} Resource name string. - */ - userPath(user:string) { - return this.pathTemplates.userPathTemplate.render({ - user: user, - }); - } - - /** - * Parse the user from User resource. - * - * @param {string} userName - * A fully-qualified path representing User resource. - * @returns {string} A string representing the user. - */ - matchUserFromUserName(userName: string) { - return this.pathTemplates.userPathTemplate.match(userName).user; - } - - /** - * 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.osLoginServiceStub && !this._terminated) { - return this.osLoginServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_client_config.json b/owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_client_config.json deleted file mode 100644 index afdd4ec0a35..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_client_config.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "interfaces": { - "google.cloud.oslogin.v1.OsLoginService": { - "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": { - "CreateSshPublicKey": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeletePosixAccount": { - "timeout_millis": 10000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "DeleteSshPublicKey": { - "timeout_millis": 10000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetLoginProfile": { - "timeout_millis": 10000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetSshPublicKey": { - "timeout_millis": 10000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ImportSshPublicKey": { - "timeout_millis": 10000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateSshPublicKey": { - "timeout_millis": 10000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_proto_list.json b/owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_proto_list.json deleted file mode 100644 index 46f125ed586..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/src/v1/os_login_service_proto_list.json +++ /dev/null @@ -1,4 +0,0 @@ -[ - "../../protos/google/cloud/oslogin/common/common.proto", - "../../protos/google/cloud/oslogin/v1/oslogin.proto" -] diff --git a/owl-bot-staging/google-cloud-oslogin/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-oslogin/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index de1b9afaf4f..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const oslogin = require('@google-cloud/os-login'); - -function main() { - const osLoginServiceClient = new oslogin.OsLoginServiceClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-oslogin/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-oslogin/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index ab3709b1bb9..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {OsLoginServiceClient} from '@google-cloud/os-login'; - -// check that the client class type name can be used -function doStuffWithOsLoginServiceClient(client: OsLoginServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const osLoginServiceClient = new OsLoginServiceClient(); - doStuffWithOsLoginServiceClient(osLoginServiceClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-oslogin/v1/system-test/install.ts b/owl-bot-staging/google-cloud-oslogin/v1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/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-oslogin/v1/test/gapic_os_login_service_v1.ts b/owl-bot-staging/google-cloud-oslogin/v1/test/gapic_os_login_service_v1.ts deleted file mode 100644 index 4ddd4c6d480..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/test/gapic_os_login_service_v1.ts +++ /dev/null @@ -1,1015 +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 osloginserviceModule from '../src'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -describe('v1.OsLoginServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = osloginserviceModule.v1.OsLoginServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = osloginserviceModule.v1.OsLoginServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = osloginserviceModule.v1.OsLoginServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.osLoginServiceStub, undefined); - await client.initialize(); - assert(client.osLoginServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.osLoginServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.osLoginServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - 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 osloginserviceModule.v1.OsLoginServiceClient({ - 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('createSshPublicKey', () => { - it('invokes createSshPublicKey without error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.CreateSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.CreateSshPublicKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.common.SshPublicKey() - ); - client.innerApiCalls.createSshPublicKey = stubSimpleCall(expectedResponse); - const [response] = await client.createSshPublicKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSshPublicKey without error using callback', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.CreateSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.CreateSshPublicKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.common.SshPublicKey() - ); - client.innerApiCalls.createSshPublicKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createSshPublicKey( - request, - (err?: Error|null, result?: protos.google.cloud.oslogin.common.ISshPublicKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSshPublicKey with error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.CreateSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.CreateSshPublicKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSshPublicKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createSshPublicKey(request), expectedError); - const actualRequest = (client.innerApiCalls.createSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSshPublicKey with closed client', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.CreateSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.CreateSshPublicKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createSshPublicKey(request), expectedError); - }); - }); - - describe('deletePosixAccount', () => { - it('invokes deletePosixAccount without error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.DeletePosixAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.DeletePosixAccountRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePosixAccount = stubSimpleCall(expectedResponse); - const [response] = await client.deletePosixAccount(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deletePosixAccount as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePosixAccount as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePosixAccount without error using callback', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.DeletePosixAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.DeletePosixAccountRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePosixAccount = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deletePosixAccount( - 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.deletePosixAccount as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePosixAccount as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePosixAccount with error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.DeletePosixAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.DeletePosixAccountRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deletePosixAccount = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deletePosixAccount(request), expectedError); - const actualRequest = (client.innerApiCalls.deletePosixAccount as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePosixAccount as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePosixAccount with closed client', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.DeletePosixAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.DeletePosixAccountRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deletePosixAccount(request), expectedError); - }); - }); - - describe('deleteSshPublicKey', () => { - it('invokes deleteSshPublicKey without error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteSshPublicKey = stubSimpleCall(expectedResponse); - const [response] = await client.deleteSshPublicKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteSshPublicKey without error using callback', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteSshPublicKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteSshPublicKey( - 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.deleteSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteSshPublicKey with error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSshPublicKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteSshPublicKey(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteSshPublicKey with closed client', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteSshPublicKey(request), expectedError); - }); - }); - - describe('getLoginProfile', () => { - it('invokes getLoginProfile without error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.GetLoginProfileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.GetLoginProfileRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.v1.LoginProfile() - ); - client.innerApiCalls.getLoginProfile = stubSimpleCall(expectedResponse); - const [response] = await client.getLoginProfile(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getLoginProfile as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLoginProfile as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getLoginProfile without error using callback', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.GetLoginProfileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.GetLoginProfileRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.v1.LoginProfile() - ); - client.innerApiCalls.getLoginProfile = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLoginProfile( - request, - (err?: Error|null, result?: protos.google.cloud.oslogin.v1.ILoginProfile|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getLoginProfile as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLoginProfile as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getLoginProfile with error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.GetLoginProfileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.GetLoginProfileRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getLoginProfile = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLoginProfile(request), expectedError); - const actualRequest = (client.innerApiCalls.getLoginProfile as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLoginProfile as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getLoginProfile with closed client', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.GetLoginProfileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.GetLoginProfileRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getLoginProfile(request), expectedError); - }); - }); - - describe('getSshPublicKey', () => { - it('invokes getSshPublicKey without error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.GetSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.GetSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.common.SshPublicKey() - ); - client.innerApiCalls.getSshPublicKey = stubSimpleCall(expectedResponse); - const [response] = await client.getSshPublicKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSshPublicKey without error using callback', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.GetSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.GetSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.common.SshPublicKey() - ); - client.innerApiCalls.getSshPublicKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getSshPublicKey( - request, - (err?: Error|null, result?: protos.google.cloud.oslogin.common.ISshPublicKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSshPublicKey with error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.GetSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.GetSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getSshPublicKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getSshPublicKey(request), expectedError); - const actualRequest = (client.innerApiCalls.getSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSshPublicKey with closed client', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.GetSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.GetSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getSshPublicKey(request), expectedError); - }); - }); - - describe('importSshPublicKey', () => { - it('invokes importSshPublicKey without error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.ImportSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.ImportSshPublicKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.v1.ImportSshPublicKeyResponse() - ); - client.innerApiCalls.importSshPublicKey = stubSimpleCall(expectedResponse); - const [response] = await client.importSshPublicKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importSshPublicKey without error using callback', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.ImportSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.ImportSshPublicKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.v1.ImportSshPublicKeyResponse() - ); - client.innerApiCalls.importSshPublicKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importSshPublicKey( - request, - (err?: Error|null, result?: protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importSshPublicKey with error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.ImportSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.ImportSshPublicKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importSshPublicKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.importSshPublicKey(request), expectedError); - const actualRequest = (client.innerApiCalls.importSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importSshPublicKey with closed client', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.ImportSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.ImportSshPublicKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.importSshPublicKey(request), expectedError); - }); - }); - - describe('updateSshPublicKey', () => { - it('invokes updateSshPublicKey without error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.common.SshPublicKey() - ); - client.innerApiCalls.updateSshPublicKey = stubSimpleCall(expectedResponse); - const [response] = await client.updateSshPublicKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateSshPublicKey without error using callback', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.common.SshPublicKey() - ); - client.innerApiCalls.updateSshPublicKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateSshPublicKey( - request, - (err?: Error|null, result?: protos.google.cloud.oslogin.common.ISshPublicKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateSshPublicKey with error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSshPublicKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateSshPublicKey(request), expectedError); - const actualRequest = (client.innerApiCalls.updateSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateSshPublicKey with closed client', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateSshPublicKey(request), expectedError); - }); - }); - - describe('Path templates', () => { - - describe('posixAccount', () => { - const fakePath = "/rendered/path/posixAccount"; - const expectedParameters = { - user: "userValue", - project: "projectValue", - }; - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.posixAccountPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.posixAccountPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('posixAccountPath', () => { - const result = client.posixAccountPath("userValue", "projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.posixAccountPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchUserFromPosixAccountName', () => { - const result = client.matchUserFromPosixAccountName(fakePath); - assert.strictEqual(result, "userValue"); - assert((client.pathTemplates.posixAccountPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProjectFromPosixAccountName', () => { - const result = client.matchProjectFromPosixAccountName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.posixAccountPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('sshPublicKey', () => { - const fakePath = "/rendered/path/sshPublicKey"; - const expectedParameters = { - user: "userValue", - fingerprint: "fingerprintValue", - }; - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.sshPublicKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.sshPublicKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('sshPublicKeyPath', () => { - const result = client.sshPublicKeyPath("userValue", "fingerprintValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.sshPublicKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchUserFromSshPublicKeyName', () => { - const result = client.matchUserFromSshPublicKeyName(fakePath); - assert.strictEqual(result, "userValue"); - assert((client.pathTemplates.sshPublicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchFingerprintFromSshPublicKeyName', () => { - const result = client.matchFingerprintFromSshPublicKeyName(fakePath); - assert.strictEqual(result, "fingerprintValue"); - assert((client.pathTemplates.sshPublicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('user', () => { - const fakePath = "/rendered/path/user"; - const expectedParameters = { - user: "userValue", - }; - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.userPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.userPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('userPath', () => { - const result = client.userPath("userValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.userPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchUserFromUserName', () => { - const result = client.matchUserFromUserName(fakePath); - assert.strictEqual(result, "userValue"); - assert((client.pathTemplates.userPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-oslogin/v1/tsconfig.json b/owl-bot-staging/google-cloud-oslogin/v1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-oslogin/v1/webpack.config.js b/owl-bot-staging/google-cloud-oslogin/v1/webpack.config.js deleted file mode 100644 index 67fc391472d..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'OsLoginService', - filename: './os-login-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-oslogin/v1beta/.eslintignore b/owl-bot-staging/google-cloud-oslogin/v1beta/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/.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-oslogin/v1beta/.eslintrc.json b/owl-bot-staging/google-cloud-oslogin/v1beta/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/.gitignore b/owl-bot-staging/google-cloud-oslogin/v1beta/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/.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-oslogin/v1beta/.jsdoc.js b/owl-bot-staging/google-cloud-oslogin/v1beta/.jsdoc.js deleted file mode 100644 index f945dc1e9e4..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/.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/os-login', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/.mocharc.js b/owl-bot-staging/google-cloud-oslogin/v1beta/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/.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-oslogin/v1beta/.prettierrc.js b/owl-bot-staging/google-cloud-oslogin/v1beta/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/.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-oslogin/v1beta/README.md b/owl-bot-staging/google-cloud-oslogin/v1beta/README.md deleted file mode 100644 index f7acdc89a3a..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/README.md +++ /dev/null @@ -1 +0,0 @@ -Oslogin: Nodejs Client diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/package.json b/owl-bot-staging/google-cloud-oslogin/v1beta/package.json deleted file mode 100644 index 7dc97d13da3..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/os-login", - "version": "0.1.0", - "description": "Oslogin client for Node.js", - "repository": "googleapis/nodejs-oslogin", - "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 oslogin", - "oslogin", - "os login service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/protos/google/cloud/oslogin/common/common.proto b/owl-bot-staging/google-cloud-oslogin/v1beta/protos/google/cloud/oslogin/common/common.proto deleted file mode 100644 index c0a15cc71fd..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/protos/google/cloud/oslogin/common/common.proto +++ /dev/null @@ -1,108 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.oslogin.common; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; - -option csharp_namespace = "Google.Cloud.OsLogin.Common"; -option go_package = "cloud.google.com/go/oslogin/common/commonpb;commonpb"; -option java_outer_classname = "OsLoginProto"; -option java_package = "com.google.cloud.oslogin.common"; -option php_namespace = "Google\\Cloud\\OsLogin\\Common"; -option ruby_package = "Google::Cloud::OsLogin::Common"; -option (google.api.resource_definition) = { - type: "oslogin.googleapis.com/User" - pattern: "users/{user}" -}; - -// The operating system options for account entries. -enum OperatingSystemType { - // The operating system type associated with the user account information is - // unspecified. - OPERATING_SYSTEM_TYPE_UNSPECIFIED = 0; - - // Linux user account information. - LINUX = 1; - - // Windows user account information. - WINDOWS = 2; -} - -// The POSIX account information associated with a Google account. -message PosixAccount { - option (google.api.resource) = { - type: "oslogin.googleapis.com/PosixAccount" - pattern: "users/{user}/projects/{project}" - }; - - // Only one POSIX account can be marked as primary. - bool primary = 1; - - // The username of the POSIX account. - string username = 2; - - // The user ID. - int64 uid = 3; - - // The default group ID. - int64 gid = 4; - - // The path to the home directory for this account. - string home_directory = 5; - - // The path to the logic shell for this account. - string shell = 6; - - // The GECOS (user information) entry for this account. - string gecos = 7; - - // System identifier for which account the username or uid applies to. - // By default, the empty value is used. - string system_id = 8; - - // Output only. A POSIX account identifier. - string account_id = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The operating system type where this account applies. - OperatingSystemType operating_system_type = 10; - - // Output only. The canonical resource name. - string name = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// The SSH public key information associated with a Google account. -message SshPublicKey { - option (google.api.resource) = { - type: "oslogin.googleapis.com/SshPublicKey" - pattern: "users/{user}/sshPublicKeys/{fingerprint}" - }; - - // Public key text in SSH format, defined by - // RFC4253 - // section 6.6. - string key = 1; - - // An expiration time in microseconds since epoch. - int64 expiration_time_usec = 2; - - // Output only. The SHA-256 fingerprint of the SSH public key. - string fingerprint = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The canonical resource name. - string name = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/protos/google/cloud/oslogin/v1beta/oslogin.proto b/owl-bot-staging/google-cloud-oslogin/v1beta/protos/google/cloud/oslogin/v1beta/oslogin.proto deleted file mode 100644 index 5209b44316c..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/protos/google/cloud/oslogin/v1beta/oslogin.proto +++ /dev/null @@ -1,321 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.oslogin.v1beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/oslogin/common/common.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option csharp_namespace = "Google.Cloud.OsLogin.V1Beta"; -option go_package = "cloud.google.com/go/oslogin/apiv1beta/osloginpb;osloginpb"; -option java_multiple_files = true; -option java_outer_classname = "OsLoginProto"; -option java_package = "com.google.cloud.oslogin.v1beta"; -option php_namespace = "Google\\Cloud\\OsLogin\\V1beta"; -option ruby_package = "Google::Cloud::OsLogin::V1beta"; - -// Cloud OS Login API -// -// The Cloud OS Login API allows you to manage users and their associated SSH -// public keys for logging into virtual machines on Google Cloud Platform. -service OsLoginService { - option (google.api.default_host) = "oslogin.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-platform.read-only," - "https://www.googleapis.com/auth/compute," - "https://www.googleapis.com/auth/compute.readonly"; - - // Create an SSH public key - rpc CreateSshPublicKey(CreateSshPublicKeyRequest) - returns (google.cloud.oslogin.common.SshPublicKey) { - option (google.api.http) = { - post: "/v1beta/{parent=users/*}/sshPublicKeys" - body: "ssh_public_key" - }; - option (google.api.method_signature) = "parent,ssh_public_key"; - } - - // Deletes a POSIX account. - rpc DeletePosixAccount(DeletePosixAccountRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1beta/{name=users/*/projects/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Deletes an SSH public key. - rpc DeleteSshPublicKey(DeleteSshPublicKeyRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1beta/{name=users/*/sshPublicKeys/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Retrieves the profile information used for logging in to a virtual machine - // on Google Compute Engine. - rpc GetLoginProfile(GetLoginProfileRequest) returns (LoginProfile) { - option (google.api.http) = { - get: "/v1beta/{name=users/*}/loginProfile" - }; - option (google.api.method_signature) = "name"; - } - - // Retrieves an SSH public key. - rpc GetSshPublicKey(GetSshPublicKeyRequest) - returns (google.cloud.oslogin.common.SshPublicKey) { - option (google.api.http) = { - get: "/v1beta/{name=users/*/sshPublicKeys/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Adds an SSH public key and returns the profile information. Default POSIX - // account information is set when no username and UID exist as part of the - // login profile. - rpc ImportSshPublicKey(ImportSshPublicKeyRequest) - returns (ImportSshPublicKeyResponse) { - option (google.api.http) = { - post: "/v1beta/{parent=users/*}:importSshPublicKey" - body: "ssh_public_key" - }; - option (google.api.method_signature) = "parent,ssh_public_key"; - option (google.api.method_signature) = "parent,ssh_public_key,project_id"; - } - - // Updates an SSH public key and returns the profile information. This method - // supports patch semantics. - rpc UpdateSshPublicKey(UpdateSshPublicKeyRequest) - returns (google.cloud.oslogin.common.SshPublicKey) { - option (google.api.http) = { - patch: "/v1beta/{name=users/*/sshPublicKeys/*}" - body: "ssh_public_key" - }; - option (google.api.method_signature) = "name,ssh_public_key"; - option (google.api.method_signature) = "name,ssh_public_key,update_mask"; - } - - // Signs an SSH public key for a user to authenticate to an instance. - rpc SignSshPublicKey(SignSshPublicKeyRequest) - returns (SignSshPublicKeyResponse) { - option (google.api.http) = { - post: "/v1beta/{parent=users/*/projects/*/zones/*}:signSshPublicKey" - body: "*" - }; - option (google.api.method_signature) = "parent,ssh_public_key"; - } -} - -// The user profile information used for logging in to a virtual machine on -// Google Compute Engine. -message LoginProfile { - // Required. A unique user ID. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // The list of POSIX accounts associated with the user. - repeated google.cloud.oslogin.common.PosixAccount posix_accounts = 2; - - // A map from SSH public key fingerprint to the associated key object. - map ssh_public_keys = 3; - - // The registered security key credentials for a user. - repeated SecurityKey security_keys = 5; -} - -// A request message for creating an SSH public key. -message CreateSshPublicKeyRequest { - // Required. The unique ID for the user in format `users/{user}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "oslogin.googleapis.com/SshPublicKey" - } - ]; - - // Required. The SSH public key and expiration time. - google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 - [(google.api.field_behavior) = REQUIRED]; -} - -// A request message for deleting a POSIX account entry. -message DeletePosixAccountRequest { - // Required. A reference to the POSIX account to update. POSIX accounts are - // identified by the project ID they are associated with. A reference to the - // POSIX account is in format `users/{user}/projects/{project}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "oslogin.googleapis.com/PosixAccount" - } - ]; -} - -// A request message for deleting an SSH public key. -message DeleteSshPublicKeyRequest { - // Required. The fingerprint of the public key to update. Public keys are - // identified by their SHA-256 fingerprint. The fingerprint of the public key - // is in format `users/{user}/sshPublicKeys/{fingerprint}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "oslogin.googleapis.com/SshPublicKey" - } - ]; -} - -// A request message for retrieving the login profile information for a user. -message GetLoginProfileRequest { - // Required. The unique ID for the user in format `users/{user}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "oslogin.googleapis.com/User" } - ]; - - // The project ID of the Google Cloud Platform project. - string project_id = 2; - - // A system ID for filtering the results of the request. - string system_id = 3; - - // The view configures whether to retrieve security keys information. - LoginProfileView view = 4; -} - -// A request message for retrieving an SSH public key. -message GetSshPublicKeyRequest { - // Required. The fingerprint of the public key to retrieve. Public keys are - // identified by their SHA-256 fingerprint. The fingerprint of the public key - // is in format `users/{user}/sshPublicKeys/{fingerprint}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "oslogin.googleapis.com/SshPublicKey" - } - ]; -} - -// A request message for importing an SSH public key. -message ImportSshPublicKeyRequest { - // The unique ID for the user in format `users/{user}`. - string parent = 1 [(google.api.resource_reference) = { - child_type: "oslogin.googleapis.com/SshPublicKey" - }]; - - // Required. The SSH public key and expiration time. - google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 - [(google.api.field_behavior) = REQUIRED]; - - // The project ID of the Google Cloud Platform project. - string project_id = 3; - - // The view configures whether to retrieve security keys information. - LoginProfileView view = 4; -} - -// A response message for importing an SSH public key. -message ImportSshPublicKeyResponse { - // The login profile information for the user. - LoginProfile login_profile = 1; - - // Detailed information about import results. - string details = 2; -} - -// A request message for updating an SSH public key. -message UpdateSshPublicKeyRequest { - // Required. The fingerprint of the public key to update. Public keys are - // identified by their SHA-256 fingerprint. The fingerprint of the public key - // is in format `users/{user}/sshPublicKeys/{fingerprint}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "oslogin.googleapis.com/SshPublicKey" - } - ]; - - // Required. The SSH public key and expiration time. - google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Mask to control which fields get updated. Updates all if not present. - google.protobuf.FieldMask update_mask = 3; -} - -// The credential information for a Google registered security key. -message SecurityKey { - // Public key text in SSH format, defined by - // [RFC4253]("https://www.ietf.org/rfc/rfc4253.txt") section 6.6. - string public_key = 1; - - // Hardware-backed private key text in SSH format. - string private_key = 2; - - // The FIDO protocol type used to register this credential. - oneof protocol_type { - // The U2F protocol type. - UniversalTwoFactor universal_two_factor = 3; - - // The Web Authentication protocol type. - WebAuthn web_authn = 4; - } -} - -// Security key information specific to the U2F protocol. -message UniversalTwoFactor { - // Application ID for the U2F protocol. - string app_id = 1; -} - -// Security key information specific to the Web Authentication protocol. -message WebAuthn { - // Relying party ID for Web Authentication. - string rp_id = 1; -} - -message SignSshPublicKeyRequest { - // The SSH public key to sign. - string ssh_public_key = 1; - - // The parent project and zone for the signing request. This is needed to - // properly ensure per-organization ISS processing and potentially to provide - // for the possibility of zone-specific certificates used in the signing - // process. - string parent = 2; -} - -message SignSshPublicKeyResponse { - // The signed SSH public key to use in the SSH handshake. - string signed_ssh_public_key = 1; -} - -// The login profile view limits the user content retrieved. -enum LoginProfileView { - // The default login profile view. The API defaults to the BASIC view. - LOGIN_PROFILE_VIEW_UNSPECIFIED = 0; - - // Includes POSIX and SSH key information. - BASIC = 1; - - // Include security key information for the user. - SECURITY_KEY = 2; -} diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.create_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.create_ssh_public_key.js deleted file mode 100644 index 4541a3cc13c..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.create_ssh_public_key.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(parent, sshPublicKey) { - // [START oslogin_v1beta_generated_OsLoginService_CreateSshPublicKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The unique ID for the user in format `users/{user}`. - */ - // const parent = 'abc123' - /** - * Required. The SSH public key and expiration time. - */ - // const sshPublicKey = {} - - // Imports the Oslogin library - const {OsLoginServiceClient} = require('@google-cloud/os-login').v1beta; - - // Instantiates a client - const osloginClient = new OsLoginServiceClient(); - - async function callCreateSshPublicKey() { - // Construct request - const request = { - parent, - sshPublicKey, - }; - - // Run request - const response = await osloginClient.createSshPublicKey(request); - console.log(response); - } - - callCreateSshPublicKey(); - // [END oslogin_v1beta_generated_OsLoginService_CreateSshPublicKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.delete_posix_account.js b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.delete_posix_account.js deleted file mode 100644 index 66fe4e57ce9..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.delete_posix_account.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 oslogin_v1beta_generated_OsLoginService_DeletePosixAccount_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A reference to the POSIX account to update. POSIX accounts are - * identified by the project ID they are associated with. A reference to the - * POSIX account is in format `users/{user}/projects/{project}`. - */ - // const name = 'abc123' - - // Imports the Oslogin library - const {OsLoginServiceClient} = require('@google-cloud/os-login').v1beta; - - // Instantiates a client - const osloginClient = new OsLoginServiceClient(); - - async function callDeletePosixAccount() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osloginClient.deletePosixAccount(request); - console.log(response); - } - - callDeletePosixAccount(); - // [END oslogin_v1beta_generated_OsLoginService_DeletePosixAccount_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.delete_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.delete_ssh_public_key.js deleted file mode 100644 index edf261fc8bf..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.delete_ssh_public_key.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 oslogin_v1beta_generated_OsLoginService_DeleteSshPublicKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The fingerprint of the public key to update. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - */ - // const name = 'abc123' - - // Imports the Oslogin library - const {OsLoginServiceClient} = require('@google-cloud/os-login').v1beta; - - // Instantiates a client - const osloginClient = new OsLoginServiceClient(); - - async function callDeleteSshPublicKey() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osloginClient.deleteSshPublicKey(request); - console.log(response); - } - - callDeleteSshPublicKey(); - // [END oslogin_v1beta_generated_OsLoginService_DeleteSshPublicKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.get_login_profile.js b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.get_login_profile.js deleted file mode 100644 index cb23ebc80dc..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.get_login_profile.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(name) { - // [START oslogin_v1beta_generated_OsLoginService_GetLoginProfile_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The unique ID for the user in format `users/{user}`. - */ - // const name = 'abc123' - /** - * The project ID of the Google Cloud Platform project. - */ - // const projectId = 'abc123' - /** - * A system ID for filtering the results of the request. - */ - // const systemId = 'abc123' - /** - * The view configures whether to retrieve security keys information. - */ - // const view = {} - - // Imports the Oslogin library - const {OsLoginServiceClient} = require('@google-cloud/os-login').v1beta; - - // Instantiates a client - const osloginClient = new OsLoginServiceClient(); - - async function callGetLoginProfile() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osloginClient.getLoginProfile(request); - console.log(response); - } - - callGetLoginProfile(); - // [END oslogin_v1beta_generated_OsLoginService_GetLoginProfile_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.get_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.get_ssh_public_key.js deleted file mode 100644 index 158e5dc7bda..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.get_ssh_public_key.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 oslogin_v1beta_generated_OsLoginService_GetSshPublicKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The fingerprint of the public key to retrieve. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - */ - // const name = 'abc123' - - // Imports the Oslogin library - const {OsLoginServiceClient} = require('@google-cloud/os-login').v1beta; - - // Instantiates a client - const osloginClient = new OsLoginServiceClient(); - - async function callGetSshPublicKey() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await osloginClient.getSshPublicKey(request); - console.log(response); - } - - callGetSshPublicKey(); - // [END oslogin_v1beta_generated_OsLoginService_GetSshPublicKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.import_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.import_ssh_public_key.js deleted file mode 100644 index e4f5bdcf0a2..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.import_ssh_public_key.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(sshPublicKey) { - // [START oslogin_v1beta_generated_OsLoginService_ImportSshPublicKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 unique ID for the user in format `users/{user}`. - */ - // const parent = 'abc123' - /** - * Required. The SSH public key and expiration time. - */ - // const sshPublicKey = {} - /** - * The project ID of the Google Cloud Platform project. - */ - // const projectId = 'abc123' - /** - * The view configures whether to retrieve security keys information. - */ - // const view = {} - - // Imports the Oslogin library - const {OsLoginServiceClient} = require('@google-cloud/os-login').v1beta; - - // Instantiates a client - const osloginClient = new OsLoginServiceClient(); - - async function callImportSshPublicKey() { - // Construct request - const request = { - sshPublicKey, - }; - - // Run request - const response = await osloginClient.importSshPublicKey(request); - console.log(response); - } - - callImportSshPublicKey(); - // [END oslogin_v1beta_generated_OsLoginService_ImportSshPublicKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.sign_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.sign_ssh_public_key.js deleted file mode 100644 index 9d9f2b2dfb5..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.sign_ssh_public_key.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() { - // [START oslogin_v1beta_generated_OsLoginService_SignSshPublicKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 SSH public key to sign. - */ - // const sshPublicKey = 'abc123' - /** - * The parent project and zone for the signing request. This is needed to - * properly ensure per-organization ISS processing and potentially to provide - * for the possibility of zone-specific certificates used in the signing - * process. - */ - // const parent = 'abc123' - - // Imports the Oslogin library - const {OsLoginServiceClient} = require('@google-cloud/os-login').v1beta; - - // Instantiates a client - const osloginClient = new OsLoginServiceClient(); - - async function callSignSshPublicKey() { - // Construct request - const request = { - }; - - // Run request - const response = await osloginClient.signSshPublicKey(request); - console.log(response); - } - - callSignSshPublicKey(); - // [END oslogin_v1beta_generated_OsLoginService_SignSshPublicKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.update_ssh_public_key.js b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.update_ssh_public_key.js deleted file mode 100644 index f4c10f3fba9..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/os_login_service.update_ssh_public_key.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(name, sshPublicKey) { - // [START oslogin_v1beta_generated_OsLoginService_UpdateSshPublicKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The fingerprint of the public key to update. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - */ - // const name = 'abc123' - /** - * Required. The SSH public key and expiration time. - */ - // const sshPublicKey = {} - /** - * Mask to control which fields get updated. Updates all if not present. - */ - // const updateMask = {} - - // Imports the Oslogin library - const {OsLoginServiceClient} = require('@google-cloud/os-login').v1beta; - - // Instantiates a client - const osloginClient = new OsLoginServiceClient(); - - async function callUpdateSshPublicKey() { - // Construct request - const request = { - name, - sshPublicKey, - }; - - // Run request - const response = await osloginClient.updateSshPublicKey(request); - console.log(response); - } - - callUpdateSshPublicKey(); - // [END oslogin_v1beta_generated_OsLoginService_UpdateSshPublicKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/snippet_metadata_google.cloud.oslogin.v1beta.json b/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/snippet_metadata_google.cloud.oslogin.v1beta.json deleted file mode 100644 index b1fa3694f12..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/samples/generated/v1beta/snippet_metadata_google.cloud.oslogin.v1beta.json +++ /dev/null @@ -1,375 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-oslogin", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.oslogin.v1beta", - "version": "v1beta" - } - ] - }, - "snippets": [ - { - "regionTag": "oslogin_v1beta_generated_OsLoginService_CreateSshPublicKey_async", - "title": "OsLoginService createSshPublicKey Sample", - "origin": "API_DEFINITION", - "description": " Create an SSH public key", - "canonical": true, - "file": "os_login_service.create_ssh_public_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateSshPublicKey", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService.CreateSshPublicKey", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "ssh_public_key", - "type": ".google.cloud.oslogin.common.SshPublicKey" - } - ], - "resultType": ".google.cloud.oslogin.common.SshPublicKey", - "client": { - "shortName": "OsLoginServiceClient", - "fullName": "google.cloud.oslogin.v1beta.OsLoginServiceClient" - }, - "method": { - "shortName": "CreateSshPublicKey", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService.CreateSshPublicKey", - "service": { - "shortName": "OsLoginService", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService" - } - } - } - }, - { - "regionTag": "oslogin_v1beta_generated_OsLoginService_DeletePosixAccount_async", - "title": "OsLoginService deletePosixAccount Sample", - "origin": "API_DEFINITION", - "description": " Deletes a POSIX account.", - "canonical": true, - "file": "os_login_service.delete_posix_account.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeletePosixAccount", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService.DeletePosixAccount", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "OsLoginServiceClient", - "fullName": "google.cloud.oslogin.v1beta.OsLoginServiceClient" - }, - "method": { - "shortName": "DeletePosixAccount", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService.DeletePosixAccount", - "service": { - "shortName": "OsLoginService", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService" - } - } - } - }, - { - "regionTag": "oslogin_v1beta_generated_OsLoginService_DeleteSshPublicKey_async", - "title": "OsLoginService deleteSshPublicKey Sample", - "origin": "API_DEFINITION", - "description": " Deletes an SSH public key.", - "canonical": true, - "file": "os_login_service.delete_ssh_public_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteSshPublicKey", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService.DeleteSshPublicKey", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "OsLoginServiceClient", - "fullName": "google.cloud.oslogin.v1beta.OsLoginServiceClient" - }, - "method": { - "shortName": "DeleteSshPublicKey", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService.DeleteSshPublicKey", - "service": { - "shortName": "OsLoginService", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService" - } - } - } - }, - { - "regionTag": "oslogin_v1beta_generated_OsLoginService_GetLoginProfile_async", - "title": "OsLoginService getLoginProfile Sample", - "origin": "API_DEFINITION", - "description": " Retrieves the profile information used for logging in to a virtual machine on Google Compute Engine.", - "canonical": true, - "file": "os_login_service.get_login_profile.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetLoginProfile", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService.GetLoginProfile", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "project_id", - "type": "TYPE_STRING" - }, - { - "name": "system_id", - "type": "TYPE_STRING" - }, - { - "name": "view", - "type": ".google.cloud.oslogin.v1beta.LoginProfileView" - } - ], - "resultType": ".google.cloud.oslogin.v1beta.LoginProfile", - "client": { - "shortName": "OsLoginServiceClient", - "fullName": "google.cloud.oslogin.v1beta.OsLoginServiceClient" - }, - "method": { - "shortName": "GetLoginProfile", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService.GetLoginProfile", - "service": { - "shortName": "OsLoginService", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService" - } - } - } - }, - { - "regionTag": "oslogin_v1beta_generated_OsLoginService_GetSshPublicKey_async", - "title": "OsLoginService getSshPublicKey Sample", - "origin": "API_DEFINITION", - "description": " Retrieves an SSH public key.", - "canonical": true, - "file": "os_login_service.get_ssh_public_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetSshPublicKey", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService.GetSshPublicKey", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.oslogin.common.SshPublicKey", - "client": { - "shortName": "OsLoginServiceClient", - "fullName": "google.cloud.oslogin.v1beta.OsLoginServiceClient" - }, - "method": { - "shortName": "GetSshPublicKey", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService.GetSshPublicKey", - "service": { - "shortName": "OsLoginService", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService" - } - } - } - }, - { - "regionTag": "oslogin_v1beta_generated_OsLoginService_ImportSshPublicKey_async", - "title": "OsLoginService importSshPublicKey Sample", - "origin": "API_DEFINITION", - "description": " Adds an SSH public key and returns the profile information. Default POSIX account information is set when no username and UID exist as part of the login profile.", - "canonical": true, - "file": "os_login_service.import_ssh_public_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportSshPublicKey", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService.ImportSshPublicKey", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "ssh_public_key", - "type": ".google.cloud.oslogin.common.SshPublicKey" - }, - { - "name": "project_id", - "type": "TYPE_STRING" - }, - { - "name": "view", - "type": ".google.cloud.oslogin.v1beta.LoginProfileView" - } - ], - "resultType": ".google.cloud.oslogin.v1beta.ImportSshPublicKeyResponse", - "client": { - "shortName": "OsLoginServiceClient", - "fullName": "google.cloud.oslogin.v1beta.OsLoginServiceClient" - }, - "method": { - "shortName": "ImportSshPublicKey", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService.ImportSshPublicKey", - "service": { - "shortName": "OsLoginService", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService" - } - } - } - }, - { - "regionTag": "oslogin_v1beta_generated_OsLoginService_UpdateSshPublicKey_async", - "title": "OsLoginService updateSshPublicKey Sample", - "origin": "API_DEFINITION", - "description": " Updates an SSH public key and returns the profile information. This method supports patch semantics.", - "canonical": true, - "file": "os_login_service.update_ssh_public_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateSshPublicKey", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService.UpdateSshPublicKey", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "ssh_public_key", - "type": ".google.cloud.oslogin.common.SshPublicKey" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.oslogin.common.SshPublicKey", - "client": { - "shortName": "OsLoginServiceClient", - "fullName": "google.cloud.oslogin.v1beta.OsLoginServiceClient" - }, - "method": { - "shortName": "UpdateSshPublicKey", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService.UpdateSshPublicKey", - "service": { - "shortName": "OsLoginService", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService" - } - } - } - }, - { - "regionTag": "oslogin_v1beta_generated_OsLoginService_SignSshPublicKey_async", - "title": "OsLoginService signSshPublicKey Sample", - "origin": "API_DEFINITION", - "description": " Signs an SSH public key for a user to authenticate to an instance.", - "canonical": true, - "file": "os_login_service.sign_ssh_public_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SignSshPublicKey", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService.SignSshPublicKey", - "async": true, - "parameters": [ - { - "name": "ssh_public_key", - "type": "TYPE_STRING" - }, - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.oslogin.v1beta.SignSshPublicKeyResponse", - "client": { - "shortName": "OsLoginServiceClient", - "fullName": "google.cloud.oslogin.v1beta.OsLoginServiceClient" - }, - "method": { - "shortName": "SignSshPublicKey", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService.SignSshPublicKey", - "service": { - "shortName": "OsLoginService", - "fullName": "google.cloud.oslogin.v1beta.OsLoginService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/src/index.ts b/owl-bot-staging/google-cloud-oslogin/v1beta/src/index.ts deleted file mode 100644 index 5237f188fbf..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/src/index.ts +++ /dev/null @@ -1,25 +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 v1beta from './v1beta'; -const OsLoginServiceClient = v1beta.OsLoginServiceClient; -type OsLoginServiceClient = v1beta.OsLoginServiceClient; -export {v1beta, OsLoginServiceClient}; -export default {v1beta, OsLoginServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/gapic_metadata.json b/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/gapic_metadata.json deleted file mode 100644 index 850a4c8b40a..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/gapic_metadata.json +++ /dev/null @@ -1,103 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.oslogin.v1beta", - "libraryPackage": "@google-cloud/os-login", - "services": { - "OsLoginService": { - "clients": { - "grpc": { - "libraryClient": "OsLoginServiceClient", - "rpcs": { - "CreateSshPublicKey": { - "methods": [ - "createSshPublicKey" - ] - }, - "DeletePosixAccount": { - "methods": [ - "deletePosixAccount" - ] - }, - "DeleteSshPublicKey": { - "methods": [ - "deleteSshPublicKey" - ] - }, - "GetLoginProfile": { - "methods": [ - "getLoginProfile" - ] - }, - "GetSshPublicKey": { - "methods": [ - "getSshPublicKey" - ] - }, - "ImportSshPublicKey": { - "methods": [ - "importSshPublicKey" - ] - }, - "UpdateSshPublicKey": { - "methods": [ - "updateSshPublicKey" - ] - }, - "SignSshPublicKey": { - "methods": [ - "signSshPublicKey" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "OsLoginServiceClient", - "rpcs": { - "CreateSshPublicKey": { - "methods": [ - "createSshPublicKey" - ] - }, - "DeletePosixAccount": { - "methods": [ - "deletePosixAccount" - ] - }, - "DeleteSshPublicKey": { - "methods": [ - "deleteSshPublicKey" - ] - }, - "GetLoginProfile": { - "methods": [ - "getLoginProfile" - ] - }, - "GetSshPublicKey": { - "methods": [ - "getSshPublicKey" - ] - }, - "ImportSshPublicKey": { - "methods": [ - "importSshPublicKey" - ] - }, - "UpdateSshPublicKey": { - "methods": [ - "updateSshPublicKey" - ] - }, - "SignSshPublicKey": { - "methods": [ - "signSshPublicKey" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/index.ts b/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/index.ts deleted file mode 100644 index 477969ae393..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/index.ts +++ /dev/null @@ -1,19 +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 {OsLoginServiceClient} from './os_login_service_client'; diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_client.ts b/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_client.ts deleted file mode 100644 index ec29e0b9ccf..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_client.ts +++ /dev/null @@ -1,1021 +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} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta/os_login_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './os_login_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Cloud OS Login API - * - * The Cloud OS Login API allows you to manage users and their associated SSH - * public keys for logging into virtual machines on Google Cloud Platform. - * @class - * @memberof v1beta - */ -export class OsLoginServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - osLoginServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of OsLoginServiceClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 OsLoginServiceClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof OsLoginServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - posixAccountPathTemplate: new this._gaxModule.PathTemplate( - 'users/{user}/projects/{project}' - ), - sshPublicKeyPathTemplate: new this._gaxModule.PathTemplate( - 'users/{user}/sshPublicKeys/{fingerprint}' - ), - userPathTemplate: new this._gaxModule.PathTemplate( - 'users/{user}' - ), - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.oslogin.v1beta.OsLoginService', 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.osLoginServiceStub) { - return this.osLoginServiceStub; - } - - // Put together the "service stub" for - // google.cloud.oslogin.v1beta.OsLoginService. - this.osLoginServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.oslogin.v1beta.OsLoginService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.oslogin.v1beta.OsLoginService, - 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 osLoginServiceStubMethods = - ['createSshPublicKey', 'deletePosixAccount', 'deleteSshPublicKey', 'getLoginProfile', 'getSshPublicKey', 'importSshPublicKey', 'updateSshPublicKey', 'signSshPublicKey']; - for (const methodName of osLoginServiceStubMethods) { - const callPromise = this.osLoginServiceStub.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.osLoginServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'oslogin.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 'oslogin.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - 'https://www.googleapis.com/auth/compute', - 'https://www.googleapis.com/auth/compute.readonly' - ]; - } - - 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 -- - // ------------------- -/** - * Create an SSH public key - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The unique ID for the user in format `users/{user}`. - * @param {google.cloud.oslogin.common.SshPublicKey} request.sshPublicKey - * Required. The SSH public key and expiration time. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.oslogin.common.SshPublicKey|SshPublicKey}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_login_service.create_ssh_public_key.js - * region_tag:oslogin_v1beta_generated_OsLoginService_CreateSshPublicKey_async - */ - createSshPublicKey( - request?: protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest|undefined, {}|undefined - ]>; - createSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - createSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest, - callback: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - createSshPublicKey( - request?: protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createSshPublicKey(request, options, callback); - } -/** - * Deletes a POSIX account. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A reference to the POSIX account to update. POSIX accounts are - * identified by the project ID they are associated with. A reference to the - * POSIX account is in format `users/{user}/projects/{project}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_login_service.delete_posix_account.js - * region_tag:oslogin_v1beta_generated_OsLoginService_DeletePosixAccount_async - */ - deletePosixAccount( - request?: protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest|undefined, {}|undefined - ]>; - deletePosixAccount( - request: protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest|null|undefined, - {}|null|undefined>): void; - deletePosixAccount( - request: protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest|null|undefined, - {}|null|undefined>): void; - deletePosixAccount( - request?: protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deletePosixAccount(request, options, callback); - } -/** - * Deletes an SSH public key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The fingerprint of the public key to update. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_login_service.delete_ssh_public_key.js - * region_tag:oslogin_v1beta_generated_OsLoginService_DeleteSshPublicKey_async - */ - deleteSshPublicKey( - request?: protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest|undefined, {}|undefined - ]>; - deleteSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - deleteSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - deleteSshPublicKey( - request?: protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteSshPublicKey(request, options, callback); - } -/** - * Retrieves the profile information used for logging in to a virtual machine - * on Google Compute Engine. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The unique ID for the user in format `users/{user}`. - * @param {string} request.projectId - * The project ID of the Google Cloud Platform project. - * @param {string} request.systemId - * A system ID for filtering the results of the request. - * @param {google.cloud.oslogin.v1beta.LoginProfileView} request.view - * The view configures whether to retrieve security keys information. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.oslogin.v1beta.LoginProfile|LoginProfile}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_login_service.get_login_profile.js - * region_tag:oslogin_v1beta_generated_OsLoginService_GetLoginProfile_async - */ - getLoginProfile( - request?: protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oslogin.v1beta.ILoginProfile, - protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest|undefined, {}|undefined - ]>; - getLoginProfile( - request: protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oslogin.v1beta.ILoginProfile, - protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest|null|undefined, - {}|null|undefined>): void; - getLoginProfile( - request: protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest, - callback: Callback< - protos.google.cloud.oslogin.v1beta.ILoginProfile, - protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest|null|undefined, - {}|null|undefined>): void; - getLoginProfile( - request?: protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oslogin.v1beta.ILoginProfile, - protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.oslogin.v1beta.ILoginProfile, - protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oslogin.v1beta.ILoginProfile, - protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getLoginProfile(request, options, callback); - } -/** - * Retrieves an SSH public key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The fingerprint of the public key to retrieve. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.oslogin.common.SshPublicKey|SshPublicKey}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_login_service.get_ssh_public_key.js - * region_tag:oslogin_v1beta_generated_OsLoginService_GetSshPublicKey_async - */ - getSshPublicKey( - request?: protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest|undefined, {}|undefined - ]>; - getSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - getSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest, - callback: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - getSshPublicKey( - request?: protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getSshPublicKey(request, options, callback); - } -/** - * Adds an SSH public key and returns the profile information. Default POSIX - * account information is set when no username and UID exist as part of the - * login profile. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The unique ID for the user in format `users/{user}`. - * @param {google.cloud.oslogin.common.SshPublicKey} request.sshPublicKey - * Required. The SSH public key and expiration time. - * @param {string} request.projectId - * The project ID of the Google Cloud Platform project. - * @param {google.cloud.oslogin.v1beta.LoginProfileView} request.view - * The view configures whether to retrieve security keys information. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyResponse|ImportSshPublicKeyResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_login_service.import_ssh_public_key.js - * region_tag:oslogin_v1beta_generated_OsLoginService_ImportSshPublicKey_async - */ - importSshPublicKey( - request?: protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, - protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest|undefined, {}|undefined - ]>; - importSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, - protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - importSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest, - callback: Callback< - protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, - protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - importSshPublicKey( - request?: protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, - protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, - protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, - protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.importSshPublicKey(request, options, callback); - } -/** - * Updates an SSH public key and returns the profile information. This method - * supports patch semantics. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The fingerprint of the public key to update. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * @param {google.cloud.oslogin.common.SshPublicKey} request.sshPublicKey - * Required. The SSH public key and expiration time. - * @param {google.protobuf.FieldMask} request.updateMask - * Mask to control which fields get updated. Updates all if not present. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.oslogin.common.SshPublicKey|SshPublicKey}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_login_service.update_ssh_public_key.js - * region_tag:oslogin_v1beta_generated_OsLoginService_UpdateSshPublicKey_async - */ - updateSshPublicKey( - request?: protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest|undefined, {}|undefined - ]>; - updateSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - updateSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest, - callback: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - updateSshPublicKey( - request?: protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateSshPublicKey(request, options, callback); - } -/** - * Signs an SSH public key for a user to authenticate to an instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.sshPublicKey - * The SSH public key to sign. - * @param {string} request.parent - * The parent project and zone for the signing request. This is needed to - * properly ensure per-organization ISS processing and potentially to provide - * for the possibility of zone-specific certificates used in the signing - * process. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.oslogin.v1beta.SignSshPublicKeyResponse|SignSshPublicKeyResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/os_login_service.sign_ssh_public_key.js - * region_tag:oslogin_v1beta_generated_OsLoginService_SignSshPublicKey_async - */ - signSshPublicKey( - request?: protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyResponse, - protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyRequest|undefined, {}|undefined - ]>; - signSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyResponse, - protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - signSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyRequest, - callback: Callback< - protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyResponse, - protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyRequest|null|undefined, - {}|null|undefined>): void; - signSshPublicKey( - request?: protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyResponse, - protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyResponse, - protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyResponse, - protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.signSshPublicKey(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified posixAccount resource name string. - * - * @param {string} user - * @param {string} project - * @returns {string} Resource name string. - */ - posixAccountPath(user:string,project:string) { - return this.pathTemplates.posixAccountPathTemplate.render({ - user: user, - project: project, - }); - } - - /** - * Parse the user from PosixAccount resource. - * - * @param {string} posixAccountName - * A fully-qualified path representing PosixAccount resource. - * @returns {string} A string representing the user. - */ - matchUserFromPosixAccountName(posixAccountName: string) { - return this.pathTemplates.posixAccountPathTemplate.match(posixAccountName).user; - } - - /** - * Parse the project from PosixAccount resource. - * - * @param {string} posixAccountName - * A fully-qualified path representing PosixAccount resource. - * @returns {string} A string representing the project. - */ - matchProjectFromPosixAccountName(posixAccountName: string) { - return this.pathTemplates.posixAccountPathTemplate.match(posixAccountName).project; - } - - /** - * Return a fully-qualified sshPublicKey resource name string. - * - * @param {string} user - * @param {string} fingerprint - * @returns {string} Resource name string. - */ - sshPublicKeyPath(user:string,fingerprint:string) { - return this.pathTemplates.sshPublicKeyPathTemplate.render({ - user: user, - fingerprint: fingerprint, - }); - } - - /** - * Parse the user from SshPublicKey resource. - * - * @param {string} sshPublicKeyName - * A fully-qualified path representing SshPublicKey resource. - * @returns {string} A string representing the user. - */ - matchUserFromSshPublicKeyName(sshPublicKeyName: string) { - return this.pathTemplates.sshPublicKeyPathTemplate.match(sshPublicKeyName).user; - } - - /** - * Parse the fingerprint from SshPublicKey resource. - * - * @param {string} sshPublicKeyName - * A fully-qualified path representing SshPublicKey resource. - * @returns {string} A string representing the fingerprint. - */ - matchFingerprintFromSshPublicKeyName(sshPublicKeyName: string) { - return this.pathTemplates.sshPublicKeyPathTemplate.match(sshPublicKeyName).fingerprint; - } - - /** - * Return a fully-qualified user resource name string. - * - * @param {string} user - * @returns {string} Resource name string. - */ - userPath(user:string) { - return this.pathTemplates.userPathTemplate.render({ - user: user, - }); - } - - /** - * Parse the user from User resource. - * - * @param {string} userName - * A fully-qualified path representing User resource. - * @returns {string} A string representing the user. - */ - matchUserFromUserName(userName: string) { - return this.pathTemplates.userPathTemplate.match(userName).user; - } - - /** - * 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.osLoginServiceStub && !this._terminated) { - return this.osLoginServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_client_config.json b/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_client_config.json deleted file mode 100644 index 993e2ef12fe..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_client_config.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "interfaces": { - "google.cloud.oslogin.v1beta.OsLoginService": { - "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": { - "CreateSshPublicKey": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeletePosixAccount": { - "timeout_millis": 10000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "DeleteSshPublicKey": { - "timeout_millis": 10000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetLoginProfile": { - "timeout_millis": 10000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetSshPublicKey": { - "timeout_millis": 10000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ImportSshPublicKey": { - "timeout_millis": 10000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateSshPublicKey": { - "timeout_millis": 10000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "SignSshPublicKey": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_proto_list.json b/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_proto_list.json deleted file mode 100644 index 078ed1d537d..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/src/v1beta/os_login_service_proto_list.json +++ /dev/null @@ -1,4 +0,0 @@ -[ - "../../protos/google/cloud/oslogin/common/common.proto", - "../../protos/google/cloud/oslogin/v1beta/oslogin.proto" -] diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-oslogin/v1beta/system-test/fixtures/sample/src/index.js deleted file mode 100644 index de1b9afaf4f..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const oslogin = require('@google-cloud/os-login'); - -function main() { - const osLoginServiceClient = new oslogin.OsLoginServiceClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-oslogin/v1beta/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index ab3709b1bb9..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {OsLoginServiceClient} from '@google-cloud/os-login'; - -// check that the client class type name can be used -function doStuffWithOsLoginServiceClient(client: OsLoginServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const osLoginServiceClient = new OsLoginServiceClient(); - doStuffWithOsLoginServiceClient(osLoginServiceClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/system-test/install.ts b/owl-bot-staging/google-cloud-oslogin/v1beta/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/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-oslogin/v1beta/test/gapic_os_login_service_v1beta.ts b/owl-bot-staging/google-cloud-oslogin/v1beta/test/gapic_os_login_service_v1beta.ts deleted file mode 100644 index 75819591839..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/test/gapic_os_login_service_v1beta.ts +++ /dev/null @@ -1,1123 +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 osloginserviceModule from '../src'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -describe('v1beta.OsLoginServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = osloginserviceModule.v1beta.OsLoginServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = osloginserviceModule.v1beta.OsLoginServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = osloginserviceModule.v1beta.OsLoginServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.osLoginServiceStub, undefined); - await client.initialize(); - assert(client.osLoginServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.osLoginServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.osLoginServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - 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 osloginserviceModule.v1beta.OsLoginServiceClient({ - 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('createSshPublicKey', () => { - it('invokes createSshPublicKey without error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.common.SshPublicKey() - ); - client.innerApiCalls.createSshPublicKey = stubSimpleCall(expectedResponse); - const [response] = await client.createSshPublicKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSshPublicKey without error using callback', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.common.SshPublicKey() - ); - client.innerApiCalls.createSshPublicKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createSshPublicKey( - request, - (err?: Error|null, result?: protos.google.cloud.oslogin.common.ISshPublicKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSshPublicKey with error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSshPublicKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createSshPublicKey(request), expectedError); - const actualRequest = (client.innerApiCalls.createSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSshPublicKey with closed client', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createSshPublicKey(request), expectedError); - }); - }); - - describe('deletePosixAccount', () => { - it('invokes deletePosixAccount without error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.DeletePosixAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.DeletePosixAccountRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePosixAccount = stubSimpleCall(expectedResponse); - const [response] = await client.deletePosixAccount(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deletePosixAccount as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePosixAccount as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePosixAccount without error using callback', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.DeletePosixAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.DeletePosixAccountRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePosixAccount = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deletePosixAccount( - 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.deletePosixAccount as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePosixAccount as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePosixAccount with error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.DeletePosixAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.DeletePosixAccountRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deletePosixAccount = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deletePosixAccount(request), expectedError); - const actualRequest = (client.innerApiCalls.deletePosixAccount as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePosixAccount as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePosixAccount with closed client', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.DeletePosixAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.DeletePosixAccountRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deletePosixAccount(request), expectedError); - }); - }); - - describe('deleteSshPublicKey', () => { - it('invokes deleteSshPublicKey without error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteSshPublicKey = stubSimpleCall(expectedResponse); - const [response] = await client.deleteSshPublicKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteSshPublicKey without error using callback', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteSshPublicKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteSshPublicKey( - 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.deleteSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteSshPublicKey with error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSshPublicKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteSshPublicKey(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteSshPublicKey with closed client', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteSshPublicKey(request), expectedError); - }); - }); - - describe('getLoginProfile', () => { - it('invokes getLoginProfile without error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.GetLoginProfileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.GetLoginProfileRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.LoginProfile() - ); - client.innerApiCalls.getLoginProfile = stubSimpleCall(expectedResponse); - const [response] = await client.getLoginProfile(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getLoginProfile as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLoginProfile as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getLoginProfile without error using callback', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.GetLoginProfileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.GetLoginProfileRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.LoginProfile() - ); - client.innerApiCalls.getLoginProfile = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLoginProfile( - request, - (err?: Error|null, result?: protos.google.cloud.oslogin.v1beta.ILoginProfile|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getLoginProfile as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLoginProfile as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getLoginProfile with error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.GetLoginProfileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.GetLoginProfileRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getLoginProfile = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLoginProfile(request), expectedError); - const actualRequest = (client.innerApiCalls.getLoginProfile as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLoginProfile as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getLoginProfile with closed client', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.GetLoginProfileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.GetLoginProfileRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getLoginProfile(request), expectedError); - }); - }); - - describe('getSshPublicKey', () => { - it('invokes getSshPublicKey without error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.common.SshPublicKey() - ); - client.innerApiCalls.getSshPublicKey = stubSimpleCall(expectedResponse); - const [response] = await client.getSshPublicKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSshPublicKey without error using callback', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.common.SshPublicKey() - ); - client.innerApiCalls.getSshPublicKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getSshPublicKey( - request, - (err?: Error|null, result?: protos.google.cloud.oslogin.common.ISshPublicKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSshPublicKey with error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getSshPublicKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getSshPublicKey(request), expectedError); - const actualRequest = (client.innerApiCalls.getSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSshPublicKey with closed client', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getSshPublicKey(request), expectedError); - }); - }); - - describe('importSshPublicKey', () => { - it('invokes importSshPublicKey without error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyResponse() - ); - client.innerApiCalls.importSshPublicKey = stubSimpleCall(expectedResponse); - const [response] = await client.importSshPublicKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importSshPublicKey without error using callback', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyResponse() - ); - client.innerApiCalls.importSshPublicKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importSshPublicKey( - request, - (err?: Error|null, result?: protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importSshPublicKey with error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importSshPublicKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.importSshPublicKey(request), expectedError); - const actualRequest = (client.innerApiCalls.importSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importSshPublicKey with closed client', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.importSshPublicKey(request), expectedError); - }); - }); - - describe('updateSshPublicKey', () => { - it('invokes updateSshPublicKey without error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.common.SshPublicKey() - ); - client.innerApiCalls.updateSshPublicKey = stubSimpleCall(expectedResponse); - const [response] = await client.updateSshPublicKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateSshPublicKey without error using callback', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.common.SshPublicKey() - ); - client.innerApiCalls.updateSshPublicKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateSshPublicKey( - request, - (err?: Error|null, result?: protos.google.cloud.oslogin.common.ISshPublicKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateSshPublicKey with error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSshPublicKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateSshPublicKey(request), expectedError); - const actualRequest = (client.innerApiCalls.updateSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateSshPublicKey with closed client', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateSshPublicKey(request), expectedError); - }); - }); - - describe('signSshPublicKey', () => { - it('invokes signSshPublicKey without error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.SignSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.SignSshPublicKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.SignSshPublicKeyResponse() - ); - client.innerApiCalls.signSshPublicKey = stubSimpleCall(expectedResponse); - const [response] = await client.signSshPublicKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.signSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.signSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes signSshPublicKey without error using callback', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.SignSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.SignSshPublicKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.SignSshPublicKeyResponse() - ); - client.innerApiCalls.signSshPublicKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.signSshPublicKey( - request, - (err?: Error|null, result?: protos.google.cloud.oslogin.v1beta.ISignSshPublicKeyResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.signSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.signSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes signSshPublicKey with error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.SignSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.SignSshPublicKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.signSshPublicKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.signSshPublicKey(request), expectedError); - const actualRequest = (client.innerApiCalls.signSshPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.signSshPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes signSshPublicKey with closed client', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.SignSshPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oslogin.v1beta.SignSshPublicKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.signSshPublicKey(request), expectedError); - }); - }); - - describe('Path templates', () => { - - describe('posixAccount', () => { - const fakePath = "/rendered/path/posixAccount"; - const expectedParameters = { - user: "userValue", - project: "projectValue", - }; - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.posixAccountPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.posixAccountPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('posixAccountPath', () => { - const result = client.posixAccountPath("userValue", "projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.posixAccountPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchUserFromPosixAccountName', () => { - const result = client.matchUserFromPosixAccountName(fakePath); - assert.strictEqual(result, "userValue"); - assert((client.pathTemplates.posixAccountPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProjectFromPosixAccountName', () => { - const result = client.matchProjectFromPosixAccountName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.posixAccountPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('sshPublicKey', () => { - const fakePath = "/rendered/path/sshPublicKey"; - const expectedParameters = { - user: "userValue", - fingerprint: "fingerprintValue", - }; - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.sshPublicKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.sshPublicKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('sshPublicKeyPath', () => { - const result = client.sshPublicKeyPath("userValue", "fingerprintValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.sshPublicKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchUserFromSshPublicKeyName', () => { - const result = client.matchUserFromSshPublicKeyName(fakePath); - assert.strictEqual(result, "userValue"); - assert((client.pathTemplates.sshPublicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchFingerprintFromSshPublicKeyName', () => { - const result = client.matchFingerprintFromSshPublicKeyName(fakePath); - assert.strictEqual(result, "fingerprintValue"); - assert((client.pathTemplates.sshPublicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('user', () => { - const fakePath = "/rendered/path/user"; - const expectedParameters = { - user: "userValue", - }; - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.userPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.userPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('userPath', () => { - const result = client.userPath("userValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.userPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchUserFromUserName', () => { - const result = client.matchUserFromUserName(fakePath); - assert.strictEqual(result, "userValue"); - assert((client.pathTemplates.userPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-oslogin/v1beta/tsconfig.json b/owl-bot-staging/google-cloud-oslogin/v1beta/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/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-oslogin/v1beta/webpack.config.js b/owl-bot-staging/google-cloud-oslogin/v1beta/webpack.config.js deleted file mode 100644 index 67fc391472d..00000000000 --- a/owl-bot-staging/google-cloud-oslogin/v1beta/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: 'OsLoginService', - filename: './os-login-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-phishingprotection/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.gitignore b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.jsdoc.js deleted file mode 100644 index 42bc19bd758..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.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/phishing-protection', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.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-phishingprotection/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/.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-phishingprotection/v1beta1/README.md b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/README.md deleted file mode 100644 index 30dcb3ca0dc..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Phishingprotection: Nodejs Client diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/package.json b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/package.json deleted file mode 100644 index 835ea83496c..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/phishing-protection", - "version": "0.1.0", - "description": "Phishingprotection client for Node.js", - "repository": "googleapis/nodejs-phishingprotection", - "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 phishingprotection", - "phishingprotection", - "phishing protection service v1 beta1" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/protos/google/cloud/phishingprotection/v1beta1/phishingprotection.proto b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/protos/google/cloud/phishingprotection/v1beta1/phishingprotection.proto deleted file mode 100644 index 82eb6af4424..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/protos/google/cloud/phishingprotection/v1beta1/phishingprotection.proto +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2019 Google LLC. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -syntax = "proto3"; - -package google.cloud.phishingprotection.v1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; - -option csharp_namespace = "Google.Cloud.PhishingProtection.V1Beta1"; -option go_package = "cloud.google.com/go/phishingprotection/apiv1beta1/phishingprotectionpb;phishingprotectionpb"; -option java_multiple_files = true; -option java_outer_classname = "PhishingProtectionProto"; -option java_package = "com.google.phishingprotection.v1beta1"; -option objc_class_prefix = "GCPP"; -option php_namespace = "Google\\Cloud\\PhishingProtection\\V1beta1"; -option ruby_package = "Google::Cloud::PhishingProtection::V1beta1"; - -// Service to report phishing URIs. -service PhishingProtectionServiceV1Beta1 { - option (google.api.default_host) = "phishingprotection.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Reports a URI suspected of containing phishing content to be reviewed. Once - // the report review is complete, its result can be found in the Cloud - // Security Command Center findings dashboard for Phishing Protection. If the - // result verifies the existence of malicious phishing content, the site will - // be added the to [Google's Social Engineering - // lists](https://support.google.com/webmasters/answer/6350487/) in order to - // protect users that could get exposed to this threat in the future. - rpc ReportPhishing(ReportPhishingRequest) returns (ReportPhishingResponse) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*}/phishing:report" - body: "*" - }; - option (google.api.method_signature) = "parent,uri"; - } -} - -// The ReportPhishing request message. -message ReportPhishingRequest { - // Required. The name of the project for which the report will be created, - // in the format "projects/{project_number}". - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Required. The URI that is being reported for phishing content to be analyzed. - string uri = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// The ReportPhishing (empty) response message. -message ReportPhishingResponse { - -} diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/samples/generated/v1beta1/phishing_protection_service_v1_beta1.report_phishing.js b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/samples/generated/v1beta1/phishing_protection_service_v1_beta1.report_phishing.js deleted file mode 100644 index 0d1b2c7c635..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/samples/generated/v1beta1/phishing_protection_service_v1_beta1.report_phishing.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(parent, uri) { - // [START phishingprotection_v1beta1_generated_PhishingProtectionServiceV1Beta1_ReportPhishing_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 project for which the report will be created, - * in the format "projects/{project_number}". - */ - // const parent = 'abc123' - /** - * Required. The URI that is being reported for phishing content to be analyzed. - */ - // const uri = 'abc123' - - // Imports the Phishingprotection library - const {PhishingProtectionServiceV1Beta1Client} = require('@google-cloud/phishing-protection').v1beta1; - - // Instantiates a client - const phishingprotectionClient = new PhishingProtectionServiceV1Beta1Client(); - - async function callReportPhishing() { - // Construct request - const request = { - parent, - uri, - }; - - // Run request - const response = await phishingprotectionClient.reportPhishing(request); - console.log(response); - } - - callReportPhishing(); - // [END phishingprotection_v1beta1_generated_PhishingProtectionServiceV1Beta1_ReportPhishing_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.phishingprotection.v1beta1.json b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.phishingprotection.v1beta1.json deleted file mode 100644 index 3b80591f191..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.phishingprotection.v1beta1.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-phishingprotection", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.phishingprotection.v1beta1", - "version": "v1beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "phishingprotection_v1beta1_generated_PhishingProtectionServiceV1Beta1_ReportPhishing_async", - "title": "PhishingProtectionServiceV1Beta1 reportPhishing Sample", - "origin": "API_DEFINITION", - "description": " Reports a URI suspected of containing phishing content to be reviewed. Once the report review is complete, its result can be found in the Cloud Security Command Center findings dashboard for Phishing Protection. If the result verifies the existence of malicious phishing content, the site will be added the to [Google's Social Engineering lists](https://support.google.com/webmasters/answer/6350487/) in order to protect users that could get exposed to this threat in the future.", - "canonical": true, - "file": "phishing_protection_service_v1_beta1.report_phishing.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ReportPhishing", - "fullName": "google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1.ReportPhishing", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "uri", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.phishingprotection.v1beta1.ReportPhishingResponse", - "client": { - "shortName": "PhishingProtectionServiceV1Beta1Client", - "fullName": "google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1Client" - }, - "method": { - "shortName": "ReportPhishing", - "fullName": "google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1.ReportPhishing", - "service": { - "shortName": "PhishingProtectionServiceV1Beta1", - "fullName": "google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/index.ts deleted file mode 100644 index 32cceabcb87..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/index.ts +++ /dev/null @@ -1,25 +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 v1beta1 from './v1beta1'; -const PhishingProtectionServiceV1Beta1Client = v1beta1.PhishingProtectionServiceV1Beta1Client; -type PhishingProtectionServiceV1Beta1Client = v1beta1.PhishingProtectionServiceV1Beta1Client; -export {v1beta1, PhishingProtectionServiceV1Beta1Client}; -export default {v1beta1, PhishingProtectionServiceV1Beta1Client}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/gapic_metadata.json deleted file mode 100644 index 1840cf8dbd5..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/gapic_metadata.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.phishingprotection.v1beta1", - "libraryPackage": "@google-cloud/phishing-protection", - "services": { - "PhishingProtectionServiceV1Beta1": { - "clients": { - "grpc": { - "libraryClient": "PhishingProtectionServiceV1Beta1Client", - "rpcs": { - "ReportPhishing": { - "methods": [ - "reportPhishing" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "PhishingProtectionServiceV1Beta1Client", - "rpcs": { - "ReportPhishing": { - "methods": [ - "reportPhishing" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/index.ts deleted file mode 100644 index f2c65442af2..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/index.ts +++ /dev/null @@ -1,19 +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 {PhishingProtectionServiceV1Beta1Client} from './phishing_protection_service_v1_beta1_client'; diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_client.ts b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_client.ts deleted file mode 100644 index 38487d835dd..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_client.ts +++ /dev/null @@ -1,421 +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} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta1/phishing_protection_service_v1_beta1_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './phishing_protection_service_v1_beta1_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service to report phishing URIs. - * @class - * @memberof v1beta1 - */ -export class PhishingProtectionServiceV1Beta1Client { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - phishingProtectionServiceV1Beta1Stub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of PhishingProtectionServiceV1Beta1Client. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 PhishingProtectionServiceV1Beta1Client({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof PhishingProtectionServiceV1Beta1Client; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1', 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.phishingProtectionServiceV1Beta1Stub) { - return this.phishingProtectionServiceV1Beta1Stub; - } - - // Put together the "service stub" for - // google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1. - this.phishingProtectionServiceV1Beta1Stub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1, - 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 phishingProtectionServiceV1Beta1StubMethods = - ['reportPhishing']; - for (const methodName of phishingProtectionServiceV1Beta1StubMethods) { - const callPromise = this.phishingProtectionServiceV1Beta1Stub.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.phishingProtectionServiceV1Beta1Stub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'phishingprotection.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 'phishingprotection.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 -- - // ------------------- -/** - * Reports a URI suspected of containing phishing content to be reviewed. Once - * the report review is complete, its result can be found in the Cloud - * Security Command Center findings dashboard for Phishing Protection. If the - * result verifies the existence of malicious phishing content, the site will - * be added the to [Google's Social Engineering - * lists](https://support.google.com/webmasters/answer/6350487/) in order to - * protect users that could get exposed to this threat in the future. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project for which the report will be created, - * in the format "projects/{project_number}". - * @param {string} request.uri - * Required. The URI that is being reported for phishing content to be analyzed. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.phishingprotection.v1beta1.ReportPhishingResponse|ReportPhishingResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/phishing_protection_service_v1_beta1.report_phishing.js - * region_tag:phishingprotection_v1beta1_generated_PhishingProtectionServiceV1Beta1_ReportPhishing_async - */ - reportPhishing( - request?: protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse, - protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest|undefined, {}|undefined - ]>; - reportPhishing( - request: protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse, - protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest|null|undefined, - {}|null|undefined>): void; - reportPhishing( - request: protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest, - callback: Callback< - protos.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse, - protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest|null|undefined, - {}|null|undefined>): void; - reportPhishing( - request?: protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse, - protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse, - protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse, - protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.reportPhishing(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.phishingProtectionServiceV1Beta1Stub && !this._terminated) { - return this.phishingProtectionServiceV1Beta1Stub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_client_config.json b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_client_config.json deleted file mode 100644 index 44b8db8ab62..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_client_config.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "interfaces": { - "google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1": { - "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": { - "ReportPhishing": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_proto_list.json b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_proto_list.json deleted file mode 100644 index 55a8764d3ea..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/src/v1beta1/phishing_protection_service_v1_beta1_proto_list.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "../../protos/google/cloud/phishingprotection/v1beta1/phishingprotection.proto" -] diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 969b6c48196..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const phishingprotection = require('@google-cloud/phishing-protection'); - -function main() { - const phishingProtectionServiceV1Beta1Client = new phishingprotection.PhishingProtectionServiceV1Beta1Client(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index a60c7a4ddae..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {PhishingProtectionServiceV1Beta1Client} from '@google-cloud/phishing-protection'; - -// check that the client class type name can be used -function doStuffWithPhishingProtectionServiceV1Beta1Client(client: PhishingProtectionServiceV1Beta1Client) { - client.close(); -} - -function main() { - // check that the client instance can be created - const phishingProtectionServiceV1Beta1Client = new PhishingProtectionServiceV1Beta1Client(); - doStuffWithPhishingProtectionServiceV1Beta1Client(phishingProtectionServiceV1Beta1Client); -} - -main(); diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/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-phishingprotection/v1beta1/test/gapic_phishing_protection_service_v1_beta1_v1beta1.ts b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/test/gapic_phishing_protection_service_v1_beta1_v1beta1.ts deleted file mode 100644 index e1000c503bf..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/test/gapic_phishing_protection_service_v1_beta1_v1beta1.ts +++ /dev/null @@ -1,291 +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 phishingprotectionservicev1beta1Module from '../src'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -describe('v1beta1.PhishingProtectionServiceV1Beta1Client', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.phishingProtectionServiceV1Beta1Stub, undefined); - await client.initialize(); - assert(client.phishingProtectionServiceV1Beta1Stub); - }); - - it('has close method for the initialized client', done => { - const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.phishingProtectionServiceV1Beta1Stub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.phishingProtectionServiceV1Beta1Stub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ - 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 phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ - 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('reportPhishing', () => { - it('invokes reportPhishing without error', async () => { - const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.phishingprotection.v1beta1.ReportPhishingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.phishingprotection.v1beta1.ReportPhishingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.phishingprotection.v1beta1.ReportPhishingResponse() - ); - client.innerApiCalls.reportPhishing = stubSimpleCall(expectedResponse); - const [response] = await client.reportPhishing(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reportPhishing as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportPhishing as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reportPhishing without error using callback', async () => { - const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.phishingprotection.v1beta1.ReportPhishingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.phishingprotection.v1beta1.ReportPhishingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.phishingprotection.v1beta1.ReportPhishingResponse() - ); - client.innerApiCalls.reportPhishing = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.reportPhishing( - request, - (err?: Error|null, result?: protos.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reportPhishing as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportPhishing as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reportPhishing with error', async () => { - const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.phishingprotection.v1beta1.ReportPhishingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.phishingprotection.v1beta1.ReportPhishingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.reportPhishing = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.reportPhishing(request), expectedError); - const actualRequest = (client.innerApiCalls.reportPhishing as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportPhishing as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reportPhishing with closed client', async () => { - const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.phishingprotection.v1beta1.ReportPhishingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.phishingprotection.v1beta1.ReportPhishingRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.reportPhishing(request), expectedError); - }); - }); - - describe('Path templates', () => { - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new phishingprotectionservicev1beta1Module.v1beta1.PhishingProtectionServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-phishingprotection/v1beta1/webpack.config.js deleted file mode 100644 index e3f8ac35c5f..00000000000 --- a/owl-bot-staging/google-cloud-phishingprotection/v1beta1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'PhishingProtectionServiceV1Beta1', - filename: './phishing-protection-service-v1-beta1.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-policytroubleshooter-iam/v3/.eslintignore b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.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-policytroubleshooter-iam/v3/.eslintrc.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.gitignore b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.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-policytroubleshooter-iam/v3/.jsdoc.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.jsdoc.js deleted file mode 100644 index cdc66248f75..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.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/iam', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.mocharc.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.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-policytroubleshooter-iam/v3/.prettierrc.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/.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-policytroubleshooter-iam/v3/README.md b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/README.md deleted file mode 100644 index 905fae6bcad..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/README.md +++ /dev/null @@ -1 +0,0 @@ -Iam: Nodejs Client diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/package.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/package.json deleted file mode 100644 index 050b00ab47e..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/package.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "name": "@google-cloud/iam", - "version": "0.1.0", - "description": "Iam client for Node.js", - "repository": "googleapis/nodejs-iam", - "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 iam", - "iam", - "policies", - "policy troubleshooter" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/protos/google/cloud/policytroubleshooter/iam/v3/troubleshooter.proto b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/protos/google/cloud/policytroubleshooter/iam/v3/troubleshooter.proto deleted file mode 100644 index 6a2928b1d55..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/protos/google/cloud/policytroubleshooter/iam/v3/troubleshooter.proto +++ /dev/null @@ -1,757 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.policytroubleshooter.iam.v3; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/iam/v1/policy.proto"; -import "google/iam/v2/policy.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/expr.proto"; - -option cc_enable_arenas = true; -option csharp_namespace = "Google.Cloud.PolicyTroubleshooter.Iam.V3"; -option go_package = "cloud.google.com/go/policytroubleshooter/iam/apiv3/iampb;iampb"; -option java_multiple_files = true; -option java_outer_classname = "TroubleshooterProto"; -option java_package = "com.google.cloud.policytroubleshooter.iam.v3"; -option php_namespace = "Google\\Cloud\\PolicyTroubleshooter\\Iam\\V3"; -option ruby_package = "Google::Cloud::PolicyTroubleshooter::Iam::V3"; - -// IAM Policy Troubleshooter service. -// -// This service helps you troubleshoot access issues for Google Cloud resources. -service PolicyTroubleshooter { - option (google.api.default_host) = "policytroubleshooter.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Checks whether a principal has a specific permission for a specific - // resource, and explains why the principal does or doesn't have that - // permission. - rpc TroubleshootIamPolicy(TroubleshootIamPolicyRequest) - returns (TroubleshootIamPolicyResponse) { - option (google.api.http) = { - post: "/v3/iam:troubleshoot" - body: "*" - }; - } -} - -// Whether IAM allow policies gives the principal the permission. -enum AllowAccessState { - // Not specified. - ALLOW_ACCESS_STATE_UNSPECIFIED = 0; - - // The allow policy gives the principal the permission. - ALLOW_ACCESS_STATE_GRANTED = 1; - - // The allow policy doesn't give the principal the permission. - ALLOW_ACCESS_STATE_NOT_GRANTED = 2; - - // The allow policy gives the principal the permission if a condition - // expression evaluate to `true`. However, the sender of the request didn't - // provide enough context for Policy Troubleshooter to evaluate the condition - // expression. - ALLOW_ACCESS_STATE_UNKNOWN_CONDITIONAL = 3; - - // The sender of the request doesn't have access to all of the allow policies - // that Policy Troubleshooter needs to evaluate the principal's access. - ALLOW_ACCESS_STATE_UNKNOWN_INFO = 4; -} - -// Whether IAM deny policies deny the principal the permission. -enum DenyAccessState { - // Not specified. - DENY_ACCESS_STATE_UNSPECIFIED = 0; - - // The deny policy denies the principal the permission. - DENY_ACCESS_STATE_DENIED = 1; - - // The deny policy doesn't deny the principal the permission. - DENY_ACCESS_STATE_NOT_DENIED = 2; - - // The deny policy denies the principal the permission if a condition - // expression evaluates to `true`. However, the sender of the request didn't - // provide enough context for Policy Troubleshooter to evaluate the condition - // expression. - DENY_ACCESS_STATE_UNKNOWN_CONDITIONAL = 3; - - // The sender of the request does not have access to all of the deny policies - // that Policy Troubleshooter needs to evaluate the principal's access. - DENY_ACCESS_STATE_UNKNOWN_INFO = 4; -} - -// Whether a role includes a specific permission. -enum RolePermissionInclusionState { - // Not specified. - ROLE_PERMISSION_INCLUSION_STATE_UNSPECIFIED = 0; - - // The permission is included in the role. - ROLE_PERMISSION_INCLUDED = 1; - - // The permission is not included in the role. - ROLE_PERMISSION_NOT_INCLUDED = 2; - - // The sender of the request is not allowed to access the role definition. - ROLE_PERMISSION_UNKNOWN_INFO = 3; -} - -// Whether the permission in the request matches the permission in the policy. -enum PermissionPatternMatchingState { - // Not specified. - PERMISSION_PATTERN_MATCHING_STATE_UNSPECIFIED = 0; - - // The permission in the request matches the permission in the policy. - PERMISSION_PATTERN_MATCHED = 1; - - // The permission in the request matches the permission in the policy. - PERMISSION_PATTERN_NOT_MATCHED = 2; -} - -// Whether the principal in the request matches the principal in the policy. -enum MembershipMatchingState { - // Not specified. - MEMBERSHIP_MATCHING_STATE_UNSPECIFIED = 0; - - // The principal in the request matches the principal in the policy. The - // principal can be included directly or indirectly: - // - // * A principal is included directly if that principal is listed in the - // role binding. - // * A principal is included indirectly if that principal is in a Google - // group, Google Workspace account, or Cloud Identity domain that is listed - // in the policy. - MEMBERSHIP_MATCHED = 1; - - // The principal in the request doesn't match the principal in the policy. - MEMBERSHIP_NOT_MATCHED = 2; - - // The principal in the policy is a group or domain, and the sender of the - // request doesn't have permission to view whether the principal in the - // request is a member of the group or domain. - MEMBERSHIP_UNKNOWN_INFO = 3; - - // The principal is an unsupported type. - MEMBERSHIP_UNKNOWN_UNSUPPORTED = 4; -} - -// The extent to which a single data point contributes to an overall -// determination. -enum HeuristicRelevance { - // Not specified. - HEURISTIC_RELEVANCE_UNSPECIFIED = 0; - - // The data point has a limited effect on the result. Changing the data point - // is unlikely to affect the overall determination. - HEURISTIC_RELEVANCE_NORMAL = 1; - - // The data point has a strong effect on the result. Changing the data point - // is likely to affect the overall determination. - HEURISTIC_RELEVANCE_HIGH = 2; -} - -// Request for -// [TroubleshootIamPolicy][google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter.TroubleshootIamPolicy]. -message TroubleshootIamPolicyRequest { - // The information to use for checking whether a principal has a permission - // for a resource. - AccessTuple access_tuple = 1; -} - -// Response for -// [TroubleshootIamPolicy][google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter.TroubleshootIamPolicy]. -message TroubleshootIamPolicyResponse { - // Whether the principal has the permission on the resource. - enum OverallAccessState { - // Not specified. - OVERALL_ACCESS_STATE_UNSPECIFIED = 0; - - // The principal has the permission. - CAN_ACCESS = 1; - - // The principal doesn't have the permission. - CANNOT_ACCESS = 2; - - // The principal might have the permission, but the sender can't access all - // of the information needed to fully evaluate the principal's access. - UNKNOWN_INFO = 3; - - // The principal might have the permission, but Policy Troubleshooter can't - // fully evaluate the principal's access because the sender didn't provide - // the required context to evaluate the condition. - UNKNOWN_CONDITIONAL = 4; - } - - // Indicates whether the principal has the specified permission for the - // specified resource, based on evaluating all types of the applicable IAM - // policies. - OverallAccessState overall_access_state = 1; - - // The access tuple from the request, including any provided context used to - // evaluate the condition. - AccessTuple access_tuple = 2; - - // An explanation of how the applicable IAM allow policies affect the final - // access state. - AllowPolicyExplanation allow_policy_explanation = 3; - - // An explanation of how the applicable IAM deny policies affect the final - // access state. - DenyPolicyExplanation deny_policy_explanation = 4; -} - -// Information about the principal, resource, and permission to check. -message AccessTuple { - // Required. The email address of the principal whose access you want to - // check. For example, `alice@example.com` or - // `my-service-account@my-project.iam.gserviceaccount.com`. - // - // The principal must be a Google Account or a service account. Other types of - // principals are not supported. - string principal = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The full resource name that identifies the resource. For example, - // `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`. - // - // For examples of full resource names for Google Cloud services, see - // https://cloud.google.com/iam/help/troubleshooter/full-resource-names. - string full_resource_name = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The IAM permission to check for, either in the `v1` permission - // format or the `v2` permission format. - // - // For a complete list of IAM permissions in the `v1` format, see - // https://cloud.google.com/iam/help/permissions/reference. - // - // For a list of IAM permissions in the `v2` format, see - // https://cloud.google.com/iam/help/deny/supported-permissions. - // - // For a complete list of predefined IAM roles and the permissions in each - // role, see https://cloud.google.com/iam/help/roles/reference. - string permission = 3 [(google.api.field_behavior) = REQUIRED]; - - // Output only. The permission that Policy Troubleshooter checked for, in - // the `v2` format. - string permission_fqdn = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Additional context for the request, such as the request time or - // IP address. This context allows Policy Troubleshooter to troubleshoot - // conditional role bindings and deny rules. - ConditionContext condition_context = 5 - [(google.api.field_behavior) = OPTIONAL]; -} - -// Additional context for troubleshooting conditional role bindings and deny -// rules. -message ConditionContext { - // Core attributes for a resource. A resource is an - // addressable (named) entity provided by the destination service. For - // example, a Compute Engine instance. - message Resource { - // The name of the service that this resource belongs to, such as - // `compute.googleapis.com`. The service name might not match the DNS - // hostname that actually serves the request. - // - // For a full list of resource service values, see - // https://cloud.google.com/iam/help/conditions/resource-services - string service = 1; - - // The stable identifier (name) of a resource on the `service`. A resource - // can be logically identified as `//{resource.service}/{resource.name}`. - // Unlike the resource URI, the resource name doesn't contain any protocol - // and version information. - // - // For a list of full resource name formats, see - // https://cloud.google.com/iam/help/troubleshooter/full-resource-names - string name = 2; - - // The type of the resource, in the format `{service}/{kind}`. - // - // For a full list of resource type values, see - // https://cloud.google.com/iam/help/conditions/resource-types - string type = 3; - } - - // This message defines attributes for a node that handles a network request. - // The node can be either a service or an application that sends, forwards, - // or receives the request. Service peers should fill in - // `principal` and `labels` as appropriate. - message Peer { - // The IPv4 or IPv6 address of the peer. - string ip = 1; - - // The network port of the peer. - int64 port = 2; - } - - // This message defines attributes for an HTTP request. If the actual - // request is not an HTTP request, the runtime system should try to map - // the actual request to an equivalent HTTP request. - message Request { - // Optional. The timestamp when the destination service receives the first - // byte of the request. - google.protobuf.Timestamp receive_time = 1 - [(google.api.field_behavior) = OPTIONAL]; - } - - // A tag that applies to a resource during policy evaluation. Tags can be - // either directly bound to a resource or inherited from its ancestor. - // `EffectiveTag` contains the `name` and `namespaced_name` of the tag value - // and tag key, with additional fields of `inherited` to indicate the - // inheritance status of the effective tag. - message EffectiveTag { - // Output only. Resource name for TagValue in the format `tagValues/456`. - string tag_value = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The namespaced name of the TagValue. Can be in the form - // `{organization_id}/{tag_key_short_name}/{tag_value_short_name}` or - // `{project_id}/{tag_key_short_name}/{tag_value_short_name}` or - // `{project_number}/{tag_key_short_name}/{tag_value_short_name}`. - string namespaced_tag_value = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The name of the TagKey, in the format `tagKeys/{id}`, such - // as `tagKeys/123`. - string tag_key = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The namespaced name of the TagKey. Can be in the form - // `{organization_id}/{tag_key_short_name}` or - // `{project_id}/{tag_key_short_name}` or - // `{project_number}/{tag_key_short_name}`. - string namespaced_tag_key = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The parent name of the tag key. - // Must be in the format `organizations/{organization_id}` or - // `projects/{project_number}` - string tag_key_parent_name = 6; - - // Output only. Indicates the inheritance status of a tag value - // attached to the given resource. If the tag value is inherited from one of - // the resource's ancestors, inherited will be true. If false, then the tag - // value is directly attached to the resource, inherited will be false. - bool inherited = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - } - - // Represents a target resource that is involved with a network activity. - // If multiple resources are involved with an activity, this must be the - // primary one. - Resource resource = 1; - - // The destination of a network activity, such as accepting a TCP connection. - // In a multi-hop network activity, the destination represents the receiver of - // the last hop. - Peer destination = 2; - - // Represents a network request, such as an HTTP request. - Request request = 3; - - // Output only. The effective tags on the resource. The effective tags are - // fetched during troubleshooting. - repeated EffectiveTag effective_tags = 4 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Details about how the relevant IAM allow policies affect the final access -// state. -message AllowPolicyExplanation { - // Indicates whether the principal has the specified permission for the - // specified resource, based on evaluating all applicable IAM allow policies. - AllowAccessState allow_access_state = 1; - - // List of IAM allow policies that were evaluated to check the principal's - // permissions, with annotations to indicate how each policy contributed to - // the final result. - // - // The list of policies includes the policy for the resource itself, as well - // as allow policies that are inherited from higher levels of the resource - // hierarchy, including the organization, the folder, and the project. - // - // To learn more about the resource hierarchy, see - // https://cloud.google.com/iam/help/resource-hierarchy. - repeated ExplainedAllowPolicy explained_policies = 2; - - // The relevance of the allow policy type to the overall access state. - HeuristicRelevance relevance = 3; -} - -// Details about how a specific IAM allow policy contributed to the final access -// state. -message ExplainedAllowPolicy { - // Required. Indicates whether _this policy_ provides the specified permission - // to the specified principal for the specified resource. - // - // This field does _not_ indicate whether the principal actually has the - // permission for the resource. There might be another policy that overrides - // this policy. To determine whether the principal actually has the - // permission, use the `overall_access_state` field in the - // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse]. - AllowAccessState allow_access_state = 1 - [(google.api.field_behavior) = REQUIRED]; - - // The full resource name that identifies the resource. For example, - // `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`. - // - // If the sender of the request does not have access to the policy, this field - // is omitted. - // - // For examples of full resource names for Google Cloud services, see - // https://cloud.google.com/iam/help/troubleshooter/full-resource-names. - string full_resource_name = 2; - - // Details about how each role binding in the policy affects the principal's - // ability, or inability, to use the permission for the resource. The order of - // the role bindings matches the role binding order in the policy. - // - // If the sender of the request does not have access to the policy, this field - // is omitted. - repeated AllowBindingExplanation binding_explanations = 3; - - // The relevance of this policy to the overall access state in the - // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse]. - // - // If the sender of the request does not have access to the policy, this field - // is omitted. - HeuristicRelevance relevance = 4; - - // The IAM allow policy attached to the resource. - // - // If the sender of the request does not have access to the policy, this field - // is empty. - google.iam.v1.Policy policy = 5; -} - -// Details about how a role binding in an allow policy affects a principal's -// ability to use a permission. -message AllowBindingExplanation { - // Details about whether the role binding includes the principal. - message AnnotatedAllowMembership { - // Indicates whether the role binding includes the principal. - MembershipMatchingState membership = 1; - - // The relevance of the principal's status to the overall determination for - // the role binding. - HeuristicRelevance relevance = 2; - } - - // Required. Indicates whether _this role binding_ gives the specified - // permission to the specified principal on the specified resource. - // - // This field does _not_ indicate whether the principal actually has the - // permission on the resource. There might be another role binding that - // overrides this role binding. To determine whether the principal actually - // has the permission, use the `overall_access_state` field in the - // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse]. - AllowAccessState allow_access_state = 1 - [(google.api.field_behavior) = REQUIRED]; - - // The role that this role binding grants. For example, - // `roles/compute.admin`. - // - // For a complete list of predefined IAM roles, as well as the permissions in - // each role, see https://cloud.google.com/iam/help/roles/reference. - string role = 2; - - // Indicates whether the role granted by this role binding contains the - // specified permission. - RolePermissionInclusionState role_permission = 3; - - // The relevance of the permission's existence, or nonexistence, in the role - // to the overall determination for the entire policy. - HeuristicRelevance role_permission_relevance = 4; - - // The combined result of all memberships. Indicates if the principal is - // included in any role binding, either directly or indirectly. - AnnotatedAllowMembership combined_membership = 5; - - // Indicates whether each role binding includes the principal specified in the - // request, either directly or indirectly. Each key identifies a principal in - // the role binding, and each value indicates whether the principal in the - // role binding includes the principal in the request. - // - // For example, suppose that a role binding includes the following principals: - // - // * `user:alice@example.com` - // * `group:product-eng@example.com` - // - // You want to troubleshoot access for `user:bob@example.com`. This user is a - // member of the group `group:product-eng@example.com`. - // - // For the first principal in the role binding, the key is - // `user:alice@example.com`, and the `membership` field in the value is set to - // `NOT_INCLUDED`. - // - // For the second principal in the role binding, the key is - // `group:product-eng@example.com`, and the `membership` field in the value is - // set to `INCLUDED`. - map memberships = 6; - - // The relevance of this role binding to the overall determination for the - // entire policy. - HeuristicRelevance relevance = 7; - - // A condition expression that specifies when the role binding grants access. - // - // To learn about IAM Conditions, see - // https://cloud.google.com/iam/help/conditions/overview. - google.type.Expr condition = 8; - - // Condition evaluation state for this role binding. - ConditionExplanation condition_explanation = 9; -} - -// Details about how the relevant IAM deny policies affect the final access -// state. -message DenyPolicyExplanation { - // Indicates whether the principal is denied the specified permission for - // the specified resource, based on evaluating all applicable IAM deny - // policies. - DenyAccessState deny_access_state = 1; - - // List of resources with IAM deny policies that were evaluated to check the - // principal's denied permissions, with annotations to indicate how each - // policy contributed to the final result. - // - // The list of resources includes the policy for the resource itself, as well - // as policies that are inherited from higher levels of the resource - // hierarchy, including the organization, the folder, and the project. The - // order of the resources starts from the resource and climbs up the resource - // hierarchy. - // - // To learn more about the resource hierarchy, see - // https://cloud.google.com/iam/help/resource-hierarchy. - repeated ExplainedDenyResource explained_resources = 2; - - // The relevance of the deny policy result to the overall access state. - HeuristicRelevance relevance = 3; - - // Indicates whether the permission to troubleshoot is supported in deny - // policies. - bool permission_deniable = 4; -} - -// Details about how a specific resource contributed to the deny policy -// evaluation. -message ExplainedDenyResource { - // Required. Indicates whether any policies attached to _this resource_ deny - // the specific permission to the specified principal for the specified - // resource. - // - // This field does _not_ indicate whether the principal actually has the - // permission for the resource. There might be another policy that overrides - // this policy. To determine whether the principal actually has the - // permission, use the `overall_access_state` field in the - // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse]. - DenyAccessState deny_access_state = 1 - [(google.api.field_behavior) = REQUIRED]; - - // The full resource name that identifies the resource. For example, - // `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`. - // - // If the sender of the request does not have access to the policy, this field - // is omitted. - // - // For examples of full resource names for Google Cloud services, see - // https://cloud.google.com/iam/help/troubleshooter/full-resource-names. - string full_resource_name = 2; - - // List of IAM deny policies that were evaluated to check the principal's - // denied permissions, with annotations to indicate how each policy - // contributed to the final result. - repeated ExplainedDenyPolicy explained_policies = 3; - - // The relevance of this policy to the overall access state in the - // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse]. - // - // If the sender of the request does not have access to the policy, this field - // is omitted. - HeuristicRelevance relevance = 4; -} - -// Details about how a specific IAM deny policy [Policy][google.iam.v2.Policy] -// contributed to the access check. -message ExplainedDenyPolicy { - // Required. Indicates whether _this policy_ denies the specified permission - // to the specified principal for the specified resource. - // - // This field does _not_ indicate whether the principal actually has the - // permission for the resource. There might be another policy that overrides - // this policy. To determine whether the principal actually has the - // permission, use the `overall_access_state` field in the - // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse]. - DenyAccessState deny_access_state = 1 - [(google.api.field_behavior) = REQUIRED]; - - // The IAM deny policy attached to the resource. - // - // If the sender of the request does not have access to the policy, this field - // is omitted. - google.iam.v2.Policy policy = 2; - - // Details about how each rule in the policy affects the principal's inability - // to use the permission for the resource. The order of the deny rule matches - // the order of the rules in the deny policy. - // - // If the sender of the request does not have access to the policy, this field - // is omitted. - repeated DenyRuleExplanation rule_explanations = 3; - - // The relevance of this policy to the overall access state in the - // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse]. - // - // If the sender of the request does not have access to the policy, this field - // is omitted. - HeuristicRelevance relevance = 4; -} - -// Details about how a deny rule in a deny policy affects a principal's ability -// to use a permission. -message DenyRuleExplanation { - // Details about whether the permission in the request is denied by the - // deny rule. - message AnnotatedPermissionMatching { - // Indicates whether the permission in the request is denied by the deny - // rule. - PermissionPatternMatchingState permission_matching_state = 1; - - // The relevance of the permission status to the overall determination for - // the rule. - HeuristicRelevance relevance = 2; - } - - // Details about whether the principal in the request is listed as a denied - // principal in the deny rule, either directly or through membership in a - // principal set. - message AnnotatedDenyPrincipalMatching { - // Indicates whether the principal is listed as a denied principal in the - // deny rule, either directly or through membership in a principal set. - MembershipMatchingState membership = 1; - - // The relevance of the principal's status to the overall determination for - // the role binding. - HeuristicRelevance relevance = 2; - } - - // Required. Indicates whether _this rule_ denies the specified permission to - // the specified principal for the specified resource. - // - // This field does _not_ indicate whether the principal is actually denied on - // the permission for the resource. There might be another rule that overrides - // this rule. To determine whether the principal actually has the permission, - // use the `overall_access_state` field in the - // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse]. - DenyAccessState deny_access_state = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates whether the permission in the request is listed as a denied - // permission in the deny rule. - AnnotatedPermissionMatching combined_denied_permission = 2; - - // Lists all denied permissions in the deny rule and indicates whether each - // permission matches the permission in the request. - // - // Each key identifies a denied permission in the rule, and each value - // indicates whether the denied permission matches the permission in the - // request. - map denied_permissions = 3; - - // Indicates whether the permission in the request is listed as an exception - // permission in the deny rule. - AnnotatedPermissionMatching combined_exception_permission = 4; - - // Lists all exception permissions in the deny rule and indicates whether each - // permission matches the permission in the request. - // - // Each key identifies a exception permission in the rule, and each value - // indicates whether the exception permission matches the permission in the - // request. - map exception_permissions = 5; - - // Indicates whether the principal is listed as a denied principal in the - // deny rule, either directly or through membership in a principal set. - AnnotatedDenyPrincipalMatching combined_denied_principal = 6; - - // Lists all denied principals in the deny rule and indicates whether each - // principal matches the principal in the request, either directly or through - // membership in a principal set. - // - // Each key identifies a denied principal in the rule, and each value - // indicates whether the denied principal matches the principal in the - // request. - map denied_principals = 7; - - // Indicates whether the principal is listed as an exception principal in the - // deny rule, either directly or through membership in a principal set. - AnnotatedDenyPrincipalMatching combined_exception_principal = 8; - - // Lists all exception principals in the deny rule and indicates whether each - // principal matches the principal in the request, either directly or through - // membership in a principal set. - // - // Each key identifies a exception principal in the rule, and each value - // indicates whether the exception principal matches the principal in the - // request. - map exception_principals = 9; - - // The relevance of this role binding to the overall determination for the - // entire policy. - HeuristicRelevance relevance = 10; - - // A condition expression that specifies when the deny rule denies the - // principal access. - // - // To learn about IAM Conditions, see - // https://cloud.google.com/iam/help/conditions/overview. - google.type.Expr condition = 11; - - // Condition evaluation state for this role binding. - ConditionExplanation condition_explanation = 12; -} - -// Explanation for how a condition affects a principal's access -message ConditionExplanation { - // Evaluated state of a condition expression. - message EvaluationState { - // Start position of an expression in the condition, by character. - int32 start = 1; - - // End position of an expression in the condition, by character, - // end included, for example: the end position of the first part of - // `a==b || c==d` would be 4. - int32 end = 2; - - // Value of this expression. - google.protobuf.Value value = 3; - - // Any errors that prevented complete evaluation of the condition - // expression. - repeated google.rpc.Status errors = 4; - } - - // Value of the condition. - google.protobuf.Value value = 1; - - // Any errors that prevented complete evaluation of the condition expression. - repeated google.rpc.Status errors = 3; - - // The value of each statement of the condition expression. The value can be - // `true`, `false`, or `null`. The value is `null` if the statement can't be - // evaluated. - repeated EvaluationState evaluation_states = 2; -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/samples/generated/v3/policy_troubleshooter.troubleshoot_iam_policy.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/samples/generated/v3/policy_troubleshooter.troubleshoot_iam_policy.js deleted file mode 100644 index d8808bed570..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/samples/generated/v3/policy_troubleshooter.troubleshoot_iam_policy.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 policytroubleshooter_v3_generated_PolicyTroubleshooter_TroubleshootIamPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 information to use for checking whether a principal has a permission - * for a resource. - */ - // const accessTuple = {} - - // Imports the Iam library - const {PolicyTroubleshooterClient} = require('@google-cloud/iam').v3; - - // Instantiates a client - const iamClient = new PolicyTroubleshooterClient(); - - async function callTroubleshootIamPolicy() { - // Construct request - const request = { - }; - - // Run request - const response = await iamClient.troubleshootIamPolicy(request); - console.log(response); - } - - callTroubleshootIamPolicy(); - // [END policytroubleshooter_v3_generated_PolicyTroubleshooter_TroubleshootIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/samples/generated/v3/snippet_metadata_google.cloud.policytroubleshooter.iam.v3.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/samples/generated/v3/snippet_metadata_google.cloud.policytroubleshooter.iam.v3.json deleted file mode 100644 index a15c84dda60..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/samples/generated/v3/snippet_metadata_google.cloud.policytroubleshooter.iam.v3.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-iam", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.policytroubleshooter.iam.v3", - "version": "v3" - } - ] - }, - "snippets": [ - { - "regionTag": "policytroubleshooter_v3_generated_PolicyTroubleshooter_TroubleshootIamPolicy_async", - "title": "Policies troubleshootIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Checks whether a principal has a specific permission for a specific resource, and explains why the principal does or doesn't have that permission.", - "canonical": true, - "file": "policy_troubleshooter.troubleshoot_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TroubleshootIamPolicy", - "fullName": "google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter.TroubleshootIamPolicy", - "async": true, - "parameters": [ - { - "name": "access_tuple", - "type": ".google.cloud.policytroubleshooter.iam.v3.AccessTuple" - } - ], - "resultType": ".google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse", - "client": { - "shortName": "PolicyTroubleshooterClient", - "fullName": "google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooterClient" - }, - "method": { - "shortName": "TroubleshootIamPolicy", - "fullName": "google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter.TroubleshootIamPolicy", - "service": { - "shortName": "PolicyTroubleshooter", - "fullName": "google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/index.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/index.ts deleted file mode 100644 index a50d76fcacd..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/index.ts +++ /dev/null @@ -1,25 +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 v3 from './v3'; -const PolicyTroubleshooterClient = v3.PolicyTroubleshooterClient; -type PolicyTroubleshooterClient = v3.PolicyTroubleshooterClient; -export {v3, PolicyTroubleshooterClient}; -export default {v3, PolicyTroubleshooterClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/gapic_metadata.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/gapic_metadata.json deleted file mode 100644 index 2b25fe850a6..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/gapic_metadata.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.policytroubleshooter.iam.v3", - "libraryPackage": "@google-cloud/iam", - "services": { - "PolicyTroubleshooter": { - "clients": { - "grpc": { - "libraryClient": "PolicyTroubleshooterClient", - "rpcs": { - "TroubleshootIamPolicy": { - "methods": [ - "troubleshootIamPolicy" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "PolicyTroubleshooterClient", - "rpcs": { - "TroubleshootIamPolicy": { - "methods": [ - "troubleshootIamPolicy" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/index.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/index.ts deleted file mode 100644 index cb1bab0ce55..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/index.ts +++ /dev/null @@ -1,19 +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 {PolicyTroubleshooterClient} from './policy_troubleshooter_client'; diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_client.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_client.ts deleted file mode 100644 index 4df8f58dce0..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_client.ts +++ /dev/null @@ -1,376 +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} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v3/policy_troubleshooter_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './policy_troubleshooter_client_config.json'; -const version = require('../../../package.json').version; - -/** - * IAM Policy Troubleshooter service. - * - * This service helps you troubleshoot access issues for Google Cloud resources. - * @class - * @memberof v3 - */ -export class PolicyTroubleshooterClient { - 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}; - policyTroubleshooterStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of PolicyTroubleshooterClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 PolicyTroubleshooterClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof PolicyTroubleshooterClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter', 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.policyTroubleshooterStub) { - return this.policyTroubleshooterStub; - } - - // Put together the "service stub" for - // google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter. - this.policyTroubleshooterStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter, - 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 policyTroubleshooterStubMethods = - ['troubleshootIamPolicy']; - for (const methodName of policyTroubleshooterStubMethods) { - const callPromise = this.policyTroubleshooterStub.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.policyTroubleshooterStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'policytroubleshooter.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 'policytroubleshooter.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 -- - // ------------------- -/** - * Checks whether a principal has a specific permission for a specific - * resource, and explains why the principal does or doesn't have that - * permission. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.policytroubleshooter.iam.v3.AccessTuple} request.accessTuple - * The information to use for checking whether a principal has a permission - * for a resource. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse|TroubleshootIamPolicyResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/policy_troubleshooter.troubleshoot_iam_policy.js - * region_tag:policytroubleshooter_v3_generated_PolicyTroubleshooter_TroubleshootIamPolicy_async - */ - troubleshootIamPolicy( - request?: protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyResponse, - protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyRequest|undefined, {}|undefined - ]>; - troubleshootIamPolicy( - request: protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyResponse, - protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - troubleshootIamPolicy( - request: protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyRequest, - callback: Callback< - protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyResponse, - protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - troubleshootIamPolicy( - request?: protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyResponse, - protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyResponse, - protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyResponse, - protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.troubleshootIamPolicy(request, options, callback); - } - - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.policyTroubleshooterStub && !this._terminated) { - return this.policyTroubleshooterStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_client_config.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_client_config.json deleted file mode 100644 index d181f4c282f..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_client_config.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "interfaces": { - "google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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 - }, - "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "TroubleshootIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_proto_list.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_proto_list.json deleted file mode 100644 index 175cedf9925..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/src/v3/policy_troubleshooter_proto_list.json +++ /dev/null @@ -1,4 +0,0 @@ -[ - "../../protos/google/cloud/policytroubleshooter/iam/v3/troubleshooter.proto", - "../../protos/google/iam/v2/deny.proto" -] diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 74397918dca..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const iam = require('@google-cloud/iam'); - -function main() { - const policyTroubleshooterClient = new iam.PolicyTroubleshooterClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 14de8f1de24..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {PolicyTroubleshooterClient} from '@google-cloud/iam'; - -// check that the client class type name can be used -function doStuffWithPolicyTroubleshooterClient(client: PolicyTroubleshooterClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const policyTroubleshooterClient = new PolicyTroubleshooterClient(); - doStuffWithPolicyTroubleshooterClient(policyTroubleshooterClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/install.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/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-policytroubleshooter-iam/v3/test/gapic_policy_troubleshooter_v3.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/test/gapic_policy_troubleshooter_v3.ts deleted file mode 100644 index ef1b568e11b..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/test/gapic_policy_troubleshooter_v3.ts +++ /dev/null @@ -1,225 +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 policytroubleshooterModule from '../src'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -describe('v3.PolicyTroubleshooterClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = policytroubleshooterModule.v3.PolicyTroubleshooterClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = policytroubleshooterModule.v3.PolicyTroubleshooterClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = policytroubleshooterModule.v3.PolicyTroubleshooterClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new policytroubleshooterModule.v3.PolicyTroubleshooterClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new policytroubleshooterModule.v3.PolicyTroubleshooterClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new policytroubleshooterModule.v3.PolicyTroubleshooterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.policyTroubleshooterStub, undefined); - await client.initialize(); - assert(client.policyTroubleshooterStub); - }); - - it('has close method for the initialized client', done => { - const client = new policytroubleshooterModule.v3.PolicyTroubleshooterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.policyTroubleshooterStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new policytroubleshooterModule.v3.PolicyTroubleshooterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.policyTroubleshooterStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new policytroubleshooterModule.v3.PolicyTroubleshooterClient({ - 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 policytroubleshooterModule.v3.PolicyTroubleshooterClient({ - 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('troubleshootIamPolicy', () => { - it('invokes troubleshootIamPolicy without error', async () => { - const client = new policytroubleshooterModule.v3.PolicyTroubleshooterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse() - ); - client.innerApiCalls.troubleshootIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.troubleshootIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes troubleshootIamPolicy without error using callback', async () => { - const client = new policytroubleshooterModule.v3.PolicyTroubleshooterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyResponse() - ); - client.innerApiCalls.troubleshootIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.troubleshootIamPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.policytroubleshooter.iam.v3.ITroubleshootIamPolicyResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes troubleshootIamPolicy with error', async () => { - const client = new policytroubleshooterModule.v3.PolicyTroubleshooterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.troubleshootIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.troubleshootIamPolicy(request), expectedError); - }); - - it('invokes troubleshootIamPolicy with closed client', async () => { - const client = new policytroubleshooterModule.v3.PolicyTroubleshooterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.policytroubleshooter.iam.v3.TroubleshootIamPolicyRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.troubleshootIamPolicy(request), expectedError); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/tsconfig.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/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-policytroubleshooter-iam/v3/webpack.config.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/webpack.config.js deleted file mode 100644 index f423e0d5294..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3/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: 'Policies', - filename: './policies.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-policytroubleshooter-iam/v3beta/.eslintignore b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.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-policytroubleshooter-iam/v3beta/.eslintrc.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.gitignore b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.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-policytroubleshooter-iam/v3beta/.jsdoc.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.jsdoc.js deleted file mode 100644 index ead6a1300bd..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.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/policy-troubleshooter-iam', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.mocharc.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.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-policytroubleshooter-iam/v3beta/.prettierrc.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/.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-policytroubleshooter-iam/v3beta/README.md b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/README.md deleted file mode 100644 index 905fae6bcad..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/README.md +++ /dev/null @@ -1 +0,0 @@ -Iam: Nodejs Client diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/package.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/package.json deleted file mode 100644 index d4dacb27b30..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/package.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "name": "@google-cloud/policy-troubleshooter-iam", - "version": "0.1.0", - "description": "Iam client for Node.js", - "repository": "googleapis/nodejs-iam", - "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 iam", - "iam", - "policies", - "policy troubleshooter" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/cloud/policytroubleshooter/iam/v3beta/troubleshooter.proto b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/cloud/policytroubleshooter/iam/v3beta/troubleshooter.proto deleted file mode 100644 index 2d4c9429a14..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/cloud/policytroubleshooter/iam/v3beta/troubleshooter.proto +++ /dev/null @@ -1,754 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.policytroubleshooter.iam.v3beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/iam/v1/policy.proto"; -import "google/iam/v2/policy.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/expr.proto"; - -option cc_enable_arenas = true; -option go_package = "cloud.google.com/go/policytroubleshooter/iam/apiv3beta/iampb;iampb"; -option java_multiple_files = true; -option java_outer_classname = "TroubleshooterProto"; -option java_package = "com.google.cloud.policytroubleshooter.iam.v3beta"; - -// IAM Policy Troubleshooter service. -// -// This service helps you troubleshoot access issues for Google Cloud resources. -service PolicyTroubleshooter { - option (google.api.default_host) = "policytroubleshooter.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Checks whether a principal has a specific permission for a specific - // resource, and explains why the principal does or doesn't have that - // permission. - rpc TroubleshootIamPolicy(TroubleshootIamPolicyRequest) - returns (TroubleshootIamPolicyResponse) { - option (google.api.http) = { - post: "/v3beta/iam:troubleshoot" - body: "*" - }; - } -} - -// Whether IAM allow policies gives the principal the permission. -enum AllowAccessState { - // Not specified. - ALLOW_ACCESS_STATE_UNSPECIFIED = 0; - - // The allow policy gives the principal the permission. - ALLOW_ACCESS_STATE_GRANTED = 1; - - // The allow policy doesn't give the principal the permission. - ALLOW_ACCESS_STATE_NOT_GRANTED = 2; - - // The allow policy gives the principal the permission if a condition - // expression evaluate to `true`. However, the sender of the request didn't - // provide enough context for Policy Troubleshooter to evaluate the condition - // expression. - ALLOW_ACCESS_STATE_UNKNOWN_CONDITIONAL = 3; - - // The sender of the request doesn't have access to all of the allow policies - // that Policy Troubleshooter needs to evaluate the principal's access. - ALLOW_ACCESS_STATE_UNKNOWN_INFO = 4; -} - -// Whether IAM deny policies deny the principal the permission. -enum DenyAccessState { - // Not specified. - DENY_ACCESS_STATE_UNSPECIFIED = 0; - - // The deny policy denies the principal the permission. - DENY_ACCESS_STATE_DENIED = 1; - - // The deny policy doesn't deny the principal the permission. - DENY_ACCESS_STATE_NOT_DENIED = 2; - - // The deny policy denies the principal the permission if a condition - // expression evaluates to `true`. However, the sender of the request didn't - // provide enough context for Policy Troubleshooter to evaluate the condition - // expression. - DENY_ACCESS_STATE_UNKNOWN_CONDITIONAL = 3; - - // The sender of the request does not have access to all of the deny policies - // that Policy Troubleshooter needs to evaluate the principal's access. - DENY_ACCESS_STATE_UNKNOWN_INFO = 4; -} - -// Whether a role includes a specific permission. -enum RolePermissionInclusionState { - // Not specified. - ROLE_PERMISSION_INCLUSION_STATE_UNSPECIFIED = 0; - - // The permission is included in the role. - ROLE_PERMISSION_INCLUDED = 1; - - // The permission is not included in the role. - ROLE_PERMISSION_NOT_INCLUDED = 2; - - // The sender of the request is not allowed to access the role definition. - ROLE_PERMISSION_UNKNOWN_INFO = 3; -} - -// Whether the permission in the request matches the permission in the policy. -enum PermissionPatternMatchingState { - // Not specified. - PERMISSION_PATTERN_MATCHING_STATE_UNSPECIFIED = 0; - - // The permission in the request matches the permission in the policy. - PERMISSION_PATTERN_MATCHED = 1; - - // The permission in the request matches the permission in the policy. - PERMISSION_PATTERN_NOT_MATCHED = 2; -} - -// Whether the principal in the request matches the principal in the policy. -enum MembershipMatchingState { - // Not specified. - MEMBERSHIP_MATCHING_STATE_UNSPECIFIED = 0; - - // The principal in the request matches the principal in the policy. The - // principal can be included directly or indirectly: - // - // * A principal is included directly if that principal is listed in the - // role binding. - // * A principal is included indirectly if that principal is in a Google - // group, Google Workspace account, or Cloud Identity domain that is listed - // in the policy. - MEMBERSHIP_MATCHED = 1; - - // The principal in the request doesn't match the principal in the policy. - MEMBERSHIP_NOT_MATCHED = 2; - - // The principal in the policy is a group or domain, and the sender of the - // request doesn't have permission to view whether the principal in the - // request is a member of the group or domain. - MEMBERSHIP_UNKNOWN_INFO = 3; - - // The principal is an unsupported type. - MEMBERSHIP_UNKNOWN_UNSUPPORTED = 4; -} - -// The extent to which a single data point contributes to an overall -// determination. -enum HeuristicRelevance { - // Not specified. - HEURISTIC_RELEVANCE_UNSPECIFIED = 0; - - // The data point has a limited effect on the result. Changing the data point - // is unlikely to affect the overall determination. - HEURISTIC_RELEVANCE_NORMAL = 1; - - // The data point has a strong effect on the result. Changing the data point - // is likely to affect the overall determination. - HEURISTIC_RELEVANCE_HIGH = 2; -} - -// Request for -// [TroubleshootIamPolicy][google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooter.TroubleshootIamPolicy]. -message TroubleshootIamPolicyRequest { - // The information to use for checking whether a principal has a permission - // for a resource. - AccessTuple access_tuple = 1; -} - -// Response for -// [TroubleshootIamPolicy][google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooter.TroubleshootIamPolicy]. -message TroubleshootIamPolicyResponse { - // Whether the principal has the permission on the resource. - enum OverallAccessState { - // Not specified. - OVERALL_ACCESS_STATE_UNSPECIFIED = 0; - - // The principal has the permission. - CAN_ACCESS = 1; - - // The principal doesn't have the permission. - CANNOT_ACCESS = 2; - - // The principal might have the permission, but the sender can't access all - // of the information needed to fully evaluate the principal's access. - UNKNOWN_INFO = 3; - - // The principal might have the permission, but Policy Troubleshooter can't - // fully evaluate the principal's access because the sender didn't provide - // the required context to evaluate the condition. - UNKNOWN_CONDITIONAL = 4; - } - - // Indicates whether the principal has the specified permission for the - // specified resource, based on evaluating all types of the applicable IAM - // policies. - OverallAccessState overall_access_state = 1; - - // The access tuple from the request, including any provided context used to - // evaluate the condition. - AccessTuple access_tuple = 2; - - // An explanation of how the applicable IAM allow policies affect the final - // access state. - AllowPolicyExplanation allow_policy_explanation = 3; - - // An explanation of how the applicable IAM deny policies affect the final - // access state. - DenyPolicyExplanation deny_policy_explanation = 4; -} - -// Information about the principal, resource, and permission to check. -message AccessTuple { - // Required. The email address of the principal whose access you want to - // check. For example, `alice@example.com` or - // `my-service-account@my-project.iam.gserviceaccount.com`. - // - // The principal must be a Google Account or a service account. Other types of - // principals are not supported. - string principal = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The full resource name that identifies the resource. For example, - // `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`. - // - // For examples of full resource names for Google Cloud services, see - // https://cloud.google.com/iam/help/troubleshooter/full-resource-names. - string full_resource_name = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The IAM permission to check for, either in the `v1` permission - // format or the `v2` permission format. - // - // For a complete list of IAM permissions in the `v1` format, see - // https://cloud.google.com/iam/help/permissions/reference. - // - // For a list of IAM permissions in the `v2` format, see - // https://cloud.google.com/iam/help/deny/supported-permissions. - // - // For a complete list of predefined IAM roles and the permissions in each - // role, see https://cloud.google.com/iam/help/roles/reference. - string permission = 3 [(google.api.field_behavior) = REQUIRED]; - - // Output only. The permission that Policy Troubleshooter checked for, in - // the `v2` format. - string permission_fqdn = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Additional context for the request, such as the request time or - // IP address. This context allows Policy Troubleshooter to troubleshoot - // conditional role bindings and deny rules. - ConditionContext condition_context = 5 - [(google.api.field_behavior) = OPTIONAL]; -} - -// Additional context for troubleshooting conditional role bindings and deny -// rules. -message ConditionContext { - // Core attributes for a resource. A resource is an - // addressable (named) entity provided by the destination service. For - // example, a Compute Engine instance. - message Resource { - // The name of the service that this resource belongs to, such as - // `compute.googleapis.com`. The service name might not match the DNS - // hostname that actually serves the request. - // - // For a full list of resource service values, see - // https://cloud.google.com/iam/help/conditions/resource-services - string service = 1; - - // The stable identifier (name) of a resource on the `service`. A resource - // can be logically identified as `//{resource.service}/{resource.name}`. - // Unlike the resource URI, the resource name doesn't contain any protocol - // and version information. - // - // For a list of full resource name formats, see - // https://cloud.google.com/iam/help/troubleshooter/full-resource-names - string name = 2; - - // The type of the resource, in the format `{service}/{kind}`. - // - // For a full list of resource type values, see - // https://cloud.google.com/iam/help/conditions/resource-types - string type = 3; - } - - // This message defines attributes for a node that handles a network request. - // The node can be either a service or an application that sends, forwards, - // or receives the request. Service peers should fill in - // `principal` and `labels` as appropriate. - message Peer { - // The IPv4 or IPv6 address of the peer. - string ip = 1; - - // The network port of the peer. - int64 port = 2; - } - - // This message defines attributes for an HTTP request. If the actual - // request is not an HTTP request, the runtime system should try to map - // the actual request to an equivalent HTTP request. - message Request { - // Optional. The timestamp when the destination service receives the first - // byte of the request. - google.protobuf.Timestamp receive_time = 1 - [(google.api.field_behavior) = OPTIONAL]; - } - - // A tag that applies to a resource during policy evaluation. Tags can be - // either directly bound to a resource or inherited from its ancestor. - // `EffectiveTag` contains the `name` and `namespaced_name` of the tag value - // and tag key, with additional fields of `inherited` to indicate the - // inheritance status of the effective tag. - message EffectiveTag { - // Output only. Resource name for TagValue in the format `tagValues/456`. - string tag_value = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The namespaced name of the TagValue. Can be in the form - // `{organization_id}/{tag_key_short_name}/{tag_value_short_name}` or - // `{project_id}/{tag_key_short_name}/{tag_value_short_name}` or - // `{project_number}/{tag_key_short_name}/{tag_value_short_name}`. - string namespaced_tag_value = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The name of the TagKey, in the format `tagKeys/{id}`, such - // as `tagKeys/123`. - string tag_key = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The namespaced name of the TagKey. Can be in the form - // `{organization_id}/{tag_key_short_name}` or - // `{project_id}/{tag_key_short_name}` or - // `{project_number}/{tag_key_short_name}`. - string namespaced_tag_key = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The parent name of the tag key. - // Must be in the format `organizations/{organization_id}` or - // `projects/{project_number}` - string tag_key_parent_name = 6; - - // Output only. Indicates the inheritance status of a tag value - // attached to the given resource. If the tag value is inherited from one of - // the resource's ancestors, inherited will be true. If false, then the tag - // value is directly attached to the resource, inherited will be false. - bool inherited = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - } - - // Represents a target resource that is involved with a network activity. - // If multiple resources are involved with an activity, this must be the - // primary one. - Resource resource = 1; - - // The destination of a network activity, such as accepting a TCP connection. - // In a multi-hop network activity, the destination represents the receiver of - // the last hop. - Peer destination = 2; - - // Represents a network request, such as an HTTP request. - Request request = 3; - - // Output only. The effective tags on the resource. The effective tags are - // fetched during troubleshooting. - repeated EffectiveTag effective_tags = 4 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Details about how the relevant IAM allow policies affect the final access -// state. -message AllowPolicyExplanation { - // Indicates whether the principal has the specified permission for the - // specified resource, based on evaluating all applicable IAM allow policies. - AllowAccessState allow_access_state = 1; - - // List of IAM allow policies that were evaluated to check the principal's - // permissions, with annotations to indicate how each policy contributed to - // the final result. - // - // The list of policies includes the policy for the resource itself, as well - // as allow policies that are inherited from higher levels of the resource - // hierarchy, including the organization, the folder, and the project. - // - // To learn more about the resource hierarchy, see - // https://cloud.google.com/iam/help/resource-hierarchy. - repeated ExplainedAllowPolicy explained_policies = 2; - - // The relevance of the allow policy type to the overall access state. - HeuristicRelevance relevance = 3; -} - -// Details about how a specific IAM allow policy contributed to the final access -// state. -message ExplainedAllowPolicy { - // Required. Indicates whether _this policy_ provides the specified permission - // to the specified principal for the specified resource. - // - // This field does _not_ indicate whether the principal actually has the - // permission for the resource. There might be another policy that overrides - // this policy. To determine whether the principal actually has the - // permission, use the `overall_access_state` field in the - // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse]. - AllowAccessState allow_access_state = 1 - [(google.api.field_behavior) = REQUIRED]; - - // The full resource name that identifies the resource. For example, - // `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`. - // - // If the sender of the request does not have access to the policy, this field - // is omitted. - // - // For examples of full resource names for Google Cloud services, see - // https://cloud.google.com/iam/help/troubleshooter/full-resource-names. - string full_resource_name = 2; - - // Details about how each role binding in the policy affects the principal's - // ability, or inability, to use the permission for the resource. The order of - // the role bindings matches the role binding order in the policy. - // - // If the sender of the request does not have access to the policy, this field - // is omitted. - repeated AllowBindingExplanation binding_explanations = 3; - - // The relevance of this policy to the overall access state in the - // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse]. - // - // If the sender of the request does not have access to the policy, this field - // is omitted. - HeuristicRelevance relevance = 4; - - // The IAM allow policy attached to the resource. - // - // If the sender of the request does not have access to the policy, this field - // is empty. - google.iam.v1.Policy policy = 5; -} - -// Details about how a role binding in an allow policy affects a principal's -// ability to use a permission. -message AllowBindingExplanation { - // Details about whether the role binding includes the principal. - message AnnotatedAllowMembership { - // Indicates whether the role binding includes the principal. - MembershipMatchingState membership = 1; - - // The relevance of the principal's status to the overall determination for - // the role binding. - HeuristicRelevance relevance = 2; - } - - // Required. Indicates whether _this role binding_ gives the specified - // permission to the specified principal on the specified resource. - // - // This field does _not_ indicate whether the principal actually has the - // permission on the resource. There might be another role binding that - // overrides this role binding. To determine whether the principal actually - // has the permission, use the `overall_access_state` field in the - // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse]. - AllowAccessState allow_access_state = 1 - [(google.api.field_behavior) = REQUIRED]; - - // The role that this role binding grants. For example, - // `roles/compute.admin`. - // - // For a complete list of predefined IAM roles, as well as the permissions in - // each role, see https://cloud.google.com/iam/help/roles/reference. - string role = 2; - - // Indicates whether the role granted by this role binding contains the - // specified permission. - RolePermissionInclusionState role_permission = 3; - - // The relevance of the permission's existence, or nonexistence, in the role - // to the overall determination for the entire policy. - HeuristicRelevance role_permission_relevance = 4; - - // The combined result of all memberships. Indicates if the principal is - // included in any role binding, either directly or indirectly. - AnnotatedAllowMembership combined_membership = 5; - - // Indicates whether each role binding includes the principal specified in the - // request, either directly or indirectly. Each key identifies a principal in - // the role binding, and each value indicates whether the principal in the - // role binding includes the principal in the request. - // - // For example, suppose that a role binding includes the following principals: - // - // * `user:alice@example.com` - // * `group:product-eng@example.com` - // - // You want to troubleshoot access for `user:bob@example.com`. This user is a - // member of the group `group:product-eng@example.com`. - // - // For the first principal in the role binding, the key is - // `user:alice@example.com`, and the `membership` field in the value is set to - // `NOT_INCLUDED`. - // - // For the second principal in the role binding, the key is - // `group:product-eng@example.com`, and the `membership` field in the value is - // set to `INCLUDED`. - map memberships = 6; - - // The relevance of this role binding to the overall determination for the - // entire policy. - HeuristicRelevance relevance = 7; - - // A condition expression that specifies when the role binding grants access. - // - // To learn about IAM Conditions, see - // https://cloud.google.com/iam/help/conditions/overview. - google.type.Expr condition = 8; - - // Condition evaluation state for this role binding. - ConditionExplanation condition_explanation = 9; -} - -// Details about how the relevant IAM deny policies affect the final access -// state. -message DenyPolicyExplanation { - // Indicates whether the principal is denied the specified permission for - // the specified resource, based on evaluating all applicable IAM deny - // policies. - DenyAccessState deny_access_state = 1; - - // List of resources with IAM deny policies that were evaluated to check the - // principal's denied permissions, with annotations to indicate how each - // policy contributed to the final result. - // - // The list of resources includes the policy for the resource itself, as well - // as policies that are inherited from higher levels of the resource - // hierarchy, including the organization, the folder, and the project. The - // order of the resources starts from the resource and climbs up the resource - // hierarchy. - // - // To learn more about the resource hierarchy, see - // https://cloud.google.com/iam/help/resource-hierarchy. - repeated ExplainedDenyResource explained_resources = 2; - - // The relevance of the deny policy result to the overall access state. - HeuristicRelevance relevance = 3; - - // Indicates whether the permission to troubleshoot is supported in deny - // policies. - bool permission_deniable = 4; -} - -// Details about how a specific resource contributed to the deny policy -// evaluation. -message ExplainedDenyResource { - // Required. Indicates whether any policies attached to _this resource_ deny - // the specific permission to the specified principal for the specified - // resource. - // - // This field does _not_ indicate whether the principal actually has the - // permission for the resource. There might be another policy that overrides - // this policy. To determine whether the principal actually has the - // permission, use the `overall_access_state` field in the - // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse]. - DenyAccessState deny_access_state = 1 - [(google.api.field_behavior) = REQUIRED]; - - // The full resource name that identifies the resource. For example, - // `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`. - // - // If the sender of the request does not have access to the policy, this field - // is omitted. - // - // For examples of full resource names for Google Cloud services, see - // https://cloud.google.com/iam/help/troubleshooter/full-resource-names. - string full_resource_name = 2; - - // List of IAM deny policies that were evaluated to check the principal's - // denied permissions, with annotations to indicate how each policy - // contributed to the final result. - repeated ExplainedDenyPolicy explained_policies = 3; - - // The relevance of this policy to the overall access state in the - // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse]. - // - // If the sender of the request does not have access to the policy, this field - // is omitted. - HeuristicRelevance relevance = 4; -} - -// Details about how a specific IAM deny policy [Policy][google.iam.v2.Policy] -// contributed to the access check. -message ExplainedDenyPolicy { - // Required. Indicates whether _this policy_ denies the specified permission - // to the specified principal for the specified resource. - // - // This field does _not_ indicate whether the principal actually has the - // permission for the resource. There might be another policy that overrides - // this policy. To determine whether the principal actually has the - // permission, use the `overall_access_state` field in the - // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse]. - DenyAccessState deny_access_state = 1 - [(google.api.field_behavior) = REQUIRED]; - - // The IAM deny policy attached to the resource. - // - // If the sender of the request does not have access to the policy, this field - // is omitted. - google.iam.v2.Policy policy = 2; - - // Details about how each rule in the policy affects the principal's inability - // to use the permission for the resource. The order of the deny rule matches - // the order of the rules in the deny policy. - // - // If the sender of the request does not have access to the policy, this field - // is omitted. - repeated DenyRuleExplanation rule_explanations = 3; - - // The relevance of this policy to the overall access state in the - // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse]. - // - // If the sender of the request does not have access to the policy, this field - // is omitted. - HeuristicRelevance relevance = 4; -} - -// Details about how a deny rule in a deny policy affects a principal's ability -// to use a permission. -message DenyRuleExplanation { - // Details about whether the permission in the request is denied by the - // deny rule. - message AnnotatedPermissionMatching { - // Indicates whether the permission in the request is denied by the deny - // rule. - PermissionPatternMatchingState permission_matching_state = 1; - - // The relevance of the permission status to the overall determination for - // the rule. - HeuristicRelevance relevance = 2; - } - - // Details about whether the principal in the request is listed as a denied - // principal in the deny rule, either directly or through membership in a - // principal set. - message AnnotatedDenyPrincipalMatching { - // Indicates whether the principal is listed as a denied principal in the - // deny rule, either directly or through membership in a principal set. - MembershipMatchingState membership = 1; - - // The relevance of the principal's status to the overall determination for - // the role binding. - HeuristicRelevance relevance = 2; - } - - // Required. Indicates whether _this rule_ denies the specified permission to - // the specified principal for the specified resource. - // - // This field does _not_ indicate whether the principal is actually denied on - // the permission for the resource. There might be another rule that overrides - // this rule. To determine whether the principal actually has the permission, - // use the `overall_access_state` field in the - // [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse]. - DenyAccessState deny_access_state = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates whether the permission in the request is listed as a denied - // permission in the deny rule. - AnnotatedPermissionMatching combined_denied_permission = 2; - - // Lists all denied permissions in the deny rule and indicates whether each - // permission matches the permission in the request. - // - // Each key identifies a denied permission in the rule, and each value - // indicates whether the denied permission matches the permission in the - // request. - map denied_permissions = 3; - - // Indicates whether the permission in the request is listed as an exception - // permission in the deny rule. - AnnotatedPermissionMatching combined_exception_permission = 4; - - // Lists all exception permissions in the deny rule and indicates whether each - // permission matches the permission in the request. - // - // Each key identifies a exception permission in the rule, and each value - // indicates whether the exception permission matches the permission in the - // request. - map exception_permissions = 5; - - // Indicates whether the principal is listed as a denied principal in the - // deny rule, either directly or through membership in a principal set. - AnnotatedDenyPrincipalMatching combined_denied_principal = 6; - - // Lists all denied principals in the deny rule and indicates whether each - // principal matches the principal in the request, either directly or through - // membership in a principal set. - // - // Each key identifies a denied principal in the rule, and each value - // indicates whether the denied principal matches the principal in the - // request. - map denied_principals = 7; - - // Indicates whether the principal is listed as an exception principal in the - // deny rule, either directly or through membership in a principal set. - AnnotatedDenyPrincipalMatching combined_exception_principal = 8; - - // Lists all exception principals in the deny rule and indicates whether each - // principal matches the principal in the request, either directly or through - // membership in a principal set. - // - // Each key identifies a exception principal in the rule, and each value - // indicates whether the exception principal matches the principal in the - // request. - map exception_principals = 9; - - // The relevance of this role binding to the overall determination for the - // entire policy. - HeuristicRelevance relevance = 10; - - // A condition expression that specifies when the deny rule denies the - // principal access. - // - // To learn about IAM Conditions, see - // https://cloud.google.com/iam/help/conditions/overview. - google.type.Expr condition = 11; - - // Condition evaluation state for this role binding. - ConditionExplanation condition_explanation = 12; -} - -// Explanation for how a condition affects a principal's access -message ConditionExplanation { - // Evaluated state of a condition expression. - message EvaluationState { - // Start position of an expression in the condition, by character. - int32 start = 1; - - // End position of an expression in the condition, by character, - // end included, for example: the end position of the first part of - // `a==b || c==d` would be 4. - int32 end = 2; - - // Value of this expression. - google.protobuf.Value value = 3; - - // Any errors that prevented complete evaluation of the condition - // expression. - repeated google.rpc.Status errors = 4; - } - - // Value of the condition. - google.protobuf.Value value = 1; - - // Any errors that prevented complete evaluation of the condition expression. - repeated google.rpc.Status errors = 3; - - // The value of each statement of the condition expression. The value can be - // `true`, `false`, or `null`. The value is `null` if the statement can't be - // evaluated. - repeated EvaluationState evaluation_states = 2; -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v1/policy.proto b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v1/policy.proto deleted file mode 100644 index 2386563b36e..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v1/policy.proto +++ /dev/null @@ -1,410 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.iam.v1; - -import "google/type/expr.proto"; - -option cc_enable_arenas = true; -option csharp_namespace = "Google.Cloud.Iam.V1"; -option go_package = "cloud.google.com/go/iam/apiv1/iampb;iampb"; -option java_multiple_files = true; -option java_outer_classname = "PolicyProto"; -option java_package = "com.google.iam.v1"; -option php_namespace = "Google\\Cloud\\Iam\\V1"; - -// An Identity and Access Management (IAM) policy, which specifies access -// controls for Google Cloud resources. -// -// -// A `Policy` is a collection of `bindings`. A `binding` binds one or more -// `members`, or principals, to a single `role`. Principals can be user -// accounts, service accounts, Google groups, and domains (such as G Suite). A -// `role` is a named list of permissions; each `role` can be an IAM predefined -// role or a user-created custom role. -// -// For some types of Google Cloud resources, a `binding` can also specify a -// `condition`, which is a logical expression that allows access to a resource -// only if the expression evaluates to `true`. A condition can add constraints -// based on attributes of the request, the resource, or both. To learn which -// resources support conditions in their IAM policies, see the -// [IAM -// documentation](https://cloud.google.com/iam/help/conditions/resource-policies). -// -// **JSON example:** -// -// ``` -// { -// "bindings": [ -// { -// "role": "roles/resourcemanager.organizationAdmin", -// "members": [ -// "user:mike@example.com", -// "group:admins@example.com", -// "domain:google.com", -// "serviceAccount:my-project-id@appspot.gserviceaccount.com" -// ] -// }, -// { -// "role": "roles/resourcemanager.organizationViewer", -// "members": [ -// "user:eve@example.com" -// ], -// "condition": { -// "title": "expirable access", -// "description": "Does not grant access after Sep 2020", -// "expression": "request.time < -// timestamp('2020-10-01T00:00:00.000Z')", -// } -// } -// ], -// "etag": "BwWWja0YfJA=", -// "version": 3 -// } -// ``` -// -// **YAML example:** -// -// ``` -// bindings: -// - members: -// - user:mike@example.com -// - group:admins@example.com -// - domain:google.com -// - serviceAccount:my-project-id@appspot.gserviceaccount.com -// role: roles/resourcemanager.organizationAdmin -// - members: -// - user:eve@example.com -// role: roles/resourcemanager.organizationViewer -// condition: -// title: expirable access -// description: Does not grant access after Sep 2020 -// expression: request.time < timestamp('2020-10-01T00:00:00.000Z') -// etag: BwWWja0YfJA= -// version: 3 -// ``` -// -// For a description of IAM and its features, see the -// [IAM documentation](https://cloud.google.com/iam/docs/). -message Policy { - // Specifies the format of the policy. - // - // Valid values are `0`, `1`, and `3`. Requests that specify an invalid value - // are rejected. - // - // Any operation that affects conditional role bindings must specify version - // `3`. This requirement applies to the following operations: - // - // * Getting a policy that includes a conditional role binding - // * Adding a conditional role binding to a policy - // * Changing a conditional role binding in a policy - // * Removing any role binding, with or without a condition, from a policy - // that includes conditions - // - // **Important:** If you use IAM Conditions, you must include the `etag` field - // whenever you call `setIamPolicy`. If you omit this field, then IAM allows - // you to overwrite a version `3` policy with a version `1` policy, and all of - // the conditions in the version `3` policy are lost. - // - // If a policy does not include any conditions, operations on that policy may - // specify any valid version or leave the field unset. - // - // To learn which resources support conditions in their IAM policies, see the - // [IAM - // documentation](https://cloud.google.com/iam/help/conditions/resource-policies). - int32 version = 1; - - // Associates a list of `members`, or principals, with a `role`. Optionally, - // may specify a `condition` that determines how and when the `bindings` are - // applied. Each of the `bindings` must contain at least one principal. - // - // The `bindings` in a `Policy` can refer to up to 1,500 principals; up to 250 - // of these principals can be Google groups. Each occurrence of a principal - // counts towards these limits. For example, if the `bindings` grant 50 - // different roles to `user:alice@example.com`, and not to any other - // principal, then you can add another 1,450 principals to the `bindings` in - // the `Policy`. - repeated Binding bindings = 4; - - // Specifies cloud audit logging configuration for this policy. - repeated AuditConfig audit_configs = 6; - - // `etag` is used for optimistic concurrency control as a way to help - // prevent simultaneous updates of a policy from overwriting each other. - // It is strongly suggested that systems make use of the `etag` in the - // read-modify-write cycle to perform policy updates in order to avoid race - // conditions: An `etag` is returned in the response to `getIamPolicy`, and - // systems are expected to put that etag in the request to `setIamPolicy` to - // ensure that their change will be applied to the same version of the policy. - // - // **Important:** If you use IAM Conditions, you must include the `etag` field - // whenever you call `setIamPolicy`. If you omit this field, then IAM allows - // you to overwrite a version `3` policy with a version `1` policy, and all of - // the conditions in the version `3` policy are lost. - bytes etag = 3; -} - -// Associates `members`, or principals, with a `role`. -message Binding { - // Role that is assigned to the list of `members`, or principals. - // For example, `roles/viewer`, `roles/editor`, or `roles/owner`. - string role = 1; - - // Specifies the principals requesting access for a Google Cloud resource. - // `members` can have the following values: - // - // * `allUsers`: A special identifier that represents anyone who is - // on the internet; with or without a Google account. - // - // * `allAuthenticatedUsers`: A special identifier that represents anyone - // who is authenticated with a Google account or a service account. - // - // * `user:{emailid}`: An email address that represents a specific Google - // account. For example, `alice@example.com` . - // - // - // * `serviceAccount:{emailid}`: An email address that represents a service - // account. For example, `my-other-app@appspot.gserviceaccount.com`. - // - // * `group:{emailid}`: An email address that represents a Google group. - // For example, `admins@example.com`. - // - // * `deleted:user:{emailid}?uid={uniqueid}`: An email address (plus unique - // identifier) representing a user that has been recently deleted. For - // example, `alice@example.com?uid=123456789012345678901`. If the user is - // recovered, this value reverts to `user:{emailid}` and the recovered user - // retains the role in the binding. - // - // * `deleted:serviceAccount:{emailid}?uid={uniqueid}`: An email address (plus - // unique identifier) representing a service account that has been recently - // deleted. For example, - // `my-other-app@appspot.gserviceaccount.com?uid=123456789012345678901`. - // If the service account is undeleted, this value reverts to - // `serviceAccount:{emailid}` and the undeleted service account retains the - // role in the binding. - // - // * `deleted:group:{emailid}?uid={uniqueid}`: An email address (plus unique - // identifier) representing a Google group that has been recently - // deleted. For example, `admins@example.com?uid=123456789012345678901`. If - // the group is recovered, this value reverts to `group:{emailid}` and the - // recovered group retains the role in the binding. - // - // - // * `domain:{domain}`: The G Suite domain (primary) that represents all the - // users of that domain. For example, `google.com` or `example.com`. - // - // - repeated string members = 2; - - // The condition that is associated with this binding. - // - // If the condition evaluates to `true`, then this binding applies to the - // current request. - // - // If the condition evaluates to `false`, then this binding does not apply to - // the current request. However, a different role binding might grant the same - // role to one or more of the principals in this binding. - // - // To learn which resources support conditions in their IAM policies, see the - // [IAM - // documentation](https://cloud.google.com/iam/help/conditions/resource-policies). - google.type.Expr condition = 3; -} - -// Specifies the audit configuration for a service. -// The configuration determines which permission types are logged, and what -// identities, if any, are exempted from logging. -// An AuditConfig must have one or more AuditLogConfigs. -// -// If there are AuditConfigs for both `allServices` and a specific service, -// the union of the two AuditConfigs is used for that service: the log_types -// specified in each AuditConfig are enabled, and the exempted_members in each -// AuditLogConfig are exempted. -// -// Example Policy with multiple AuditConfigs: -// -// { -// "audit_configs": [ -// { -// "service": "allServices", -// "audit_log_configs": [ -// { -// "log_type": "DATA_READ", -// "exempted_members": [ -// "user:jose@example.com" -// ] -// }, -// { -// "log_type": "DATA_WRITE" -// }, -// { -// "log_type": "ADMIN_READ" -// } -// ] -// }, -// { -// "service": "sampleservice.googleapis.com", -// "audit_log_configs": [ -// { -// "log_type": "DATA_READ" -// }, -// { -// "log_type": "DATA_WRITE", -// "exempted_members": [ -// "user:aliya@example.com" -// ] -// } -// ] -// } -// ] -// } -// -// For sampleservice, this policy enables DATA_READ, DATA_WRITE and ADMIN_READ -// logging. It also exempts `jose@example.com` from DATA_READ logging, and -// `aliya@example.com` from DATA_WRITE logging. -message AuditConfig { - // Specifies a service that will be enabled for audit logging. - // For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. - // `allServices` is a special value that covers all services. - string service = 1; - - // The configuration for logging of each type of permission. - repeated AuditLogConfig audit_log_configs = 3; -} - -// Provides the configuration for logging a type of permissions. -// Example: -// -// { -// "audit_log_configs": [ -// { -// "log_type": "DATA_READ", -// "exempted_members": [ -// "user:jose@example.com" -// ] -// }, -// { -// "log_type": "DATA_WRITE" -// } -// ] -// } -// -// This enables 'DATA_READ' and 'DATA_WRITE' logging, while exempting -// jose@example.com from DATA_READ logging. -message AuditLogConfig { - // The list of valid permission types for which logging can be configured. - // Admin writes are always logged, and are not configurable. - enum LogType { - // Default case. Should never be this. - LOG_TYPE_UNSPECIFIED = 0; - - // Admin reads. Example: CloudIAM getIamPolicy - ADMIN_READ = 1; - - // Data writes. Example: CloudSQL Users create - DATA_WRITE = 2; - - // Data reads. Example: CloudSQL Users list - DATA_READ = 3; - } - - // The log type that this config enables. - LogType log_type = 1; - - // Specifies the identities that do not cause logging for this type of - // permission. - // Follows the same format of - // [Binding.members][google.iam.v1.Binding.members]. - repeated string exempted_members = 2; -} - -// The difference delta between two policies. -message PolicyDelta { - // The delta for Bindings between two policies. - repeated BindingDelta binding_deltas = 1; - - // The delta for AuditConfigs between two policies. - repeated AuditConfigDelta audit_config_deltas = 2; -} - -// One delta entry for Binding. Each individual change (only one member in each -// entry) to a binding will be a separate entry. -message BindingDelta { - // The type of action performed on a Binding in a policy. - enum Action { - // Unspecified. - ACTION_UNSPECIFIED = 0; - - // Addition of a Binding. - ADD = 1; - - // Removal of a Binding. - REMOVE = 2; - } - - // The action that was performed on a Binding. - // Required - Action action = 1; - - // Role that is assigned to `members`. - // For example, `roles/viewer`, `roles/editor`, or `roles/owner`. - // Required - string role = 2; - - // A single identity requesting access for a Google Cloud resource. - // Follows the same format of Binding.members. - // Required - string member = 3; - - // The condition that is associated with this binding. - google.type.Expr condition = 4; -} - -// One delta entry for AuditConfig. Each individual change (only one -// exempted_member in each entry) to a AuditConfig will be a separate entry. -message AuditConfigDelta { - // The type of action performed on an audit configuration in a policy. - enum Action { - // Unspecified. - ACTION_UNSPECIFIED = 0; - - // Addition of an audit configuration. - ADD = 1; - - // Removal of an audit configuration. - REMOVE = 2; - } - - // The action that was performed on an audit configuration in a policy. - // Required - Action action = 1; - - // Specifies a service that was configured for Cloud Audit Logging. - // For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. - // `allServices` is a special value that covers all services. - // Required - string service = 2; - - // A single identity that is exempted from "data access" audit - // logging for the `service` specified above. - // Follows the same format of Binding.members. - string exempted_member = 3; - - // Specifies the log_type that was be enabled. ADMIN_ACTIVITY is always - // enabled, and cannot be configured. - // Required - string log_type = 4; -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v2/deny.proto b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v2/deny.proto deleted file mode 100644 index a3c8ff14e9a..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v2/deny.proto +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.iam.v2; - -import "google/type/expr.proto"; - -option csharp_namespace = "Google.Cloud.Iam.V2"; -option go_package = "cloud.google.com/go/iam/apiv2/iampb;iampb"; -option java_multiple_files = true; -option java_outer_classname = "DenyRuleProto"; -option java_package = "com.google.iam.v2"; -option php_namespace = "Google\\Cloud\\Iam\\V2"; - -// A deny rule in an IAM deny policy. -message DenyRule { - // The identities that are prevented from using one or more permissions on - // Google Cloud resources. This field can contain the following values: - // - // * `principalSet://goog/public:all`: A special identifier that represents - // any principal that is on the internet, even if they do not have a Google - // Account or are not logged in. - // - // * `principal://goog/subject/{email_id}`: A specific Google Account. - // Includes Gmail, Cloud Identity, and Google Workspace user accounts. For - // example, `principal://goog/subject/alice@example.com`. - // - // * `deleted:principal://goog/subject/{email_id}?uid={uid}`: A specific - // Google Account that was deleted recently. For example, - // `deleted:principal://goog/subject/alice@example.com?uid=1234567890`. If - // the Google Account is recovered, this identifier reverts to the standard - // identifier for a Google Account. - // - // * `principalSet://goog/group/{group_id}`: A Google group. For example, - // `principalSet://goog/group/admins@example.com`. - // - // * `deleted:principalSet://goog/group/{group_id}?uid={uid}`: A Google group - // that was deleted recently. For example, - // `deleted:principalSet://goog/group/admins@example.com?uid=1234567890`. If - // the Google group is restored, this identifier reverts to the standard - // identifier for a Google group. - // - // * `principal://iam.googleapis.com/projects/-/serviceAccounts/{service_account_id}`: - // A Google Cloud service account. For example, - // `principal://iam.googleapis.com/projects/-/serviceAccounts/my-service-account@iam.gserviceaccount.com`. - // - // * `deleted:principal://iam.googleapis.com/projects/-/serviceAccounts/{service_account_id}?uid={uid}`: - // A Google Cloud service account that was deleted recently. For example, - // `deleted:principal://iam.googleapis.com/projects/-/serviceAccounts/my-service-account@iam.gserviceaccount.com?uid=1234567890`. - // If the service account is undeleted, this identifier reverts to the - // standard identifier for a service account. - // - // * `principalSet://goog/cloudIdentityCustomerId/{customer_id}`: All of the - // principals associated with the specified Google Workspace or Cloud - // Identity customer ID. For example, - // `principalSet://goog/cloudIdentityCustomerId/C01Abc35`. - repeated string denied_principals = 1; - - // The identities that are excluded from the deny rule, even if they are - // listed in the `denied_principals`. For example, you could add a Google - // group to the `denied_principals`, then exclude specific users who belong to - // that group. - // - // This field can contain the same values as the `denied_principals` field, - // excluding `principalSet://goog/public:all`, which represents all users on - // the internet. - repeated string exception_principals = 2; - - // The permissions that are explicitly denied by this rule. Each permission - // uses the format `{service_fqdn}/{resource}.{verb}`, where `{service_fqdn}` - // is the fully qualified domain name for the service. For example, - // `iam.googleapis.com/roles.list`. - repeated string denied_permissions = 3; - - // Specifies the permissions that this rule excludes from the set of denied - // permissions given by `denied_permissions`. If a permission appears in - // `denied_permissions` _and_ in `exception_permissions` then it will _not_ be - // denied. - // - // The excluded permissions can be specified using the same syntax as - // `denied_permissions`. - repeated string exception_permissions = 4; - - // The condition that determines whether this deny rule applies to a request. - // If the condition expression evaluates to `true`, then the deny rule is - // applied; otherwise, the deny rule is not applied. - // - // Each deny rule is evaluated independently. If this deny rule does not apply - // to a request, other deny rules might still apply. - // - // The condition can use CEL functions that evaluate - // [resource - // tags](https://cloud.google.com/iam/help/conditions/resource-tags). Other - // functions and operators are not supported. - google.type.Expr denial_condition = 5; -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v2/policy.proto b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v2/policy.proto deleted file mode 100644 index 56f73da089b..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/iam/v2/policy.proto +++ /dev/null @@ -1,287 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.iam.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/iam/v2/deny.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Iam.V2"; -option go_package = "cloud.google.com/go/iam/apiv2/iampb;iampb"; -option java_multiple_files = true; -option java_outer_classname = "PolicyProto"; -option java_package = "com.google.iam.v2"; -option php_namespace = "Google\\Cloud\\Iam\\V2"; - -// An interface for managing Identity and Access Management (IAM) policies. -service Policies { - option (google.api.default_host) = "iam.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Retrieves the policies of the specified kind that are attached to a - // resource. - // - // The response lists only policy metadata. In particular, policy rules are - // omitted. - rpc ListPolicies(ListPoliciesRequest) returns (ListPoliciesResponse) { - option (google.api.http) = { - get: "/v2/{parent=policies/*/*}" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets a policy. - rpc GetPolicy(GetPolicyRequest) returns (Policy) { - option (google.api.http) = { - get: "/v2/{name=policies/*/*/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a policy. - rpc CreatePolicy(CreatePolicyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{parent=policies/*/*}" - body: "policy" - }; - option (google.api.method_signature) = "parent,policy,policy_id"; - option (google.longrunning.operation_info) = { - response_type: "Policy" - metadata_type: "PolicyOperationMetadata" - }; - } - - // Updates the specified policy. - // - // You can update only the rules and the display name for the policy. - // - // To update a policy, you should use a read-modify-write loop: - // - // 1. Use [GetPolicy][google.iam.v2.Policies.GetPolicy] to read the current version of the policy. - // 2. Modify the policy as needed. - // 3. Use `UpdatePolicy` to write the updated policy. - // - // This pattern helps prevent conflicts between concurrent updates. - rpc UpdatePolicy(UpdatePolicyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - put: "/v2/{policy.name=policies/*/*/*}" - body: "policy" - }; - option (google.longrunning.operation_info) = { - response_type: "Policy" - metadata_type: "PolicyOperationMetadata" - }; - } - - // Deletes a policy. This action is permanent. - rpc DeletePolicy(DeletePolicyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v2/{name=policies/*/*/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Policy" - metadata_type: "PolicyOperationMetadata" - }; - } -} - -// Data for an IAM policy. -message Policy { - // Immutable. The resource name of the `Policy`, which must be unique. Format: - // `policies/{attachment_point}/denypolicies/{policy_id}` - // - // - // The attachment point is identified by its URL-encoded full resource name, - // which means that the forward-slash character, `/`, must be written as - // `%2F`. For example, - // `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-deny-policy`. - // - // For organizations and folders, use the numeric ID in the full resource - // name. For projects, requests can use the alphanumeric or the numeric ID. - // Responses always contain the numeric ID. - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Immutable. The globally unique ID of the `Policy`. Assigned automatically when the - // `Policy` is created. - string uid = 2 [(google.api.field_behavior) = IMMUTABLE]; - - // Output only. The kind of the `Policy`. Always contains the value `DenyPolicy`. - string kind = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // A user-specified description of the `Policy`. This value can be up to 63 - // characters. - string display_name = 4; - - // A key-value map to store arbitrary metadata for the `Policy`. Keys - // can be up to 63 characters. Values can be up to 255 characters. - map annotations = 5; - - // An opaque tag that identifies the current version of the `Policy`. IAM uses - // this value to help manage concurrent updates, so they do not cause one - // update to be overwritten by another. - // - // If this field is present in a [CreatePolicy][] request, the value is - // ignored. - string etag = 6; - - // Output only. The time when the `Policy` was created. - google.protobuf.Timestamp create_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time when the `Policy` was last updated. - google.protobuf.Timestamp update_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time when the `Policy` was deleted. Empty if the policy is not deleted. - google.protobuf.Timestamp delete_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // A list of rules that specify the behavior of the `Policy`. All of the rules - // should be of the `kind` specified in the `Policy`. - repeated PolicyRule rules = 10; - - // Immutable. Specifies that this policy is managed by an authority and can only be - // modified by that authority. Usage is restricted. - string managing_authority = 11 [(google.api.field_behavior) = IMMUTABLE]; -} - -// A single rule in a `Policy`. -message PolicyRule { - oneof kind { - // A rule for a deny policy. - DenyRule deny_rule = 2; - } - - // A user-specified description of the rule. This value can be up to 256 - // characters. - string description = 1; -} - -// Request message for `ListPolicies`. -message ListPoliciesRequest { - // Required. The resource that the policy is attached to, along with the kind of policy - // to list. Format: - // `policies/{attachment_point}/denypolicies` - // - // - // The attachment point is identified by its URL-encoded full resource name, - // which means that the forward-slash character, `/`, must be written as - // `%2F`. For example, - // `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies`. - // - // For organizations and folders, use the numeric ID in the full resource - // name. For projects, you can use the alphanumeric or the numeric ID. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // The maximum number of policies to return. IAM ignores this value and uses - // the value 1000. - int32 page_size = 2; - - // A page token received in a [ListPoliciesResponse][google.iam.v2.ListPoliciesResponse]. Provide this token to - // retrieve the next page. - string page_token = 3; -} - -// Response message for `ListPolicies`. -message ListPoliciesResponse { - // Metadata for the policies that are attached to the resource. - repeated Policy policies = 1; - - // A page token that you can use in a [ListPoliciesRequest][google.iam.v2.ListPoliciesRequest] to retrieve the - // next page. If this field is omitted, there are no additional pages. - string next_page_token = 2; -} - -// Request message for `GetPolicy`. -message GetPolicyRequest { - // Required. The resource name of the policy to retrieve. Format: - // `policies/{attachment_point}/denypolicies/{policy_id}` - // - // - // Use the URL-encoded full resource name, which means that the forward-slash - // character, `/`, must be written as `%2F`. For example, - // `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy`. - // - // For organizations and folders, use the numeric ID in the full resource - // name. For projects, you can use the alphanumeric or the numeric ID. - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for `CreatePolicy`. -message CreatePolicyRequest { - // Required. The resource that the policy is attached to, along with the kind of policy - // to create. Format: `policies/{attachment_point}/denypolicies` - // - // - // The attachment point is identified by its URL-encoded full resource name, - // which means that the forward-slash character, `/`, must be written as - // `%2F`. For example, - // `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies`. - // - // For organizations and folders, use the numeric ID in the full resource - // name. For projects, you can use the alphanumeric or the numeric ID. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The policy to create. - Policy policy = 2 [(google.api.field_behavior) = REQUIRED]; - - // The ID to use for this policy, which will become the final component of - // the policy's resource name. The ID must contain 3 to 63 characters. It can - // contain lowercase letters and numbers, as well as dashes (`-`) and periods - // (`.`). The first character must be a lowercase letter. - string policy_id = 3; -} - -// Request message for `UpdatePolicy`. -message UpdatePolicyRequest { - // Required. The policy to update. - // - // To prevent conflicting updates, the `etag` value must match the value that - // is stored in IAM. If the `etag` values do not match, the request fails with - // a `409` error code and `ABORTED` status. - Policy policy = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for `DeletePolicy`. -message DeletePolicyRequest { - // Required. The resource name of the policy to delete. Format: - // `policies/{attachment_point}/denypolicies/{policy_id}` - // - // - // Use the URL-encoded full resource name, which means that the forward-slash - // character, `/`, must be written as `%2F`. For example, - // `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy`. - // - // For organizations and folders, use the numeric ID in the full resource - // name. For projects, you can use the alphanumeric or the numeric ID. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The expected `etag` of the policy to delete. If the value does not match - // the value that is stored in IAM, the request fails with a `409` error code - // and `ABORTED` status. - // - // If you omit this field, the policy is deleted regardless of its current - // `etag`. - string etag = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// Metadata for long-running `Policy` operations. -message PolicyOperationMetadata { - // Timestamp when the `google.longrunning.Operation` was created. - google.protobuf.Timestamp create_time = 1; -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/rpc/status.proto b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/rpc/status.proto deleted file mode 100644 index 923e169381a..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/rpc/status.proto +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.rpc; - -import "google/protobuf/any.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/rpc/status;status"; -option java_multiple_files = true; -option java_outer_classname = "StatusProto"; -option java_package = "com.google.rpc"; -option objc_class_prefix = "RPC"; - -// The `Status` type defines a logical error model that is suitable for -// different programming environments, including REST APIs and RPC APIs. It is -// used by [gRPC](https://github.com/grpc). Each `Status` message contains -// three pieces of data: error code, error message, and error details. -// -// You can find out more about this error model and how to work with it in the -// [API Design Guide](https://cloud.google.com/apis/design/errors). -message Status { - // The status code, which should be an enum value of - // [google.rpc.Code][google.rpc.Code]. - int32 code = 1; - - // A developer-facing error message, which should be in English. Any - // user-facing error message should be localized and sent in the - // [google.rpc.Status.details][google.rpc.Status.details] field, or localized - // by the client. - string message = 2; - - // A list of messages that carry the error details. There is a common set of - // message types for APIs to use. - repeated google.protobuf.Any details = 3; -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/type/expr.proto b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/type/expr.proto deleted file mode 100644 index af0778cf958..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/protos/google/type/expr.proto +++ /dev/null @@ -1,73 +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.type; - -option go_package = "google.golang.org/genproto/googleapis/type/expr;expr"; -option java_multiple_files = true; -option java_outer_classname = "ExprProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// Represents a textual expression in the Common Expression Language (CEL) -// syntax. CEL is a C-like expression language. The syntax and semantics of CEL -// are documented at https://github.com/google/cel-spec. -// -// Example (Comparison): -// -// title: "Summary size limit" -// description: "Determines if a summary is less than 100 chars" -// expression: "document.summary.size() < 100" -// -// Example (Equality): -// -// title: "Requestor is owner" -// description: "Determines if requestor is the document owner" -// expression: "document.owner == request.auth.claims.email" -// -// Example (Logic): -// -// title: "Public documents" -// description: "Determine whether the document should be publicly visible" -// expression: "document.type != 'private' && document.type != 'internal'" -// -// Example (Data Manipulation): -// -// title: "Notification string" -// description: "Create a notification string with a timestamp." -// expression: "'New message received at ' + string(document.create_time)" -// -// The exact variables and functions that may be referenced within an expression -// are determined by the service that evaluates it. See the service -// documentation for additional information. -message Expr { - // Textual representation of an expression in Common Expression Language - // syntax. - string expression = 1; - - // Optional. Title for the expression, i.e. a short string describing - // its purpose. This can be used e.g. in UIs which allow to enter the - // expression. - string title = 2; - - // Optional. Description of the expression. This is a longer text which - // describes the expression, e.g. when hovered over it in a UI. - string description = 3; - - // Optional. String indicating the location of the expression for error - // reporting, e.g. a file name and a position in the file. - string location = 4; -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/samples/generated/v3beta/policy_troubleshooter.troubleshoot_iam_policy.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/samples/generated/v3beta/policy_troubleshooter.troubleshoot_iam_policy.js deleted file mode 100644 index 53ecfb8b890..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/samples/generated/v3beta/policy_troubleshooter.troubleshoot_iam_policy.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 policytroubleshooter_v3beta_generated_PolicyTroubleshooter_TroubleshootIamPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 information to use for checking whether a principal has a permission - * for a resource. - */ - // const accessTuple = {} - - // Imports the Iam library - const {PolicyTroubleshooterClient} = require('@google-cloud/policy-troubleshooter-iam').v3beta; - - // Instantiates a client - const iamClient = new PolicyTroubleshooterClient(); - - async function callTroubleshootIamPolicy() { - // Construct request - const request = { - }; - - // Run request - const response = await iamClient.troubleshootIamPolicy(request); - console.log(response); - } - - callTroubleshootIamPolicy(); - // [END policytroubleshooter_v3beta_generated_PolicyTroubleshooter_TroubleshootIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/samples/generated/v3beta/snippet_metadata_google.cloud.policytroubleshooter.iam.v3beta.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/samples/generated/v3beta/snippet_metadata_google.cloud.policytroubleshooter.iam.v3beta.json deleted file mode 100644 index 42f975e02de..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/samples/generated/v3beta/snippet_metadata_google.cloud.policytroubleshooter.iam.v3beta.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-iam", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.policytroubleshooter.iam.v3beta", - "version": "v3beta" - } - ] - }, - "snippets": [ - { - "regionTag": "policytroubleshooter_v3beta_generated_PolicyTroubleshooter_TroubleshootIamPolicy_async", - "title": "Policies troubleshootIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Checks whether a principal has a specific permission for a specific resource, and explains why the principal does or doesn't have that permission.", - "canonical": true, - "file": "policy_troubleshooter.troubleshoot_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TroubleshootIamPolicy", - "fullName": "google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooter.TroubleshootIamPolicy", - "async": true, - "parameters": [ - { - "name": "access_tuple", - "type": ".google.cloud.policytroubleshooter.iam.v3beta.AccessTuple" - } - ], - "resultType": ".google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse", - "client": { - "shortName": "PolicyTroubleshooterClient", - "fullName": "google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooterClient" - }, - "method": { - "shortName": "TroubleshootIamPolicy", - "fullName": "google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooter.TroubleshootIamPolicy", - "service": { - "shortName": "PolicyTroubleshooter", - "fullName": "google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooter" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/index.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/index.ts deleted file mode 100644 index 29c5ee15a98..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/index.ts +++ /dev/null @@ -1,25 +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 v3beta from './v3beta'; -const PolicyTroubleshooterClient = v3beta.PolicyTroubleshooterClient; -type PolicyTroubleshooterClient = v3beta.PolicyTroubleshooterClient; -export {v3beta, PolicyTroubleshooterClient}; -export default {v3beta, PolicyTroubleshooterClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/gapic_metadata.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/gapic_metadata.json deleted file mode 100644 index 96581c62bb5..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/gapic_metadata.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.policytroubleshooter.iam.v3beta", - "libraryPackage": "@google-cloud/policy-troubleshooter-iam", - "services": { - "PolicyTroubleshooter": { - "clients": { - "grpc": { - "libraryClient": "PolicyTroubleshooterClient", - "rpcs": { - "TroubleshootIamPolicy": { - "methods": [ - "troubleshootIamPolicy" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "PolicyTroubleshooterClient", - "rpcs": { - "TroubleshootIamPolicy": { - "methods": [ - "troubleshootIamPolicy" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/index.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/index.ts deleted file mode 100644 index cb1bab0ce55..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/index.ts +++ /dev/null @@ -1,19 +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 {PolicyTroubleshooterClient} from './policy_troubleshooter_client'; diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_client.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_client.ts deleted file mode 100644 index e1ba0b9189c..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_client.ts +++ /dev/null @@ -1,376 +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} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v3beta/policy_troubleshooter_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './policy_troubleshooter_client_config.json'; -const version = require('../../../package.json').version; - -/** - * IAM Policy Troubleshooter service. - * - * This service helps you troubleshoot access issues for Google Cloud resources. - * @class - * @memberof v3beta - */ -export class PolicyTroubleshooterClient { - 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}; - policyTroubleshooterStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of PolicyTroubleshooterClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 PolicyTroubleshooterClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof PolicyTroubleshooterClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooter', 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.policyTroubleshooterStub) { - return this.policyTroubleshooterStub; - } - - // Put together the "service stub" for - // google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooter. - this.policyTroubleshooterStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooter') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooter, - 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 policyTroubleshooterStubMethods = - ['troubleshootIamPolicy']; - for (const methodName of policyTroubleshooterStubMethods) { - const callPromise = this.policyTroubleshooterStub.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.policyTroubleshooterStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'policytroubleshooter.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 'policytroubleshooter.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 -- - // ------------------- -/** - * Checks whether a principal has a specific permission for a specific - * resource, and explains why the principal does or doesn't have that - * permission. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.policytroubleshooter.iam.v3beta.AccessTuple} request.accessTuple - * The information to use for checking whether a principal has a permission - * for a resource. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse|TroubleshootIamPolicyResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3beta/policy_troubleshooter.troubleshoot_iam_policy.js - * region_tag:policytroubleshooter_v3beta_generated_PolicyTroubleshooter_TroubleshootIamPolicy_async - */ - troubleshootIamPolicy( - request?: protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyResponse, - protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyRequest|undefined, {}|undefined - ]>; - troubleshootIamPolicy( - request: protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyResponse, - protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - troubleshootIamPolicy( - request: protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyRequest, - callback: Callback< - protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyResponse, - protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - troubleshootIamPolicy( - request?: protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyResponse, - protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyResponse, - protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyResponse, - protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.troubleshootIamPolicy(request, options, callback); - } - - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.policyTroubleshooterStub && !this._terminated) { - return this.policyTroubleshooterStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_client_config.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_client_config.json deleted file mode 100644 index eb4ce1f3959..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_client_config.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "interfaces": { - "google.cloud.policytroubleshooter.iam.v3beta.PolicyTroubleshooter": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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 - }, - "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "TroubleshootIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_proto_list.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_proto_list.json deleted file mode 100644 index 45e4242c422..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/src/v3beta/policy_troubleshooter_proto_list.json +++ /dev/null @@ -1,4 +0,0 @@ -[ - "../../protos/google/cloud/policytroubleshooter/iam/v3beta/troubleshooter.proto", - "../../protos/google/iam/v2/deny.proto" -] diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 0a33a6a9558..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const iam = require('@google-cloud/policy-troubleshooter-iam'); - -function main() { - const policyTroubleshooterClient = new iam.PolicyTroubleshooterClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 640427e0ee7..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {PolicyTroubleshooterClient} from '@google-cloud/policy-troubleshooter-iam'; - -// check that the client class type name can be used -function doStuffWithPolicyTroubleshooterClient(client: PolicyTroubleshooterClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const policyTroubleshooterClient = new PolicyTroubleshooterClient(); - doStuffWithPolicyTroubleshooterClient(policyTroubleshooterClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/install.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/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-policytroubleshooter-iam/v3beta/test/gapic_policy_troubleshooter_v3beta.ts b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/test/gapic_policy_troubleshooter_v3beta.ts deleted file mode 100644 index c5336388dfa..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/test/gapic_policy_troubleshooter_v3beta.ts +++ /dev/null @@ -1,225 +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 policytroubleshooterModule from '../src'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -describe('v3beta.PolicyTroubleshooterClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = policytroubleshooterModule.v3beta.PolicyTroubleshooterClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = policytroubleshooterModule.v3beta.PolicyTroubleshooterClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = policytroubleshooterModule.v3beta.PolicyTroubleshooterClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new policytroubleshooterModule.v3beta.PolicyTroubleshooterClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new policytroubleshooterModule.v3beta.PolicyTroubleshooterClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new policytroubleshooterModule.v3beta.PolicyTroubleshooterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.policyTroubleshooterStub, undefined); - await client.initialize(); - assert(client.policyTroubleshooterStub); - }); - - it('has close method for the initialized client', done => { - const client = new policytroubleshooterModule.v3beta.PolicyTroubleshooterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.policyTroubleshooterStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new policytroubleshooterModule.v3beta.PolicyTroubleshooterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.policyTroubleshooterStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new policytroubleshooterModule.v3beta.PolicyTroubleshooterClient({ - 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 policytroubleshooterModule.v3beta.PolicyTroubleshooterClient({ - 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('troubleshootIamPolicy', () => { - it('invokes troubleshootIamPolicy without error', async () => { - const client = new policytroubleshooterModule.v3beta.PolicyTroubleshooterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse() - ); - client.innerApiCalls.troubleshootIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.troubleshootIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes troubleshootIamPolicy without error using callback', async () => { - const client = new policytroubleshooterModule.v3beta.PolicyTroubleshooterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyResponse() - ); - client.innerApiCalls.troubleshootIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.troubleshootIamPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.policytroubleshooter.iam.v3beta.ITroubleshootIamPolicyResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes troubleshootIamPolicy with error', async () => { - const client = new policytroubleshooterModule.v3beta.PolicyTroubleshooterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.troubleshootIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.troubleshootIamPolicy(request), expectedError); - }); - - it('invokes troubleshootIamPolicy with closed client', async () => { - const client = new policytroubleshooterModule.v3beta.PolicyTroubleshooterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.policytroubleshooter.iam.v3beta.TroubleshootIamPolicyRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.troubleshootIamPolicy(request), expectedError); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/tsconfig.json b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/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-policytroubleshooter-iam/v3beta/webpack.config.js b/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/webpack.config.js deleted file mode 100644 index f423e0d5294..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter-iam/v3beta/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: 'Policies', - filename: './policies.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-policytroubleshooter/v1/.eslintignore b/owl-bot-staging/google-cloud-policytroubleshooter/v1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/.eslintrc.json b/owl-bot-staging/google-cloud-policytroubleshooter/v1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/.gitignore b/owl-bot-staging/google-cloud-policytroubleshooter/v1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/.jsdoc.js b/owl-bot-staging/google-cloud-policytroubleshooter/v1/.jsdoc.js deleted file mode 100644 index 4e108ab141e..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/.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/policy-troubleshooter', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/.mocharc.js b/owl-bot-staging/google-cloud-policytroubleshooter/v1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/.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-policytroubleshooter/v1/.prettierrc.js b/owl-bot-staging/google-cloud-policytroubleshooter/v1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/.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-policytroubleshooter/v1/README.md b/owl-bot-staging/google-cloud-policytroubleshooter/v1/README.md deleted file mode 100644 index d7265c118dc..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Policytroubleshooter: Nodejs Client diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/package.json b/owl-bot-staging/google-cloud-policytroubleshooter/v1/package.json deleted file mode 100644 index d55249ffd9d..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/policy-troubleshooter", - "version": "0.1.0", - "description": "Policytroubleshooter client for Node.js", - "repository": "googleapis/nodejs-policytroubleshooter", - "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 policytroubleshooter", - "policytroubleshooter", - "iam checker" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/protos/google/cloud/policytroubleshooter/v1/checker.proto b/owl-bot-staging/google-cloud-policytroubleshooter/v1/protos/google/cloud/policytroubleshooter/v1/checker.proto deleted file mode 100644 index ebefb7b6af3..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/protos/google/cloud/policytroubleshooter/v1/checker.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.policytroubleshooter.v1; - -import public "google/cloud/policytroubleshooter/v1/explanations.proto"; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/rpc/status.proto"; - -option cc_enable_arenas = true; -option csharp_namespace = "Google.Cloud.PolicyTroubleshooter.V1"; -option go_package = "cloud.google.com/go/policytroubleshooter/apiv1/policytroubleshooterpb;policytroubleshooterpb"; -option java_multiple_files = true; -option java_outer_classname = "IAMCheckerProto"; -option java_package = "com.google.cloud.policytroubleshooter.v1"; -option php_namespace = "Google\\Cloud\\PolicyTroubleshooter\\V1"; -option ruby_package = "Google::Cloud::PolicyTroubleshooter::V1"; - -// IAM Policy Troubleshooter service. -// -// This service helps you troubleshoot access issues for Google Cloud resources. -service IamChecker { - option (google.api.default_host) = "policytroubleshooter.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Checks whether a principal has a specific permission for a specific - // resource, and explains why the principal does or does not have that - // permission. - rpc TroubleshootIamPolicy(TroubleshootIamPolicyRequest) - returns (TroubleshootIamPolicyResponse) { - option (google.api.http) = { - post: "/v1/iam:troubleshoot" - body: "*" - }; - } -} - -// Request for -// [TroubleshootIamPolicy][google.cloud.policytroubleshooter.v1.IamChecker.TroubleshootIamPolicy]. -message TroubleshootIamPolicyRequest { - // The information to use for checking whether a principal has a permission - // for a resource. - AccessTuple access_tuple = 1; -} - -// Response for -// [TroubleshootIamPolicy][google.cloud.policytroubleshooter.v1.IamChecker.TroubleshootIamPolicy]. -message TroubleshootIamPolicyResponse { - // Indicates whether the principal has the specified permission for the - // specified resource, based on evaluating all of the applicable IAM policies. - AccessState access = 1; - - // List of IAM policies that were evaluated to check the principal's - // permissions, with annotations to indicate how each policy contributed to - // the final result. - // - // The list of policies can include the policy for the resource itself. It can - // also include policies that are inherited from higher levels of the resource - // hierarchy, including the organization, the folder, and the project. - // - // To learn more about the resource hierarchy, see - // https://cloud.google.com/iam/help/resource-hierarchy. - repeated ExplainedPolicy explained_policies = 2; - - // The general errors contained in the troubleshooting response. - repeated google.rpc.Status errors = 3; -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/protos/google/cloud/policytroubleshooter/v1/explanations.proto b/owl-bot-staging/google-cloud-policytroubleshooter/v1/protos/google/cloud/policytroubleshooter/v1/explanations.proto deleted file mode 100644 index 18d4611eb1c..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/protos/google/cloud/policytroubleshooter/v1/explanations.proto +++ /dev/null @@ -1,247 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.policytroubleshooter.v1; - -import "google/api/field_behavior.proto"; -import "google/iam/v1/policy.proto"; -import "google/type/expr.proto"; - -option csharp_namespace = "Google.Cloud.PolicyTroubleshooter.V1"; -option go_package = "cloud.google.com/go/policytroubleshooter/apiv1/policytroubleshooterpb;policytroubleshooterpb"; -option php_namespace = "Google\\Cloud\\PolicyTroubleshooter\\V1"; -option ruby_package = "Google::Cloud::PolicyTroubleshooter::V1"; - -// Information about the principal, resource, and permission to check. -message AccessTuple { - // Required. The principal whose access you want to check, in the form of - // the email address that represents that principal. For example, - // `alice@example.com` or - // `my-service-account@my-project.iam.gserviceaccount.com`. - // - // The principal must be a Google Account or a service account. Other types of - // principals are not supported. - string principal = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The full resource name that identifies the resource. For example, - // `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`. - // - // For examples of full resource names for Google Cloud services, see - // https://cloud.google.com/iam/help/troubleshooter/full-resource-names. - string full_resource_name = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The IAM permission to check for the specified principal and - // resource. - // - // For a complete list of IAM permissions, see - // https://cloud.google.com/iam/help/permissions/reference. - // - // For a complete list of predefined IAM roles and the permissions in each - // role, see https://cloud.google.com/iam/help/roles/reference. - string permission = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Details about how a specific IAM [Policy][google.iam.v1.Policy] contributed -// to the access check. -message ExplainedPolicy { - // Indicates whether _this policy_ provides the specified permission to the - // specified principal for the specified resource. - // - // This field does _not_ indicate whether the principal actually has the - // permission for the resource. There might be another policy that overrides - // this policy. To determine whether the principal actually has the - // permission, use the `access` field in the - // [TroubleshootIamPolicyResponse][IamChecker.TroubleshootIamPolicyResponse]. - AccessState access = 1; - - // The full resource name that identifies the resource. For example, - // `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`. - // - // If the sender of the request does not have access to the policy, this field - // is omitted. - // - // For examples of full resource names for Google Cloud services, see - // https://cloud.google.com/iam/help/troubleshooter/full-resource-names. - string full_resource_name = 2; - - // The IAM policy attached to the resource. - // - // If the sender of the request does not have access to the policy, this field - // is empty. - google.iam.v1.Policy policy = 3; - - // Details about how each binding in the policy affects the principal's - // ability, or inability, to use the permission for the resource. - // - // If the sender of the request does not have access to the policy, this field - // is omitted. - repeated BindingExplanation binding_explanations = 4; - - // The relevance of this policy to the overall determination in the - // [TroubleshootIamPolicyResponse][IamChecker.TroubleshootIamPolicyResponse]. - // - // If the sender of the request does not have access to the policy, this field - // is omitted. - HeuristicRelevance relevance = 5; -} - -// Details about how a binding in a policy affects a principal's ability to use -// a permission. -message BindingExplanation { - // Whether a role includes a specific permission. - enum RolePermission { - // Default value. This value is unused. - ROLE_PERMISSION_UNSPECIFIED = 0; - - // The permission is included in the role. - ROLE_PERMISSION_INCLUDED = 1; - - // The permission is not included in the role. - ROLE_PERMISSION_NOT_INCLUDED = 2; - - // The sender of the request is not allowed to access the binding. - ROLE_PERMISSION_UNKNOWN_INFO_DENIED = 3; - } - - // Whether the binding includes the principal. - enum Membership { - // Default value. This value is unused. - MEMBERSHIP_UNSPECIFIED = 0; - - // The binding includes the principal. The principal can be included - // directly or indirectly. For example: - // - // * A principal is included directly if that principal is listed in the - // binding. - // * A principal is included indirectly if that principal is in a Google - // group or Google Workspace domain that is listed in the binding. - MEMBERSHIP_INCLUDED = 1; - - // The binding does not include the principal. - MEMBERSHIP_NOT_INCLUDED = 2; - - // The sender of the request is not allowed to access the binding. - MEMBERSHIP_UNKNOWN_INFO_DENIED = 3; - - // The principal is an unsupported type. Only Google Accounts and service - // accounts are supported. - MEMBERSHIP_UNKNOWN_UNSUPPORTED = 4; - } - - // Details about whether the binding includes the principal. - message AnnotatedMembership { - // Indicates whether the binding includes the principal. - Membership membership = 1; - - // The relevance of the principal's status to the overall determination for - // the binding. - HeuristicRelevance relevance = 2; - } - - // Required. Indicates whether _this binding_ provides the specified - // permission to the specified principal for the specified resource. - // - // This field does _not_ indicate whether the principal actually has the - // permission for the resource. There might be another binding that overrides - // this binding. To determine whether the principal actually has the - // permission, use the `access` field in the - // [TroubleshootIamPolicyResponse][IamChecker.TroubleshootIamPolicyResponse]. - AccessState access = 1 [(google.api.field_behavior) = REQUIRED]; - - // The role that this binding grants. For example, - // `roles/compute.serviceAgent`. - // - // For a complete list of predefined IAM roles, as well as the permissions in - // each role, see https://cloud.google.com/iam/help/roles/reference. - string role = 2; - - // Indicates whether the role granted by this binding contains the specified - // permission. - RolePermission role_permission = 3; - - // The relevance of the permission's existence, or nonexistence, in the role - // to the overall determination for the entire policy. - HeuristicRelevance role_permission_relevance = 4; - - // Indicates whether each principal in the binding includes the principal - // specified in the request, either directly or indirectly. Each key - // identifies a principal in the binding, and each value indicates whether the - // principal in the binding includes the principal in the request. - // - // For example, suppose that a binding includes the following principals: - // - // * `user:alice@example.com` - // * `group:product-eng@example.com` - // - // You want to troubleshoot access for `user:bob@example.com`. This user is a - // principal of the group `group:product-eng@example.com`. - // - // For the first principal in the binding, the key is - // `user:alice@example.com`, and the `membership` field in the value is set to - // `MEMBERSHIP_NOT_INCLUDED`. - // - // For the second principal in the binding, the key is - // `group:product-eng@example.com`, and the `membership` field in the value is - // set to `MEMBERSHIP_INCLUDED`. - map memberships = 5; - - // The relevance of this binding to the overall determination for the entire - // policy. - HeuristicRelevance relevance = 6; - - // A condition expression that prevents this binding from granting access - // unless the expression evaluates to `true`. - // - // To learn about IAM Conditions, see - // https://cloud.google.com/iam/help/conditions/overview. - google.type.Expr condition = 7; -} - -// Whether a principal has a permission for a resource. -enum AccessState { - // Default value. This value is unused. - ACCESS_STATE_UNSPECIFIED = 0; - - // The principal has the permission. - GRANTED = 1; - - // The principal does not have the permission. - NOT_GRANTED = 2; - - // The principal has the permission only if a condition expression evaluates - // to `true`. - UNKNOWN_CONDITIONAL = 3; - - // The sender of the request does not have access to all of the policies that - // Policy Troubleshooter needs to evaluate. - UNKNOWN_INFO_DENIED = 4; -} - -// The extent to which a single data point, such as the existence of a binding -// or whether a binding includes a specific principal, contributes to an overall -// determination. -enum HeuristicRelevance { - // Default value. This value is unused. - HEURISTIC_RELEVANCE_UNSPECIFIED = 0; - - // The data point has a limited effect on the result. Changing the data point - // is unlikely to affect the overall determination. - NORMAL = 1; - - // The data point has a strong effect on the result. Changing the data point - // is likely to affect the overall determination. - HIGH = 2; -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/samples/generated/v1/iam_checker.troubleshoot_iam_policy.js b/owl-bot-staging/google-cloud-policytroubleshooter/v1/samples/generated/v1/iam_checker.troubleshoot_iam_policy.js deleted file mode 100644 index 81f3d5f5e0e..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/samples/generated/v1/iam_checker.troubleshoot_iam_policy.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 policytroubleshooter_v1_generated_IamChecker_TroubleshootIamPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 information to use for checking whether a principal has a permission - * for a resource. - */ - // const accessTuple = {} - - // Imports the Policytroubleshooter library - const {IamCheckerClient} = require('@google-cloud/policy-troubleshooter').v1; - - // Instantiates a client - const policytroubleshooterClient = new IamCheckerClient(); - - async function callTroubleshootIamPolicy() { - // Construct request - const request = { - }; - - // Run request - const response = await policytroubleshooterClient.troubleshootIamPolicy(request); - console.log(response); - } - - callTroubleshootIamPolicy(); - // [END policytroubleshooter_v1_generated_IamChecker_TroubleshootIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/samples/generated/v1/snippet_metadata_google.cloud.policytroubleshooter.v1.json b/owl-bot-staging/google-cloud-policytroubleshooter/v1/samples/generated/v1/snippet_metadata_google.cloud.policytroubleshooter.v1.json deleted file mode 100644 index 9c38afc4ec0..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/samples/generated/v1/snippet_metadata_google.cloud.policytroubleshooter.v1.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-policytroubleshooter", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.policytroubleshooter.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "policytroubleshooter_v1_generated_IamChecker_TroubleshootIamPolicy_async", - "title": "IamChecker troubleshootIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Checks whether a principal has a specific permission for a specific resource, and explains why the principal does or does not have that permission.", - "canonical": true, - "file": "iam_checker.troubleshoot_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TroubleshootIamPolicy", - "fullName": "google.cloud.policytroubleshooter.v1.IamChecker.TroubleshootIamPolicy", - "async": true, - "parameters": [ - { - "name": "access_tuple", - "type": ".google.cloud.policytroubleshooter.v1.AccessTuple" - } - ], - "resultType": ".google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyResponse", - "client": { - "shortName": "IamCheckerClient", - "fullName": "google.cloud.policytroubleshooter.v1.IamCheckerClient" - }, - "method": { - "shortName": "TroubleshootIamPolicy", - "fullName": "google.cloud.policytroubleshooter.v1.IamChecker.TroubleshootIamPolicy", - "service": { - "shortName": "IamChecker", - "fullName": "google.cloud.policytroubleshooter.v1.IamChecker" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/index.ts b/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/index.ts deleted file mode 100644 index d8ee5214153..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/index.ts +++ /dev/null @@ -1,25 +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 v1 from './v1'; -const IamCheckerClient = v1.IamCheckerClient; -type IamCheckerClient = v1.IamCheckerClient; -export {v1, IamCheckerClient}; -export default {v1, IamCheckerClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/gapic_metadata.json deleted file mode 100644 index daff31dc6c1..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.policytroubleshooter.v1", - "libraryPackage": "@google-cloud/policy-troubleshooter", - "services": { - "IamChecker": { - "clients": { - "grpc": { - "libraryClient": "IamCheckerClient", - "rpcs": { - "TroubleshootIamPolicy": { - "methods": [ - "troubleshootIamPolicy" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "IamCheckerClient", - "rpcs": { - "TroubleshootIamPolicy": { - "methods": [ - "troubleshootIamPolicy" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_client.ts b/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_client.ts deleted file mode 100644 index 9a9e2908281..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_client.ts +++ /dev/null @@ -1,376 +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} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/iam_checker_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './iam_checker_client_config.json'; -const version = require('../../../package.json').version; - -/** - * IAM Policy Troubleshooter service. - * - * This service helps you troubleshoot access issues for Google Cloud resources. - * @class - * @memberof v1 - */ -export class IamCheckerClient { - 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}; - iamCheckerStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of IamCheckerClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 IamCheckerClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof IamCheckerClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.policytroubleshooter.v1.IamChecker', 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.iamCheckerStub) { - return this.iamCheckerStub; - } - - // Put together the "service stub" for - // google.cloud.policytroubleshooter.v1.IamChecker. - this.iamCheckerStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.policytroubleshooter.v1.IamChecker') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.policytroubleshooter.v1.IamChecker, - 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 iamCheckerStubMethods = - ['troubleshootIamPolicy']; - for (const methodName of iamCheckerStubMethods) { - const callPromise = this.iamCheckerStub.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.iamCheckerStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'policytroubleshooter.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 'policytroubleshooter.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 -- - // ------------------- -/** - * Checks whether a principal has a specific permission for a specific - * resource, and explains why the principal does or does not have that - * permission. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.policytroubleshooter.v1.AccessTuple} request.accessTuple - * The information to use for checking whether a principal has a permission - * for a resource. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyResponse|TroubleshootIamPolicyResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/iam_checker.troubleshoot_iam_policy.js - * region_tag:policytroubleshooter_v1_generated_IamChecker_TroubleshootIamPolicy_async - */ - troubleshootIamPolicy( - request?: protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyResponse, - protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest|undefined, {}|undefined - ]>; - troubleshootIamPolicy( - request: protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyResponse, - protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - troubleshootIamPolicy( - request: protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest, - callback: Callback< - protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyResponse, - protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - troubleshootIamPolicy( - request?: protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyResponse, - protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyResponse, - protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyResponse, - protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.troubleshootIamPolicy(request, options, callback); - } - - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.iamCheckerStub && !this._terminated) { - return this.iamCheckerStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_client_config.json b/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_client_config.json deleted file mode 100644 index 6d70cf67ac3..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_client_config.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "interfaces": { - "google.cloud.policytroubleshooter.v1.IamChecker": { - "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": { - "TroubleshootIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_proto_list.json b/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_proto_list.json deleted file mode 100644 index 3da19f410cc..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/iam_checker_proto_list.json +++ /dev/null @@ -1,4 +0,0 @@ -[ - "../../protos/google/cloud/policytroubleshooter/v1/checker.proto", - "../../protos/google/cloud/policytroubleshooter/v1/explanations.proto" -] diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/index.ts deleted file mode 100644 index 0986c6e6fce..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +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 {IamCheckerClient} from './iam_checker_client'; diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 63c539e92de..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const policytroubleshooter = require('@google-cloud/policy-troubleshooter'); - -function main() { - const iamCheckerClient = new policytroubleshooter.IamCheckerClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 26430b75adf..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {IamCheckerClient} from '@google-cloud/policy-troubleshooter'; - -// check that the client class type name can be used -function doStuffWithIamCheckerClient(client: IamCheckerClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const iamCheckerClient = new IamCheckerClient(); - doStuffWithIamCheckerClient(iamCheckerClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/install.ts b/owl-bot-staging/google-cloud-policytroubleshooter/v1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/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-policytroubleshooter/v1/test/gapic_iam_checker_v1.ts b/owl-bot-staging/google-cloud-policytroubleshooter/v1/test/gapic_iam_checker_v1.ts deleted file mode 100644 index aa508cbb6ed..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/test/gapic_iam_checker_v1.ts +++ /dev/null @@ -1,225 +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 iamcheckerModule from '../src'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -describe('v1.IamCheckerClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = iamcheckerModule.v1.IamCheckerClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = iamcheckerModule.v1.IamCheckerClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = iamcheckerModule.v1.IamCheckerClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new iamcheckerModule.v1.IamCheckerClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new iamcheckerModule.v1.IamCheckerClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new iamcheckerModule.v1.IamCheckerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.iamCheckerStub, undefined); - await client.initialize(); - assert(client.iamCheckerStub); - }); - - it('has close method for the initialized client', done => { - const client = new iamcheckerModule.v1.IamCheckerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.iamCheckerStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new iamcheckerModule.v1.IamCheckerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.iamCheckerStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new iamcheckerModule.v1.IamCheckerClient({ - 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 iamcheckerModule.v1.IamCheckerClient({ - 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('troubleshootIamPolicy', () => { - it('invokes troubleshootIamPolicy without error', async () => { - const client = new iamcheckerModule.v1.IamCheckerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyResponse() - ); - client.innerApiCalls.troubleshootIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.troubleshootIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes troubleshootIamPolicy without error using callback', async () => { - const client = new iamcheckerModule.v1.IamCheckerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyResponse() - ); - client.innerApiCalls.troubleshootIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.troubleshootIamPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes troubleshootIamPolicy with error', async () => { - const client = new iamcheckerModule.v1.IamCheckerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.troubleshootIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.troubleshootIamPolicy(request), expectedError); - }); - - it('invokes troubleshootIamPolicy with closed client', async () => { - const client = new iamcheckerModule.v1.IamCheckerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.troubleshootIamPolicy(request), expectedError); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/tsconfig.json b/owl-bot-staging/google-cloud-policytroubleshooter/v1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-policytroubleshooter/v1/webpack.config.js b/owl-bot-staging/google-cloud-policytroubleshooter/v1/webpack.config.js deleted file mode 100644 index 3fbe558bc97..00000000000 --- a/owl-bot-staging/google-cloud-policytroubleshooter/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'IamChecker', - filename: './iam-checker.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-privatecatalog/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.gitignore b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.jsdoc.js deleted file mode 100644 index aefbb43f80f..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.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/private-catalog', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.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-privatecatalog/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/.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-privatecatalog/v1beta1/README.md b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/README.md deleted file mode 100644 index 0b9f815350d..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Privatecatalog: Nodejs Client diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/package.json b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/package.json deleted file mode 100644 index 61599b4ec3e..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/private-catalog", - "version": "0.1.0", - "description": "Privatecatalog client for Node.js", - "repository": "googleapis/nodejs-privatecatalog", - "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 privatecatalog", - "privatecatalog", - "private catalog" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/protos/google/cloud/privatecatalog/v1beta1/private_catalog.proto b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/protos/google/cloud/privatecatalog/v1beta1/private_catalog.proto deleted file mode 100644 index 1ee77714357..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/protos/google/cloud/privatecatalog/v1beta1/private_catalog.proto +++ /dev/null @@ -1,556 +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.privatecatalog.v1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.PrivateCatalog.V1Beta1"; -option go_package = "cloud.google.com/go/privatecatalog/apiv1beta1/privatecatalogpb;privatecatalogpb"; -option java_multiple_files = true; -option java_outer_classname = "PrivateCatalogProto"; -option java_package = "com.google.cloud.privatecatalog.v1beta1"; -option php_namespace = "Google\\Cloud\\PrivateCatalog\\V1beta1"; -option ruby_package = "Google::Cloud::PrivateCatalog::V1beta1"; - -// `PrivateCatalog` allows catalog consumers to retrieve `Catalog`, `Product` -// and `Version` resources under a target resource context. -// -// `Catalog` is computed based on the [Association][]s linked to the target -// resource and its ancestors. Each association's -// [google.cloud.privatecatalogproducer.v1beta.Catalog][] is transformed into a -// `Catalog`. If multiple associations have the same parent -// [google.cloud.privatecatalogproducer.v1beta.Catalog][], they are -// de-duplicated into one `Catalog`. Users must have -// `cloudprivatecatalog.catalogTargets.get` IAM permission on the resource -// context in order to access catalogs. `Catalog` contains the resource name and -// a subset of data of the original -// [google.cloud.privatecatalogproducer.v1beta.Catalog][]. -// -// `Product` is child resource of the catalog. A `Product` contains the resource -// name and a subset of the data of the original -// [google.cloud.privatecatalogproducer.v1beta.Product][]. -// -// `Version` is child resource of the product. A `Version` contains the resource -// name and a subset of the data of the original -// [google.cloud.privatecatalogproducer.v1beta.Version][]. -service PrivateCatalog { - option (google.api.default_host) = "cloudprivatecatalog.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Search [Catalog][google.cloud.privatecatalog.v1beta1.Catalog] resources that consumers have access to, within the - // scope of the consumer cloud resource hierarchy context. - rpc SearchCatalogs(SearchCatalogsRequest) returns (SearchCatalogsResponse) { - option (google.api.http) = { - get: "/v1beta1/{resource=projects/*}/catalogs:search" - additional_bindings { - get: "/v1beta1/{resource=organizations/*}/catalogs:search" - } - additional_bindings { - get: "/v1beta1/{resource=folders/*}/catalogs:search" - } - }; - } - - // Search [Product][google.cloud.privatecatalog.v1beta1.Product] resources that consumers have access to, within the - // scope of the consumer cloud resource hierarchy context. - rpc SearchProducts(SearchProductsRequest) returns (SearchProductsResponse) { - option (google.api.http) = { - get: "/v1beta1/{resource=projects/*}/products:search" - additional_bindings { - get: "/v1beta1/{resource=organizations/*}/products:search" - } - additional_bindings { - get: "/v1beta1/{resource=folders/*}/products:search" - } - }; - } - - // Search [Version][google.cloud.privatecatalog.v1beta1.Version] resources that consumers have access to, within the - // scope of the consumer cloud resource hierarchy context. - rpc SearchVersions(SearchVersionsRequest) returns (SearchVersionsResponse) { - option (google.api.http) = { - get: "/v1beta1/{resource=projects/*}/versions:search" - additional_bindings { - get: "/v1beta1/{resource=organizations/*}/versions:search" - } - additional_bindings { - get: "/v1beta1/{resource=folders/*}/versions:search" - } - }; - } -} - -// Request message for [PrivateCatalog.SearchCatalogs][google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchCatalogs]. -message SearchCatalogsRequest { - // Required. The name of the resource context. It can be in following formats: - // - // * `projects/{project}` - // * `folders/{folder}` - // * `organizations/{organization}` - string resource = 1 [(google.api.field_behavior) = REQUIRED]; - - // The query to filter the catalogs. The supported queries are: - // - // * Get a single catalog: `name=catalogs/{catalog}` - string query = 2; - - // The maximum number of entries that are requested. - int32 page_size = 3; - - // A pagination token returned from a previous call to SearchCatalogs that - // indicates where this listing should continue from. - string page_token = 4; -} - -// Response message for [PrivateCatalog.SearchCatalogs][google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchCatalogs]. -message SearchCatalogsResponse { - // The `Catalog`s computed from the resource context. - repeated Catalog catalogs = 1; - - // A pagination token returned from a previous call to SearchCatalogs that - // indicates from where listing should continue. - string next_page_token = 2; -} - -// Request message for [PrivateCatalog.SearchProducts][google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchProducts]. -message SearchProductsRequest { - // Required. The name of the resource context. See [SearchCatalogsRequest.resource][google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource] - // for details. - string resource = 1 [(google.api.field_behavior) = REQUIRED]; - - // The query to filter the products. - // - // The supported queries are: - // * List products of all catalogs: empty - // * List products under a catalog: `parent=catalogs/{catalog}` - // * Get a product by name: - // `name=catalogs/{catalog}/products/{product}` - string query = 2; - - // The maximum number of entries that are requested. - int32 page_size = 3; - - // A pagination token returned from a previous call to SearchProducts that - // indicates where this listing should continue from. - string page_token = 4; -} - -// Response message for [PrivateCatalog.SearchProducts][google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchProducts]. -message SearchProductsResponse { - // The `Product` resources computed from the resource context. - repeated Product products = 1; - - // A pagination token returned from a previous call to SearchProducts that - // indicates from where listing should continue. - string next_page_token = 2; -} - -// Request message for [PrivateCatalog.SearchVersions][google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchVersions]. -message SearchVersionsRequest { - // Required. The name of the resource context. See [SearchCatalogsRequest.resource][google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource] - // for details. - string resource = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The query to filter the versions. - // - // The supported queries are: - // * List versions under a product: - // `parent=catalogs/{catalog}/products/{product}` - // * Get a version by name: - // `name=catalogs/{catalog}/products/{product}/versions/{version}` - string query = 2 [(google.api.field_behavior) = REQUIRED]; - - // The maximum number of entries that are requested. - int32 page_size = 3; - - // A pagination token returned from a previous call to SearchVersions - // that indicates where this listing should continue from. - string page_token = 4; -} - -// Response message for [PrivateCatalog.SearchVersions][google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchVersions]. -message SearchVersionsResponse { - // The `Version` resources computed from the resource context. - repeated Version versions = 1; - - // A pagination token returned from a previous call to SearchVersions that - // indicates from where the listing should continue. - string next_page_token = 2; -} - -// The readonly representation of a catalog computed with a given resource -// context. -message Catalog { - option (google.api.resource) = { - type: "cloudprivatecatalog.googleapis.com/Catalog" - pattern: "catalogs/{catalog}" - }; - - // Output only. The resource name of the target catalog, in the format of - // `catalogs/{catalog}'. - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The descriptive name of the catalog as it appears in UIs. - string display_name = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The description of the catalog. - string description = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time when the catalog was created. - google.protobuf.Timestamp create_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time when the catalog was last updated. - google.protobuf.Timestamp update_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// The readonly representation of a product computed with a given resource -// context. -message Product { - option (google.api.resource) = { - type: "cloudprivatecatalog.googleapis.com/Product" - pattern: "products/{product}" - }; - - // Output only. The resource name of the target product, in the format of - // `products/[a-z][-a-z0-9]*[a-z0-9]'. - // - // A unique identifier for the product under a catalog. - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The type of the product asset. It can be one of the following values: - // - // * `google.deploymentmanager.Template` - // * `google.cloudprivatecatalog.ListingOnly` - // * `google.cloudprivatecatalog.Terraform` - string asset_type = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Required. Output only. The display metadata to describe the product. The JSON schema of the - // metadata differs by [Product.asset_type][google.cloud.privatecatalog.v1beta1.Product.asset_type]. - // When the type is `google.deploymentmanager.Template`, the schema is as - // follows: - // - // ``` - // "$schema": http://json-schema.org/draft-04/schema# - // type: object - // properties: - // name: - // type: string - // minLength: 1 - // maxLength: 64 - // description: - // type: string - // minLength: 1 - // maxLength: 2048 - // tagline: - // type: string - // minLength: 1 - // maxLength: 100 - // support_info: - // type: string - // minLength: 1 - // maxLength: 2048 - // creator: - // type: string - // minLength: 1 - // maxLength: 100 - // documentations: - // type: array - // items: - // type: object - // properties: - // url: - // type: string - // pattern: - // "^(https?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]" - // title: - // type: string - // minLength: 1 - // maxLength: 64 - // description: - // type: string - // minLength: 1 - // maxLength: 2048 - // required: - // - name - // - description - // additionalProperties: false - // - // ``` - // - // When the asset type is `google.cloudprivatecatalog.ListingOnly`, the schema - // is as follows: - // - // ``` - // "$schema": http://json-schema.org/draft-04/schema# - // type: object - // properties: - // name: - // type: string - // minLength: 1 - // maxLength: 64 - // description: - // type: string - // minLength: 1 - // maxLength: 2048 - // tagline: - // type: string - // minLength: 1 - // maxLength: 100 - // support_info: - // type: string - // minLength: 1 - // maxLength: 2048 - // creator: - // type: string - // minLength: 1 - // maxLength: 100 - // documentations: - // type: array - // items: - // type: object - // properties: - // url: - // type: string - // pattern: - // "^(https?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]" - // title: - // type: string - // minLength: 1 - // maxLength: 64 - // description: - // type: string - // minLength: 1 - // maxLength: 2048 - // signup_url: - // type: string - // pattern: - // "^(https?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]" - // required: - // - name - // - description - // - signup_url - // additionalProperties: false - // - // ``` - // - // When the asset type is `google.cloudprivatecatalog.Terraform`, the schema - // is as follows: - // - // ``` - // "$schema": http://json-schema.org/draft-04/schema# - // type: object - // properties: - // name: - // type: string - // minLength: 1 - // maxLength: 64 - // description: - // type: string - // minLength: 1 - // maxLength: 2048 - // tagline: - // type: string - // minLength: 1 - // maxLength: 100 - // support_info: - // type: string - // minLength: 1 - // maxLength: 2048 - // creator: - // type: string - // minLength: 1 - // maxLength: 100 - // documentations: - // type: array - // items: - // type: object - // properties: - // url: - // type: string - // pattern: - // "^(https?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]" - // title: - // type: string - // minLength: 1 - // maxLength: 64 - // description: - // type: string - // minLength: 1 - // maxLength: 2048 - // required: - // - name - // - description - // additionalProperties: true - google.protobuf.Struct display_metadata = 3 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = OUTPUT_ONLY - ]; - - // Output only. The icon URI of the product. - string icon_uri = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A collection of assets referred by a product. - // This field is set for Terraform Products only. - repeated AssetReference asset_references = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time when the product was created. - google.protobuf.Timestamp create_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time when the product was last updated. - google.protobuf.Timestamp update_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Defines the reference of an asset belonging to a product. -message AssetReference { - // Possible validation steates of an asset reference. - enum AssetValidationState { - // Unknown state. - ASSET_VALIDATION_STATE_UNSPECIFIED = 0; - - // The validation is still in process. - PENDING = 1; - - // The validation is done and the asset reference is valid. - VALID = 2; - - // The validation is done and the asset reference is invalid. - INVALID = 3; - } - - // Output only. A unique identifier among asset references in a product. - string id = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The human-readable description of the referenced asset. Maximum 256 - // characters in length. - string description = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The definition of input parameters to hydrate the asset template. - Inputs inputs = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The current state of the asset reference. - AssetValidationState validation_status = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The validation process metadata. - google.longrunning.Operation validation_operation = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The destination of the asset. - oneof source { - // Output only. The asset resource name if an asset is hosted by Private Catalog. - string asset = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The cloud storage object path. - string gcs_path = 11 [ - deprecated = true, - (google.api.field_behavior) = OUTPUT_ONLY - ]; - - // Output only. The git source. - GitSource git_source = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; - } - - // Output only. The cloud storage source. - GcsSource gcs_source = 16 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The creation timestamp of the asset reference. - google.protobuf.Timestamp create_time = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The last update timestamp of the asset reference. - google.protobuf.Timestamp update_time = 13 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The version of the source used for this asset reference. - string version = 14 [deprecated = true]; -} - -// Defines definition of input parameters of asset templates. -message Inputs { - // Output only. The JSON schema defining the inputs and their formats. - google.protobuf.Struct parameters = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Defines how to access Cloud Storage source. -message GcsSource { - // Output only. the cloud storage object path. - string gcs_path = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Generation of the object, which is set when the content of an object starts - // being written. - int64 generation = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time when the object metadata was last changed. - google.protobuf.Timestamp update_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Defines how to access a Git Source. -message GitSource { - // Location of the Git repo to build. - string repo = 1; - - // Directory, relative to the source root, in which to run the build. - // - // This must be a relative path. If a step's `dir` is specified and is an - // absolute path, this value is ignored for that step's execution. - string dir = 2; - - // The revision to fetch from the Git repository such as a branch, a tag, a - // commit SHA, or any Git ref. - oneof ref { - // The revision commit to use. - string commit = 3; - - // The revision branch to use. - string branch = 4; - - // The revision tag to use. - string tag = 5; - } -} - -// The consumer representation of a version which is a child resource under a -// `Product` with asset data. -message Version { - option (google.api.resource) = { - type: "cloudprivatecatalog.googleapis.com/Version" - pattern: "catalogs/{catalog}/products/{product}/versions/{version}" - }; - - // Output only. The resource name of the version, in the format - // `catalogs/{catalog}/products/{product}/versions/[a-z][-a-z0-9]*[a-z0-9]'. - // - // A unique identifier for the version under a product. - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The user-supplied description of the version. Maximum of 256 - // characters. - string description = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The asset which has been validated and is ready to be - // provisioned. See - // [google.cloud.privatecatalogproducer.v1beta.Version.asset][] for details. - google.protobuf.Struct asset = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time when the version was created. - google.protobuf.Timestamp create_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time when the version was last updated. - google.protobuf.Timestamp update_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_catalogs.js b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_catalogs.js deleted file mode 100644 index 7b53967a42d..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_catalogs.js +++ /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. ** - - - -'use strict'; - -function main(resource) { - // [START cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchCatalogs_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 resource context. It can be in following formats: - * * `projects/{project}` - * * `folders/{folder}` - * * `organizations/{organization}` - */ - // const resource = 'abc123' - /** - * The query to filter the catalogs. The supported queries are: - * * Get a single catalog: `name=catalogs/{catalog}` - */ - // const query = 'abc123' - /** - * The maximum number of entries that are requested. - */ - // const pageSize = 1234 - /** - * A pagination token returned from a previous call to SearchCatalogs that - * indicates where this listing should continue from. - */ - // const pageToken = 'abc123' - - // Imports the Privatecatalog library - const {PrivateCatalogClient} = require('@google-cloud/private-catalog').v1beta1; - - // Instantiates a client - const privatecatalogClient = new PrivateCatalogClient(); - - async function callSearchCatalogs() { - // Construct request - const request = { - resource, - }; - - // Run request - const iterable = await privatecatalogClient.searchCatalogsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callSearchCatalogs(); - // [END cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchCatalogs_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_products.js b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_products.js deleted file mode 100644 index 7dd109ea62a..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_products.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(resource) { - // [START cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchProducts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 resource context. See SearchCatalogsRequest.resource google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource - * for details. - */ - // const resource = 'abc123' - /** - * The query to filter the products. - * The supported queries are: - * * List products of all catalogs: empty - * * List products under a catalog: `parent=catalogs/{catalog}` - * * Get a product by name: - * `name=catalogs/{catalog}/products/{product}` - */ - // const query = 'abc123' - /** - * The maximum number of entries that are requested. - */ - // const pageSize = 1234 - /** - * A pagination token returned from a previous call to SearchProducts that - * indicates where this listing should continue from. - */ - // const pageToken = 'abc123' - - // Imports the Privatecatalog library - const {PrivateCatalogClient} = require('@google-cloud/private-catalog').v1beta1; - - // Instantiates a client - const privatecatalogClient = new PrivateCatalogClient(); - - async function callSearchProducts() { - // Construct request - const request = { - resource, - }; - - // Run request - const iterable = await privatecatalogClient.searchProductsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callSearchProducts(); - // [END cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_versions.js b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_versions.js deleted file mode 100644 index 4ebfd5bf29b..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/private_catalog.search_versions.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(resource, query) { - // [START cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchVersions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 resource context. See SearchCatalogsRequest.resource google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource - * for details. - */ - // const resource = 'abc123' - /** - * Required. The query to filter the versions. - * The supported queries are: - * * List versions under a product: - * `parent=catalogs/{catalog}/products/{product}` - * * Get a version by name: - * `name=catalogs/{catalog}/products/{product}/versions/{version}` - */ - // const query = 'abc123' - /** - * The maximum number of entries that are requested. - */ - // const pageSize = 1234 - /** - * A pagination token returned from a previous call to SearchVersions - * that indicates where this listing should continue from. - */ - // const pageToken = 'abc123' - - // Imports the Privatecatalog library - const {PrivateCatalogClient} = require('@google-cloud/private-catalog').v1beta1; - - // Instantiates a client - const privatecatalogClient = new PrivateCatalogClient(); - - async function callSearchVersions() { - // Construct request - const request = { - resource, - query, - }; - - // Run request - const iterable = await privatecatalogClient.searchVersionsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callSearchVersions(); - // [END cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchVersions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.privatecatalog.v1beta1.json b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.privatecatalog.v1beta1.json deleted file mode 100644 index fabcb9253d9..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.privatecatalog.v1beta1.json +++ /dev/null @@ -1,171 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-privatecatalog", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.privatecatalog.v1beta1", - "version": "v1beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchCatalogs_async", - "title": "PrivateCatalog searchCatalogs Sample", - "origin": "API_DEFINITION", - "description": " Search [Catalog][google.cloud.privatecatalog.v1beta1.Catalog] resources that consumers have access to, within the scope of the consumer cloud resource hierarchy context.", - "canonical": true, - "file": "private_catalog.search_catalogs.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SearchCatalogs", - "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchCatalogs", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.privatecatalog.v1beta1.SearchCatalogsResponse", - "client": { - "shortName": "PrivateCatalogClient", - "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalogClient" - }, - "method": { - "shortName": "SearchCatalogs", - "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchCatalogs", - "service": { - "shortName": "PrivateCatalog", - "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog" - } - } - } - }, - { - "regionTag": "cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchProducts_async", - "title": "PrivateCatalog searchProducts Sample", - "origin": "API_DEFINITION", - "description": " Search [Product][google.cloud.privatecatalog.v1beta1.Product] resources that consumers have access to, within the scope of the consumer cloud resource hierarchy context.", - "canonical": true, - "file": "private_catalog.search_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 74, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SearchProducts", - "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchProducts", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.privatecatalog.v1beta1.SearchProductsResponse", - "client": { - "shortName": "PrivateCatalogClient", - "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalogClient" - }, - "method": { - "shortName": "SearchProducts", - "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchProducts", - "service": { - "shortName": "PrivateCatalog", - "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog" - } - } - } - }, - { - "regionTag": "cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchVersions_async", - "title": "PrivateCatalog searchVersions Sample", - "origin": "API_DEFINITION", - "description": " Search [Version][google.cloud.privatecatalog.v1beta1.Version] resources that consumers have access to, within the scope of the consumer cloud resource hierarchy context.", - "canonical": true, - "file": "private_catalog.search_versions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 75, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SearchVersions", - "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchVersions", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.privatecatalog.v1beta1.SearchVersionsResponse", - "client": { - "shortName": "PrivateCatalogClient", - "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalogClient" - }, - "method": { - "shortName": "SearchVersions", - "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchVersions", - "service": { - "shortName": "PrivateCatalog", - "fullName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/index.ts deleted file mode 100644 index b270b97e185..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/index.ts +++ /dev/null @@ -1,25 +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 v1beta1 from './v1beta1'; -const PrivateCatalogClient = v1beta1.PrivateCatalogClient; -type PrivateCatalogClient = v1beta1.PrivateCatalogClient; -export {v1beta1, PrivateCatalogClient}; -export default {v1beta1, PrivateCatalogClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/gapic_metadata.json deleted file mode 100644 index 191f515a726..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/gapic_metadata.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.privatecatalog.v1beta1", - "libraryPackage": "@google-cloud/private-catalog", - "services": { - "PrivateCatalog": { - "clients": { - "grpc": { - "libraryClient": "PrivateCatalogClient", - "rpcs": { - "SearchCatalogs": { - "methods": [ - "searchCatalogs", - "searchCatalogsStream", - "searchCatalogsAsync" - ] - }, - "SearchProducts": { - "methods": [ - "searchProducts", - "searchProductsStream", - "searchProductsAsync" - ] - }, - "SearchVersions": { - "methods": [ - "searchVersions", - "searchVersionsStream", - "searchVersionsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "PrivateCatalogClient", - "rpcs": { - "SearchCatalogs": { - "methods": [ - "searchCatalogs", - "searchCatalogsStream", - "searchCatalogsAsync" - ] - }, - "SearchProducts": { - "methods": [ - "searchProducts", - "searchProductsStream", - "searchProductsAsync" - ] - }, - "SearchVersions": { - "methods": [ - "searchVersions", - "searchVersionsStream", - "searchVersionsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/index.ts deleted file mode 100644 index b81fb955db1..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/index.ts +++ /dev/null @@ -1,19 +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 {PrivateCatalogClient} from './private_catalog_client'; diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_client.ts b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_client.ts deleted file mode 100644 index 67334899b08..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_client.ts +++ /dev/null @@ -1,1053 +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, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta1/private_catalog_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './private_catalog_client_config.json'; -const version = require('../../../package.json').version; - -/** - * `PrivateCatalog` allows catalog consumers to retrieve `Catalog`, `Product` - * and `Version` resources under a target resource context. - * - * `Catalog` is computed based on the {@link protos.|Association}s linked to the target - * resource and its ancestors. Each association's - * {@link protos.|google.cloud.privatecatalogproducer.v1beta.Catalog} is transformed into a - * `Catalog`. If multiple associations have the same parent - * {@link protos.|google.cloud.privatecatalogproducer.v1beta.Catalog}, they are - * de-duplicated into one `Catalog`. Users must have - * `cloudprivatecatalog.catalogTargets.get` IAM permission on the resource - * context in order to access catalogs. `Catalog` contains the resource name and - * a subset of data of the original - * {@link protos.|google.cloud.privatecatalogproducer.v1beta.Catalog}. - * - * `Product` is child resource of the catalog. A `Product` contains the resource - * name and a subset of the data of the original - * {@link protos.|google.cloud.privatecatalogproducer.v1beta.Product}. - * - * `Version` is child resource of the product. A `Version` contains the resource - * name and a subset of the data of the original - * {@link protos.|google.cloud.privatecatalogproducer.v1beta.Version}. - * @class - * @memberof v1beta1 - */ -export class PrivateCatalogClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - privateCatalogStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of PrivateCatalogClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 PrivateCatalogClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof PrivateCatalogClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'catalogs/{catalog}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'products/{product}' - ), - versionPathTemplate: new this._gaxModule.PathTemplate( - 'catalogs/{catalog}/products/{product}/versions/{version}' - ), - }; - - // 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 = { - searchCatalogs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'catalogs'), - searchProducts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), - searchVersions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'versions') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.privatecatalog.v1beta1.PrivateCatalog', 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.privateCatalogStub) { - return this.privateCatalogStub; - } - - // Put together the "service stub" for - // google.cloud.privatecatalog.v1beta1.PrivateCatalog. - this.privateCatalogStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.privatecatalog.v1beta1.PrivateCatalog') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.privatecatalog.v1beta1.PrivateCatalog, - 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 privateCatalogStubMethods = - ['searchCatalogs', 'searchProducts', 'searchVersions']; - for (const methodName of privateCatalogStubMethods) { - const callPromise = this.privateCatalogStub.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.privateCatalogStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudprivatecatalog.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 'cloudprivatecatalog.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 -- - // ------------------- - - /** - * Search {@link protos.google.cloud.privatecatalog.v1beta1.Catalog|Catalog} resources that consumers have access to, within the - * scope of the consumer cloud resource hierarchy context. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * Required. The name of the resource context. It can be in following formats: - * - * * `projects/{project}` - * * `folders/{folder}` - * * `organizations/{organization}` - * @param {string} request.query - * The query to filter the catalogs. The supported queries are: - * - * * Get a single catalog: `name=catalogs/{catalog}` - * @param {number} request.pageSize - * The maximum number of entries that are requested. - * @param {string} request.pageToken - * A pagination token returned from a previous call to SearchCatalogs that - * indicates where this listing should continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.privatecatalog.v1beta1.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 `searchCatalogsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - searchCatalogs( - request?: protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.privatecatalog.v1beta1.ICatalog[], - protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest|null, - protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsResponse - ]>; - searchCatalogs( - request: protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest, - protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsResponse|null|undefined, - protos.google.cloud.privatecatalog.v1beta1.ICatalog>): void; - searchCatalogs( - request: protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest, - callback: PaginationCallback< - protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest, - protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsResponse|null|undefined, - protos.google.cloud.privatecatalog.v1beta1.ICatalog>): void; - searchCatalogs( - request?: protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest, - protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsResponse|null|undefined, - protos.google.cloud.privatecatalog.v1beta1.ICatalog>, - callback?: PaginationCallback< - protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest, - protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsResponse|null|undefined, - protos.google.cloud.privatecatalog.v1beta1.ICatalog>): - Promise<[ - protos.google.cloud.privatecatalog.v1beta1.ICatalog[], - protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest|null, - protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.searchCatalogs(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.resource - * Required. The name of the resource context. It can be in following formats: - * - * * `projects/{project}` - * * `folders/{folder}` - * * `organizations/{organization}` - * @param {string} request.query - * The query to filter the catalogs. The supported queries are: - * - * * Get a single catalog: `name=catalogs/{catalog}` - * @param {number} request.pageSize - * The maximum number of entries that are requested. - * @param {string} request.pageToken - * A pagination token returned from a previous call to SearchCatalogs that - * indicates where this listing should continue from. - * @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 protos.google.cloud.privatecatalog.v1beta1.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 `searchCatalogsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - searchCatalogsStream( - request?: protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest, - 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({ - 'resource': request.resource ?? '', - }); - const defaultCallSettings = this._defaults['searchCatalogs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchCatalogs.createStream( - this.innerApiCalls.searchCatalogs as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `searchCatalogs`, 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.resource - * Required. The name of the resource context. It can be in following formats: - * - * * `projects/{project}` - * * `folders/{folder}` - * * `organizations/{organization}` - * @param {string} request.query - * The query to filter the catalogs. The supported queries are: - * - * * Get a single catalog: `name=catalogs/{catalog}` - * @param {number} request.pageSize - * The maximum number of entries that are requested. - * @param {string} request.pageToken - * A pagination token returned from a previous call to SearchCatalogs that - * indicates where this listing should continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.privatecatalog.v1beta1.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/private_catalog.search_catalogs.js - * region_tag:cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchCatalogs_async - */ - searchCatalogsAsync( - request?: protos.google.cloud.privatecatalog.v1beta1.ISearchCatalogsRequest, - 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({ - 'resource': request.resource ?? '', - }); - const defaultCallSettings = this._defaults['searchCatalogs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchCatalogs.asyncIterate( - this.innerApiCalls['searchCatalogs'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Search {@link protos.google.cloud.privatecatalog.v1beta1.Product|Product} resources that consumers have access to, within the - * scope of the consumer cloud resource hierarchy context. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * Required. The name of the resource context. See {@link protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource|SearchCatalogsRequest.resource} - * for details. - * @param {string} request.query - * The query to filter the products. - * - * The supported queries are: - * * List products of all catalogs: empty - * * List products under a catalog: `parent=catalogs/{catalog}` - * * Get a product by name: - * `name=catalogs/{catalog}/products/{product}` - * @param {number} request.pageSize - * The maximum number of entries that are requested. - * @param {string} request.pageToken - * A pagination token returned from a previous call to SearchProducts that - * indicates where this listing should continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.privatecatalog.v1beta1.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 `searchProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - searchProducts( - request?: protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.privatecatalog.v1beta1.IProduct[], - protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest|null, - protos.google.cloud.privatecatalog.v1beta1.ISearchProductsResponse - ]>; - searchProducts( - request: protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest, - protos.google.cloud.privatecatalog.v1beta1.ISearchProductsResponse|null|undefined, - protos.google.cloud.privatecatalog.v1beta1.IProduct>): void; - searchProducts( - request: protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest, - callback: PaginationCallback< - protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest, - protos.google.cloud.privatecatalog.v1beta1.ISearchProductsResponse|null|undefined, - protos.google.cloud.privatecatalog.v1beta1.IProduct>): void; - searchProducts( - request?: protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest, - protos.google.cloud.privatecatalog.v1beta1.ISearchProductsResponse|null|undefined, - protos.google.cloud.privatecatalog.v1beta1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest, - protos.google.cloud.privatecatalog.v1beta1.ISearchProductsResponse|null|undefined, - protos.google.cloud.privatecatalog.v1beta1.IProduct>): - Promise<[ - protos.google.cloud.privatecatalog.v1beta1.IProduct[], - protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest|null, - protos.google.cloud.privatecatalog.v1beta1.ISearchProductsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.searchProducts(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.resource - * Required. The name of the resource context. See {@link protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource|SearchCatalogsRequest.resource} - * for details. - * @param {string} request.query - * The query to filter the products. - * - * The supported queries are: - * * List products of all catalogs: empty - * * List products under a catalog: `parent=catalogs/{catalog}` - * * Get a product by name: - * `name=catalogs/{catalog}/products/{product}` - * @param {number} request.pageSize - * The maximum number of entries that are requested. - * @param {string} request.pageToken - * A pagination token returned from a previous call to SearchProducts that - * indicates where this listing should continue from. - * @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 protos.google.cloud.privatecatalog.v1beta1.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 `searchProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - searchProductsStream( - request?: protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest, - 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({ - 'resource': request.resource ?? '', - }); - const defaultCallSettings = this._defaults['searchProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchProducts.createStream( - this.innerApiCalls.searchProducts as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `searchProducts`, 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.resource - * Required. The name of the resource context. See {@link protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource|SearchCatalogsRequest.resource} - * for details. - * @param {string} request.query - * The query to filter the products. - * - * The supported queries are: - * * List products of all catalogs: empty - * * List products under a catalog: `parent=catalogs/{catalog}` - * * Get a product by name: - * `name=catalogs/{catalog}/products/{product}` - * @param {number} request.pageSize - * The maximum number of entries that are requested. - * @param {string} request.pageToken - * A pagination token returned from a previous call to SearchProducts that - * indicates where this listing should continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.privatecatalog.v1beta1.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/private_catalog.search_products.js - * region_tag:cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchProducts_async - */ - searchProductsAsync( - request?: protos.google.cloud.privatecatalog.v1beta1.ISearchProductsRequest, - 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({ - 'resource': request.resource ?? '', - }); - const defaultCallSettings = this._defaults['searchProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchProducts.asyncIterate( - this.innerApiCalls['searchProducts'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Search {@link protos.google.cloud.privatecatalog.v1beta1.Version|Version} resources that consumers have access to, within the - * scope of the consumer cloud resource hierarchy context. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * Required. The name of the resource context. See {@link protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource|SearchCatalogsRequest.resource} - * for details. - * @param {string} request.query - * Required. The query to filter the versions. - * - * The supported queries are: - * * List versions under a product: - * `parent=catalogs/{catalog}/products/{product}` - * * Get a version by name: - * `name=catalogs/{catalog}/products/{product}/versions/{version}` - * @param {number} request.pageSize - * The maximum number of entries that are requested. - * @param {string} request.pageToken - * A pagination token returned from a previous call to SearchVersions - * that indicates where this listing should continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.privatecatalog.v1beta1.Version|Version}. - * 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 `searchVersionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - searchVersions( - request?: protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.privatecatalog.v1beta1.IVersion[], - protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest|null, - protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsResponse - ]>; - searchVersions( - request: protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest, - protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsResponse|null|undefined, - protos.google.cloud.privatecatalog.v1beta1.IVersion>): void; - searchVersions( - request: protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest, - callback: PaginationCallback< - protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest, - protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsResponse|null|undefined, - protos.google.cloud.privatecatalog.v1beta1.IVersion>): void; - searchVersions( - request?: protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest, - protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsResponse|null|undefined, - protos.google.cloud.privatecatalog.v1beta1.IVersion>, - callback?: PaginationCallback< - protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest, - protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsResponse|null|undefined, - protos.google.cloud.privatecatalog.v1beta1.IVersion>): - Promise<[ - protos.google.cloud.privatecatalog.v1beta1.IVersion[], - protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest|null, - protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.searchVersions(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.resource - * Required. The name of the resource context. See {@link protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource|SearchCatalogsRequest.resource} - * for details. - * @param {string} request.query - * Required. The query to filter the versions. - * - * The supported queries are: - * * List versions under a product: - * `parent=catalogs/{catalog}/products/{product}` - * * Get a version by name: - * `name=catalogs/{catalog}/products/{product}/versions/{version}` - * @param {number} request.pageSize - * The maximum number of entries that are requested. - * @param {string} request.pageToken - * A pagination token returned from a previous call to SearchVersions - * that indicates where this listing should continue from. - * @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 protos.google.cloud.privatecatalog.v1beta1.Version|Version} 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 `searchVersionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - searchVersionsStream( - request?: protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest, - 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({ - 'resource': request.resource ?? '', - }); - const defaultCallSettings = this._defaults['searchVersions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchVersions.createStream( - this.innerApiCalls.searchVersions as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `searchVersions`, 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.resource - * Required. The name of the resource context. See {@link protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource|SearchCatalogsRequest.resource} - * for details. - * @param {string} request.query - * Required. The query to filter the versions. - * - * The supported queries are: - * * List versions under a product: - * `parent=catalogs/{catalog}/products/{product}` - * * Get a version by name: - * `name=catalogs/{catalog}/products/{product}/versions/{version}` - * @param {number} request.pageSize - * The maximum number of entries that are requested. - * @param {string} request.pageToken - * A pagination token returned from a previous call to SearchVersions - * that indicates where this listing should continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.privatecatalog.v1beta1.Version|Version}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/private_catalog.search_versions.js - * region_tag:cloudprivatecatalog_v1beta1_generated_PrivateCatalog_SearchVersions_async - */ - searchVersionsAsync( - request?: protos.google.cloud.privatecatalog.v1beta1.ISearchVersionsRequest, - 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({ - 'resource': request.resource ?? '', - }); - const defaultCallSettings = this._defaults['searchVersions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchVersions.asyncIterate( - this.innerApiCalls['searchVersions'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - catalog: catalog, - }); - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(product:string) { - return this.pathTemplates.productPathTemplate.render({ - product: product, - }); - } - - /** - * 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 version resource name string. - * - * @param {string} catalog - * @param {string} product - * @param {string} version - * @returns {string} Resource name string. - */ - versionPath(catalog:string,product:string,version:string) { - return this.pathTemplates.versionPathTemplate.render({ - catalog: catalog, - product: product, - version: version, - }); - } - - /** - * Parse the catalog from Version resource. - * - * @param {string} versionName - * A fully-qualified path representing Version resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromVersionName(versionName: string) { - return this.pathTemplates.versionPathTemplate.match(versionName).catalog; - } - - /** - * Parse the product from Version resource. - * - * @param {string} versionName - * A fully-qualified path representing Version resource. - * @returns {string} A string representing the product. - */ - matchProductFromVersionName(versionName: string) { - return this.pathTemplates.versionPathTemplate.match(versionName).product; - } - - /** - * Parse the version from Version resource. - * - * @param {string} versionName - * A fully-qualified path representing Version resource. - * @returns {string} A string representing the version. - */ - matchVersionFromVersionName(versionName: string) { - return this.pathTemplates.versionPathTemplate.match(versionName).version; - } - - /** - * 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.privateCatalogStub && !this._terminated) { - return this.privateCatalogStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_client_config.json b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_client_config.json deleted file mode 100644 index 117c2f9dbce..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_client_config.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "interfaces": { - "google.cloud.privatecatalog.v1beta1.PrivateCatalog": { - "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": { - "SearchCatalogs": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "SearchProducts": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "SearchVersions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_proto_list.json b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_proto_list.json deleted file mode 100644 index 1803923fd85..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/src/v1beta1/private_catalog_proto_list.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "../../protos/google/cloud/privatecatalog/v1beta1/private_catalog.proto" -] diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 208f320b48b..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const privatecatalog = require('@google-cloud/private-catalog'); - -function main() { - const privateCatalogClient = new privatecatalog.PrivateCatalogClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index db703726a6d..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {PrivateCatalogClient} from '@google-cloud/private-catalog'; - -// check that the client class type name can be used -function doStuffWithPrivateCatalogClient(client: PrivateCatalogClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const privateCatalogClient = new PrivateCatalogClient(); - doStuffWithPrivateCatalogClient(privateCatalogClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/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-privatecatalog/v1beta1/test/gapic_private_catalog_v1beta1.ts b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/test/gapic_private_catalog_v1beta1.ts deleted file mode 100644 index d6def4f42c3..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/test/gapic_private_catalog_v1beta1.ts +++ /dev/null @@ -1,1041 +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 privatecatalogModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -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('v1beta1.PrivateCatalogClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = privatecatalogModule.v1beta1.PrivateCatalogClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = privatecatalogModule.v1beta1.PrivateCatalogClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = privatecatalogModule.v1beta1.PrivateCatalogClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.privateCatalogStub, undefined); - await client.initialize(); - assert(client.privateCatalogStub); - }); - - it('has close method for the initialized client', done => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.privateCatalogStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.privateCatalogStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - 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 privatecatalogModule.v1beta1.PrivateCatalogClient({ - 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('searchCatalogs', () => { - it('invokes searchCatalogs without error', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), - ]; - client.innerApiCalls.searchCatalogs = stubSimpleCall(expectedResponse); - const [response] = await client.searchCatalogs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchCatalogs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchCatalogs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes searchCatalogs without error using callback', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), - ]; - client.innerApiCalls.searchCatalogs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchCatalogs( - request, - (err?: Error|null, result?: protos.google.cloud.privatecatalog.v1beta1.ICatalog[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchCatalogs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchCatalogs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes searchCatalogs with error', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.searchCatalogs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchCatalogs(request), expectedError); - const actualRequest = (client.innerApiCalls.searchCatalogs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchCatalogs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes searchCatalogsStream without error', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), - ]; - client.descriptors.page.searchCatalogs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchCatalogsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.privatecatalog.v1beta1.Catalog[] = []; - stream.on('data', (response: protos.google.cloud.privatecatalog.v1beta1.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.searchCatalogs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchCatalogs, request)); - assert( - (client.descriptors.page.searchCatalogs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes searchCatalogsStream with error', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.searchCatalogs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchCatalogsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.privatecatalog.v1beta1.Catalog[] = []; - stream.on('data', (response: protos.google.cloud.privatecatalog.v1beta1.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.searchCatalogs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchCatalogs, request)); - assert( - (client.descriptors.page.searchCatalogs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with searchCatalogs without error', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Catalog()), - ]; - client.descriptors.page.searchCatalogs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.privatecatalog.v1beta1.ICatalog[] = []; - const iterable = client.searchCatalogsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchCatalogs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchCatalogs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with searchCatalogs with error', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.searchCatalogs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchCatalogsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.privatecatalog.v1beta1.ICatalog[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchCatalogs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchCatalogs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('searchProducts', () => { - it('invokes searchProducts without error', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.privatecatalog.v1beta1.SearchProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchProductsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), - ]; - client.innerApiCalls.searchProducts = stubSimpleCall(expectedResponse); - const [response] = await client.searchProducts(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes searchProducts without error using callback', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.privatecatalog.v1beta1.SearchProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchProductsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), - ]; - client.innerApiCalls.searchProducts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchProducts( - request, - (err?: Error|null, result?: protos.google.cloud.privatecatalog.v1beta1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes searchProducts with error', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.privatecatalog.v1beta1.SearchProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchProductsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.searchProducts = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchProducts(request), expectedError); - const actualRequest = (client.innerApiCalls.searchProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes searchProductsStream without error', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.privatecatalog.v1beta1.SearchProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchProductsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), - ]; - client.descriptors.page.searchProducts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.privatecatalog.v1beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.privatecatalog.v1beta1.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.searchProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchProducts, request)); - assert( - (client.descriptors.page.searchProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes searchProductsStream with error', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.privatecatalog.v1beta1.SearchProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchProductsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.searchProducts.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.privatecatalog.v1beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.privatecatalog.v1beta1.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.searchProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchProducts, request)); - assert( - (client.descriptors.page.searchProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with searchProducts without error', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.privatecatalog.v1beta1.SearchProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchProductsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Product()), - ]; - client.descriptors.page.searchProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.privatecatalog.v1beta1.IProduct[] = []; - const iterable = client.searchProductsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with searchProducts with error', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.privatecatalog.v1beta1.SearchProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchProductsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.searchProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchProductsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.privatecatalog.v1beta1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('searchVersions', () => { - it('invokes searchVersions without error', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), - ]; - client.innerApiCalls.searchVersions = stubSimpleCall(expectedResponse); - const [response] = await client.searchVersions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes searchVersions without error using callback', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), - ]; - client.innerApiCalls.searchVersions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchVersions( - request, - (err?: Error|null, result?: protos.google.cloud.privatecatalog.v1beta1.IVersion[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes searchVersions with error', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.searchVersions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchVersions(request), expectedError); - const actualRequest = (client.innerApiCalls.searchVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes searchVersionsStream without error', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), - ]; - client.descriptors.page.searchVersions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.privatecatalog.v1beta1.Version[] = []; - stream.on('data', (response: protos.google.cloud.privatecatalog.v1beta1.Version) => { - 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.searchVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchVersions, request)); - assert( - (client.descriptors.page.searchVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes searchVersionsStream with error', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.searchVersions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.privatecatalog.v1beta1.Version[] = []; - stream.on('data', (response: protos.google.cloud.privatecatalog.v1beta1.Version) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.searchVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchVersions, request)); - assert( - (client.descriptors.page.searchVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with searchVersions without error', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), - generateSampleMessage(new protos.google.cloud.privatecatalog.v1beta1.Version()), - ]; - client.descriptors.page.searchVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.privatecatalog.v1beta1.IVersion[] = []; - const iterable = client.searchVersionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with searchVersions with error', async () => { - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.privatecatalog.v1beta1.SearchVersionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.searchVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchVersionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.privatecatalog.v1beta1.IVersion[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - catalog: "catalogValue", - }; - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - 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("catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - product: "productValue", - }; - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - 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("productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('version', () => { - const fakePath = "/rendered/path/version"; - const expectedParameters = { - catalog: "catalogValue", - product: "productValue", - version: "versionValue", - }; - const client = new privatecatalogModule.v1beta1.PrivateCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.versionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.versionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('versionPath', () => { - const result = client.versionPath("catalogValue", "productValue", "versionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.versionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchCatalogFromVersionName', () => { - const result = client.matchCatalogFromVersionName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.versionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromVersionName', () => { - const result = client.matchProductFromVersionName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.versionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchVersionFromVersionName', () => { - const result = client.matchVersionFromVersionName(fakePath); - assert.strictEqual(result, "versionValue"); - assert((client.pathTemplates.versionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-privatecatalog/v1beta1/webpack.config.js deleted file mode 100644 index 23fa00eb490..00000000000 --- a/owl-bot-staging/google-cloud-privatecatalog/v1beta1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'PrivateCatalog', - filename: './private-catalog.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-rapidmigrationassessment/v1/.eslintignore b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.eslintrc.json b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.gitignore b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.jsdoc.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.jsdoc.js deleted file mode 100644 index ca6869617a6..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.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/rapidmigrationassessment', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.mocharc.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.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-rapidmigrationassessment/v1/.prettierrc.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/.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-rapidmigrationassessment/v1/README.md b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/README.md deleted file mode 100644 index d371ae35ec0..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Rapidmigrationassessment: Nodejs Client diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/package.json b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/package.json deleted file mode 100644 index f4379e51abe..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/rapidmigrationassessment", - "version": "0.1.0", - "description": "Rapidmigrationassessment client for Node.js", - "repository": "googleapis/nodejs-rapidmigrationassessment", - "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 rapidmigrationassessment", - "rapidmigrationassessment", - "rapid migration assessment" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/protos/google/cloud/rapidmigrationassessment/v1/api_entities.proto b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/protos/google/cloud/rapidmigrationassessment/v1/api_entities.proto deleted file mode 100644 index 54a3247c536..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/protos/google/cloud/rapidmigrationassessment/v1/api_entities.proto +++ /dev/null @@ -1,171 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.rapidmigrationassessment.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.RapidMigrationAssessment.V1"; -option go_package = "cloud.google.com/go/rapidmigrationassessment/apiv1/rapidmigrationassessmentpb;rapidmigrationassessmentpb"; -option java_multiple_files = true; -option java_outer_classname = "ApiEntitiesProto"; -option java_package = "com.google.cloud.rapidmigrationassessment.v1"; -option php_namespace = "Google\\Cloud\\RapidMigrationAssessment\\V1"; -option ruby_package = "Google::Cloud::RapidMigrationAssessment::V1"; - -// Message describing a MC Source of type Guest OS Scan. -message GuestOsScan { - // reference to the corresponding Guest OS Scan in MC Source. - string core_source = 1; -} - -// Message describing a MC Source of type VSphere Scan. -message VSphereScan { - // reference to the corresponding VSphere Scan in MC Source. - string core_source = 1; -} - -// Message describing Collector object. -message Collector { - option (google.api.resource) = { - type: "rapidmigrationassessment.googleapis.com/Collector" - pattern: "projects/{project}/locations/{location}/collectors/{collector}" - }; - - // -- Using suggestion from API Linter Analyzer for nesting enum -- - // -- https://linter.aip.dev/216/nesting -- - // State of a Collector (server_side). - // States are used for internal purposes and named to keep - // convention of legacy product: - // https://cloud.google.com/migrate/stratozone/docs/about-stratoprobe. - enum State { - // Collector state is not recognized. - STATE_UNSPECIFIED = 0; - - // Collector started to create, but hasn't been completed MC source creation - // and db object creation. - STATE_INITIALIZING = 1; - - // Collector has been created, MC source creation and db object creation - // completed. - STATE_READY_TO_USE = 2; - - // Collector client has been registered with client. - STATE_REGISTERED = 3; - - // Collector client is actively scanning. - STATE_ACTIVE = 4; - - // Collector is not actively scanning. - STATE_PAUSED = 5; - - // Collector is starting background job for deletion. - STATE_DELETING = 6; - - // Collector completed all tasks for deletion. - STATE_DECOMMISSIONED = 7; - - // Collector is in error state. - STATE_ERROR = 8; - } - - // name of resource. - string name = 1; - - // Output only. Create time stamp. - google.protobuf.Timestamp create_time = 2 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Update time stamp. - google.protobuf.Timestamp update_time = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Labels as key value pairs. - map labels = 4; - - // User specified name of the Collector. - string display_name = 5; - - // User specified description of the Collector. - string description = 6; - - // Service Account email used to ingest data to this Collector. - string service_account = 7; - - // Output only. Store cloud storage bucket name (which is a guid) created with - // this Collector. - string bucket = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // User specified expected asset count. - int64 expected_asset_count = 9; - - // Output only. State of the Collector. - State state = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Client version. - string client_version = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Reference to MC Source Guest Os Scan. - GuestOsScan guest_os_scan = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Reference to MC Source vsphere_scan. - VSphereScan vsphere_scan = 13 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // How many days to collect data. - int32 collection_days = 14; - - // Uri for EULA (End User License Agreement) from customer. - string eula_uri = 15; -} - -// Message describing an Annotation -message Annotation { - option (google.api.resource) = { - type: "rapidmigrationassessment.googleapis.com/Annotation" - pattern: "projects/{project}/locations/{location}/annotations/{annotation}" - }; - - // Types for project level setting. - enum Type { - // Unknown type - TYPE_UNSPECIFIED = 0; - - // Indicates that this project has opted into StratoZone export. - TYPE_LEGACY_EXPORT_CONSENT = 1; - - // Indicates that this project is created by Qwiklab. - TYPE_QWIKLAB = 2; - } - - // name of resource. - string name = 1; - - // Output only. Create time stamp. - google.protobuf.Timestamp create_time = 2 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Update time stamp. - google.protobuf.Timestamp update_time = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Labels as key value pairs. - map labels = 4; - - // Type of an annotation. - Type type = 5; -} diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/protos/google/cloud/rapidmigrationassessment/v1/rapidmigrationassessment.proto b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/protos/google/cloud/rapidmigrationassessment/v1/rapidmigrationassessment.proto deleted file mode 100644 index 4e4026efe04..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/protos/google/cloud/rapidmigrationassessment/v1/rapidmigrationassessment.proto +++ /dev/null @@ -1,421 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.rapidmigrationassessment.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/rapidmigrationassessment/v1/api_entities.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.RapidMigrationAssessment.V1"; -option go_package = "cloud.google.com/go/rapidmigrationassessment/apiv1/rapidmigrationassessmentpb;rapidmigrationassessmentpb"; -option java_multiple_files = true; -option java_outer_classname = "RapidMigrationAssessmentProto"; -option java_package = "com.google.cloud.rapidmigrationassessment.v1"; -option php_namespace = "Google\\Cloud\\RapidMigrationAssessment\\V1"; -option ruby_package = "Google::Cloud::RapidMigrationAssessment::V1"; - -// Rapid Migration Assessment service -service RapidMigrationAssessment { - option (google.api.default_host) = "rapidmigrationassessment.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Create a Collector to manage the on-prem appliance which collects - // information about Customer assets. - rpc CreateCollector(CreateCollectorRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/collectors" - body: "collector" - }; - option (google.api.method_signature) = "parent,collector,collector_id"; - option (google.longrunning.operation_info) = { - response_type: "Collector" - metadata_type: "OperationMetadata" - }; - } - - // Creates an Annotation - rpc CreateAnnotation(CreateAnnotationRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/annotations" - body: "annotation" - }; - option (google.api.method_signature) = "parent,annotation"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.rapidmigrationassessment.v1.Annotation" - metadata_type: "OperationMetadata" - }; - } - - // Gets details of a single Annotation. - rpc GetAnnotation(GetAnnotationRequest) returns (Annotation) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/annotations/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists Collectors in a given project and location. - rpc ListCollectors(ListCollectorsRequest) returns (ListCollectorsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/collectors" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets details of a single Collector. - rpc GetCollector(GetCollectorRequest) returns (Collector) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/collectors/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates the parameters of a single Collector. - rpc UpdateCollector(UpdateCollectorRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1/{collector.name=projects/*/locations/*/collectors/*}" - body: "collector" - }; - option (google.api.method_signature) = "collector,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "Collector" - metadata_type: "OperationMetadata" - }; - } - - // Deletes a single Collector - changes state of collector to "Deleting". - rpc DeleteCollector(DeleteCollectorRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/collectors/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Collector" - metadata_type: "OperationMetadata" - }; - } - - // Resumes the given collector. - rpc ResumeCollector(ResumeCollectorRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/collectors/*}:resume" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Collector" - metadata_type: "OperationMetadata" - }; - } - - // Registers the given collector. - rpc RegisterCollector(RegisterCollectorRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/collectors/*}:register" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Collector" - metadata_type: "OperationMetadata" - }; - } - - // Pauses the given collector. - rpc PauseCollector(PauseCollectorRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/collectors/*}:pause" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Collector" - metadata_type: "OperationMetadata" - }; - } -} - -// Message for creating an AnnotationS. -message CreateAnnotationRequest { - // Required. Name of the parent (project+location). - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The resource being created. - Annotation annotation = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. An optional request ID to identify requests. - string request_id = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// Message for getting a specific Annotation -message GetAnnotationRequest { - // Required. Name of the resource. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "rapidmigrationassessment.googleapis.com/Annotation" - } - ]; -} - -// Message for creating a Collector. -message CreateCollectorRequest { - // Required. Name of the parent (project+location). - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. Id of the requesting object. - string collector_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The resource being created. - Collector collector = 3 [(google.api.field_behavior) = REQUIRED]; - - // Optional. An optional request ID to identify requests. - string request_id = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// Message for requesting list of Collectors. -message ListCollectorsRequest { - // Required. Parent value for ListCollectorsRequest. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Requested page size. Server may return fewer items than requested. - // If unspecified, server will pick an appropriate default. - int32 page_size = 2; - - // A token identifying a page of results the server should return. - string page_token = 3; - - // Filtering results. - string filter = 4; - - // Hint for how to order the results. - string order_by = 5; -} - -// Message for response to listing Collectors. -message ListCollectorsResponse { - // The list of Collectors. - repeated Collector collectors = 1; - - // A token identifying a page of results the server should return. - string next_page_token = 2; - - // Locations that could not be reached. - repeated string unreachable = 3; -} - -// Message for getting a specific Collector. -message GetCollectorRequest { - // Required. Name of the resource. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "rapidmigrationassessment.googleapis.com/Collector" - } - ]; -} - -// Message for deleting a Collector. -message DeleteCollectorRequest { - // Required. Name of the resource. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "rapidmigrationassessment.googleapis.com/Collector" - } - ]; - - // Optional. An optional request ID to identify requests. Specify a unique - // request ID so that if you must retry your request, the server will know to - // ignore the request if it has already been completed. The server will - // guarantee that for at least 60 minutes after the first request. - // - // For example, consider a situation where you make an initial request and - // the request times out. If you make the request again with the same request - // ID, the server can check if original operation with the same request ID - // was received, and if so, will ignore the second request. This prevents - // clients from accidentally creating duplicate commitments. - // - // The request ID must be a valid UUID with the exception that zero UUID is - // not supported (00000000-0000-0000-0000-000000000000). - string request_id = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// Message for updating a Collector. -message UpdateCollectorRequest { - // Required. Field mask is used to specify the fields to be overwritten in the - // Collector resource by the update. - // The fields specified in the update_mask are relative to the resource, not - // the full request. A field will be overwritten if it is in the mask. If the - // user does not provide a mask then all fields will be overwritten. - google.protobuf.FieldMask update_mask = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. The resource being updated. - Collector collector = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. An optional request ID to identify requests. Specify a unique - // request ID so that if you must retry your request, the server will know to - // ignore the request if it has already been completed. The server will - // guarantee that for at least 60 minutes since the first request. - // - // For example, consider a situation where you make an initial request and - // the request times out. If you make the request again with the same request - // ID, the server can check if original operation with the same request ID - // was received, and if so, will ignore the second request. This prevents - // clients from accidentally creating duplicate commitments. - // - // The request ID must be a valid UUID with the exception that zero UUID is - // not supported (00000000-0000-0000-0000-000000000000). - string request_id = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Message for resuming a Collector. -message ResumeCollectorRequest { - // Required. Name of the resource. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "rapidmigrationassessment.googleapis.com/Collector" - } - ]; - - // Optional. An optional request ID to identify requests. Specify a unique - // request ID so that if you must retry your request, the server will know to - // ignore the request if it has already been completed. The server will - // guarantee that for at least 60 minutes after the first request. - // - // For example, consider a situation where you make an initial request and - // the request times out. If you make the request again with the same request - // ID, the server can check if original operation with the same request ID - // was received, and if so, will ignore the second request. This prevents - // clients from accidentally creating duplicate commitments. - // - // The request ID must be a valid UUID with the exception that zero UUID is - // not supported (00000000-0000-0000-0000-000000000000). - string request_id = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// Message for registering a Collector. -message RegisterCollectorRequest { - // Required. Name of the resource. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "rapidmigrationassessment.googleapis.com/Collector" - } - ]; - - // Optional. An optional request ID to identify requests. Specify a unique - // request ID so that if you must retry your request, the server will know to - // ignore the request if it has already been completed. The server will - // guarantee that for at least 60 minutes after the first request. - // - // For example, consider a situation where you make an initial request and - // the request times out. If you make the request again with the same request - // ID, the server can check if original operation with the same request ID - // was received, and if so, will ignore the second request. This prevents - // clients from accidentally creating duplicate commitments. - // - // The request ID must be a valid UUID with the exception that zero UUID is - // not supported (00000000-0000-0000-0000-000000000000). - string request_id = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// Message for pausing a Collector. -message PauseCollectorRequest { - // Required. Name of the resource. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "rapidmigrationassessment.googleapis.com/Collector" - } - ]; - - // Optional. An optional request ID to identify requests. Specify a unique - // request ID so that if you must retry your request, the server will know to - // ignore the request if it has already been completed. The server will - // guarantee that for at least 60 minutes after the first request. - // - // For example, consider a situation where you make an initial request and - // the request times out. If you make the request again with the same request - // ID, the server can check if original operation with the same request ID - // was received, and if so, will ignore the second request. This prevents - // clients from accidentally creating duplicate commitments. - // - // The request ID must be a valid UUID with the exception that zero UUID is - // not supported (00000000-0000-0000-0000-000000000000). - string request_id = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// Represents the metadata of the long-running operation. -message OperationMetadata { - // Output only. The time the operation was created. - google.protobuf.Timestamp create_time = 1 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time the operation finished running. - google.protobuf.Timestamp end_time = 2 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Server-defined resource path for the target of the operation. - string target = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Name of the verb executed by the operation. - string verb = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Human-readable status of the operation, if any. - string status_message = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Identifies whether the user has requested cancellation - // of the operation. Operations that have successfully been cancelled - // have [Operation.error][] value with a - // [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to - // `Code.CANCELLED`. - bool requested_cancellation = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. API version used to start the operation. - string api_version = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.create_annotation.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.create_annotation.js deleted file mode 100644 index 8c36b454cac..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.create_annotation.js +++ /dev/null @@ -1,71 +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, annotation) { - // [START rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateAnnotation_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the parent (project+location). - */ - // const parent = 'abc123' - /** - * Required. The resource being created. - */ - // const annotation = {} - /** - * Optional. An optional request ID to identify requests. - */ - // const requestId = 'abc123' - - // Imports the Rapidmigrationassessment library - const {RapidMigrationAssessmentClient} = require('@google-cloud/rapidmigrationassessment').v1; - - // Instantiates a client - const rapidmigrationassessmentClient = new RapidMigrationAssessmentClient(); - - async function callCreateAnnotation() { - // Construct request - const request = { - parent, - annotation, - }; - - // Run request - const [operation] = await rapidmigrationassessmentClient.createAnnotation(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateAnnotation(); - // [END rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateAnnotation_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.create_collector.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.create_collector.js deleted file mode 100644 index 17da48ec980..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.create_collector.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, collectorId, collector) { - // [START rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateCollector_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the parent (project+location). - */ - // const parent = 'abc123' - /** - * Required. Id of the requesting object. - */ - // const collectorId = 'abc123' - /** - * Required. The resource being created. - */ - // const collector = {} - /** - * Optional. An optional request ID to identify requests. - */ - // const requestId = 'abc123' - - // Imports the Rapidmigrationassessment library - const {RapidMigrationAssessmentClient} = require('@google-cloud/rapidmigrationassessment').v1; - - // Instantiates a client - const rapidmigrationassessmentClient = new RapidMigrationAssessmentClient(); - - async function callCreateCollector() { - // Construct request - const request = { - parent, - collectorId, - collector, - }; - - // Run request - const [operation] = await rapidmigrationassessmentClient.createCollector(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateCollector(); - // [END rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateCollector_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.delete_collector.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.delete_collector.js deleted file mode 100644 index c7504e2980b..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.delete_collector.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(name) { - // [START rapidmigrationassessment_v1_generated_RapidMigrationAssessment_DeleteCollector_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the resource. - */ - // const name = 'abc123' - /** - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - */ - // const requestId = 'abc123' - - // Imports the Rapidmigrationassessment library - const {RapidMigrationAssessmentClient} = require('@google-cloud/rapidmigrationassessment').v1; - - // Instantiates a client - const rapidmigrationassessmentClient = new RapidMigrationAssessmentClient(); - - async function callDeleteCollector() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await rapidmigrationassessmentClient.deleteCollector(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteCollector(); - // [END rapidmigrationassessment_v1_generated_RapidMigrationAssessment_DeleteCollector_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.get_annotation.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.get_annotation.js deleted file mode 100644 index 44abe364031..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.get_annotation.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(name) { - // [START rapidmigrationassessment_v1_generated_RapidMigrationAssessment_GetAnnotation_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the resource. - */ - // const name = 'abc123' - - // Imports the Rapidmigrationassessment library - const {RapidMigrationAssessmentClient} = require('@google-cloud/rapidmigrationassessment').v1; - - // Instantiates a client - const rapidmigrationassessmentClient = new RapidMigrationAssessmentClient(); - - async function callGetAnnotation() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await rapidmigrationassessmentClient.getAnnotation(request); - console.log(response); - } - - callGetAnnotation(); - // [END rapidmigrationassessment_v1_generated_RapidMigrationAssessment_GetAnnotation_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.get_collector.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.get_collector.js deleted file mode 100644 index a4948a4a784..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.get_collector.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(name) { - // [START rapidmigrationassessment_v1_generated_RapidMigrationAssessment_GetCollector_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the resource. - */ - // const name = 'abc123' - - // Imports the Rapidmigrationassessment library - const {RapidMigrationAssessmentClient} = require('@google-cloud/rapidmigrationassessment').v1; - - // Instantiates a client - const rapidmigrationassessmentClient = new RapidMigrationAssessmentClient(); - - async function callGetCollector() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await rapidmigrationassessmentClient.getCollector(request); - console.log(response); - } - - callGetCollector(); - // [END rapidmigrationassessment_v1_generated_RapidMigrationAssessment_GetCollector_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.list_collectors.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.list_collectors.js deleted file mode 100644 index 106c18dadfa..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.list_collectors.js +++ /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. ** - - - -'use strict'; - -function main(parent) { - // [START rapidmigrationassessment_v1_generated_RapidMigrationAssessment_ListCollectors_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Parent value for ListCollectorsRequest. - */ - // const parent = 'abc123' - /** - * Requested page size. Server may return fewer items than requested. - * If unspecified, server will pick an appropriate default. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results the server should return. - */ - // const pageToken = 'abc123' - /** - * Filtering results. - */ - // const filter = 'abc123' - /** - * Hint for how to order the results. - */ - // const orderBy = 'abc123' - - // Imports the Rapidmigrationassessment library - const {RapidMigrationAssessmentClient} = require('@google-cloud/rapidmigrationassessment').v1; - - // Instantiates a client - const rapidmigrationassessmentClient = new RapidMigrationAssessmentClient(); - - async function callListCollectors() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await rapidmigrationassessmentClient.listCollectorsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListCollectors(); - // [END rapidmigrationassessment_v1_generated_RapidMigrationAssessment_ListCollectors_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.pause_collector.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.pause_collector.js deleted file mode 100644 index 3035bbf3654..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.pause_collector.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(name) { - // [START rapidmigrationassessment_v1_generated_RapidMigrationAssessment_PauseCollector_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the resource. - */ - // const name = 'abc123' - /** - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - */ - // const requestId = 'abc123' - - // Imports the Rapidmigrationassessment library - const {RapidMigrationAssessmentClient} = require('@google-cloud/rapidmigrationassessment').v1; - - // Instantiates a client - const rapidmigrationassessmentClient = new RapidMigrationAssessmentClient(); - - async function callPauseCollector() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await rapidmigrationassessmentClient.pauseCollector(request); - const [response] = await operation.promise(); - console.log(response); - } - - callPauseCollector(); - // [END rapidmigrationassessment_v1_generated_RapidMigrationAssessment_PauseCollector_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.register_collector.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.register_collector.js deleted file mode 100644 index 87b3025700b..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.register_collector.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(name) { - // [START rapidmigrationassessment_v1_generated_RapidMigrationAssessment_RegisterCollector_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the resource. - */ - // const name = 'abc123' - /** - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - */ - // const requestId = 'abc123' - - // Imports the Rapidmigrationassessment library - const {RapidMigrationAssessmentClient} = require('@google-cloud/rapidmigrationassessment').v1; - - // Instantiates a client - const rapidmigrationassessmentClient = new RapidMigrationAssessmentClient(); - - async function callRegisterCollector() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await rapidmigrationassessmentClient.registerCollector(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRegisterCollector(); - // [END rapidmigrationassessment_v1_generated_RapidMigrationAssessment_RegisterCollector_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.resume_collector.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.resume_collector.js deleted file mode 100644 index d8610ae25a9..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.resume_collector.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(name) { - // [START rapidmigrationassessment_v1_generated_RapidMigrationAssessment_ResumeCollector_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the resource. - */ - // const name = 'abc123' - /** - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - */ - // const requestId = 'abc123' - - // Imports the Rapidmigrationassessment library - const {RapidMigrationAssessmentClient} = require('@google-cloud/rapidmigrationassessment').v1; - - // Instantiates a client - const rapidmigrationassessmentClient = new RapidMigrationAssessmentClient(); - - async function callResumeCollector() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await rapidmigrationassessmentClient.resumeCollector(request); - const [response] = await operation.promise(); - console.log(response); - } - - callResumeCollector(); - // [END rapidmigrationassessment_v1_generated_RapidMigrationAssessment_ResumeCollector_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.update_collector.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.update_collector.js deleted file mode 100644 index 0f957714578..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/rapid_migration_assessment.update_collector.js +++ /dev/null @@ -1,85 +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(updateMask, collector) { - // [START rapidmigrationassessment_v1_generated_RapidMigrationAssessment_UpdateCollector_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Field mask is used to specify the fields to be overwritten in the - * Collector resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - */ - // const updateMask = {} - /** - * Required. The resource being updated. - */ - // const collector = {} - /** - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - */ - // const requestId = 'abc123' - - // Imports the Rapidmigrationassessment library - const {RapidMigrationAssessmentClient} = require('@google-cloud/rapidmigrationassessment').v1; - - // Instantiates a client - const rapidmigrationassessmentClient = new RapidMigrationAssessmentClient(); - - async function callUpdateCollector() { - // Construct request - const request = { - updateMask, - collector, - }; - - // Run request - const [operation] = await rapidmigrationassessmentClient.updateCollector(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateCollector(); - // [END rapidmigrationassessment_v1_generated_RapidMigrationAssessment_UpdateCollector_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/snippet_metadata_google.cloud.rapidmigrationassessment.v1.json b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/snippet_metadata_google.cloud.rapidmigrationassessment.v1.json deleted file mode 100644 index 529df2f36b2..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/samples/generated/v1/snippet_metadata_google.cloud.rapidmigrationassessment.v1.json +++ /dev/null @@ -1,475 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-rapidmigrationassessment", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.rapidmigrationassessment.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateCollector_async", - "title": "RapidMigrationAssessment createCollector Sample", - "origin": "API_DEFINITION", - "description": " Create a Collector to manage the on-prem appliance which collects information about Customer assets.", - "canonical": true, - "file": "rapid_migration_assessment.create_collector.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateCollector", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.CreateCollector", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "collector_id", - "type": "TYPE_STRING" - }, - { - "name": "collector", - "type": ".google.cloud.rapidmigrationassessment.v1.Collector" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "RapidMigrationAssessmentClient", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient" - }, - "method": { - "shortName": "CreateCollector", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.CreateCollector", - "service": { - "shortName": "RapidMigrationAssessment", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment" - } - } - } - }, - { - "regionTag": "rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateAnnotation_async", - "title": "RapidMigrationAssessment createAnnotation Sample", - "origin": "API_DEFINITION", - "description": " Creates an Annotation", - "canonical": true, - "file": "rapid_migration_assessment.create_annotation.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateAnnotation", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.CreateAnnotation", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "annotation", - "type": ".google.cloud.rapidmigrationassessment.v1.Annotation" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "RapidMigrationAssessmentClient", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient" - }, - "method": { - "shortName": "CreateAnnotation", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.CreateAnnotation", - "service": { - "shortName": "RapidMigrationAssessment", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment" - } - } - } - }, - { - "regionTag": "rapidmigrationassessment_v1_generated_RapidMigrationAssessment_GetAnnotation_async", - "title": "RapidMigrationAssessment getAnnotation Sample", - "origin": "API_DEFINITION", - "description": " Gets details of a single Annotation.", - "canonical": true, - "file": "rapid_migration_assessment.get_annotation.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetAnnotation", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.GetAnnotation", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.rapidmigrationassessment.v1.Annotation", - "client": { - "shortName": "RapidMigrationAssessmentClient", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient" - }, - "method": { - "shortName": "GetAnnotation", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.GetAnnotation", - "service": { - "shortName": "RapidMigrationAssessment", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment" - } - } - } - }, - { - "regionTag": "rapidmigrationassessment_v1_generated_RapidMigrationAssessment_ListCollectors_async", - "title": "RapidMigrationAssessment listCollectors Sample", - "origin": "API_DEFINITION", - "description": " Lists Collectors in a given project and location.", - "canonical": true, - "file": "rapid_migration_assessment.list_collectors.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListCollectors", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.ListCollectors", - "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": "order_by", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.rapidmigrationassessment.v1.ListCollectorsResponse", - "client": { - "shortName": "RapidMigrationAssessmentClient", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient" - }, - "method": { - "shortName": "ListCollectors", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.ListCollectors", - "service": { - "shortName": "RapidMigrationAssessment", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment" - } - } - } - }, - { - "regionTag": "rapidmigrationassessment_v1_generated_RapidMigrationAssessment_GetCollector_async", - "title": "RapidMigrationAssessment getCollector Sample", - "origin": "API_DEFINITION", - "description": " Gets details of a single Collector.", - "canonical": true, - "file": "rapid_migration_assessment.get_collector.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetCollector", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.GetCollector", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.rapidmigrationassessment.v1.Collector", - "client": { - "shortName": "RapidMigrationAssessmentClient", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient" - }, - "method": { - "shortName": "GetCollector", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.GetCollector", - "service": { - "shortName": "RapidMigrationAssessment", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment" - } - } - } - }, - { - "regionTag": "rapidmigrationassessment_v1_generated_RapidMigrationAssessment_UpdateCollector_async", - "title": "RapidMigrationAssessment updateCollector Sample", - "origin": "API_DEFINITION", - "description": " Updates the parameters of a single Collector.", - "canonical": true, - "file": "rapid_migration_assessment.update_collector.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 77, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateCollector", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.UpdateCollector", - "async": true, - "parameters": [ - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "collector", - "type": ".google.cloud.rapidmigrationassessment.v1.Collector" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "RapidMigrationAssessmentClient", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient" - }, - "method": { - "shortName": "UpdateCollector", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.UpdateCollector", - "service": { - "shortName": "RapidMigrationAssessment", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment" - } - } - } - }, - { - "regionTag": "rapidmigrationassessment_v1_generated_RapidMigrationAssessment_DeleteCollector_async", - "title": "RapidMigrationAssessment deleteCollector Sample", - "origin": "API_DEFINITION", - "description": " Deletes a single Collector - changes state of collector to \"Deleting\".", - "canonical": true, - "file": "rapid_migration_assessment.delete_collector.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteCollector", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.DeleteCollector", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "RapidMigrationAssessmentClient", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient" - }, - "method": { - "shortName": "DeleteCollector", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.DeleteCollector", - "service": { - "shortName": "RapidMigrationAssessment", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment" - } - } - } - }, - { - "regionTag": "rapidmigrationassessment_v1_generated_RapidMigrationAssessment_ResumeCollector_async", - "title": "RapidMigrationAssessment resumeCollector Sample", - "origin": "API_DEFINITION", - "description": " Resumes the given collector.", - "canonical": true, - "file": "rapid_migration_assessment.resume_collector.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ResumeCollector", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.ResumeCollector", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "RapidMigrationAssessmentClient", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient" - }, - "method": { - "shortName": "ResumeCollector", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.ResumeCollector", - "service": { - "shortName": "RapidMigrationAssessment", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment" - } - } - } - }, - { - "regionTag": "rapidmigrationassessment_v1_generated_RapidMigrationAssessment_RegisterCollector_async", - "title": "RapidMigrationAssessment registerCollector Sample", - "origin": "API_DEFINITION", - "description": " Registers the given collector.", - "canonical": true, - "file": "rapid_migration_assessment.register_collector.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RegisterCollector", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.RegisterCollector", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "RapidMigrationAssessmentClient", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient" - }, - "method": { - "shortName": "RegisterCollector", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.RegisterCollector", - "service": { - "shortName": "RapidMigrationAssessment", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment" - } - } - } - }, - { - "regionTag": "rapidmigrationassessment_v1_generated_RapidMigrationAssessment_PauseCollector_async", - "title": "RapidMigrationAssessment pauseCollector Sample", - "origin": "API_DEFINITION", - "description": " Pauses the given collector.", - "canonical": true, - "file": "rapid_migration_assessment.pause_collector.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PauseCollector", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.PauseCollector", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "RapidMigrationAssessmentClient", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessmentClient" - }, - "method": { - "shortName": "PauseCollector", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment.PauseCollector", - "service": { - "shortName": "RapidMigrationAssessment", - "fullName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/index.ts b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/index.ts deleted file mode 100644 index 382b2cd1d2c..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/index.ts +++ /dev/null @@ -1,25 +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 v1 from './v1'; -const RapidMigrationAssessmentClient = v1.RapidMigrationAssessmentClient; -type RapidMigrationAssessmentClient = v1.RapidMigrationAssessmentClient; -export {v1, RapidMigrationAssessmentClient}; -export default {v1, RapidMigrationAssessmentClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 556ad365abb..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,127 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.rapidmigrationassessment.v1", - "libraryPackage": "@google-cloud/rapidmigrationassessment", - "services": { - "RapidMigrationAssessment": { - "clients": { - "grpc": { - "libraryClient": "RapidMigrationAssessmentClient", - "rpcs": { - "GetAnnotation": { - "methods": [ - "getAnnotation" - ] - }, - "GetCollector": { - "methods": [ - "getCollector" - ] - }, - "CreateCollector": { - "methods": [ - "createCollector" - ] - }, - "CreateAnnotation": { - "methods": [ - "createAnnotation" - ] - }, - "UpdateCollector": { - "methods": [ - "updateCollector" - ] - }, - "DeleteCollector": { - "methods": [ - "deleteCollector" - ] - }, - "ResumeCollector": { - "methods": [ - "resumeCollector" - ] - }, - "RegisterCollector": { - "methods": [ - "registerCollector" - ] - }, - "PauseCollector": { - "methods": [ - "pauseCollector" - ] - }, - "ListCollectors": { - "methods": [ - "listCollectors", - "listCollectorsStream", - "listCollectorsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "RapidMigrationAssessmentClient", - "rpcs": { - "GetAnnotation": { - "methods": [ - "getAnnotation" - ] - }, - "GetCollector": { - "methods": [ - "getCollector" - ] - }, - "CreateCollector": { - "methods": [ - "createCollector" - ] - }, - "CreateAnnotation": { - "methods": [ - "createAnnotation" - ] - }, - "UpdateCollector": { - "methods": [ - "updateCollector" - ] - }, - "DeleteCollector": { - "methods": [ - "deleteCollector" - ] - }, - "ResumeCollector": { - "methods": [ - "resumeCollector" - ] - }, - "RegisterCollector": { - "methods": [ - "registerCollector" - ] - }, - "PauseCollector": { - "methods": [ - "pauseCollector" - ] - }, - "ListCollectors": { - "methods": [ - "listCollectors", - "listCollectorsStream", - "listCollectorsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/index.ts deleted file mode 100644 index 25827d9bbd9..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +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 {RapidMigrationAssessmentClient} from './rapid_migration_assessment_client'; diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_client.ts b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_client.ts deleted file mode 100644 index 08aaf0e546a..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_client.ts +++ /dev/null @@ -1,1839 +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/v1/rapid_migration_assessment_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './rapid_migration_assessment_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Rapid Migration Assessment service - * @class - * @memberof v1 - */ -export class RapidMigrationAssessmentClient { - 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; - rapidMigrationAssessmentStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of RapidMigrationAssessmentClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 RapidMigrationAssessmentClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof RapidMigrationAssessmentClient; - 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 { - 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 = { - annotationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/annotations/{annotation}' - ), - collectorPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collectors/{collector}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - }; - - // 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 = { - listCollectors: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'collectors') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createCollectorResponse = protoFilesRoot.lookup( - '.google.cloud.rapidmigrationassessment.v1.Collector') as gax.protobuf.Type; - const createCollectorMetadata = protoFilesRoot.lookup( - '.google.cloud.rapidmigrationassessment.v1.OperationMetadata') as gax.protobuf.Type; - const createAnnotationResponse = protoFilesRoot.lookup( - '.google.cloud.rapidmigrationassessment.v1.Annotation') as gax.protobuf.Type; - const createAnnotationMetadata = protoFilesRoot.lookup( - '.google.cloud.rapidmigrationassessment.v1.OperationMetadata') as gax.protobuf.Type; - const updateCollectorResponse = protoFilesRoot.lookup( - '.google.cloud.rapidmigrationassessment.v1.Collector') as gax.protobuf.Type; - const updateCollectorMetadata = protoFilesRoot.lookup( - '.google.cloud.rapidmigrationassessment.v1.OperationMetadata') as gax.protobuf.Type; - const deleteCollectorResponse = protoFilesRoot.lookup( - '.google.cloud.rapidmigrationassessment.v1.Collector') as gax.protobuf.Type; - const deleteCollectorMetadata = protoFilesRoot.lookup( - '.google.cloud.rapidmigrationassessment.v1.OperationMetadata') as gax.protobuf.Type; - const resumeCollectorResponse = protoFilesRoot.lookup( - '.google.cloud.rapidmigrationassessment.v1.Collector') as gax.protobuf.Type; - const resumeCollectorMetadata = protoFilesRoot.lookup( - '.google.cloud.rapidmigrationassessment.v1.OperationMetadata') as gax.protobuf.Type; - const registerCollectorResponse = protoFilesRoot.lookup( - '.google.cloud.rapidmigrationassessment.v1.Collector') as gax.protobuf.Type; - const registerCollectorMetadata = protoFilesRoot.lookup( - '.google.cloud.rapidmigrationassessment.v1.OperationMetadata') as gax.protobuf.Type; - const pauseCollectorResponse = protoFilesRoot.lookup( - '.google.cloud.rapidmigrationassessment.v1.Collector') as gax.protobuf.Type; - const pauseCollectorMetadata = protoFilesRoot.lookup( - '.google.cloud.rapidmigrationassessment.v1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createCollector: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createCollectorResponse.decode.bind(createCollectorResponse), - createCollectorMetadata.decode.bind(createCollectorMetadata)), - createAnnotation: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createAnnotationResponse.decode.bind(createAnnotationResponse), - createAnnotationMetadata.decode.bind(createAnnotationMetadata)), - updateCollector: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateCollectorResponse.decode.bind(updateCollectorResponse), - updateCollectorMetadata.decode.bind(updateCollectorMetadata)), - deleteCollector: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteCollectorResponse.decode.bind(deleteCollectorResponse), - deleteCollectorMetadata.decode.bind(deleteCollectorMetadata)), - resumeCollector: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - resumeCollectorResponse.decode.bind(resumeCollectorResponse), - resumeCollectorMetadata.decode.bind(resumeCollectorMetadata)), - registerCollector: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - registerCollectorResponse.decode.bind(registerCollectorResponse), - registerCollectorMetadata.decode.bind(registerCollectorMetadata)), - pauseCollector: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - pauseCollectorResponse.decode.bind(pauseCollectorResponse), - pauseCollectorMetadata.decode.bind(pauseCollectorMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment', 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.rapidMigrationAssessmentStub) { - return this.rapidMigrationAssessmentStub; - } - - // Put together the "service stub" for - // google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment. - this.rapidMigrationAssessmentStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment, - 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 rapidMigrationAssessmentStubMethods = - ['createCollector', 'createAnnotation', 'getAnnotation', 'listCollectors', 'getCollector', 'updateCollector', 'deleteCollector', 'resumeCollector', 'registerCollector', 'pauseCollector']; - for (const methodName of rapidMigrationAssessmentStubMethods) { - const callPromise = this.rapidMigrationAssessmentStub.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.rapidMigrationAssessmentStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'rapidmigrationassessment.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 'rapidmigrationassessment.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 details of a single Annotation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.rapidmigrationassessment.v1.Annotation|Annotation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/rapid_migration_assessment.get_annotation.js - * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_GetAnnotation_async - */ - getAnnotation( - request?: protos.google.cloud.rapidmigrationassessment.v1.IGetAnnotationRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.rapidmigrationassessment.v1.IAnnotation, - protos.google.cloud.rapidmigrationassessment.v1.IGetAnnotationRequest|undefined, {}|undefined - ]>; - getAnnotation( - request: protos.google.cloud.rapidmigrationassessment.v1.IGetAnnotationRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.rapidmigrationassessment.v1.IAnnotation, - protos.google.cloud.rapidmigrationassessment.v1.IGetAnnotationRequest|null|undefined, - {}|null|undefined>): void; - getAnnotation( - request: protos.google.cloud.rapidmigrationassessment.v1.IGetAnnotationRequest, - callback: Callback< - protos.google.cloud.rapidmigrationassessment.v1.IAnnotation, - protos.google.cloud.rapidmigrationassessment.v1.IGetAnnotationRequest|null|undefined, - {}|null|undefined>): void; - getAnnotation( - request?: protos.google.cloud.rapidmigrationassessment.v1.IGetAnnotationRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.rapidmigrationassessment.v1.IAnnotation, - protos.google.cloud.rapidmigrationassessment.v1.IGetAnnotationRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.rapidmigrationassessment.v1.IAnnotation, - protos.google.cloud.rapidmigrationassessment.v1.IGetAnnotationRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.rapidmigrationassessment.v1.IAnnotation, - protos.google.cloud.rapidmigrationassessment.v1.IGetAnnotationRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getAnnotation(request, options, callback); - } -/** - * Gets details of a single Collector. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.rapidmigrationassessment.v1.Collector|Collector}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/rapid_migration_assessment.get_collector.js - * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_GetCollector_async - */ - getCollector( - request?: protos.google.cloud.rapidmigrationassessment.v1.IGetCollectorRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.rapidmigrationassessment.v1.ICollector, - protos.google.cloud.rapidmigrationassessment.v1.IGetCollectorRequest|undefined, {}|undefined - ]>; - getCollector( - request: protos.google.cloud.rapidmigrationassessment.v1.IGetCollectorRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.rapidmigrationassessment.v1.ICollector, - protos.google.cloud.rapidmigrationassessment.v1.IGetCollectorRequest|null|undefined, - {}|null|undefined>): void; - getCollector( - request: protos.google.cloud.rapidmigrationassessment.v1.IGetCollectorRequest, - callback: Callback< - protos.google.cloud.rapidmigrationassessment.v1.ICollector, - protos.google.cloud.rapidmigrationassessment.v1.IGetCollectorRequest|null|undefined, - {}|null|undefined>): void; - getCollector( - request?: protos.google.cloud.rapidmigrationassessment.v1.IGetCollectorRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.rapidmigrationassessment.v1.ICollector, - protos.google.cloud.rapidmigrationassessment.v1.IGetCollectorRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.rapidmigrationassessment.v1.ICollector, - protos.google.cloud.rapidmigrationassessment.v1.IGetCollectorRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.rapidmigrationassessment.v1.ICollector, - protos.google.cloud.rapidmigrationassessment.v1.IGetCollectorRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getCollector(request, options, callback); - } - -/** - * Create a Collector to manage the on-prem appliance which collects - * information about Customer assets. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the parent (project+location). - * @param {string} request.collectorId - * Required. Id of the requesting object. - * @param {google.cloud.rapidmigrationassessment.v1.Collector} request.collector - * Required. The resource being created. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/rapid_migration_assessment.create_collector.js - * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateCollector_async - */ - createCollector( - request?: protos.google.cloud.rapidmigrationassessment.v1.ICreateCollectorRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createCollector( - request: protos.google.cloud.rapidmigrationassessment.v1.ICreateCollectorRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createCollector( - request: protos.google.cloud.rapidmigrationassessment.v1.ICreateCollectorRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createCollector( - request?: protos.google.cloud.rapidmigrationassessment.v1.ICreateCollectorRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createCollector(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createCollector()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/rapid_migration_assessment.create_collector.js - * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateCollector_async - */ - async checkCreateCollectorProgress(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.createCollector, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Creates an Annotation - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the parent (project+location). - * @param {google.cloud.rapidmigrationassessment.v1.Annotation} request.annotation - * Required. The resource being created. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/rapid_migration_assessment.create_annotation.js - * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateAnnotation_async - */ - createAnnotation( - request?: protos.google.cloud.rapidmigrationassessment.v1.ICreateAnnotationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createAnnotation( - request: protos.google.cloud.rapidmigrationassessment.v1.ICreateAnnotationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createAnnotation( - request: protos.google.cloud.rapidmigrationassessment.v1.ICreateAnnotationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createAnnotation( - request?: protos.google.cloud.rapidmigrationassessment.v1.ICreateAnnotationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createAnnotation(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createAnnotation()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/rapid_migration_assessment.create_annotation.js - * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateAnnotation_async - */ - async checkCreateAnnotationProgress(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.createAnnotation, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the parameters of a single Collector. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Field mask is used to specify the fields to be overwritten in the - * Collector resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.rapidmigrationassessment.v1.Collector} request.collector - * Required. The resource being updated. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/rapid_migration_assessment.update_collector.js - * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_UpdateCollector_async - */ - updateCollector( - request?: protos.google.cloud.rapidmigrationassessment.v1.IUpdateCollectorRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateCollector( - request: protos.google.cloud.rapidmigrationassessment.v1.IUpdateCollectorRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateCollector( - request: protos.google.cloud.rapidmigrationassessment.v1.IUpdateCollectorRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateCollector( - request?: protos.google.cloud.rapidmigrationassessment.v1.IUpdateCollectorRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'collector.name': request.collector!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateCollector(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateCollector()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/rapid_migration_assessment.update_collector.js - * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_UpdateCollector_async - */ - async checkUpdateCollectorProgress(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.updateCollector, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a single Collector - changes state of collector to "Deleting". - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/rapid_migration_assessment.delete_collector.js - * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_DeleteCollector_async - */ - deleteCollector( - request?: protos.google.cloud.rapidmigrationassessment.v1.IDeleteCollectorRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteCollector( - request: protos.google.cloud.rapidmigrationassessment.v1.IDeleteCollectorRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteCollector( - request: protos.google.cloud.rapidmigrationassessment.v1.IDeleteCollectorRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteCollector( - request?: protos.google.cloud.rapidmigrationassessment.v1.IDeleteCollectorRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteCollector(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteCollector()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/rapid_migration_assessment.delete_collector.js - * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_DeleteCollector_async - */ - async checkDeleteCollectorProgress(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.deleteCollector, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Resumes the given collector. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/rapid_migration_assessment.resume_collector.js - * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_ResumeCollector_async - */ - resumeCollector( - request?: protos.google.cloud.rapidmigrationassessment.v1.IResumeCollectorRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - resumeCollector( - request: protos.google.cloud.rapidmigrationassessment.v1.IResumeCollectorRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - resumeCollector( - request: protos.google.cloud.rapidmigrationassessment.v1.IResumeCollectorRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - resumeCollector( - request?: protos.google.cloud.rapidmigrationassessment.v1.IResumeCollectorRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.resumeCollector(request, options, callback); - } -/** - * Check the status of the long running operation returned by `resumeCollector()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/rapid_migration_assessment.resume_collector.js - * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_ResumeCollector_async - */ - async checkResumeCollectorProgress(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.resumeCollector, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Registers the given collector. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/rapid_migration_assessment.register_collector.js - * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_RegisterCollector_async - */ - registerCollector( - request?: protos.google.cloud.rapidmigrationassessment.v1.IRegisterCollectorRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - registerCollector( - request: protos.google.cloud.rapidmigrationassessment.v1.IRegisterCollectorRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - registerCollector( - request: protos.google.cloud.rapidmigrationassessment.v1.IRegisterCollectorRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - registerCollector( - request?: protos.google.cloud.rapidmigrationassessment.v1.IRegisterCollectorRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.registerCollector(request, options, callback); - } -/** - * Check the status of the long running operation returned by `registerCollector()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/rapid_migration_assessment.register_collector.js - * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_RegisterCollector_async - */ - async checkRegisterCollectorProgress(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.registerCollector, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Pauses the given collector. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/rapid_migration_assessment.pause_collector.js - * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_PauseCollector_async - */ - pauseCollector( - request?: protos.google.cloud.rapidmigrationassessment.v1.IPauseCollectorRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - pauseCollector( - request: protos.google.cloud.rapidmigrationassessment.v1.IPauseCollectorRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - pauseCollector( - request: protos.google.cloud.rapidmigrationassessment.v1.IPauseCollectorRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - pauseCollector( - request?: protos.google.cloud.rapidmigrationassessment.v1.IPauseCollectorRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.pauseCollector(request, options, callback); - } -/** - * Check the status of the long running operation returned by `pauseCollector()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/rapid_migration_assessment.pause_collector.js - * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_PauseCollector_async - */ - async checkPauseCollectorProgress(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.pauseCollector, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists Collectors in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListCollectorsRequest. - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Hint for how to order the 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 Array of {@link protos.google.cloud.rapidmigrationassessment.v1.Collector|Collector}. - * 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 `listCollectorsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listCollectors( - request?: protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.rapidmigrationassessment.v1.ICollector[], - protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest|null, - protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsResponse - ]>; - listCollectors( - request: protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest, - protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsResponse|null|undefined, - protos.google.cloud.rapidmigrationassessment.v1.ICollector>): void; - listCollectors( - request: protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest, - callback: PaginationCallback< - protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest, - protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsResponse|null|undefined, - protos.google.cloud.rapidmigrationassessment.v1.ICollector>): void; - listCollectors( - request?: protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest, - protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsResponse|null|undefined, - protos.google.cloud.rapidmigrationassessment.v1.ICollector>, - callback?: PaginationCallback< - protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest, - protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsResponse|null|undefined, - protos.google.cloud.rapidmigrationassessment.v1.ICollector>): - Promise<[ - protos.google.cloud.rapidmigrationassessment.v1.ICollector[], - protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest|null, - protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listCollectors(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. Parent value for ListCollectorsRequest. - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Hint for how to order the results. - * @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 protos.google.cloud.rapidmigrationassessment.v1.Collector|Collector} 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 `listCollectorsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listCollectorsStream( - request?: protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest, - 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['listCollectors']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCollectors.createStream( - this.innerApiCalls.listCollectors as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listCollectors`, 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. Parent value for ListCollectorsRequest. - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Hint for how to order the results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.rapidmigrationassessment.v1.Collector|Collector}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/rapid_migration_assessment.list_collectors.js - * region_tag:rapidmigrationassessment_v1_generated_RapidMigrationAssessment_ListCollectors_async - */ - listCollectorsAsync( - request?: protos.google.cloud.rapidmigrationassessment.v1.IListCollectorsRequest, - 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['listCollectors']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCollectors.asyncIterate( - this.innerApiCalls['listCollectors'] 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 annotation resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} annotation - * @returns {string} Resource name string. - */ - annotationPath(project:string,location:string,annotation:string) { - return this.pathTemplates.annotationPathTemplate.render({ - project: project, - location: location, - annotation: annotation, - }); - } - - /** - * Parse the project from Annotation resource. - * - * @param {string} annotationName - * A fully-qualified path representing Annotation resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAnnotationName(annotationName: string) { - return this.pathTemplates.annotationPathTemplate.match(annotationName).project; - } - - /** - * Parse the location from Annotation resource. - * - * @param {string} annotationName - * A fully-qualified path representing Annotation resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAnnotationName(annotationName: string) { - return this.pathTemplates.annotationPathTemplate.match(annotationName).location; - } - - /** - * Parse the annotation from Annotation resource. - * - * @param {string} annotationName - * A fully-qualified path representing Annotation resource. - * @returns {string} A string representing the annotation. - */ - matchAnnotationFromAnnotationName(annotationName: string) { - return this.pathTemplates.annotationPathTemplate.match(annotationName).annotation; - } - - /** - * Return a fully-qualified collector resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collector - * @returns {string} Resource name string. - */ - collectorPath(project:string,location:string,collector:string) { - return this.pathTemplates.collectorPathTemplate.render({ - project: project, - location: location, - collector: collector, - }); - } - - /** - * Parse the project from Collector resource. - * - * @param {string} collectorName - * A fully-qualified path representing Collector resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCollectorName(collectorName: string) { - return this.pathTemplates.collectorPathTemplate.match(collectorName).project; - } - - /** - * Parse the location from Collector resource. - * - * @param {string} collectorName - * A fully-qualified path representing Collector resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCollectorName(collectorName: string) { - return this.pathTemplates.collectorPathTemplate.match(collectorName).location; - } - - /** - * Parse the collector from Collector resource. - * - * @param {string} collectorName - * A fully-qualified path representing Collector resource. - * @returns {string} A string representing the collector. - */ - matchCollectorFromCollectorName(collectorName: string) { - return this.pathTemplates.collectorPathTemplate.match(collectorName).collector; - } - - /** - * 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; - } - - /** - * 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.rapidMigrationAssessmentStub && !this._terminated) { - return this.rapidMigrationAssessmentStub.then(stub => { - this._terminated = true; - stub.close(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_client_config.json b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_client_config.json deleted file mode 100644 index 83e4b3b1c8b..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_client_config.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "interfaces": { - "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment": { - "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 - }, - "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateCollector": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateAnnotation": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetAnnotation": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "ListCollectors": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "GetCollector": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "UpdateCollector": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteCollector": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ResumeCollector": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RegisterCollector": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "PauseCollector": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_proto_list.json b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_proto_list.json deleted file mode 100644 index 6c93aa0c5bd..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/src/v1/rapid_migration_assessment_proto_list.json +++ /dev/null @@ -1,4 +0,0 @@ -[ - "../../protos/google/cloud/rapidmigrationassessment/v1/api_entities.proto", - "../../protos/google/cloud/rapidmigrationassessment/v1/rapidmigrationassessment.proto" -] diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 043caedcfc7..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const rapidmigrationassessment = require('@google-cloud/rapidmigrationassessment'); - -function main() { - const rapidMigrationAssessmentClient = new rapidmigrationassessment.RapidMigrationAssessmentClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 5f1819598d7..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {RapidMigrationAssessmentClient} from '@google-cloud/rapidmigrationassessment'; - -// check that the client class type name can be used -function doStuffWithRapidMigrationAssessmentClient(client: RapidMigrationAssessmentClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const rapidMigrationAssessmentClient = new RapidMigrationAssessmentClient(); - doStuffWithRapidMigrationAssessmentClient(rapidMigrationAssessmentClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/install.ts b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/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-rapidmigrationassessment/v1/test/gapic_rapid_migration_assessment_v1.ts b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/test/gapic_rapid_migration_assessment_v1.ts deleted file mode 100644 index 5cf9b669399..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/test/gapic_rapid_migration_assessment_v1.ts +++ /dev/null @@ -1,2310 +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 rapidmigrationassessmentModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.RapidMigrationAssessmentClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.rapidMigrationAssessmentStub, undefined); - await client.initialize(); - assert(client.rapidMigrationAssessmentStub); - }); - - it('has close method for the initialized client', done => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.rapidMigrationAssessmentStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.rapidMigrationAssessmentStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - 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('getAnnotation', () => { - it('invokes getAnnotation without error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.GetAnnotationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.GetAnnotationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.Annotation() - ); - client.innerApiCalls.getAnnotation = stubSimpleCall(expectedResponse); - const [response] = await client.getAnnotation(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAnnotation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAnnotation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAnnotation without error using callback', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.GetAnnotationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.GetAnnotationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.Annotation() - ); - client.innerApiCalls.getAnnotation = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getAnnotation( - request, - (err?: Error|null, result?: protos.google.cloud.rapidmigrationassessment.v1.IAnnotation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAnnotation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAnnotation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAnnotation with error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.GetAnnotationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.GetAnnotationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getAnnotation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAnnotation(request), expectedError); - const actualRequest = (client.innerApiCalls.getAnnotation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAnnotation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAnnotation with closed client', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.GetAnnotationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.GetAnnotationRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getAnnotation(request), expectedError); - }); - }); - - describe('getCollector', () => { - it('invokes getCollector without error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.GetCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.GetCollectorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.Collector() - ); - client.innerApiCalls.getCollector = stubSimpleCall(expectedResponse); - const [response] = await client.getCollector(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCollector without error using callback', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.GetCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.GetCollectorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.Collector() - ); - client.innerApiCalls.getCollector = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCollector( - request, - (err?: Error|null, result?: protos.google.cloud.rapidmigrationassessment.v1.ICollector|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCollector with error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.GetCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.GetCollectorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCollector = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCollector(request), expectedError); - const actualRequest = (client.innerApiCalls.getCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCollector with closed client', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.GetCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.GetCollectorRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getCollector(request), expectedError); - }); - }); - - describe('createCollector', () => { - it('invokes createCollector without error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.CreateCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.CreateCollectorRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createCollector = stubLongRunningCall(expectedResponse); - const [operation] = await client.createCollector(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createCollector without error using callback', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.CreateCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.CreateCollectorRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createCollector = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createCollector( - request, - (err?: Error|null, - result?: 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.createCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createCollector with call error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.CreateCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.CreateCollectorRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCollector = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createCollector(request), expectedError); - const actualRequest = (client.innerApiCalls.createCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createCollector with LRO error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.CreateCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.CreateCollectorRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCollector = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createCollector(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateCollectorProgress without error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateCollectorProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateCollectorProgress with error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateCollectorProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('createAnnotation', () => { - it('invokes createAnnotation without error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.CreateAnnotationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.CreateAnnotationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createAnnotation = stubLongRunningCall(expectedResponse); - const [operation] = await client.createAnnotation(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createAnnotation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAnnotation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createAnnotation without error using callback', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.CreateAnnotationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.CreateAnnotationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createAnnotation = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createAnnotation( - request, - (err?: Error|null, - result?: 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.createAnnotation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAnnotation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createAnnotation with call error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.CreateAnnotationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.CreateAnnotationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createAnnotation = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createAnnotation(request), expectedError); - const actualRequest = (client.innerApiCalls.createAnnotation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAnnotation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createAnnotation with LRO error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.CreateAnnotationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.CreateAnnotationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createAnnotation = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createAnnotation(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createAnnotation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAnnotation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateAnnotationProgress without error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateAnnotationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateAnnotationProgress with error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateAnnotationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateCollector', () => { - it('invokes updateCollector without error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.UpdateCollectorRequest() - ); - request.collector ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.UpdateCollectorRequest', ['collector', 'name']); - request.collector.name = defaultValue1; - const expectedHeaderRequestParams = `collector.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateCollector = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateCollector(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCollector without error using callback', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.UpdateCollectorRequest() - ); - request.collector ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.UpdateCollectorRequest', ['collector', 'name']); - request.collector.name = defaultValue1; - const expectedHeaderRequestParams = `collector.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateCollector = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCollector( - request, - (err?: Error|null, - result?: 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.updateCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCollector with call error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.UpdateCollectorRequest() - ); - request.collector ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.UpdateCollectorRequest', ['collector', 'name']); - request.collector.name = defaultValue1; - const expectedHeaderRequestParams = `collector.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCollector = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateCollector(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCollector with LRO error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.UpdateCollectorRequest() - ); - request.collector ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.UpdateCollectorRequest', ['collector', 'name']); - request.collector.name = defaultValue1; - const expectedHeaderRequestParams = `collector.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCollector = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateCollector(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateCollectorProgress without error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateCollectorProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateCollectorProgress with error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateCollectorProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteCollector', () => { - it('invokes deleteCollector without error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.DeleteCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.DeleteCollectorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteCollector = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteCollector(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteCollector without error using callback', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.DeleteCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.DeleteCollectorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteCollector = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteCollector( - request, - (err?: Error|null, - result?: 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.deleteCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteCollector with call error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.DeleteCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.DeleteCollectorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCollector = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteCollector(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteCollector with LRO error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.DeleteCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.DeleteCollectorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCollector = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteCollector(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteCollectorProgress without error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteCollectorProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteCollectorProgress with error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteCollectorProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('resumeCollector', () => { - it('invokes resumeCollector without error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.ResumeCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ResumeCollectorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.resumeCollector = stubLongRunningCall(expectedResponse); - const [operation] = await client.resumeCollector(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeCollector without error using callback', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.ResumeCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ResumeCollectorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.resumeCollector = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resumeCollector( - request, - (err?: Error|null, - result?: 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.resumeCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeCollector with call error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.ResumeCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ResumeCollectorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.resumeCollector = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.resumeCollector(request), expectedError); - const actualRequest = (client.innerApiCalls.resumeCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeCollector with LRO error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.ResumeCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ResumeCollectorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.resumeCollector = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.resumeCollector(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.resumeCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkResumeCollectorProgress without error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkResumeCollectorProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkResumeCollectorProgress with error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkResumeCollectorProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('registerCollector', () => { - it('invokes registerCollector without error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.RegisterCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.RegisterCollectorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.registerCollector = stubLongRunningCall(expectedResponse); - const [operation] = await client.registerCollector(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.registerCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.registerCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes registerCollector without error using callback', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.RegisterCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.RegisterCollectorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.registerCollector = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.registerCollector( - request, - (err?: Error|null, - result?: 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.registerCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.registerCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes registerCollector with call error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.RegisterCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.RegisterCollectorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.registerCollector = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.registerCollector(request), expectedError); - const actualRequest = (client.innerApiCalls.registerCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.registerCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes registerCollector with LRO error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.RegisterCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.RegisterCollectorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.registerCollector = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.registerCollector(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.registerCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.registerCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkRegisterCollectorProgress without error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRegisterCollectorProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRegisterCollectorProgress with error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRegisterCollectorProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('pauseCollector', () => { - it('invokes pauseCollector without error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.PauseCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.PauseCollectorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.pauseCollector = stubLongRunningCall(expectedResponse); - const [operation] = await client.pauseCollector(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pauseCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseCollector without error using callback', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.PauseCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.PauseCollectorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.pauseCollector = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.pauseCollector( - request, - (err?: Error|null, - result?: 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.pauseCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseCollector with call error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.PauseCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.PauseCollectorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.pauseCollector = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.pauseCollector(request), expectedError); - const actualRequest = (client.innerApiCalls.pauseCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseCollector with LRO error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.PauseCollectorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.PauseCollectorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.pauseCollector = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.pauseCollector(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.pauseCollector as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseCollector as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkPauseCollectorProgress without error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkPauseCollectorProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkPauseCollectorProgress with error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkPauseCollectorProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listCollectors', () => { - it('invokes listCollectors without error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), - generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), - generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), - ]; - client.innerApiCalls.listCollectors = stubSimpleCall(expectedResponse); - const [response] = await client.listCollectors(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCollectors as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCollectors as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listCollectors without error using callback', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), - generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), - generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), - ]; - client.innerApiCalls.listCollectors = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCollectors( - request, - (err?: Error|null, result?: protos.google.cloud.rapidmigrationassessment.v1.ICollector[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCollectors as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCollectors as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listCollectors with error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCollectors = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCollectors(request), expectedError); - const actualRequest = (client.innerApiCalls.listCollectors as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCollectors as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listCollectorsStream without error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), - generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), - generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), - ]; - client.descriptors.page.listCollectors.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCollectorsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.rapidmigrationassessment.v1.Collector[] = []; - stream.on('data', (response: protos.google.cloud.rapidmigrationassessment.v1.Collector) => { - 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.listCollectors.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCollectors, request)); - assert( - (client.descriptors.page.listCollectors.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listCollectorsStream with error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listCollectors.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCollectorsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.rapidmigrationassessment.v1.Collector[] = []; - stream.on('data', (response: protos.google.cloud.rapidmigrationassessment.v1.Collector) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCollectors.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCollectors, request)); - assert( - (client.descriptors.page.listCollectors.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listCollectors without error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), - generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), - generateSampleMessage(new protos.google.cloud.rapidmigrationassessment.v1.Collector()), - ]; - client.descriptors.page.listCollectors.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.rapidmigrationassessment.v1.ICollector[] = []; - const iterable = client.listCollectorsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCollectors.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCollectors.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listCollectors with error', async () => { - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.rapidmigrationassessment.v1.ListCollectorsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listCollectors.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCollectorsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.rapidmigrationassessment.v1.ICollector[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCollectors.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCollectors.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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - 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 rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - 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('annotation', () => { - const fakePath = "/rendered/path/annotation"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - annotation: "annotationValue", - }; - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.annotationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.annotationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('annotationPath', () => { - const result = client.annotationPath("projectValue", "locationValue", "annotationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.annotationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAnnotationName', () => { - const result = client.matchProjectFromAnnotationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.annotationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAnnotationName', () => { - const result = client.matchLocationFromAnnotationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.annotationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAnnotationFromAnnotationName', () => { - const result = client.matchAnnotationFromAnnotationName(fakePath); - assert.strictEqual(result, "annotationValue"); - assert((client.pathTemplates.annotationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('collector', () => { - const fakePath = "/rendered/path/collector"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collector: "collectorValue", - }; - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.collectorPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.collectorPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('collectorPath', () => { - const result = client.collectorPath("projectValue", "locationValue", "collectorValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.collectorPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCollectorName', () => { - const result = client.matchProjectFromCollectorName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.collectorPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCollectorName', () => { - const result = client.matchLocationFromCollectorName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.collectorPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectorFromCollectorName', () => { - const result = client.matchCollectorFromCollectorName(fakePath); - assert.strictEqual(result, "collectorValue"); - assert((client.pathTemplates.collectorPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new rapidmigrationassessmentModule.v1.RapidMigrationAssessmentClient({ - 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)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/tsconfig.json b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/webpack.config.js b/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/webpack.config.js deleted file mode 100644 index 5dfe6903548..00000000000 --- a/owl-bot-staging/google-cloud-rapidmigrationassessment/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'RapidMigrationAssessment', - filename: './rapid-migration-assessment.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-recaptchaenterprise/v1/.eslintignore b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.eslintrc.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.gitignore b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.jsdoc.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.jsdoc.js deleted file mode 100644 index 495384476fc..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.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/recaptcha-enterprise', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.mocharc.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.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-recaptchaenterprise/v1/.prettierrc.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/.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-recaptchaenterprise/v1/README.md b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/README.md deleted file mode 100644 index 57a5e168123..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Recaptchaenterprise: Nodejs Client diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/package.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/package.json deleted file mode 100644 index 8fa34225ff3..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/recaptcha-enterprise", - "version": "0.1.0", - "description": "Recaptchaenterprise client for Node.js", - "repository": "googleapis/nodejs-recaptchaenterprise", - "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 recaptchaenterprise", - "recaptchaenterprise", - "recaptcha enterprise service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto deleted file mode 100644 index e73de0c97e0..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto +++ /dev/null @@ -1,1427 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.recaptchaenterprise.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.RecaptchaEnterprise.V1"; -option go_package = "cloud.google.com/go/recaptchaenterprise/v2/apiv1/recaptchaenterprisepb;recaptchaenterprisepb"; -option java_multiple_files = true; -option java_outer_classname = "RecaptchaEnterpriseProto"; -option java_package = "com.google.recaptchaenterprise.v1"; -option objc_class_prefix = "GCRE"; -option php_namespace = "Google\\Cloud\\RecaptchaEnterprise\\V1"; -option ruby_package = "Google::Cloud::RecaptchaEnterprise::V1"; - -// Service to determine the likelihood an event is legitimate. -service RecaptchaEnterpriseService { - option (google.api.default_host) = "recaptchaenterprise.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates an Assessment of the likelihood an event is legitimate. - rpc CreateAssessment(CreateAssessmentRequest) returns (Assessment) { - option (google.api.http) = { - post: "/v1/{parent=projects/*}/assessments" - body: "assessment" - }; - option (google.api.method_signature) = "parent,assessment"; - } - - // Annotates a previously created Assessment to provide additional information - // on whether the event turned out to be authentic or fraudulent. - rpc AnnotateAssessment(AnnotateAssessmentRequest) - returns (AnnotateAssessmentResponse) { - option (google.api.http) = { - post: "/v1/{name=projects/*/assessments/*}:annotate" - body: "*" - }; - option (google.api.method_signature) = "name,annotation"; - } - - // Creates a new reCAPTCHA Enterprise key. - rpc CreateKey(CreateKeyRequest) returns (Key) { - option (google.api.http) = { - post: "/v1/{parent=projects/*}/keys" - body: "key" - }; - option (google.api.method_signature) = "parent,key"; - } - - // Returns the list of all keys that belong to a project. - rpc ListKeys(ListKeysRequest) returns (ListKeysResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*}/keys" - }; - option (google.api.method_signature) = "parent"; - } - - // Returns the secret key related to the specified public key. - // You must use the legacy secret key only in a 3rd party integration with - // legacy reCAPTCHA. - rpc RetrieveLegacySecretKey(RetrieveLegacySecretKeyRequest) - returns (RetrieveLegacySecretKeyResponse) { - option (google.api.http) = { - get: "/v1/{key=projects/*/keys/*}:retrieveLegacySecretKey" - }; - option (google.api.method_signature) = "key"; - } - - // Returns the specified key. - rpc GetKey(GetKeyRequest) returns (Key) { - option (google.api.http) = { - get: "/v1/{name=projects/*/keys/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates the specified key. - rpc UpdateKey(UpdateKeyRequest) returns (Key) { - option (google.api.http) = { - patch: "/v1/{key.name=projects/*/keys/*}" - body: "key" - }; - option (google.api.method_signature) = "key,update_mask"; - } - - // Deletes the specified key. - rpc DeleteKey(DeleteKeyRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/keys/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise. - // Once a key is migrated, it can be used from either product. SiteVerify - // requests are billed as CreateAssessment calls. You must be - // authenticated as one of the current owners of the reCAPTCHA Site Key, and - // your user must have the reCAPTCHA Enterprise Admin IAM role in the - // destination project. - rpc MigrateKey(MigrateKeyRequest) returns (Key) { - option (google.api.http) = { - post: "/v1/{name=projects/*/keys/*}:migrate" - body: "*" - }; - } - - // Get some aggregated metrics for a Key. This data can be used to build - // dashboards. - rpc GetMetrics(GetMetricsRequest) returns (Metrics) { - option (google.api.http) = { - get: "/v1/{name=projects/*/keys/*/metrics}" - }; - option (google.api.method_signature) = "name"; - } - - // List groups of related accounts. - rpc ListRelatedAccountGroups(ListRelatedAccountGroupsRequest) - returns (ListRelatedAccountGroupsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*}/relatedaccountgroups" - }; - option (google.api.method_signature) = "parent"; - } - - // Get memberships in a group of related accounts. - rpc ListRelatedAccountGroupMemberships( - ListRelatedAccountGroupMembershipsRequest) - returns (ListRelatedAccountGroupMembershipsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/relatedaccountgroups/*}/memberships" - }; - option (google.api.method_signature) = "parent"; - } - - // Search group memberships related to a given account. - rpc SearchRelatedAccountGroupMemberships( - SearchRelatedAccountGroupMembershipsRequest) - returns (SearchRelatedAccountGroupMembershipsResponse) { - option (google.api.http) = { - post: "/v1/{project=projects/*}/relatedaccountgroupmemberships:search" - body: "*" - }; - option (google.api.method_signature) = "project,hashed_account_id"; - } -} - -// The create assessment request message. -message CreateAssessmentRequest { - // Required. The name of the project in which the assessment will be created, - // in the format "projects/{project}". - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Required. The assessment details. - Assessment assessment = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Describes an event in the lifecycle of a payment transaction. -message TransactionEvent { - // Enum that represents an event in the payment transaction lifecycle. - enum TransactionEventType { - // Default, unspecified event type. - TRANSACTION_EVENT_TYPE_UNSPECIFIED = 0; - - // Indicates that the transaction is approved by the merchant. The - // accompanying reasons can include terms such as 'INHOUSE', 'ACCERTIFY', - // 'CYBERSOURCE', or 'MANUAL_REVIEW'. - MERCHANT_APPROVE = 1; - - // Indicates that the transaction is denied and concluded due to risks - // detected by the merchant. The accompanying reasons can include terms such - // as 'INHOUSE', 'ACCERTIFY', 'CYBERSOURCE', or 'MANUAL_REVIEW'. - MERCHANT_DENY = 2; - - // Indicates that the transaction is being evaluated by a human, due to - // suspicion or risk. - MANUAL_REVIEW = 3; - - // Indicates that the authorization attempt with the card issuer succeeded. - AUTHORIZATION = 4; - - // Indicates that the authorization attempt with the card issuer failed. - // The accompanying reasons can include Visa's '54' indicating that the card - // is expired, or '82' indicating that the CVV is incorrect. - AUTHORIZATION_DECLINE = 5; - - // Indicates that the transaction is completed because the funds were - // settled. - PAYMENT_CAPTURE = 6; - - // Indicates that the transaction could not be completed because the funds - // were not settled. - PAYMENT_CAPTURE_DECLINE = 7; - - // Indicates that the transaction has been canceled. Specify the reason - // for the cancellation. For example, 'INSUFFICIENT_INVENTORY'. - CANCEL = 8; - - // Indicates that the merchant has received a chargeback inquiry due to - // fraud for the transaction, requesting additional information before a - // fraud chargeback is officially issued and a formal chargeback - // notification is sent. - CHARGEBACK_INQUIRY = 9; - - // Indicates that the merchant has received a chargeback alert due to fraud - // for the transaction. The process of resolving the dispute without - // involving the payment network is started. - CHARGEBACK_ALERT = 10; - - // Indicates that a fraud notification is issued for the transaction, sent - // by the payment instrument's issuing bank because the transaction appears - // to be fraudulent. We recommend including TC40 or SAFE data in the - // `reason` field for this event type. For partial chargebacks, we recommend - // that you include an amount in the `value` field. - FRAUD_NOTIFICATION = 11; - - // Indicates that the merchant is informed by the payment network that the - // transaction has entered the chargeback process due to fraud. Reason code - // examples include Discover's '6005' and '6041'. For partial chargebacks, - // we recommend that you include an amount in the `value` field. - CHARGEBACK = 12; - - // Indicates that the transaction has entered the chargeback process due to - // fraud, and that the merchant has chosen to enter representment. Reason - // examples include Discover's '6005' and '6041'. For partial chargebacks, - // we recommend that you include an amount in the `value` field. - CHARGEBACK_REPRESENTMENT = 13; - - // Indicates that the transaction has had a fraud chargeback which was - // illegitimate and was reversed as a result. For partial chargebacks, we - // recommend that you include an amount in the `value` field. - CHARGEBACK_REVERSE = 14; - - // Indicates that the merchant has received a refund for a completed - // transaction. For partial refunds, we recommend that you include an amount - // in the `value` field. Reason example: 'TAX_EXEMPT' (partial refund of - // exempt tax) - REFUND_REQUEST = 15; - - // Indicates that the merchant has received a refund request for this - // transaction, but that they have declined it. For partial refunds, we - // recommend that you include an amount in the `value` field. Reason - // example: 'TAX_EXEMPT' (partial refund of exempt tax) - REFUND_DECLINE = 16; - - // Indicates that the completed transaction was refunded by the merchant. - // For partial refunds, we recommend that you include an amount in the - // `value` field. Reason example: 'TAX_EXEMPT' (partial refund of exempt - // tax) - REFUND = 17; - - // Indicates that the completed transaction was refunded by the merchant, - // and that this refund was reversed. For partial refunds, we recommend that - // you include an amount in the `value` field. - REFUND_REVERSE = 18; - } - - // Optional. The type of this transaction event. - TransactionEventType event_type = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The reason or standardized code that corresponds with this - // transaction event, if one exists. For example, a CHARGEBACK event with code - // 6005. - string reason = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The value that corresponds with this transaction event, if one - // exists. For example, a refund event where $5.00 was refunded. Currency is - // obtained from the original transaction data. - double value = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Timestamp when this transaction event occurred; otherwise assumed - // to be the time of the API call. - google.protobuf.Timestamp event_time = 4 - [(google.api.field_behavior) = OPTIONAL]; -} - -// The request message to annotate an Assessment. -message AnnotateAssessmentRequest { - // Enum that represents the types of annotations. - enum Annotation { - // Default unspecified type. - ANNOTATION_UNSPECIFIED = 0; - - // Provides information that the event turned out to be legitimate. - LEGITIMATE = 1; - - // Provides information that the event turned out to be fraudulent. - FRAUDULENT = 2; - - // Provides information that the event was related to a login event in which - // the user typed the correct password. Deprecated, prefer indicating - // CORRECT_PASSWORD through the reasons field instead. - PASSWORD_CORRECT = 3 [deprecated = true]; - - // Provides information that the event was related to a login event in which - // the user typed the incorrect password. Deprecated, prefer indicating - // INCORRECT_PASSWORD through the reasons field instead. - PASSWORD_INCORRECT = 4 [deprecated = true]; - } - - // Enum that represents potential reasons for annotating an assessment. - enum Reason { - // Default unspecified reason. - REASON_UNSPECIFIED = 0; - - // Indicates that the transaction had a chargeback issued with no other - // details. When possible, specify the type by using CHARGEBACK_FRAUD or - // CHARGEBACK_DISPUTE instead. - CHARGEBACK = 1; - - // Indicates that the transaction had a chargeback issued related to an - // alleged unauthorized transaction from the cardholder's perspective (for - // example, the card number was stolen). - CHARGEBACK_FRAUD = 8; - - // Indicates that the transaction had a chargeback issued related to the - // cardholder having provided their card details but allegedly not being - // satisfied with the purchase (for example, misrepresentation, attempted - // cancellation). - CHARGEBACK_DISPUTE = 9; - - // Indicates that the completed payment transaction was refunded by the - // seller. - REFUND = 10; - - // Indicates that the completed payment transaction was determined to be - // fraudulent by the seller, and was cancelled and refunded as a result. - REFUND_FRAUD = 11; - - // Indicates that the payment transaction was accepted, and the user was - // charged. - TRANSACTION_ACCEPTED = 12; - - // Indicates that the payment transaction was declined, for example due to - // invalid card details. - TRANSACTION_DECLINED = 13; - - // Indicates the transaction associated with the assessment is suspected of - // being fraudulent based on the payment method, billing details, shipping - // address or other transaction information. - PAYMENT_HEURISTICS = 2; - - // Indicates that the user was served a 2FA challenge. An old assessment - // with `ENUM_VALUES.INITIATED_TWO_FACTOR` reason that has not been - // overwritten with `PASSED_TWO_FACTOR` is treated as an abandoned 2FA flow. - // This is equivalent to `FAILED_TWO_FACTOR`. - INITIATED_TWO_FACTOR = 7; - - // Indicates that the user passed a 2FA challenge. - PASSED_TWO_FACTOR = 3; - - // Indicates that the user failed a 2FA challenge. - FAILED_TWO_FACTOR = 4; - - // Indicates the user provided the correct password. - CORRECT_PASSWORD = 5; - - // Indicates the user provided an incorrect password. - INCORRECT_PASSWORD = 6; - - // Indicates that the user sent unwanted and abusive messages to other users - // of the platform, such as spam, scams, phishing, or social engineering. - SOCIAL_SPAM = 14; - } - - // Required. The resource name of the Assessment, in the format - // "projects/{project}/assessments/{assessment}". - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recaptchaenterprise.googleapis.com/Assessment" - } - ]; - - // Optional. The annotation that will be assigned to the Event. This field can - // be left empty to provide reasons that apply to an event without concluding - // whether the event is legitimate or fraudulent. - Annotation annotation = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Optional reasons for the annotation that will be assigned to the - // Event. - repeated Reason reasons = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Unique stable hashed user identifier to apply to the assessment. - // This is an alternative to setting the hashed_account_id in - // CreateAssessment, for example when the account identifier is not yet known - // in the initial request. It is recommended that the identifier is hashed - // using hmac-sha256 with stable secret. - bytes hashed_account_id = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. If the assessment is part of a payment transaction, provide - // details on payment lifecycle events that occur in the transaction. - TransactionEvent transaction_event = 5 - [(google.api.field_behavior) = OPTIONAL]; -} - -// Empty response for AnnotateAssessment. -message AnnotateAssessmentResponse {} - -// Information about a verification endpoint that can be used for 2FA. -message EndpointVerificationInfo { - oneof endpoint { - // Email address for which to trigger a verification request. - string email_address = 1; - - // Phone number for which to trigger a verification request. Should be given - // in E.164 format. - string phone_number = 2; - } - - // Output only. Token to provide to the client to trigger endpoint - // verification. It must be used within 15 minutes. - string request_token = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Timestamp of the last successful verification for the - // endpoint, if any. - google.protobuf.Timestamp last_verification_time = 4 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Information about account verification, used for identity verification. -message AccountVerificationInfo { - // Result of the account verification as contained in the verdict token issued - // at the end of the verification flow. - enum Result { - // No information about the latest account verification. - RESULT_UNSPECIFIED = 0; - - // The user was successfully verified. This means the account verification - // challenge was successfully completed. - SUCCESS_USER_VERIFIED = 1; - - // The user failed the verification challenge. - ERROR_USER_NOT_VERIFIED = 2; - - // The site is not properly onboarded to use the account verification - // feature. - ERROR_SITE_ONBOARDING_INCOMPLETE = 3; - - // The recipient is not allowed for account verification. This can occur - // during integration but should not occur in production. - ERROR_RECIPIENT_NOT_ALLOWED = 4; - - // The recipient has already been sent too many verification codes in a - // short amount of time. - ERROR_RECIPIENT_ABUSE_LIMIT_EXHAUSTED = 5; - - // The verification flow could not be completed due to a critical internal - // error. - ERROR_CRITICAL_INTERNAL = 6; - - // The client has exceeded their two factor request quota for this period of - // time. - ERROR_CUSTOMER_QUOTA_EXHAUSTED = 7; - - // The request cannot be processed at the time because of an incident. This - // bypass can be restricted to a problematic destination email domain, a - // customer, or could affect the entire service. - ERROR_VERIFICATION_BYPASSED = 8; - - // The request parameters do not match with the token provided and cannot be - // processed. - ERROR_VERDICT_MISMATCH = 9; - } - - // Endpoints that can be used for identity verification. - repeated EndpointVerificationInfo endpoints = 1; - - // Language code preference for the verification message, set as a IETF BCP 47 - // language code. - string language_code = 3; - - // Output only. Result of the latest account verification challenge. - Result latest_verification_result = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Username of the account that is being verified. Deprecated. Customers - // should now provide the hashed account ID field in Event. - string username = 2 [deprecated = true]; -} - -// Private password leak verification info. -message PrivatePasswordLeakVerification { - // Optional. Exactly 26-bit prefix of the SHA-256 hash of the canonicalized - // username. It is used to look up password leaks associated with that hash - // prefix. - bytes lookup_hash_prefix = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Encrypted Scrypt hash of the canonicalized username+password. It - // is re-encrypted by the server and returned through - // `reencrypted_user_credentials_hash`. - bytes encrypted_user_credentials_hash = 2 - [(google.api.field_behavior) = OPTIONAL]; - - // Output only. List of prefixes of the encrypted potential password leaks - // that matched the given parameters. They must be compared with the - // client-side decryption prefix of `reencrypted_user_credentials_hash` - repeated bytes encrypted_leak_match_prefixes = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Corresponds to the re-encryption of the - // `encrypted_user_credentials_hash` field. It is used to match potential - // password leaks within `encrypted_leak_match_prefixes`. - bytes reencrypted_user_credentials_hash = 4 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A reCAPTCHA Enterprise assessment resource. -message Assessment { - option (google.api.resource) = { - type: "recaptchaenterprise.googleapis.com/Assessment" - pattern: "projects/{project}/assessments/{assessment}" - }; - - // Output only. The resource name for the Assessment in the format - // "projects/{project}/assessments/{assessment}". - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The event being assessed. - Event event = 2; - - // Output only. The risk analysis result for the event being assessed. - RiskAnalysis risk_analysis = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Properties of the provided event token. - TokenProperties token_properties = 4 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Account verification information for identity verification. The assessment - // event must include a token and site key to use this feature. - AccountVerificationInfo account_verification = 5; - - // Assessment returned by account defender when a hashed_account_id is - // provided. - AccountDefenderAssessment account_defender_assessment = 6; - - // The private password leak verification field contains the parameters that - // are used to to check for leaks privately without sharing user credentials. - PrivatePasswordLeakVerification private_password_leak_verification = 8; - - // Assessment returned by Fraud Prevention when TransactionData is provided. - FraudPreventionAssessment fraud_prevention_assessment = 11; -} - -// The event being assessed. -message Event { - // Optional. The user response token provided by the reCAPTCHA Enterprise - // client-side integration on your site. - string token = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The site key that was used to invoke reCAPTCHA Enterprise on your - // site and generate the token. - string site_key = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The user agent present in the request from the user's device - // related to this event. - string user_agent = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The IP address in the request from the user's device related to - // this event. - string user_ip_address = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The expected action for this type of event. This should be the - // same action provided at token generation time on client-side platforms - // already integrated with recaptcha enterprise. - string expected_action = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Unique stable hashed user identifier for the request. The - // identifier must be hashed using hmac-sha256 with stable secret. - bytes hashed_account_id = 6 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Data describing a payment transaction to be assessed. Sending - // this data enables reCAPTCHA Enterprise Fraud Prevention and the - // FraudPreventionAssessment component in the response. - TransactionData transaction_data = 13 - [(google.api.field_behavior) = OPTIONAL]; -} - -// Transaction data associated with a payment protected by reCAPTCHA Enterprise. -// All fields are optional. -message TransactionData { - // Structured address format for billing and shipping addresses. - message Address { - // The recipient name, potentially including information such as "care of". - string recipient = 1; - - // The first lines of the address. The first line generally contains the - // street name and number, and further lines may include information such as - // an apartment number. - repeated string address = 2; - - // The town/city of the address. - string locality = 3; - - // The state, province, or otherwise administrative area of the address. - string administrative_area = 4; - - // The CLDR country/region of the address. - string region_code = 5; - - // The postal or ZIP code of the address. - string postal_code = 6; - } - - // Details about a user's account involved in the transaction. - message User { - // Unique account identifier for this user. If using account defender, - // this should match the hashed_account_id field. Otherwise, a unique and - // persistent identifier for this account. - string account_id = 6; - - // The epoch milliseconds of the user's account creation. - int64 creation_ms = 1; - - // The email address of the user. - string email = 2; - - // Whether the email has been verified to be accessible by the user (OTP or - // similar). - bool email_verified = 3; - - // The phone number of the user, with country code. - string phone_number = 4; - - // Whether the phone number has been verified to be accessible by the user - // (OTP or similar). - bool phone_verified = 5; - } - - // Line items being purchased in this transaction. - message Item { - // The full name of the item. - string name = 1; - - // The value per item that the user is paying, in the transaction currency, - // after discounts. - double value = 2; - - // The quantity of this item that is being purchased. - int64 quantity = 3; - - // When a merchant is specified, its corresponding account_id. Necessary to - // populate marketplace-style transactions. - string merchant_account_id = 4; - } - - // Details about the transaction from the gateway. - message GatewayInfo { - // Name of the gateway service (for example, stripe, square, paypal). - string name = 1; - - // Gateway response code describing the state of the transaction. - string gateway_response_code = 2; - - // AVS response code from the gateway - // (available only when reCAPTCHA Enterprise is called after authorization). - string avs_response_code = 3; - - // CVV response code from the gateway - // (available only when reCAPTCHA Enterprise is called after authorization). - string cvv_response_code = 4; - } - - // Unique identifier for the transaction. This custom identifier can be used - // to reference this transaction in the future, for example, labeling a refund - // or chargeback event. Two attempts at the same transaction should use the - // same transaction id. - optional string transaction_id = 11; - - // The payment method for the transaction. The allowed values are: - // - // * credit-card - // * debit-card - // * gift-card - // * processor-{name} (If a third-party is used, for example, - // processor-paypal) - // * custom-{name} (If an alternative method is used, for example, - // custom-crypto) - string payment_method = 1; - - // The Bank Identification Number - generally the first 6 or 8 digits of the - // card. - string card_bin = 2; - - // The last four digits of the card. - string card_last_four = 3; - - // The currency code in ISO-4217 format. - string currency_code = 4; - - // The decimal value of the transaction in the specified currency. - double value = 5; - - // The value of shipping in the specified currency. 0 for free or no shipping. - double shipping_value = 12; - - // Destination address if this transaction involves shipping a physical item. - Address shipping_address = 6; - - // Address associated with the payment method when applicable. - Address billing_address = 7; - - // Information about the user paying/initiating the transaction. - User user = 8; - - // Information about the user or users fulfilling the transaction. - repeated User merchants = 13; - - // Items purchased in this transaction. - repeated Item items = 14; - - // Information about the payment gateway's response to the transaction. - GatewayInfo gateway_info = 10; -} - -// Risk analysis result for an event. -message RiskAnalysis { - // Reasons contributing to the risk analysis verdict. - enum ClassificationReason { - // Default unspecified type. - CLASSIFICATION_REASON_UNSPECIFIED = 0; - - // Interactions matched the behavior of an automated agent. - AUTOMATION = 1; - - // The event originated from an illegitimate environment. - UNEXPECTED_ENVIRONMENT = 2; - - // Traffic volume from the event source is higher than normal. - TOO_MUCH_TRAFFIC = 3; - - // Interactions with the site were significantly different than expected - // patterns. - UNEXPECTED_USAGE_PATTERNS = 4; - - // Too little traffic has been received from this site thus far to generate - // quality risk analysis. - LOW_CONFIDENCE_SCORE = 5; - - // The request matches behavioral characteristics of a carding attack. - SUSPECTED_CARDING = 6; - - // The request matches behavioral characteristics of chargebacks for fraud. - SUSPECTED_CHARGEBACK = 7; - } - - // Legitimate event score from 0.0 to 1.0. - // (1.0 means very likely legitimate traffic while 0.0 means very likely - // non-legitimate traffic). - float score = 1; - - // Reasons contributing to the risk analysis verdict. - repeated ClassificationReason reasons = 2; -} - -// Properties of the provided event token. -message TokenProperties { - // Enum that represents the types of invalid token reasons. - enum InvalidReason { - // Default unspecified type. - INVALID_REASON_UNSPECIFIED = 0; - - // If the failure reason was not accounted for. - UNKNOWN_INVALID_REASON = 1; - - // The provided user verification token was malformed. - MALFORMED = 2; - - // The user verification token had expired. - EXPIRED = 3; - - // The user verification had already been seen. - DUPE = 4; - - // The user verification token was not present. - MISSING = 5; - - // A retriable error (such as network failure) occurred on the browser. - // Could easily be simulated by an attacker. - BROWSER_ERROR = 6; - } - - // Whether the provided user response token is valid. When valid = false, the - // reason could be specified in invalid_reason or it could also be due to - // a user failing to solve a challenge or a sitekey mismatch (i.e the sitekey - // used to generate the token was different than the one specified in the - // assessment). - bool valid = 1; - - // Reason associated with the response when valid = false. - InvalidReason invalid_reason = 2; - - // The timestamp corresponding to the generation of the token. - google.protobuf.Timestamp create_time = 3; - - // The hostname of the page on which the token was generated (Web keys only). - string hostname = 4; - - // The name of the Android package with which the token was generated (Android - // keys only). - string android_package_name = 8; - - // The ID of the iOS bundle with which the token was generated (iOS keys - // only). - string ios_bundle_id = 9; - - // Action name provided at token generation. - string action = 5; -} - -// Assessment for Fraud Prevention. -message FraudPreventionAssessment { - // Information about stolen instrument fraud, where the user is not the - // legitimate owner of the instrument being used for the purchase. - message StolenInstrumentVerdict { - // Probability (0-1) of this transaction being executed with a stolen - // instrument. - float risk = 1; - } - - // Information about card testing fraud, where an adversary is testing - // fraudulently obtained cards or brute forcing their details. - message CardTestingVerdict { - // Probability (0-1) of this transaction attempt being part of a card - // testing attack. - float risk = 1; - } - - // Probability (0-1) of this transaction being fraudulent. Summarizes the - // combined risk of attack vectors below. - float transaction_risk = 1; - - // Assessment of this transaction for risk of a stolen instrument. - StolenInstrumentVerdict stolen_instrument_verdict = 2; - - // Assessment of this transaction for risk of being part of a card testing - // attack. - CardTestingVerdict card_testing_verdict = 3; -} - -// Account defender risk assessment. -message AccountDefenderAssessment { - // Labels returned by account defender for this request. - enum AccountDefenderLabel { - // Default unspecified type. - ACCOUNT_DEFENDER_LABEL_UNSPECIFIED = 0; - - // The request matches a known good profile for the user. - PROFILE_MATCH = 1; - - // The request is potentially a suspicious login event and must be further - // verified either through multi-factor authentication or another system. - SUSPICIOUS_LOGIN_ACTIVITY = 2; - - // The request matched a profile that previously had suspicious account - // creation behavior. This can mean that this is a fake account. - SUSPICIOUS_ACCOUNT_CREATION = 3; - - // The account in the request has a high number of related accounts. It does - // not necessarily imply that the account is bad but can require further - // investigation. - RELATED_ACCOUNTS_NUMBER_HIGH = 4; - } - - // Labels for this request. - repeated AccountDefenderLabel labels = 1; -} - -// The create key request message. -message CreateKeyRequest { - // Required. The name of the project in which the key will be created, in the - // format "projects/{project}". - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Required. Information to create a reCAPTCHA Enterprise key. - Key key = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// The list keys request message. -message ListKeysRequest { - // Required. The name of the project that contains the keys that will be - // listed, in the format "projects/{project}". - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Optional. The maximum number of keys to return. Default is 10. Max limit is - // 1000. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The next_page_token value returned from a previous. - // ListKeysRequest, if any. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Response to request to list keys in a project. -message ListKeysResponse { - // Key details. - repeated Key keys = 1; - - // Token to retrieve the next page of results. It is set to empty if no keys - // remain in results. - string next_page_token = 2; -} - -// The retrieve legacy secret key request message. -message RetrieveLegacySecretKeyRequest { - // Required. The public key name linked to the requested secret key in the - // format "projects/{project}/keys/{key}". - string key = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recaptchaenterprise.googleapis.com/Key" - } - ]; -} - -// The get key request message. -message GetKeyRequest { - // Required. The name of the requested key, in the format - // "projects/{project}/keys/{key}". - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recaptchaenterprise.googleapis.com/Key" - } - ]; -} - -// The update key request message. -message UpdateKeyRequest { - // Required. The key to update. - Key key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The mask to control which fields of the key get updated. If the - // mask is not present, all fields will be updated. - google.protobuf.FieldMask update_mask = 2 - [(google.api.field_behavior) = OPTIONAL]; -} - -// The delete key request message. -message DeleteKeyRequest { - // Required. The name of the key to be deleted, in the format - // "projects/{project}/keys/{key}". - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recaptchaenterprise.googleapis.com/Key" - } - ]; -} - -// The migrate key request message. -message MigrateKeyRequest { - // Required. The name of the key to be migrated, in the format - // "projects/{project}/keys/{key}". - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recaptchaenterprise.googleapis.com/Key" - } - ]; - - // Optional. If true, skips the billing check. - // A reCAPTCHA Enterprise key or migrated key behaves differently than a - // reCAPTCHA (non-Enterprise version) key when you reach a quota limit (see - // https://cloud.google.com/recaptcha-enterprise/quotas#quota_limit). To avoid - // any disruption of your usage, we check that a billing account is present. - // If your usage of reCAPTCHA is under the free quota, you can safely skip the - // billing check and proceed with the migration. See - // https://cloud.google.com/recaptcha-enterprise/docs/billing-information. - bool skip_billing_check = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// The get metrics request message. -message GetMetricsRequest { - // Required. The name of the requested metrics, in the format - // "projects/{project}/keys/{key}/metrics". - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recaptchaenterprise.googleapis.com/Metrics" - } - ]; -} - -// Metrics for a single Key. -message Metrics { - option (google.api.resource) = { - type: "recaptchaenterprise.googleapis.com/Metrics" - pattern: "projects/{project}/keys/{key}/metrics" - }; - - // Output only. The name of the metrics, in the format - // "projects/{project}/keys/{key}/metrics". - string name = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Inclusive start time aligned to a day (UTC). - google.protobuf.Timestamp start_time = 1; - - // Metrics will be continuous and in order by dates, and in the granularity - // of day. All Key types should have score-based data. - repeated ScoreMetrics score_metrics = 2; - - // Metrics will be continuous and in order by dates, and in the granularity - // of day. Only challenge-based keys (CHECKBOX, INVISIBLE), will have - // challenge-based data. - repeated ChallengeMetrics challenge_metrics = 3; -} - -// Secret key is used only in legacy reCAPTCHA. It must be used in a 3rd party -// integration with legacy reCAPTCHA. -message RetrieveLegacySecretKeyResponse { - // The secret key (also known as shared secret) authorizes communication - // between your application backend and the reCAPTCHA Enterprise server to - // create an assessment. - // The secret key needs to be kept safe for security purposes. - string legacy_secret_key = 1; -} - -// A key used to identify and configure applications (web and/or mobile) that -// use reCAPTCHA Enterprise. -message Key { - option (google.api.resource) = { - type: "recaptchaenterprise.googleapis.com/Key" - pattern: "projects/{project}/keys/{key}" - }; - - // The resource name for the Key in the format - // "projects/{project}/keys/{key}". - string name = 1; - - // Human-readable display name of this key. Modifiable by user. - string display_name = 2; - - // Platform specific settings for this key. The key can only be used on a - // platform for which the settings are enabled. - oneof platform_settings { - // Settings for keys that can be used by websites. - WebKeySettings web_settings = 3; - - // Settings for keys that can be used by Android apps. - AndroidKeySettings android_settings = 4; - - // Settings for keys that can be used by iOS apps. - IOSKeySettings ios_settings = 5; - } - - // See - // Creating and managing labels. - map labels = 6; - - // Output only. The timestamp corresponding to the creation of this Key. - google.protobuf.Timestamp create_time = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Options for user acceptance testing. - TestingOptions testing_options = 9; - - // Settings for WAF - WafSettings waf_settings = 10; -} - -// Options for user acceptance testing. -message TestingOptions { - // Enum that represents the challenge option for challenge-based (CHECKBOX, - // INVISIBLE) testing keys. - enum TestingChallenge { - // Perform the normal risk analysis and return either nocaptcha or a - // challenge depending on risk and trust factors. - TESTING_CHALLENGE_UNSPECIFIED = 0; - - // Challenge requests for this key always return a nocaptcha, which - // does not require a solution. - NOCAPTCHA = 1; - - // Challenge requests for this key always return an unsolvable - // challenge. - UNSOLVABLE_CHALLENGE = 2; - } - - // All assessments for this Key will return this score. Must be between 0 - // (likely not legitimate) and 1 (likely legitimate) inclusive. - float testing_score = 1; - - // For challenge-based keys only (CHECKBOX, INVISIBLE), all challenge requests - // for this site will return nocaptcha if NOCAPTCHA, or an unsolvable - // challenge if CHALLENGE. - TestingChallenge testing_challenge = 2; -} - -// Settings specific to keys that can be used by websites. -message WebKeySettings { - // Enum that represents the integration types for web keys. - enum IntegrationType { - // Default type that indicates this enum hasn't been specified. This is not - // a valid IntegrationType, one of the other types must be specified - // instead. - INTEGRATION_TYPE_UNSPECIFIED = 0; - - // Only used to produce scores. It doesn't display the "I'm not a robot" - // checkbox and never shows captcha challenges. - SCORE = 1; - - // Displays the "I'm not a robot" checkbox and may show captcha challenges - // after it is checked. - CHECKBOX = 2; - - // Doesn't display the "I'm not a robot" checkbox, but may show captcha - // challenges after risk analysis. - INVISIBLE = 3; - } - - // Enum that represents the possible challenge frequency and difficulty - // configurations for a web key. - enum ChallengeSecurityPreference { - // Default type that indicates this enum hasn't been specified. - CHALLENGE_SECURITY_PREFERENCE_UNSPECIFIED = 0; - - // Key tends to show fewer and easier challenges. - USABILITY = 1; - - // Key tends to show balanced (in amount and difficulty) challenges. - BALANCE = 2; - - // Key tends to show more and harder challenges. - SECURITY = 3; - } - - // If set to true, it means allowed_domains will not be enforced. - bool allow_all_domains = 3; - - // Domains or subdomains of websites allowed to use the key. All subdomains - // of an allowed domain are automatically allowed. A valid domain requires a - // host and must not include any path, port, query or fragment. - // Examples: 'example.com' or 'subdomain.example.com' - repeated string allowed_domains = 1; - - // If set to true, the key can be used on AMP (Accelerated Mobile Pages) - // websites. This is supported only for the SCORE integration type. - bool allow_amp_traffic = 2; - - // Required. Describes how this key is integrated with the website. - IntegrationType integration_type = 4 [(google.api.field_behavior) = REQUIRED]; - - // Settings for the frequency and difficulty at which this key triggers - // captcha challenges. This should only be specified for IntegrationTypes - // CHECKBOX and INVISIBLE. - ChallengeSecurityPreference challenge_security_preference = 5; -} - -// Settings specific to keys that can be used by Android apps. -message AndroidKeySettings { - // If set to true, allowed_package_names are not enforced. - bool allow_all_package_names = 2; - - // Android package names of apps allowed to use the key. - // Example: 'com.companyname.appname' - repeated string allowed_package_names = 1; -} - -// Settings specific to keys that can be used by iOS apps. -message IOSKeySettings { - // If set to true, allowed_bundle_ids are not enforced. - bool allow_all_bundle_ids = 2; - - // iOS bundle ids of apps allowed to use the key. - // Example: 'com.companyname.productname.appname' - repeated string allowed_bundle_ids = 1; -} - -// Score distribution. -message ScoreDistribution { - // Map key is score value multiplied by 100. The scores are discrete values - // between [0, 1]. The maximum number of buckets is on order of a few dozen, - // but typically much lower (ie. 10). - map score_buckets = 1; -} - -// Metrics related to scoring. -message ScoreMetrics { - // Aggregated score metrics for all traffic. - ScoreDistribution overall_metrics = 1; - - // Action-based metrics. The map key is the action name which specified by the - // site owners at time of the "execute" client-side call. - map action_metrics = 2; -} - -// Metrics related to challenges. -message ChallengeMetrics { - // Count of reCAPTCHA checkboxes or badges rendered. This is mostly equivalent - // to a count of pageloads for pages that include reCAPTCHA. - int64 pageload_count = 1; - - // Count of nocaptchas (successful verification without a challenge) issued. - int64 nocaptcha_count = 2; - - // Count of submitted challenge solutions that were incorrect or otherwise - // deemed suspicious such that a subsequent challenge was triggered. - int64 failed_count = 3; - - // Count of nocaptchas (successful verification without a challenge) plus - // submitted challenge solutions that were correct and resulted in - // verification. - int64 passed_count = 4; -} - -// The request message to list memberships in a related account group. -message ListRelatedAccountGroupMembershipsRequest { - // Required. The resource name for the related account group in the format - // `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "recaptchaenterprise.googleapis.com/RelatedAccountGroupMembership" - } - ]; - - // Optional. The maximum number of accounts to return. The service might - // return fewer than this value. If unspecified, at most 50 accounts are - // returned. The maximum value is 1000; values above 1000 are coerced to 1000. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A page token, received from a previous - // `ListRelatedAccountGroupMemberships` call. - // - // When paginating, all other parameters provided to - // `ListRelatedAccountGroupMemberships` must match the call that provided the - // page token. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// The response to a `ListRelatedAccountGroupMemberships` call. -message ListRelatedAccountGroupMembershipsResponse { - // The memberships listed by the query. - repeated RelatedAccountGroupMembership related_account_group_memberships = 1; - - // A token, which can be sent as `page_token` to retrieve the next page. - // If this field is omitted, there are no subsequent pages. - string next_page_token = 2; -} - -// The request message to list related account groups. -message ListRelatedAccountGroupsRequest { - // Required. The name of the project to list related account groups from, in - // the format "projects/{project}". - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "recaptchaenterprise.googleapis.com/RelatedAccountGroup" - } - ]; - - // Optional. The maximum number of groups to return. The service might return - // fewer than this value. If unspecified, at most 50 groups are returned. The - // maximum value is 1000; values above 1000 are coerced to 1000. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A page token, received from a previous `ListRelatedAccountGroups` - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // `ListRelatedAccountGroups` must match the call that provided the page - // token. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// The response to a `ListRelatedAccountGroups` call. -message ListRelatedAccountGroupsResponse { - // The groups of related accounts listed by the query. - repeated RelatedAccountGroup related_account_groups = 1; - - // A token, which can be sent as `page_token` to retrieve the next page. - // If this field is omitted, there are no subsequent pages. - string next_page_token = 2; -} - -// The request message to search related account group memberships. -message SearchRelatedAccountGroupMembershipsRequest { - // Required. The name of the project to search related account group - // memberships from. Specify the project name in the following format: - // "projects/{project}". - string project = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "recaptchaenterprise.googleapis.com/RelatedAccountGroupMembership" - } - ]; - - // Optional. The unique stable hashed user identifier we should search - // connections to. The identifier should correspond to a `hashed_account_id` - // provided in a previous `CreateAssessment` or `AnnotateAssessment` call. - bytes hashed_account_id = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The maximum number of groups to return. The service might return - // fewer than this value. If unspecified, at most 50 groups are returned. The - // maximum value is 1000; values above 1000 are coerced to 1000. - int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A page token, received from a previous - // `SearchRelatedAccountGroupMemberships` call. Provide this to retrieve the - // subsequent page. - // - // When paginating, all other parameters provided to - // `SearchRelatedAccountGroupMemberships` must match the call that provided - // the page token. - string page_token = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// The response to a `SearchRelatedAccountGroupMemberships` call. -message SearchRelatedAccountGroupMembershipsResponse { - // The queried memberships. - repeated RelatedAccountGroupMembership related_account_group_memberships = 1; - - // A token, which can be sent as `page_token` to retrieve the next page. - // If this field is omitted, there are no subsequent pages. - string next_page_token = 2; -} - -// A membership in a group of related accounts. -message RelatedAccountGroupMembership { - option (google.api.resource) = { - type: "recaptchaenterprise.googleapis.com/RelatedAccountGroupMembership" - pattern: "projects/{project}/relatedaccountgroups/{relatedaccountgroup}/memberships/{membership}" - }; - - // Required. The resource name for this membership in the format - // `projects/{project}/relatedaccountgroups/{relatedaccountgroup}/memberships/{membership}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recaptchaenterprise.googleapis.com/RelatedAccountGroupMembership" - } - ]; - - // The unique stable hashed user identifier of the member. The identifier - // corresponds to a `hashed_account_id` provided in a previous - // `CreateAssessment` or `AnnotateAssessment` call. - bytes hashed_account_id = 2; -} - -// A group of related accounts. -message RelatedAccountGroup { - option (google.api.resource) = { - type: "recaptchaenterprise.googleapis.com/RelatedAccountGroup" - pattern: "projects/{project}/relatedaccountgroups/{relatedaccountgroup}" - }; - - // Required. The resource name for the related account group in the format - // `projects/{project}/relatedaccountgroups/{related_account_group}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recaptchaenterprise.googleapis.com/RelatedAccountGroup" - } - ]; -} - -// Settings specific to keys that can be used for WAF (Web Application -// Firewall). -message WafSettings { - // Supported WAF features. For more information, see - // https://cloud.google.com/recaptcha-enterprise/docs/usecase#comparison_of_features. - enum WafFeature { - // Undefined feature. - WAF_FEATURE_UNSPECIFIED = 0; - - // Redirects suspicious traffic to reCAPTCHA. - CHALLENGE_PAGE = 1; - - // Use reCAPTCHA session-tokens to protect the whole user session on the - // site's domain. - SESSION_TOKEN = 2; - - // Use reCAPTCHA action-tokens to protect user actions. - ACTION_TOKEN = 3; - } - - // Web Application Firewalls supported by reCAPTCHA Enterprise. - enum WafService { - // Undefined WAF - WAF_SERVICE_UNSPECIFIED = 0; - - // Cloud Armor - CA = 1; - } - - // Required. The WAF service that uses this key. - WafService waf_service = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The WAF feature for which this key is enabled. - WafFeature waf_feature = 2 [(google.api.field_behavior) = REQUIRED]; -} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.annotate_assessment.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.annotate_assessment.js deleted file mode 100644 index cee2e28bab5..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.annotate_assessment.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(name) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_AnnotateAssessment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 Assessment, in the format - * "projects/{project}/assessments/{assessment}". - */ - // const name = 'abc123' - /** - * Optional. The annotation that will be assigned to the Event. This field can - * be left empty to provide reasons that apply to an event without concluding - * whether the event is legitimate or fraudulent. - */ - // const annotation = {} - /** - * Optional. Optional reasons for the annotation that will be assigned to the - * Event. - */ - // const reasons = [1,2,3,4] - /** - * Optional. Unique stable hashed user identifier to apply to the assessment. - * This is an alternative to setting the hashed_account_id in - * CreateAssessment, for example when the account identifier is not yet known - * in the initial request. It is recommended that the identifier is hashed - * using hmac-sha256 with stable secret. - */ - // const hashedAccountId = Buffer.from('string') - /** - * Optional. If the assessment is part of a payment transaction, provide - * details on payment lifecycle events that occur in the transaction. - */ - // const transactionEvent = {} - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callAnnotateAssessment() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await recaptchaenterpriseClient.annotateAssessment(request); - console.log(response); - } - - callAnnotateAssessment(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_AnnotateAssessment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.create_assessment.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.create_assessment.js deleted file mode 100644 index 29aa4bca8ba..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.create_assessment.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(parent, assessment) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateAssessment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 project in which the assessment will be created, - * in the format "projects/{project}". - */ - // const parent = 'abc123' - /** - * Required. The assessment details. - */ - // const assessment = {} - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callCreateAssessment() { - // Construct request - const request = { - parent, - assessment, - }; - - // Run request - const response = await recaptchaenterpriseClient.createAssessment(request); - console.log(response); - } - - callCreateAssessment(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateAssessment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.create_key.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.create_key.js deleted file mode 100644 index 7fe47aeda81..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.create_key.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(parent, key) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 project in which the key will be created, in the - * format "projects/{project}". - */ - // const parent = 'abc123' - /** - * Required. Information to create a reCAPTCHA Enterprise key. - */ - // const key = {} - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callCreateKey() { - // Construct request - const request = { - parent, - key, - }; - - // Run request - const response = await recaptchaenterpriseClient.createKey(request); - console.log(response); - } - - callCreateKey(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.delete_key.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.delete_key.js deleted file mode 100644 index 83e23ec68f4..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.delete_key.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 recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 key to be deleted, in the format - * "projects/{project}/keys/{key}". - */ - // const name = 'abc123' - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callDeleteKey() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await recaptchaenterpriseClient.deleteKey(request); - console.log(response); - } - - callDeleteKey(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.get_key.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.get_key.js deleted file mode 100644 index 6c56f81e9b6..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.get_key.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 recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 requested key, in the format - * "projects/{project}/keys/{key}". - */ - // const name = 'abc123' - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callGetKey() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await recaptchaenterpriseClient.getKey(request); - console.log(response); - } - - callGetKey(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.get_metrics.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.get_metrics.js deleted file mode 100644 index 4f39fdf1b68..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.get_metrics.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 recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetMetrics_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 requested metrics, in the format - * "projects/{project}/keys/{key}/metrics". - */ - // const name = 'abc123' - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callGetMetrics() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await recaptchaenterpriseClient.getMetrics(request); - console.log(response); - } - - callGetMetrics(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetMetrics_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_keys.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_keys.js deleted file mode 100644 index 0e1be786060..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_keys.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) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListKeys_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 project that contains the keys that will be - * listed, in the format "projects/{project}". - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of keys to return. Default is 10. Max limit is - * 1000. - */ - // const pageSize = 1234 - /** - * Optional. The next_page_token value returned from a previous. - * ListKeysRequest, if any. - */ - // const pageToken = 'abc123' - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callListKeys() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await recaptchaenterpriseClient.listKeysAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListKeys(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListKeys_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_group_memberships.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_group_memberships.js deleted file mode 100644 index a5465546337..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_group_memberships.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(parent) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroupMemberships_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name for the related account group in the format - * `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`. - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of accounts to return. The service might - * return fewer than this value. If unspecified, at most 50 accounts are - * returned. The maximum value is 1000; values above 1000 are coerced to 1000. - */ - // const pageSize = 1234 - /** - * Optional. A page token, received from a previous - * `ListRelatedAccountGroupMemberships` call. - * When paginating, all other parameters provided to - * `ListRelatedAccountGroupMemberships` must match the call that provided the - * page token. - */ - // const pageToken = 'abc123' - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callListRelatedAccountGroupMemberships() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await recaptchaenterpriseClient.listRelatedAccountGroupMembershipsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListRelatedAccountGroupMemberships(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroupMemberships_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_groups.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_groups.js deleted file mode 100644 index 933d0de8409..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_groups.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(parent) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroups_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 project to list related account groups from, in - * the format "projects/{project}". - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of groups to return. The service might return - * fewer than this value. If unspecified, at most 50 groups are returned. The - * maximum value is 1000; values above 1000 are coerced to 1000. - */ - // const pageSize = 1234 - /** - * Optional. A page token, received from a previous `ListRelatedAccountGroups` - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * `ListRelatedAccountGroups` must match the call that provided the page - * token. - */ - // const pageToken = 'abc123' - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callListRelatedAccountGroups() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await recaptchaenterpriseClient.listRelatedAccountGroupsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListRelatedAccountGroups(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroups_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.migrate_key.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.migrate_key.js deleted file mode 100644 index 1939aa98f80..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.migrate_key.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(name) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_MigrateKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 key to be migrated, in the format - * "projects/{project}/keys/{key}". - */ - // const name = 'abc123' - /** - * Optional. If true, skips the billing check. - * A reCAPTCHA Enterprise key or migrated key behaves differently than a - * reCAPTCHA (non-Enterprise version) key when you reach a quota limit (see - * https://cloud.google.com/recaptcha-enterprise/quotas#quota_limit). To avoid - * any disruption of your usage, we check that a billing account is present. - * If your usage of reCAPTCHA is under the free quota, you can safely skip the - * billing check and proceed with the migration. See - * https://cloud.google.com/recaptcha-enterprise/docs/billing-information. - */ - // const skipBillingCheck = true - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callMigrateKey() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await recaptchaenterpriseClient.migrateKey(request); - console.log(response); - } - - callMigrateKey(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_MigrateKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.retrieve_legacy_secret_key.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.retrieve_legacy_secret_key.js deleted file mode 100644 index 38b39612b9c..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.retrieve_legacy_secret_key.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(key) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_RetrieveLegacySecretKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The public key name linked to the requested secret key in the - * format "projects/{project}/keys/{key}". - */ - // const key = 'abc123' - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callRetrieveLegacySecretKey() { - // Construct request - const request = { - key, - }; - - // Run request - const response = await recaptchaenterpriseClient.retrieveLegacySecretKey(request); - console.log(response); - } - - callRetrieveLegacySecretKey(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_RetrieveLegacySecretKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.search_related_account_group_memberships.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.search_related_account_group_memberships.js deleted file mode 100644 index bf66fa88c2f..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.search_related_account_group_memberships.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(project) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_SearchRelatedAccountGroupMemberships_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 project to search related account group - * memberships from. Specify the project name in the following format: - * "projects/{project}". - */ - // const project = 'my-project' - /** - * Optional. The unique stable hashed user identifier we should search - * connections to. The identifier should correspond to a `hashed_account_id` - * provided in a previous `CreateAssessment` or `AnnotateAssessment` call. - */ - // const hashedAccountId = Buffer.from('string') - /** - * Optional. The maximum number of groups to return. The service might return - * fewer than this value. If unspecified, at most 50 groups are returned. The - * maximum value is 1000; values above 1000 are coerced to 1000. - */ - // const pageSize = 1234 - /** - * Optional. A page token, received from a previous - * `SearchRelatedAccountGroupMemberships` call. Provide this to retrieve the - * subsequent page. - * When paginating, all other parameters provided to - * `SearchRelatedAccountGroupMemberships` must match the call that provided - * the page token. - */ - // const pageToken = 'abc123' - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callSearchRelatedAccountGroupMemberships() { - // Construct request - const request = { - project, - }; - - // Run request - const iterable = await recaptchaenterpriseClient.searchRelatedAccountGroupMembershipsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callSearchRelatedAccountGroupMemberships(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_SearchRelatedAccountGroupMemberships_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.update_key.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.update_key.js deleted file mode 100644 index 7bc0ae4bc29..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/recaptcha_enterprise_service.update_key.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(key) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_UpdateKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The key to update. - */ - // const key = {} - /** - * Optional. The mask to control which fields of the key get updated. If the - * mask is not present, all fields will be updated. - */ - // const updateMask = {} - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callUpdateKey() { - // Construct request - const request = { - key, - }; - - // Run request - const response = await recaptchaenterpriseClient.updateKey(request); - console.log(response); - } - - callUpdateKey(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_UpdateKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/snippet_metadata_google.cloud.recaptchaenterprise.v1.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/snippet_metadata_google.cloud.recaptchaenterprise.v1.json deleted file mode 100644 index 7ec1519e054..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/samples/generated/v1/snippet_metadata_google.cloud.recaptchaenterprise.v1.json +++ /dev/null @@ -1,603 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-recaptchaenterprise", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.recaptchaenterprise.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateAssessment_async", - "title": "RecaptchaEnterpriseService createAssessment Sample", - "origin": "API_DEFINITION", - "description": " Creates an Assessment of the likelihood an event is legitimate.", - "canonical": true, - "file": "recaptcha_enterprise_service.create_assessment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateAssessment", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.CreateAssessment", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "assessment", - "type": ".google.cloud.recaptchaenterprise.v1.Assessment" - } - ], - "resultType": ".google.cloud.recaptchaenterprise.v1.Assessment", - "client": { - "shortName": "RecaptchaEnterpriseServiceClient", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" - }, - "method": { - "shortName": "CreateAssessment", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.CreateAssessment", - "service": { - "shortName": "RecaptchaEnterpriseService", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" - } - } - } - }, - { - "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_AnnotateAssessment_async", - "title": "RecaptchaEnterpriseService annotateAssessment Sample", - "origin": "API_DEFINITION", - "description": " Annotates a previously created Assessment to provide additional information on whether the event turned out to be authentic or fraudulent.", - "canonical": true, - "file": "recaptcha_enterprise_service.annotate_assessment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 78, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AnnotateAssessment", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.AnnotateAssessment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "annotation", - "type": ".google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest.Annotation" - }, - { - "name": "reasons", - "type": "TYPE_ENUM[]" - }, - { - "name": "hashed_account_id", - "type": "TYPE_BYTES" - }, - { - "name": "transaction_event", - "type": ".google.cloud.recaptchaenterprise.v1.TransactionEvent" - } - ], - "resultType": ".google.cloud.recaptchaenterprise.v1.AnnotateAssessmentResponse", - "client": { - "shortName": "RecaptchaEnterpriseServiceClient", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" - }, - "method": { - "shortName": "AnnotateAssessment", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.AnnotateAssessment", - "service": { - "shortName": "RecaptchaEnterpriseService", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" - } - } - } - }, - { - "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateKey_async", - "title": "RecaptchaEnterpriseService createKey Sample", - "origin": "API_DEFINITION", - "description": " Creates a new reCAPTCHA Enterprise key.", - "canonical": true, - "file": "recaptcha_enterprise_service.create_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateKey", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.CreateKey", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "key", - "type": ".google.cloud.recaptchaenterprise.v1.Key" - } - ], - "resultType": ".google.cloud.recaptchaenterprise.v1.Key", - "client": { - "shortName": "RecaptchaEnterpriseServiceClient", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" - }, - "method": { - "shortName": "CreateKey", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.CreateKey", - "service": { - "shortName": "RecaptchaEnterpriseService", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" - } - } - } - }, - { - "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListKeys_async", - "title": "RecaptchaEnterpriseService listKeys Sample", - "origin": "API_DEFINITION", - "description": " Returns the list of all keys that belong to a project.", - "canonical": true, - "file": "recaptcha_enterprise_service.list_keys.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListKeys", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.ListKeys", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recaptchaenterprise.v1.ListKeysResponse", - "client": { - "shortName": "RecaptchaEnterpriseServiceClient", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" - }, - "method": { - "shortName": "ListKeys", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.ListKeys", - "service": { - "shortName": "RecaptchaEnterpriseService", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" - } - } - } - }, - { - "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_RetrieveLegacySecretKey_async", - "title": "RecaptchaEnterpriseService retrieveLegacySecretKey Sample", - "origin": "API_DEFINITION", - "description": " Returns the secret key related to the specified public key. You must use the legacy secret key only in a 3rd party integration with legacy reCAPTCHA.", - "canonical": true, - "file": "recaptcha_enterprise_service.retrieve_legacy_secret_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RetrieveLegacySecretKey", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.RetrieveLegacySecretKey", - "async": true, - "parameters": [ - { - "name": "key", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyResponse", - "client": { - "shortName": "RecaptchaEnterpriseServiceClient", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" - }, - "method": { - "shortName": "RetrieveLegacySecretKey", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.RetrieveLegacySecretKey", - "service": { - "shortName": "RecaptchaEnterpriseService", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" - } - } - } - }, - { - "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetKey_async", - "title": "RecaptchaEnterpriseService getKey Sample", - "origin": "API_DEFINITION", - "description": " Returns the specified key.", - "canonical": true, - "file": "recaptcha_enterprise_service.get_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetKey", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.GetKey", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recaptchaenterprise.v1.Key", - "client": { - "shortName": "RecaptchaEnterpriseServiceClient", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" - }, - "method": { - "shortName": "GetKey", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.GetKey", - "service": { - "shortName": "RecaptchaEnterpriseService", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" - } - } - } - }, - { - "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_UpdateKey_async", - "title": "RecaptchaEnterpriseService updateKey Sample", - "origin": "API_DEFINITION", - "description": " Updates the specified key.", - "canonical": true, - "file": "recaptcha_enterprise_service.update_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateKey", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.UpdateKey", - "async": true, - "parameters": [ - { - "name": "key", - "type": ".google.cloud.recaptchaenterprise.v1.Key" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.recaptchaenterprise.v1.Key", - "client": { - "shortName": "RecaptchaEnterpriseServiceClient", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" - }, - "method": { - "shortName": "UpdateKey", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.UpdateKey", - "service": { - "shortName": "RecaptchaEnterpriseService", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" - } - } - } - }, - { - "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteKey_async", - "title": "RecaptchaEnterpriseService deleteKey Sample", - "origin": "API_DEFINITION", - "description": " Deletes the specified key.", - "canonical": true, - "file": "recaptcha_enterprise_service.delete_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteKey", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.DeleteKey", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "RecaptchaEnterpriseServiceClient", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" - }, - "method": { - "shortName": "DeleteKey", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.DeleteKey", - "service": { - "shortName": "RecaptchaEnterpriseService", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" - } - } - } - }, - { - "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_MigrateKey_async", - "title": "RecaptchaEnterpriseService migrateKey Sample", - "origin": "API_DEFINITION", - "description": " Migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise. Once a key is migrated, it can be used from either product. SiteVerify requests are billed as CreateAssessment calls. You must be authenticated as one of the current owners of the reCAPTCHA Site Key, and your user must have the reCAPTCHA Enterprise Admin IAM role in the destination project.", - "canonical": true, - "file": "recaptcha_enterprise_service.migrate_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "MigrateKey", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.MigrateKey", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "skip_billing_check", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.recaptchaenterprise.v1.Key", - "client": { - "shortName": "RecaptchaEnterpriseServiceClient", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" - }, - "method": { - "shortName": "MigrateKey", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.MigrateKey", - "service": { - "shortName": "RecaptchaEnterpriseService", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" - } - } - } - }, - { - "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetMetrics_async", - "title": "RecaptchaEnterpriseService getMetrics Sample", - "origin": "API_DEFINITION", - "description": " Get some aggregated metrics for a Key. This data can be used to build dashboards.", - "canonical": true, - "file": "recaptcha_enterprise_service.get_metrics.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetMetrics", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.GetMetrics", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recaptchaenterprise.v1.Metrics", - "client": { - "shortName": "RecaptchaEnterpriseServiceClient", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" - }, - "method": { - "shortName": "GetMetrics", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.GetMetrics", - "service": { - "shortName": "RecaptchaEnterpriseService", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" - } - } - } - }, - { - "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroups_async", - "title": "RecaptchaEnterpriseService listRelatedAccountGroups Sample", - "origin": "API_DEFINITION", - "description": " List groups of related accounts.", - "canonical": true, - "file": "recaptcha_enterprise_service.list_related_account_groups.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListRelatedAccountGroups", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.ListRelatedAccountGroups", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsResponse", - "client": { - "shortName": "RecaptchaEnterpriseServiceClient", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" - }, - "method": { - "shortName": "ListRelatedAccountGroups", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.ListRelatedAccountGroups", - "service": { - "shortName": "RecaptchaEnterpriseService", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" - } - } - } - }, - { - "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroupMemberships_async", - "title": "RecaptchaEnterpriseService listRelatedAccountGroupMemberships Sample", - "origin": "API_DEFINITION", - "description": " Get memberships in a group of related accounts.", - "canonical": true, - "file": "recaptcha_enterprise_service.list_related_account_group_memberships.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListRelatedAccountGroupMemberships", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.ListRelatedAccountGroupMemberships", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsResponse", - "client": { - "shortName": "RecaptchaEnterpriseServiceClient", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" - }, - "method": { - "shortName": "ListRelatedAccountGroupMemberships", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.ListRelatedAccountGroupMemberships", - "service": { - "shortName": "RecaptchaEnterpriseService", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" - } - } - } - }, - { - "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_SearchRelatedAccountGroupMemberships_async", - "title": "RecaptchaEnterpriseService searchRelatedAccountGroupMemberships Sample", - "origin": "API_DEFINITION", - "description": " Search group memberships related to a given account.", - "canonical": true, - "file": "recaptcha_enterprise_service.search_related_account_group_memberships.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 78, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SearchRelatedAccountGroupMemberships", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.SearchRelatedAccountGroupMemberships", - "async": true, - "parameters": [ - { - "name": "project", - "type": "TYPE_STRING" - }, - { - "name": "hashed_account_id", - "type": "TYPE_BYTES" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsResponse", - "client": { - "shortName": "RecaptchaEnterpriseServiceClient", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient" - }, - "method": { - "shortName": "SearchRelatedAccountGroupMemberships", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.SearchRelatedAccountGroupMemberships", - "service": { - "shortName": "RecaptchaEnterpriseService", - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/index.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/index.ts deleted file mode 100644 index d639c71ddee..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/index.ts +++ /dev/null @@ -1,25 +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 v1 from './v1'; -const RecaptchaEnterpriseServiceClient = v1.RecaptchaEnterpriseServiceClient; -type RecaptchaEnterpriseServiceClient = v1.RecaptchaEnterpriseServiceClient; -export {v1, RecaptchaEnterpriseServiceClient}; -export default {v1, RecaptchaEnterpriseServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 023c63fe31e..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,169 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.recaptchaenterprise.v1", - "libraryPackage": "@google-cloud/recaptcha-enterprise", - "services": { - "RecaptchaEnterpriseService": { - "clients": { - "grpc": { - "libraryClient": "RecaptchaEnterpriseServiceClient", - "rpcs": { - "CreateAssessment": { - "methods": [ - "createAssessment" - ] - }, - "AnnotateAssessment": { - "methods": [ - "annotateAssessment" - ] - }, - "CreateKey": { - "methods": [ - "createKey" - ] - }, - "RetrieveLegacySecretKey": { - "methods": [ - "retrieveLegacySecretKey" - ] - }, - "GetKey": { - "methods": [ - "getKey" - ] - }, - "UpdateKey": { - "methods": [ - "updateKey" - ] - }, - "DeleteKey": { - "methods": [ - "deleteKey" - ] - }, - "MigrateKey": { - "methods": [ - "migrateKey" - ] - }, - "GetMetrics": { - "methods": [ - "getMetrics" - ] - }, - "ListKeys": { - "methods": [ - "listKeys", - "listKeysStream", - "listKeysAsync" - ] - }, - "ListRelatedAccountGroups": { - "methods": [ - "listRelatedAccountGroups", - "listRelatedAccountGroupsStream", - "listRelatedAccountGroupsAsync" - ] - }, - "ListRelatedAccountGroupMemberships": { - "methods": [ - "listRelatedAccountGroupMemberships", - "listRelatedAccountGroupMembershipsStream", - "listRelatedAccountGroupMembershipsAsync" - ] - }, - "SearchRelatedAccountGroupMemberships": { - "methods": [ - "searchRelatedAccountGroupMemberships", - "searchRelatedAccountGroupMembershipsStream", - "searchRelatedAccountGroupMembershipsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "RecaptchaEnterpriseServiceClient", - "rpcs": { - "CreateAssessment": { - "methods": [ - "createAssessment" - ] - }, - "AnnotateAssessment": { - "methods": [ - "annotateAssessment" - ] - }, - "CreateKey": { - "methods": [ - "createKey" - ] - }, - "RetrieveLegacySecretKey": { - "methods": [ - "retrieveLegacySecretKey" - ] - }, - "GetKey": { - "methods": [ - "getKey" - ] - }, - "UpdateKey": { - "methods": [ - "updateKey" - ] - }, - "DeleteKey": { - "methods": [ - "deleteKey" - ] - }, - "MigrateKey": { - "methods": [ - "migrateKey" - ] - }, - "GetMetrics": { - "methods": [ - "getMetrics" - ] - }, - "ListKeys": { - "methods": [ - "listKeys", - "listKeysStream", - "listKeysAsync" - ] - }, - "ListRelatedAccountGroups": { - "methods": [ - "listRelatedAccountGroups", - "listRelatedAccountGroupsStream", - "listRelatedAccountGroupsAsync" - ] - }, - "ListRelatedAccountGroupMemberships": { - "methods": [ - "listRelatedAccountGroupMemberships", - "listRelatedAccountGroupMembershipsStream", - "listRelatedAccountGroupMembershipsAsync" - ] - }, - "SearchRelatedAccountGroupMemberships": { - "methods": [ - "searchRelatedAccountGroupMemberships", - "searchRelatedAccountGroupMembershipsStream", - "searchRelatedAccountGroupMembershipsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/index.ts deleted file mode 100644 index c976fda6970..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +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 {RecaptchaEnterpriseServiceClient} from './recaptcha_enterprise_service_client'; diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_client.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_client.ts deleted file mode 100644 index 79b512852dd..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_client.ts +++ /dev/null @@ -1,2023 +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, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/recaptcha_enterprise_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './recaptcha_enterprise_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service to determine the likelihood an event is legitimate. - * @class - * @memberof v1 - */ -export class RecaptchaEnterpriseServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - recaptchaEnterpriseServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of RecaptchaEnterpriseServiceClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 RecaptchaEnterpriseServiceClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof RecaptchaEnterpriseServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - assessmentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/assessments/{assessment}' - ), - keyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/keys/{key}' - ), - metricsPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/keys/{key}/metrics' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - relatedAccountGroupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/relatedaccountgroups/{relatedaccountgroup}' - ), - relatedAccountGroupMembershipPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/relatedaccountgroups/{relatedaccountgroup}/memberships/{membership}' - ), - }; - - // 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 = { - listKeys: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'keys'), - listRelatedAccountGroups: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'relatedAccountGroups'), - listRelatedAccountGroupMemberships: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'relatedAccountGroupMemberships'), - searchRelatedAccountGroupMemberships: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'relatedAccountGroupMemberships') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService', 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.recaptchaEnterpriseServiceStub) { - return this.recaptchaEnterpriseServiceStub; - } - - // Put together the "service stub" for - // google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService. - this.recaptchaEnterpriseServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService, - 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 recaptchaEnterpriseServiceStubMethods = - ['createAssessment', 'annotateAssessment', 'createKey', 'listKeys', 'retrieveLegacySecretKey', 'getKey', 'updateKey', 'deleteKey', 'migrateKey', 'getMetrics', 'listRelatedAccountGroups', 'listRelatedAccountGroupMemberships', 'searchRelatedAccountGroupMemberships']; - for (const methodName of recaptchaEnterpriseServiceStubMethods) { - const callPromise = this.recaptchaEnterpriseServiceStub.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.recaptchaEnterpriseServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'recaptchaenterprise.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 'recaptchaenterprise.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 an Assessment of the likelihood an event is legitimate. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project in which the assessment will be created, - * in the format "projects/{project}". - * @param {google.cloud.recaptchaenterprise.v1.Assessment} request.assessment - * Required. The assessment 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 protos.google.cloud.recaptchaenterprise.v1.Assessment|Assessment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recaptcha_enterprise_service.create_assessment.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateAssessment_async - */ - createAssessment( - request?: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|undefined, {}|undefined - ]>; - createAssessment( - request: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>): void; - createAssessment( - request: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>): void; - createAssessment( - request?: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createAssessment(request, options, callback); - } -/** - * Annotates a previously created Assessment to provide additional information - * on whether the event turned out to be authentic or fraudulent. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Assessment, in the format - * "projects/{project}/assessments/{assessment}". - * @param {google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest.Annotation} [request.annotation] - * Optional. The annotation that will be assigned to the Event. This field can - * be left empty to provide reasons that apply to an event without concluding - * whether the event is legitimate or fraudulent. - * @param {number[]} [request.reasons] - * Optional. Optional reasons for the annotation that will be assigned to the - * Event. - * @param {Buffer} [request.hashedAccountId] - * Optional. Unique stable hashed user identifier to apply to the assessment. - * This is an alternative to setting the hashed_account_id in - * CreateAssessment, for example when the account identifier is not yet known - * in the initial request. It is recommended that the identifier is hashed - * using hmac-sha256 with stable secret. - * @param {google.cloud.recaptchaenterprise.v1.TransactionEvent} [request.transactionEvent] - * Optional. If the assessment is part of a payment transaction, provide - * details on payment lifecycle events that occur in the transaction. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentResponse|AnnotateAssessmentResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recaptcha_enterprise_service.annotate_assessment.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_AnnotateAssessment_async - */ - annotateAssessment( - request?: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|undefined, {}|undefined - ]>; - annotateAssessment( - request: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>): void; - annotateAssessment( - request: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>): void; - annotateAssessment( - request?: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.annotateAssessment(request, options, callback); - } -/** - * Creates a new reCAPTCHA Enterprise key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project in which the key will be created, in the - * format "projects/{project}". - * @param {google.cloud.recaptchaenterprise.v1.Key} request.key - * Required. Information to create a reCAPTCHA Enterprise key. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recaptchaenterprise.v1.Key|Key}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recaptcha_enterprise_service.create_key.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateKey_async - */ - createKey( - request?: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|undefined, {}|undefined - ]>; - createKey( - request: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|null|undefined, - {}|null|undefined>): void; - createKey( - request: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|null|undefined, - {}|null|undefined>): void; - createKey( - request?: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createKey(request, options, callback); - } -/** - * Returns the secret key related to the specified public key. - * You must use the legacy secret key only in a 3rd party integration with - * legacy reCAPTCHA. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.key - * Required. The public key name linked to the requested secret key in the - * format "projects/{project}/keys/{key}". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyResponse|RetrieveLegacySecretKeyResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recaptcha_enterprise_service.retrieve_legacy_secret_key.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_RetrieveLegacySecretKey_async - */ - retrieveLegacySecretKey( - request?: protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyResponse, - protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyRequest|undefined, {}|undefined - ]>; - retrieveLegacySecretKey( - request: protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyResponse, - protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyRequest|null|undefined, - {}|null|undefined>): void; - retrieveLegacySecretKey( - request: protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyResponse, - protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyRequest|null|undefined, - {}|null|undefined>): void; - retrieveLegacySecretKey( - request?: protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyResponse, - protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyResponse, - protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyResponse, - protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'key': request.key ?? '', - }); - this.initialize(); - return this.innerApiCalls.retrieveLegacySecretKey(request, options, callback); - } -/** - * Returns the specified key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the requested key, in the format - * "projects/{project}/keys/{key}". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recaptchaenterprise.v1.Key|Key}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recaptcha_enterprise_service.get_key.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetKey_async - */ - getKey( - request?: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|undefined, {}|undefined - ]>; - getKey( - request: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|null|undefined, - {}|null|undefined>): void; - getKey( - request: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|null|undefined, - {}|null|undefined>): void; - getKey( - request?: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getKey(request, options, callback); - } -/** - * Updates the specified key. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.recaptchaenterprise.v1.Key} request.key - * Required. The key to update. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. The mask to control which fields of the key get updated. If the - * mask is not present, all fields will be 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 protos.google.cloud.recaptchaenterprise.v1.Key|Key}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recaptcha_enterprise_service.update_key.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_UpdateKey_async - */ - updateKey( - request?: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|undefined, {}|undefined - ]>; - updateKey( - request: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|null|undefined, - {}|null|undefined>): void; - updateKey( - request: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|null|undefined, - {}|null|undefined>): void; - updateKey( - request?: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'key.name': request.key!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateKey(request, options, callback); - } -/** - * Deletes the specified key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the key to be deleted, in the format - * "projects/{project}/keys/{key}". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recaptcha_enterprise_service.delete_key.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteKey_async - */ - deleteKey( - request?: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|undefined, {}|undefined - ]>; - deleteKey( - request: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|null|undefined, - {}|null|undefined>): void; - deleteKey( - request: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|null|undefined, - {}|null|undefined>): void; - deleteKey( - request?: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteKey(request, options, callback); - } -/** - * Migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise. - * Once a key is migrated, it can be used from either product. SiteVerify - * requests are billed as CreateAssessment calls. You must be - * authenticated as one of the current owners of the reCAPTCHA Site Key, and - * your user must have the reCAPTCHA Enterprise Admin IAM role in the - * destination project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the key to be migrated, in the format - * "projects/{project}/keys/{key}". - * @param {boolean} [request.skipBillingCheck] - * Optional. If true, skips the billing check. - * A reCAPTCHA Enterprise key or migrated key behaves differently than a - * reCAPTCHA (non-Enterprise version) key when you reach a quota limit (see - * https://cloud.google.com/recaptcha-enterprise/quotas#quota_limit). To avoid - * any disruption of your usage, we check that a billing account is present. - * If your usage of reCAPTCHA is under the free quota, you can safely skip the - * billing check and proceed with the migration. See - * https://cloud.google.com/recaptcha-enterprise/docs/billing-information. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recaptchaenterprise.v1.Key|Key}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recaptcha_enterprise_service.migrate_key.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_MigrateKey_async - */ - migrateKey( - request?: protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|undefined, {}|undefined - ]>; - migrateKey( - request: protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|null|undefined, - {}|null|undefined>): void; - migrateKey( - request: protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|null|undefined, - {}|null|undefined>): void; - migrateKey( - request?: protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.migrateKey(request, options, callback); - } -/** - * Get some aggregated metrics for a Key. This data can be used to build - * dashboards. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the requested metrics, in the format - * "projects/{project}/keys/{key}/metrics". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recaptchaenterprise.v1.Metrics|Metrics}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recaptcha_enterprise_service.get_metrics.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetMetrics_async - */ - getMetrics( - request?: protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IMetrics, - protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|undefined, {}|undefined - ]>; - getMetrics( - request: protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IMetrics, - protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|null|undefined, - {}|null|undefined>): void; - getMetrics( - request: protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IMetrics, - protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|null|undefined, - {}|null|undefined>): void; - getMetrics( - request?: protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1.IMetrics, - protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1.IMetrics, - protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IMetrics, - protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getMetrics(request, options, callback); - } - - /** - * Returns the list of all keys that belong to a project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project that contains the keys that will be - * listed, in the format "projects/{project}". - * @param {number} [request.pageSize] - * Optional. The maximum number of keys to return. Default is 10. Max limit is - * 1000. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous. - * ListKeysRequest, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.recaptchaenterprise.v1.Key|Key}. - * 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 `listKeysAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listKeys( - request?: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey[], - protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest|null, - protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse - ]>; - listKeys( - request: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IKey>): void; - listKeys( - request: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IKey>): void; - listKeys( - request?: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IKey>, - callback?: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IKey>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey[], - protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest|null, - protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listKeys(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 name of the project that contains the keys that will be - * listed, in the format "projects/{project}". - * @param {number} [request.pageSize] - * Optional. The maximum number of keys to return. Default is 10. Max limit is - * 1000. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous. - * ListKeysRequest, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.recaptchaenterprise.v1.Key|Key} 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 `listKeysAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listKeysStream( - request?: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - 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['listKeys']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listKeys.createStream( - this.innerApiCalls.listKeys as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listKeys`, 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 name of the project that contains the keys that will be - * listed, in the format "projects/{project}". - * @param {number} [request.pageSize] - * Optional. The maximum number of keys to return. Default is 10. Max limit is - * 1000. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous. - * ListKeysRequest, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.recaptchaenterprise.v1.Key|Key}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recaptcha_enterprise_service.list_keys.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListKeys_async - */ - listKeysAsync( - request?: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - 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['listKeys']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listKeys.asyncIterate( - this.innerApiCalls['listKeys'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * List groups of related accounts. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project to list related account groups from, in - * the format "projects/{project}". - * @param {number} [request.pageSize] - * Optional. The maximum number of groups to return. The service might return - * fewer than this value. If unspecified, at most 50 groups are returned. The - * maximum value is 1000; values above 1000 are coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListRelatedAccountGroups` - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * `ListRelatedAccountGroups` must match the call that provided the page - * token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup|RelatedAccountGroup}. - * 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 `listRelatedAccountGroupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listRelatedAccountGroups( - request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup[], - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest|null, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse - ]>; - listRelatedAccountGroups( - request: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup>): void; - listRelatedAccountGroups( - request: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup>): void; - listRelatedAccountGroups( - request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup>, - callback?: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup[], - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest|null, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listRelatedAccountGroups(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 name of the project to list related account groups from, in - * the format "projects/{project}". - * @param {number} [request.pageSize] - * Optional. The maximum number of groups to return. The service might return - * fewer than this value. If unspecified, at most 50 groups are returned. The - * maximum value is 1000; values above 1000 are coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListRelatedAccountGroups` - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * `ListRelatedAccountGroups` must match the call that provided the page - * token. - * @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 protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup|RelatedAccountGroup} 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 `listRelatedAccountGroupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listRelatedAccountGroupsStream( - request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, - 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['listRelatedAccountGroups']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRelatedAccountGroups.createStream( - this.innerApiCalls.listRelatedAccountGroups as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listRelatedAccountGroups`, 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 name of the project to list related account groups from, in - * the format "projects/{project}". - * @param {number} [request.pageSize] - * Optional. The maximum number of groups to return. The service might return - * fewer than this value. If unspecified, at most 50 groups are returned. The - * maximum value is 1000; values above 1000 are coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListRelatedAccountGroups` - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * `ListRelatedAccountGroups` must match the call that provided the 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup|RelatedAccountGroup}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recaptcha_enterprise_service.list_related_account_groups.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroups_async - */ - listRelatedAccountGroupsAsync( - request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, - 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['listRelatedAccountGroups']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRelatedAccountGroups.asyncIterate( - this.innerApiCalls['listRelatedAccountGroups'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Get memberships in a group of related accounts. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name for the related account group in the format - * `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of accounts to return. The service might - * return fewer than this value. If unspecified, at most 50 accounts are - * returned. The maximum value is 1000; values above 1000 are coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * `ListRelatedAccountGroupMemberships` call. - * - * When paginating, all other parameters provided to - * `ListRelatedAccountGroupMemberships` must match the call that provided the - * page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership|RelatedAccountGroupMembership}. - * 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 `listRelatedAccountGroupMembershipsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listRelatedAccountGroupMemberships( - request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[], - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest|null, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse - ]>; - listRelatedAccountGroupMemberships( - request: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): void; - listRelatedAccountGroupMemberships( - request: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): void; - listRelatedAccountGroupMemberships( - request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>, - callback?: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[], - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest|null, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listRelatedAccountGroupMemberships(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name for the related account group in the format - * `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of accounts to return. The service might - * return fewer than this value. If unspecified, at most 50 accounts are - * returned. The maximum value is 1000; values above 1000 are coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * `ListRelatedAccountGroupMemberships` call. - * - * When paginating, all other parameters provided to - * `ListRelatedAccountGroupMemberships` must match the call that provided the - * page token. - * @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 protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership|RelatedAccountGroupMembership} 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 `listRelatedAccountGroupMembershipsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listRelatedAccountGroupMembershipsStream( - request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, - 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['listRelatedAccountGroupMemberships']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRelatedAccountGroupMemberships.createStream( - this.innerApiCalls.listRelatedAccountGroupMemberships as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listRelatedAccountGroupMemberships`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name for the related account group in the format - * `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of accounts to return. The service might - * return fewer than this value. If unspecified, at most 50 accounts are - * returned. The maximum value is 1000; values above 1000 are coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * `ListRelatedAccountGroupMemberships` call. - * - * When paginating, all other parameters provided to - * `ListRelatedAccountGroupMemberships` must match the call that provided the - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership|RelatedAccountGroupMembership}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recaptcha_enterprise_service.list_related_account_group_memberships.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroupMemberships_async - */ - listRelatedAccountGroupMembershipsAsync( - request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, - 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['listRelatedAccountGroupMemberships']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate( - this.innerApiCalls['listRelatedAccountGroupMemberships'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Search group memberships related to a given account. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.project - * Required. The name of the project to search related account group - * memberships from. Specify the project name in the following format: - * "projects/{project}". - * @param {Buffer} [request.hashedAccountId] - * Optional. The unique stable hashed user identifier we should search - * connections to. The identifier should correspond to a `hashed_account_id` - * provided in a previous `CreateAssessment` or `AnnotateAssessment` call. - * @param {number} [request.pageSize] - * Optional. The maximum number of groups to return. The service might return - * fewer than this value. If unspecified, at most 50 groups are returned. The - * maximum value is 1000; values above 1000 are coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * `SearchRelatedAccountGroupMemberships` call. Provide this to retrieve the - * subsequent page. - * - * When paginating, all other parameters provided to - * `SearchRelatedAccountGroupMemberships` must match the call that provided - * the page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership|RelatedAccountGroupMembership}. - * 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 `searchRelatedAccountGroupMembershipsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - searchRelatedAccountGroupMemberships( - request?: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[], - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest|null, - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse - ]>; - searchRelatedAccountGroupMemberships( - request: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): void; - searchRelatedAccountGroupMemberships( - request: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): void; - searchRelatedAccountGroupMemberships( - request?: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>, - callback?: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[], - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest|null, - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - }); - this.initialize(); - return this.innerApiCalls.searchRelatedAccountGroupMemberships(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.project - * Required. The name of the project to search related account group - * memberships from. Specify the project name in the following format: - * "projects/{project}". - * @param {Buffer} [request.hashedAccountId] - * Optional. The unique stable hashed user identifier we should search - * connections to. The identifier should correspond to a `hashed_account_id` - * provided in a previous `CreateAssessment` or `AnnotateAssessment` call. - * @param {number} [request.pageSize] - * Optional. The maximum number of groups to return. The service might return - * fewer than this value. If unspecified, at most 50 groups are returned. The - * maximum value is 1000; values above 1000 are coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * `SearchRelatedAccountGroupMemberships` call. Provide this to retrieve the - * subsequent page. - * - * When paginating, all other parameters provided to - * `SearchRelatedAccountGroupMemberships` must match the call that provided - * the page token. - * @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 protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership|RelatedAccountGroupMembership} 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 `searchRelatedAccountGroupMembershipsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - searchRelatedAccountGroupMembershipsStream( - request?: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, - 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({ - 'project': request.project ?? '', - }); - const defaultCallSettings = this._defaults['searchRelatedAccountGroupMemberships']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchRelatedAccountGroupMemberships.createStream( - this.innerApiCalls.searchRelatedAccountGroupMemberships as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `searchRelatedAccountGroupMemberships`, 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.project - * Required. The name of the project to search related account group - * memberships from. Specify the project name in the following format: - * "projects/{project}". - * @param {Buffer} [request.hashedAccountId] - * Optional. The unique stable hashed user identifier we should search - * connections to. The identifier should correspond to a `hashed_account_id` - * provided in a previous `CreateAssessment` or `AnnotateAssessment` call. - * @param {number} [request.pageSize] - * Optional. The maximum number of groups to return. The service might return - * fewer than this value. If unspecified, at most 50 groups are returned. The - * maximum value is 1000; values above 1000 are coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * `SearchRelatedAccountGroupMemberships` call. Provide this to retrieve the - * subsequent page. - * - * When paginating, all other parameters provided to - * `SearchRelatedAccountGroupMemberships` must match the call that provided - * the 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership|RelatedAccountGroupMembership}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recaptcha_enterprise_service.search_related_account_group_memberships.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_SearchRelatedAccountGroupMemberships_async - */ - searchRelatedAccountGroupMembershipsAsync( - request?: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, - 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({ - 'project': request.project ?? '', - }); - const defaultCallSettings = this._defaults['searchRelatedAccountGroupMemberships']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate( - this.innerApiCalls['searchRelatedAccountGroupMemberships'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified assessment resource name string. - * - * @param {string} project - * @param {string} assessment - * @returns {string} Resource name string. - */ - assessmentPath(project:string,assessment:string) { - return this.pathTemplates.assessmentPathTemplate.render({ - project: project, - assessment: assessment, - }); - } - - /** - * Parse the project from Assessment resource. - * - * @param {string} assessmentName - * A fully-qualified path representing Assessment resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAssessmentName(assessmentName: string) { - return this.pathTemplates.assessmentPathTemplate.match(assessmentName).project; - } - - /** - * Parse the assessment from Assessment resource. - * - * @param {string} assessmentName - * A fully-qualified path representing Assessment resource. - * @returns {string} A string representing the assessment. - */ - matchAssessmentFromAssessmentName(assessmentName: string) { - return this.pathTemplates.assessmentPathTemplate.match(assessmentName).assessment; - } - - /** - * Return a fully-qualified key resource name string. - * - * @param {string} project - * @param {string} key - * @returns {string} Resource name string. - */ - keyPath(project:string,key:string) { - return this.pathTemplates.keyPathTemplate.render({ - project: project, - key: key, - }); - } - - /** - * Parse the project from Key resource. - * - * @param {string} keyName - * A fully-qualified path representing Key resource. - * @returns {string} A string representing the project. - */ - matchProjectFromKeyName(keyName: string) { - return this.pathTemplates.keyPathTemplate.match(keyName).project; - } - - /** - * Parse the key from Key resource. - * - * @param {string} keyName - * A fully-qualified path representing Key resource. - * @returns {string} A string representing the key. - */ - matchKeyFromKeyName(keyName: string) { - return this.pathTemplates.keyPathTemplate.match(keyName).key; - } - - /** - * Return a fully-qualified metrics resource name string. - * - * @param {string} project - * @param {string} key - * @returns {string} Resource name string. - */ - metricsPath(project:string,key:string) { - return this.pathTemplates.metricsPathTemplate.render({ - project: project, - key: key, - }); - } - - /** - * Parse the project from Metrics resource. - * - * @param {string} metricsName - * A fully-qualified path representing Metrics resource. - * @returns {string} A string representing the project. - */ - matchProjectFromMetricsName(metricsName: string) { - return this.pathTemplates.metricsPathTemplate.match(metricsName).project; - } - - /** - * Parse the key from Metrics resource. - * - * @param {string} metricsName - * A fully-qualified path representing Metrics resource. - * @returns {string} A string representing the key. - */ - matchKeyFromMetricsName(metricsName: string) { - return this.pathTemplates.metricsPathTemplate.match(metricsName).key; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified relatedAccountGroup resource name string. - * - * @param {string} project - * @param {string} relatedaccountgroup - * @returns {string} Resource name string. - */ - relatedAccountGroupPath(project:string,relatedaccountgroup:string) { - return this.pathTemplates.relatedAccountGroupPathTemplate.render({ - project: project, - relatedaccountgroup: relatedaccountgroup, - }); - } - - /** - * Parse the project from RelatedAccountGroup resource. - * - * @param {string} relatedAccountGroupName - * A fully-qualified path representing RelatedAccountGroup resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRelatedAccountGroupName(relatedAccountGroupName: string) { - return this.pathTemplates.relatedAccountGroupPathTemplate.match(relatedAccountGroupName).project; - } - - /** - * Parse the relatedaccountgroup from RelatedAccountGroup resource. - * - * @param {string} relatedAccountGroupName - * A fully-qualified path representing RelatedAccountGroup resource. - * @returns {string} A string representing the relatedaccountgroup. - */ - matchRelatedaccountgroupFromRelatedAccountGroupName(relatedAccountGroupName: string) { - return this.pathTemplates.relatedAccountGroupPathTemplate.match(relatedAccountGroupName).relatedaccountgroup; - } - - /** - * Return a fully-qualified relatedAccountGroupMembership resource name string. - * - * @param {string} project - * @param {string} relatedaccountgroup - * @param {string} membership - * @returns {string} Resource name string. - */ - relatedAccountGroupMembershipPath(project:string,relatedaccountgroup:string,membership:string) { - return this.pathTemplates.relatedAccountGroupMembershipPathTemplate.render({ - project: project, - relatedaccountgroup: relatedaccountgroup, - membership: membership, - }); - } - - /** - * Parse the project from RelatedAccountGroupMembership resource. - * - * @param {string} relatedAccountGroupMembershipName - * A fully-qualified path representing RelatedAccountGroupMembership resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRelatedAccountGroupMembershipName(relatedAccountGroupMembershipName: string) { - return this.pathTemplates.relatedAccountGroupMembershipPathTemplate.match(relatedAccountGroupMembershipName).project; - } - - /** - * Parse the relatedaccountgroup from RelatedAccountGroupMembership resource. - * - * @param {string} relatedAccountGroupMembershipName - * A fully-qualified path representing RelatedAccountGroupMembership resource. - * @returns {string} A string representing the relatedaccountgroup. - */ - matchRelatedaccountgroupFromRelatedAccountGroupMembershipName(relatedAccountGroupMembershipName: string) { - return this.pathTemplates.relatedAccountGroupMembershipPathTemplate.match(relatedAccountGroupMembershipName).relatedaccountgroup; - } - - /** - * Parse the membership from RelatedAccountGroupMembership resource. - * - * @param {string} relatedAccountGroupMembershipName - * A fully-qualified path representing RelatedAccountGroupMembership resource. - * @returns {string} A string representing the membership. - */ - matchMembershipFromRelatedAccountGroupMembershipName(relatedAccountGroupMembershipName: string) { - return this.pathTemplates.relatedAccountGroupMembershipPathTemplate.match(relatedAccountGroupMembershipName).membership; - } - - /** - * 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.recaptchaEnterpriseServiceStub && !this._terminated) { - return this.recaptchaEnterpriseServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_client_config.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_client_config.json deleted file mode 100644 index acb5f95bd9c..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_client_config.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "interfaces": { - "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService": { - "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": { - "CreateAssessment": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "AnnotateAssessment": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateKey": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListKeys": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RetrieveLegacySecretKey": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetKey": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateKey": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteKey": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "MigrateKey": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetMetrics": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListRelatedAccountGroups": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListRelatedAccountGroupMemberships": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "SearchRelatedAccountGroupMemberships": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_proto_list.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_proto_list.json deleted file mode 100644 index 790fef960af..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/src/v1/recaptcha_enterprise_service_proto_list.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "../../protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto" -] diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 765861da444..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const recaptchaenterprise = require('@google-cloud/recaptcha-enterprise'); - -function main() { - const recaptchaEnterpriseServiceClient = new recaptchaenterprise.RecaptchaEnterpriseServiceClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 29561bc0841..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {RecaptchaEnterpriseServiceClient} from '@google-cloud/recaptcha-enterprise'; - -// check that the client class type name can be used -function doStuffWithRecaptchaEnterpriseServiceClient(client: RecaptchaEnterpriseServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient(); - doStuffWithRecaptchaEnterpriseServiceClient(recaptchaEnterpriseServiceClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/install.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/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-recaptchaenterprise/v1/test/gapic_recaptcha_enterprise_service_v1.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/test/gapic_recaptcha_enterprise_service_v1.ts deleted file mode 100644 index 6caf38f8ca0..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/test/gapic_recaptcha_enterprise_service_v1.ts +++ /dev/null @@ -1,2384 +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 recaptchaenterpriseserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.RecaptchaEnterpriseServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.recaptchaEnterpriseServiceStub, undefined); - await client.initialize(); - assert(client.recaptchaEnterpriseServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.recaptchaEnterpriseServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.recaptchaEnterpriseServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - 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 recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - 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('createAssessment', () => { - it('invokes createAssessment without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.Assessment() - ); - client.innerApiCalls.createAssessment = stubSimpleCall(expectedResponse); - const [response] = await client.createAssessment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createAssessment without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.Assessment() - ); - client.innerApiCalls.createAssessment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createAssessment( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IAssessment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createAssessment with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createAssessment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createAssessment(request), expectedError); - const actualRequest = (client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createAssessment with closed client', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createAssessment(request), expectedError); - }); - }); - - describe('annotateAssessment', () => { - it('invokes annotateAssessment without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentResponse() - ); - client.innerApiCalls.annotateAssessment = stubSimpleCall(expectedResponse); - const [response] = await client.annotateAssessment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes annotateAssessment without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentResponse() - ); - client.innerApiCalls.annotateAssessment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.annotateAssessment( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes annotateAssessment with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.annotateAssessment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.annotateAssessment(request), expectedError); - const actualRequest = (client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes annotateAssessment with closed client', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.annotateAssessment(request), expectedError); - }); - }); - - describe('createKey', () => { - it('invokes createKey without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.CreateKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.CreateKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.Key() - ); - client.innerApiCalls.createKey = stubSimpleCall(expectedResponse); - const [response] = await client.createKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createKey without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.CreateKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.CreateKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.Key() - ); - client.innerApiCalls.createKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createKey( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createKey with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.CreateKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.CreateKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createKey(request), expectedError); - const actualRequest = (client.innerApiCalls.createKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createKey with closed client', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.CreateKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.CreateKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createKey(request), expectedError); - }); - }); - - describe('retrieveLegacySecretKey', () => { - it('invokes retrieveLegacySecretKey without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyRequest', ['key']); - request.key = defaultValue1; - const expectedHeaderRequestParams = `key=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyResponse() - ); - client.innerApiCalls.retrieveLegacySecretKey = stubSimpleCall(expectedResponse); - const [response] = await client.retrieveLegacySecretKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.retrieveLegacySecretKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.retrieveLegacySecretKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes retrieveLegacySecretKey without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyRequest', ['key']); - request.key = defaultValue1; - const expectedHeaderRequestParams = `key=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyResponse() - ); - client.innerApiCalls.retrieveLegacySecretKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.retrieveLegacySecretKey( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IRetrieveLegacySecretKeyResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.retrieveLegacySecretKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.retrieveLegacySecretKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes retrieveLegacySecretKey with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyRequest', ['key']); - request.key = defaultValue1; - const expectedHeaderRequestParams = `key=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.retrieveLegacySecretKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.retrieveLegacySecretKey(request), expectedError); - const actualRequest = (client.innerApiCalls.retrieveLegacySecretKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.retrieveLegacySecretKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes retrieveLegacySecretKey with closed client', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.RetrieveLegacySecretKeyRequest', ['key']); - request.key = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.retrieveLegacySecretKey(request), expectedError); - }); - }); - - describe('getKey', () => { - it('invokes getKey without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.GetKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.GetKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.Key() - ); - client.innerApiCalls.getKey = stubSimpleCall(expectedResponse); - const [response] = await client.getKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getKey without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.GetKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.GetKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.Key() - ); - client.innerApiCalls.getKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getKey( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getKey with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.GetKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.GetKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getKey(request), expectedError); - const actualRequest = (client.innerApiCalls.getKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getKey with closed client', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.GetKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.GetKeyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getKey(request), expectedError); - }); - }); - - describe('updateKey', () => { - it('invokes updateKey without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest() - ); - request.key ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest', ['key', 'name']); - request.key.name = defaultValue1; - const expectedHeaderRequestParams = `key.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.Key() - ); - client.innerApiCalls.updateKey = stubSimpleCall(expectedResponse); - const [response] = await client.updateKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateKey without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest() - ); - request.key ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest', ['key', 'name']); - request.key.name = defaultValue1; - const expectedHeaderRequestParams = `key.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.Key() - ); - client.innerApiCalls.updateKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateKey( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateKey with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest() - ); - request.key ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest', ['key', 'name']); - request.key.name = defaultValue1; - const expectedHeaderRequestParams = `key.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateKey(request), expectedError); - const actualRequest = (client.innerApiCalls.updateKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateKey with closed client', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest() - ); - request.key ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest', ['key', 'name']); - request.key.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateKey(request), expectedError); - }); - }); - - describe('deleteKey', () => { - it('invokes deleteKey without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteKey = stubSimpleCall(expectedResponse); - const [response] = await client.deleteKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteKey without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteKey( - 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.deleteKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteKey with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteKey(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteKey with closed client', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteKey(request), expectedError); - }); - }); - - describe('migrateKey', () => { - it('invokes migrateKey without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.MigrateKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.MigrateKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.Key() - ); - client.innerApiCalls.migrateKey = stubSimpleCall(expectedResponse); - const [response] = await client.migrateKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.migrateKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.migrateKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes migrateKey without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.MigrateKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.MigrateKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.Key() - ); - client.innerApiCalls.migrateKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.migrateKey( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.migrateKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.migrateKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes migrateKey with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.MigrateKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.MigrateKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.migrateKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.migrateKey(request), expectedError); - const actualRequest = (client.innerApiCalls.migrateKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.migrateKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes migrateKey with closed client', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.MigrateKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.MigrateKeyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.migrateKey(request), expectedError); - }); - }); - - describe('getMetrics', () => { - it('invokes getMetrics without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.GetMetricsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.GetMetricsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.Metrics() - ); - client.innerApiCalls.getMetrics = stubSimpleCall(expectedResponse); - const [response] = await client.getMetrics(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMetrics as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMetrics as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getMetrics without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.GetMetricsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.GetMetricsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.Metrics() - ); - client.innerApiCalls.getMetrics = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getMetrics( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IMetrics|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMetrics as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMetrics as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getMetrics with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.GetMetricsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.GetMetricsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getMetrics = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getMetrics(request), expectedError); - const actualRequest = (client.innerApiCalls.getMetrics as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMetrics as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getMetrics with closed client', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.GetMetricsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.GetMetricsRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getMetrics(request), expectedError); - }); - }); - - describe('listKeys', () => { - it('invokes listKeys without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListKeysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - ]; - client.innerApiCalls.listKeys = stubSimpleCall(expectedResponse); - const [response] = await client.listKeys(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listKeys as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listKeys as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listKeys without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListKeysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - ]; - client.innerApiCalls.listKeys = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listKeys( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listKeys as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listKeys as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listKeys with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListKeysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listKeys = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listKeys(request), expectedError); - const actualRequest = (client.innerApiCalls.listKeys as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listKeys as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listKeysStream without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListKeysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - ]; - client.descriptors.page.listKeys.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listKeysStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1.Key[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.Key) => { - 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.listKeys.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listKeys, request)); - assert( - (client.descriptors.page.listKeys.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listKeysStream with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListKeysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listKeys.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listKeysStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1.Key[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.Key) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listKeys.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listKeys, request)); - assert( - (client.descriptors.page.listKeys.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listKeys without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListKeysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - ]; - client.descriptors.page.listKeys.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.recaptchaenterprise.v1.IKey[] = []; - const iterable = client.listKeysAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listKeys.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listKeys.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listKeys with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListKeysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listKeys.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listKeysAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.recaptchaenterprise.v1.IKey[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listKeys.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listKeys.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listRelatedAccountGroups', () => { - it('invokes listRelatedAccountGroups without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - ]; - client.innerApiCalls.listRelatedAccountGroups = stubSimpleCall(expectedResponse); - const [response] = await client.listRelatedAccountGroups(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRelatedAccountGroups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRelatedAccountGroups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRelatedAccountGroups without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - ]; - client.innerApiCalls.listRelatedAccountGroups = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listRelatedAccountGroups( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRelatedAccountGroups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRelatedAccountGroups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRelatedAccountGroups with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listRelatedAccountGroups = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listRelatedAccountGroups(request), expectedError); - const actualRequest = (client.innerApiCalls.listRelatedAccountGroups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRelatedAccountGroups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRelatedAccountGroupsStream without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - ]; - client.descriptors.page.listRelatedAccountGroups.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listRelatedAccountGroupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup) => { - 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.listRelatedAccountGroups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRelatedAccountGroups, request)); - assert( - (client.descriptors.page.listRelatedAccountGroups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listRelatedAccountGroupsStream with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listRelatedAccountGroups.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listRelatedAccountGroupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listRelatedAccountGroups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRelatedAccountGroups, request)); - assert( - (client.descriptors.page.listRelatedAccountGroups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRelatedAccountGroups without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - ]; - client.descriptors.page.listRelatedAccountGroups.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup[] = []; - const iterable = client.listRelatedAccountGroupsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listRelatedAccountGroups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRelatedAccountGroups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRelatedAccountGroups with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listRelatedAccountGroups.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listRelatedAccountGroupsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listRelatedAccountGroups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRelatedAccountGroups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listRelatedAccountGroupMemberships', () => { - it('invokes listRelatedAccountGroupMemberships without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - ]; - client.innerApiCalls.listRelatedAccountGroupMemberships = stubSimpleCall(expectedResponse); - const [response] = await client.listRelatedAccountGroupMemberships(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRelatedAccountGroupMemberships as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRelatedAccountGroupMemberships as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRelatedAccountGroupMemberships without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - ]; - client.innerApiCalls.listRelatedAccountGroupMemberships = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listRelatedAccountGroupMemberships( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRelatedAccountGroupMemberships as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRelatedAccountGroupMemberships as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRelatedAccountGroupMemberships with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listRelatedAccountGroupMemberships = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listRelatedAccountGroupMemberships(request), expectedError); - const actualRequest = (client.innerApiCalls.listRelatedAccountGroupMemberships as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRelatedAccountGroupMemberships as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRelatedAccountGroupMembershipsStream without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - ]; - client.descriptors.page.listRelatedAccountGroupMemberships.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listRelatedAccountGroupMembershipsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership) => { - 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.listRelatedAccountGroupMemberships.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRelatedAccountGroupMemberships, request)); - assert( - (client.descriptors.page.listRelatedAccountGroupMemberships.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listRelatedAccountGroupMembershipsStream with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listRelatedAccountGroupMemberships.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listRelatedAccountGroupMembershipsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listRelatedAccountGroupMemberships.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRelatedAccountGroupMemberships, request)); - assert( - (client.descriptors.page.listRelatedAccountGroupMemberships.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRelatedAccountGroupMemberships without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - ]; - client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[] = []; - const iterable = client.listRelatedAccountGroupMembershipsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRelatedAccountGroupMemberships with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.ListRelatedAccountGroupMembershipsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listRelatedAccountGroupMembershipsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('searchRelatedAccountGroupMemberships', () => { - it('invokes searchRelatedAccountGroupMemberships without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - ]; - client.innerApiCalls.searchRelatedAccountGroupMemberships = stubSimpleCall(expectedResponse); - const [response] = await client.searchRelatedAccountGroupMemberships(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchRelatedAccountGroupMemberships as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchRelatedAccountGroupMemberships as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes searchRelatedAccountGroupMemberships without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - ]; - client.innerApiCalls.searchRelatedAccountGroupMemberships = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchRelatedAccountGroupMemberships( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchRelatedAccountGroupMemberships as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchRelatedAccountGroupMemberships as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes searchRelatedAccountGroupMemberships with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.searchRelatedAccountGroupMemberships = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchRelatedAccountGroupMemberships(request), expectedError); - const actualRequest = (client.innerApiCalls.searchRelatedAccountGroupMemberships as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchRelatedAccountGroupMemberships as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes searchRelatedAccountGroupMembershipsStream without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - ]; - client.descriptors.page.searchRelatedAccountGroupMemberships.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchRelatedAccountGroupMembershipsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership) => { - 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.searchRelatedAccountGroupMemberships.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchRelatedAccountGroupMemberships, request)); - assert( - (client.descriptors.page.searchRelatedAccountGroupMemberships.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes searchRelatedAccountGroupMembershipsStream with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.searchRelatedAccountGroupMemberships.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchRelatedAccountGroupMembershipsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.searchRelatedAccountGroupMemberships.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchRelatedAccountGroupMemberships, request)); - assert( - (client.descriptors.page.searchRelatedAccountGroupMemberships.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with searchRelatedAccountGroupMemberships without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - ]; - client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[] = []; - const iterable = client.searchRelatedAccountGroupMembershipsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with searchRelatedAccountGroupMemberships with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1.SearchRelatedAccountGroupMembershipsRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchRelatedAccountGroupMembershipsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('assessment', () => { - const fakePath = "/rendered/path/assessment"; - const expectedParameters = { - project: "projectValue", - assessment: "assessmentValue", - }; - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.assessmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.assessmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('assessmentPath', () => { - const result = client.assessmentPath("projectValue", "assessmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.assessmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAssessmentName', () => { - const result = client.matchProjectFromAssessmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.assessmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAssessmentFromAssessmentName', () => { - const result = client.matchAssessmentFromAssessmentName(fakePath); - assert.strictEqual(result, "assessmentValue"); - assert((client.pathTemplates.assessmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('key', () => { - const fakePath = "/rendered/path/key"; - const expectedParameters = { - project: "projectValue", - key: "keyValue", - }; - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.keyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.keyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('keyPath', () => { - const result = client.keyPath("projectValue", "keyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.keyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromKeyName', () => { - const result = client.matchProjectFromKeyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.keyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyFromKeyName', () => { - const result = client.matchKeyFromKeyName(fakePath); - assert.strictEqual(result, "keyValue"); - assert((client.pathTemplates.keyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('metrics', () => { - const fakePath = "/rendered/path/metrics"; - const expectedParameters = { - project: "projectValue", - key: "keyValue", - }; - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.metricsPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.metricsPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('metricsPath', () => { - const result = client.metricsPath("projectValue", "keyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.metricsPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMetricsName', () => { - const result = client.matchProjectFromMetricsName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.metricsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyFromMetricsName', () => { - const result = client.matchKeyFromMetricsName(fakePath); - assert.strictEqual(result, "keyValue"); - assert((client.pathTemplates.metricsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('relatedAccountGroup', () => { - const fakePath = "/rendered/path/relatedAccountGroup"; - const expectedParameters = { - project: "projectValue", - relatedaccountgroup: "relatedaccountgroupValue", - }; - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.relatedAccountGroupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.relatedAccountGroupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('relatedAccountGroupPath', () => { - const result = client.relatedAccountGroupPath("projectValue", "relatedaccountgroupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.relatedAccountGroupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRelatedAccountGroupName', () => { - const result = client.matchProjectFromRelatedAccountGroupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.relatedAccountGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRelatedaccountgroupFromRelatedAccountGroupName', () => { - const result = client.matchRelatedaccountgroupFromRelatedAccountGroupName(fakePath); - assert.strictEqual(result, "relatedaccountgroupValue"); - assert((client.pathTemplates.relatedAccountGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('relatedAccountGroupMembership', () => { - const fakePath = "/rendered/path/relatedAccountGroupMembership"; - const expectedParameters = { - project: "projectValue", - relatedaccountgroup: "relatedaccountgroupValue", - membership: "membershipValue", - }; - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.relatedAccountGroupMembershipPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.relatedAccountGroupMembershipPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('relatedAccountGroupMembershipPath', () => { - const result = client.relatedAccountGroupMembershipPath("projectValue", "relatedaccountgroupValue", "membershipValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.relatedAccountGroupMembershipPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRelatedAccountGroupMembershipName', () => { - const result = client.matchProjectFromRelatedAccountGroupMembershipName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.relatedAccountGroupMembershipPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRelatedaccountgroupFromRelatedAccountGroupMembershipName', () => { - const result = client.matchRelatedaccountgroupFromRelatedAccountGroupMembershipName(fakePath); - assert.strictEqual(result, "relatedaccountgroupValue"); - assert((client.pathTemplates.relatedAccountGroupMembershipPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMembershipFromRelatedAccountGroupMembershipName', () => { - const result = client.matchMembershipFromRelatedAccountGroupMembershipName(fakePath); - assert.strictEqual(result, "membershipValue"); - assert((client.pathTemplates.relatedAccountGroupMembershipPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/tsconfig.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/webpack.config.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1/webpack.config.js deleted file mode 100644 index 6a9d07da0f4..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'RecaptchaEnterpriseService', - filename: './recaptcha-enterprise-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-recaptchaenterprise/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.gitignore b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.jsdoc.js deleted file mode 100644 index 495384476fc..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.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/recaptcha-enterprise', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.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-recaptchaenterprise/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/.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-recaptchaenterprise/v1beta1/README.md b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/README.md deleted file mode 100644 index 57a5e168123..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Recaptchaenterprise: Nodejs Client diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/package.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/package.json deleted file mode 100644 index 4461de9c2d1..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/recaptcha-enterprise", - "version": "0.1.0", - "description": "Recaptchaenterprise client for Node.js", - "repository": "googleapis/nodejs-recaptchaenterprise", - "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 recaptchaenterprise", - "recaptchaenterprise", - "recaptcha enterprise service v1 beta1" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto deleted file mode 100644 index 8d44b92e411..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto +++ /dev/null @@ -1,682 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.recaptchaenterprise.v1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.RecaptchaEnterprise.V1Beta1"; -option go_package = "cloud.google.com/go/recaptchaenterprise/v2/apiv1beta1/recaptchaenterprisepb;recaptchaenterprisepb"; -option java_multiple_files = true; -option java_outer_classname = "RecaptchaEnterpriseProto"; -option java_package = "com.google.recaptchaenterprise.v1beta1"; -option objc_class_prefix = "GCRE"; -option php_namespace = "Google\\Cloud\\RecaptchaEnterprise\\V1beta1"; -option ruby_package = "Google::Cloud::RecaptchaEnterprise::V1beta1"; - -// Service to determine the likelihood an event is legitimate. -service RecaptchaEnterpriseServiceV1Beta1 { - option (google.api.default_host) = "recaptchaenterprise.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates an Assessment of the likelihood an event is legitimate. - rpc CreateAssessment(CreateAssessmentRequest) returns (Assessment) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*}/assessments" - body: "assessment" - }; - option (google.api.method_signature) = "parent,assessment"; - } - - // Annotates a previously created Assessment to provide additional information - // on whether the event turned out to be authentic or fradulent. - rpc AnnotateAssessment(AnnotateAssessmentRequest) - returns (AnnotateAssessmentResponse) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/assessments/*}:annotate" - body: "*" - }; - option (google.api.method_signature) = "name,annotation"; - } -} - -// The create assessment request message. -message CreateAssessmentRequest { - // Required. The name of the project in which the assessment will be created, - // in the format "projects/{project_number}". - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Required. The assessment details. - Assessment assessment = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Describes an event in the lifecycle of a payment transaction. -message TransactionEvent { - // Enum that represents an event in the payment transaction lifecycle. - enum TransactionEventType { - // Default, unspecified event type. - TRANSACTION_EVENT_TYPE_UNSPECIFIED = 0; - - // Indicates that the transaction is approved by the merchant. The - // accompanying reasons can include terms such as 'INHOUSE', 'ACCERTIFY', - // 'CYBERSOURCE', or 'MANUAL_REVIEW'. - MERCHANT_APPROVE = 1; - - // Indicates that the transaction is denied and concluded due to risks - // detected by the merchant. The accompanying reasons can include terms such - // as 'INHOUSE', 'ACCERTIFY', 'CYBERSOURCE', or 'MANUAL_REVIEW'. - MERCHANT_DENY = 2; - - // Indicates that the transaction is being evaluated by a human, due to - // suspicion or risk. - MANUAL_REVIEW = 3; - - // Indicates that the authorization attempt with the card issuer succeeded. - AUTHORIZATION = 4; - - // Indicates that the authorization attempt with the card issuer failed. - // The accompanying reasons can include Visa's '54' indicating that the card - // is expired, or '82' indicating that the CVV is incorrect. - AUTHORIZATION_DECLINE = 5; - - // Indicates that the transaction is completed because the funds were - // settled. - PAYMENT_CAPTURE = 6; - - // Indicates that the transaction could not be completed because the funds - // were not settled. - PAYMENT_CAPTURE_DECLINE = 7; - - // Indicates that the transaction has been canceled. Specify the reason - // for the cancellation. For example, 'INSUFFICIENT_INVENTORY'. - CANCEL = 8; - - // Indicates that the merchant has received a chargeback inquiry due to - // fraud for the transaction, requesting additional information before a - // fraud chargeback is officially issued and a formal chargeback - // notification is sent. - CHARGEBACK_INQUIRY = 9; - - // Indicates that the merchant has received a chargeback alert due to fraud - // for the transaction. The process of resolving the dispute without - // involving the payment network is started. - CHARGEBACK_ALERT = 10; - - // Indicates that a fraud notification is issued for the transaction, sent - // by the payment instrument's issuing bank because the transaction appears - // to be fraudulent. We recommend including TC40 or SAFE data in the - // `reason` field for this event type. For partial chargebacks, we recommend - // that you include an amount in the `value` field. - FRAUD_NOTIFICATION = 11; - - // Indicates that the merchant is informed by the payment network that the - // transaction has entered the chargeback process due to fraud. Reason code - // examples include Discover's '6005' and '6041'. For partial chargebacks, - // we recommend that you include an amount in the `value` field. - CHARGEBACK = 12; - - // Indicates that the transaction has entered the chargeback process due to - // fraud, and that the merchant has chosen to enter representment. Reason - // examples include Discover's '6005' and '6041'. For partial chargebacks, - // we recommend that you include an amount in the `value` field. - CHARGEBACK_REPRESENTMENT = 13; - - // Indicates that the transaction has had a fraud chargeback which was - // illegitimate and was reversed as a result. For partial chargebacks, we - // recommend that you include an amount in the `value` field. - CHARGEBACK_REVERSE = 14; - - // Indicates that the merchant has received a refund for a completed - // transaction. For partial refunds, we recommend that you include an amount - // in the `value` field. Reason example: 'TAX_EXEMPT' (partial refund of - // exempt tax) - REFUND_REQUEST = 15; - - // Indicates that the merchant has received a refund request for this - // transaction, but that they have declined it. For partial refunds, we - // recommend that you include an amount in the `value` field. Reason - // example: 'TAX_EXEMPT' (partial refund of exempt tax) - REFUND_DECLINE = 16; - - // Indicates that the completed transaction was refunded by the merchant. - // For partial refunds, we recommend that you include an amount in the - // `value` field. Reason example: 'TAX_EXEMPT' (partial refund of exempt - // tax) - REFUND = 17; - - // Indicates that the completed transaction was refunded by the merchant, - // and that this refund was reversed. For partial refunds, we recommend that - // you include an amount in the `value` field. - REFUND_REVERSE = 18; - } - - // Optional. The type of this transaction event. - TransactionEventType event_type = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The reason or standardized code that corresponds with this - // transaction event, if one exists. For example, a CHARGEBACK event with code - // 6005. - string reason = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The value that corresponds with this transaction event, if one - // exists. For example, a refund event where $5.00 was refunded. Currency is - // obtained from the original transaction data. - double value = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Timestamp when this transaction event occurred; otherwise assumed - // to be the time of the API call. - google.protobuf.Timestamp event_time = 4 - [(google.api.field_behavior) = OPTIONAL]; -} - -// The request message to annotate an Assessment. -message AnnotateAssessmentRequest { - // Enum that represents the types of annotations. - enum Annotation { - // Default unspecified type. - ANNOTATION_UNSPECIFIED = 0; - - // Provides information that the event turned out to be legitimate. - LEGITIMATE = 1; - - // Provides information that the event turned out to be fraudulent. - FRAUDULENT = 2; - - // Provides information that the event was related to a login event in which - // the user typed the correct password. Deprecated, prefer indicating - // CORRECT_PASSWORD through the reasons field instead. - PASSWORD_CORRECT = 3 [deprecated = true]; - - // Provides information that the event was related to a login event in which - // the user typed the incorrect password. Deprecated, prefer indicating - // INCORRECT_PASSWORD through the reasons field instead. - PASSWORD_INCORRECT = 4 [deprecated = true]; - } - - // Enum that represents potential reasons for annotating an assessment. - enum Reason { - // Default unspecified reason. - REASON_UNSPECIFIED = 0; - - // Indicates that the transaction had a chargeback issued with no other - // details. When possible, specify the type by using CHARGEBACK_FRAUD or - // CHARGEBACK_DISPUTE instead. - CHARGEBACK = 1; - - // Indicates that the transaction had a chargeback issued related to an - // alleged unauthorized transaction from the cardholder's perspective (for - // example, the card number was stolen). - CHARGEBACK_FRAUD = 8; - - // Indicates that the transaction had a chargeback issued related to the - // cardholder having provided their card details but allegedly not being - // satisfied with the purchase (for example, misrepresentation, attempted - // cancellation). - CHARGEBACK_DISPUTE = 9; - - // Indicates that the completed payment transaction was refunded by the - // seller. - REFUND = 10; - - // Indicates that the completed payment transaction was determined to be - // fraudulent by the seller, and was cancelled and refunded as a result. - REFUND_FRAUD = 11; - - // Indicates that the payment transaction was accepted, and the user was - // charged. - TRANSACTION_ACCEPTED = 12; - - // Indicates that the payment transaction was declined, for example due to - // invalid card details. - TRANSACTION_DECLINED = 13; - - // Indicates the transaction associated with the assessment is suspected of - // being fraudulent based on the payment method, billing details, shipping - // address or other transaction information. - PAYMENT_HEURISTICS = 2; - - // Indicates that the user was served a 2FA challenge. An old assessment - // with `ENUM_VALUES.INITIATED_TWO_FACTOR` reason that has not been - // overwritten with `PASSED_TWO_FACTOR` is treated as an abandoned 2FA flow. - // This is equivalent to `FAILED_TWO_FACTOR`. - INITIATED_TWO_FACTOR = 7; - - // Indicates that the user passed a 2FA challenge. - PASSED_TWO_FACTOR = 3; - - // Indicates that the user failed a 2FA challenge. - FAILED_TWO_FACTOR = 4; - - // Indicates the user provided the correct password. - CORRECT_PASSWORD = 5; - - // Indicates the user provided an incorrect password. - INCORRECT_PASSWORD = 6; - - // Indicates that the user sent unwanted and abusive messages to other users - // of the platform, such as spam, scams, phishing, or social engineering. - SOCIAL_SPAM = 14; - } - - // Required. The resource name of the Assessment, in the format - // "projects/{project_number}/assessments/{assessment_id}". - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recaptchaenterprise.googleapis.com/Assessment" - } - ]; - - // Optional. The annotation that will be assigned to the Event. This field can - // be left empty to provide reasons that apply to an event without concluding - // whether the event is legitimate or fraudulent. - Annotation annotation = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Optional reasons for the annotation that will be assigned to the - // Event. - repeated Reason reasons = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Optional unique stable hashed user identifier to apply to the - // assessment. This is an alternative to setting the hashed_account_id in - // CreateAssessment, for example when the account identifier is not yet known - // in the initial request. It is recommended that the identifier is hashed - // using hmac-sha256 with stable secret. - bytes hashed_account_id = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. If the assessment is part of a payment transaction, provide - // details on payment lifecycle events that occur in the transaction. - TransactionEvent transaction_event = 5 - [(google.api.field_behavior) = OPTIONAL]; -} - -// Empty response for AnnotateAssessment. -message AnnotateAssessmentResponse {} - -// Password leak verification info. -message PasswordLeakVerification { - // Optional. Scrypt hash of the username+password that the customer wants to - // verify against a known password leak. - bytes hashed_user_credentials = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. Whether or not the user's credentials are present in a known - // leak. - bool credentials_leaked = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. The username part of the user credentials for which we want to - // trigger a leak check in canonicalized form. This is the same data used to - // create the hashed_user_credentials on the customer side. - string canonicalized_username = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// A reCAPTCHA Enterprise assessment resource. -message Assessment { - option (google.api.resource) = { - type: "recaptchaenterprise.googleapis.com/Assessment" - pattern: "projects/{project}/assessments/{assessment}" - }; - - // Reasons contributing to the risk analysis verdict. - enum ClassificationReason { - // Default unspecified type. - CLASSIFICATION_REASON_UNSPECIFIED = 0; - - // Interactions matched the behavior of an automated agent. - AUTOMATION = 1; - - // The event originated from an illegitimate environment. - UNEXPECTED_ENVIRONMENT = 2; - - // Traffic volume from the event source is higher than normal. - TOO_MUCH_TRAFFIC = 3; - - // Interactions with the site were significantly different than expected - // patterns. - UNEXPECTED_USAGE_PATTERNS = 4; - - // Too little traffic has been received from this site thus far to generate - // quality risk analysis. - LOW_CONFIDENCE_SCORE = 5; - - // The request matches behavioral characteristics of a carding attack. - SUSPECTED_CARDING = 6; - - // The request matches behavioral characteristics of chargebacks for fraud. - SUSPECTED_CHARGEBACK = 7; - } - - // Output only. The resource name for the Assessment in the format - // "projects/{project_number}/assessments/{assessment_id}". - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The event being assessed. - Event event = 2; - - // Output only. Legitimate event score from 0.0 to 1.0. - // (1.0 means very likely legitimate traffic while 0.0 means very likely - // non-legitimate traffic). - float score = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Properties of the provided event token. - TokenProperties token_properties = 4 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Reasons contributing to the risk analysis verdict. - repeated ClassificationReason reasons = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Information about the user's credentials used to check for leaks. - // This feature is part of the Early Access Program (EAP). Exercise caution, - // and do not deploy integrations based on this feature in a production - // environment. - PasswordLeakVerification password_leak_verification = 7; - - // Assessment returned by account defender when a hashed_account_id is - // provided. - AccountDefenderAssessment account_defender_assessment = 8; - - // Assessment returned by Fraud Prevention when TransactionData is provided. - FraudPreventionAssessment fraud_prevention_assessment = 11; -} - -message Event { - // Optional. The user response token provided by the reCAPTCHA Enterprise - // client-side integration on your site. - string token = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The site key that was used to invoke reCAPTCHA Enterprise on your - // site and generate the token. - string site_key = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The user agent present in the request from the user's device - // related to this event. - string user_agent = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The IP address in the request from the user's device related to - // this event. - string user_ip_address = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The expected action for this type of event. This should be the - // same action provided at token generation time on client-side platforms - // already integrated with recaptcha enterprise. - string expected_action = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Unique stable hashed user identifier for the request. The - // identifier must be hashed using hmac-sha256 with stable secret. - bytes hashed_account_id = 6 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Data describing a payment transaction to be assessed. Sending - // this data enables reCAPTCHA Enterprise Fraud Prevention and the - // FraudPreventionAssessment component in the response. - TransactionData transaction_data = 13 - [(google.api.field_behavior) = OPTIONAL]; -} - -// Transaction data associated with a payment protected by reCAPTCHA Enterprise. -// All fields are optional. -message TransactionData { - // Structured address format for billing and shipping addresses. - message Address { - // The recipient name, potentially including information such as "care of". - string recipient = 1; - - // The first lines of the address. The first line generally contains the - // street name and number, and further lines may include information such as - // an apartment number. - repeated string address = 2; - - // The town/city of the address. - string locality = 3; - - // The state, province, or otherwise administrative area of the address. - string administrative_area = 4; - - // The CLDR country/region of the address. - string region_code = 5; - - // The postal or ZIP code of the address. - string postal_code = 6; - } - - // Details about a user's account involved in the transaction. - message User { - // Unique account identifier for this user. If using account defender, - // this should match the hashed_account_id field. Otherwise, a unique and - // persistent identifier for this account. - string account_id = 6; - - // The epoch milliseconds of the user's account creation. - int64 creation_ms = 1; - - // The email address of the user. - string email = 2; - - // Whether the email has been verified to be accessible by the user (OTP or - // similar). - bool email_verified = 3; - - // The phone number of the user, with country code. - string phone_number = 4; - - // Whether the phone number has been verified to be accessible by the user - // (OTP or similar). - bool phone_verified = 5; - } - - // Line items being purchased in this transaction. - message Item { - // The full name of the item. - string name = 1; - - // The value per item that the user is paying, in the transaction currency, - // after discounts. - double value = 2; - - // The quantity of this item that is being purchased. - int64 quantity = 3; - - // When a merchant is specified, its corresponding account_id. Necessary to - // populate marketplace-style transactions. - string merchant_account_id = 4; - } - - // Details about the transaction from the gateway. - message GatewayInfo { - // Name of the gateway service (for example, stripe, square, paypal). - string name = 1; - - // Gateway response code describing the state of the transaction. - string gateway_response_code = 2; - - // AVS response code from the gateway - // (available only when reCAPTCHA Enterprise is called after authorization). - string avs_response_code = 3; - - // CVV response code from the gateway - // (available only when reCAPTCHA Enterprise is called after authorization). - string cvv_response_code = 4; - } - - // Unique identifier for the transaction. This custom identifier can be used - // to reference this transaction in the future, for example, labeling a refund - // or chargeback event. Two attempts at the same transaction should use the - // same transaction id. - optional string transaction_id = 11; - - // The payment method for the transaction. The allowed values are: - // - // * credit-card - // * debit-card - // * gift-card - // * processor-{name} (If a third-party is used, for example, - // processor-paypal) - // * custom-{name} (If an alternative method is used, for example, - // custom-crypto) - string payment_method = 1; - - // The Bank Identification Number - generally the first 6 or 8 digits of the - // card. - string card_bin = 2; - - // The last four digits of the card. - string card_last_four = 3; - - // The currency code in ISO-4217 format. - string currency_code = 4; - - // The decimal value of the transaction in the specified currency. - double value = 5; - - // The value of shipping in the specified currency. 0 for free or no shipping. - double shipping_value = 12; - - // Destination address if this transaction involves shipping a physical item. - Address shipping_address = 6; - - // Address associated with the payment method when applicable. - Address billing_address = 7; - - // Information about the user paying/initiating the transaction. - User user = 8; - - // Information about the user or users fulfilling the transaction. - repeated User merchants = 13; - - // Items purchased in this transaction. - repeated Item items = 14; - - // Information about the payment gateway's response to the transaction. - GatewayInfo gateway_info = 10; -} - -message TokenProperties { - // Enum that represents the types of invalid token reasons. - enum InvalidReason { - // Default unspecified type. - INVALID_REASON_UNSPECIFIED = 0; - - // If the failure reason was not accounted for. - UNKNOWN_INVALID_REASON = 1; - - // The provided user verification token was malformed. - MALFORMED = 2; - - // The user verification token had expired. - EXPIRED = 3; - - // The user verification had already been seen. - DUPE = 4; - - // The user verification token did not match the provided site key. - // This may be a configuration error (for example, development keys used in - // production) or end users trying to use verification tokens from other - // sites. - SITE_MISMATCH = 5 [deprecated = true]; - - // The user verification token was not present. It is a required input. - MISSING = 6; - - // A retriable error (such as network failure) occurred on the browser. - // Could easily be simulated by an attacker. - BROWSER_ERROR = 7; - } - - // Whether the provided user response token is valid. When valid = false, the - // reason could be specified in invalid_reason or it could also be due to - // a user failing to solve a challenge or a sitekey mismatch (i.e the sitekey - // used to generate the token was different than the one specified in the - // assessment). - bool valid = 1; - - // Reason associated with the response when valid = false. - InvalidReason invalid_reason = 2; - - // The timestamp corresponding to the generation of the token. - google.protobuf.Timestamp create_time = 3; - - // The hostname of the page on which the token was generated. - string hostname = 4; - - // Action name provided at token generation. - string action = 5; -} - -// Assessment for Fraud Prevention. -message FraudPreventionAssessment { - // Information about stolen instrument fraud, where the user is not the - // legitimate owner of the instrument being used for the purchase. - message StolenInstrumentVerdict { - // Probability (0-1) of this transaction being executed with a stolen - // instrument. - float risk = 1; - } - - // Information about card testing fraud, where an adversary is testing - // fraudulently obtained cards or brute forcing their details. - message CardTestingVerdict { - // Probability (0-1) of this transaction attempt being part of a card - // testing attack. - float risk = 1; - } - - // Probability (0-1) of this transaction being fraudulent. Summarizes the - // combined risk of attack vectors below. - float transaction_risk = 1; - - // Assessment of this transaction for risk of a stolen instrument. - StolenInstrumentVerdict stolen_instrument_verdict = 2; - - // Assessment of this transaction for risk of being part of a card testing - // attack. - CardTestingVerdict card_testing_verdict = 3; -} - -// Account defender risk assessment. -message AccountDefenderAssessment { - // Labels returned by account defender for this request. - enum AccountDefenderLabel { - // Default unspecified type. - ACCOUNT_DEFENDER_LABEL_UNSPECIFIED = 0; - - // The request matches a known good profile for the user. - PROFILE_MATCH = 1; - - // The request is potentially a suspicious login event and should be further - // verified either via multi-factor authentication or another system. - SUSPICIOUS_LOGIN_ACTIVITY = 2; - - // The request matched a profile that previously had suspicious account - // creation behavior. This could mean this is a fake account. - SUSPICIOUS_ACCOUNT_CREATION = 3; - - // The account in the request has a high number of related accounts. It does - // not necessarily imply that the account is bad but could require - // investigating. - RELATED_ACCOUNTS_NUMBER_HIGH = 4; - } - - // Labels for this request. - repeated AccountDefenderLabel labels = 1; -} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.annotate_assessment.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.annotate_assessment.js deleted file mode 100644 index 9bc2f9269c6..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.annotate_assessment.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(name) { - // [START recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_AnnotateAssessment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 Assessment, in the format - * "projects/{project_number}/assessments/{assessment_id}". - */ - // const name = 'abc123' - /** - * Optional. The annotation that will be assigned to the Event. This field can - * be left empty to provide reasons that apply to an event without concluding - * whether the event is legitimate or fraudulent. - */ - // const annotation = {} - /** - * Optional. Optional reasons for the annotation that will be assigned to the - * Event. - */ - // const reasons = [1,2,3,4] - /** - * Optional. Optional unique stable hashed user identifier to apply to the - * assessment. This is an alternative to setting the hashed_account_id in - * CreateAssessment, for example when the account identifier is not yet known - * in the initial request. It is recommended that the identifier is hashed - * using hmac-sha256 with stable secret. - */ - // const hashedAccountId = Buffer.from('string') - /** - * Optional. If the assessment is part of a payment transaction, provide - * details on payment lifecycle events that occur in the transaction. - */ - // const transactionEvent = {} - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceV1Beta1Client} = require('@google-cloud/recaptcha-enterprise').v1beta1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceV1Beta1Client(); - - async function callAnnotateAssessment() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await recaptchaenterpriseClient.annotateAssessment(request); - console.log(response); - } - - callAnnotateAssessment(); - // [END recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_AnnotateAssessment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_assessment.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_assessment.js deleted file mode 100644 index f0192b59427..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_assessment.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(parent, assessment) { - // [START recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_CreateAssessment_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 project in which the assessment will be created, - * in the format "projects/{project_number}". - */ - // const parent = 'abc123' - /** - * Required. The assessment details. - */ - // const assessment = {} - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceV1Beta1Client} = require('@google-cloud/recaptcha-enterprise').v1beta1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceV1Beta1Client(); - - async function callCreateAssessment() { - // Construct request - const request = { - parent, - assessment, - }; - - // Run request - const response = await recaptchaenterpriseClient.createAssessment(request); - console.log(response); - } - - callCreateAssessment(); - // [END recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_CreateAssessment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.recaptchaenterprise.v1beta1.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.recaptchaenterprise.v1beta1.json deleted file mode 100644 index a3466d51dda..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.recaptchaenterprise.v1beta1.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-recaptchaenterprise", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.recaptchaenterprise.v1beta1", - "version": "v1beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_CreateAssessment_async", - "title": "RecaptchaEnterpriseServiceV1Beta1 createAssessment Sample", - "origin": "API_DEFINITION", - "description": " Creates an Assessment of the likelihood an event is legitimate.", - "canonical": true, - "file": "recaptcha_enterprise_service_v1_beta1.create_assessment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateAssessment", - "fullName": "google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1.CreateAssessment", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "assessment", - "type": ".google.cloud.recaptchaenterprise.v1beta1.Assessment" - } - ], - "resultType": ".google.cloud.recaptchaenterprise.v1beta1.Assessment", - "client": { - "shortName": "RecaptchaEnterpriseServiceV1Beta1Client", - "fullName": "google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client" - }, - "method": { - "shortName": "CreateAssessment", - "fullName": "google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1.CreateAssessment", - "service": { - "shortName": "RecaptchaEnterpriseServiceV1Beta1", - "fullName": "google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1" - } - } - } - }, - { - "regionTag": "recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_AnnotateAssessment_async", - "title": "RecaptchaEnterpriseServiceV1Beta1 annotateAssessment Sample", - "origin": "API_DEFINITION", - "description": " Annotates a previously created Assessment to provide additional information on whether the event turned out to be authentic or fradulent.", - "canonical": true, - "file": "recaptcha_enterprise_service_v1_beta1.annotate_assessment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 78, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AnnotateAssessment", - "fullName": "google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1.AnnotateAssessment", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "annotation", - "type": ".google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest.Annotation" - }, - { - "name": "reasons", - "type": "TYPE_ENUM[]" - }, - { - "name": "hashed_account_id", - "type": "TYPE_BYTES" - }, - { - "name": "transaction_event", - "type": ".google.cloud.recaptchaenterprise.v1beta1.TransactionEvent" - } - ], - "resultType": ".google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse", - "client": { - "shortName": "RecaptchaEnterpriseServiceV1Beta1Client", - "fullName": "google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client" - }, - "method": { - "shortName": "AnnotateAssessment", - "fullName": "google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1.AnnotateAssessment", - "service": { - "shortName": "RecaptchaEnterpriseServiceV1Beta1", - "fullName": "google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/index.ts deleted file mode 100644 index 405eb8c9a51..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/index.ts +++ /dev/null @@ -1,25 +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 v1beta1 from './v1beta1'; -const RecaptchaEnterpriseServiceV1Beta1Client = v1beta1.RecaptchaEnterpriseServiceV1Beta1Client; -type RecaptchaEnterpriseServiceV1Beta1Client = v1beta1.RecaptchaEnterpriseServiceV1Beta1Client; -export {v1beta1, RecaptchaEnterpriseServiceV1Beta1Client}; -export default {v1beta1, RecaptchaEnterpriseServiceV1Beta1Client}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/gapic_metadata.json deleted file mode 100644 index 2a7ea778505..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/gapic_metadata.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.recaptchaenterprise.v1beta1", - "libraryPackage": "@google-cloud/recaptcha-enterprise", - "services": { - "RecaptchaEnterpriseServiceV1Beta1": { - "clients": { - "grpc": { - "libraryClient": "RecaptchaEnterpriseServiceV1Beta1Client", - "rpcs": { - "CreateAssessment": { - "methods": [ - "createAssessment" - ] - }, - "AnnotateAssessment": { - "methods": [ - "annotateAssessment" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "RecaptchaEnterpriseServiceV1Beta1Client", - "rpcs": { - "CreateAssessment": { - "methods": [ - "createAssessment" - ] - }, - "AnnotateAssessment": { - "methods": [ - "annotateAssessment" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/index.ts deleted file mode 100644 index 33e314fd5a2..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/index.ts +++ /dev/null @@ -1,19 +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 {RecaptchaEnterpriseServiceV1Beta1Client} from './recaptcha_enterprise_service_v1_beta1_client'; diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts deleted file mode 100644 index e16495d6b94..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts +++ /dev/null @@ -1,542 +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} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './recaptcha_enterprise_service_v1_beta1_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service to determine the likelihood an event is legitimate. - * @class - * @memberof v1beta1 - */ -export class RecaptchaEnterpriseServiceV1Beta1Client { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - recaptchaEnterpriseServiceV1Beta1Stub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of RecaptchaEnterpriseServiceV1Beta1Client. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 RecaptchaEnterpriseServiceV1Beta1Client({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof RecaptchaEnterpriseServiceV1Beta1Client; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - assessmentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/assessments/{assessment}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1', 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.recaptchaEnterpriseServiceV1Beta1Stub) { - return this.recaptchaEnterpriseServiceV1Beta1Stub; - } - - // Put together the "service stub" for - // google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1. - this.recaptchaEnterpriseServiceV1Beta1Stub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1, - 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 recaptchaEnterpriseServiceV1Beta1StubMethods = - ['createAssessment', 'annotateAssessment']; - for (const methodName of recaptchaEnterpriseServiceV1Beta1StubMethods) { - const callPromise = this.recaptchaEnterpriseServiceV1Beta1Stub.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.recaptchaEnterpriseServiceV1Beta1Stub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'recaptchaenterprise.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 'recaptchaenterprise.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 an Assessment of the likelihood an event is legitimate. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project in which the assessment will be created, - * in the format "projects/{project_number}". - * @param {google.cloud.recaptchaenterprise.v1beta1.Assessment} request.assessment - * Required. The assessment 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 protos.google.cloud.recaptchaenterprise.v1beta1.Assessment|Assessment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_assessment.js - * region_tag:recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_CreateAssessment_async - */ - createAssessment( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|undefined, {}|undefined - ]>; - createAssessment( - request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>): void; - createAssessment( - request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>): void; - createAssessment( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createAssessment(request, options, callback); - } -/** - * Annotates a previously created Assessment to provide additional information - * on whether the event turned out to be authentic or fradulent. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Assessment, in the format - * "projects/{project_number}/assessments/{assessment_id}". - * @param {google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest.Annotation} [request.annotation] - * Optional. The annotation that will be assigned to the Event. This field can - * be left empty to provide reasons that apply to an event without concluding - * whether the event is legitimate or fraudulent. - * @param {number[]} [request.reasons] - * Optional. Optional reasons for the annotation that will be assigned to the - * Event. - * @param {Buffer} [request.hashedAccountId] - * Optional. Optional unique stable hashed user identifier to apply to the - * assessment. This is an alternative to setting the hashed_account_id in - * CreateAssessment, for example when the account identifier is not yet known - * in the initial request. It is recommended that the identifier is hashed - * using hmac-sha256 with stable secret. - * @param {google.cloud.recaptchaenterprise.v1beta1.TransactionEvent} [request.transactionEvent] - * Optional. If the assessment is part of a payment transaction, provide - * details on payment lifecycle events that occur in the transaction. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse|AnnotateAssessmentResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.annotate_assessment.js - * region_tag:recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_AnnotateAssessment_async - */ - annotateAssessment( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|undefined, {}|undefined - ]>; - annotateAssessment( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>): void; - annotateAssessment( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>): void; - annotateAssessment( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.annotateAssessment(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified assessment resource name string. - * - * @param {string} project - * @param {string} assessment - * @returns {string} Resource name string. - */ - assessmentPath(project:string,assessment:string) { - return this.pathTemplates.assessmentPathTemplate.render({ - project: project, - assessment: assessment, - }); - } - - /** - * Parse the project from Assessment resource. - * - * @param {string} assessmentName - * A fully-qualified path representing Assessment resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAssessmentName(assessmentName: string) { - return this.pathTemplates.assessmentPathTemplate.match(assessmentName).project; - } - - /** - * Parse the assessment from Assessment resource. - * - * @param {string} assessmentName - * A fully-qualified path representing Assessment resource. - * @returns {string} A string representing the assessment. - */ - matchAssessmentFromAssessmentName(assessmentName: string) { - return this.pathTemplates.assessmentPathTemplate.match(assessmentName).assessment; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.recaptchaEnterpriseServiceV1Beta1Stub && !this._terminated) { - return this.recaptchaEnterpriseServiceV1Beta1Stub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json deleted file mode 100644 index 7907ebe8f8e..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "interfaces": { - "google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1": { - "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": { - "CreateAssessment": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "AnnotateAssessment": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_proto_list.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_proto_list.json deleted file mode 100644 index 35d2e7543ad..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_proto_list.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "../../protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto" -] diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index f81af678451..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const recaptchaenterprise = require('@google-cloud/recaptcha-enterprise'); - -function main() { - const recaptchaEnterpriseServiceV1Beta1Client = new recaptchaenterprise.RecaptchaEnterpriseServiceV1Beta1Client(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 79563939674..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {RecaptchaEnterpriseServiceV1Beta1Client} from '@google-cloud/recaptcha-enterprise'; - -// check that the client class type name can be used -function doStuffWithRecaptchaEnterpriseServiceV1Beta1Client(client: RecaptchaEnterpriseServiceV1Beta1Client) { - client.close(); -} - -function main() { - // check that the client instance can be created - const recaptchaEnterpriseServiceV1Beta1Client = new RecaptchaEnterpriseServiceV1Beta1Client(); - doStuffWithRecaptchaEnterpriseServiceV1Beta1Client(recaptchaEnterpriseServiceV1Beta1Client); -} - -main(); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/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-recaptchaenterprise/v1beta1/test/gapic_recaptcha_enterprise_service_v1_beta1_v1beta1.ts b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/test/gapic_recaptcha_enterprise_service_v1_beta1_v1beta1.ts deleted file mode 100644 index 751c9b12780..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/test/gapic_recaptcha_enterprise_service_v1_beta1_v1beta1.ts +++ /dev/null @@ -1,437 +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 recaptchaenterpriseservicev1beta1Module from '../src'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.recaptchaEnterpriseServiceV1Beta1Stub, undefined); - await client.initialize(); - assert(client.recaptchaEnterpriseServiceV1Beta1Stub); - }); - - it('has close method for the initialized client', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.recaptchaEnterpriseServiceV1Beta1Stub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.recaptchaEnterpriseServiceV1Beta1Stub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - 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 recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - 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('createAssessment', () => { - it('invokes createAssessment without error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1beta1.Assessment() - ); - client.innerApiCalls.createAssessment = stubSimpleCall(expectedResponse); - const [response] = await client.createAssessment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createAssessment without error using callback', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1beta1.Assessment() - ); - client.innerApiCalls.createAssessment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createAssessment( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createAssessment with error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createAssessment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createAssessment(request), expectedError); - const actualRequest = (client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createAssessment with closed client', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createAssessment(request), expectedError); - }); - }); - - describe('annotateAssessment', () => { - it('invokes annotateAssessment without error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse() - ); - client.innerApiCalls.annotateAssessment = stubSimpleCall(expectedResponse); - const [response] = await client.annotateAssessment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes annotateAssessment without error using callback', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse() - ); - client.innerApiCalls.annotateAssessment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.annotateAssessment( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes annotateAssessment with error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.annotateAssessment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.annotateAssessment(request), expectedError); - const actualRequest = (client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes annotateAssessment with closed client', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.annotateAssessment(request), expectedError); - }); - }); - - describe('Path templates', () => { - - describe('assessment', () => { - const fakePath = "/rendered/path/assessment"; - const expectedParameters = { - project: "projectValue", - assessment: "assessmentValue", - }; - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.assessmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.assessmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('assessmentPath', () => { - const result = client.assessmentPath("projectValue", "assessmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.assessmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAssessmentName', () => { - const result = client.matchProjectFromAssessmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.assessmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAssessmentFromAssessmentName', () => { - const result = client.matchAssessmentFromAssessmentName(fakePath); - assert.strictEqual(result, "assessmentValue"); - assert((client.pathTemplates.assessmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/webpack.config.js deleted file mode 100644 index a5030d63883..00000000000 --- a/owl-bot-staging/google-cloud-recaptchaenterprise/v1beta1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'RecaptchaEnterpriseServiceV1Beta1', - filename: './recaptcha-enterprise-service-v1-beta1.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-recommender/v1/.eslintignore b/owl-bot-staging/google-cloud-recommender/v1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-recommender/v1/.eslintrc.json b/owl-bot-staging/google-cloud-recommender/v1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-recommender/v1/.gitignore b/owl-bot-staging/google-cloud-recommender/v1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-recommender/v1/.jsdoc.js b/owl-bot-staging/google-cloud-recommender/v1/.jsdoc.js deleted file mode 100644 index c2e2fb04e21..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/.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/recommender', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-recommender/v1/.mocharc.js b/owl-bot-staging/google-cloud-recommender/v1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/.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-recommender/v1/.prettierrc.js b/owl-bot-staging/google-cloud-recommender/v1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/.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-recommender/v1/README.md b/owl-bot-staging/google-cloud-recommender/v1/README.md deleted file mode 100644 index 59dc6bb7bb1..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Recommender: Nodejs Client diff --git a/owl-bot-staging/google-cloud-recommender/v1/package.json b/owl-bot-staging/google-cloud-recommender/v1/package.json deleted file mode 100644 index 5f3c60b1639..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/recommender", - "version": "0.1.0", - "description": "Recommender client for Node.js", - "repository": "googleapis/nodejs-recommender", - "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 recommender", - "recommender", - "recommender" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/insight.proto b/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/insight.proto deleted file mode 100644 index 2d7c01339e3..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/insight.proto +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.recommender.v1; - -import "google/api/resource.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Recommender.V1"; -option go_package = "cloud.google.com/go/recommender/apiv1/recommenderpb;recommenderpb"; -option java_multiple_files = true; -option java_outer_classname = "InsightProto"; -option java_package = "com.google.cloud.recommender.v1"; -option objc_class_prefix = "CREC"; -option (google.api.resource_definition) = { - type: "recommender.googleapis.com/InsightType" - pattern: "projects/{project}/locations/{location}/insightTypes/{insight_type}" - pattern: "billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}" - pattern: "folders/{folder}/locations/{location}/insightTypes/{insight_type}" - pattern: "organizations/{organization}/locations/{location}/insightTypes/{insight_type}" -}; - -// An insight along with the information used to derive the insight. The insight -// may have associated recomendations as well. -message Insight { - option (google.api.resource) = { - type: "recommender.googleapis.com/Insight" - pattern: "projects/{project}/locations/{location}/insightTypes/{insight_type}/insights/{insight}" - pattern: "billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}/insights/{insight}" - pattern: "folders/{folder}/locations/{location}/insightTypes/{insight_type}/insights/{insight}" - pattern: "organizations/{organization}/locations/{location}/insightTypes/{insight_type}/insights/{insight}" - }; - - // Insight category. - enum Category { - // Unspecified category. - CATEGORY_UNSPECIFIED = 0; - - // The insight is related to cost. - COST = 1; - - // The insight is related to security. - SECURITY = 2; - - // The insight is related to performance. - PERFORMANCE = 3; - - // This insight is related to manageability. - MANAGEABILITY = 4; - } - - // Insight severity levels. - enum Severity { - // Insight has unspecified severity. - SEVERITY_UNSPECIFIED = 0; - - // Insight has low severity. - LOW = 1; - - // Insight has medium severity. - MEDIUM = 2; - - // Insight has high severity. - HIGH = 3; - - // Insight has critical severity. - CRITICAL = 4; - } - - // Reference to an associated recommendation. - message RecommendationReference { - // Recommendation resource name, e.g. - // projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/recommendations/[RECOMMENDATION_ID] - string recommendation = 1; - } - - // Name of the insight. - string name = 1; - - // Free-form human readable summary in English. The maximum length is 500 - // characters. - string description = 2; - - // Fully qualified resource names that this insight is targeting. - repeated string target_resources = 9; - - // Insight subtype. Insight content schema will be stable for a given subtype. - string insight_subtype = 10; - - // A struct of custom fields to explain the insight. - // Example: "grantedPermissionsCount": "1000" - google.protobuf.Struct content = 3; - - // Timestamp of the latest data used to generate the insight. - google.protobuf.Timestamp last_refresh_time = 4; - - // Observation period that led to the insight. The source data used to - // generate the insight ends at last_refresh_time and begins at - // (last_refresh_time - observation_period). - google.protobuf.Duration observation_period = 5; - - // Information state and metadata. - InsightStateInfo state_info = 6; - - // Category being targeted by the insight. - Category category = 7; - - // Insight's severity. - Severity severity = 15; - - // Fingerprint of the Insight. Provides optimistic locking when updating - // states. - string etag = 11; - - // Recommendations derived from this insight. - repeated RecommendationReference associated_recommendations = 8; -} - -// Information related to insight state. -message InsightStateInfo { - // Represents insight state. - enum State { - // Unspecified state. - STATE_UNSPECIFIED = 0; - - // Insight is active. Content for ACTIVE insights can be updated by Google. - // ACTIVE insights can be marked DISMISSED OR ACCEPTED. - ACTIVE = 1; - - // Some action has been taken based on this insight. Insights become - // accepted when a recommendation derived from the insight has been marked - // CLAIMED, SUCCEEDED, or FAILED. ACTIVE insights can also be marked - // ACCEPTED explicitly. Content for ACCEPTED insights is immutable. ACCEPTED - // insights can only be marked ACCEPTED (which may update state metadata). - ACCEPTED = 2; - - // Insight is dismissed. Content for DISMISSED insights can be updated by - // Google. DISMISSED insights can be marked as ACTIVE. - DISMISSED = 3; - } - - // Insight state. - State state = 1; - - // A map of metadata for the state, provided by user or automations systems. - map state_metadata = 2; -} diff --git a/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/insight_type_config.proto b/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/insight_type_config.proto deleted file mode 100644 index 742864bc75b..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/insight_type_config.proto +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.recommender.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Recommender.V1"; -option go_package = "cloud.google.com/go/recommender/apiv1/recommenderpb;recommenderpb"; -option java_multiple_files = true; -option java_outer_classname = "InsightTypeConfigProto"; -option java_package = "com.google.cloud.recommender.v1"; -option objc_class_prefix = "CREC"; - -// Configuration for an InsightType. -message InsightTypeConfig { - option (google.api.resource) = { - type: "recommender.googleapis.com/InsightTypeConfig" - pattern: "projects/{project}/locations/{location}/insightTypes/{insight_type}/config" - pattern: "organizations/{organization}/locations/{location}/insightTypes/{insight_type}/config" - }; - - // Name of insight type config. - // Eg, - // projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config - string name = 1; - - // InsightTypeGenerationConfig which configures the generation of - // insights for this insight type. - InsightTypeGenerationConfig insight_type_generation_config = 2; - - // Fingerprint of the InsightTypeConfig. Provides optimistic locking when - // updating. - string etag = 3; - - // Last time when the config was updated. - google.protobuf.Timestamp update_time = 4; - - // Output only. Immutable. The revision ID of the config. - // A new revision is committed whenever the config is changed in any way. - // The format is an 8-character hexadecimal string. - string revision_id = 5 [ - (google.api.field_behavior) = IMMUTABLE, - (google.api.field_behavior) = OUTPUT_ONLY - ]; - - // Allows clients to store small amounts of arbitrary data. Annotations must - // follow the Kubernetes syntax. - // The total size of all keys and values combined is limited to 256k. - // Key can have 2 segments: prefix (optional) and name (required), - // separated by a slash (/). - // Prefix must be a DNS subdomain. - // Name must be 63 characters or less, begin and end with alphanumerics, - // with dashes (-), underscores (_), dots (.), and alphanumerics between. - map annotations = 6; - - // A user-settable field to provide a human-readable name to be used in user - // interfaces. - string display_name = 7; -} - -// A configuration to customize the generation of insights. -// Eg, customizing the lookback period considered when generating a -// insight. -message InsightTypeGenerationConfig { - // Parameters for this InsightTypeGenerationConfig. These configs can be used - // by or are applied to all subtypes. - google.protobuf.Struct params = 1; -} diff --git a/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommendation.proto b/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommendation.proto deleted file mode 100644 index fd153345688..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommendation.proto +++ /dev/null @@ -1,343 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.recommender.v1; - -import "google/api/resource.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; -import "google/type/money.proto"; - -option csharp_namespace = "Google.Cloud.Recommender.V1"; -option go_package = "cloud.google.com/go/recommender/apiv1/recommenderpb;recommenderpb"; -option java_multiple_files = true; -option java_package = "com.google.cloud.recommender.v1"; -option objc_class_prefix = "CREC"; -option (google.api.resource_definition) = { - type: "recommender.googleapis.com/Recommender" - pattern: "projects/{project}/locations/{location}/recommenders/{recommender}" - pattern: "billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}" - pattern: "folders/{folder}/locations/{location}/recommenders/{recommender}" - pattern: "organizations/{organization}/locations/{location}/recommenders/{recommender}" -}; - -// A recommendation along with a suggested action. E.g., a rightsizing -// recommendation for an underutilized VM, IAM role recommendations, etc -message Recommendation { - option (google.api.resource) = { - type: "recommender.googleapis.com/Recommendation" - pattern: "projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}" - pattern: "billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}" - pattern: "folders/{folder}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}" - pattern: "organizations/{organization}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}" - }; - - // Recommendation priority levels. - enum Priority { - // Recommendation has unspecified priority. - PRIORITY_UNSPECIFIED = 0; - - // Recommendation has P4 priority (lowest priority). - P4 = 1; - - // Recommendation has P3 priority (second lowest priority). - P3 = 2; - - // Recommendation has P2 priority (second highest priority). - P2 = 3; - - // Recommendation has P1 priority (highest priority). - P1 = 4; - } - - // Reference to an associated insight. - message InsightReference { - // Insight resource name, e.g. - // projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/insights/[INSIGHT_ID] - string insight = 1; - } - - // Name of recommendation. - string name = 1; - - // Free-form human readable summary in English. The maximum length is 500 - // characters. - string description = 2; - - // Contains an identifier for a subtype of recommendations produced for the - // same recommender. Subtype is a function of content and impact, meaning a - // new subtype might be added when significant changes to `content` or - // `primary_impact.category` are introduced. See the Recommenders section - // to see a list of subtypes for a given Recommender. - // - // Examples: - // For recommender = "google.iam.policy.Recommender", - // recommender_subtype can be one of "REMOVE_ROLE"/"REPLACE_ROLE" - string recommender_subtype = 12; - - // Last time this recommendation was refreshed by the system that created it - // in the first place. - google.protobuf.Timestamp last_refresh_time = 4; - - // The primary impact that this recommendation can have while trying to - // optimize for one category. - Impact primary_impact = 5; - - // Optional set of additional impact that this recommendation may have when - // trying to optimize for the primary category. These may be positive - // or negative. - repeated Impact additional_impact = 6; - - // Recommendation's priority. - Priority priority = 17; - - // Content of the recommendation describing recommended changes to resources. - RecommendationContent content = 7; - - // Information for state. Contains state and metadata. - RecommendationStateInfo state_info = 10; - - // Fingerprint of the Recommendation. Provides optimistic locking when - // updating states. - string etag = 11; - - // Insights that led to this recommendation. - repeated InsightReference associated_insights = 14; - - // Corresponds to a mutually exclusive group ID within a recommender. - // A non-empty ID indicates that the recommendation belongs to a mutually - // exclusive group. This means that only one recommendation within the group - // is suggested to be applied. - string xor_group_id = 18; -} - -// Contains what resources are changing and how they are changing. -message RecommendationContent { - // Operations to one or more Google Cloud resources grouped in such a way - // that, all operations within one group are expected to be performed - // atomically and in an order. - repeated OperationGroup operation_groups = 2; - - // Condensed overview information about the recommendation. - google.protobuf.Struct overview = 3; -} - -// Group of operations that need to be performed atomically. -message OperationGroup { - // List of operations across one or more resources that belong to this group. - // Loosely based on RFC6902 and should be performed in the order they appear. - repeated Operation operations = 1; -} - -// Contains an operation for a resource loosely based on the JSON-PATCH format -// with support for: -// -// * Custom filters for describing partial array patch. -// * Extended path values for describing nested arrays. -// * Custom fields for describing the resource for which the operation is being -// described. -// * Allows extension to custom operations not natively supported by RFC6902. -// See https://tools.ietf.org/html/rfc6902 for details on the original RFC. -message Operation { - // Type of this operation. Contains one of 'add', 'remove', 'replace', 'move', - // 'copy', 'test' and custom operations. This field is case-insensitive and - // always populated. - string action = 1; - - // Type of GCP resource being modified/tested. This field is always populated. - // Example: cloudresourcemanager.googleapis.com/Project, - // compute.googleapis.com/Instance - string resource_type = 2; - - // Contains the fully qualified resource name. This field is always populated. - // ex: //cloudresourcemanager.googleapis.com/projects/foo. - string resource = 3; - - // Path to the target field being operated on. If the operation is at the - // resource level, then path should be "/". This field is always populated. - string path = 4; - - // Can be set with action 'copy' to copy resource configuration across - // different resources of the same type. Example: A resource clone can be - // done via action = 'copy', path = "/", from = "/", - // source_resource = and resource_name = . - // This field is empty for all other values of `action`. - string source_resource = 5; - - // Can be set with action 'copy' or 'move' to indicate the source field within - // resource or source_resource, ignored if provided for other operation types. - string source_path = 6; - - // One of the fields in the following block will be set and intend to - // describe a value for 'path' field. - oneof path_value { - // Value for the `path` field. Will be set for actions:'add'/'replace'. - // Maybe set for action: 'test'. Either this or `value_matcher` will be set - // for 'test' operation. An exact match must be performed. - google.protobuf.Value value = 7; - - // Can be set for action 'test' for advanced matching for the value of - // 'path' field. Either this or `value` will be set for 'test' operation. - ValueMatcher value_matcher = 10; - } - - // Set of filters to apply if `path` refers to array elements or nested array - // elements in order to narrow down to a single unique element that is being - // tested/modified. - // This is intended to be an exact match per filter. To perform advanced - // matching, use path_value_matchers. - // - // * Example: - // ``` - // { - // "/versions/*/name" : "it-123" - // "/versions/*/targetSize/percent": 20 - // } - // ``` - // * Example: - // ``` - // { - // "/bindings/*/role": "roles/owner" - // "/bindings/*/condition" : null - // } - // ``` - // * Example: - // ``` - // { - // "/bindings/*/role": "roles/owner" - // "/bindings/*/members/*" : ["x@example.com", "y@example.com"] - // } - // ``` - // When both path_filters and path_value_matchers are set, an implicit AND - // must be performed. - map path_filters = 8; - - // Similar to path_filters, this contains set of filters to apply if `path` - // field refers to array elements. This is meant to support value matching - // beyond exact match. To perform exact match, use path_filters. - // When both path_filters and path_value_matchers are set, an implicit AND - // must be performed. - map path_value_matchers = 11; -} - -// Contains various matching options for values for a GCP resource field. -message ValueMatcher { - oneof match_variant { - // To be used for full regex matching. The regular expression is using the - // Google RE2 syntax (https://github.com/google/re2/wiki/Syntax), so to be - // used with RE2::FullMatch - string matches_pattern = 1; - } -} - -// Contains metadata about how much money a recommendation can save or incur. -message CostProjection { - // An approximate projection on amount saved or amount incurred. Negative cost - // units indicate cost savings and positive cost units indicate increase. - // See google.type.Money documentation for positive/negative units. - // - // A user's permissions may affect whether the cost is computed using list - // prices or custom contract prices. - google.type.Money cost = 1; - - // Duration for which this cost applies. - google.protobuf.Duration duration = 2; -} - -// Contains various ways of describing the impact on Security. -message SecurityProjection { - // Additional security impact details that is provided by the recommender. - google.protobuf.Struct details = 2; -} - -// Contains the impact a recommendation can have for a given category. -message Impact { - // The category of the impact. - enum Category { - // Default unspecified category. Don't use directly. - CATEGORY_UNSPECIFIED = 0; - - // Indicates a potential increase or decrease in cost. - COST = 1; - - // Indicates a potential increase or decrease in security. - SECURITY = 2; - - // Indicates a potential increase or decrease in performance. - PERFORMANCE = 3; - - // Indicates a potential increase or decrease in manageability. - MANAGEABILITY = 4; - } - - // Category that is being targeted. - Category category = 1; - - // Contains projections (if any) for this category. - oneof projection { - // Use with CategoryType.COST - CostProjection cost_projection = 100; - - // Use with CategoryType.SECURITY - SecurityProjection security_projection = 101; - } -} - -// Information for state. Contains state and metadata. -message RecommendationStateInfo { - // Represents Recommendation State. - enum State { - // Default state. Don't use directly. - STATE_UNSPECIFIED = 0; - - // Recommendation is active and can be applied. Recommendations content can - // be updated by Google. - // - // ACTIVE recommendations can be marked as CLAIMED, SUCCEEDED, or FAILED. - ACTIVE = 1; - - // Recommendation is in claimed state. Recommendations content is - // immutable and cannot be updated by Google. - // - // CLAIMED recommendations can be marked as CLAIMED, SUCCEEDED, or FAILED. - CLAIMED = 6; - - // Recommendation is in succeeded state. Recommendations content is - // immutable and cannot be updated by Google. - // - // SUCCEEDED recommendations can be marked as SUCCEEDED, or FAILED. - SUCCEEDED = 3; - - // Recommendation is in failed state. Recommendations content is immutable - // and cannot be updated by Google. - // - // FAILED recommendations can be marked as SUCCEEDED, or FAILED. - FAILED = 4; - - // Recommendation is in dismissed state. Recommendation content can be - // updated by Google. - // - // DISMISSED recommendations can be marked as ACTIVE. - DISMISSED = 5; - } - - // The state of the recommendation, Eg ACTIVE, SUCCEEDED, FAILED. - State state = 1; - - // A map of metadata for the state, provided by user or automations systems. - map state_metadata = 2; -} diff --git a/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommender_config.proto b/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommender_config.proto deleted file mode 100644 index 0e0c613b982..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommender_config.proto +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.recommender.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Recommender.V1"; -option go_package = "cloud.google.com/go/recommender/apiv1/recommenderpb;recommenderpb"; -option java_multiple_files = true; -option java_outer_classname = "RecommenderConfigProto"; -option java_package = "com.google.cloud.recommender.v1"; -option objc_class_prefix = "CREC"; - -// Configuration for a Recommender. -message RecommenderConfig { - option (google.api.resource) = { - type: "recommender.googleapis.com/RecommenderConfig" - pattern: "projects/{project}/locations/{location}/recommenders/{recommender}/config" - pattern: "organizations/{organization}/locations/{location}/recommenders/{recommender}/config" - }; - - // Name of recommender config. - // Eg, - // projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config - string name = 1; - - // RecommenderGenerationConfig which configures the Generation of - // recommendations for this recommender. - RecommenderGenerationConfig recommender_generation_config = 2; - - // Fingerprint of the RecommenderConfig. Provides optimistic locking when - // updating. - string etag = 3; - - // Last time when the config was updated. - google.protobuf.Timestamp update_time = 4; - - // Output only. Immutable. The revision ID of the config. - // A new revision is committed whenever the config is changed in any way. - // The format is an 8-character hexadecimal string. - string revision_id = 5 [ - (google.api.field_behavior) = IMMUTABLE, - (google.api.field_behavior) = OUTPUT_ONLY - ]; - - // Allows clients to store small amounts of arbitrary data. Annotations must - // follow the Kubernetes syntax. - // The total size of all keys and values combined is limited to 256k. - // Key can have 2 segments: prefix (optional) and name (required), - // separated by a slash (/). - // Prefix must be a DNS subdomain. - // Name must be 63 characters or less, begin and end with alphanumerics, - // with dashes (-), underscores (_), dots (.), and alphanumerics between. - map annotations = 6; - - // A user-settable field to provide a human-readable name to be used in user - // interfaces. - string display_name = 7; -} - -// A Configuration to customize the generation of recommendations. -// Eg, customizing the lookback period considered when generating a -// recommendation. -message RecommenderGenerationConfig { - // Parameters for this RecommenderGenerationConfig. These configs can be used - // by or are applied to all subtypes. - google.protobuf.Struct params = 1; -} diff --git a/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommender_service.proto b/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommender_service.proto deleted file mode 100644 index 947687639d1..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/protos/google/cloud/recommender/v1/recommender_service.proto +++ /dev/null @@ -1,604 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.recommender.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/recommender/v1/insight.proto"; -import "google/cloud/recommender/v1/insight_type_config.proto"; -import "google/cloud/recommender/v1/recommendation.proto"; -import "google/cloud/recommender/v1/recommender_config.proto"; -import "google/protobuf/field_mask.proto"; - -option csharp_namespace = "Google.Cloud.Recommender.V1"; -option go_package = "cloud.google.com/go/recommender/apiv1/recommenderpb;recommenderpb"; -option java_multiple_files = true; -option java_outer_classname = "RecommenderProto"; -option java_package = "com.google.cloud.recommender.v1"; -option objc_class_prefix = "CREC"; - -// Provides insights and recommendations for cloud customers for various -// categories like performance optimization, cost savings, reliability, feature -// discovery, etc. Insights and recommendations are generated automatically -// based on analysis of user resources, configuration and monitoring metrics. -service Recommender { - option (google.api.default_host) = "recommender.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Lists insights for the specified Cloud Resource. Requires the - // recommender.*.list IAM permission for the specified insight type. - rpc ListInsights(ListInsightsRequest) returns (ListInsightsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*/insightTypes/*}/insights" - additional_bindings { - get: "/v1/{parent=billingAccounts/*/locations/*/insightTypes/*}/insights" - } - additional_bindings { - get: "/v1/{parent=folders/*/locations/*/insightTypes/*}/insights" - } - additional_bindings { - get: "/v1/{parent=organizations/*/locations/*/insightTypes/*}/insights" - } - }; - option (google.api.method_signature) = "parent"; - } - - // Gets the requested insight. Requires the recommender.*.get IAM permission - // for the specified insight type. - rpc GetInsight(GetInsightRequest) returns (Insight) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/insightTypes/*/insights/*}" - additional_bindings { - get: "/v1/{name=billingAccounts/*/locations/*/insightTypes/*/insights/*}" - } - additional_bindings { - get: "/v1/{name=folders/*/locations/*/insightTypes/*/insights/*}" - } - additional_bindings { - get: "/v1/{name=organizations/*/locations/*/insightTypes/*/insights/*}" - } - }; - option (google.api.method_signature) = "name"; - } - - // Marks the Insight State as Accepted. Users can use this method to - // indicate to the Recommender API that they have applied some action based - // on the insight. This stops the insight content from being updated. - // - // MarkInsightAccepted can be applied to insights in ACTIVE state. Requires - // the recommender.*.update IAM permission for the specified insight. - rpc MarkInsightAccepted(MarkInsightAcceptedRequest) returns (Insight) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/insightTypes/*/insights/*}:markAccepted" - body: "*" - additional_bindings { - post: "/v1/{name=billingAccounts/*/locations/*/insightTypes/*/insights/*}:markAccepted" - body: "*" - } - additional_bindings { - post: "/v1/{name=folders/*/locations/*/insightTypes/*/insights/*}:markAccepted" - body: "*" - } - additional_bindings { - post: "/v1/{name=organizations/*/locations/*/insightTypes/*/insights/*}:markAccepted" - body: "*" - } - }; - option (google.api.method_signature) = "name,state_metadata,etag"; - } - - // Lists recommendations for the specified Cloud Resource. Requires the - // recommender.*.list IAM permission for the specified recommender. - rpc ListRecommendations(ListRecommendationsRequest) - returns (ListRecommendationsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*/recommenders/*}/recommendations" - additional_bindings { - get: "/v1/{parent=billingAccounts/*/locations/*/recommenders/*}/recommendations" - } - additional_bindings { - get: "/v1/{parent=folders/*/locations/*/recommenders/*}/recommendations" - } - additional_bindings { - get: "/v1/{parent=organizations/*/locations/*/recommenders/*}/recommendations" - } - }; - option (google.api.method_signature) = "parent"; - option (google.api.method_signature) = "parent,filter"; - } - - // Gets the requested recommendation. Requires the recommender.*.get - // IAM permission for the specified recommender. - rpc GetRecommendation(GetRecommendationRequest) returns (Recommendation) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/recommenders/*/recommendations/*}" - additional_bindings { - get: "/v1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}" - } - additional_bindings { - get: "/v1/{name=folders/*/locations/*/recommenders/*/recommendations/*}" - } - additional_bindings { - get: "/v1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}" - } - }; - option (google.api.method_signature) = "name"; - } - - // Marks the Recommendation State as Claimed. Users can use this method to - // indicate to the Recommender API that they are starting to apply the - // recommendation themselves. This stops the recommendation content from being - // updated. Associated insights are frozen and placed in the ACCEPTED state. - // - // MarkRecommendationClaimed can be applied to recommendations in CLAIMED, - // SUCCEEDED, FAILED, or ACTIVE state. - // - // Requires the recommender.*.update IAM permission for the specified - // recommender. - rpc MarkRecommendationClaimed(MarkRecommendationClaimedRequest) - returns (Recommendation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markClaimed" - body: "*" - additional_bindings { - post: "/v1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markClaimed" - body: "*" - } - additional_bindings { - post: "/v1/{name=folders/*/locations/*/recommenders/*/recommendations/*}:markClaimed" - body: "*" - } - additional_bindings { - post: "/v1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}:markClaimed" - body: "*" - } - }; - option (google.api.method_signature) = "name,state_metadata,etag"; - } - - // Marks the Recommendation State as Succeeded. Users can use this method to - // indicate to the Recommender API that they have applied the recommendation - // themselves, and the operation was successful. This stops the recommendation - // content from being updated. Associated insights are frozen and placed in - // the ACCEPTED state. - // - // MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, - // CLAIMED, SUCCEEDED, or FAILED state. - // - // Requires the recommender.*.update IAM permission for the specified - // recommender. - rpc MarkRecommendationSucceeded(MarkRecommendationSucceededRequest) - returns (Recommendation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markSucceeded" - body: "*" - additional_bindings { - post: "/v1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markSucceeded" - body: "*" - } - additional_bindings { - post: "/v1/{name=folders/*/locations/*/recommenders/*/recommendations/*}:markSucceeded" - body: "*" - } - additional_bindings { - post: "/v1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}:markSucceeded" - body: "*" - } - }; - option (google.api.method_signature) = "name,state_metadata,etag"; - } - - // Marks the Recommendation State as Failed. Users can use this method to - // indicate to the Recommender API that they have applied the recommendation - // themselves, and the operation failed. This stops the recommendation content - // from being updated. Associated insights are frozen and placed in the - // ACCEPTED state. - // - // MarkRecommendationFailed can be applied to recommendations in ACTIVE, - // CLAIMED, SUCCEEDED, or FAILED state. - // - // Requires the recommender.*.update IAM permission for the specified - // recommender. - rpc MarkRecommendationFailed(MarkRecommendationFailedRequest) - returns (Recommendation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markFailed" - body: "*" - additional_bindings { - post: "/v1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markFailed" - body: "*" - } - additional_bindings { - post: "/v1/{name=folders/*/locations/*/recommenders/*/recommendations/*}:markFailed" - body: "*" - } - additional_bindings { - post: "/v1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}:markFailed" - body: "*" - } - }; - option (google.api.method_signature) = "name,state_metadata,etag"; - } - - // Gets the requested Recommender Config. There is only one instance of the - // config for each Recommender. - rpc GetRecommenderConfig(GetRecommenderConfigRequest) - returns (RecommenderConfig) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/recommenders/*/config}" - additional_bindings { - get: "/v1/{name=organizations/*/locations/*/recommenders/*/config}" - } - }; - option (google.api.method_signature) = "name"; - } - - // Updates a Recommender Config. This will create a new revision of the - // config. - rpc UpdateRecommenderConfig(UpdateRecommenderConfigRequest) - returns (RecommenderConfig) { - option (google.api.http) = { - patch: "/v1/{recommender_config.name=projects/*/locations/*/recommenders/*/config}" - body: "recommender_config" - additional_bindings { - patch: "/v1/{recommender_config.name=organizations/*/locations/*/recommenders/*/config}" - body: "recommender_config" - } - }; - option (google.api.method_signature) = "recommender_config,update_mask"; - } - - // Gets the requested InsightTypeConfig. There is only one instance of the - // config for each InsightType. - rpc GetInsightTypeConfig(GetInsightTypeConfigRequest) - returns (InsightTypeConfig) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/insightTypes/*/config}" - additional_bindings { - get: "/v1/{name=organizations/*/locations/*/insightTypes/*/config}" - } - }; - option (google.api.method_signature) = "name"; - } - - // Updates an InsightTypeConfig change. This will create a new revision of the - // config. - rpc UpdateInsightTypeConfig(UpdateInsightTypeConfigRequest) - returns (InsightTypeConfig) { - option (google.api.http) = { - patch: "/v1/{insight_type_config.name=projects/*/locations/*/insightTypes/*/config}" - body: "insight_type_config" - additional_bindings { - patch: "/v1/{insight_type_config.name=organizations/*/locations/*/insightTypes/*/config}" - body: "insight_type_config" - } - }; - option (google.api.method_signature) = "insight_type_config,update_mask"; - } -} - -// Request for the `ListInsights` method. -message ListInsightsRequest { - // Required. The container resource on which to execute the request. - // Acceptable formats: - // - // * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - // - // * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - // - // * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - // - // * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - // - // * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - // - // LOCATION here refers to GCP Locations: - // https://cloud.google.com/about/locations/ - // INSIGHT_TYPE_ID refers to supported insight types: - // https://cloud.google.com/recommender/docs/insights/insight-types. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recommender.googleapis.com/InsightType" - } - ]; - - // Optional. The maximum number of results to return from this request. - // Non-positive values are ignored. If not specified, the server will - // determine the number of results to return. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. If present, retrieves the next batch of results from the - // preceding call to this method. `page_token` must be the value of - // `next_page_token` from the previous response. The values of other method - // parameters must be identical to those in the previous call. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Filter expression to restrict the insights returned. Supported - // filter fields: - // - // * `stateInfo.state` - // - // * `insightSubtype` - // - // * `severity` - // - // Examples: - // - // * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - // - // * `insightSubtype = PERMISSIONS_USAGE` - // - // * `severity = CRITICAL OR severity = HIGH` - // - // * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` - // - // (These expressions are based on the filter language described at - // https://google.aip.dev/160) - string filter = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// Response to the `ListInsights` method. -message ListInsightsResponse { - // The set of insights for the `parent` resource. - repeated Insight insights = 1; - - // A token that can be used to request the next page of results. This field is - // empty if there are no additional results. - string next_page_token = 2; -} - -// Request to the `GetInsight` method. -message GetInsightRequest { - // Required. Name of the insight. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recommender.googleapis.com/Insight" - } - ]; -} - -// Request for the `MarkInsightAccepted` method. -message MarkInsightAcceptedRequest { - // Required. Name of the insight. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recommender.googleapis.com/Insight" - } - ]; - - // Optional. State properties user wish to include with this state. Full - // replace of the current state_metadata. - map state_metadata = 2 - [(google.api.field_behavior) = OPTIONAL]; - - // Required. Fingerprint of the Insight. Provides optimistic locking. - string etag = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for the `ListRecommendations` method. -message ListRecommendationsRequest { - // Required. The container resource on which to execute the request. - // Acceptable formats: - // - // * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - // - // * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - // - // * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - // - // * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - // - // * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - // - // LOCATION here refers to GCP Locations: - // https://cloud.google.com/about/locations/ - // RECOMMENDER_ID refers to supported recommenders: - // https://cloud.google.com/recommender/docs/recommenders. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recommender.googleapis.com/Recommender" - } - ]; - - // Optional. The maximum number of results to return from this request. - // Non-positive values are ignored. If not specified, the server will - // determine the number of results to return. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. If present, retrieves the next batch of results from the - // preceding call to this method. `page_token` must be the value of - // `next_page_token` from the previous response. The values of other method - // parameters must be identical to those in the previous call. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Filter expression to restrict the recommendations returned. Supported - // filter fields: - // - // * `state_info.state` - // - // * `recommenderSubtype` - // - // * `priority` - // - // Examples: - // - // * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - // - // * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` - // - // * `priority = P1 OR priority = P2` - // - // * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` - // - // (These expressions are based on the filter language described at - // https://google.aip.dev/160) - string filter = 5; -} - -// Response to the `ListRecommendations` method. -message ListRecommendationsResponse { - // The set of recommendations for the `parent` resource. - repeated Recommendation recommendations = 1; - - // A token that can be used to request the next page of results. This field is - // empty if there are no additional results. - string next_page_token = 2; -} - -// Request to the `GetRecommendation` method. -message GetRecommendationRequest { - // Required. Name of the recommendation. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recommender.googleapis.com/Recommendation" - } - ]; -} - -// Request for the `MarkRecommendationClaimed` Method. -message MarkRecommendationClaimedRequest { - // Required. Name of the recommendation. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recommender.googleapis.com/Recommendation" - } - ]; - - // State properties to include with this state. Overwrites any existing - // `state_metadata`. - // Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. - // Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. - map state_metadata = 2; - - // Required. Fingerprint of the Recommendation. Provides optimistic locking. - string etag = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for the `MarkRecommendationSucceeded` Method. -message MarkRecommendationSucceededRequest { - // Required. Name of the recommendation. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recommender.googleapis.com/Recommendation" - } - ]; - - // State properties to include with this state. Overwrites any existing - // `state_metadata`. - // Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. - // Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. - map state_metadata = 2; - - // Required. Fingerprint of the Recommendation. Provides optimistic locking. - string etag = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for the `MarkRecommendationFailed` Method. -message MarkRecommendationFailedRequest { - // Required. Name of the recommendation. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recommender.googleapis.com/Recommendation" - } - ]; - - // State properties to include with this state. Overwrites any existing - // `state_metadata`. - // Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. - // Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. - map state_metadata = 2; - - // Required. Fingerprint of the Recommendation. Provides optimistic locking. - string etag = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for the GetRecommenderConfig` method. -message GetRecommenderConfigRequest { - // Required. Name of the Recommendation Config to get. - // - // Acceptable formats: - // - // * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` - // - // * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` - // - // * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recommender.googleapis.com/RecommenderConfig" - } - ]; -} - -// Request for the `UpdateRecommenderConfig` method. -message UpdateRecommenderConfigRequest { - // Required. The RecommenderConfig to update. - RecommenderConfig recommender_config = 1 - [(google.api.field_behavior) = REQUIRED]; - - // The list of fields to be updated. - google.protobuf.FieldMask update_mask = 2; - - // If true, validate the request and preview the change, but do not actually - // update it. - bool validate_only = 3; -} - -// Request for the GetInsightTypeConfig` method. -message GetInsightTypeConfigRequest { - // Required. Name of the InsightTypeConfig to get. - // - // Acceptable formats: - // - // * `projects/[PROJECT_NUMBER]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` - // - // * `projects/[PROJECT_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` - // - // * `organizations/[ORGANIZATION_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recommender.googleapis.com/InsightTypeConfig" - } - ]; -} - -// Request for the `UpdateInsightTypeConfig` method. -message UpdateInsightTypeConfigRequest { - // Required. The InsightTypeConfig to update. - InsightTypeConfig insight_type_config = 1 - [(google.api.field_behavior) = REQUIRED]; - - // The list of fields to be updated. - google.protobuf.FieldMask update_mask = 2; - - // If true, validate the request and preview the change, but do not actually - // update it. - bool validate_only = 3; -} diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_insight.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_insight.js deleted file mode 100644 index 1bd5f590f46..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_insight.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(name) { - // [START recommender_v1_generated_Recommender_GetInsight_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the insight. - */ - // const name = 'abc123' - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callGetInsight() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await recommenderClient.getInsight(request); - console.log(response); - } - - callGetInsight(); - // [END recommender_v1_generated_Recommender_GetInsight_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_insight_type_config.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_insight_type_config.js deleted file mode 100644 index 36551fb8396..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_insight_type_config.js +++ /dev/null @@ -1,65 +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 recommender_v1_generated_Recommender_GetInsightTypeConfig_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the InsightTypeConfig to get. - * Acceptable formats: - * * `projects/[PROJECT_NUMBER]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` - * * `projects/[PROJECT_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` - * * `organizations/[ORGANIZATION_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` - */ - // const name = 'abc123' - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callGetInsightTypeConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await recommenderClient.getInsightTypeConfig(request); - console.log(response); - } - - callGetInsightTypeConfig(); - // [END recommender_v1_generated_Recommender_GetInsightTypeConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_recommendation.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_recommendation.js deleted file mode 100644 index 5e5eb1c8a7f..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_recommendation.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(name) { - // [START recommender_v1_generated_Recommender_GetRecommendation_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the recommendation. - */ - // const name = 'abc123' - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callGetRecommendation() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await recommenderClient.getRecommendation(request); - console.log(response); - } - - callGetRecommendation(); - // [END recommender_v1_generated_Recommender_GetRecommendation_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_recommender_config.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_recommender_config.js deleted file mode 100644 index f3f43e99f7c..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.get_recommender_config.js +++ /dev/null @@ -1,65 +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 recommender_v1_generated_Recommender_GetRecommenderConfig_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the Recommendation Config to get. - * Acceptable formats: - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` - * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` - */ - // const name = 'abc123' - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callGetRecommenderConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await recommenderClient.getRecommenderConfig(request); - console.log(response); - } - - callGetRecommenderConfig(); - // [END recommender_v1_generated_Recommender_GetRecommenderConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.list_insights.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.list_insights.js deleted file mode 100644 index 47c9e1f056c..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.list_insights.js +++ /dev/null @@ -1,101 +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 recommender_v1_generated_Recommender_ListInsights_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The container resource on which to execute the request. - * Acceptable formats: - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * LOCATION here refers to GCP Locations: - * https://cloud.google.com/about/locations/ - * INSIGHT_TYPE_ID refers to supported insight types: - * https://cloud.google.com/recommender/docs/insights/insight-types. - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of results to return from this request. - * Non-positive values are ignored. If not specified, the server will - * determine the number of results to return. - */ - // const pageSize = 1234 - /** - * Optional. If present, retrieves the next batch of results from the - * preceding call to this method. `page_token` must be the value of - * `next_page_token` from the previous response. The values of other method - * parameters must be identical to those in the previous call. - */ - // const pageToken = 'abc123' - /** - * Optional. Filter expression to restrict the insights returned. Supported - * filter fields: - * * `stateInfo.state` - * * `insightSubtype` - * * `severity` - * Examples: - * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - * * `insightSubtype = PERMISSIONS_USAGE` - * * `severity = CRITICAL OR severity = HIGH` - * * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` - * (These expressions are based on the filter language described at - * https://google.aip.dev/160) - */ - // const filter = 'abc123' - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callListInsights() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await recommenderClient.listInsightsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListInsights(); - // [END recommender_v1_generated_Recommender_ListInsights_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.list_recommendations.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.list_recommendations.js deleted file mode 100644 index c21dcc38993..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.list_recommendations.js +++ /dev/null @@ -1,101 +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 recommender_v1_generated_Recommender_ListRecommendations_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The container resource on which to execute the request. - * Acceptable formats: - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * LOCATION here refers to GCP Locations: - * https://cloud.google.com/about/locations/ - * RECOMMENDER_ID refers to supported recommenders: - * https://cloud.google.com/recommender/docs/recommenders. - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of results to return from this request. - * Non-positive values are ignored. If not specified, the server will - * determine the number of results to return. - */ - // const pageSize = 1234 - /** - * Optional. If present, retrieves the next batch of results from the - * preceding call to this method. `page_token` must be the value of - * `next_page_token` from the previous response. The values of other method - * parameters must be identical to those in the previous call. - */ - // const pageToken = 'abc123' - /** - * Filter expression to restrict the recommendations returned. Supported - * filter fields: - * * `state_info.state` - * * `recommenderSubtype` - * * `priority` - * Examples: - * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - * * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` - * * `priority = P1 OR priority = P2` - * * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` - * (These expressions are based on the filter language described at - * https://google.aip.dev/160) - */ - // const filter = 'abc123' - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callListRecommendations() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await recommenderClient.listRecommendationsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListRecommendations(); - // [END recommender_v1_generated_Recommender_ListRecommendations_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_insight_accepted.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_insight_accepted.js deleted file mode 100644 index 0dff5d47d9b..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_insight_accepted.js +++ /dev/null @@ -1,71 +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, etag) { - // [START recommender_v1_generated_Recommender_MarkInsightAccepted_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the insight. - */ - // const name = 'abc123' - /** - * Optional. State properties user wish to include with this state. Full - * replace of the current state_metadata. - */ - // const stateMetadata = [1,2,3,4] - /** - * Required. Fingerprint of the Insight. Provides optimistic locking. - */ - // const etag = 'abc123' - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callMarkInsightAccepted() { - // Construct request - const request = { - name, - etag, - }; - - // Run request - const response = await recommenderClient.markInsightAccepted(request); - console.log(response); - } - - callMarkInsightAccepted(); - // [END recommender_v1_generated_Recommender_MarkInsightAccepted_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_claimed.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_claimed.js deleted file mode 100644 index f3b8ffdc89a..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_claimed.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(name, etag) { - // [START recommender_v1_generated_Recommender_MarkRecommendationClaimed_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the recommendation. - */ - // const name = 'abc123' - /** - * State properties to include with this state. Overwrites any existing - * `state_metadata`. - * Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. - * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. - */ - // const stateMetadata = [1,2,3,4] - /** - * Required. Fingerprint of the Recommendation. Provides optimistic locking. - */ - // const etag = 'abc123' - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callMarkRecommendationClaimed() { - // Construct request - const request = { - name, - etag, - }; - - // Run request - const response = await recommenderClient.markRecommendationClaimed(request); - console.log(response); - } - - callMarkRecommendationClaimed(); - // [END recommender_v1_generated_Recommender_MarkRecommendationClaimed_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_failed.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_failed.js deleted file mode 100644 index 129aed6e91c..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_failed.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(name, etag) { - // [START recommender_v1_generated_Recommender_MarkRecommendationFailed_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the recommendation. - */ - // const name = 'abc123' - /** - * State properties to include with this state. Overwrites any existing - * `state_metadata`. - * Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. - * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. - */ - // const stateMetadata = [1,2,3,4] - /** - * Required. Fingerprint of the Recommendation. Provides optimistic locking. - */ - // const etag = 'abc123' - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callMarkRecommendationFailed() { - // Construct request - const request = { - name, - etag, - }; - - // Run request - const response = await recommenderClient.markRecommendationFailed(request); - console.log(response); - } - - callMarkRecommendationFailed(); - // [END recommender_v1_generated_Recommender_MarkRecommendationFailed_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_succeeded.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_succeeded.js deleted file mode 100644 index aff7d9418f7..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.mark_recommendation_succeeded.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(name, etag) { - // [START recommender_v1_generated_Recommender_MarkRecommendationSucceeded_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the recommendation. - */ - // const name = 'abc123' - /** - * State properties to include with this state. Overwrites any existing - * `state_metadata`. - * Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. - * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. - */ - // const stateMetadata = [1,2,3,4] - /** - * Required. Fingerprint of the Recommendation. Provides optimistic locking. - */ - // const etag = 'abc123' - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callMarkRecommendationSucceeded() { - // Construct request - const request = { - name, - etag, - }; - - // Run request - const response = await recommenderClient.markRecommendationSucceeded(request); - console.log(response); - } - - callMarkRecommendationSucceeded(); - // [END recommender_v1_generated_Recommender_MarkRecommendationSucceeded_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.update_insight_type_config.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.update_insight_type_config.js deleted file mode 100644 index 1b370d8c471..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.update_insight_type_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(insightTypeConfig) { - // [START recommender_v1_generated_Recommender_UpdateInsightTypeConfig_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The InsightTypeConfig to update. - */ - // const insightTypeConfig = {} - /** - * The list of fields to be updated. - */ - // const updateMask = {} - /** - * If true, validate the request and preview the change, but do not actually - * update it. - */ - // const validateOnly = true - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callUpdateInsightTypeConfig() { - // Construct request - const request = { - insightTypeConfig, - }; - - // Run request - const response = await recommenderClient.updateInsightTypeConfig(request); - console.log(response); - } - - callUpdateInsightTypeConfig(); - // [END recommender_v1_generated_Recommender_UpdateInsightTypeConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.update_recommender_config.js b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.update_recommender_config.js deleted file mode 100644 index e4ac74aba64..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/recommender.update_recommender_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(recommenderConfig) { - // [START recommender_v1_generated_Recommender_UpdateRecommenderConfig_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The RecommenderConfig to update. - */ - // const recommenderConfig = {} - /** - * The list of fields to be updated. - */ - // const updateMask = {} - /** - * If true, validate the request and preview the change, but do not actually - * update it. - */ - // const validateOnly = true - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callUpdateRecommenderConfig() { - // Construct request - const request = { - recommenderConfig, - }; - - // Run request - const response = await recommenderClient.updateRecommenderConfig(request); - console.log(response); - } - - callUpdateRecommenderConfig(); - // [END recommender_v1_generated_Recommender_UpdateRecommenderConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/snippet_metadata_google.cloud.recommender.v1.json b/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/snippet_metadata_google.cloud.recommender.v1.json deleted file mode 100644 index 23f0e88e485..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/samples/generated/v1/snippet_metadata_google.cloud.recommender.v1.json +++ /dev/null @@ -1,567 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-recommender", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.recommender.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "recommender_v1_generated_Recommender_ListInsights_async", - "title": "Recommender listInsights Sample", - "origin": "API_DEFINITION", - "description": " Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.", - "canonical": true, - "file": "recommender.list_insights.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 93, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListInsights", - "fullName": "google.cloud.recommender.v1.Recommender.ListInsights", - "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.recommender.v1.ListInsightsResponse", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1.RecommenderClient" - }, - "method": { - "shortName": "ListInsights", - "fullName": "google.cloud.recommender.v1.Recommender.ListInsights", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1_generated_Recommender_GetInsight_async", - "title": "Recommender getInsight Sample", - "origin": "API_DEFINITION", - "description": " Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.", - "canonical": true, - "file": "recommender.get_insight.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetInsight", - "fullName": "google.cloud.recommender.v1.Recommender.GetInsight", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recommender.v1.Insight", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1.RecommenderClient" - }, - "method": { - "shortName": "GetInsight", - "fullName": "google.cloud.recommender.v1.Recommender.GetInsight", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1_generated_Recommender_MarkInsightAccepted_async", - "title": "Recommender markInsightAccepted Sample", - "origin": "API_DEFINITION", - "description": " Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated. MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.", - "canonical": true, - "file": "recommender.mark_insight_accepted.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "MarkInsightAccepted", - "fullName": "google.cloud.recommender.v1.Recommender.MarkInsightAccepted", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "state_metadata", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "etag", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recommender.v1.Insight", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1.RecommenderClient" - }, - "method": { - "shortName": "MarkInsightAccepted", - "fullName": "google.cloud.recommender.v1.Recommender.MarkInsightAccepted", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1_generated_Recommender_ListRecommendations_async", - "title": "Recommender listRecommendations Sample", - "origin": "API_DEFINITION", - "description": " Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.", - "canonical": true, - "file": "recommender.list_recommendations.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 93, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListRecommendations", - "fullName": "google.cloud.recommender.v1.Recommender.ListRecommendations", - "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.recommender.v1.ListRecommendationsResponse", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1.RecommenderClient" - }, - "method": { - "shortName": "ListRecommendations", - "fullName": "google.cloud.recommender.v1.Recommender.ListRecommendations", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1_generated_Recommender_GetRecommendation_async", - "title": "Recommender getRecommendation Sample", - "origin": "API_DEFINITION", - "description": " Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.", - "canonical": true, - "file": "recommender.get_recommendation.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetRecommendation", - "fullName": "google.cloud.recommender.v1.Recommender.GetRecommendation", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recommender.v1.Recommendation", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1.RecommenderClient" - }, - "method": { - "shortName": "GetRecommendation", - "fullName": "google.cloud.recommender.v1.Recommender.GetRecommendation", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1_generated_Recommender_MarkRecommendationClaimed_async", - "title": "Recommender markRecommendationClaimed Sample", - "origin": "API_DEFINITION", - "description": " Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationClaimed can be applied to recommendations in CLAIMED, SUCCEEDED, FAILED, or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.", - "canonical": true, - "file": "recommender.mark_recommendation_claimed.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "MarkRecommendationClaimed", - "fullName": "google.cloud.recommender.v1.Recommender.MarkRecommendationClaimed", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "state_metadata", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "etag", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recommender.v1.Recommendation", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1.RecommenderClient" - }, - "method": { - "shortName": "MarkRecommendationClaimed", - "fullName": "google.cloud.recommender.v1.Recommender.MarkRecommendationClaimed", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1_generated_Recommender_MarkRecommendationSucceeded_async", - "title": "Recommender markRecommendationSucceeded Sample", - "origin": "API_DEFINITION", - "description": " Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.", - "canonical": true, - "file": "recommender.mark_recommendation_succeeded.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "MarkRecommendationSucceeded", - "fullName": "google.cloud.recommender.v1.Recommender.MarkRecommendationSucceeded", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "state_metadata", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "etag", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recommender.v1.Recommendation", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1.RecommenderClient" - }, - "method": { - "shortName": "MarkRecommendationSucceeded", - "fullName": "google.cloud.recommender.v1.Recommender.MarkRecommendationSucceeded", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1_generated_Recommender_MarkRecommendationFailed_async", - "title": "Recommender markRecommendationFailed Sample", - "origin": "API_DEFINITION", - "description": " Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.", - "canonical": true, - "file": "recommender.mark_recommendation_failed.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "MarkRecommendationFailed", - "fullName": "google.cloud.recommender.v1.Recommender.MarkRecommendationFailed", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "state_metadata", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "etag", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recommender.v1.Recommendation", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1.RecommenderClient" - }, - "method": { - "shortName": "MarkRecommendationFailed", - "fullName": "google.cloud.recommender.v1.Recommender.MarkRecommendationFailed", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1_generated_Recommender_GetRecommenderConfig_async", - "title": "Recommender getRecommenderConfig Sample", - "origin": "API_DEFINITION", - "description": " Gets the requested Recommender Config. There is only one instance of the config for each Recommender.", - "canonical": true, - "file": "recommender.get_recommender_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetRecommenderConfig", - "fullName": "google.cloud.recommender.v1.Recommender.GetRecommenderConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recommender.v1.RecommenderConfig", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1.RecommenderClient" - }, - "method": { - "shortName": "GetRecommenderConfig", - "fullName": "google.cloud.recommender.v1.Recommender.GetRecommenderConfig", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1_generated_Recommender_UpdateRecommenderConfig_async", - "title": "Recommender updateRecommenderConfig Sample", - "origin": "API_DEFINITION", - "description": " Updates a Recommender Config. This will create a new revision of the config.", - "canonical": true, - "file": "recommender.update_recommender_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateRecommenderConfig", - "fullName": "google.cloud.recommender.v1.Recommender.UpdateRecommenderConfig", - "async": true, - "parameters": [ - { - "name": "recommender_config", - "type": ".google.cloud.recommender.v1.RecommenderConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.recommender.v1.RecommenderConfig", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1.RecommenderClient" - }, - "method": { - "shortName": "UpdateRecommenderConfig", - "fullName": "google.cloud.recommender.v1.Recommender.UpdateRecommenderConfig", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1_generated_Recommender_GetInsightTypeConfig_async", - "title": "Recommender getInsightTypeConfig Sample", - "origin": "API_DEFINITION", - "description": " Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.", - "canonical": true, - "file": "recommender.get_insight_type_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetInsightTypeConfig", - "fullName": "google.cloud.recommender.v1.Recommender.GetInsightTypeConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recommender.v1.InsightTypeConfig", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1.RecommenderClient" - }, - "method": { - "shortName": "GetInsightTypeConfig", - "fullName": "google.cloud.recommender.v1.Recommender.GetInsightTypeConfig", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1_generated_Recommender_UpdateInsightTypeConfig_async", - "title": "Recommender updateInsightTypeConfig Sample", - "origin": "API_DEFINITION", - "description": " Updates an InsightTypeConfig change. This will create a new revision of the config.", - "canonical": true, - "file": "recommender.update_insight_type_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateInsightTypeConfig", - "fullName": "google.cloud.recommender.v1.Recommender.UpdateInsightTypeConfig", - "async": true, - "parameters": [ - { - "name": "insight_type_config", - "type": ".google.cloud.recommender.v1.InsightTypeConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.recommender.v1.InsightTypeConfig", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1.RecommenderClient" - }, - "method": { - "shortName": "UpdateInsightTypeConfig", - "fullName": "google.cloud.recommender.v1.Recommender.UpdateInsightTypeConfig", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1.Recommender" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-recommender/v1/src/index.ts b/owl-bot-staging/google-cloud-recommender/v1/src/index.ts deleted file mode 100644 index 9b1977ca960..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/src/index.ts +++ /dev/null @@ -1,25 +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 v1 from './v1'; -const RecommenderClient = v1.RecommenderClient; -type RecommenderClient = v1.RecommenderClient; -export {v1, RecommenderClient}; -export default {v1, RecommenderClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-recommender/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-recommender/v1/src/v1/gapic_metadata.json deleted file mode 100644 index ac3dc26d8b6..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,151 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.recommender.v1", - "libraryPackage": "@google-cloud/recommender", - "services": { - "Recommender": { - "clients": { - "grpc": { - "libraryClient": "RecommenderClient", - "rpcs": { - "GetInsight": { - "methods": [ - "getInsight" - ] - }, - "MarkInsightAccepted": { - "methods": [ - "markInsightAccepted" - ] - }, - "GetRecommendation": { - "methods": [ - "getRecommendation" - ] - }, - "MarkRecommendationClaimed": { - "methods": [ - "markRecommendationClaimed" - ] - }, - "MarkRecommendationSucceeded": { - "methods": [ - "markRecommendationSucceeded" - ] - }, - "MarkRecommendationFailed": { - "methods": [ - "markRecommendationFailed" - ] - }, - "GetRecommenderConfig": { - "methods": [ - "getRecommenderConfig" - ] - }, - "UpdateRecommenderConfig": { - "methods": [ - "updateRecommenderConfig" - ] - }, - "GetInsightTypeConfig": { - "methods": [ - "getInsightTypeConfig" - ] - }, - "UpdateInsightTypeConfig": { - "methods": [ - "updateInsightTypeConfig" - ] - }, - "ListInsights": { - "methods": [ - "listInsights", - "listInsightsStream", - "listInsightsAsync" - ] - }, - "ListRecommendations": { - "methods": [ - "listRecommendations", - "listRecommendationsStream", - "listRecommendationsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "RecommenderClient", - "rpcs": { - "GetInsight": { - "methods": [ - "getInsight" - ] - }, - "MarkInsightAccepted": { - "methods": [ - "markInsightAccepted" - ] - }, - "GetRecommendation": { - "methods": [ - "getRecommendation" - ] - }, - "MarkRecommendationClaimed": { - "methods": [ - "markRecommendationClaimed" - ] - }, - "MarkRecommendationSucceeded": { - "methods": [ - "markRecommendationSucceeded" - ] - }, - "MarkRecommendationFailed": { - "methods": [ - "markRecommendationFailed" - ] - }, - "GetRecommenderConfig": { - "methods": [ - "getRecommenderConfig" - ] - }, - "UpdateRecommenderConfig": { - "methods": [ - "updateRecommenderConfig" - ] - }, - "GetInsightTypeConfig": { - "methods": [ - "getInsightTypeConfig" - ] - }, - "UpdateInsightTypeConfig": { - "methods": [ - "updateInsightTypeConfig" - ] - }, - "ListInsights": { - "methods": [ - "listInsights", - "listInsightsStream", - "listInsightsAsync" - ] - }, - "ListRecommendations": { - "methods": [ - "listRecommendations", - "listRecommendationsStream", - "listRecommendationsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-recommender/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-recommender/v1/src/v1/index.ts deleted file mode 100644 index fbe6584bdf2..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +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 {RecommenderClient} from './recommender_client'; diff --git a/owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_client.ts b/owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_client.ts deleted file mode 100644 index cc25dbaa309..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_client.ts +++ /dev/null @@ -1,2866 +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, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/recommender_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './recommender_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Provides insights and recommendations for cloud customers for various - * categories like performance optimization, cost savings, reliability, feature - * discovery, etc. Insights and recommendations are generated automatically - * based on analysis of user resources, configuration and monitoring metrics. - * @class - * @memberof v1 - */ -export class RecommenderClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - recommenderStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of RecommenderClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 RecommenderClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof RecommenderClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - billingAccountLocationInsightTypePathTemplate: new this._gaxModule.PathTemplate( - 'billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}' - ), - billingAccountLocationInsightTypeInsightPathTemplate: new this._gaxModule.PathTemplate( - 'billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}/insights/{insight}' - ), - billingAccountLocationRecommenderPathTemplate: new this._gaxModule.PathTemplate( - 'billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}' - ), - billingAccountLocationRecommenderRecommendationPathTemplate: new this._gaxModule.PathTemplate( - 'billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}' - ), - folderLocationInsightTypePathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}/locations/{location}/insightTypes/{insight_type}' - ), - folderLocationInsightTypeInsightPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}/locations/{location}/insightTypes/{insight_type}/insights/{insight}' - ), - folderLocationRecommenderPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}/locations/{location}/recommenders/{recommender}' - ), - folderLocationRecommenderRecommendationPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}' - ), - organizationLocationInsightTypePathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/insightTypes/{insight_type}' - ), - organizationLocationInsightTypeConfigPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/insightTypes/{insight_type}/config' - ), - organizationLocationInsightTypeInsightPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/insightTypes/{insight_type}/insights/{insight}' - ), - organizationLocationRecommenderPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/recommenders/{recommender}' - ), - organizationLocationRecommenderConfigPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/recommenders/{recommender}/config' - ), - organizationLocationRecommenderRecommendationPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}' - ), - projectLocationInsightTypePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/insightTypes/{insight_type}' - ), - projectLocationInsightTypeConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/insightTypes/{insight_type}/config' - ), - projectLocationInsightTypeInsightPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/insightTypes/{insight_type}/insights/{insight}' - ), - projectLocationRecommenderPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/recommenders/{recommender}' - ), - projectLocationRecommenderConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/recommenders/{recommender}/config' - ), - projectLocationRecommenderRecommendationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}' - ), - }; - - // 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 = { - listInsights: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'insights'), - listRecommendations: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'recommendations') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.recommender.v1.Recommender', 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.recommenderStub) { - return this.recommenderStub; - } - - // Put together the "service stub" for - // google.cloud.recommender.v1.Recommender. - this.recommenderStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.recommender.v1.Recommender') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.recommender.v1.Recommender, - 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 recommenderStubMethods = - ['listInsights', 'getInsight', 'markInsightAccepted', 'listRecommendations', 'getRecommendation', 'markRecommendationClaimed', 'markRecommendationSucceeded', 'markRecommendationFailed', 'getRecommenderConfig', 'updateRecommenderConfig', 'getInsightTypeConfig', 'updateInsightTypeConfig']; - for (const methodName of recommenderStubMethods) { - const callPromise = this.recommenderStub.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.recommenderStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'recommender.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 'recommender.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 the requested insight. Requires the recommender.*.get IAM permission - * for the specified insight type. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the insight. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1.Insight|Insight}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recommender.get_insight.js - * region_tag:recommender_v1_generated_Recommender_GetInsight_async - */ - getInsight( - request?: protos.google.cloud.recommender.v1.IGetInsightRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1.IInsight, - protos.google.cloud.recommender.v1.IGetInsightRequest|undefined, {}|undefined - ]>; - getInsight( - request: protos.google.cloud.recommender.v1.IGetInsightRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recommender.v1.IInsight, - protos.google.cloud.recommender.v1.IGetInsightRequest|null|undefined, - {}|null|undefined>): void; - getInsight( - request: protos.google.cloud.recommender.v1.IGetInsightRequest, - callback: Callback< - protos.google.cloud.recommender.v1.IInsight, - protos.google.cloud.recommender.v1.IGetInsightRequest|null|undefined, - {}|null|undefined>): void; - getInsight( - request?: protos.google.cloud.recommender.v1.IGetInsightRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recommender.v1.IInsight, - protos.google.cloud.recommender.v1.IGetInsightRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recommender.v1.IInsight, - protos.google.cloud.recommender.v1.IGetInsightRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recommender.v1.IInsight, - protos.google.cloud.recommender.v1.IGetInsightRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getInsight(request, options, callback); - } -/** - * Marks the Insight State as Accepted. Users can use this method to - * indicate to the Recommender API that they have applied some action based - * on the insight. This stops the insight content from being updated. - * - * MarkInsightAccepted can be applied to insights in ACTIVE state. Requires - * the recommender.*.update IAM permission for the specified insight. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the insight. - * @param {number[]} [request.stateMetadata] - * Optional. State properties user wish to include with this state. Full - * replace of the current state_metadata. - * @param {string} request.etag - * Required. Fingerprint of the Insight. Provides optimistic locking. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1.Insight|Insight}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recommender.mark_insight_accepted.js - * region_tag:recommender_v1_generated_Recommender_MarkInsightAccepted_async - */ - markInsightAccepted( - request?: protos.google.cloud.recommender.v1.IMarkInsightAcceptedRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1.IInsight, - protos.google.cloud.recommender.v1.IMarkInsightAcceptedRequest|undefined, {}|undefined - ]>; - markInsightAccepted( - request: protos.google.cloud.recommender.v1.IMarkInsightAcceptedRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recommender.v1.IInsight, - protos.google.cloud.recommender.v1.IMarkInsightAcceptedRequest|null|undefined, - {}|null|undefined>): void; - markInsightAccepted( - request: protos.google.cloud.recommender.v1.IMarkInsightAcceptedRequest, - callback: Callback< - protos.google.cloud.recommender.v1.IInsight, - protos.google.cloud.recommender.v1.IMarkInsightAcceptedRequest|null|undefined, - {}|null|undefined>): void; - markInsightAccepted( - request?: protos.google.cloud.recommender.v1.IMarkInsightAcceptedRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recommender.v1.IInsight, - protos.google.cloud.recommender.v1.IMarkInsightAcceptedRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recommender.v1.IInsight, - protos.google.cloud.recommender.v1.IMarkInsightAcceptedRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recommender.v1.IInsight, - protos.google.cloud.recommender.v1.IMarkInsightAcceptedRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.markInsightAccepted(request, options, callback); - } -/** - * Gets the requested recommendation. Requires the recommender.*.get - * IAM permission for the specified recommender. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the recommendation. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1.Recommendation|Recommendation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recommender.get_recommendation.js - * region_tag:recommender_v1_generated_Recommender_GetRecommendation_async - */ - getRecommendation( - request?: protos.google.cloud.recommender.v1.IGetRecommendationRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IGetRecommendationRequest|undefined, {}|undefined - ]>; - getRecommendation( - request: protos.google.cloud.recommender.v1.IGetRecommendationRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IGetRecommendationRequest|null|undefined, - {}|null|undefined>): void; - getRecommendation( - request: protos.google.cloud.recommender.v1.IGetRecommendationRequest, - callback: Callback< - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IGetRecommendationRequest|null|undefined, - {}|null|undefined>): void; - getRecommendation( - request?: protos.google.cloud.recommender.v1.IGetRecommendationRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IGetRecommendationRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IGetRecommendationRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IGetRecommendationRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getRecommendation(request, options, callback); - } -/** - * Marks the Recommendation State as Claimed. Users can use this method to - * indicate to the Recommender API that they are starting to apply the - * recommendation themselves. This stops the recommendation content from being - * updated. Associated insights are frozen and placed in the ACCEPTED state. - * - * MarkRecommendationClaimed can be applied to recommendations in CLAIMED, - * SUCCEEDED, FAILED, or ACTIVE state. - * - * Requires the recommender.*.update IAM permission for the specified - * recommender. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the recommendation. - * @param {number[]} request.stateMetadata - * State properties to include with this state. Overwrites any existing - * `state_metadata`. - * Keys must match the regex `/^{@link protos.a-z0-9_.-|a-z0-9}{0,62}$/`. - * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. - * @param {string} request.etag - * Required. Fingerprint of the Recommendation. Provides optimistic locking. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1.Recommendation|Recommendation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recommender.mark_recommendation_claimed.js - * region_tag:recommender_v1_generated_Recommender_MarkRecommendationClaimed_async - */ - markRecommendationClaimed( - request?: protos.google.cloud.recommender.v1.IMarkRecommendationClaimedRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IMarkRecommendationClaimedRequest|undefined, {}|undefined - ]>; - markRecommendationClaimed( - request: protos.google.cloud.recommender.v1.IMarkRecommendationClaimedRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IMarkRecommendationClaimedRequest|null|undefined, - {}|null|undefined>): void; - markRecommendationClaimed( - request: protos.google.cloud.recommender.v1.IMarkRecommendationClaimedRequest, - callback: Callback< - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IMarkRecommendationClaimedRequest|null|undefined, - {}|null|undefined>): void; - markRecommendationClaimed( - request?: protos.google.cloud.recommender.v1.IMarkRecommendationClaimedRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IMarkRecommendationClaimedRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IMarkRecommendationClaimedRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IMarkRecommendationClaimedRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.markRecommendationClaimed(request, options, callback); - } -/** - * Marks the Recommendation State as Succeeded. Users can use this method to - * indicate to the Recommender API that they have applied the recommendation - * themselves, and the operation was successful. This stops the recommendation - * content from being updated. Associated insights are frozen and placed in - * the ACCEPTED state. - * - * MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, - * CLAIMED, SUCCEEDED, or FAILED state. - * - * Requires the recommender.*.update IAM permission for the specified - * recommender. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the recommendation. - * @param {number[]} request.stateMetadata - * State properties to include with this state. Overwrites any existing - * `state_metadata`. - * Keys must match the regex `/^{@link protos.a-z0-9_.-|a-z0-9}{0,62}$/`. - * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. - * @param {string} request.etag - * Required. Fingerprint of the Recommendation. Provides optimistic locking. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1.Recommendation|Recommendation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recommender.mark_recommendation_succeeded.js - * region_tag:recommender_v1_generated_Recommender_MarkRecommendationSucceeded_async - */ - markRecommendationSucceeded( - request?: protos.google.cloud.recommender.v1.IMarkRecommendationSucceededRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IMarkRecommendationSucceededRequest|undefined, {}|undefined - ]>; - markRecommendationSucceeded( - request: protos.google.cloud.recommender.v1.IMarkRecommendationSucceededRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IMarkRecommendationSucceededRequest|null|undefined, - {}|null|undefined>): void; - markRecommendationSucceeded( - request: protos.google.cloud.recommender.v1.IMarkRecommendationSucceededRequest, - callback: Callback< - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IMarkRecommendationSucceededRequest|null|undefined, - {}|null|undefined>): void; - markRecommendationSucceeded( - request?: protos.google.cloud.recommender.v1.IMarkRecommendationSucceededRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IMarkRecommendationSucceededRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IMarkRecommendationSucceededRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IMarkRecommendationSucceededRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.markRecommendationSucceeded(request, options, callback); - } -/** - * Marks the Recommendation State as Failed. Users can use this method to - * indicate to the Recommender API that they have applied the recommendation - * themselves, and the operation failed. This stops the recommendation content - * from being updated. Associated insights are frozen and placed in the - * ACCEPTED state. - * - * MarkRecommendationFailed can be applied to recommendations in ACTIVE, - * CLAIMED, SUCCEEDED, or FAILED state. - * - * Requires the recommender.*.update IAM permission for the specified - * recommender. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the recommendation. - * @param {number[]} request.stateMetadata - * State properties to include with this state. Overwrites any existing - * `state_metadata`. - * Keys must match the regex `/^{@link protos.a-z0-9_.-|a-z0-9}{0,62}$/`. - * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. - * @param {string} request.etag - * Required. Fingerprint of the Recommendation. Provides optimistic locking. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1.Recommendation|Recommendation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recommender.mark_recommendation_failed.js - * region_tag:recommender_v1_generated_Recommender_MarkRecommendationFailed_async - */ - markRecommendationFailed( - request?: protos.google.cloud.recommender.v1.IMarkRecommendationFailedRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IMarkRecommendationFailedRequest|undefined, {}|undefined - ]>; - markRecommendationFailed( - request: protos.google.cloud.recommender.v1.IMarkRecommendationFailedRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IMarkRecommendationFailedRequest|null|undefined, - {}|null|undefined>): void; - markRecommendationFailed( - request: protos.google.cloud.recommender.v1.IMarkRecommendationFailedRequest, - callback: Callback< - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IMarkRecommendationFailedRequest|null|undefined, - {}|null|undefined>): void; - markRecommendationFailed( - request?: protos.google.cloud.recommender.v1.IMarkRecommendationFailedRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IMarkRecommendationFailedRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IMarkRecommendationFailedRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recommender.v1.IRecommendation, - protos.google.cloud.recommender.v1.IMarkRecommendationFailedRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.markRecommendationFailed(request, options, callback); - } -/** - * Gets the requested Recommender Config. There is only one instance of the - * config for each Recommender. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the Recommendation Config to get. - * - * Acceptable formats: - * - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` - * - * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` - * - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/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 protos.google.cloud.recommender.v1.RecommenderConfig|RecommenderConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recommender.get_recommender_config.js - * region_tag:recommender_v1_generated_Recommender_GetRecommenderConfig_async - */ - getRecommenderConfig( - request?: protos.google.cloud.recommender.v1.IGetRecommenderConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1.IRecommenderConfig, - protos.google.cloud.recommender.v1.IGetRecommenderConfigRequest|undefined, {}|undefined - ]>; - getRecommenderConfig( - request: protos.google.cloud.recommender.v1.IGetRecommenderConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recommender.v1.IRecommenderConfig, - protos.google.cloud.recommender.v1.IGetRecommenderConfigRequest|null|undefined, - {}|null|undefined>): void; - getRecommenderConfig( - request: protos.google.cloud.recommender.v1.IGetRecommenderConfigRequest, - callback: Callback< - protos.google.cloud.recommender.v1.IRecommenderConfig, - protos.google.cloud.recommender.v1.IGetRecommenderConfigRequest|null|undefined, - {}|null|undefined>): void; - getRecommenderConfig( - request?: protos.google.cloud.recommender.v1.IGetRecommenderConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recommender.v1.IRecommenderConfig, - protos.google.cloud.recommender.v1.IGetRecommenderConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recommender.v1.IRecommenderConfig, - protos.google.cloud.recommender.v1.IGetRecommenderConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recommender.v1.IRecommenderConfig, - protos.google.cloud.recommender.v1.IGetRecommenderConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getRecommenderConfig(request, options, callback); - } -/** - * Updates a Recommender Config. This will create a new revision of the - * config. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.recommender.v1.RecommenderConfig} request.recommenderConfig - * Required. The RecommenderConfig to update. - * @param {google.protobuf.FieldMask} request.updateMask - * The list of fields to be updated. - * @param {boolean} request.validateOnly - * If true, validate the request and preview the change, but do not actually - * update it. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1.RecommenderConfig|RecommenderConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recommender.update_recommender_config.js - * region_tag:recommender_v1_generated_Recommender_UpdateRecommenderConfig_async - */ - updateRecommenderConfig( - request?: protos.google.cloud.recommender.v1.IUpdateRecommenderConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1.IRecommenderConfig, - protos.google.cloud.recommender.v1.IUpdateRecommenderConfigRequest|undefined, {}|undefined - ]>; - updateRecommenderConfig( - request: protos.google.cloud.recommender.v1.IUpdateRecommenderConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recommender.v1.IRecommenderConfig, - protos.google.cloud.recommender.v1.IUpdateRecommenderConfigRequest|null|undefined, - {}|null|undefined>): void; - updateRecommenderConfig( - request: protos.google.cloud.recommender.v1.IUpdateRecommenderConfigRequest, - callback: Callback< - protos.google.cloud.recommender.v1.IRecommenderConfig, - protos.google.cloud.recommender.v1.IUpdateRecommenderConfigRequest|null|undefined, - {}|null|undefined>): void; - updateRecommenderConfig( - request?: protos.google.cloud.recommender.v1.IUpdateRecommenderConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recommender.v1.IRecommenderConfig, - protos.google.cloud.recommender.v1.IUpdateRecommenderConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recommender.v1.IRecommenderConfig, - protos.google.cloud.recommender.v1.IUpdateRecommenderConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recommender.v1.IRecommenderConfig, - protos.google.cloud.recommender.v1.IUpdateRecommenderConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'recommender_config.name': request.recommenderConfig!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateRecommenderConfig(request, options, callback); - } -/** - * Gets the requested InsightTypeConfig. There is only one instance of the - * config for each InsightType. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the InsightTypeConfig to get. - * - * Acceptable formats: - * - * * `projects/[PROJECT_NUMBER]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` - * - * * `projects/[PROJECT_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` - * - * * `organizations/[ORGANIZATION_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/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 protos.google.cloud.recommender.v1.InsightTypeConfig|InsightTypeConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recommender.get_insight_type_config.js - * region_tag:recommender_v1_generated_Recommender_GetInsightTypeConfig_async - */ - getInsightTypeConfig( - request?: protos.google.cloud.recommender.v1.IGetInsightTypeConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1.IInsightTypeConfig, - protos.google.cloud.recommender.v1.IGetInsightTypeConfigRequest|undefined, {}|undefined - ]>; - getInsightTypeConfig( - request: protos.google.cloud.recommender.v1.IGetInsightTypeConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recommender.v1.IInsightTypeConfig, - protos.google.cloud.recommender.v1.IGetInsightTypeConfigRequest|null|undefined, - {}|null|undefined>): void; - getInsightTypeConfig( - request: protos.google.cloud.recommender.v1.IGetInsightTypeConfigRequest, - callback: Callback< - protos.google.cloud.recommender.v1.IInsightTypeConfig, - protos.google.cloud.recommender.v1.IGetInsightTypeConfigRequest|null|undefined, - {}|null|undefined>): void; - getInsightTypeConfig( - request?: protos.google.cloud.recommender.v1.IGetInsightTypeConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recommender.v1.IInsightTypeConfig, - protos.google.cloud.recommender.v1.IGetInsightTypeConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recommender.v1.IInsightTypeConfig, - protos.google.cloud.recommender.v1.IGetInsightTypeConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recommender.v1.IInsightTypeConfig, - protos.google.cloud.recommender.v1.IGetInsightTypeConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getInsightTypeConfig(request, options, callback); - } -/** - * Updates an InsightTypeConfig change. This will create a new revision of the - * config. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.recommender.v1.InsightTypeConfig} request.insightTypeConfig - * Required. The InsightTypeConfig to update. - * @param {google.protobuf.FieldMask} request.updateMask - * The list of fields to be updated. - * @param {boolean} request.validateOnly - * If true, validate the request and preview the change, but do not actually - * update it. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1.InsightTypeConfig|InsightTypeConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recommender.update_insight_type_config.js - * region_tag:recommender_v1_generated_Recommender_UpdateInsightTypeConfig_async - */ - updateInsightTypeConfig( - request?: protos.google.cloud.recommender.v1.IUpdateInsightTypeConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1.IInsightTypeConfig, - protos.google.cloud.recommender.v1.IUpdateInsightTypeConfigRequest|undefined, {}|undefined - ]>; - updateInsightTypeConfig( - request: protos.google.cloud.recommender.v1.IUpdateInsightTypeConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recommender.v1.IInsightTypeConfig, - protos.google.cloud.recommender.v1.IUpdateInsightTypeConfigRequest|null|undefined, - {}|null|undefined>): void; - updateInsightTypeConfig( - request: protos.google.cloud.recommender.v1.IUpdateInsightTypeConfigRequest, - callback: Callback< - protos.google.cloud.recommender.v1.IInsightTypeConfig, - protos.google.cloud.recommender.v1.IUpdateInsightTypeConfigRequest|null|undefined, - {}|null|undefined>): void; - updateInsightTypeConfig( - request?: protos.google.cloud.recommender.v1.IUpdateInsightTypeConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recommender.v1.IInsightTypeConfig, - protos.google.cloud.recommender.v1.IUpdateInsightTypeConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recommender.v1.IInsightTypeConfig, - protos.google.cloud.recommender.v1.IUpdateInsightTypeConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recommender.v1.IInsightTypeConfig, - protos.google.cloud.recommender.v1.IUpdateInsightTypeConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'insight_type_config.name': request.insightTypeConfig!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateInsightTypeConfig(request, options, callback); - } - - /** - * Lists insights for the specified Cloud Resource. Requires the - * recommender.*.list IAM permission for the specified insight type. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The container resource on which to execute the request. - * Acceptable formats: - * - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * LOCATION here refers to GCP Locations: - * https://cloud.google.com/about/locations/ - * INSIGHT_TYPE_ID refers to supported insight types: - * https://cloud.google.com/recommender/docs/insights/insight-types. - * @param {number} [request.pageSize] - * Optional. The maximum number of results to return from this request. - * Non-positive values are ignored. If not specified, the server will - * determine the number of results to return. - * @param {string} [request.pageToken] - * Optional. If present, retrieves the next batch of results from the - * preceding call to this method. `page_token` must be the value of - * `next_page_token` from the previous response. The values of other method - * parameters must be identical to those in the previous call. - * @param {string} [request.filter] - * Optional. Filter expression to restrict the insights returned. Supported - * filter fields: - * - * * `stateInfo.state` - * - * * `insightSubtype` - * - * * `severity` - * - * Examples: - * - * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - * - * * `insightSubtype = PERMISSIONS_USAGE` - * - * * `severity = CRITICAL OR severity = HIGH` - * - * * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` - * - * (These expressions are based on the filter language described at - * https://google.aip.dev/160) - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.recommender.v1.Insight|Insight}. - * 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 `listInsightsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listInsights( - request?: protos.google.cloud.recommender.v1.IListInsightsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1.IInsight[], - protos.google.cloud.recommender.v1.IListInsightsRequest|null, - protos.google.cloud.recommender.v1.IListInsightsResponse - ]>; - listInsights( - request: protos.google.cloud.recommender.v1.IListInsightsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.recommender.v1.IListInsightsRequest, - protos.google.cloud.recommender.v1.IListInsightsResponse|null|undefined, - protos.google.cloud.recommender.v1.IInsight>): void; - listInsights( - request: protos.google.cloud.recommender.v1.IListInsightsRequest, - callback: PaginationCallback< - protos.google.cloud.recommender.v1.IListInsightsRequest, - protos.google.cloud.recommender.v1.IListInsightsResponse|null|undefined, - protos.google.cloud.recommender.v1.IInsight>): void; - listInsights( - request?: protos.google.cloud.recommender.v1.IListInsightsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.recommender.v1.IListInsightsRequest, - protos.google.cloud.recommender.v1.IListInsightsResponse|null|undefined, - protos.google.cloud.recommender.v1.IInsight>, - callback?: PaginationCallback< - protos.google.cloud.recommender.v1.IListInsightsRequest, - protos.google.cloud.recommender.v1.IListInsightsResponse|null|undefined, - protos.google.cloud.recommender.v1.IInsight>): - Promise<[ - protos.google.cloud.recommender.v1.IInsight[], - protos.google.cloud.recommender.v1.IListInsightsRequest|null, - protos.google.cloud.recommender.v1.IListInsightsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listInsights(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 container resource on which to execute the request. - * Acceptable formats: - * - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * LOCATION here refers to GCP Locations: - * https://cloud.google.com/about/locations/ - * INSIGHT_TYPE_ID refers to supported insight types: - * https://cloud.google.com/recommender/docs/insights/insight-types. - * @param {number} [request.pageSize] - * Optional. The maximum number of results to return from this request. - * Non-positive values are ignored. If not specified, the server will - * determine the number of results to return. - * @param {string} [request.pageToken] - * Optional. If present, retrieves the next batch of results from the - * preceding call to this method. `page_token` must be the value of - * `next_page_token` from the previous response. The values of other method - * parameters must be identical to those in the previous call. - * @param {string} [request.filter] - * Optional. Filter expression to restrict the insights returned. Supported - * filter fields: - * - * * `stateInfo.state` - * - * * `insightSubtype` - * - * * `severity` - * - * Examples: - * - * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - * - * * `insightSubtype = PERMISSIONS_USAGE` - * - * * `severity = CRITICAL OR severity = HIGH` - * - * * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` - * - * (These expressions are based on the filter language described at - * https://google.aip.dev/160) - * @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 protos.google.cloud.recommender.v1.Insight|Insight} 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 `listInsightsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listInsightsStream( - request?: protos.google.cloud.recommender.v1.IListInsightsRequest, - 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['listInsights']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInsights.createStream( - this.innerApiCalls.listInsights as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listInsights`, 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 container resource on which to execute the request. - * Acceptable formats: - * - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * LOCATION here refers to GCP Locations: - * https://cloud.google.com/about/locations/ - * INSIGHT_TYPE_ID refers to supported insight types: - * https://cloud.google.com/recommender/docs/insights/insight-types. - * @param {number} [request.pageSize] - * Optional. The maximum number of results to return from this request. - * Non-positive values are ignored. If not specified, the server will - * determine the number of results to return. - * @param {string} [request.pageToken] - * Optional. If present, retrieves the next batch of results from the - * preceding call to this method. `page_token` must be the value of - * `next_page_token` from the previous response. The values of other method - * parameters must be identical to those in the previous call. - * @param {string} [request.filter] - * Optional. Filter expression to restrict the insights returned. Supported - * filter fields: - * - * * `stateInfo.state` - * - * * `insightSubtype` - * - * * `severity` - * - * Examples: - * - * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - * - * * `insightSubtype = PERMISSIONS_USAGE` - * - * * `severity = CRITICAL OR severity = HIGH` - * - * * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` - * - * (These expressions are based on the filter language described at - * https://google.aip.dev/160) - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.recommender.v1.Insight|Insight}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recommender.list_insights.js - * region_tag:recommender_v1_generated_Recommender_ListInsights_async - */ - listInsightsAsync( - request?: protos.google.cloud.recommender.v1.IListInsightsRequest, - 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['listInsights']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInsights.asyncIterate( - this.innerApiCalls['listInsights'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists recommendations for the specified Cloud Resource. Requires the - * recommender.*.list IAM permission for the specified recommender. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The container resource on which to execute the request. - * Acceptable formats: - * - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * LOCATION here refers to GCP Locations: - * https://cloud.google.com/about/locations/ - * RECOMMENDER_ID refers to supported recommenders: - * https://cloud.google.com/recommender/docs/recommenders. - * @param {number} [request.pageSize] - * Optional. The maximum number of results to return from this request. - * Non-positive values are ignored. If not specified, the server will - * determine the number of results to return. - * @param {string} [request.pageToken] - * Optional. If present, retrieves the next batch of results from the - * preceding call to this method. `page_token` must be the value of - * `next_page_token` from the previous response. The values of other method - * parameters must be identical to those in the previous call. - * @param {string} request.filter - * Filter expression to restrict the recommendations returned. Supported - * filter fields: - * - * * `state_info.state` - * - * * `recommenderSubtype` - * - * * `priority` - * - * Examples: - * - * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - * - * * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` - * - * * `priority = P1 OR priority = P2` - * - * * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` - * - * (These expressions are based on the filter language described at - * https://google.aip.dev/160) - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.recommender.v1.Recommendation|Recommendation}. - * 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 `listRecommendationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listRecommendations( - request?: protos.google.cloud.recommender.v1.IListRecommendationsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1.IRecommendation[], - protos.google.cloud.recommender.v1.IListRecommendationsRequest|null, - protos.google.cloud.recommender.v1.IListRecommendationsResponse - ]>; - listRecommendations( - request: protos.google.cloud.recommender.v1.IListRecommendationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.recommender.v1.IListRecommendationsRequest, - protos.google.cloud.recommender.v1.IListRecommendationsResponse|null|undefined, - protos.google.cloud.recommender.v1.IRecommendation>): void; - listRecommendations( - request: protos.google.cloud.recommender.v1.IListRecommendationsRequest, - callback: PaginationCallback< - protos.google.cloud.recommender.v1.IListRecommendationsRequest, - protos.google.cloud.recommender.v1.IListRecommendationsResponse|null|undefined, - protos.google.cloud.recommender.v1.IRecommendation>): void; - listRecommendations( - request?: protos.google.cloud.recommender.v1.IListRecommendationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.recommender.v1.IListRecommendationsRequest, - protos.google.cloud.recommender.v1.IListRecommendationsResponse|null|undefined, - protos.google.cloud.recommender.v1.IRecommendation>, - callback?: PaginationCallback< - protos.google.cloud.recommender.v1.IListRecommendationsRequest, - protos.google.cloud.recommender.v1.IListRecommendationsResponse|null|undefined, - protos.google.cloud.recommender.v1.IRecommendation>): - Promise<[ - protos.google.cloud.recommender.v1.IRecommendation[], - protos.google.cloud.recommender.v1.IListRecommendationsRequest|null, - protos.google.cloud.recommender.v1.IListRecommendationsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listRecommendations(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 container resource on which to execute the request. - * Acceptable formats: - * - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * LOCATION here refers to GCP Locations: - * https://cloud.google.com/about/locations/ - * RECOMMENDER_ID refers to supported recommenders: - * https://cloud.google.com/recommender/docs/recommenders. - * @param {number} [request.pageSize] - * Optional. The maximum number of results to return from this request. - * Non-positive values are ignored. If not specified, the server will - * determine the number of results to return. - * @param {string} [request.pageToken] - * Optional. If present, retrieves the next batch of results from the - * preceding call to this method. `page_token` must be the value of - * `next_page_token` from the previous response. The values of other method - * parameters must be identical to those in the previous call. - * @param {string} request.filter - * Filter expression to restrict the recommendations returned. Supported - * filter fields: - * - * * `state_info.state` - * - * * `recommenderSubtype` - * - * * `priority` - * - * Examples: - * - * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - * - * * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` - * - * * `priority = P1 OR priority = P2` - * - * * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` - * - * (These expressions are based on the filter language described at - * https://google.aip.dev/160) - * @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 protos.google.cloud.recommender.v1.Recommendation|Recommendation} 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 `listRecommendationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listRecommendationsStream( - request?: protos.google.cloud.recommender.v1.IListRecommendationsRequest, - 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['listRecommendations']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRecommendations.createStream( - this.innerApiCalls.listRecommendations as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listRecommendations`, 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 container resource on which to execute the request. - * Acceptable formats: - * - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * LOCATION here refers to GCP Locations: - * https://cloud.google.com/about/locations/ - * RECOMMENDER_ID refers to supported recommenders: - * https://cloud.google.com/recommender/docs/recommenders. - * @param {number} [request.pageSize] - * Optional. The maximum number of results to return from this request. - * Non-positive values are ignored. If not specified, the server will - * determine the number of results to return. - * @param {string} [request.pageToken] - * Optional. If present, retrieves the next batch of results from the - * preceding call to this method. `page_token` must be the value of - * `next_page_token` from the previous response. The values of other method - * parameters must be identical to those in the previous call. - * @param {string} request.filter - * Filter expression to restrict the recommendations returned. Supported - * filter fields: - * - * * `state_info.state` - * - * * `recommenderSubtype` - * - * * `priority` - * - * Examples: - * - * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - * - * * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` - * - * * `priority = P1 OR priority = P2` - * - * * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` - * - * (These expressions are based on the filter language described at - * https://google.aip.dev/160) - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.recommender.v1.Recommendation|Recommendation}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/recommender.list_recommendations.js - * region_tag:recommender_v1_generated_Recommender_ListRecommendations_async - */ - listRecommendationsAsync( - request?: protos.google.cloud.recommender.v1.IListRecommendationsRequest, - 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['listRecommendations']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRecommendations.asyncIterate( - this.innerApiCalls['listRecommendations'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified billingAccountLocationInsightType resource name string. - * - * @param {string} billing_account - * @param {string} location - * @param {string} insight_type - * @returns {string} Resource name string. - */ - billingAccountLocationInsightTypePath(billingAccount:string,location:string,insightType:string) { - return this.pathTemplates.billingAccountLocationInsightTypePathTemplate.render({ - billing_account: billingAccount, - location: location, - insight_type: insightType, - }); - } - - /** - * Parse the billing_account from BillingAccountLocationInsightType resource. - * - * @param {string} billingAccountLocationInsightTypeName - * A fully-qualified path representing billing_account_location_insight_type resource. - * @returns {string} A string representing the billing_account. - */ - matchBillingAccountFromBillingAccountLocationInsightTypeName(billingAccountLocationInsightTypeName: string) { - return this.pathTemplates.billingAccountLocationInsightTypePathTemplate.match(billingAccountLocationInsightTypeName).billing_account; - } - - /** - * Parse the location from BillingAccountLocationInsightType resource. - * - * @param {string} billingAccountLocationInsightTypeName - * A fully-qualified path representing billing_account_location_insight_type resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBillingAccountLocationInsightTypeName(billingAccountLocationInsightTypeName: string) { - return this.pathTemplates.billingAccountLocationInsightTypePathTemplate.match(billingAccountLocationInsightTypeName).location; - } - - /** - * Parse the insight_type from BillingAccountLocationInsightType resource. - * - * @param {string} billingAccountLocationInsightTypeName - * A fully-qualified path representing billing_account_location_insight_type resource. - * @returns {string} A string representing the insight_type. - */ - matchInsightTypeFromBillingAccountLocationInsightTypeName(billingAccountLocationInsightTypeName: string) { - return this.pathTemplates.billingAccountLocationInsightTypePathTemplate.match(billingAccountLocationInsightTypeName).insight_type; - } - - /** - * Return a fully-qualified billingAccountLocationInsightTypeInsight resource name string. - * - * @param {string} billing_account - * @param {string} location - * @param {string} insight_type - * @param {string} insight - * @returns {string} Resource name string. - */ - billingAccountLocationInsightTypeInsightPath(billingAccount:string,location:string,insightType:string,insight:string) { - return this.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.render({ - billing_account: billingAccount, - location: location, - insight_type: insightType, - insight: insight, - }); - } - - /** - * Parse the billing_account from BillingAccountLocationInsightTypeInsight resource. - * - * @param {string} billingAccountLocationInsightTypeInsightName - * A fully-qualified path representing billing_account_location_insight_type_insight resource. - * @returns {string} A string representing the billing_account. - */ - matchBillingAccountFromBillingAccountLocationInsightTypeInsightName(billingAccountLocationInsightTypeInsightName: string) { - return this.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match(billingAccountLocationInsightTypeInsightName).billing_account; - } - - /** - * Parse the location from BillingAccountLocationInsightTypeInsight resource. - * - * @param {string} billingAccountLocationInsightTypeInsightName - * A fully-qualified path representing billing_account_location_insight_type_insight resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBillingAccountLocationInsightTypeInsightName(billingAccountLocationInsightTypeInsightName: string) { - return this.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match(billingAccountLocationInsightTypeInsightName).location; - } - - /** - * Parse the insight_type from BillingAccountLocationInsightTypeInsight resource. - * - * @param {string} billingAccountLocationInsightTypeInsightName - * A fully-qualified path representing billing_account_location_insight_type_insight resource. - * @returns {string} A string representing the insight_type. - */ - matchInsightTypeFromBillingAccountLocationInsightTypeInsightName(billingAccountLocationInsightTypeInsightName: string) { - return this.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match(billingAccountLocationInsightTypeInsightName).insight_type; - } - - /** - * Parse the insight from BillingAccountLocationInsightTypeInsight resource. - * - * @param {string} billingAccountLocationInsightTypeInsightName - * A fully-qualified path representing billing_account_location_insight_type_insight resource. - * @returns {string} A string representing the insight. - */ - matchInsightFromBillingAccountLocationInsightTypeInsightName(billingAccountLocationInsightTypeInsightName: string) { - return this.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match(billingAccountLocationInsightTypeInsightName).insight; - } - - /** - * Return a fully-qualified billingAccountLocationRecommender resource name string. - * - * @param {string} billing_account - * @param {string} location - * @param {string} recommender - * @returns {string} Resource name string. - */ - billingAccountLocationRecommenderPath(billingAccount:string,location:string,recommender:string) { - return this.pathTemplates.billingAccountLocationRecommenderPathTemplate.render({ - billing_account: billingAccount, - location: location, - recommender: recommender, - }); - } - - /** - * Parse the billing_account from BillingAccountLocationRecommender resource. - * - * @param {string} billingAccountLocationRecommenderName - * A fully-qualified path representing billing_account_location_recommender resource. - * @returns {string} A string representing the billing_account. - */ - matchBillingAccountFromBillingAccountLocationRecommenderName(billingAccountLocationRecommenderName: string) { - return this.pathTemplates.billingAccountLocationRecommenderPathTemplate.match(billingAccountLocationRecommenderName).billing_account; - } - - /** - * Parse the location from BillingAccountLocationRecommender resource. - * - * @param {string} billingAccountLocationRecommenderName - * A fully-qualified path representing billing_account_location_recommender resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBillingAccountLocationRecommenderName(billingAccountLocationRecommenderName: string) { - return this.pathTemplates.billingAccountLocationRecommenderPathTemplate.match(billingAccountLocationRecommenderName).location; - } - - /** - * Parse the recommender from BillingAccountLocationRecommender resource. - * - * @param {string} billingAccountLocationRecommenderName - * A fully-qualified path representing billing_account_location_recommender resource. - * @returns {string} A string representing the recommender. - */ - matchRecommenderFromBillingAccountLocationRecommenderName(billingAccountLocationRecommenderName: string) { - return this.pathTemplates.billingAccountLocationRecommenderPathTemplate.match(billingAccountLocationRecommenderName).recommender; - } - - /** - * Return a fully-qualified billingAccountLocationRecommenderRecommendation resource name string. - * - * @param {string} billing_account - * @param {string} location - * @param {string} recommender - * @param {string} recommendation - * @returns {string} Resource name string. - */ - billingAccountLocationRecommenderRecommendationPath(billingAccount:string,location:string,recommender:string,recommendation:string) { - return this.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.render({ - billing_account: billingAccount, - location: location, - recommender: recommender, - recommendation: recommendation, - }); - } - - /** - * Parse the billing_account from BillingAccountLocationRecommenderRecommendation resource. - * - * @param {string} billingAccountLocationRecommenderRecommendationName - * A fully-qualified path representing billing_account_location_recommender_recommendation resource. - * @returns {string} A string representing the billing_account. - */ - matchBillingAccountFromBillingAccountLocationRecommenderRecommendationName(billingAccountLocationRecommenderRecommendationName: string) { - return this.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match(billingAccountLocationRecommenderRecommendationName).billing_account; - } - - /** - * Parse the location from BillingAccountLocationRecommenderRecommendation resource. - * - * @param {string} billingAccountLocationRecommenderRecommendationName - * A fully-qualified path representing billing_account_location_recommender_recommendation resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBillingAccountLocationRecommenderRecommendationName(billingAccountLocationRecommenderRecommendationName: string) { - return this.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match(billingAccountLocationRecommenderRecommendationName).location; - } - - /** - * Parse the recommender from BillingAccountLocationRecommenderRecommendation resource. - * - * @param {string} billingAccountLocationRecommenderRecommendationName - * A fully-qualified path representing billing_account_location_recommender_recommendation resource. - * @returns {string} A string representing the recommender. - */ - matchRecommenderFromBillingAccountLocationRecommenderRecommendationName(billingAccountLocationRecommenderRecommendationName: string) { - return this.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match(billingAccountLocationRecommenderRecommendationName).recommender; - } - - /** - * Parse the recommendation from BillingAccountLocationRecommenderRecommendation resource. - * - * @param {string} billingAccountLocationRecommenderRecommendationName - * A fully-qualified path representing billing_account_location_recommender_recommendation resource. - * @returns {string} A string representing the recommendation. - */ - matchRecommendationFromBillingAccountLocationRecommenderRecommendationName(billingAccountLocationRecommenderRecommendationName: string) { - return this.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match(billingAccountLocationRecommenderRecommendationName).recommendation; - } - - /** - * Return a fully-qualified folderLocationInsightType resource name string. - * - * @param {string} folder - * @param {string} location - * @param {string} insight_type - * @returns {string} Resource name string. - */ - folderLocationInsightTypePath(folder:string,location:string,insightType:string) { - return this.pathTemplates.folderLocationInsightTypePathTemplate.render({ - folder: folder, - location: location, - insight_type: insightType, - }); - } - - /** - * Parse the folder from FolderLocationInsightType resource. - * - * @param {string} folderLocationInsightTypeName - * A fully-qualified path representing folder_location_insight_type resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderLocationInsightTypeName(folderLocationInsightTypeName: string) { - return this.pathTemplates.folderLocationInsightTypePathTemplate.match(folderLocationInsightTypeName).folder; - } - - /** - * Parse the location from FolderLocationInsightType resource. - * - * @param {string} folderLocationInsightTypeName - * A fully-qualified path representing folder_location_insight_type resource. - * @returns {string} A string representing the location. - */ - matchLocationFromFolderLocationInsightTypeName(folderLocationInsightTypeName: string) { - return this.pathTemplates.folderLocationInsightTypePathTemplate.match(folderLocationInsightTypeName).location; - } - - /** - * Parse the insight_type from FolderLocationInsightType resource. - * - * @param {string} folderLocationInsightTypeName - * A fully-qualified path representing folder_location_insight_type resource. - * @returns {string} A string representing the insight_type. - */ - matchInsightTypeFromFolderLocationInsightTypeName(folderLocationInsightTypeName: string) { - return this.pathTemplates.folderLocationInsightTypePathTemplate.match(folderLocationInsightTypeName).insight_type; - } - - /** - * Return a fully-qualified folderLocationInsightTypeInsight resource name string. - * - * @param {string} folder - * @param {string} location - * @param {string} insight_type - * @param {string} insight - * @returns {string} Resource name string. - */ - folderLocationInsightTypeInsightPath(folder:string,location:string,insightType:string,insight:string) { - return this.pathTemplates.folderLocationInsightTypeInsightPathTemplate.render({ - folder: folder, - location: location, - insight_type: insightType, - insight: insight, - }); - } - - /** - * Parse the folder from FolderLocationInsightTypeInsight resource. - * - * @param {string} folderLocationInsightTypeInsightName - * A fully-qualified path representing folder_location_insight_type_insight resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderLocationInsightTypeInsightName(folderLocationInsightTypeInsightName: string) { - return this.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match(folderLocationInsightTypeInsightName).folder; - } - - /** - * Parse the location from FolderLocationInsightTypeInsight resource. - * - * @param {string} folderLocationInsightTypeInsightName - * A fully-qualified path representing folder_location_insight_type_insight resource. - * @returns {string} A string representing the location. - */ - matchLocationFromFolderLocationInsightTypeInsightName(folderLocationInsightTypeInsightName: string) { - return this.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match(folderLocationInsightTypeInsightName).location; - } - - /** - * Parse the insight_type from FolderLocationInsightTypeInsight resource. - * - * @param {string} folderLocationInsightTypeInsightName - * A fully-qualified path representing folder_location_insight_type_insight resource. - * @returns {string} A string representing the insight_type. - */ - matchInsightTypeFromFolderLocationInsightTypeInsightName(folderLocationInsightTypeInsightName: string) { - return this.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match(folderLocationInsightTypeInsightName).insight_type; - } - - /** - * Parse the insight from FolderLocationInsightTypeInsight resource. - * - * @param {string} folderLocationInsightTypeInsightName - * A fully-qualified path representing folder_location_insight_type_insight resource. - * @returns {string} A string representing the insight. - */ - matchInsightFromFolderLocationInsightTypeInsightName(folderLocationInsightTypeInsightName: string) { - return this.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match(folderLocationInsightTypeInsightName).insight; - } - - /** - * Return a fully-qualified folderLocationRecommender resource name string. - * - * @param {string} folder - * @param {string} location - * @param {string} recommender - * @returns {string} Resource name string. - */ - folderLocationRecommenderPath(folder:string,location:string,recommender:string) { - return this.pathTemplates.folderLocationRecommenderPathTemplate.render({ - folder: folder, - location: location, - recommender: recommender, - }); - } - - /** - * Parse the folder from FolderLocationRecommender resource. - * - * @param {string} folderLocationRecommenderName - * A fully-qualified path representing folder_location_recommender resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderLocationRecommenderName(folderLocationRecommenderName: string) { - return this.pathTemplates.folderLocationRecommenderPathTemplate.match(folderLocationRecommenderName).folder; - } - - /** - * Parse the location from FolderLocationRecommender resource. - * - * @param {string} folderLocationRecommenderName - * A fully-qualified path representing folder_location_recommender resource. - * @returns {string} A string representing the location. - */ - matchLocationFromFolderLocationRecommenderName(folderLocationRecommenderName: string) { - return this.pathTemplates.folderLocationRecommenderPathTemplate.match(folderLocationRecommenderName).location; - } - - /** - * Parse the recommender from FolderLocationRecommender resource. - * - * @param {string} folderLocationRecommenderName - * A fully-qualified path representing folder_location_recommender resource. - * @returns {string} A string representing the recommender. - */ - matchRecommenderFromFolderLocationRecommenderName(folderLocationRecommenderName: string) { - return this.pathTemplates.folderLocationRecommenderPathTemplate.match(folderLocationRecommenderName).recommender; - } - - /** - * Return a fully-qualified folderLocationRecommenderRecommendation resource name string. - * - * @param {string} folder - * @param {string} location - * @param {string} recommender - * @param {string} recommendation - * @returns {string} Resource name string. - */ - folderLocationRecommenderRecommendationPath(folder:string,location:string,recommender:string,recommendation:string) { - return this.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.render({ - folder: folder, - location: location, - recommender: recommender, - recommendation: recommendation, - }); - } - - /** - * Parse the folder from FolderLocationRecommenderRecommendation resource. - * - * @param {string} folderLocationRecommenderRecommendationName - * A fully-qualified path representing folder_location_recommender_recommendation resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderLocationRecommenderRecommendationName(folderLocationRecommenderRecommendationName: string) { - return this.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match(folderLocationRecommenderRecommendationName).folder; - } - - /** - * Parse the location from FolderLocationRecommenderRecommendation resource. - * - * @param {string} folderLocationRecommenderRecommendationName - * A fully-qualified path representing folder_location_recommender_recommendation resource. - * @returns {string} A string representing the location. - */ - matchLocationFromFolderLocationRecommenderRecommendationName(folderLocationRecommenderRecommendationName: string) { - return this.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match(folderLocationRecommenderRecommendationName).location; - } - - /** - * Parse the recommender from FolderLocationRecommenderRecommendation resource. - * - * @param {string} folderLocationRecommenderRecommendationName - * A fully-qualified path representing folder_location_recommender_recommendation resource. - * @returns {string} A string representing the recommender. - */ - matchRecommenderFromFolderLocationRecommenderRecommendationName(folderLocationRecommenderRecommendationName: string) { - return this.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match(folderLocationRecommenderRecommendationName).recommender; - } - - /** - * Parse the recommendation from FolderLocationRecommenderRecommendation resource. - * - * @param {string} folderLocationRecommenderRecommendationName - * A fully-qualified path representing folder_location_recommender_recommendation resource. - * @returns {string} A string representing the recommendation. - */ - matchRecommendationFromFolderLocationRecommenderRecommendationName(folderLocationRecommenderRecommendationName: string) { - return this.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match(folderLocationRecommenderRecommendationName).recommendation; - } - - /** - * Return a fully-qualified organizationLocationInsightType resource name string. - * - * @param {string} organization - * @param {string} location - * @param {string} insight_type - * @returns {string} Resource name string. - */ - organizationLocationInsightTypePath(organization:string,location:string,insightType:string) { - return this.pathTemplates.organizationLocationInsightTypePathTemplate.render({ - organization: organization, - location: location, - insight_type: insightType, - }); - } - - /** - * Parse the organization from OrganizationLocationInsightType resource. - * - * @param {string} organizationLocationInsightTypeName - * A fully-qualified path representing organization_location_insight_type resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationLocationInsightTypeName(organizationLocationInsightTypeName: string) { - return this.pathTemplates.organizationLocationInsightTypePathTemplate.match(organizationLocationInsightTypeName).organization; - } - - /** - * Parse the location from OrganizationLocationInsightType resource. - * - * @param {string} organizationLocationInsightTypeName - * A fully-qualified path representing organization_location_insight_type resource. - * @returns {string} A string representing the location. - */ - matchLocationFromOrganizationLocationInsightTypeName(organizationLocationInsightTypeName: string) { - return this.pathTemplates.organizationLocationInsightTypePathTemplate.match(organizationLocationInsightTypeName).location; - } - - /** - * Parse the insight_type from OrganizationLocationInsightType resource. - * - * @param {string} organizationLocationInsightTypeName - * A fully-qualified path representing organization_location_insight_type resource. - * @returns {string} A string representing the insight_type. - */ - matchInsightTypeFromOrganizationLocationInsightTypeName(organizationLocationInsightTypeName: string) { - return this.pathTemplates.organizationLocationInsightTypePathTemplate.match(organizationLocationInsightTypeName).insight_type; - } - - /** - * Return a fully-qualified organizationLocationInsightTypeConfig resource name string. - * - * @param {string} organization - * @param {string} location - * @param {string} insight_type - * @returns {string} Resource name string. - */ - organizationLocationInsightTypeConfigPath(organization:string,location:string,insightType:string) { - return this.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.render({ - organization: organization, - location: location, - insight_type: insightType, - }); - } - - /** - * Parse the organization from OrganizationLocationInsightTypeConfig resource. - * - * @param {string} organizationLocationInsightTypeConfigName - * A fully-qualified path representing organization_location_insight_type_config resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationLocationInsightTypeConfigName(organizationLocationInsightTypeConfigName: string) { - return this.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match(organizationLocationInsightTypeConfigName).organization; - } - - /** - * Parse the location from OrganizationLocationInsightTypeConfig resource. - * - * @param {string} organizationLocationInsightTypeConfigName - * A fully-qualified path representing organization_location_insight_type_config resource. - * @returns {string} A string representing the location. - */ - matchLocationFromOrganizationLocationInsightTypeConfigName(organizationLocationInsightTypeConfigName: string) { - return this.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match(organizationLocationInsightTypeConfigName).location; - } - - /** - * Parse the insight_type from OrganizationLocationInsightTypeConfig resource. - * - * @param {string} organizationLocationInsightTypeConfigName - * A fully-qualified path representing organization_location_insight_type_config resource. - * @returns {string} A string representing the insight_type. - */ - matchInsightTypeFromOrganizationLocationInsightTypeConfigName(organizationLocationInsightTypeConfigName: string) { - return this.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match(organizationLocationInsightTypeConfigName).insight_type; - } - - /** - * Return a fully-qualified organizationLocationInsightTypeInsight resource name string. - * - * @param {string} organization - * @param {string} location - * @param {string} insight_type - * @param {string} insight - * @returns {string} Resource name string. - */ - organizationLocationInsightTypeInsightPath(organization:string,location:string,insightType:string,insight:string) { - return this.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.render({ - organization: organization, - location: location, - insight_type: insightType, - insight: insight, - }); - } - - /** - * Parse the organization from OrganizationLocationInsightTypeInsight resource. - * - * @param {string} organizationLocationInsightTypeInsightName - * A fully-qualified path representing organization_location_insight_type_insight resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationLocationInsightTypeInsightName(organizationLocationInsightTypeInsightName: string) { - return this.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match(organizationLocationInsightTypeInsightName).organization; - } - - /** - * Parse the location from OrganizationLocationInsightTypeInsight resource. - * - * @param {string} organizationLocationInsightTypeInsightName - * A fully-qualified path representing organization_location_insight_type_insight resource. - * @returns {string} A string representing the location. - */ - matchLocationFromOrganizationLocationInsightTypeInsightName(organizationLocationInsightTypeInsightName: string) { - return this.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match(organizationLocationInsightTypeInsightName).location; - } - - /** - * Parse the insight_type from OrganizationLocationInsightTypeInsight resource. - * - * @param {string} organizationLocationInsightTypeInsightName - * A fully-qualified path representing organization_location_insight_type_insight resource. - * @returns {string} A string representing the insight_type. - */ - matchInsightTypeFromOrganizationLocationInsightTypeInsightName(organizationLocationInsightTypeInsightName: string) { - return this.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match(organizationLocationInsightTypeInsightName).insight_type; - } - - /** - * Parse the insight from OrganizationLocationInsightTypeInsight resource. - * - * @param {string} organizationLocationInsightTypeInsightName - * A fully-qualified path representing organization_location_insight_type_insight resource. - * @returns {string} A string representing the insight. - */ - matchInsightFromOrganizationLocationInsightTypeInsightName(organizationLocationInsightTypeInsightName: string) { - return this.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match(organizationLocationInsightTypeInsightName).insight; - } - - /** - * Return a fully-qualified organizationLocationRecommender resource name string. - * - * @param {string} organization - * @param {string} location - * @param {string} recommender - * @returns {string} Resource name string. - */ - organizationLocationRecommenderPath(organization:string,location:string,recommender:string) { - return this.pathTemplates.organizationLocationRecommenderPathTemplate.render({ - organization: organization, - location: location, - recommender: recommender, - }); - } - - /** - * Parse the organization from OrganizationLocationRecommender resource. - * - * @param {string} organizationLocationRecommenderName - * A fully-qualified path representing organization_location_recommender resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationLocationRecommenderName(organizationLocationRecommenderName: string) { - return this.pathTemplates.organizationLocationRecommenderPathTemplate.match(organizationLocationRecommenderName).organization; - } - - /** - * Parse the location from OrganizationLocationRecommender resource. - * - * @param {string} organizationLocationRecommenderName - * A fully-qualified path representing organization_location_recommender resource. - * @returns {string} A string representing the location. - */ - matchLocationFromOrganizationLocationRecommenderName(organizationLocationRecommenderName: string) { - return this.pathTemplates.organizationLocationRecommenderPathTemplate.match(organizationLocationRecommenderName).location; - } - - /** - * Parse the recommender from OrganizationLocationRecommender resource. - * - * @param {string} organizationLocationRecommenderName - * A fully-qualified path representing organization_location_recommender resource. - * @returns {string} A string representing the recommender. - */ - matchRecommenderFromOrganizationLocationRecommenderName(organizationLocationRecommenderName: string) { - return this.pathTemplates.organizationLocationRecommenderPathTemplate.match(organizationLocationRecommenderName).recommender; - } - - /** - * Return a fully-qualified organizationLocationRecommenderConfig resource name string. - * - * @param {string} organization - * @param {string} location - * @param {string} recommender - * @returns {string} Resource name string. - */ - organizationLocationRecommenderConfigPath(organization:string,location:string,recommender:string) { - return this.pathTemplates.organizationLocationRecommenderConfigPathTemplate.render({ - organization: organization, - location: location, - recommender: recommender, - }); - } - - /** - * Parse the organization from OrganizationLocationRecommenderConfig resource. - * - * @param {string} organizationLocationRecommenderConfigName - * A fully-qualified path representing organization_location_recommender_config resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationLocationRecommenderConfigName(organizationLocationRecommenderConfigName: string) { - return this.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match(organizationLocationRecommenderConfigName).organization; - } - - /** - * Parse the location from OrganizationLocationRecommenderConfig resource. - * - * @param {string} organizationLocationRecommenderConfigName - * A fully-qualified path representing organization_location_recommender_config resource. - * @returns {string} A string representing the location. - */ - matchLocationFromOrganizationLocationRecommenderConfigName(organizationLocationRecommenderConfigName: string) { - return this.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match(organizationLocationRecommenderConfigName).location; - } - - /** - * Parse the recommender from OrganizationLocationRecommenderConfig resource. - * - * @param {string} organizationLocationRecommenderConfigName - * A fully-qualified path representing organization_location_recommender_config resource. - * @returns {string} A string representing the recommender. - */ - matchRecommenderFromOrganizationLocationRecommenderConfigName(organizationLocationRecommenderConfigName: string) { - return this.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match(organizationLocationRecommenderConfigName).recommender; - } - - /** - * Return a fully-qualified organizationLocationRecommenderRecommendation resource name string. - * - * @param {string} organization - * @param {string} location - * @param {string} recommender - * @param {string} recommendation - * @returns {string} Resource name string. - */ - organizationLocationRecommenderRecommendationPath(organization:string,location:string,recommender:string,recommendation:string) { - return this.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.render({ - organization: organization, - location: location, - recommender: recommender, - recommendation: recommendation, - }); - } - - /** - * Parse the organization from OrganizationLocationRecommenderRecommendation resource. - * - * @param {string} organizationLocationRecommenderRecommendationName - * A fully-qualified path representing organization_location_recommender_recommendation resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationLocationRecommenderRecommendationName(organizationLocationRecommenderRecommendationName: string) { - return this.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match(organizationLocationRecommenderRecommendationName).organization; - } - - /** - * Parse the location from OrganizationLocationRecommenderRecommendation resource. - * - * @param {string} organizationLocationRecommenderRecommendationName - * A fully-qualified path representing organization_location_recommender_recommendation resource. - * @returns {string} A string representing the location. - */ - matchLocationFromOrganizationLocationRecommenderRecommendationName(organizationLocationRecommenderRecommendationName: string) { - return this.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match(organizationLocationRecommenderRecommendationName).location; - } - - /** - * Parse the recommender from OrganizationLocationRecommenderRecommendation resource. - * - * @param {string} organizationLocationRecommenderRecommendationName - * A fully-qualified path representing organization_location_recommender_recommendation resource. - * @returns {string} A string representing the recommender. - */ - matchRecommenderFromOrganizationLocationRecommenderRecommendationName(organizationLocationRecommenderRecommendationName: string) { - return this.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match(organizationLocationRecommenderRecommendationName).recommender; - } - - /** - * Parse the recommendation from OrganizationLocationRecommenderRecommendation resource. - * - * @param {string} organizationLocationRecommenderRecommendationName - * A fully-qualified path representing organization_location_recommender_recommendation resource. - * @returns {string} A string representing the recommendation. - */ - matchRecommendationFromOrganizationLocationRecommenderRecommendationName(organizationLocationRecommenderRecommendationName: string) { - return this.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match(organizationLocationRecommenderRecommendationName).recommendation; - } - - /** - * Return a fully-qualified projectLocationInsightType resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} insight_type - * @returns {string} Resource name string. - */ - projectLocationInsightTypePath(project:string,location:string,insightType:string) { - return this.pathTemplates.projectLocationInsightTypePathTemplate.render({ - project: project, - location: location, - insight_type: insightType, - }); - } - - /** - * Parse the project from ProjectLocationInsightType resource. - * - * @param {string} projectLocationInsightTypeName - * A fully-qualified path representing project_location_insight_type resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationInsightTypeName(projectLocationInsightTypeName: string) { - return this.pathTemplates.projectLocationInsightTypePathTemplate.match(projectLocationInsightTypeName).project; - } - - /** - * Parse the location from ProjectLocationInsightType resource. - * - * @param {string} projectLocationInsightTypeName - * A fully-qualified path representing project_location_insight_type resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationInsightTypeName(projectLocationInsightTypeName: string) { - return this.pathTemplates.projectLocationInsightTypePathTemplate.match(projectLocationInsightTypeName).location; - } - - /** - * Parse the insight_type from ProjectLocationInsightType resource. - * - * @param {string} projectLocationInsightTypeName - * A fully-qualified path representing project_location_insight_type resource. - * @returns {string} A string representing the insight_type. - */ - matchInsightTypeFromProjectLocationInsightTypeName(projectLocationInsightTypeName: string) { - return this.pathTemplates.projectLocationInsightTypePathTemplate.match(projectLocationInsightTypeName).insight_type; - } - - /** - * Return a fully-qualified projectLocationInsightTypeConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} insight_type - * @returns {string} Resource name string. - */ - projectLocationInsightTypeConfigPath(project:string,location:string,insightType:string) { - return this.pathTemplates.projectLocationInsightTypeConfigPathTemplate.render({ - project: project, - location: location, - insight_type: insightType, - }); - } - - /** - * Parse the project from ProjectLocationInsightTypeConfig resource. - * - * @param {string} projectLocationInsightTypeConfigName - * A fully-qualified path representing project_location_insight_type_config resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationInsightTypeConfigName(projectLocationInsightTypeConfigName: string) { - return this.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match(projectLocationInsightTypeConfigName).project; - } - - /** - * Parse the location from ProjectLocationInsightTypeConfig resource. - * - * @param {string} projectLocationInsightTypeConfigName - * A fully-qualified path representing project_location_insight_type_config resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationInsightTypeConfigName(projectLocationInsightTypeConfigName: string) { - return this.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match(projectLocationInsightTypeConfigName).location; - } - - /** - * Parse the insight_type from ProjectLocationInsightTypeConfig resource. - * - * @param {string} projectLocationInsightTypeConfigName - * A fully-qualified path representing project_location_insight_type_config resource. - * @returns {string} A string representing the insight_type. - */ - matchInsightTypeFromProjectLocationInsightTypeConfigName(projectLocationInsightTypeConfigName: string) { - return this.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match(projectLocationInsightTypeConfigName).insight_type; - } - - /** - * Return a fully-qualified projectLocationInsightTypeInsight resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} insight_type - * @param {string} insight - * @returns {string} Resource name string. - */ - projectLocationInsightTypeInsightPath(project:string,location:string,insightType:string,insight:string) { - return this.pathTemplates.projectLocationInsightTypeInsightPathTemplate.render({ - project: project, - location: location, - insight_type: insightType, - insight: insight, - }); - } - - /** - * Parse the project from ProjectLocationInsightTypeInsight resource. - * - * @param {string} projectLocationInsightTypeInsightName - * A fully-qualified path representing project_location_insight_type_insight resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationInsightTypeInsightName(projectLocationInsightTypeInsightName: string) { - return this.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match(projectLocationInsightTypeInsightName).project; - } - - /** - * Parse the location from ProjectLocationInsightTypeInsight resource. - * - * @param {string} projectLocationInsightTypeInsightName - * A fully-qualified path representing project_location_insight_type_insight resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationInsightTypeInsightName(projectLocationInsightTypeInsightName: string) { - return this.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match(projectLocationInsightTypeInsightName).location; - } - - /** - * Parse the insight_type from ProjectLocationInsightTypeInsight resource. - * - * @param {string} projectLocationInsightTypeInsightName - * A fully-qualified path representing project_location_insight_type_insight resource. - * @returns {string} A string representing the insight_type. - */ - matchInsightTypeFromProjectLocationInsightTypeInsightName(projectLocationInsightTypeInsightName: string) { - return this.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match(projectLocationInsightTypeInsightName).insight_type; - } - - /** - * Parse the insight from ProjectLocationInsightTypeInsight resource. - * - * @param {string} projectLocationInsightTypeInsightName - * A fully-qualified path representing project_location_insight_type_insight resource. - * @returns {string} A string representing the insight. - */ - matchInsightFromProjectLocationInsightTypeInsightName(projectLocationInsightTypeInsightName: string) { - return this.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match(projectLocationInsightTypeInsightName).insight; - } - - /** - * Return a fully-qualified projectLocationRecommender resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} recommender - * @returns {string} Resource name string. - */ - projectLocationRecommenderPath(project:string,location:string,recommender:string) { - return this.pathTemplates.projectLocationRecommenderPathTemplate.render({ - project: project, - location: location, - recommender: recommender, - }); - } - - /** - * Parse the project from ProjectLocationRecommender resource. - * - * @param {string} projectLocationRecommenderName - * A fully-qualified path representing project_location_recommender resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationRecommenderName(projectLocationRecommenderName: string) { - return this.pathTemplates.projectLocationRecommenderPathTemplate.match(projectLocationRecommenderName).project; - } - - /** - * Parse the location from ProjectLocationRecommender resource. - * - * @param {string} projectLocationRecommenderName - * A fully-qualified path representing project_location_recommender resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationRecommenderName(projectLocationRecommenderName: string) { - return this.pathTemplates.projectLocationRecommenderPathTemplate.match(projectLocationRecommenderName).location; - } - - /** - * Parse the recommender from ProjectLocationRecommender resource. - * - * @param {string} projectLocationRecommenderName - * A fully-qualified path representing project_location_recommender resource. - * @returns {string} A string representing the recommender. - */ - matchRecommenderFromProjectLocationRecommenderName(projectLocationRecommenderName: string) { - return this.pathTemplates.projectLocationRecommenderPathTemplate.match(projectLocationRecommenderName).recommender; - } - - /** - * Return a fully-qualified projectLocationRecommenderConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} recommender - * @returns {string} Resource name string. - */ - projectLocationRecommenderConfigPath(project:string,location:string,recommender:string) { - return this.pathTemplates.projectLocationRecommenderConfigPathTemplate.render({ - project: project, - location: location, - recommender: recommender, - }); - } - - /** - * Parse the project from ProjectLocationRecommenderConfig resource. - * - * @param {string} projectLocationRecommenderConfigName - * A fully-qualified path representing project_location_recommender_config resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationRecommenderConfigName(projectLocationRecommenderConfigName: string) { - return this.pathTemplates.projectLocationRecommenderConfigPathTemplate.match(projectLocationRecommenderConfigName).project; - } - - /** - * Parse the location from ProjectLocationRecommenderConfig resource. - * - * @param {string} projectLocationRecommenderConfigName - * A fully-qualified path representing project_location_recommender_config resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationRecommenderConfigName(projectLocationRecommenderConfigName: string) { - return this.pathTemplates.projectLocationRecommenderConfigPathTemplate.match(projectLocationRecommenderConfigName).location; - } - - /** - * Parse the recommender from ProjectLocationRecommenderConfig resource. - * - * @param {string} projectLocationRecommenderConfigName - * A fully-qualified path representing project_location_recommender_config resource. - * @returns {string} A string representing the recommender. - */ - matchRecommenderFromProjectLocationRecommenderConfigName(projectLocationRecommenderConfigName: string) { - return this.pathTemplates.projectLocationRecommenderConfigPathTemplate.match(projectLocationRecommenderConfigName).recommender; - } - - /** - * Return a fully-qualified projectLocationRecommenderRecommendation resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} recommender - * @param {string} recommendation - * @returns {string} Resource name string. - */ - projectLocationRecommenderRecommendationPath(project:string,location:string,recommender:string,recommendation:string) { - return this.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.render({ - project: project, - location: location, - recommender: recommender, - recommendation: recommendation, - }); - } - - /** - * Parse the project from ProjectLocationRecommenderRecommendation resource. - * - * @param {string} projectLocationRecommenderRecommendationName - * A fully-qualified path representing project_location_recommender_recommendation resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationRecommenderRecommendationName(projectLocationRecommenderRecommendationName: string) { - return this.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match(projectLocationRecommenderRecommendationName).project; - } - - /** - * Parse the location from ProjectLocationRecommenderRecommendation resource. - * - * @param {string} projectLocationRecommenderRecommendationName - * A fully-qualified path representing project_location_recommender_recommendation resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationRecommenderRecommendationName(projectLocationRecommenderRecommendationName: string) { - return this.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match(projectLocationRecommenderRecommendationName).location; - } - - /** - * Parse the recommender from ProjectLocationRecommenderRecommendation resource. - * - * @param {string} projectLocationRecommenderRecommendationName - * A fully-qualified path representing project_location_recommender_recommendation resource. - * @returns {string} A string representing the recommender. - */ - matchRecommenderFromProjectLocationRecommenderRecommendationName(projectLocationRecommenderRecommendationName: string) { - return this.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match(projectLocationRecommenderRecommendationName).recommender; - } - - /** - * Parse the recommendation from ProjectLocationRecommenderRecommendation resource. - * - * @param {string} projectLocationRecommenderRecommendationName - * A fully-qualified path representing project_location_recommender_recommendation resource. - * @returns {string} A string representing the recommendation. - */ - matchRecommendationFromProjectLocationRecommenderRecommendationName(projectLocationRecommenderRecommendationName: string) { - return this.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match(projectLocationRecommenderRecommendationName).recommendation; - } - - /** - * 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.recommenderStub && !this._terminated) { - return this.recommenderStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_client_config.json b/owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_client_config.json deleted file mode 100644 index a8ffdbb5b6e..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_client_config.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "interfaces": { - "google.cloud.recommender.v1.Recommender": { - "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": { - "ListInsights": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetInsight": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "MarkInsightAccepted": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListRecommendations": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetRecommendation": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "MarkRecommendationClaimed": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "MarkRecommendationSucceeded": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "MarkRecommendationFailed": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetRecommenderConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateRecommenderConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetInsightTypeConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateInsightTypeConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_proto_list.json b/owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_proto_list.json deleted file mode 100644 index 016dc35c415..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/src/v1/recommender_proto_list.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - "../../protos/google/cloud/recommender/v1/insight.proto", - "../../protos/google/cloud/recommender/v1/insight_type_config.proto", - "../../protos/google/cloud/recommender/v1/recommendation.proto", - "../../protos/google/cloud/recommender/v1/recommender_config.proto", - "../../protos/google/cloud/recommender/v1/recommender_service.proto" -] diff --git a/owl-bot-staging/google-cloud-recommender/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-recommender/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 8db790db9d7..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const recommender = require('@google-cloud/recommender'); - -function main() { - const recommenderClient = new recommender.RecommenderClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-recommender/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-recommender/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 5142e8f3f3e..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {RecommenderClient} from '@google-cloud/recommender'; - -// check that the client class type name can be used -function doStuffWithRecommenderClient(client: RecommenderClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const recommenderClient = new RecommenderClient(); - doStuffWithRecommenderClient(recommenderClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-recommender/v1/system-test/install.ts b/owl-bot-staging/google-cloud-recommender/v1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/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-recommender/v1/test/gapic_recommender_v1.ts b/owl-bot-staging/google-cloud-recommender/v1/test/gapic_recommender_v1.ts deleted file mode 100644 index 244e152f69f..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/test/gapic_recommender_v1.ts +++ /dev/null @@ -1,2762 +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 recommenderModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.RecommenderClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = recommenderModule.v1.RecommenderClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = recommenderModule.v1.RecommenderClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = recommenderModule.v1.RecommenderClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new recommenderModule.v1.RecommenderClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new recommenderModule.v1.RecommenderClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.recommenderStub, undefined); - await client.initialize(); - assert(client.recommenderStub); - }); - - it('has close method for the initialized client', done => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.recommenderStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.recommenderStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new recommenderModule.v1.RecommenderClient({ - 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 recommenderModule.v1.RecommenderClient({ - 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('getInsight', () => { - it('invokes getInsight without error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.GetInsightRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.GetInsightRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1.Insight() - ); - client.innerApiCalls.getInsight = stubSimpleCall(expectedResponse); - const [response] = await client.getInsight(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInsight as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInsight as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInsight without error using callback', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.GetInsightRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.GetInsightRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1.Insight() - ); - client.innerApiCalls.getInsight = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInsight( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1.IInsight|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInsight as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInsight as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInsight with error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.GetInsightRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.GetInsightRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInsight = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInsight(request), expectedError); - const actualRequest = (client.innerApiCalls.getInsight as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInsight as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInsight with closed client', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.GetInsightRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.GetInsightRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getInsight(request), expectedError); - }); - }); - - describe('markInsightAccepted', () => { - it('invokes markInsightAccepted without error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.MarkInsightAcceptedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.MarkInsightAcceptedRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1.Insight() - ); - client.innerApiCalls.markInsightAccepted = stubSimpleCall(expectedResponse); - const [response] = await client.markInsightAccepted(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.markInsightAccepted as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markInsightAccepted as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markInsightAccepted without error using callback', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.MarkInsightAcceptedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.MarkInsightAcceptedRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1.Insight() - ); - client.innerApiCalls.markInsightAccepted = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.markInsightAccepted( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1.IInsight|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.markInsightAccepted as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markInsightAccepted as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markInsightAccepted with error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.MarkInsightAcceptedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.MarkInsightAcceptedRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.markInsightAccepted = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.markInsightAccepted(request), expectedError); - const actualRequest = (client.innerApiCalls.markInsightAccepted as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markInsightAccepted as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markInsightAccepted with closed client', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.MarkInsightAcceptedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.MarkInsightAcceptedRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.markInsightAccepted(request), expectedError); - }); - }); - - describe('getRecommendation', () => { - it('invokes getRecommendation without error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.GetRecommendationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.GetRecommendationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1.Recommendation() - ); - client.innerApiCalls.getRecommendation = stubSimpleCall(expectedResponse); - const [response] = await client.getRecommendation(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRecommendation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRecommendation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRecommendation without error using callback', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.GetRecommendationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.GetRecommendationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1.Recommendation() - ); - client.innerApiCalls.getRecommendation = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getRecommendation( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1.IRecommendation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRecommendation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRecommendation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRecommendation with error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.GetRecommendationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.GetRecommendationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getRecommendation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getRecommendation(request), expectedError); - const actualRequest = (client.innerApiCalls.getRecommendation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRecommendation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRecommendation with closed client', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.GetRecommendationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.GetRecommendationRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getRecommendation(request), expectedError); - }); - }); - - describe('markRecommendationClaimed', () => { - it('invokes markRecommendationClaimed without error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.MarkRecommendationClaimedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationClaimedRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1.Recommendation() - ); - client.innerApiCalls.markRecommendationClaimed = stubSimpleCall(expectedResponse); - const [response] = await client.markRecommendationClaimed(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.markRecommendationClaimed as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationClaimed as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markRecommendationClaimed without error using callback', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.MarkRecommendationClaimedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationClaimedRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1.Recommendation() - ); - client.innerApiCalls.markRecommendationClaimed = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.markRecommendationClaimed( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1.IRecommendation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.markRecommendationClaimed as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationClaimed as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markRecommendationClaimed with error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.MarkRecommendationClaimedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationClaimedRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.markRecommendationClaimed = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.markRecommendationClaimed(request), expectedError); - const actualRequest = (client.innerApiCalls.markRecommendationClaimed as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationClaimed as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markRecommendationClaimed with closed client', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.MarkRecommendationClaimedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationClaimedRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.markRecommendationClaimed(request), expectedError); - }); - }); - - describe('markRecommendationSucceeded', () => { - it('invokes markRecommendationSucceeded without error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.MarkRecommendationSucceededRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationSucceededRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1.Recommendation() - ); - client.innerApiCalls.markRecommendationSucceeded = stubSimpleCall(expectedResponse); - const [response] = await client.markRecommendationSucceeded(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markRecommendationSucceeded without error using callback', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.MarkRecommendationSucceededRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationSucceededRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1.Recommendation() - ); - client.innerApiCalls.markRecommendationSucceeded = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.markRecommendationSucceeded( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1.IRecommendation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markRecommendationSucceeded with error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.MarkRecommendationSucceededRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationSucceededRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.markRecommendationSucceeded = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.markRecommendationSucceeded(request), expectedError); - const actualRequest = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markRecommendationSucceeded with closed client', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.MarkRecommendationSucceededRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationSucceededRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.markRecommendationSucceeded(request), expectedError); - }); - }); - - describe('markRecommendationFailed', () => { - it('invokes markRecommendationFailed without error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.MarkRecommendationFailedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationFailedRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1.Recommendation() - ); - client.innerApiCalls.markRecommendationFailed = stubSimpleCall(expectedResponse); - const [response] = await client.markRecommendationFailed(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.markRecommendationFailed as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationFailed as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markRecommendationFailed without error using callback', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.MarkRecommendationFailedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationFailedRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1.Recommendation() - ); - client.innerApiCalls.markRecommendationFailed = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.markRecommendationFailed( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1.IRecommendation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.markRecommendationFailed as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationFailed as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markRecommendationFailed with error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.MarkRecommendationFailedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationFailedRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.markRecommendationFailed = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.markRecommendationFailed(request), expectedError); - const actualRequest = (client.innerApiCalls.markRecommendationFailed as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationFailed as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markRecommendationFailed with closed client', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.MarkRecommendationFailedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.MarkRecommendationFailedRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.markRecommendationFailed(request), expectedError); - }); - }); - - describe('getRecommenderConfig', () => { - it('invokes getRecommenderConfig without error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.GetRecommenderConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.GetRecommenderConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1.RecommenderConfig() - ); - client.innerApiCalls.getRecommenderConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getRecommenderConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRecommenderConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRecommenderConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRecommenderConfig without error using callback', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.GetRecommenderConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.GetRecommenderConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1.RecommenderConfig() - ); - client.innerApiCalls.getRecommenderConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getRecommenderConfig( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1.IRecommenderConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRecommenderConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRecommenderConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRecommenderConfig with error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.GetRecommenderConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.GetRecommenderConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getRecommenderConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getRecommenderConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getRecommenderConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRecommenderConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRecommenderConfig with closed client', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.GetRecommenderConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.GetRecommenderConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getRecommenderConfig(request), expectedError); - }); - }); - - describe('updateRecommenderConfig', () => { - it('invokes updateRecommenderConfig without error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.UpdateRecommenderConfigRequest() - ); - request.recommenderConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.UpdateRecommenderConfigRequest', ['recommenderConfig', 'name']); - request.recommenderConfig.name = defaultValue1; - const expectedHeaderRequestParams = `recommender_config.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1.RecommenderConfig() - ); - client.innerApiCalls.updateRecommenderConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateRecommenderConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateRecommenderConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateRecommenderConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateRecommenderConfig without error using callback', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.UpdateRecommenderConfigRequest() - ); - request.recommenderConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.UpdateRecommenderConfigRequest', ['recommenderConfig', 'name']); - request.recommenderConfig.name = defaultValue1; - const expectedHeaderRequestParams = `recommender_config.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1.RecommenderConfig() - ); - client.innerApiCalls.updateRecommenderConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateRecommenderConfig( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1.IRecommenderConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateRecommenderConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateRecommenderConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateRecommenderConfig with error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.UpdateRecommenderConfigRequest() - ); - request.recommenderConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.UpdateRecommenderConfigRequest', ['recommenderConfig', 'name']); - request.recommenderConfig.name = defaultValue1; - const expectedHeaderRequestParams = `recommender_config.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateRecommenderConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateRecommenderConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateRecommenderConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateRecommenderConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateRecommenderConfig with closed client', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.UpdateRecommenderConfigRequest() - ); - request.recommenderConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.UpdateRecommenderConfigRequest', ['recommenderConfig', 'name']); - request.recommenderConfig.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateRecommenderConfig(request), expectedError); - }); - }); - - describe('getInsightTypeConfig', () => { - it('invokes getInsightTypeConfig without error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.GetInsightTypeConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.GetInsightTypeConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1.InsightTypeConfig() - ); - client.innerApiCalls.getInsightTypeConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getInsightTypeConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInsightTypeConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInsightTypeConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInsightTypeConfig without error using callback', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.GetInsightTypeConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.GetInsightTypeConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1.InsightTypeConfig() - ); - client.innerApiCalls.getInsightTypeConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInsightTypeConfig( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1.IInsightTypeConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInsightTypeConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInsightTypeConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInsightTypeConfig with error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.GetInsightTypeConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.GetInsightTypeConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInsightTypeConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInsightTypeConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getInsightTypeConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInsightTypeConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInsightTypeConfig with closed client', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.GetInsightTypeConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.GetInsightTypeConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getInsightTypeConfig(request), expectedError); - }); - }); - - describe('updateInsightTypeConfig', () => { - it('invokes updateInsightTypeConfig without error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.UpdateInsightTypeConfigRequest() - ); - request.insightTypeConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.UpdateInsightTypeConfigRequest', ['insightTypeConfig', 'name']); - request.insightTypeConfig.name = defaultValue1; - const expectedHeaderRequestParams = `insight_type_config.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1.InsightTypeConfig() - ); - client.innerApiCalls.updateInsightTypeConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateInsightTypeConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInsightTypeConfig without error using callback', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.UpdateInsightTypeConfigRequest() - ); - request.insightTypeConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.UpdateInsightTypeConfigRequest', ['insightTypeConfig', 'name']); - request.insightTypeConfig.name = defaultValue1; - const expectedHeaderRequestParams = `insight_type_config.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1.InsightTypeConfig() - ); - client.innerApiCalls.updateInsightTypeConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateInsightTypeConfig( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1.IInsightTypeConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInsightTypeConfig with error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.UpdateInsightTypeConfigRequest() - ); - request.insightTypeConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.UpdateInsightTypeConfigRequest', ['insightTypeConfig', 'name']); - request.insightTypeConfig.name = defaultValue1; - const expectedHeaderRequestParams = `insight_type_config.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInsightTypeConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateInsightTypeConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInsightTypeConfig with closed client', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.UpdateInsightTypeConfigRequest() - ); - request.insightTypeConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.UpdateInsightTypeConfigRequest', ['insightTypeConfig', 'name']); - request.insightTypeConfig.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateInsightTypeConfig(request), expectedError); - }); - }); - - describe('listInsights', () => { - it('invokes listInsights without error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.ListInsightsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.ListInsightsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), - generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), - generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), - ]; - client.innerApiCalls.listInsights = stubSimpleCall(expectedResponse); - const [response] = await client.listInsights(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInsights as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInsights as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInsights without error using callback', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.ListInsightsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.ListInsightsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), - generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), - generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), - ]; - client.innerApiCalls.listInsights = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInsights( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1.IInsight[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInsights as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInsights as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInsights with error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.ListInsightsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.ListInsightsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInsights = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInsights(request), expectedError); - const actualRequest = (client.innerApiCalls.listInsights as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInsights as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInsightsStream without error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.ListInsightsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.ListInsightsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), - generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), - generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), - ]; - client.descriptors.page.listInsights.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInsightsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recommender.v1.Insight[] = []; - stream.on('data', (response: protos.google.cloud.recommender.v1.Insight) => { - 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.listInsights.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInsights, request)); - assert( - (client.descriptors.page.listInsights.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listInsightsStream with error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.ListInsightsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.ListInsightsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInsights.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInsightsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recommender.v1.Insight[] = []; - stream.on('data', (response: protos.google.cloud.recommender.v1.Insight) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listInsights.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInsights, request)); - assert( - (client.descriptors.page.listInsights.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInsights without error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.ListInsightsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.ListInsightsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), - generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), - generateSampleMessage(new protos.google.cloud.recommender.v1.Insight()), - ]; - client.descriptors.page.listInsights.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.recommender.v1.IInsight[] = []; - const iterable = client.listInsightsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInsights.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInsights.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInsights with error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.ListInsightsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.ListInsightsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInsights.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInsightsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.recommender.v1.IInsight[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listInsights.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInsights.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listRecommendations', () => { - it('invokes listRecommendations without error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.ListRecommendationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.ListRecommendationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), - generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), - generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), - ]; - client.innerApiCalls.listRecommendations = stubSimpleCall(expectedResponse); - const [response] = await client.listRecommendations(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRecommendations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRecommendations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRecommendations without error using callback', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.ListRecommendationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.ListRecommendationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), - generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), - generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), - ]; - client.innerApiCalls.listRecommendations = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listRecommendations( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1.IRecommendation[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRecommendations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRecommendations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRecommendations with error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.ListRecommendationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.ListRecommendationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listRecommendations = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listRecommendations(request), expectedError); - const actualRequest = (client.innerApiCalls.listRecommendations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRecommendations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRecommendationsStream without error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.ListRecommendationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.ListRecommendationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), - generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), - generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), - ]; - client.descriptors.page.listRecommendations.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listRecommendationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recommender.v1.Recommendation[] = []; - stream.on('data', (response: protos.google.cloud.recommender.v1.Recommendation) => { - 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.listRecommendations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRecommendations, request)); - assert( - (client.descriptors.page.listRecommendations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listRecommendationsStream with error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.ListRecommendationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.ListRecommendationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listRecommendations.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listRecommendationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recommender.v1.Recommendation[] = []; - stream.on('data', (response: protos.google.cloud.recommender.v1.Recommendation) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listRecommendations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRecommendations, request)); - assert( - (client.descriptors.page.listRecommendations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRecommendations without error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.ListRecommendationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.ListRecommendationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), - generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), - generateSampleMessage(new protos.google.cloud.recommender.v1.Recommendation()), - ]; - client.descriptors.page.listRecommendations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.recommender.v1.IRecommendation[] = []; - const iterable = client.listRecommendationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listRecommendations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRecommendations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRecommendations with error', async () => { - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1.ListRecommendationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1.ListRecommendationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listRecommendations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listRecommendationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.recommender.v1.IRecommendation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listRecommendations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRecommendations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('billingAccountLocationInsightType', () => { - const fakePath = "/rendered/path/billingAccountLocationInsightType"; - const expectedParameters = { - billing_account: "billingAccountValue", - location: "locationValue", - insight_type: "insightTypeValue", - }; - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.billingAccountLocationInsightTypePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.billingAccountLocationInsightTypePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('billingAccountLocationInsightTypePath', () => { - const result = client.billingAccountLocationInsightTypePath("billingAccountValue", "locationValue", "insightTypeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.billingAccountLocationInsightTypePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchBillingAccountFromBillingAccountLocationInsightTypeName', () => { - const result = client.matchBillingAccountFromBillingAccountLocationInsightTypeName(fakePath); - assert.strictEqual(result, "billingAccountValue"); - assert((client.pathTemplates.billingAccountLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBillingAccountLocationInsightTypeName', () => { - const result = client.matchLocationFromBillingAccountLocationInsightTypeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.billingAccountLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightTypeFromBillingAccountLocationInsightTypeName', () => { - const result = client.matchInsightTypeFromBillingAccountLocationInsightTypeName(fakePath); - assert.strictEqual(result, "insightTypeValue"); - assert((client.pathTemplates.billingAccountLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('billingAccountLocationInsightTypeInsight', () => { - const fakePath = "/rendered/path/billingAccountLocationInsightTypeInsight"; - const expectedParameters = { - billing_account: "billingAccountValue", - location: "locationValue", - insight_type: "insightTypeValue", - insight: "insightValue", - }; - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('billingAccountLocationInsightTypeInsightPath', () => { - const result = client.billingAccountLocationInsightTypeInsightPath("billingAccountValue", "locationValue", "insightTypeValue", "insightValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchBillingAccountFromBillingAccountLocationInsightTypeInsightName', () => { - const result = client.matchBillingAccountFromBillingAccountLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "billingAccountValue"); - assert((client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBillingAccountLocationInsightTypeInsightName', () => { - const result = client.matchLocationFromBillingAccountLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightTypeFromBillingAccountLocationInsightTypeInsightName', () => { - const result = client.matchInsightTypeFromBillingAccountLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "insightTypeValue"); - assert((client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightFromBillingAccountLocationInsightTypeInsightName', () => { - const result = client.matchInsightFromBillingAccountLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "insightValue"); - assert((client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('billingAccountLocationRecommender', () => { - const fakePath = "/rendered/path/billingAccountLocationRecommender"; - const expectedParameters = { - billing_account: "billingAccountValue", - location: "locationValue", - recommender: "recommenderValue", - }; - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.billingAccountLocationRecommenderPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.billingAccountLocationRecommenderPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('billingAccountLocationRecommenderPath', () => { - const result = client.billingAccountLocationRecommenderPath("billingAccountValue", "locationValue", "recommenderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.billingAccountLocationRecommenderPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchBillingAccountFromBillingAccountLocationRecommenderName', () => { - const result = client.matchBillingAccountFromBillingAccountLocationRecommenderName(fakePath); - assert.strictEqual(result, "billingAccountValue"); - assert((client.pathTemplates.billingAccountLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBillingAccountLocationRecommenderName', () => { - const result = client.matchLocationFromBillingAccountLocationRecommenderName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.billingAccountLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommenderFromBillingAccountLocationRecommenderName', () => { - const result = client.matchRecommenderFromBillingAccountLocationRecommenderName(fakePath); - assert.strictEqual(result, "recommenderValue"); - assert((client.pathTemplates.billingAccountLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('billingAccountLocationRecommenderRecommendation', () => { - const fakePath = "/rendered/path/billingAccountLocationRecommenderRecommendation"; - const expectedParameters = { - billing_account: "billingAccountValue", - location: "locationValue", - recommender: "recommenderValue", - recommendation: "recommendationValue", - }; - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('billingAccountLocationRecommenderRecommendationPath', () => { - const result = client.billingAccountLocationRecommenderRecommendationPath("billingAccountValue", "locationValue", "recommenderValue", "recommendationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchBillingAccountFromBillingAccountLocationRecommenderRecommendationName', () => { - const result = client.matchBillingAccountFromBillingAccountLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "billingAccountValue"); - assert((client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBillingAccountLocationRecommenderRecommendationName', () => { - const result = client.matchLocationFromBillingAccountLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommenderFromBillingAccountLocationRecommenderRecommendationName', () => { - const result = client.matchRecommenderFromBillingAccountLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "recommenderValue"); - assert((client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommendationFromBillingAccountLocationRecommenderRecommendationName', () => { - const result = client.matchRecommendationFromBillingAccountLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "recommendationValue"); - assert((client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('folderLocationInsightType', () => { - const fakePath = "/rendered/path/folderLocationInsightType"; - const expectedParameters = { - folder: "folderValue", - location: "locationValue", - insight_type: "insightTypeValue", - }; - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderLocationInsightTypePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderLocationInsightTypePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderLocationInsightTypePath', () => { - const result = client.folderLocationInsightTypePath("folderValue", "locationValue", "insightTypeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderLocationInsightTypePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderLocationInsightTypeName', () => { - const result = client.matchFolderFromFolderLocationInsightTypeName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromFolderLocationInsightTypeName', () => { - const result = client.matchLocationFromFolderLocationInsightTypeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.folderLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightTypeFromFolderLocationInsightTypeName', () => { - const result = client.matchInsightTypeFromFolderLocationInsightTypeName(fakePath); - assert.strictEqual(result, "insightTypeValue"); - assert((client.pathTemplates.folderLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('folderLocationInsightTypeInsight', () => { - const fakePath = "/rendered/path/folderLocationInsightTypeInsight"; - const expectedParameters = { - folder: "folderValue", - location: "locationValue", - insight_type: "insightTypeValue", - insight: "insightValue", - }; - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderLocationInsightTypeInsightPath', () => { - const result = client.folderLocationInsightTypeInsightPath("folderValue", "locationValue", "insightTypeValue", "insightValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderLocationInsightTypeInsightName', () => { - const result = client.matchFolderFromFolderLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromFolderLocationInsightTypeInsightName', () => { - const result = client.matchLocationFromFolderLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightTypeFromFolderLocationInsightTypeInsightName', () => { - const result = client.matchInsightTypeFromFolderLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "insightTypeValue"); - assert((client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightFromFolderLocationInsightTypeInsightName', () => { - const result = client.matchInsightFromFolderLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "insightValue"); - assert((client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('folderLocationRecommender', () => { - const fakePath = "/rendered/path/folderLocationRecommender"; - const expectedParameters = { - folder: "folderValue", - location: "locationValue", - recommender: "recommenderValue", - }; - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderLocationRecommenderPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderLocationRecommenderPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderLocationRecommenderPath', () => { - const result = client.folderLocationRecommenderPath("folderValue", "locationValue", "recommenderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderLocationRecommenderPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderLocationRecommenderName', () => { - const result = client.matchFolderFromFolderLocationRecommenderName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromFolderLocationRecommenderName', () => { - const result = client.matchLocationFromFolderLocationRecommenderName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.folderLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommenderFromFolderLocationRecommenderName', () => { - const result = client.matchRecommenderFromFolderLocationRecommenderName(fakePath); - assert.strictEqual(result, "recommenderValue"); - assert((client.pathTemplates.folderLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('folderLocationRecommenderRecommendation', () => { - const fakePath = "/rendered/path/folderLocationRecommenderRecommendation"; - const expectedParameters = { - folder: "folderValue", - location: "locationValue", - recommender: "recommenderValue", - recommendation: "recommendationValue", - }; - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderLocationRecommenderRecommendationPath', () => { - const result = client.folderLocationRecommenderRecommendationPath("folderValue", "locationValue", "recommenderValue", "recommendationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderLocationRecommenderRecommendationName', () => { - const result = client.matchFolderFromFolderLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromFolderLocationRecommenderRecommendationName', () => { - const result = client.matchLocationFromFolderLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommenderFromFolderLocationRecommenderRecommendationName', () => { - const result = client.matchRecommenderFromFolderLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "recommenderValue"); - assert((client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommendationFromFolderLocationRecommenderRecommendationName', () => { - const result = client.matchRecommendationFromFolderLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "recommendationValue"); - assert((client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organizationLocationInsightType', () => { - const fakePath = "/rendered/path/organizationLocationInsightType"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - insight_type: "insightTypeValue", - }; - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationLocationInsightTypePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationLocationInsightTypePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationLocationInsightTypePath', () => { - const result = client.organizationLocationInsightTypePath("organizationValue", "locationValue", "insightTypeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationLocationInsightTypePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationLocationInsightTypeName', () => { - const result = client.matchOrganizationFromOrganizationLocationInsightTypeName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOrganizationLocationInsightTypeName', () => { - const result = client.matchLocationFromOrganizationLocationInsightTypeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightTypeFromOrganizationLocationInsightTypeName', () => { - const result = client.matchInsightTypeFromOrganizationLocationInsightTypeName(fakePath); - assert.strictEqual(result, "insightTypeValue"); - assert((client.pathTemplates.organizationLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organizationLocationInsightTypeConfig', () => { - const fakePath = "/rendered/path/organizationLocationInsightTypeConfig"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - insight_type: "insightTypeValue", - }; - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationLocationInsightTypeConfigPath', () => { - const result = client.organizationLocationInsightTypeConfigPath("organizationValue", "locationValue", "insightTypeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationLocationInsightTypeConfigName', () => { - const result = client.matchOrganizationFromOrganizationLocationInsightTypeConfigName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOrganizationLocationInsightTypeConfigName', () => { - const result = client.matchLocationFromOrganizationLocationInsightTypeConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightTypeFromOrganizationLocationInsightTypeConfigName', () => { - const result = client.matchInsightTypeFromOrganizationLocationInsightTypeConfigName(fakePath); - assert.strictEqual(result, "insightTypeValue"); - assert((client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organizationLocationInsightTypeInsight', () => { - const fakePath = "/rendered/path/organizationLocationInsightTypeInsight"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - insight_type: "insightTypeValue", - insight: "insightValue", - }; - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationLocationInsightTypeInsightPath', () => { - const result = client.organizationLocationInsightTypeInsightPath("organizationValue", "locationValue", "insightTypeValue", "insightValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationLocationInsightTypeInsightName', () => { - const result = client.matchOrganizationFromOrganizationLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOrganizationLocationInsightTypeInsightName', () => { - const result = client.matchLocationFromOrganizationLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightTypeFromOrganizationLocationInsightTypeInsightName', () => { - const result = client.matchInsightTypeFromOrganizationLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "insightTypeValue"); - assert((client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightFromOrganizationLocationInsightTypeInsightName', () => { - const result = client.matchInsightFromOrganizationLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "insightValue"); - assert((client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organizationLocationRecommender', () => { - const fakePath = "/rendered/path/organizationLocationRecommender"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - recommender: "recommenderValue", - }; - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationLocationRecommenderPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationLocationRecommenderPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationLocationRecommenderPath', () => { - const result = client.organizationLocationRecommenderPath("organizationValue", "locationValue", "recommenderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationLocationRecommenderPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationLocationRecommenderName', () => { - const result = client.matchOrganizationFromOrganizationLocationRecommenderName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOrganizationLocationRecommenderName', () => { - const result = client.matchLocationFromOrganizationLocationRecommenderName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommenderFromOrganizationLocationRecommenderName', () => { - const result = client.matchRecommenderFromOrganizationLocationRecommenderName(fakePath); - assert.strictEqual(result, "recommenderValue"); - assert((client.pathTemplates.organizationLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organizationLocationRecommenderConfig', () => { - const fakePath = "/rendered/path/organizationLocationRecommenderConfig"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - recommender: "recommenderValue", - }; - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationLocationRecommenderConfigPath', () => { - const result = client.organizationLocationRecommenderConfigPath("organizationValue", "locationValue", "recommenderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationLocationRecommenderConfigName', () => { - const result = client.matchOrganizationFromOrganizationLocationRecommenderConfigName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOrganizationLocationRecommenderConfigName', () => { - const result = client.matchLocationFromOrganizationLocationRecommenderConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommenderFromOrganizationLocationRecommenderConfigName', () => { - const result = client.matchRecommenderFromOrganizationLocationRecommenderConfigName(fakePath); - assert.strictEqual(result, "recommenderValue"); - assert((client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organizationLocationRecommenderRecommendation', () => { - const fakePath = "/rendered/path/organizationLocationRecommenderRecommendation"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - recommender: "recommenderValue", - recommendation: "recommendationValue", - }; - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationLocationRecommenderRecommendationPath', () => { - const result = client.organizationLocationRecommenderRecommendationPath("organizationValue", "locationValue", "recommenderValue", "recommendationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationLocationRecommenderRecommendationName', () => { - const result = client.matchOrganizationFromOrganizationLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOrganizationLocationRecommenderRecommendationName', () => { - const result = client.matchLocationFromOrganizationLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommenderFromOrganizationLocationRecommenderRecommendationName', () => { - const result = client.matchRecommenderFromOrganizationLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "recommenderValue"); - assert((client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommendationFromOrganizationLocationRecommenderRecommendationName', () => { - const result = client.matchRecommendationFromOrganizationLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "recommendationValue"); - assert((client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationInsightType', () => { - const fakePath = "/rendered/path/projectLocationInsightType"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - insight_type: "insightTypeValue", - }; - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationInsightTypePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationInsightTypePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationInsightTypePath', () => { - const result = client.projectLocationInsightTypePath("projectValue", "locationValue", "insightTypeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationInsightTypePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationInsightTypeName', () => { - const result = client.matchProjectFromProjectLocationInsightTypeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationInsightTypeName', () => { - const result = client.matchLocationFromProjectLocationInsightTypeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightTypeFromProjectLocationInsightTypeName', () => { - const result = client.matchInsightTypeFromProjectLocationInsightTypeName(fakePath); - assert.strictEqual(result, "insightTypeValue"); - assert((client.pathTemplates.projectLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationInsightTypeConfig', () => { - const fakePath = "/rendered/path/projectLocationInsightTypeConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - insight_type: "insightTypeValue", - }; - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationInsightTypeConfigPath', () => { - const result = client.projectLocationInsightTypeConfigPath("projectValue", "locationValue", "insightTypeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationInsightTypeConfigName', () => { - const result = client.matchProjectFromProjectLocationInsightTypeConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationInsightTypeConfigName', () => { - const result = client.matchLocationFromProjectLocationInsightTypeConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightTypeFromProjectLocationInsightTypeConfigName', () => { - const result = client.matchInsightTypeFromProjectLocationInsightTypeConfigName(fakePath); - assert.strictEqual(result, "insightTypeValue"); - assert((client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationInsightTypeInsight', () => { - const fakePath = "/rendered/path/projectLocationInsightTypeInsight"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - insight_type: "insightTypeValue", - insight: "insightValue", - }; - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationInsightTypeInsightPath', () => { - const result = client.projectLocationInsightTypeInsightPath("projectValue", "locationValue", "insightTypeValue", "insightValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationInsightTypeInsightName', () => { - const result = client.matchProjectFromProjectLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationInsightTypeInsightName', () => { - const result = client.matchLocationFromProjectLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightTypeFromProjectLocationInsightTypeInsightName', () => { - const result = client.matchInsightTypeFromProjectLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "insightTypeValue"); - assert((client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightFromProjectLocationInsightTypeInsightName', () => { - const result = client.matchInsightFromProjectLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "insightValue"); - assert((client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationRecommender', () => { - const fakePath = "/rendered/path/projectLocationRecommender"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - recommender: "recommenderValue", - }; - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationRecommenderPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationRecommenderPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationRecommenderPath', () => { - const result = client.projectLocationRecommenderPath("projectValue", "locationValue", "recommenderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationRecommenderPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationRecommenderName', () => { - const result = client.matchProjectFromProjectLocationRecommenderName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationRecommenderName', () => { - const result = client.matchLocationFromProjectLocationRecommenderName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommenderFromProjectLocationRecommenderName', () => { - const result = client.matchRecommenderFromProjectLocationRecommenderName(fakePath); - assert.strictEqual(result, "recommenderValue"); - assert((client.pathTemplates.projectLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationRecommenderConfig', () => { - const fakePath = "/rendered/path/projectLocationRecommenderConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - recommender: "recommenderValue", - }; - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationRecommenderConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationRecommenderConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationRecommenderConfigPath', () => { - const result = client.projectLocationRecommenderConfigPath("projectValue", "locationValue", "recommenderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationRecommenderConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationRecommenderConfigName', () => { - const result = client.matchProjectFromProjectLocationRecommenderConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationRecommenderConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationRecommenderConfigName', () => { - const result = client.matchLocationFromProjectLocationRecommenderConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationRecommenderConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommenderFromProjectLocationRecommenderConfigName', () => { - const result = client.matchRecommenderFromProjectLocationRecommenderConfigName(fakePath); - assert.strictEqual(result, "recommenderValue"); - assert((client.pathTemplates.projectLocationRecommenderConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationRecommenderRecommendation', () => { - const fakePath = "/rendered/path/projectLocationRecommenderRecommendation"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - recommender: "recommenderValue", - recommendation: "recommendationValue", - }; - const client = new recommenderModule.v1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationRecommenderRecommendationPath', () => { - const result = client.projectLocationRecommenderRecommendationPath("projectValue", "locationValue", "recommenderValue", "recommendationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationRecommenderRecommendationName', () => { - const result = client.matchProjectFromProjectLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationRecommenderRecommendationName', () => { - const result = client.matchLocationFromProjectLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommenderFromProjectLocationRecommenderRecommendationName', () => { - const result = client.matchRecommenderFromProjectLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "recommenderValue"); - assert((client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommendationFromProjectLocationRecommenderRecommendationName', () => { - const result = client.matchRecommendationFromProjectLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "recommendationValue"); - assert((client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-recommender/v1/tsconfig.json b/owl-bot-staging/google-cloud-recommender/v1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-recommender/v1/webpack.config.js b/owl-bot-staging/google-cloud-recommender/v1/webpack.config.js deleted file mode 100644 index a74f57c48a0..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'Recommender', - filename: './recommender.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-recommender/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-recommender/v1beta1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-recommender/v1beta1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/.gitignore b/owl-bot-staging/google-cloud-recommender/v1beta1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-recommender/v1beta1/.jsdoc.js deleted file mode 100644 index c2e2fb04e21..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/.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/recommender', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-recommender/v1beta1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/.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-recommender/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-recommender/v1beta1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/.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-recommender/v1beta1/README.md b/owl-bot-staging/google-cloud-recommender/v1beta1/README.md deleted file mode 100644 index 59dc6bb7bb1..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Recommender: Nodejs Client diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/package.json b/owl-bot-staging/google-cloud-recommender/v1beta1/package.json deleted file mode 100644 index 5f3c60b1639..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/recommender", - "version": "0.1.0", - "description": "Recommender client for Node.js", - "repository": "googleapis/nodejs-recommender", - "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 recommender", - "recommender", - "recommender" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/insight.proto b/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/insight.proto deleted file mode 100644 index 2fc7f6477e6..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/insight.proto +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.recommender.v1beta1; - -import "google/api/resource.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Recommender.V1Beta1"; -option go_package = "cloud.google.com/go/recommender/apiv1beta1/recommenderpb;recommenderpb"; -option java_multiple_files = true; -option java_package = "com.google.cloud.recommender.v1beta1"; -option objc_class_prefix = "CREC"; -option (google.api.resource_definition) = { - type: "recommender.googleapis.com/InsightType" - pattern: "projects/{project}/locations/{location}/insightTypes/{insight_type}" - pattern: "billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}" - pattern: "folders/{folder}/locations/{location}/insightTypes/{insight_type}" - pattern: "organizations/{organization}/locations/{location}/insightTypes/{insight_type}" -}; - -// An insight along with the information used to derive the insight. The insight -// may have associated recomendations as well. -message Insight { - option (google.api.resource) = { - type: "recommender.googleapis.com/Insight" - pattern: "projects/{project}/locations/{location}/insightTypes/{insight_type}/insights/{insight}" - pattern: "billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}/insights/{insight}" - pattern: "folders/{folder}/locations/{location}/insightTypes/{insight_type}/insights/{insight}" - pattern: "organizations/{organization}/locations/{location}/insightTypes/{insight_type}/insights/{insight}" - }; - - // Insight category. - enum Category { - // Unspecified category. - CATEGORY_UNSPECIFIED = 0; - - // The insight is related to cost. - COST = 1; - - // The insight is related to security. - SECURITY = 2; - - // The insight is related to performance. - PERFORMANCE = 3; - - // This insight is related to manageability. - MANAGEABILITY = 4; - } - - // Insight severity levels. - enum Severity { - // Insight has unspecified severity. - SEVERITY_UNSPECIFIED = 0; - - // Insight has low severity. - LOW = 1; - - // Insight has medium severity. - MEDIUM = 2; - - // Insight has high severity. - HIGH = 3; - - // Insight has critical severity. - CRITICAL = 4; - } - - // Reference to an associated recommendation. - message RecommendationReference { - // Recommendation resource name, e.g. - // projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/recommendations/[RECOMMENDATION_ID] - string recommendation = 1; - } - - // Name of the insight. - string name = 1; - - // Free-form human readable summary in English. The maximum length is 500 - // characters. - string description = 2; - - // Fully qualified resource names that this insight is targeting. - repeated string target_resources = 9; - - // Insight subtype. Insight content schema will be stable for a given subtype. - string insight_subtype = 10; - - // A struct of custom fields to explain the insight. - // Example: "grantedPermissionsCount": "1000" - google.protobuf.Struct content = 3; - - // Timestamp of the latest data used to generate the insight. - google.protobuf.Timestamp last_refresh_time = 4; - - // Observation period that led to the insight. The source data used to - // generate the insight ends at last_refresh_time and begins at - // (last_refresh_time - observation_period). - google.protobuf.Duration observation_period = 5; - - // Information state and metadata. - InsightStateInfo state_info = 6; - - // Category being targeted by the insight. - Category category = 7; - - // Insight's severity. - Severity severity = 15; - - // Fingerprint of the Insight. Provides optimistic locking when updating - // states. - string etag = 11; - - // Recommendations derived from this insight. - repeated RecommendationReference associated_recommendations = 8; -} - -// Information related to insight state. -message InsightStateInfo { - // Represents insight state. - enum State { - // Unspecified state. - STATE_UNSPECIFIED = 0; - - // Insight is active. Content for ACTIVE insights can be updated by Google. - // ACTIVE insights can be marked DISMISSED OR ACCEPTED. - ACTIVE = 1; - - // Some action has been taken based on this insight. Insights become - // accepted when a recommendation derived from the insight has been marked - // CLAIMED, SUCCEEDED, or FAILED. ACTIVE insights can also be marked - // ACCEPTED explicitly. Content for ACCEPTED insights is immutable. ACCEPTED - // insights can only be marked ACCEPTED (which may update state metadata). - ACCEPTED = 2; - - // Insight is dismissed. Content for DISMISSED insights can be updated by - // Google. DISMISSED insights can be marked as ACTIVE. - DISMISSED = 3; - } - - // Insight state. - State state = 1; - - // A map of metadata for the state, provided by user or automations systems. - map state_metadata = 2; -} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/insight_type_config.proto b/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/insight_type_config.proto deleted file mode 100644 index e910a3d26d3..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/insight_type_config.proto +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.recommender.v1beta1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Recommender.V1Beta1"; -option go_package = "cloud.google.com/go/recommender/apiv1beta1/recommenderpb;recommenderpb"; -option java_multiple_files = true; -option java_outer_classname = "InsightTypeConfigProto"; -option java_package = "com.google.cloud.recommender.v1beta1"; -option objc_class_prefix = "CREC"; - -// Configuration for an InsightType. -message InsightTypeConfig { - option (google.api.resource) = { - type: "recommender.googleapis.com/InsightTypeConfig" - pattern: "projects/{project}/locations/{location}/insightTypes/{insight_type}/config" - pattern: "organizations/{organization}/locations/{location}/insightTypes/{insight_type}/config" - }; - - // Name of insight type config. - // Eg, - // projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config - string name = 1; - - // InsightTypeGenerationConfig which configures the generation of - // insights for this insight type. - InsightTypeGenerationConfig insight_type_generation_config = 2; - - // Fingerprint of the InsightTypeConfig. Provides optimistic locking when - // updating. - string etag = 3; - - // Last time when the config was updated. - google.protobuf.Timestamp update_time = 4; - - // Output only. Immutable. The revision ID of the config. - // A new revision is committed whenever the config is changed in any way. - // The format is an 8-character hexadecimal string. - string revision_id = 5 [ - (google.api.field_behavior) = IMMUTABLE, - (google.api.field_behavior) = OUTPUT_ONLY - ]; - - // Allows clients to store small amounts of arbitrary data. Annotations must - // follow the Kubernetes syntax. - // The total size of all keys and values combined is limited to 256k. - // Key can have 2 segments: prefix (optional) and name (required), - // separated by a slash (/). - // Prefix must be a DNS subdomain. - // Name must be 63 characters or less, begin and end with alphanumerics, - // with dashes (-), underscores (_), dots (.), and alphanumerics between. - map annotations = 6; - - // A user-settable field to provide a human-readable name to be used in user - // interfaces. - string display_name = 7; -} - -// A configuration to customize the generation of insights. -// Eg, customizing the lookback period considered when generating a -// insight. -message InsightTypeGenerationConfig { - // Parameters for this InsightTypeGenerationConfig. These configs can be used - // by or are applied to all subtypes. - google.protobuf.Struct params = 1; -} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommendation.proto b/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommendation.proto deleted file mode 100644 index 390958c62ce..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommendation.proto +++ /dev/null @@ -1,361 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.recommender.v1beta1; - -import "google/api/resource.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; -import "google/type/money.proto"; - -option csharp_namespace = "Google.Cloud.Recommender.V1Beta1"; -option go_package = "cloud.google.com/go/recommender/apiv1beta1/recommenderpb;recommenderpb"; -option java_multiple_files = true; -option java_package = "com.google.cloud.recommender.v1beta1"; -option objc_class_prefix = "CREC"; -option (google.api.resource_definition) = { - type: "recommender.googleapis.com/Recommender" - pattern: "projects/{project}/locations/{location}/recommenders/{recommender}" - pattern: "billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}" - pattern: "folders/{folder}/locations/{location}/recommenders/{recommender}" - pattern: "organizations/{organization}/locations/{location}/recommenders/{recommender}" -}; - -// A recommendation along with a suggested action. E.g., a rightsizing -// recommendation for an underutilized VM, IAM role recommendations, etc -message Recommendation { - option (google.api.resource) = { - type: "recommender.googleapis.com/Recommendation" - pattern: "projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}" - pattern: "billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}" - pattern: "folders/{folder}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}" - pattern: "organizations/{organization}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}" - }; - - // Recommendation priority levels. - enum Priority { - // Recommendation has unspecified priority. - PRIORITY_UNSPECIFIED = 0; - - // Recommendation has P4 priority (lowest priority). - P4 = 1; - - // Recommendation has P3 priority (second lowest priority). - P3 = 2; - - // Recommendation has P2 priority (second highest priority). - P2 = 3; - - // Recommendation has P1 priority (highest priority). - P1 = 4; - } - - // Reference to an associated insight. - message InsightReference { - // Insight resource name, e.g. - // projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/insights/[INSIGHT_ID] - string insight = 1; - } - - // Name of recommendation. - string name = 1; - - // Free-form human readable summary in English. The maximum length is 500 - // characters. - string description = 2; - - // Contains an identifier for a subtype of recommendations produced for the - // same recommender. Subtype is a function of content and impact, meaning a - // new subtype might be added when significant changes to `content` or - // `primary_impact.category` are introduced. See the Recommenders section - // to see a list of subtypes for a given Recommender. - // - // Examples: - // For recommender = "google.iam.policy.Recommender", - // recommender_subtype can be one of "REMOVE_ROLE"/"REPLACE_ROLE" - string recommender_subtype = 12; - - // Last time this recommendation was refreshed by the system that created it - // in the first place. - google.protobuf.Timestamp last_refresh_time = 4; - - // The primary impact that this recommendation can have while trying to - // optimize for one category. - Impact primary_impact = 5; - - // Optional set of additional impact that this recommendation may have when - // trying to optimize for the primary category. These may be positive - // or negative. - repeated Impact additional_impact = 6; - - // Recommendation's priority. - Priority priority = 17; - - // Content of the recommendation describing recommended changes to resources. - RecommendationContent content = 7; - - // Information for state. Contains state and metadata. - RecommendationStateInfo state_info = 10; - - // Fingerprint of the Recommendation. Provides optimistic locking when - // updating states. - string etag = 11; - - // Insights that led to this recommendation. - repeated InsightReference associated_insights = 14; - - // Corresponds to a mutually exclusive group ID within a recommender. - // A non-empty ID indicates that the recommendation belongs to a mutually - // exclusive group. This means that only one recommendation within the group - // is suggested to be applied. - string xor_group_id = 18; -} - -// Contains what resources are changing and how they are changing. -message RecommendationContent { - // Operations to one or more Google Cloud resources grouped in such a way - // that, all operations within one group are expected to be performed - // atomically and in an order. - repeated OperationGroup operation_groups = 2; - - // Condensed overview information about the recommendation. - google.protobuf.Struct overview = 3; -} - -// Group of operations that need to be performed atomically. -message OperationGroup { - // List of operations across one or more resources that belong to this group. - // Loosely based on RFC6902 and should be performed in the order they appear. - repeated Operation operations = 1; -} - -// Contains an operation for a resource loosely based on the JSON-PATCH format -// with support for: -// -// * Custom filters for describing partial array patch. -// * Extended path values for describing nested arrays. -// * Custom fields for describing the resource for which the operation is being -// described. -// * Allows extension to custom operations not natively supported by RFC6902. -// See https://tools.ietf.org/html/rfc6902 for details on the original RFC. -message Operation { - // Type of this operation. Contains one of 'add', 'remove', 'replace', 'move', - // 'copy', 'test' and 'custom' operations. This field is case-insensitive and - // always populated. - string action = 1; - - // Type of GCP resource being modified/tested. This field is always populated. - // Example: cloudresourcemanager.googleapis.com/Project, - // compute.googleapis.com/Instance - string resource_type = 2; - - // Contains the fully qualified resource name. This field is always populated. - // ex: //cloudresourcemanager.googleapis.com/projects/foo. - string resource = 3; - - // Path to the target field being operated on. If the operation is at the - // resource level, then path should be "/". This field is always populated. - string path = 4; - - // Can be set with action 'copy' to copy resource configuration across - // different resources of the same type. Example: A resource clone can be - // done via action = 'copy', path = "/", from = "/", - // source_resource = and resource_name = . - // This field is empty for all other values of `action`. - string source_resource = 5; - - // Can be set with action 'copy' or 'move' to indicate the source field within - // resource or source_resource, ignored if provided for other operation types. - string source_path = 6; - - // One of the fields in the following block will be set and intend to - // describe a value for 'path' field. - oneof path_value { - // Value for the `path` field. Will be set for actions:'add'/'replace'. - // Maybe set for action: 'test'. Either this or `value_matcher` will be set - // for 'test' operation. An exact match must be performed. - google.protobuf.Value value = 7; - - // Can be set for action 'test' for advanced matching for the value of - // 'path' field. Either this or `value` will be set for 'test' operation. - ValueMatcher value_matcher = 10; - } - - // Set of filters to apply if `path` refers to array elements or nested array - // elements in order to narrow down to a single unique element that is being - // tested/modified. - // This is intended to be an exact match per filter. To perform advanced - // matching, use path_value_matchers. - // - // * Example: - // ``` - // { - // "/versions/*/name" : "it-123" - // "/versions/*/targetSize/percent": 20 - // } - // ``` - // * Example: - // ``` - // { - // "/bindings/*/role": "roles/owner" - // "/bindings/*/condition" : null - // } - // ``` - // * Example: - // ``` - // { - // "/bindings/*/role": "roles/owner" - // "/bindings/*/members/*" : ["x@example.com", "y@example.com"] - // } - // ``` - // When both path_filters and path_value_matchers are set, an implicit AND - // must be performed. - map path_filters = 8; - - // Similar to path_filters, this contains set of filters to apply if `path` - // field refers to array elements. This is meant to support value matching - // beyond exact match. To perform exact match, use path_filters. - // When both path_filters and path_value_matchers are set, an implicit AND - // must be performed. - map path_value_matchers = 11; -} - -// Contains various matching options for values for a GCP resource field. -message ValueMatcher { - oneof match_variant { - // To be used for full regex matching. The regular expression is using the - // Google RE2 syntax (https://github.com/google/re2/wiki/Syntax), so to be - // used with RE2::FullMatch - string matches_pattern = 1; - } -} - -// Contains metadata about how much money a recommendation can save or incur. -message CostProjection { - // An approximate projection on amount saved or amount incurred. Negative cost - // units indicate cost savings and positive cost units indicate increase. - // See google.type.Money documentation for positive/negative units. - // - // A user's permissions may affect whether the cost is computed using list - // prices or custom contract prices. - google.type.Money cost = 1; - - // Duration for which this cost applies. - google.protobuf.Duration duration = 2; -} - -// Contains various ways of describing the impact on Security. -message SecurityProjection { - // This field can be used by the recommender to define details specific to - // security impact. - google.protobuf.Struct details = 2; -} - -// Contains metadata about how much sustainability a recommendation can save or -// incur. -message SustainabilityProjection { - // Carbon Footprint generated in kg of CO2 equivalent. - // Chose kg_c_o2e so that the name renders correctly in camelCase (kgCO2e). - double kg_c_o2e = 1; - - // Duration for which this sustanability applies. - google.protobuf.Duration duration = 2; -} - -// Contains the impact a recommendation can have for a given category. -message Impact { - // The category of the impact. - enum Category { - // Default unspecified category. Don't use directly. - CATEGORY_UNSPECIFIED = 0; - - // Indicates a potential increase or decrease in cost. - COST = 1; - - // Indicates a potential increase or decrease in security. - SECURITY = 2; - - // Indicates a potential increase or decrease in performance. - PERFORMANCE = 3; - - // Indicates a potential increase or decrease in manageability. - MANAGEABILITY = 4; - - // Indicates a potential increase or decrease in sustainability. - SUSTAINABILITY = 5; - } - - // Category that is being targeted. - Category category = 1; - - // Contains projections (if any) for this category. - oneof projection { - // Use with CategoryType.COST - CostProjection cost_projection = 100; - - // Use with CategoryType.SECURITY - SecurityProjection security_projection = 101; - - // Use with CategoryType.SUSTAINABILITY - SustainabilityProjection sustainability_projection = 102; - } -} - -// Information for state. Contains state and metadata. -message RecommendationStateInfo { - // Represents Recommendation State. - enum State { - // Default state. Don't use directly. - STATE_UNSPECIFIED = 0; - - // Recommendation is active and can be applied. Recommendations content can - // be updated by Google. - // - // ACTIVE recommendations can be marked as CLAIMED, SUCCEEDED, or FAILED. - ACTIVE = 1; - - // Recommendation is in claimed state. Recommendations content is - // immutable and cannot be updated by Google. - // - // CLAIMED recommendations can be marked as CLAIMED, SUCCEEDED, or FAILED. - CLAIMED = 6; - - // Recommendation is in succeeded state. Recommendations content is - // immutable and cannot be updated by Google. - // - // SUCCEEDED recommendations can be marked as SUCCEEDED, or FAILED. - SUCCEEDED = 3; - - // Recommendation is in failed state. Recommendations content is immutable - // and cannot be updated by Google. - // - // FAILED recommendations can be marked as SUCCEEDED, or FAILED. - FAILED = 4; - - // Recommendation is in dismissed state. Recommendation content can be - // updated by Google. - // - // DISMISSED recommendations can be marked as ACTIVE. - DISMISSED = 5; - } - - // The state of the recommendation, Eg ACTIVE, SUCCEEDED, FAILED. - State state = 1; - - // A map of metadata for the state, provided by user or automations systems. - map state_metadata = 2; -} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommender_config.proto b/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommender_config.proto deleted file mode 100644 index 834f17beadb..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommender_config.proto +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.recommender.v1beta1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Recommender.V1Beta1"; -option go_package = "cloud.google.com/go/recommender/apiv1beta1/recommenderpb;recommenderpb"; -option java_multiple_files = true; -option java_outer_classname = "RecommenderConfigProto"; -option java_package = "com.google.cloud.recommender.v1beta1"; -option objc_class_prefix = "CREC"; - -// Configuration for a Recommender. -message RecommenderConfig { - option (google.api.resource) = { - type: "recommender.googleapis.com/RecommenderConfig" - pattern: "projects/{project}/locations/{location}/recommenders/{recommender}/config" - pattern: "organizations/{organization}/locations/{location}/recommenders/{recommender}/config" - }; - - // Name of recommender config. - // Eg, - // projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config - string name = 1; - - // RecommenderGenerationConfig which configures the Generation of - // recommendations for this recommender. - RecommenderGenerationConfig recommender_generation_config = 2; - - // Fingerprint of the RecommenderConfig. Provides optimistic locking when - // updating. - string etag = 3; - - // Last time when the config was updated. - google.protobuf.Timestamp update_time = 4; - - // Output only. Immutable. The revision ID of the config. - // A new revision is committed whenever the config is changed in any way. - // The format is an 8-character hexadecimal string. - string revision_id = 5 [ - (google.api.field_behavior) = IMMUTABLE, - (google.api.field_behavior) = OUTPUT_ONLY - ]; - - // Allows clients to store small amounts of arbitrary data. Annotations must - // follow the Kubernetes syntax. - // The total size of all keys and values combined is limited to 256k. - // Key can have 2 segments: prefix (optional) and name (required), - // separated by a slash (/). - // Prefix must be a DNS subdomain. - // Name must be 63 characters or less, begin and end with alphanumerics, - // with dashes (-), underscores (_), dots (.), and alphanumerics between. - map annotations = 6; - - // A user-settable field to provide a human-readable name to be used in user - // interfaces. - string display_name = 7; -} - -// A Configuration to customize the generation of recommendations. -// Eg, customizing the lookback period considered when generating a -// recommendation. -message RecommenderGenerationConfig { - // Parameters for this RecommenderGenerationConfig. These configs can be used - // by or are applied to all subtypes. - google.protobuf.Struct params = 1; -} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommender_service.proto b/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommender_service.proto deleted file mode 100644 index 80829a90c01..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/protos/google/cloud/recommender/v1beta1/recommender_service.proto +++ /dev/null @@ -1,591 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.recommender.v1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/recommender/v1beta1/insight.proto"; -import "google/cloud/recommender/v1beta1/insight_type_config.proto"; -import "google/cloud/recommender/v1beta1/recommendation.proto"; -import "google/cloud/recommender/v1beta1/recommender_config.proto"; -import "google/protobuf/field_mask.proto"; - -option csharp_namespace = "Google.Cloud.Recommender.V1Beta1"; -option go_package = "cloud.google.com/go/recommender/apiv1beta1/recommenderpb;recommenderpb"; -option java_multiple_files = true; -option java_outer_classname = "RecommenderProto"; -option java_package = "com.google.cloud.recommender.v1beta1"; -option objc_class_prefix = "CREC"; - -// Provides insights and recommendations for cloud customers for various -// categories like performance optimization, cost savings, reliability, feature -// discovery, etc. Insights and recommendations are generated automatically -// based on analysis of user resources, configuration and monitoring metrics. -service Recommender { - option (google.api.default_host) = "recommender.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Lists insights for the specified Cloud Resource. Requires the - // recommender.*.list IAM permission for the specified insight type. - rpc ListInsights(ListInsightsRequest) returns (ListInsightsResponse) { - option (google.api.http) = { - get: "/v1beta1/{parent=projects/*/locations/*/insightTypes/*}/insights" - additional_bindings { - get: "/v1beta1/{parent=billingAccounts/*/locations/*/insightTypes/*}/insights" - } - additional_bindings { - get: "/v1beta1/{parent=folders/*/locations/*/insightTypes/*}/insights" - } - additional_bindings { - get: "/v1beta1/{parent=organizations/*/locations/*/insightTypes/*}/insights" - } - }; - option (google.api.method_signature) = "parent"; - } - - // Gets the requested insight. Requires the recommender.*.get IAM permission - // for the specified insight type. - rpc GetInsight(GetInsightRequest) returns (Insight) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/locations/*/insightTypes/*/insights/*}" - additional_bindings { - get: "/v1beta1/{name=billingAccounts/*/locations/*/insightTypes/*/insights/*}" - } - additional_bindings { - get: "/v1beta1/{name=folders/*/locations/*/insightTypes/*/insights/*}" - } - additional_bindings { - get: "/v1beta1/{name=organizations/*/locations/*/insightTypes/*/insights/*}" - } - }; - option (google.api.method_signature) = "name"; - } - - // Marks the Insight State as Accepted. Users can use this method to - // indicate to the Recommender API that they have applied some action based - // on the insight. This stops the insight content from being updated. - // - // MarkInsightAccepted can be applied to insights in ACTIVE state. Requires - // the recommender.*.update IAM permission for the specified insight. - rpc MarkInsightAccepted(MarkInsightAcceptedRequest) returns (Insight) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/insightTypes/*/insights/*}:markAccepted" - body: "*" - additional_bindings { - post: "/v1beta1/{name=billingAccounts/*/locations/*/insightTypes/*/insights/*}:markAccepted" - body: "*" - } - additional_bindings { - post: "/v1beta1/{name=folders/*/locations/*/insightTypes/*/insights/*}:markAccepted" - body: "*" - } - additional_bindings { - post: "/v1beta1/{name=organizations/*/locations/*/insightTypes/*/insights/*}:markAccepted" - body: "*" - } - }; - option (google.api.method_signature) = "name,state_metadata,etag"; - } - - // Lists recommendations for the specified Cloud Resource. Requires the - // recommender.*.list IAM permission for the specified recommender. - rpc ListRecommendations(ListRecommendationsRequest) returns (ListRecommendationsResponse) { - option (google.api.http) = { - get: "/v1beta1/{parent=projects/*/locations/*/recommenders/*}/recommendations" - additional_bindings { - get: "/v1beta1/{parent=billingAccounts/*/locations/*/recommenders/*}/recommendations" - } - additional_bindings { - get: "/v1beta1/{parent=folders/*/locations/*/recommenders/*}/recommendations" - } - additional_bindings { - get: "/v1beta1/{parent=organizations/*/locations/*/recommenders/*}/recommendations" - } - }; - option (google.api.method_signature) = "parent,filter"; - } - - // Gets the requested recommendation. Requires the recommender.*.get - // IAM permission for the specified recommender. - rpc GetRecommendation(GetRecommendationRequest) returns (Recommendation) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}" - additional_bindings { - get: "/v1beta1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}" - } - additional_bindings { - get: "/v1beta1/{name=folders/*/locations/*/recommenders/*/recommendations/*}" - } - additional_bindings { - get: "/v1beta1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}" - } - }; - option (google.api.method_signature) = "name"; - } - - // Marks the Recommendation State as Claimed. Users can use this method to - // indicate to the Recommender API that they are starting to apply the - // recommendation themselves. This stops the recommendation content from being - // updated. Associated insights are frozen and placed in the ACCEPTED state. - // - // MarkRecommendationClaimed can be applied to recommendations in CLAIMED or - // ACTIVE state. - // - // Requires the recommender.*.update IAM permission for the specified - // recommender. - rpc MarkRecommendationClaimed(MarkRecommendationClaimedRequest) returns (Recommendation) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markClaimed" - body: "*" - additional_bindings { - post: "/v1beta1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markClaimed" - body: "*" - } - additional_bindings { - post: "/v1beta1/{name=folders/*/locations/*/recommenders/*/recommendations/*}:markClaimed" - body: "*" - } - additional_bindings { - post: "/v1beta1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}:markClaimed" - body: "*" - } - }; - option (google.api.method_signature) = "name,state_metadata,etag"; - } - - // Marks the Recommendation State as Succeeded. Users can use this method to - // indicate to the Recommender API that they have applied the recommendation - // themselves, and the operation was successful. This stops the recommendation - // content from being updated. Associated insights are frozen and placed in - // the ACCEPTED state. - // - // MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, - // CLAIMED, SUCCEEDED, or FAILED state. - // - // Requires the recommender.*.update IAM permission for the specified - // recommender. - rpc MarkRecommendationSucceeded(MarkRecommendationSucceededRequest) returns (Recommendation) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markSucceeded" - body: "*" - additional_bindings { - post: "/v1beta1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markSucceeded" - body: "*" - } - additional_bindings { - post: "/v1beta1/{name=folders/*/locations/*/recommenders/*/recommendations/*}:markSucceeded" - body: "*" - } - additional_bindings { - post: "/v1beta1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}:markSucceeded" - body: "*" - } - }; - option (google.api.method_signature) = "name,state_metadata,etag"; - } - - // Marks the Recommendation State as Failed. Users can use this method to - // indicate to the Recommender API that they have applied the recommendation - // themselves, and the operation failed. This stops the recommendation content - // from being updated. Associated insights are frozen and placed in the - // ACCEPTED state. - // - // MarkRecommendationFailed can be applied to recommendations in ACTIVE, - // CLAIMED, SUCCEEDED, or FAILED state. - // - // Requires the recommender.*.update IAM permission for the specified - // recommender. - rpc MarkRecommendationFailed(MarkRecommendationFailedRequest) returns (Recommendation) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markFailed" - body: "*" - additional_bindings { - post: "/v1beta1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markFailed" - body: "*" - } - additional_bindings { - post: "/v1beta1/{name=folders/*/locations/*/recommenders/*/recommendations/*}:markFailed" - body: "*" - } - additional_bindings { - post: "/v1beta1/{name=organizations/*/locations/*/recommenders/*/recommendations/*}:markFailed" - body: "*" - } - }; - option (google.api.method_signature) = "name,state_metadata,etag"; - } - - // Gets the requested Recommender Config. There is only one instance of the - // config for each Recommender. - rpc GetRecommenderConfig(GetRecommenderConfigRequest) returns (RecommenderConfig) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/locations/*/recommenders/*/config}" - additional_bindings { - get: "/v1beta1/{name=organizations/*/locations/*/recommenders/*/config}" - } - }; - option (google.api.method_signature) = "name"; - } - - // Updates a Recommender Config. This will create a new revision of the - // config. - rpc UpdateRecommenderConfig(UpdateRecommenderConfigRequest) returns (RecommenderConfig) { - option (google.api.http) = { - patch: "/v1beta1/{recommender_config.name=projects/*/locations/*/recommenders/*/config}" - body: "recommender_config" - additional_bindings { - post: "/v1beta1/{recommender_config.name=organizations/*/locations/*/recommenders/*/config}" - body: "recommender_config" - } - }; - option (google.api.method_signature) = "recommender_config,update_mask"; - } - - // Gets the requested InsightTypeConfig. There is only one instance of the - // config for each InsightType. - rpc GetInsightTypeConfig(GetInsightTypeConfigRequest) returns (InsightTypeConfig) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/locations/*/insightTypes/*/config}" - additional_bindings { - get: "/v1beta1/{name=organizations/*/locations/*/insightTypes/*/config}" - } - }; - option (google.api.method_signature) = "name"; - } - - // Updates an InsightTypeConfig change. This will create a new revision of the - // config. - rpc UpdateInsightTypeConfig(UpdateInsightTypeConfigRequest) returns (InsightTypeConfig) { - option (google.api.http) = { - patch: "/v1beta1/{insight_type_config.name=projects/*/locations/*/insightTypes/*/config}" - body: "insight_type_config" - additional_bindings { - post: "/v1beta1/{insight_type_config.name=organizations/*/locations/*/insightTypes/*/config}" - body: "insight_type_config" - } - }; - option (google.api.method_signature) = "insight_type_config,update_mask"; - } -} - -// Request for the `ListInsights` method. -message ListInsightsRequest { - // Required. The container resource on which to execute the request. - // Acceptable formats: - // - // * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - // - // * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - // - // * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - // - // * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - // - // * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - // - // LOCATION here refers to GCP Locations: - // https://cloud.google.com/about/locations/ - // INSIGHT_TYPE_ID refers to supported insight types: - // https://cloud.google.com/recommender/docs/insights/insight-types. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recommender.googleapis.com/InsightType" - } - ]; - - // Optional. The maximum number of results to return from this request. Non-positive - // values are ignored. If not specified, the server will determine the number - // of results to return. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. If present, retrieves the next batch of results from the preceding call to - // this method. `page_token` must be the value of `next_page_token` from the - // previous response. The values of other method parameters must be identical - // to those in the previous call. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Filter expression to restrict the insights returned. Supported - // filter fields: - // - // * `stateInfo.state` - // - // * `insightSubtype` - // - // * `severity` - // - // Examples: - // - // * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - // - // * `insightSubtype = PERMISSIONS_USAGE` - // - // * `severity = CRITICAL OR severity = HIGH` - // - // * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` - // - // (These expressions are based on the filter language described at - // https://google.aip.dev/160) - string filter = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// Response to the `ListInsights` method. -message ListInsightsResponse { - // The set of insights for the `parent` resource. - repeated Insight insights = 1; - - // A token that can be used to request the next page of results. This field is - // empty if there are no additional results. - string next_page_token = 2; -} - -// Request to the `GetInsight` method. -message GetInsightRequest { - // Required. Name of the insight. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recommender.googleapis.com/Insight" - } - ]; -} - -// Request for the `MarkInsightAccepted` method. -message MarkInsightAcceptedRequest { - // Required. Name of the insight. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recommender.googleapis.com/Insight" - } - ]; - - // Optional. State properties user wish to include with this state. Full replace of the - // current state_metadata. - map state_metadata = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Required. Fingerprint of the Insight. Provides optimistic locking. - string etag = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for the `ListRecommendations` method. -message ListRecommendationsRequest { - // Required. The container resource on which to execute the request. - // Acceptable formats: - // - // * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - // - // * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - // - // * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - // - // * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - // - // * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - // - // LOCATION here refers to GCP Locations: - // https://cloud.google.com/about/locations/ - // RECOMMENDER_ID refers to supported recommenders: - // https://cloud.google.com/recommender/docs/recommenders. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recommender.googleapis.com/Recommender" - } - ]; - - // Optional. The maximum number of results to return from this request. Non-positive - // values are ignored. If not specified, the server will determine the number - // of results to return. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. If present, retrieves the next batch of results from the preceding call to - // this method. `page_token` must be the value of `next_page_token` from the - // previous response. The values of other method parameters must be identical - // to those in the previous call. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Filter expression to restrict the recommendations returned. Supported - // filter fields: - // - // * `state_info.state` - // - // * `recommenderSubtype` - // - // * `priority` - // - // Examples: - // - // * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - // - // * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` - // - // * `priority = P1 OR priority = P2` - // - // * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` - // - // (These expressions are based on the filter language described at - // https://google.aip.dev/160) - string filter = 5; -} - -// Response to the `ListRecommendations` method. -message ListRecommendationsResponse { - // The set of recommendations for the `parent` resource. - repeated Recommendation recommendations = 1; - - // A token that can be used to request the next page of results. This field is - // empty if there are no additional results. - string next_page_token = 2; -} - -// Request to the `GetRecommendation` method. -message GetRecommendationRequest { - // Required. Name of the recommendation. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recommender.googleapis.com/Recommendation" - } - ]; -} - -// Request for the `MarkRecommendationClaimed` Method. -message MarkRecommendationClaimedRequest { - // Required. Name of the recommendation. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recommender.googleapis.com/Recommendation" - } - ]; - - // State properties to include with this state. Overwrites any existing - // `state_metadata`. - // Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. - // Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. - map state_metadata = 2; - - // Required. Fingerprint of the Recommendation. Provides optimistic locking. - string etag = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for the `MarkRecommendationSucceeded` Method. -message MarkRecommendationSucceededRequest { - // Required. Name of the recommendation. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recommender.googleapis.com/Recommendation" - } - ]; - - // State properties to include with this state. Overwrites any existing - // `state_metadata`. - // Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. - // Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. - map state_metadata = 2; - - // Required. Fingerprint of the Recommendation. Provides optimistic locking. - string etag = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for the `MarkRecommendationFailed` Method. -message MarkRecommendationFailedRequest { - // Required. Name of the recommendation. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recommender.googleapis.com/Recommendation" - } - ]; - - // State properties to include with this state. Overwrites any existing - // `state_metadata`. - // Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. - // Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. - map state_metadata = 2; - - // Required. Fingerprint of the Recommendation. Provides optimistic locking. - string etag = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for the GetRecommenderConfig` method. -message GetRecommenderConfigRequest { - // Required. Name of the Recommendation Config to get. - // - // Acceptable formats: - // - // * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` - // - // * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` - // - // * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recommender.googleapis.com/RecommenderConfig" - } - ]; -} - -// Request for the `UpdateRecommenderConfig` method. -message UpdateRecommenderConfigRequest { - // Required. The RecommenderConfig to update. - RecommenderConfig recommender_config = 1 [(google.api.field_behavior) = REQUIRED]; - - // The list of fields to be updated. - google.protobuf.FieldMask update_mask = 2; - - // If true, validate the request and preview the change, but do not actually - // update it. - bool validate_only = 3; -} - -// Request for the GetInsightTypeConfig` method. -message GetInsightTypeConfigRequest { - // Required. Name of the InsightTypeConfig to get. - // - // Acceptable formats: - // - // * `projects/[PROJECT_NUMBER]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` - // - // * `projects/[PROJECT_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` - // - // * `organizations/[ORGANIZATION_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recommender.googleapis.com/InsightTypeConfig" - } - ]; -} - -// Request for the `UpdateInsightTypeConfig` method. -message UpdateInsightTypeConfigRequest { - // Required. The InsightTypeConfig to update. - InsightTypeConfig insight_type_config = 1 [(google.api.field_behavior) = REQUIRED]; - - // The list of fields to be updated. - google.protobuf.FieldMask update_mask = 2; - - // If true, validate the request and preview the change, but do not actually - // update it. - bool validate_only = 3; -} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_insight.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_insight.js deleted file mode 100644 index 9fe532fc4a1..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_insight.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(name) { - // [START recommender_v1beta1_generated_Recommender_GetInsight_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the insight. - */ - // const name = 'abc123' - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callGetInsight() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await recommenderClient.getInsight(request); - console.log(response); - } - - callGetInsight(); - // [END recommender_v1beta1_generated_Recommender_GetInsight_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_insight_type_config.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_insight_type_config.js deleted file mode 100644 index a10fda24e5e..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_insight_type_config.js +++ /dev/null @@ -1,65 +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 recommender_v1beta1_generated_Recommender_GetInsightTypeConfig_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the InsightTypeConfig to get. - * Acceptable formats: - * * `projects/[PROJECT_NUMBER]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` - * * `projects/[PROJECT_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` - * * `organizations/[ORGANIZATION_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` - */ - // const name = 'abc123' - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callGetInsightTypeConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await recommenderClient.getInsightTypeConfig(request); - console.log(response); - } - - callGetInsightTypeConfig(); - // [END recommender_v1beta1_generated_Recommender_GetInsightTypeConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_recommendation.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_recommendation.js deleted file mode 100644 index 1eec74a9226..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_recommendation.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(name) { - // [START recommender_v1beta1_generated_Recommender_GetRecommendation_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the recommendation. - */ - // const name = 'abc123' - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callGetRecommendation() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await recommenderClient.getRecommendation(request); - console.log(response); - } - - callGetRecommendation(); - // [END recommender_v1beta1_generated_Recommender_GetRecommendation_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_recommender_config.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_recommender_config.js deleted file mode 100644 index 714bfb6daa3..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.get_recommender_config.js +++ /dev/null @@ -1,65 +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 recommender_v1beta1_generated_Recommender_GetRecommenderConfig_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the Recommendation Config to get. - * Acceptable formats: - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` - * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` - */ - // const name = 'abc123' - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callGetRecommenderConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await recommenderClient.getRecommenderConfig(request); - console.log(response); - } - - callGetRecommenderConfig(); - // [END recommender_v1beta1_generated_Recommender_GetRecommenderConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.list_insights.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.list_insights.js deleted file mode 100644 index 4021b57de47..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.list_insights.js +++ /dev/null @@ -1,101 +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 recommender_v1beta1_generated_Recommender_ListInsights_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The container resource on which to execute the request. - * Acceptable formats: - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * LOCATION here refers to GCP Locations: - * https://cloud.google.com/about/locations/ - * INSIGHT_TYPE_ID refers to supported insight types: - * https://cloud.google.com/recommender/docs/insights/insight-types. - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of results to return from this request. Non-positive - * values are ignored. If not specified, the server will determine the number - * of results to return. - */ - // const pageSize = 1234 - /** - * Optional. If present, retrieves the next batch of results from the preceding call to - * this method. `page_token` must be the value of `next_page_token` from the - * previous response. The values of other method parameters must be identical - * to those in the previous call. - */ - // const pageToken = 'abc123' - /** - * Optional. Filter expression to restrict the insights returned. Supported - * filter fields: - * * `stateInfo.state` - * * `insightSubtype` - * * `severity` - * Examples: - * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - * * `insightSubtype = PERMISSIONS_USAGE` - * * `severity = CRITICAL OR severity = HIGH` - * * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` - * (These expressions are based on the filter language described at - * https://google.aip.dev/160) - */ - // const filter = 'abc123' - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callListInsights() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await recommenderClient.listInsightsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListInsights(); - // [END recommender_v1beta1_generated_Recommender_ListInsights_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.list_recommendations.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.list_recommendations.js deleted file mode 100644 index 85973f13f6b..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.list_recommendations.js +++ /dev/null @@ -1,101 +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 recommender_v1beta1_generated_Recommender_ListRecommendations_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The container resource on which to execute the request. - * Acceptable formats: - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * LOCATION here refers to GCP Locations: - * https://cloud.google.com/about/locations/ - * RECOMMENDER_ID refers to supported recommenders: - * https://cloud.google.com/recommender/docs/recommenders. - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of results to return from this request. Non-positive - * values are ignored. If not specified, the server will determine the number - * of results to return. - */ - // const pageSize = 1234 - /** - * Optional. If present, retrieves the next batch of results from the preceding call to - * this method. `page_token` must be the value of `next_page_token` from the - * previous response. The values of other method parameters must be identical - * to those in the previous call. - */ - // const pageToken = 'abc123' - /** - * Filter expression to restrict the recommendations returned. Supported - * filter fields: - * * `state_info.state` - * * `recommenderSubtype` - * * `priority` - * Examples: - * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - * * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` - * * `priority = P1 OR priority = P2` - * * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` - * (These expressions are based on the filter language described at - * https://google.aip.dev/160) - */ - // const filter = 'abc123' - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callListRecommendations() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await recommenderClient.listRecommendationsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListRecommendations(); - // [END recommender_v1beta1_generated_Recommender_ListRecommendations_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_insight_accepted.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_insight_accepted.js deleted file mode 100644 index 29c50b7343c..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_insight_accepted.js +++ /dev/null @@ -1,71 +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, etag) { - // [START recommender_v1beta1_generated_Recommender_MarkInsightAccepted_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the insight. - */ - // const name = 'abc123' - /** - * Optional. State properties user wish to include with this state. Full replace of the - * current state_metadata. - */ - // const stateMetadata = [1,2,3,4] - /** - * Required. Fingerprint of the Insight. Provides optimistic locking. - */ - // const etag = 'abc123' - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callMarkInsightAccepted() { - // Construct request - const request = { - name, - etag, - }; - - // Run request - const response = await recommenderClient.markInsightAccepted(request); - console.log(response); - } - - callMarkInsightAccepted(); - // [END recommender_v1beta1_generated_Recommender_MarkInsightAccepted_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_claimed.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_claimed.js deleted file mode 100644 index 560fdcb421f..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_claimed.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(name, etag) { - // [START recommender_v1beta1_generated_Recommender_MarkRecommendationClaimed_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the recommendation. - */ - // const name = 'abc123' - /** - * State properties to include with this state. Overwrites any existing - * `state_metadata`. - * Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. - * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. - */ - // const stateMetadata = [1,2,3,4] - /** - * Required. Fingerprint of the Recommendation. Provides optimistic locking. - */ - // const etag = 'abc123' - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callMarkRecommendationClaimed() { - // Construct request - const request = { - name, - etag, - }; - - // Run request - const response = await recommenderClient.markRecommendationClaimed(request); - console.log(response); - } - - callMarkRecommendationClaimed(); - // [END recommender_v1beta1_generated_Recommender_MarkRecommendationClaimed_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_failed.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_failed.js deleted file mode 100644 index de9056d402f..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_failed.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(name, etag) { - // [START recommender_v1beta1_generated_Recommender_MarkRecommendationFailed_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the recommendation. - */ - // const name = 'abc123' - /** - * State properties to include with this state. Overwrites any existing - * `state_metadata`. - * Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. - * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. - */ - // const stateMetadata = [1,2,3,4] - /** - * Required. Fingerprint of the Recommendation. Provides optimistic locking. - */ - // const etag = 'abc123' - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callMarkRecommendationFailed() { - // Construct request - const request = { - name, - etag, - }; - - // Run request - const response = await recommenderClient.markRecommendationFailed(request); - console.log(response); - } - - callMarkRecommendationFailed(); - // [END recommender_v1beta1_generated_Recommender_MarkRecommendationFailed_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_succeeded.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_succeeded.js deleted file mode 100644 index 8d6245faba3..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.mark_recommendation_succeeded.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(name, etag) { - // [START recommender_v1beta1_generated_Recommender_MarkRecommendationSucceeded_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Name of the recommendation. - */ - // const name = 'abc123' - /** - * State properties to include with this state. Overwrites any existing - * `state_metadata`. - * Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. - * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. - */ - // const stateMetadata = [1,2,3,4] - /** - * Required. Fingerprint of the Recommendation. Provides optimistic locking. - */ - // const etag = 'abc123' - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callMarkRecommendationSucceeded() { - // Construct request - const request = { - name, - etag, - }; - - // Run request - const response = await recommenderClient.markRecommendationSucceeded(request); - console.log(response); - } - - callMarkRecommendationSucceeded(); - // [END recommender_v1beta1_generated_Recommender_MarkRecommendationSucceeded_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.update_insight_type_config.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.update_insight_type_config.js deleted file mode 100644 index d5e4ee4bdb8..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.update_insight_type_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(insightTypeConfig) { - // [START recommender_v1beta1_generated_Recommender_UpdateInsightTypeConfig_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The InsightTypeConfig to update. - */ - // const insightTypeConfig = {} - /** - * The list of fields to be updated. - */ - // const updateMask = {} - /** - * If true, validate the request and preview the change, but do not actually - * update it. - */ - // const validateOnly = true - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callUpdateInsightTypeConfig() { - // Construct request - const request = { - insightTypeConfig, - }; - - // Run request - const response = await recommenderClient.updateInsightTypeConfig(request); - console.log(response); - } - - callUpdateInsightTypeConfig(); - // [END recommender_v1beta1_generated_Recommender_UpdateInsightTypeConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.update_recommender_config.js b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.update_recommender_config.js deleted file mode 100644 index a34d8e21c88..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/recommender.update_recommender_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(recommenderConfig) { - // [START recommender_v1beta1_generated_Recommender_UpdateRecommenderConfig_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The RecommenderConfig to update. - */ - // const recommenderConfig = {} - /** - * The list of fields to be updated. - */ - // const updateMask = {} - /** - * If true, validate the request and preview the change, but do not actually - * update it. - */ - // const validateOnly = true - - // Imports the Recommender library - const {RecommenderClient} = require('@google-cloud/recommender').v1beta1; - - // Instantiates a client - const recommenderClient = new RecommenderClient(); - - async function callUpdateRecommenderConfig() { - // Construct request - const request = { - recommenderConfig, - }; - - // Run request - const response = await recommenderClient.updateRecommenderConfig(request); - console.log(response); - } - - callUpdateRecommenderConfig(); - // [END recommender_v1beta1_generated_Recommender_UpdateRecommenderConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.recommender.v1beta1.json b/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.recommender.v1beta1.json deleted file mode 100644 index ce02de64676..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.recommender.v1beta1.json +++ /dev/null @@ -1,567 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-recommender", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.recommender.v1beta1", - "version": "v1beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "recommender_v1beta1_generated_Recommender_ListInsights_async", - "title": "Recommender listInsights Sample", - "origin": "API_DEFINITION", - "description": " Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.", - "canonical": true, - "file": "recommender.list_insights.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 93, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListInsights", - "fullName": "google.cloud.recommender.v1beta1.Recommender.ListInsights", - "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.recommender.v1beta1.ListInsightsResponse", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" - }, - "method": { - "shortName": "ListInsights", - "fullName": "google.cloud.recommender.v1beta1.Recommender.ListInsights", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1beta1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1beta1_generated_Recommender_GetInsight_async", - "title": "Recommender getInsight Sample", - "origin": "API_DEFINITION", - "description": " Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.", - "canonical": true, - "file": "recommender.get_insight.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetInsight", - "fullName": "google.cloud.recommender.v1beta1.Recommender.GetInsight", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recommender.v1beta1.Insight", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" - }, - "method": { - "shortName": "GetInsight", - "fullName": "google.cloud.recommender.v1beta1.Recommender.GetInsight", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1beta1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1beta1_generated_Recommender_MarkInsightAccepted_async", - "title": "Recommender markInsightAccepted Sample", - "origin": "API_DEFINITION", - "description": " Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated. MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.", - "canonical": true, - "file": "recommender.mark_insight_accepted.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "MarkInsightAccepted", - "fullName": "google.cloud.recommender.v1beta1.Recommender.MarkInsightAccepted", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "state_metadata", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "etag", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recommender.v1beta1.Insight", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" - }, - "method": { - "shortName": "MarkInsightAccepted", - "fullName": "google.cloud.recommender.v1beta1.Recommender.MarkInsightAccepted", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1beta1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1beta1_generated_Recommender_ListRecommendations_async", - "title": "Recommender listRecommendations Sample", - "origin": "API_DEFINITION", - "description": " Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.", - "canonical": true, - "file": "recommender.list_recommendations.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 93, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListRecommendations", - "fullName": "google.cloud.recommender.v1beta1.Recommender.ListRecommendations", - "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.recommender.v1beta1.ListRecommendationsResponse", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" - }, - "method": { - "shortName": "ListRecommendations", - "fullName": "google.cloud.recommender.v1beta1.Recommender.ListRecommendations", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1beta1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1beta1_generated_Recommender_GetRecommendation_async", - "title": "Recommender getRecommendation Sample", - "origin": "API_DEFINITION", - "description": " Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.", - "canonical": true, - "file": "recommender.get_recommendation.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetRecommendation", - "fullName": "google.cloud.recommender.v1beta1.Recommender.GetRecommendation", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recommender.v1beta1.Recommendation", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" - }, - "method": { - "shortName": "GetRecommendation", - "fullName": "google.cloud.recommender.v1beta1.Recommender.GetRecommendation", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1beta1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1beta1_generated_Recommender_MarkRecommendationClaimed_async", - "title": "Recommender markRecommendationClaimed Sample", - "origin": "API_DEFINITION", - "description": " Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationClaimed can be applied to recommendations in CLAIMED or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.", - "canonical": true, - "file": "recommender.mark_recommendation_claimed.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "MarkRecommendationClaimed", - "fullName": "google.cloud.recommender.v1beta1.Recommender.MarkRecommendationClaimed", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "state_metadata", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "etag", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recommender.v1beta1.Recommendation", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" - }, - "method": { - "shortName": "MarkRecommendationClaimed", - "fullName": "google.cloud.recommender.v1beta1.Recommender.MarkRecommendationClaimed", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1beta1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1beta1_generated_Recommender_MarkRecommendationSucceeded_async", - "title": "Recommender markRecommendationSucceeded Sample", - "origin": "API_DEFINITION", - "description": " Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.", - "canonical": true, - "file": "recommender.mark_recommendation_succeeded.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "MarkRecommendationSucceeded", - "fullName": "google.cloud.recommender.v1beta1.Recommender.MarkRecommendationSucceeded", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "state_metadata", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "etag", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recommender.v1beta1.Recommendation", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" - }, - "method": { - "shortName": "MarkRecommendationSucceeded", - "fullName": "google.cloud.recommender.v1beta1.Recommender.MarkRecommendationSucceeded", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1beta1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1beta1_generated_Recommender_MarkRecommendationFailed_async", - "title": "Recommender markRecommendationFailed Sample", - "origin": "API_DEFINITION", - "description": " Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.", - "canonical": true, - "file": "recommender.mark_recommendation_failed.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "MarkRecommendationFailed", - "fullName": "google.cloud.recommender.v1beta1.Recommender.MarkRecommendationFailed", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "state_metadata", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "etag", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recommender.v1beta1.Recommendation", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" - }, - "method": { - "shortName": "MarkRecommendationFailed", - "fullName": "google.cloud.recommender.v1beta1.Recommender.MarkRecommendationFailed", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1beta1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1beta1_generated_Recommender_GetRecommenderConfig_async", - "title": "Recommender getRecommenderConfig Sample", - "origin": "API_DEFINITION", - "description": " Gets the requested Recommender Config. There is only one instance of the config for each Recommender.", - "canonical": true, - "file": "recommender.get_recommender_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetRecommenderConfig", - "fullName": "google.cloud.recommender.v1beta1.Recommender.GetRecommenderConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recommender.v1beta1.RecommenderConfig", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" - }, - "method": { - "shortName": "GetRecommenderConfig", - "fullName": "google.cloud.recommender.v1beta1.Recommender.GetRecommenderConfig", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1beta1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1beta1_generated_Recommender_UpdateRecommenderConfig_async", - "title": "Recommender updateRecommenderConfig Sample", - "origin": "API_DEFINITION", - "description": " Updates a Recommender Config. This will create a new revision of the config.", - "canonical": true, - "file": "recommender.update_recommender_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateRecommenderConfig", - "fullName": "google.cloud.recommender.v1beta1.Recommender.UpdateRecommenderConfig", - "async": true, - "parameters": [ - { - "name": "recommender_config", - "type": ".google.cloud.recommender.v1beta1.RecommenderConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.recommender.v1beta1.RecommenderConfig", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" - }, - "method": { - "shortName": "UpdateRecommenderConfig", - "fullName": "google.cloud.recommender.v1beta1.Recommender.UpdateRecommenderConfig", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1beta1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1beta1_generated_Recommender_GetInsightTypeConfig_async", - "title": "Recommender getInsightTypeConfig Sample", - "origin": "API_DEFINITION", - "description": " Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.", - "canonical": true, - "file": "recommender.get_insight_type_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetInsightTypeConfig", - "fullName": "google.cloud.recommender.v1beta1.Recommender.GetInsightTypeConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.recommender.v1beta1.InsightTypeConfig", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" - }, - "method": { - "shortName": "GetInsightTypeConfig", - "fullName": "google.cloud.recommender.v1beta1.Recommender.GetInsightTypeConfig", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1beta1.Recommender" - } - } - } - }, - { - "regionTag": "recommender_v1beta1_generated_Recommender_UpdateInsightTypeConfig_async", - "title": "Recommender updateInsightTypeConfig Sample", - "origin": "API_DEFINITION", - "description": " Updates an InsightTypeConfig change. This will create a new revision of the config.", - "canonical": true, - "file": "recommender.update_insight_type_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateInsightTypeConfig", - "fullName": "google.cloud.recommender.v1beta1.Recommender.UpdateInsightTypeConfig", - "async": true, - "parameters": [ - { - "name": "insight_type_config", - "type": ".google.cloud.recommender.v1beta1.InsightTypeConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.recommender.v1beta1.InsightTypeConfig", - "client": { - "shortName": "RecommenderClient", - "fullName": "google.cloud.recommender.v1beta1.RecommenderClient" - }, - "method": { - "shortName": "UpdateInsightTypeConfig", - "fullName": "google.cloud.recommender.v1beta1.Recommender.UpdateInsightTypeConfig", - "service": { - "shortName": "Recommender", - "fullName": "google.cloud.recommender.v1beta1.Recommender" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-recommender/v1beta1/src/index.ts deleted file mode 100644 index 01acf655919..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/src/index.ts +++ /dev/null @@ -1,25 +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 v1beta1 from './v1beta1'; -const RecommenderClient = v1beta1.RecommenderClient; -type RecommenderClient = v1beta1.RecommenderClient; -export {v1beta1, RecommenderClient}; -export default {v1beta1, RecommenderClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/gapic_metadata.json deleted file mode 100644 index 7728d04eacb..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/gapic_metadata.json +++ /dev/null @@ -1,151 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.recommender.v1beta1", - "libraryPackage": "@google-cloud/recommender", - "services": { - "Recommender": { - "clients": { - "grpc": { - "libraryClient": "RecommenderClient", - "rpcs": { - "GetInsight": { - "methods": [ - "getInsight" - ] - }, - "MarkInsightAccepted": { - "methods": [ - "markInsightAccepted" - ] - }, - "GetRecommendation": { - "methods": [ - "getRecommendation" - ] - }, - "MarkRecommendationClaimed": { - "methods": [ - "markRecommendationClaimed" - ] - }, - "MarkRecommendationSucceeded": { - "methods": [ - "markRecommendationSucceeded" - ] - }, - "MarkRecommendationFailed": { - "methods": [ - "markRecommendationFailed" - ] - }, - "GetRecommenderConfig": { - "methods": [ - "getRecommenderConfig" - ] - }, - "UpdateRecommenderConfig": { - "methods": [ - "updateRecommenderConfig" - ] - }, - "GetInsightTypeConfig": { - "methods": [ - "getInsightTypeConfig" - ] - }, - "UpdateInsightTypeConfig": { - "methods": [ - "updateInsightTypeConfig" - ] - }, - "ListInsights": { - "methods": [ - "listInsights", - "listInsightsStream", - "listInsightsAsync" - ] - }, - "ListRecommendations": { - "methods": [ - "listRecommendations", - "listRecommendationsStream", - "listRecommendationsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "RecommenderClient", - "rpcs": { - "GetInsight": { - "methods": [ - "getInsight" - ] - }, - "MarkInsightAccepted": { - "methods": [ - "markInsightAccepted" - ] - }, - "GetRecommendation": { - "methods": [ - "getRecommendation" - ] - }, - "MarkRecommendationClaimed": { - "methods": [ - "markRecommendationClaimed" - ] - }, - "MarkRecommendationSucceeded": { - "methods": [ - "markRecommendationSucceeded" - ] - }, - "MarkRecommendationFailed": { - "methods": [ - "markRecommendationFailed" - ] - }, - "GetRecommenderConfig": { - "methods": [ - "getRecommenderConfig" - ] - }, - "UpdateRecommenderConfig": { - "methods": [ - "updateRecommenderConfig" - ] - }, - "GetInsightTypeConfig": { - "methods": [ - "getInsightTypeConfig" - ] - }, - "UpdateInsightTypeConfig": { - "methods": [ - "updateInsightTypeConfig" - ] - }, - "ListInsights": { - "methods": [ - "listInsights", - "listInsightsStream", - "listInsightsAsync" - ] - }, - "ListRecommendations": { - "methods": [ - "listRecommendations", - "listRecommendationsStream", - "listRecommendationsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/index.ts deleted file mode 100644 index fbe6584bdf2..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/index.ts +++ /dev/null @@ -1,19 +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 {RecommenderClient} from './recommender_client'; diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_client.ts b/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_client.ts deleted file mode 100644 index 3319a7b463a..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_client.ts +++ /dev/null @@ -1,2866 +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, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta1/recommender_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './recommender_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Provides insights and recommendations for cloud customers for various - * categories like performance optimization, cost savings, reliability, feature - * discovery, etc. Insights and recommendations are generated automatically - * based on analysis of user resources, configuration and monitoring metrics. - * @class - * @memberof v1beta1 - */ -export class RecommenderClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - recommenderStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of RecommenderClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 RecommenderClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof RecommenderClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - billingAccountLocationInsightTypePathTemplate: new this._gaxModule.PathTemplate( - 'billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}' - ), - billingAccountLocationInsightTypeInsightPathTemplate: new this._gaxModule.PathTemplate( - 'billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}/insights/{insight}' - ), - billingAccountLocationRecommenderPathTemplate: new this._gaxModule.PathTemplate( - 'billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}' - ), - billingAccountLocationRecommenderRecommendationPathTemplate: new this._gaxModule.PathTemplate( - 'billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}' - ), - folderLocationInsightTypePathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}/locations/{location}/insightTypes/{insight_type}' - ), - folderLocationInsightTypeInsightPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}/locations/{location}/insightTypes/{insight_type}/insights/{insight}' - ), - folderLocationRecommenderPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}/locations/{location}/recommenders/{recommender}' - ), - folderLocationRecommenderRecommendationPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}' - ), - organizationLocationInsightTypePathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/insightTypes/{insight_type}' - ), - organizationLocationInsightTypeConfigPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/insightTypes/{insight_type}/config' - ), - organizationLocationInsightTypeInsightPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/insightTypes/{insight_type}/insights/{insight}' - ), - organizationLocationRecommenderPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/recommenders/{recommender}' - ), - organizationLocationRecommenderConfigPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/recommenders/{recommender}/config' - ), - organizationLocationRecommenderRecommendationPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}' - ), - projectLocationInsightTypePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/insightTypes/{insight_type}' - ), - projectLocationInsightTypeConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/insightTypes/{insight_type}/config' - ), - projectLocationInsightTypeInsightPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/insightTypes/{insight_type}/insights/{insight}' - ), - projectLocationRecommenderPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/recommenders/{recommender}' - ), - projectLocationRecommenderConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/recommenders/{recommender}/config' - ), - projectLocationRecommenderRecommendationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}' - ), - }; - - // 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 = { - listInsights: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'insights'), - listRecommendations: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'recommendations') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.recommender.v1beta1.Recommender', 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.recommenderStub) { - return this.recommenderStub; - } - - // Put together the "service stub" for - // google.cloud.recommender.v1beta1.Recommender. - this.recommenderStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.recommender.v1beta1.Recommender') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.recommender.v1beta1.Recommender, - 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 recommenderStubMethods = - ['listInsights', 'getInsight', 'markInsightAccepted', 'listRecommendations', 'getRecommendation', 'markRecommendationClaimed', 'markRecommendationSucceeded', 'markRecommendationFailed', 'getRecommenderConfig', 'updateRecommenderConfig', 'getInsightTypeConfig', 'updateInsightTypeConfig']; - for (const methodName of recommenderStubMethods) { - const callPromise = this.recommenderStub.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.recommenderStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'recommender.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 'recommender.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 the requested insight. Requires the recommender.*.get IAM permission - * for the specified insight type. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the insight. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1beta1.Insight|Insight}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/recommender.get_insight.js - * region_tag:recommender_v1beta1_generated_Recommender_GetInsight_async - */ - getInsight( - request?: protos.google.cloud.recommender.v1beta1.IGetInsightRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1beta1.IInsight, - protos.google.cloud.recommender.v1beta1.IGetInsightRequest|undefined, {}|undefined - ]>; - getInsight( - request: protos.google.cloud.recommender.v1beta1.IGetInsightRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recommender.v1beta1.IInsight, - protos.google.cloud.recommender.v1beta1.IGetInsightRequest|null|undefined, - {}|null|undefined>): void; - getInsight( - request: protos.google.cloud.recommender.v1beta1.IGetInsightRequest, - callback: Callback< - protos.google.cloud.recommender.v1beta1.IInsight, - protos.google.cloud.recommender.v1beta1.IGetInsightRequest|null|undefined, - {}|null|undefined>): void; - getInsight( - request?: protos.google.cloud.recommender.v1beta1.IGetInsightRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recommender.v1beta1.IInsight, - protos.google.cloud.recommender.v1beta1.IGetInsightRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recommender.v1beta1.IInsight, - protos.google.cloud.recommender.v1beta1.IGetInsightRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recommender.v1beta1.IInsight, - protos.google.cloud.recommender.v1beta1.IGetInsightRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getInsight(request, options, callback); - } -/** - * Marks the Insight State as Accepted. Users can use this method to - * indicate to the Recommender API that they have applied some action based - * on the insight. This stops the insight content from being updated. - * - * MarkInsightAccepted can be applied to insights in ACTIVE state. Requires - * the recommender.*.update IAM permission for the specified insight. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the insight. - * @param {number[]} [request.stateMetadata] - * Optional. State properties user wish to include with this state. Full replace of the - * current state_metadata. - * @param {string} request.etag - * Required. Fingerprint of the Insight. Provides optimistic locking. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1beta1.Insight|Insight}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/recommender.mark_insight_accepted.js - * region_tag:recommender_v1beta1_generated_Recommender_MarkInsightAccepted_async - */ - markInsightAccepted( - request?: protos.google.cloud.recommender.v1beta1.IMarkInsightAcceptedRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1beta1.IInsight, - protos.google.cloud.recommender.v1beta1.IMarkInsightAcceptedRequest|undefined, {}|undefined - ]>; - markInsightAccepted( - request: protos.google.cloud.recommender.v1beta1.IMarkInsightAcceptedRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recommender.v1beta1.IInsight, - protos.google.cloud.recommender.v1beta1.IMarkInsightAcceptedRequest|null|undefined, - {}|null|undefined>): void; - markInsightAccepted( - request: protos.google.cloud.recommender.v1beta1.IMarkInsightAcceptedRequest, - callback: Callback< - protos.google.cloud.recommender.v1beta1.IInsight, - protos.google.cloud.recommender.v1beta1.IMarkInsightAcceptedRequest|null|undefined, - {}|null|undefined>): void; - markInsightAccepted( - request?: protos.google.cloud.recommender.v1beta1.IMarkInsightAcceptedRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recommender.v1beta1.IInsight, - protos.google.cloud.recommender.v1beta1.IMarkInsightAcceptedRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recommender.v1beta1.IInsight, - protos.google.cloud.recommender.v1beta1.IMarkInsightAcceptedRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recommender.v1beta1.IInsight, - protos.google.cloud.recommender.v1beta1.IMarkInsightAcceptedRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.markInsightAccepted(request, options, callback); - } -/** - * Gets the requested recommendation. Requires the recommender.*.get - * IAM permission for the specified recommender. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the recommendation. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1beta1.Recommendation|Recommendation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/recommender.get_recommendation.js - * region_tag:recommender_v1beta1_generated_Recommender_GetRecommendation_async - */ - getRecommendation( - request?: protos.google.cloud.recommender.v1beta1.IGetRecommendationRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IGetRecommendationRequest|undefined, {}|undefined - ]>; - getRecommendation( - request: protos.google.cloud.recommender.v1beta1.IGetRecommendationRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IGetRecommendationRequest|null|undefined, - {}|null|undefined>): void; - getRecommendation( - request: protos.google.cloud.recommender.v1beta1.IGetRecommendationRequest, - callback: Callback< - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IGetRecommendationRequest|null|undefined, - {}|null|undefined>): void; - getRecommendation( - request?: protos.google.cloud.recommender.v1beta1.IGetRecommendationRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IGetRecommendationRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IGetRecommendationRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IGetRecommendationRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getRecommendation(request, options, callback); - } -/** - * Marks the Recommendation State as Claimed. Users can use this method to - * indicate to the Recommender API that they are starting to apply the - * recommendation themselves. This stops the recommendation content from being - * updated. Associated insights are frozen and placed in the ACCEPTED state. - * - * MarkRecommendationClaimed can be applied to recommendations in CLAIMED or - * ACTIVE state. - * - * Requires the recommender.*.update IAM permission for the specified - * recommender. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the recommendation. - * @param {number[]} request.stateMetadata - * State properties to include with this state. Overwrites any existing - * `state_metadata`. - * Keys must match the regex `/^{@link protos.a-z0-9_.-|a-z0-9}{0,62}$/`. - * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. - * @param {string} request.etag - * Required. Fingerprint of the Recommendation. Provides optimistic locking. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1beta1.Recommendation|Recommendation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/recommender.mark_recommendation_claimed.js - * region_tag:recommender_v1beta1_generated_Recommender_MarkRecommendationClaimed_async - */ - markRecommendationClaimed( - request?: protos.google.cloud.recommender.v1beta1.IMarkRecommendationClaimedRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IMarkRecommendationClaimedRequest|undefined, {}|undefined - ]>; - markRecommendationClaimed( - request: protos.google.cloud.recommender.v1beta1.IMarkRecommendationClaimedRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IMarkRecommendationClaimedRequest|null|undefined, - {}|null|undefined>): void; - markRecommendationClaimed( - request: protos.google.cloud.recommender.v1beta1.IMarkRecommendationClaimedRequest, - callback: Callback< - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IMarkRecommendationClaimedRequest|null|undefined, - {}|null|undefined>): void; - markRecommendationClaimed( - request?: protos.google.cloud.recommender.v1beta1.IMarkRecommendationClaimedRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IMarkRecommendationClaimedRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IMarkRecommendationClaimedRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IMarkRecommendationClaimedRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.markRecommendationClaimed(request, options, callback); - } -/** - * Marks the Recommendation State as Succeeded. Users can use this method to - * indicate to the Recommender API that they have applied the recommendation - * themselves, and the operation was successful. This stops the recommendation - * content from being updated. Associated insights are frozen and placed in - * the ACCEPTED state. - * - * MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, - * CLAIMED, SUCCEEDED, or FAILED state. - * - * Requires the recommender.*.update IAM permission for the specified - * recommender. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the recommendation. - * @param {number[]} request.stateMetadata - * State properties to include with this state. Overwrites any existing - * `state_metadata`. - * Keys must match the regex `/^{@link protos.a-z0-9_.-|a-z0-9}{0,62}$/`. - * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. - * @param {string} request.etag - * Required. Fingerprint of the Recommendation. Provides optimistic locking. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1beta1.Recommendation|Recommendation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/recommender.mark_recommendation_succeeded.js - * region_tag:recommender_v1beta1_generated_Recommender_MarkRecommendationSucceeded_async - */ - markRecommendationSucceeded( - request?: protos.google.cloud.recommender.v1beta1.IMarkRecommendationSucceededRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IMarkRecommendationSucceededRequest|undefined, {}|undefined - ]>; - markRecommendationSucceeded( - request: protos.google.cloud.recommender.v1beta1.IMarkRecommendationSucceededRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IMarkRecommendationSucceededRequest|null|undefined, - {}|null|undefined>): void; - markRecommendationSucceeded( - request: protos.google.cloud.recommender.v1beta1.IMarkRecommendationSucceededRequest, - callback: Callback< - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IMarkRecommendationSucceededRequest|null|undefined, - {}|null|undefined>): void; - markRecommendationSucceeded( - request?: protos.google.cloud.recommender.v1beta1.IMarkRecommendationSucceededRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IMarkRecommendationSucceededRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IMarkRecommendationSucceededRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IMarkRecommendationSucceededRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.markRecommendationSucceeded(request, options, callback); - } -/** - * Marks the Recommendation State as Failed. Users can use this method to - * indicate to the Recommender API that they have applied the recommendation - * themselves, and the operation failed. This stops the recommendation content - * from being updated. Associated insights are frozen and placed in the - * ACCEPTED state. - * - * MarkRecommendationFailed can be applied to recommendations in ACTIVE, - * CLAIMED, SUCCEEDED, or FAILED state. - * - * Requires the recommender.*.update IAM permission for the specified - * recommender. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the recommendation. - * @param {number[]} request.stateMetadata - * State properties to include with this state. Overwrites any existing - * `state_metadata`. - * Keys must match the regex `/^{@link protos.a-z0-9_.-|a-z0-9}{0,62}$/`. - * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. - * @param {string} request.etag - * Required. Fingerprint of the Recommendation. Provides optimistic locking. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1beta1.Recommendation|Recommendation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/recommender.mark_recommendation_failed.js - * region_tag:recommender_v1beta1_generated_Recommender_MarkRecommendationFailed_async - */ - markRecommendationFailed( - request?: protos.google.cloud.recommender.v1beta1.IMarkRecommendationFailedRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IMarkRecommendationFailedRequest|undefined, {}|undefined - ]>; - markRecommendationFailed( - request: protos.google.cloud.recommender.v1beta1.IMarkRecommendationFailedRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IMarkRecommendationFailedRequest|null|undefined, - {}|null|undefined>): void; - markRecommendationFailed( - request: protos.google.cloud.recommender.v1beta1.IMarkRecommendationFailedRequest, - callback: Callback< - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IMarkRecommendationFailedRequest|null|undefined, - {}|null|undefined>): void; - markRecommendationFailed( - request?: protos.google.cloud.recommender.v1beta1.IMarkRecommendationFailedRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IMarkRecommendationFailedRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IMarkRecommendationFailedRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recommender.v1beta1.IRecommendation, - protos.google.cloud.recommender.v1beta1.IMarkRecommendationFailedRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.markRecommendationFailed(request, options, callback); - } -/** - * Gets the requested Recommender Config. There is only one instance of the - * config for each Recommender. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the Recommendation Config to get. - * - * Acceptable formats: - * - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` - * - * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` - * - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/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 protos.google.cloud.recommender.v1beta1.RecommenderConfig|RecommenderConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/recommender.get_recommender_config.js - * region_tag:recommender_v1beta1_generated_Recommender_GetRecommenderConfig_async - */ - getRecommenderConfig( - request?: protos.google.cloud.recommender.v1beta1.IGetRecommenderConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1beta1.IRecommenderConfig, - protos.google.cloud.recommender.v1beta1.IGetRecommenderConfigRequest|undefined, {}|undefined - ]>; - getRecommenderConfig( - request: protos.google.cloud.recommender.v1beta1.IGetRecommenderConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recommender.v1beta1.IRecommenderConfig, - protos.google.cloud.recommender.v1beta1.IGetRecommenderConfigRequest|null|undefined, - {}|null|undefined>): void; - getRecommenderConfig( - request: protos.google.cloud.recommender.v1beta1.IGetRecommenderConfigRequest, - callback: Callback< - protos.google.cloud.recommender.v1beta1.IRecommenderConfig, - protos.google.cloud.recommender.v1beta1.IGetRecommenderConfigRequest|null|undefined, - {}|null|undefined>): void; - getRecommenderConfig( - request?: protos.google.cloud.recommender.v1beta1.IGetRecommenderConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recommender.v1beta1.IRecommenderConfig, - protos.google.cloud.recommender.v1beta1.IGetRecommenderConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recommender.v1beta1.IRecommenderConfig, - protos.google.cloud.recommender.v1beta1.IGetRecommenderConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recommender.v1beta1.IRecommenderConfig, - protos.google.cloud.recommender.v1beta1.IGetRecommenderConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getRecommenderConfig(request, options, callback); - } -/** - * Updates a Recommender Config. This will create a new revision of the - * config. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.recommender.v1beta1.RecommenderConfig} request.recommenderConfig - * Required. The RecommenderConfig to update. - * @param {google.protobuf.FieldMask} request.updateMask - * The list of fields to be updated. - * @param {boolean} request.validateOnly - * If true, validate the request and preview the change, but do not actually - * update it. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1beta1.RecommenderConfig|RecommenderConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/recommender.update_recommender_config.js - * region_tag:recommender_v1beta1_generated_Recommender_UpdateRecommenderConfig_async - */ - updateRecommenderConfig( - request?: protos.google.cloud.recommender.v1beta1.IUpdateRecommenderConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1beta1.IRecommenderConfig, - protos.google.cloud.recommender.v1beta1.IUpdateRecommenderConfigRequest|undefined, {}|undefined - ]>; - updateRecommenderConfig( - request: protos.google.cloud.recommender.v1beta1.IUpdateRecommenderConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recommender.v1beta1.IRecommenderConfig, - protos.google.cloud.recommender.v1beta1.IUpdateRecommenderConfigRequest|null|undefined, - {}|null|undefined>): void; - updateRecommenderConfig( - request: protos.google.cloud.recommender.v1beta1.IUpdateRecommenderConfigRequest, - callback: Callback< - protos.google.cloud.recommender.v1beta1.IRecommenderConfig, - protos.google.cloud.recommender.v1beta1.IUpdateRecommenderConfigRequest|null|undefined, - {}|null|undefined>): void; - updateRecommenderConfig( - request?: protos.google.cloud.recommender.v1beta1.IUpdateRecommenderConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recommender.v1beta1.IRecommenderConfig, - protos.google.cloud.recommender.v1beta1.IUpdateRecommenderConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recommender.v1beta1.IRecommenderConfig, - protos.google.cloud.recommender.v1beta1.IUpdateRecommenderConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recommender.v1beta1.IRecommenderConfig, - protos.google.cloud.recommender.v1beta1.IUpdateRecommenderConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'recommender_config.name': request.recommenderConfig!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateRecommenderConfig(request, options, callback); - } -/** - * Gets the requested InsightTypeConfig. There is only one instance of the - * config for each InsightType. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the InsightTypeConfig to get. - * - * Acceptable formats: - * - * * `projects/[PROJECT_NUMBER]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` - * - * * `projects/[PROJECT_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config` - * - * * `organizations/[ORGANIZATION_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/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 protos.google.cloud.recommender.v1beta1.InsightTypeConfig|InsightTypeConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/recommender.get_insight_type_config.js - * region_tag:recommender_v1beta1_generated_Recommender_GetInsightTypeConfig_async - */ - getInsightTypeConfig( - request?: protos.google.cloud.recommender.v1beta1.IGetInsightTypeConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, - protos.google.cloud.recommender.v1beta1.IGetInsightTypeConfigRequest|undefined, {}|undefined - ]>; - getInsightTypeConfig( - request: protos.google.cloud.recommender.v1beta1.IGetInsightTypeConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, - protos.google.cloud.recommender.v1beta1.IGetInsightTypeConfigRequest|null|undefined, - {}|null|undefined>): void; - getInsightTypeConfig( - request: protos.google.cloud.recommender.v1beta1.IGetInsightTypeConfigRequest, - callback: Callback< - protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, - protos.google.cloud.recommender.v1beta1.IGetInsightTypeConfigRequest|null|undefined, - {}|null|undefined>): void; - getInsightTypeConfig( - request?: protos.google.cloud.recommender.v1beta1.IGetInsightTypeConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, - protos.google.cloud.recommender.v1beta1.IGetInsightTypeConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, - protos.google.cloud.recommender.v1beta1.IGetInsightTypeConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, - protos.google.cloud.recommender.v1beta1.IGetInsightTypeConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getInsightTypeConfig(request, options, callback); - } -/** - * Updates an InsightTypeConfig change. This will create a new revision of the - * config. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.recommender.v1beta1.InsightTypeConfig} request.insightTypeConfig - * Required. The InsightTypeConfig to update. - * @param {google.protobuf.FieldMask} request.updateMask - * The list of fields to be updated. - * @param {boolean} request.validateOnly - * If true, validate the request and preview the change, but do not actually - * update it. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.recommender.v1beta1.InsightTypeConfig|InsightTypeConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/recommender.update_insight_type_config.js - * region_tag:recommender_v1beta1_generated_Recommender_UpdateInsightTypeConfig_async - */ - updateInsightTypeConfig( - request?: protos.google.cloud.recommender.v1beta1.IUpdateInsightTypeConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, - protos.google.cloud.recommender.v1beta1.IUpdateInsightTypeConfigRequest|undefined, {}|undefined - ]>; - updateInsightTypeConfig( - request: protos.google.cloud.recommender.v1beta1.IUpdateInsightTypeConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, - protos.google.cloud.recommender.v1beta1.IUpdateInsightTypeConfigRequest|null|undefined, - {}|null|undefined>): void; - updateInsightTypeConfig( - request: protos.google.cloud.recommender.v1beta1.IUpdateInsightTypeConfigRequest, - callback: Callback< - protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, - protos.google.cloud.recommender.v1beta1.IUpdateInsightTypeConfigRequest|null|undefined, - {}|null|undefined>): void; - updateInsightTypeConfig( - request?: protos.google.cloud.recommender.v1beta1.IUpdateInsightTypeConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, - protos.google.cloud.recommender.v1beta1.IUpdateInsightTypeConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, - protos.google.cloud.recommender.v1beta1.IUpdateInsightTypeConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recommender.v1beta1.IInsightTypeConfig, - protos.google.cloud.recommender.v1beta1.IUpdateInsightTypeConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'insight_type_config.name': request.insightTypeConfig!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateInsightTypeConfig(request, options, callback); - } - - /** - * Lists insights for the specified Cloud Resource. Requires the - * recommender.*.list IAM permission for the specified insight type. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The container resource on which to execute the request. - * Acceptable formats: - * - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * LOCATION here refers to GCP Locations: - * https://cloud.google.com/about/locations/ - * INSIGHT_TYPE_ID refers to supported insight types: - * https://cloud.google.com/recommender/docs/insights/insight-types. - * @param {number} [request.pageSize] - * Optional. The maximum number of results to return from this request. Non-positive - * values are ignored. If not specified, the server will determine the number - * of results to return. - * @param {string} [request.pageToken] - * Optional. If present, retrieves the next batch of results from the preceding call to - * this method. `page_token` must be the value of `next_page_token` from the - * previous response. The values of other method parameters must be identical - * to those in the previous call. - * @param {string} [request.filter] - * Optional. Filter expression to restrict the insights returned. Supported - * filter fields: - * - * * `stateInfo.state` - * - * * `insightSubtype` - * - * * `severity` - * - * Examples: - * - * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - * - * * `insightSubtype = PERMISSIONS_USAGE` - * - * * `severity = CRITICAL OR severity = HIGH` - * - * * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` - * - * (These expressions are based on the filter language described at - * https://google.aip.dev/160) - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.recommender.v1beta1.Insight|Insight}. - * 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 `listInsightsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listInsights( - request?: protos.google.cloud.recommender.v1beta1.IListInsightsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1beta1.IInsight[], - protos.google.cloud.recommender.v1beta1.IListInsightsRequest|null, - protos.google.cloud.recommender.v1beta1.IListInsightsResponse - ]>; - listInsights( - request: protos.google.cloud.recommender.v1beta1.IListInsightsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.recommender.v1beta1.IListInsightsRequest, - protos.google.cloud.recommender.v1beta1.IListInsightsResponse|null|undefined, - protos.google.cloud.recommender.v1beta1.IInsight>): void; - listInsights( - request: protos.google.cloud.recommender.v1beta1.IListInsightsRequest, - callback: PaginationCallback< - protos.google.cloud.recommender.v1beta1.IListInsightsRequest, - protos.google.cloud.recommender.v1beta1.IListInsightsResponse|null|undefined, - protos.google.cloud.recommender.v1beta1.IInsight>): void; - listInsights( - request?: protos.google.cloud.recommender.v1beta1.IListInsightsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.recommender.v1beta1.IListInsightsRequest, - protos.google.cloud.recommender.v1beta1.IListInsightsResponse|null|undefined, - protos.google.cloud.recommender.v1beta1.IInsight>, - callback?: PaginationCallback< - protos.google.cloud.recommender.v1beta1.IListInsightsRequest, - protos.google.cloud.recommender.v1beta1.IListInsightsResponse|null|undefined, - protos.google.cloud.recommender.v1beta1.IInsight>): - Promise<[ - protos.google.cloud.recommender.v1beta1.IInsight[], - protos.google.cloud.recommender.v1beta1.IListInsightsRequest|null, - protos.google.cloud.recommender.v1beta1.IListInsightsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listInsights(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 container resource on which to execute the request. - * Acceptable formats: - * - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * LOCATION here refers to GCP Locations: - * https://cloud.google.com/about/locations/ - * INSIGHT_TYPE_ID refers to supported insight types: - * https://cloud.google.com/recommender/docs/insights/insight-types. - * @param {number} [request.pageSize] - * Optional. The maximum number of results to return from this request. Non-positive - * values are ignored. If not specified, the server will determine the number - * of results to return. - * @param {string} [request.pageToken] - * Optional. If present, retrieves the next batch of results from the preceding call to - * this method. `page_token` must be the value of `next_page_token` from the - * previous response. The values of other method parameters must be identical - * to those in the previous call. - * @param {string} [request.filter] - * Optional. Filter expression to restrict the insights returned. Supported - * filter fields: - * - * * `stateInfo.state` - * - * * `insightSubtype` - * - * * `severity` - * - * Examples: - * - * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - * - * * `insightSubtype = PERMISSIONS_USAGE` - * - * * `severity = CRITICAL OR severity = HIGH` - * - * * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` - * - * (These expressions are based on the filter language described at - * https://google.aip.dev/160) - * @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 protos.google.cloud.recommender.v1beta1.Insight|Insight} 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 `listInsightsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listInsightsStream( - request?: protos.google.cloud.recommender.v1beta1.IListInsightsRequest, - 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['listInsights']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInsights.createStream( - this.innerApiCalls.listInsights as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listInsights`, 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 container resource on which to execute the request. - * Acceptable formats: - * - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * LOCATION here refers to GCP Locations: - * https://cloud.google.com/about/locations/ - * INSIGHT_TYPE_ID refers to supported insight types: - * https://cloud.google.com/recommender/docs/insights/insight-types. - * @param {number} [request.pageSize] - * Optional. The maximum number of results to return from this request. Non-positive - * values are ignored. If not specified, the server will determine the number - * of results to return. - * @param {string} [request.pageToken] - * Optional. If present, retrieves the next batch of results from the preceding call to - * this method. `page_token` must be the value of `next_page_token` from the - * previous response. The values of other method parameters must be identical - * to those in the previous call. - * @param {string} [request.filter] - * Optional. Filter expression to restrict the insights returned. Supported - * filter fields: - * - * * `stateInfo.state` - * - * * `insightSubtype` - * - * * `severity` - * - * Examples: - * - * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - * - * * `insightSubtype = PERMISSIONS_USAGE` - * - * * `severity = CRITICAL OR severity = HIGH` - * - * * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` - * - * (These expressions are based on the filter language described at - * https://google.aip.dev/160) - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.recommender.v1beta1.Insight|Insight}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/recommender.list_insights.js - * region_tag:recommender_v1beta1_generated_Recommender_ListInsights_async - */ - listInsightsAsync( - request?: protos.google.cloud.recommender.v1beta1.IListInsightsRequest, - 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['listInsights']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInsights.asyncIterate( - this.innerApiCalls['listInsights'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists recommendations for the specified Cloud Resource. Requires the - * recommender.*.list IAM permission for the specified recommender. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The container resource on which to execute the request. - * Acceptable formats: - * - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * LOCATION here refers to GCP Locations: - * https://cloud.google.com/about/locations/ - * RECOMMENDER_ID refers to supported recommenders: - * https://cloud.google.com/recommender/docs/recommenders. - * @param {number} [request.pageSize] - * Optional. The maximum number of results to return from this request. Non-positive - * values are ignored. If not specified, the server will determine the number - * of results to return. - * @param {string} [request.pageToken] - * Optional. If present, retrieves the next batch of results from the preceding call to - * this method. `page_token` must be the value of `next_page_token` from the - * previous response. The values of other method parameters must be identical - * to those in the previous call. - * @param {string} request.filter - * Filter expression to restrict the recommendations returned. Supported - * filter fields: - * - * * `state_info.state` - * - * * `recommenderSubtype` - * - * * `priority` - * - * Examples: - * - * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - * - * * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` - * - * * `priority = P1 OR priority = P2` - * - * * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` - * - * (These expressions are based on the filter language described at - * https://google.aip.dev/160) - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.recommender.v1beta1.Recommendation|Recommendation}. - * 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 `listRecommendationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listRecommendations( - request?: protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recommender.v1beta1.IRecommendation[], - protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest|null, - protos.google.cloud.recommender.v1beta1.IListRecommendationsResponse - ]>; - listRecommendations( - request: protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest, - protos.google.cloud.recommender.v1beta1.IListRecommendationsResponse|null|undefined, - protos.google.cloud.recommender.v1beta1.IRecommendation>): void; - listRecommendations( - request: protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest, - callback: PaginationCallback< - protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest, - protos.google.cloud.recommender.v1beta1.IListRecommendationsResponse|null|undefined, - protos.google.cloud.recommender.v1beta1.IRecommendation>): void; - listRecommendations( - request?: protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest, - protos.google.cloud.recommender.v1beta1.IListRecommendationsResponse|null|undefined, - protos.google.cloud.recommender.v1beta1.IRecommendation>, - callback?: PaginationCallback< - protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest, - protos.google.cloud.recommender.v1beta1.IListRecommendationsResponse|null|undefined, - protos.google.cloud.recommender.v1beta1.IRecommendation>): - Promise<[ - protos.google.cloud.recommender.v1beta1.IRecommendation[], - protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest|null, - protos.google.cloud.recommender.v1beta1.IListRecommendationsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listRecommendations(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 container resource on which to execute the request. - * Acceptable formats: - * - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * LOCATION here refers to GCP Locations: - * https://cloud.google.com/about/locations/ - * RECOMMENDER_ID refers to supported recommenders: - * https://cloud.google.com/recommender/docs/recommenders. - * @param {number} [request.pageSize] - * Optional. The maximum number of results to return from this request. Non-positive - * values are ignored. If not specified, the server will determine the number - * of results to return. - * @param {string} [request.pageToken] - * Optional. If present, retrieves the next batch of results from the preceding call to - * this method. `page_token` must be the value of `next_page_token` from the - * previous response. The values of other method parameters must be identical - * to those in the previous call. - * @param {string} request.filter - * Filter expression to restrict the recommendations returned. Supported - * filter fields: - * - * * `state_info.state` - * - * * `recommenderSubtype` - * - * * `priority` - * - * Examples: - * - * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - * - * * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` - * - * * `priority = P1 OR priority = P2` - * - * * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` - * - * (These expressions are based on the filter language described at - * https://google.aip.dev/160) - * @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 protos.google.cloud.recommender.v1beta1.Recommendation|Recommendation} 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 `listRecommendationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listRecommendationsStream( - request?: protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest, - 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['listRecommendations']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRecommendations.createStream( - this.innerApiCalls.listRecommendations as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listRecommendations`, 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 container resource on which to execute the request. - * Acceptable formats: - * - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * LOCATION here refers to GCP Locations: - * https://cloud.google.com/about/locations/ - * RECOMMENDER_ID refers to supported recommenders: - * https://cloud.google.com/recommender/docs/recommenders. - * @param {number} [request.pageSize] - * Optional. The maximum number of results to return from this request. Non-positive - * values are ignored. If not specified, the server will determine the number - * of results to return. - * @param {string} [request.pageToken] - * Optional. If present, retrieves the next batch of results from the preceding call to - * this method. `page_token` must be the value of `next_page_token` from the - * previous response. The values of other method parameters must be identical - * to those in the previous call. - * @param {string} request.filter - * Filter expression to restrict the recommendations returned. Supported - * filter fields: - * - * * `state_info.state` - * - * * `recommenderSubtype` - * - * * `priority` - * - * Examples: - * - * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - * - * * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` - * - * * `priority = P1 OR priority = P2` - * - * * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` - * - * (These expressions are based on the filter language described at - * https://google.aip.dev/160) - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.recommender.v1beta1.Recommendation|Recommendation}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/recommender.list_recommendations.js - * region_tag:recommender_v1beta1_generated_Recommender_ListRecommendations_async - */ - listRecommendationsAsync( - request?: protos.google.cloud.recommender.v1beta1.IListRecommendationsRequest, - 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['listRecommendations']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRecommendations.asyncIterate( - this.innerApiCalls['listRecommendations'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified billingAccountLocationInsightType resource name string. - * - * @param {string} billing_account - * @param {string} location - * @param {string} insight_type - * @returns {string} Resource name string. - */ - billingAccountLocationInsightTypePath(billingAccount:string,location:string,insightType:string) { - return this.pathTemplates.billingAccountLocationInsightTypePathTemplate.render({ - billing_account: billingAccount, - location: location, - insight_type: insightType, - }); - } - - /** - * Parse the billing_account from BillingAccountLocationInsightType resource. - * - * @param {string} billingAccountLocationInsightTypeName - * A fully-qualified path representing billing_account_location_insight_type resource. - * @returns {string} A string representing the billing_account. - */ - matchBillingAccountFromBillingAccountLocationInsightTypeName(billingAccountLocationInsightTypeName: string) { - return this.pathTemplates.billingAccountLocationInsightTypePathTemplate.match(billingAccountLocationInsightTypeName).billing_account; - } - - /** - * Parse the location from BillingAccountLocationInsightType resource. - * - * @param {string} billingAccountLocationInsightTypeName - * A fully-qualified path representing billing_account_location_insight_type resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBillingAccountLocationInsightTypeName(billingAccountLocationInsightTypeName: string) { - return this.pathTemplates.billingAccountLocationInsightTypePathTemplate.match(billingAccountLocationInsightTypeName).location; - } - - /** - * Parse the insight_type from BillingAccountLocationInsightType resource. - * - * @param {string} billingAccountLocationInsightTypeName - * A fully-qualified path representing billing_account_location_insight_type resource. - * @returns {string} A string representing the insight_type. - */ - matchInsightTypeFromBillingAccountLocationInsightTypeName(billingAccountLocationInsightTypeName: string) { - return this.pathTemplates.billingAccountLocationInsightTypePathTemplate.match(billingAccountLocationInsightTypeName).insight_type; - } - - /** - * Return a fully-qualified billingAccountLocationInsightTypeInsight resource name string. - * - * @param {string} billing_account - * @param {string} location - * @param {string} insight_type - * @param {string} insight - * @returns {string} Resource name string. - */ - billingAccountLocationInsightTypeInsightPath(billingAccount:string,location:string,insightType:string,insight:string) { - return this.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.render({ - billing_account: billingAccount, - location: location, - insight_type: insightType, - insight: insight, - }); - } - - /** - * Parse the billing_account from BillingAccountLocationInsightTypeInsight resource. - * - * @param {string} billingAccountLocationInsightTypeInsightName - * A fully-qualified path representing billing_account_location_insight_type_insight resource. - * @returns {string} A string representing the billing_account. - */ - matchBillingAccountFromBillingAccountLocationInsightTypeInsightName(billingAccountLocationInsightTypeInsightName: string) { - return this.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match(billingAccountLocationInsightTypeInsightName).billing_account; - } - - /** - * Parse the location from BillingAccountLocationInsightTypeInsight resource. - * - * @param {string} billingAccountLocationInsightTypeInsightName - * A fully-qualified path representing billing_account_location_insight_type_insight resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBillingAccountLocationInsightTypeInsightName(billingAccountLocationInsightTypeInsightName: string) { - return this.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match(billingAccountLocationInsightTypeInsightName).location; - } - - /** - * Parse the insight_type from BillingAccountLocationInsightTypeInsight resource. - * - * @param {string} billingAccountLocationInsightTypeInsightName - * A fully-qualified path representing billing_account_location_insight_type_insight resource. - * @returns {string} A string representing the insight_type. - */ - matchInsightTypeFromBillingAccountLocationInsightTypeInsightName(billingAccountLocationInsightTypeInsightName: string) { - return this.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match(billingAccountLocationInsightTypeInsightName).insight_type; - } - - /** - * Parse the insight from BillingAccountLocationInsightTypeInsight resource. - * - * @param {string} billingAccountLocationInsightTypeInsightName - * A fully-qualified path representing billing_account_location_insight_type_insight resource. - * @returns {string} A string representing the insight. - */ - matchInsightFromBillingAccountLocationInsightTypeInsightName(billingAccountLocationInsightTypeInsightName: string) { - return this.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match(billingAccountLocationInsightTypeInsightName).insight; - } - - /** - * Return a fully-qualified billingAccountLocationRecommender resource name string. - * - * @param {string} billing_account - * @param {string} location - * @param {string} recommender - * @returns {string} Resource name string. - */ - billingAccountLocationRecommenderPath(billingAccount:string,location:string,recommender:string) { - return this.pathTemplates.billingAccountLocationRecommenderPathTemplate.render({ - billing_account: billingAccount, - location: location, - recommender: recommender, - }); - } - - /** - * Parse the billing_account from BillingAccountLocationRecommender resource. - * - * @param {string} billingAccountLocationRecommenderName - * A fully-qualified path representing billing_account_location_recommender resource. - * @returns {string} A string representing the billing_account. - */ - matchBillingAccountFromBillingAccountLocationRecommenderName(billingAccountLocationRecommenderName: string) { - return this.pathTemplates.billingAccountLocationRecommenderPathTemplate.match(billingAccountLocationRecommenderName).billing_account; - } - - /** - * Parse the location from BillingAccountLocationRecommender resource. - * - * @param {string} billingAccountLocationRecommenderName - * A fully-qualified path representing billing_account_location_recommender resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBillingAccountLocationRecommenderName(billingAccountLocationRecommenderName: string) { - return this.pathTemplates.billingAccountLocationRecommenderPathTemplate.match(billingAccountLocationRecommenderName).location; - } - - /** - * Parse the recommender from BillingAccountLocationRecommender resource. - * - * @param {string} billingAccountLocationRecommenderName - * A fully-qualified path representing billing_account_location_recommender resource. - * @returns {string} A string representing the recommender. - */ - matchRecommenderFromBillingAccountLocationRecommenderName(billingAccountLocationRecommenderName: string) { - return this.pathTemplates.billingAccountLocationRecommenderPathTemplate.match(billingAccountLocationRecommenderName).recommender; - } - - /** - * Return a fully-qualified billingAccountLocationRecommenderRecommendation resource name string. - * - * @param {string} billing_account - * @param {string} location - * @param {string} recommender - * @param {string} recommendation - * @returns {string} Resource name string. - */ - billingAccountLocationRecommenderRecommendationPath(billingAccount:string,location:string,recommender:string,recommendation:string) { - return this.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.render({ - billing_account: billingAccount, - location: location, - recommender: recommender, - recommendation: recommendation, - }); - } - - /** - * Parse the billing_account from BillingAccountLocationRecommenderRecommendation resource. - * - * @param {string} billingAccountLocationRecommenderRecommendationName - * A fully-qualified path representing billing_account_location_recommender_recommendation resource. - * @returns {string} A string representing the billing_account. - */ - matchBillingAccountFromBillingAccountLocationRecommenderRecommendationName(billingAccountLocationRecommenderRecommendationName: string) { - return this.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match(billingAccountLocationRecommenderRecommendationName).billing_account; - } - - /** - * Parse the location from BillingAccountLocationRecommenderRecommendation resource. - * - * @param {string} billingAccountLocationRecommenderRecommendationName - * A fully-qualified path representing billing_account_location_recommender_recommendation resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBillingAccountLocationRecommenderRecommendationName(billingAccountLocationRecommenderRecommendationName: string) { - return this.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match(billingAccountLocationRecommenderRecommendationName).location; - } - - /** - * Parse the recommender from BillingAccountLocationRecommenderRecommendation resource. - * - * @param {string} billingAccountLocationRecommenderRecommendationName - * A fully-qualified path representing billing_account_location_recommender_recommendation resource. - * @returns {string} A string representing the recommender. - */ - matchRecommenderFromBillingAccountLocationRecommenderRecommendationName(billingAccountLocationRecommenderRecommendationName: string) { - return this.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match(billingAccountLocationRecommenderRecommendationName).recommender; - } - - /** - * Parse the recommendation from BillingAccountLocationRecommenderRecommendation resource. - * - * @param {string} billingAccountLocationRecommenderRecommendationName - * A fully-qualified path representing billing_account_location_recommender_recommendation resource. - * @returns {string} A string representing the recommendation. - */ - matchRecommendationFromBillingAccountLocationRecommenderRecommendationName(billingAccountLocationRecommenderRecommendationName: string) { - return this.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match(billingAccountLocationRecommenderRecommendationName).recommendation; - } - - /** - * Return a fully-qualified folderLocationInsightType resource name string. - * - * @param {string} folder - * @param {string} location - * @param {string} insight_type - * @returns {string} Resource name string. - */ - folderLocationInsightTypePath(folder:string,location:string,insightType:string) { - return this.pathTemplates.folderLocationInsightTypePathTemplate.render({ - folder: folder, - location: location, - insight_type: insightType, - }); - } - - /** - * Parse the folder from FolderLocationInsightType resource. - * - * @param {string} folderLocationInsightTypeName - * A fully-qualified path representing folder_location_insight_type resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderLocationInsightTypeName(folderLocationInsightTypeName: string) { - return this.pathTemplates.folderLocationInsightTypePathTemplate.match(folderLocationInsightTypeName).folder; - } - - /** - * Parse the location from FolderLocationInsightType resource. - * - * @param {string} folderLocationInsightTypeName - * A fully-qualified path representing folder_location_insight_type resource. - * @returns {string} A string representing the location. - */ - matchLocationFromFolderLocationInsightTypeName(folderLocationInsightTypeName: string) { - return this.pathTemplates.folderLocationInsightTypePathTemplate.match(folderLocationInsightTypeName).location; - } - - /** - * Parse the insight_type from FolderLocationInsightType resource. - * - * @param {string} folderLocationInsightTypeName - * A fully-qualified path representing folder_location_insight_type resource. - * @returns {string} A string representing the insight_type. - */ - matchInsightTypeFromFolderLocationInsightTypeName(folderLocationInsightTypeName: string) { - return this.pathTemplates.folderLocationInsightTypePathTemplate.match(folderLocationInsightTypeName).insight_type; - } - - /** - * Return a fully-qualified folderLocationInsightTypeInsight resource name string. - * - * @param {string} folder - * @param {string} location - * @param {string} insight_type - * @param {string} insight - * @returns {string} Resource name string. - */ - folderLocationInsightTypeInsightPath(folder:string,location:string,insightType:string,insight:string) { - return this.pathTemplates.folderLocationInsightTypeInsightPathTemplate.render({ - folder: folder, - location: location, - insight_type: insightType, - insight: insight, - }); - } - - /** - * Parse the folder from FolderLocationInsightTypeInsight resource. - * - * @param {string} folderLocationInsightTypeInsightName - * A fully-qualified path representing folder_location_insight_type_insight resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderLocationInsightTypeInsightName(folderLocationInsightTypeInsightName: string) { - return this.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match(folderLocationInsightTypeInsightName).folder; - } - - /** - * Parse the location from FolderLocationInsightTypeInsight resource. - * - * @param {string} folderLocationInsightTypeInsightName - * A fully-qualified path representing folder_location_insight_type_insight resource. - * @returns {string} A string representing the location. - */ - matchLocationFromFolderLocationInsightTypeInsightName(folderLocationInsightTypeInsightName: string) { - return this.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match(folderLocationInsightTypeInsightName).location; - } - - /** - * Parse the insight_type from FolderLocationInsightTypeInsight resource. - * - * @param {string} folderLocationInsightTypeInsightName - * A fully-qualified path representing folder_location_insight_type_insight resource. - * @returns {string} A string representing the insight_type. - */ - matchInsightTypeFromFolderLocationInsightTypeInsightName(folderLocationInsightTypeInsightName: string) { - return this.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match(folderLocationInsightTypeInsightName).insight_type; - } - - /** - * Parse the insight from FolderLocationInsightTypeInsight resource. - * - * @param {string} folderLocationInsightTypeInsightName - * A fully-qualified path representing folder_location_insight_type_insight resource. - * @returns {string} A string representing the insight. - */ - matchInsightFromFolderLocationInsightTypeInsightName(folderLocationInsightTypeInsightName: string) { - return this.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match(folderLocationInsightTypeInsightName).insight; - } - - /** - * Return a fully-qualified folderLocationRecommender resource name string. - * - * @param {string} folder - * @param {string} location - * @param {string} recommender - * @returns {string} Resource name string. - */ - folderLocationRecommenderPath(folder:string,location:string,recommender:string) { - return this.pathTemplates.folderLocationRecommenderPathTemplate.render({ - folder: folder, - location: location, - recommender: recommender, - }); - } - - /** - * Parse the folder from FolderLocationRecommender resource. - * - * @param {string} folderLocationRecommenderName - * A fully-qualified path representing folder_location_recommender resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderLocationRecommenderName(folderLocationRecommenderName: string) { - return this.pathTemplates.folderLocationRecommenderPathTemplate.match(folderLocationRecommenderName).folder; - } - - /** - * Parse the location from FolderLocationRecommender resource. - * - * @param {string} folderLocationRecommenderName - * A fully-qualified path representing folder_location_recommender resource. - * @returns {string} A string representing the location. - */ - matchLocationFromFolderLocationRecommenderName(folderLocationRecommenderName: string) { - return this.pathTemplates.folderLocationRecommenderPathTemplate.match(folderLocationRecommenderName).location; - } - - /** - * Parse the recommender from FolderLocationRecommender resource. - * - * @param {string} folderLocationRecommenderName - * A fully-qualified path representing folder_location_recommender resource. - * @returns {string} A string representing the recommender. - */ - matchRecommenderFromFolderLocationRecommenderName(folderLocationRecommenderName: string) { - return this.pathTemplates.folderLocationRecommenderPathTemplate.match(folderLocationRecommenderName).recommender; - } - - /** - * Return a fully-qualified folderLocationRecommenderRecommendation resource name string. - * - * @param {string} folder - * @param {string} location - * @param {string} recommender - * @param {string} recommendation - * @returns {string} Resource name string. - */ - folderLocationRecommenderRecommendationPath(folder:string,location:string,recommender:string,recommendation:string) { - return this.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.render({ - folder: folder, - location: location, - recommender: recommender, - recommendation: recommendation, - }); - } - - /** - * Parse the folder from FolderLocationRecommenderRecommendation resource. - * - * @param {string} folderLocationRecommenderRecommendationName - * A fully-qualified path representing folder_location_recommender_recommendation resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderLocationRecommenderRecommendationName(folderLocationRecommenderRecommendationName: string) { - return this.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match(folderLocationRecommenderRecommendationName).folder; - } - - /** - * Parse the location from FolderLocationRecommenderRecommendation resource. - * - * @param {string} folderLocationRecommenderRecommendationName - * A fully-qualified path representing folder_location_recommender_recommendation resource. - * @returns {string} A string representing the location. - */ - matchLocationFromFolderLocationRecommenderRecommendationName(folderLocationRecommenderRecommendationName: string) { - return this.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match(folderLocationRecommenderRecommendationName).location; - } - - /** - * Parse the recommender from FolderLocationRecommenderRecommendation resource. - * - * @param {string} folderLocationRecommenderRecommendationName - * A fully-qualified path representing folder_location_recommender_recommendation resource. - * @returns {string} A string representing the recommender. - */ - matchRecommenderFromFolderLocationRecommenderRecommendationName(folderLocationRecommenderRecommendationName: string) { - return this.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match(folderLocationRecommenderRecommendationName).recommender; - } - - /** - * Parse the recommendation from FolderLocationRecommenderRecommendation resource. - * - * @param {string} folderLocationRecommenderRecommendationName - * A fully-qualified path representing folder_location_recommender_recommendation resource. - * @returns {string} A string representing the recommendation. - */ - matchRecommendationFromFolderLocationRecommenderRecommendationName(folderLocationRecommenderRecommendationName: string) { - return this.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match(folderLocationRecommenderRecommendationName).recommendation; - } - - /** - * Return a fully-qualified organizationLocationInsightType resource name string. - * - * @param {string} organization - * @param {string} location - * @param {string} insight_type - * @returns {string} Resource name string. - */ - organizationLocationInsightTypePath(organization:string,location:string,insightType:string) { - return this.pathTemplates.organizationLocationInsightTypePathTemplate.render({ - organization: organization, - location: location, - insight_type: insightType, - }); - } - - /** - * Parse the organization from OrganizationLocationInsightType resource. - * - * @param {string} organizationLocationInsightTypeName - * A fully-qualified path representing organization_location_insight_type resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationLocationInsightTypeName(organizationLocationInsightTypeName: string) { - return this.pathTemplates.organizationLocationInsightTypePathTemplate.match(organizationLocationInsightTypeName).organization; - } - - /** - * Parse the location from OrganizationLocationInsightType resource. - * - * @param {string} organizationLocationInsightTypeName - * A fully-qualified path representing organization_location_insight_type resource. - * @returns {string} A string representing the location. - */ - matchLocationFromOrganizationLocationInsightTypeName(organizationLocationInsightTypeName: string) { - return this.pathTemplates.organizationLocationInsightTypePathTemplate.match(organizationLocationInsightTypeName).location; - } - - /** - * Parse the insight_type from OrganizationLocationInsightType resource. - * - * @param {string} organizationLocationInsightTypeName - * A fully-qualified path representing organization_location_insight_type resource. - * @returns {string} A string representing the insight_type. - */ - matchInsightTypeFromOrganizationLocationInsightTypeName(organizationLocationInsightTypeName: string) { - return this.pathTemplates.organizationLocationInsightTypePathTemplate.match(organizationLocationInsightTypeName).insight_type; - } - - /** - * Return a fully-qualified organizationLocationInsightTypeConfig resource name string. - * - * @param {string} organization - * @param {string} location - * @param {string} insight_type - * @returns {string} Resource name string. - */ - organizationLocationInsightTypeConfigPath(organization:string,location:string,insightType:string) { - return this.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.render({ - organization: organization, - location: location, - insight_type: insightType, - }); - } - - /** - * Parse the organization from OrganizationLocationInsightTypeConfig resource. - * - * @param {string} organizationLocationInsightTypeConfigName - * A fully-qualified path representing organization_location_insight_type_config resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationLocationInsightTypeConfigName(organizationLocationInsightTypeConfigName: string) { - return this.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match(organizationLocationInsightTypeConfigName).organization; - } - - /** - * Parse the location from OrganizationLocationInsightTypeConfig resource. - * - * @param {string} organizationLocationInsightTypeConfigName - * A fully-qualified path representing organization_location_insight_type_config resource. - * @returns {string} A string representing the location. - */ - matchLocationFromOrganizationLocationInsightTypeConfigName(organizationLocationInsightTypeConfigName: string) { - return this.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match(organizationLocationInsightTypeConfigName).location; - } - - /** - * Parse the insight_type from OrganizationLocationInsightTypeConfig resource. - * - * @param {string} organizationLocationInsightTypeConfigName - * A fully-qualified path representing organization_location_insight_type_config resource. - * @returns {string} A string representing the insight_type. - */ - matchInsightTypeFromOrganizationLocationInsightTypeConfigName(organizationLocationInsightTypeConfigName: string) { - return this.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match(organizationLocationInsightTypeConfigName).insight_type; - } - - /** - * Return a fully-qualified organizationLocationInsightTypeInsight resource name string. - * - * @param {string} organization - * @param {string} location - * @param {string} insight_type - * @param {string} insight - * @returns {string} Resource name string. - */ - organizationLocationInsightTypeInsightPath(organization:string,location:string,insightType:string,insight:string) { - return this.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.render({ - organization: organization, - location: location, - insight_type: insightType, - insight: insight, - }); - } - - /** - * Parse the organization from OrganizationLocationInsightTypeInsight resource. - * - * @param {string} organizationLocationInsightTypeInsightName - * A fully-qualified path representing organization_location_insight_type_insight resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationLocationInsightTypeInsightName(organizationLocationInsightTypeInsightName: string) { - return this.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match(organizationLocationInsightTypeInsightName).organization; - } - - /** - * Parse the location from OrganizationLocationInsightTypeInsight resource. - * - * @param {string} organizationLocationInsightTypeInsightName - * A fully-qualified path representing organization_location_insight_type_insight resource. - * @returns {string} A string representing the location. - */ - matchLocationFromOrganizationLocationInsightTypeInsightName(organizationLocationInsightTypeInsightName: string) { - return this.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match(organizationLocationInsightTypeInsightName).location; - } - - /** - * Parse the insight_type from OrganizationLocationInsightTypeInsight resource. - * - * @param {string} organizationLocationInsightTypeInsightName - * A fully-qualified path representing organization_location_insight_type_insight resource. - * @returns {string} A string representing the insight_type. - */ - matchInsightTypeFromOrganizationLocationInsightTypeInsightName(organizationLocationInsightTypeInsightName: string) { - return this.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match(organizationLocationInsightTypeInsightName).insight_type; - } - - /** - * Parse the insight from OrganizationLocationInsightTypeInsight resource. - * - * @param {string} organizationLocationInsightTypeInsightName - * A fully-qualified path representing organization_location_insight_type_insight resource. - * @returns {string} A string representing the insight. - */ - matchInsightFromOrganizationLocationInsightTypeInsightName(organizationLocationInsightTypeInsightName: string) { - return this.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match(organizationLocationInsightTypeInsightName).insight; - } - - /** - * Return a fully-qualified organizationLocationRecommender resource name string. - * - * @param {string} organization - * @param {string} location - * @param {string} recommender - * @returns {string} Resource name string. - */ - organizationLocationRecommenderPath(organization:string,location:string,recommender:string) { - return this.pathTemplates.organizationLocationRecommenderPathTemplate.render({ - organization: organization, - location: location, - recommender: recommender, - }); - } - - /** - * Parse the organization from OrganizationLocationRecommender resource. - * - * @param {string} organizationLocationRecommenderName - * A fully-qualified path representing organization_location_recommender resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationLocationRecommenderName(organizationLocationRecommenderName: string) { - return this.pathTemplates.organizationLocationRecommenderPathTemplate.match(organizationLocationRecommenderName).organization; - } - - /** - * Parse the location from OrganizationLocationRecommender resource. - * - * @param {string} organizationLocationRecommenderName - * A fully-qualified path representing organization_location_recommender resource. - * @returns {string} A string representing the location. - */ - matchLocationFromOrganizationLocationRecommenderName(organizationLocationRecommenderName: string) { - return this.pathTemplates.organizationLocationRecommenderPathTemplate.match(organizationLocationRecommenderName).location; - } - - /** - * Parse the recommender from OrganizationLocationRecommender resource. - * - * @param {string} organizationLocationRecommenderName - * A fully-qualified path representing organization_location_recommender resource. - * @returns {string} A string representing the recommender. - */ - matchRecommenderFromOrganizationLocationRecommenderName(organizationLocationRecommenderName: string) { - return this.pathTemplates.organizationLocationRecommenderPathTemplate.match(organizationLocationRecommenderName).recommender; - } - - /** - * Return a fully-qualified organizationLocationRecommenderConfig resource name string. - * - * @param {string} organization - * @param {string} location - * @param {string} recommender - * @returns {string} Resource name string. - */ - organizationLocationRecommenderConfigPath(organization:string,location:string,recommender:string) { - return this.pathTemplates.organizationLocationRecommenderConfigPathTemplate.render({ - organization: organization, - location: location, - recommender: recommender, - }); - } - - /** - * Parse the organization from OrganizationLocationRecommenderConfig resource. - * - * @param {string} organizationLocationRecommenderConfigName - * A fully-qualified path representing organization_location_recommender_config resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationLocationRecommenderConfigName(organizationLocationRecommenderConfigName: string) { - return this.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match(organizationLocationRecommenderConfigName).organization; - } - - /** - * Parse the location from OrganizationLocationRecommenderConfig resource. - * - * @param {string} organizationLocationRecommenderConfigName - * A fully-qualified path representing organization_location_recommender_config resource. - * @returns {string} A string representing the location. - */ - matchLocationFromOrganizationLocationRecommenderConfigName(organizationLocationRecommenderConfigName: string) { - return this.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match(organizationLocationRecommenderConfigName).location; - } - - /** - * Parse the recommender from OrganizationLocationRecommenderConfig resource. - * - * @param {string} organizationLocationRecommenderConfigName - * A fully-qualified path representing organization_location_recommender_config resource. - * @returns {string} A string representing the recommender. - */ - matchRecommenderFromOrganizationLocationRecommenderConfigName(organizationLocationRecommenderConfigName: string) { - return this.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match(organizationLocationRecommenderConfigName).recommender; - } - - /** - * Return a fully-qualified organizationLocationRecommenderRecommendation resource name string. - * - * @param {string} organization - * @param {string} location - * @param {string} recommender - * @param {string} recommendation - * @returns {string} Resource name string. - */ - organizationLocationRecommenderRecommendationPath(organization:string,location:string,recommender:string,recommendation:string) { - return this.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.render({ - organization: organization, - location: location, - recommender: recommender, - recommendation: recommendation, - }); - } - - /** - * Parse the organization from OrganizationLocationRecommenderRecommendation resource. - * - * @param {string} organizationLocationRecommenderRecommendationName - * A fully-qualified path representing organization_location_recommender_recommendation resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationLocationRecommenderRecommendationName(organizationLocationRecommenderRecommendationName: string) { - return this.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match(organizationLocationRecommenderRecommendationName).organization; - } - - /** - * Parse the location from OrganizationLocationRecommenderRecommendation resource. - * - * @param {string} organizationLocationRecommenderRecommendationName - * A fully-qualified path representing organization_location_recommender_recommendation resource. - * @returns {string} A string representing the location. - */ - matchLocationFromOrganizationLocationRecommenderRecommendationName(organizationLocationRecommenderRecommendationName: string) { - return this.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match(organizationLocationRecommenderRecommendationName).location; - } - - /** - * Parse the recommender from OrganizationLocationRecommenderRecommendation resource. - * - * @param {string} organizationLocationRecommenderRecommendationName - * A fully-qualified path representing organization_location_recommender_recommendation resource. - * @returns {string} A string representing the recommender. - */ - matchRecommenderFromOrganizationLocationRecommenderRecommendationName(organizationLocationRecommenderRecommendationName: string) { - return this.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match(organizationLocationRecommenderRecommendationName).recommender; - } - - /** - * Parse the recommendation from OrganizationLocationRecommenderRecommendation resource. - * - * @param {string} organizationLocationRecommenderRecommendationName - * A fully-qualified path representing organization_location_recommender_recommendation resource. - * @returns {string} A string representing the recommendation. - */ - matchRecommendationFromOrganizationLocationRecommenderRecommendationName(organizationLocationRecommenderRecommendationName: string) { - return this.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match(organizationLocationRecommenderRecommendationName).recommendation; - } - - /** - * Return a fully-qualified projectLocationInsightType resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} insight_type - * @returns {string} Resource name string. - */ - projectLocationInsightTypePath(project:string,location:string,insightType:string) { - return this.pathTemplates.projectLocationInsightTypePathTemplate.render({ - project: project, - location: location, - insight_type: insightType, - }); - } - - /** - * Parse the project from ProjectLocationInsightType resource. - * - * @param {string} projectLocationInsightTypeName - * A fully-qualified path representing project_location_insight_type resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationInsightTypeName(projectLocationInsightTypeName: string) { - return this.pathTemplates.projectLocationInsightTypePathTemplate.match(projectLocationInsightTypeName).project; - } - - /** - * Parse the location from ProjectLocationInsightType resource. - * - * @param {string} projectLocationInsightTypeName - * A fully-qualified path representing project_location_insight_type resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationInsightTypeName(projectLocationInsightTypeName: string) { - return this.pathTemplates.projectLocationInsightTypePathTemplate.match(projectLocationInsightTypeName).location; - } - - /** - * Parse the insight_type from ProjectLocationInsightType resource. - * - * @param {string} projectLocationInsightTypeName - * A fully-qualified path representing project_location_insight_type resource. - * @returns {string} A string representing the insight_type. - */ - matchInsightTypeFromProjectLocationInsightTypeName(projectLocationInsightTypeName: string) { - return this.pathTemplates.projectLocationInsightTypePathTemplate.match(projectLocationInsightTypeName).insight_type; - } - - /** - * Return a fully-qualified projectLocationInsightTypeConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} insight_type - * @returns {string} Resource name string. - */ - projectLocationInsightTypeConfigPath(project:string,location:string,insightType:string) { - return this.pathTemplates.projectLocationInsightTypeConfigPathTemplate.render({ - project: project, - location: location, - insight_type: insightType, - }); - } - - /** - * Parse the project from ProjectLocationInsightTypeConfig resource. - * - * @param {string} projectLocationInsightTypeConfigName - * A fully-qualified path representing project_location_insight_type_config resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationInsightTypeConfigName(projectLocationInsightTypeConfigName: string) { - return this.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match(projectLocationInsightTypeConfigName).project; - } - - /** - * Parse the location from ProjectLocationInsightTypeConfig resource. - * - * @param {string} projectLocationInsightTypeConfigName - * A fully-qualified path representing project_location_insight_type_config resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationInsightTypeConfigName(projectLocationInsightTypeConfigName: string) { - return this.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match(projectLocationInsightTypeConfigName).location; - } - - /** - * Parse the insight_type from ProjectLocationInsightTypeConfig resource. - * - * @param {string} projectLocationInsightTypeConfigName - * A fully-qualified path representing project_location_insight_type_config resource. - * @returns {string} A string representing the insight_type. - */ - matchInsightTypeFromProjectLocationInsightTypeConfigName(projectLocationInsightTypeConfigName: string) { - return this.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match(projectLocationInsightTypeConfigName).insight_type; - } - - /** - * Return a fully-qualified projectLocationInsightTypeInsight resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} insight_type - * @param {string} insight - * @returns {string} Resource name string. - */ - projectLocationInsightTypeInsightPath(project:string,location:string,insightType:string,insight:string) { - return this.pathTemplates.projectLocationInsightTypeInsightPathTemplate.render({ - project: project, - location: location, - insight_type: insightType, - insight: insight, - }); - } - - /** - * Parse the project from ProjectLocationInsightTypeInsight resource. - * - * @param {string} projectLocationInsightTypeInsightName - * A fully-qualified path representing project_location_insight_type_insight resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationInsightTypeInsightName(projectLocationInsightTypeInsightName: string) { - return this.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match(projectLocationInsightTypeInsightName).project; - } - - /** - * Parse the location from ProjectLocationInsightTypeInsight resource. - * - * @param {string} projectLocationInsightTypeInsightName - * A fully-qualified path representing project_location_insight_type_insight resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationInsightTypeInsightName(projectLocationInsightTypeInsightName: string) { - return this.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match(projectLocationInsightTypeInsightName).location; - } - - /** - * Parse the insight_type from ProjectLocationInsightTypeInsight resource. - * - * @param {string} projectLocationInsightTypeInsightName - * A fully-qualified path representing project_location_insight_type_insight resource. - * @returns {string} A string representing the insight_type. - */ - matchInsightTypeFromProjectLocationInsightTypeInsightName(projectLocationInsightTypeInsightName: string) { - return this.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match(projectLocationInsightTypeInsightName).insight_type; - } - - /** - * Parse the insight from ProjectLocationInsightTypeInsight resource. - * - * @param {string} projectLocationInsightTypeInsightName - * A fully-qualified path representing project_location_insight_type_insight resource. - * @returns {string} A string representing the insight. - */ - matchInsightFromProjectLocationInsightTypeInsightName(projectLocationInsightTypeInsightName: string) { - return this.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match(projectLocationInsightTypeInsightName).insight; - } - - /** - * Return a fully-qualified projectLocationRecommender resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} recommender - * @returns {string} Resource name string. - */ - projectLocationRecommenderPath(project:string,location:string,recommender:string) { - return this.pathTemplates.projectLocationRecommenderPathTemplate.render({ - project: project, - location: location, - recommender: recommender, - }); - } - - /** - * Parse the project from ProjectLocationRecommender resource. - * - * @param {string} projectLocationRecommenderName - * A fully-qualified path representing project_location_recommender resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationRecommenderName(projectLocationRecommenderName: string) { - return this.pathTemplates.projectLocationRecommenderPathTemplate.match(projectLocationRecommenderName).project; - } - - /** - * Parse the location from ProjectLocationRecommender resource. - * - * @param {string} projectLocationRecommenderName - * A fully-qualified path representing project_location_recommender resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationRecommenderName(projectLocationRecommenderName: string) { - return this.pathTemplates.projectLocationRecommenderPathTemplate.match(projectLocationRecommenderName).location; - } - - /** - * Parse the recommender from ProjectLocationRecommender resource. - * - * @param {string} projectLocationRecommenderName - * A fully-qualified path representing project_location_recommender resource. - * @returns {string} A string representing the recommender. - */ - matchRecommenderFromProjectLocationRecommenderName(projectLocationRecommenderName: string) { - return this.pathTemplates.projectLocationRecommenderPathTemplate.match(projectLocationRecommenderName).recommender; - } - - /** - * Return a fully-qualified projectLocationRecommenderConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} recommender - * @returns {string} Resource name string. - */ - projectLocationRecommenderConfigPath(project:string,location:string,recommender:string) { - return this.pathTemplates.projectLocationRecommenderConfigPathTemplate.render({ - project: project, - location: location, - recommender: recommender, - }); - } - - /** - * Parse the project from ProjectLocationRecommenderConfig resource. - * - * @param {string} projectLocationRecommenderConfigName - * A fully-qualified path representing project_location_recommender_config resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationRecommenderConfigName(projectLocationRecommenderConfigName: string) { - return this.pathTemplates.projectLocationRecommenderConfigPathTemplate.match(projectLocationRecommenderConfigName).project; - } - - /** - * Parse the location from ProjectLocationRecommenderConfig resource. - * - * @param {string} projectLocationRecommenderConfigName - * A fully-qualified path representing project_location_recommender_config resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationRecommenderConfigName(projectLocationRecommenderConfigName: string) { - return this.pathTemplates.projectLocationRecommenderConfigPathTemplate.match(projectLocationRecommenderConfigName).location; - } - - /** - * Parse the recommender from ProjectLocationRecommenderConfig resource. - * - * @param {string} projectLocationRecommenderConfigName - * A fully-qualified path representing project_location_recommender_config resource. - * @returns {string} A string representing the recommender. - */ - matchRecommenderFromProjectLocationRecommenderConfigName(projectLocationRecommenderConfigName: string) { - return this.pathTemplates.projectLocationRecommenderConfigPathTemplate.match(projectLocationRecommenderConfigName).recommender; - } - - /** - * Return a fully-qualified projectLocationRecommenderRecommendation resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} recommender - * @param {string} recommendation - * @returns {string} Resource name string. - */ - projectLocationRecommenderRecommendationPath(project:string,location:string,recommender:string,recommendation:string) { - return this.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.render({ - project: project, - location: location, - recommender: recommender, - recommendation: recommendation, - }); - } - - /** - * Parse the project from ProjectLocationRecommenderRecommendation resource. - * - * @param {string} projectLocationRecommenderRecommendationName - * A fully-qualified path representing project_location_recommender_recommendation resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationRecommenderRecommendationName(projectLocationRecommenderRecommendationName: string) { - return this.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match(projectLocationRecommenderRecommendationName).project; - } - - /** - * Parse the location from ProjectLocationRecommenderRecommendation resource. - * - * @param {string} projectLocationRecommenderRecommendationName - * A fully-qualified path representing project_location_recommender_recommendation resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationRecommenderRecommendationName(projectLocationRecommenderRecommendationName: string) { - return this.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match(projectLocationRecommenderRecommendationName).location; - } - - /** - * Parse the recommender from ProjectLocationRecommenderRecommendation resource. - * - * @param {string} projectLocationRecommenderRecommendationName - * A fully-qualified path representing project_location_recommender_recommendation resource. - * @returns {string} A string representing the recommender. - */ - matchRecommenderFromProjectLocationRecommenderRecommendationName(projectLocationRecommenderRecommendationName: string) { - return this.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match(projectLocationRecommenderRecommendationName).recommender; - } - - /** - * Parse the recommendation from ProjectLocationRecommenderRecommendation resource. - * - * @param {string} projectLocationRecommenderRecommendationName - * A fully-qualified path representing project_location_recommender_recommendation resource. - * @returns {string} A string representing the recommendation. - */ - matchRecommendationFromProjectLocationRecommenderRecommendationName(projectLocationRecommenderRecommendationName: string) { - return this.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match(projectLocationRecommenderRecommendationName).recommendation; - } - - /** - * 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.recommenderStub && !this._terminated) { - return this.recommenderStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_client_config.json b/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_client_config.json deleted file mode 100644 index 76661e8589b..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_client_config.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "interfaces": { - "google.cloud.recommender.v1beta1.Recommender": { - "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": { - "ListInsights": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetInsight": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "MarkInsightAccepted": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListRecommendations": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetRecommendation": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "MarkRecommendationClaimed": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "MarkRecommendationSucceeded": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "MarkRecommendationFailed": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetRecommenderConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateRecommenderConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetInsightTypeConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateInsightTypeConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_proto_list.json b/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_proto_list.json deleted file mode 100644 index 7e1fb4b4ee6..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/src/v1beta1/recommender_proto_list.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - "../../protos/google/cloud/recommender/v1beta1/insight.proto", - "../../protos/google/cloud/recommender/v1beta1/insight_type_config.proto", - "../../protos/google/cloud/recommender/v1beta1/recommendation.proto", - "../../protos/google/cloud/recommender/v1beta1/recommender_config.proto", - "../../protos/google/cloud/recommender/v1beta1/recommender_service.proto" -] diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-recommender/v1beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 8db790db9d7..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const recommender = require('@google-cloud/recommender'); - -function main() { - const recommenderClient = new recommender.RecommenderClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-recommender/v1beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 5142e8f3f3e..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {RecommenderClient} from '@google-cloud/recommender'; - -// check that the client class type name can be used -function doStuffWithRecommenderClient(client: RecommenderClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const recommenderClient = new RecommenderClient(); - doStuffWithRecommenderClient(recommenderClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-recommender/v1beta1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/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-recommender/v1beta1/test/gapic_recommender_v1beta1.ts b/owl-bot-staging/google-cloud-recommender/v1beta1/test/gapic_recommender_v1beta1.ts deleted file mode 100644 index a8277cf581c..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/test/gapic_recommender_v1beta1.ts +++ /dev/null @@ -1,2762 +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 recommenderModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -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('v1beta1.RecommenderClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = recommenderModule.v1beta1.RecommenderClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = recommenderModule.v1beta1.RecommenderClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = recommenderModule.v1beta1.RecommenderClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new recommenderModule.v1beta1.RecommenderClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.recommenderStub, undefined); - await client.initialize(); - assert(client.recommenderStub); - }); - - it('has close method for the initialized client', done => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.recommenderStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.recommenderStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new recommenderModule.v1beta1.RecommenderClient({ - 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 recommenderModule.v1beta1.RecommenderClient({ - 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('getInsight', () => { - it('invokes getInsight without error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.GetInsightRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetInsightRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.Insight() - ); - client.innerApiCalls.getInsight = stubSimpleCall(expectedResponse); - const [response] = await client.getInsight(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInsight as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInsight as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInsight without error using callback', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.GetInsightRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetInsightRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.Insight() - ); - client.innerApiCalls.getInsight = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInsight( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IInsight|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInsight as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInsight as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInsight with error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.GetInsightRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetInsightRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInsight = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInsight(request), expectedError); - const actualRequest = (client.innerApiCalls.getInsight as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInsight as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInsight with closed client', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.GetInsightRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetInsightRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getInsight(request), expectedError); - }); - }); - - describe('markInsightAccepted', () => { - it('invokes markInsightAccepted without error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.MarkInsightAcceptedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkInsightAcceptedRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.Insight() - ); - client.innerApiCalls.markInsightAccepted = stubSimpleCall(expectedResponse); - const [response] = await client.markInsightAccepted(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.markInsightAccepted as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markInsightAccepted as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markInsightAccepted without error using callback', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.MarkInsightAcceptedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkInsightAcceptedRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.Insight() - ); - client.innerApiCalls.markInsightAccepted = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.markInsightAccepted( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IInsight|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.markInsightAccepted as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markInsightAccepted as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markInsightAccepted with error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.MarkInsightAcceptedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkInsightAcceptedRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.markInsightAccepted = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.markInsightAccepted(request), expectedError); - const actualRequest = (client.innerApiCalls.markInsightAccepted as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markInsightAccepted as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markInsightAccepted with closed client', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.MarkInsightAcceptedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkInsightAcceptedRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.markInsightAccepted(request), expectedError); - }); - }); - - describe('getRecommendation', () => { - it('invokes getRecommendation without error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.GetRecommendationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetRecommendationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.Recommendation() - ); - client.innerApiCalls.getRecommendation = stubSimpleCall(expectedResponse); - const [response] = await client.getRecommendation(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRecommendation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRecommendation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRecommendation without error using callback', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.GetRecommendationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetRecommendationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.Recommendation() - ); - client.innerApiCalls.getRecommendation = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getRecommendation( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IRecommendation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRecommendation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRecommendation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRecommendation with error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.GetRecommendationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetRecommendationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getRecommendation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getRecommendation(request), expectedError); - const actualRequest = (client.innerApiCalls.getRecommendation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRecommendation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRecommendation with closed client', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.GetRecommendationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetRecommendationRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getRecommendation(request), expectedError); - }); - }); - - describe('markRecommendationClaimed', () => { - it('invokes markRecommendationClaimed without error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.Recommendation() - ); - client.innerApiCalls.markRecommendationClaimed = stubSimpleCall(expectedResponse); - const [response] = await client.markRecommendationClaimed(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.markRecommendationClaimed as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationClaimed as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markRecommendationClaimed without error using callback', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.Recommendation() - ); - client.innerApiCalls.markRecommendationClaimed = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.markRecommendationClaimed( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IRecommendation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.markRecommendationClaimed as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationClaimed as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markRecommendationClaimed with error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.markRecommendationClaimed = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.markRecommendationClaimed(request), expectedError); - const actualRequest = (client.innerApiCalls.markRecommendationClaimed as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationClaimed as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markRecommendationClaimed with closed client', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.markRecommendationClaimed(request), expectedError); - }); - }); - - describe('markRecommendationSucceeded', () => { - it('invokes markRecommendationSucceeded without error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.Recommendation() - ); - client.innerApiCalls.markRecommendationSucceeded = stubSimpleCall(expectedResponse); - const [response] = await client.markRecommendationSucceeded(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markRecommendationSucceeded without error using callback', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.Recommendation() - ); - client.innerApiCalls.markRecommendationSucceeded = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.markRecommendationSucceeded( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IRecommendation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markRecommendationSucceeded with error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.markRecommendationSucceeded = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.markRecommendationSucceeded(request), expectedError); - const actualRequest = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationSucceeded as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markRecommendationSucceeded with closed client', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.markRecommendationSucceeded(request), expectedError); - }); - }); - - describe('markRecommendationFailed', () => { - it('invokes markRecommendationFailed without error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.Recommendation() - ); - client.innerApiCalls.markRecommendationFailed = stubSimpleCall(expectedResponse); - const [response] = await client.markRecommendationFailed(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.markRecommendationFailed as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationFailed as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markRecommendationFailed without error using callback', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.Recommendation() - ); - client.innerApiCalls.markRecommendationFailed = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.markRecommendationFailed( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IRecommendation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.markRecommendationFailed as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationFailed as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markRecommendationFailed with error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.markRecommendationFailed = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.markRecommendationFailed(request), expectedError); - const actualRequest = (client.innerApiCalls.markRecommendationFailed as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.markRecommendationFailed as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes markRecommendationFailed with closed client', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.markRecommendationFailed(request), expectedError); - }); - }); - - describe('getRecommenderConfig', () => { - it('invokes getRecommenderConfig without error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.GetRecommenderConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetRecommenderConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.RecommenderConfig() - ); - client.innerApiCalls.getRecommenderConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getRecommenderConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRecommenderConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRecommenderConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRecommenderConfig without error using callback', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.GetRecommenderConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetRecommenderConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.RecommenderConfig() - ); - client.innerApiCalls.getRecommenderConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getRecommenderConfig( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IRecommenderConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRecommenderConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRecommenderConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRecommenderConfig with error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.GetRecommenderConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetRecommenderConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getRecommenderConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getRecommenderConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getRecommenderConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRecommenderConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRecommenderConfig with closed client', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.GetRecommenderConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetRecommenderConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getRecommenderConfig(request), expectedError); - }); - }); - - describe('updateRecommenderConfig', () => { - it('invokes updateRecommenderConfig without error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.UpdateRecommenderConfigRequest() - ); - request.recommenderConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.UpdateRecommenderConfigRequest', ['recommenderConfig', 'name']); - request.recommenderConfig.name = defaultValue1; - const expectedHeaderRequestParams = `recommender_config.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.RecommenderConfig() - ); - client.innerApiCalls.updateRecommenderConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateRecommenderConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateRecommenderConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateRecommenderConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateRecommenderConfig without error using callback', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.UpdateRecommenderConfigRequest() - ); - request.recommenderConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.UpdateRecommenderConfigRequest', ['recommenderConfig', 'name']); - request.recommenderConfig.name = defaultValue1; - const expectedHeaderRequestParams = `recommender_config.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.RecommenderConfig() - ); - client.innerApiCalls.updateRecommenderConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateRecommenderConfig( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IRecommenderConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateRecommenderConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateRecommenderConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateRecommenderConfig with error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.UpdateRecommenderConfigRequest() - ); - request.recommenderConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.UpdateRecommenderConfigRequest', ['recommenderConfig', 'name']); - request.recommenderConfig.name = defaultValue1; - const expectedHeaderRequestParams = `recommender_config.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateRecommenderConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateRecommenderConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateRecommenderConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateRecommenderConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateRecommenderConfig with closed client', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.UpdateRecommenderConfigRequest() - ); - request.recommenderConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.UpdateRecommenderConfigRequest', ['recommenderConfig', 'name']); - request.recommenderConfig.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateRecommenderConfig(request), expectedError); - }); - }); - - describe('getInsightTypeConfig', () => { - it('invokes getInsightTypeConfig without error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.GetInsightTypeConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetInsightTypeConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.InsightTypeConfig() - ); - client.innerApiCalls.getInsightTypeConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getInsightTypeConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInsightTypeConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInsightTypeConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInsightTypeConfig without error using callback', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.GetInsightTypeConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetInsightTypeConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.InsightTypeConfig() - ); - client.innerApiCalls.getInsightTypeConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInsightTypeConfig( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IInsightTypeConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInsightTypeConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInsightTypeConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInsightTypeConfig with error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.GetInsightTypeConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetInsightTypeConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInsightTypeConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInsightTypeConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getInsightTypeConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInsightTypeConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInsightTypeConfig with closed client', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.GetInsightTypeConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.GetInsightTypeConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getInsightTypeConfig(request), expectedError); - }); - }); - - describe('updateInsightTypeConfig', () => { - it('invokes updateInsightTypeConfig without error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.UpdateInsightTypeConfigRequest() - ); - request.insightTypeConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.UpdateInsightTypeConfigRequest', ['insightTypeConfig', 'name']); - request.insightTypeConfig.name = defaultValue1; - const expectedHeaderRequestParams = `insight_type_config.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.InsightTypeConfig() - ); - client.innerApiCalls.updateInsightTypeConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateInsightTypeConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInsightTypeConfig without error using callback', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.UpdateInsightTypeConfigRequest() - ); - request.insightTypeConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.UpdateInsightTypeConfigRequest', ['insightTypeConfig', 'name']); - request.insightTypeConfig.name = defaultValue1; - const expectedHeaderRequestParams = `insight_type_config.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.InsightTypeConfig() - ); - client.innerApiCalls.updateInsightTypeConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateInsightTypeConfig( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IInsightTypeConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInsightTypeConfig with error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.UpdateInsightTypeConfigRequest() - ); - request.insightTypeConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.UpdateInsightTypeConfigRequest', ['insightTypeConfig', 'name']); - request.insightTypeConfig.name = defaultValue1; - const expectedHeaderRequestParams = `insight_type_config.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInsightTypeConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateInsightTypeConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInsightTypeConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInsightTypeConfig with closed client', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.UpdateInsightTypeConfigRequest() - ); - request.insightTypeConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.UpdateInsightTypeConfigRequest', ['insightTypeConfig', 'name']); - request.insightTypeConfig.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateInsightTypeConfig(request), expectedError); - }); - }); - - describe('listInsights', () => { - it('invokes listInsights without error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.ListInsightsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListInsightsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), - ]; - client.innerApiCalls.listInsights = stubSimpleCall(expectedResponse); - const [response] = await client.listInsights(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInsights as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInsights as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInsights without error using callback', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.ListInsightsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListInsightsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), - ]; - client.innerApiCalls.listInsights = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInsights( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IInsight[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInsights as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInsights as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInsights with error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.ListInsightsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListInsightsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInsights = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInsights(request), expectedError); - const actualRequest = (client.innerApiCalls.listInsights as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInsights as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInsightsStream without error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.ListInsightsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListInsightsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), - ]; - client.descriptors.page.listInsights.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInsightsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recommender.v1beta1.Insight[] = []; - stream.on('data', (response: protos.google.cloud.recommender.v1beta1.Insight) => { - 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.listInsights.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInsights, request)); - assert( - (client.descriptors.page.listInsights.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listInsightsStream with error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.ListInsightsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListInsightsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInsights.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInsightsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recommender.v1beta1.Insight[] = []; - stream.on('data', (response: protos.google.cloud.recommender.v1beta1.Insight) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listInsights.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInsights, request)); - assert( - (client.descriptors.page.listInsights.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInsights without error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.ListInsightsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListInsightsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Insight()), - ]; - client.descriptors.page.listInsights.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.recommender.v1beta1.IInsight[] = []; - const iterable = client.listInsightsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInsights.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInsights.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInsights with error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.ListInsightsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListInsightsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInsights.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInsightsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.recommender.v1beta1.IInsight[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listInsights.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInsights.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listRecommendations', () => { - it('invokes listRecommendations without error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.ListRecommendationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListRecommendationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), - ]; - client.innerApiCalls.listRecommendations = stubSimpleCall(expectedResponse); - const [response] = await client.listRecommendations(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRecommendations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRecommendations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRecommendations without error using callback', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.ListRecommendationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListRecommendationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), - ]; - client.innerApiCalls.listRecommendations = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listRecommendations( - request, - (err?: Error|null, result?: protos.google.cloud.recommender.v1beta1.IRecommendation[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRecommendations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRecommendations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRecommendations with error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.ListRecommendationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListRecommendationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listRecommendations = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listRecommendations(request), expectedError); - const actualRequest = (client.innerApiCalls.listRecommendations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRecommendations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRecommendationsStream without error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.ListRecommendationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListRecommendationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), - ]; - client.descriptors.page.listRecommendations.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listRecommendationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recommender.v1beta1.Recommendation[] = []; - stream.on('data', (response: protos.google.cloud.recommender.v1beta1.Recommendation) => { - 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.listRecommendations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRecommendations, request)); - assert( - (client.descriptors.page.listRecommendations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listRecommendationsStream with error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.ListRecommendationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListRecommendationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listRecommendations.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listRecommendationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recommender.v1beta1.Recommendation[] = []; - stream.on('data', (response: protos.google.cloud.recommender.v1beta1.Recommendation) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listRecommendations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRecommendations, request)); - assert( - (client.descriptors.page.listRecommendations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRecommendations without error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.ListRecommendationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListRecommendationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), - generateSampleMessage(new protos.google.cloud.recommender.v1beta1.Recommendation()), - ]; - client.descriptors.page.listRecommendations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.recommender.v1beta1.IRecommendation[] = []; - const iterable = client.listRecommendationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listRecommendations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRecommendations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRecommendations with error', async () => { - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.recommender.v1beta1.ListRecommendationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.recommender.v1beta1.ListRecommendationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listRecommendations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listRecommendationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.recommender.v1beta1.IRecommendation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listRecommendations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRecommendations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('billingAccountLocationInsightType', () => { - const fakePath = "/rendered/path/billingAccountLocationInsightType"; - const expectedParameters = { - billing_account: "billingAccountValue", - location: "locationValue", - insight_type: "insightTypeValue", - }; - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.billingAccountLocationInsightTypePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.billingAccountLocationInsightTypePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('billingAccountLocationInsightTypePath', () => { - const result = client.billingAccountLocationInsightTypePath("billingAccountValue", "locationValue", "insightTypeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.billingAccountLocationInsightTypePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchBillingAccountFromBillingAccountLocationInsightTypeName', () => { - const result = client.matchBillingAccountFromBillingAccountLocationInsightTypeName(fakePath); - assert.strictEqual(result, "billingAccountValue"); - assert((client.pathTemplates.billingAccountLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBillingAccountLocationInsightTypeName', () => { - const result = client.matchLocationFromBillingAccountLocationInsightTypeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.billingAccountLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightTypeFromBillingAccountLocationInsightTypeName', () => { - const result = client.matchInsightTypeFromBillingAccountLocationInsightTypeName(fakePath); - assert.strictEqual(result, "insightTypeValue"); - assert((client.pathTemplates.billingAccountLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('billingAccountLocationInsightTypeInsight', () => { - const fakePath = "/rendered/path/billingAccountLocationInsightTypeInsight"; - const expectedParameters = { - billing_account: "billingAccountValue", - location: "locationValue", - insight_type: "insightTypeValue", - insight: "insightValue", - }; - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('billingAccountLocationInsightTypeInsightPath', () => { - const result = client.billingAccountLocationInsightTypeInsightPath("billingAccountValue", "locationValue", "insightTypeValue", "insightValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchBillingAccountFromBillingAccountLocationInsightTypeInsightName', () => { - const result = client.matchBillingAccountFromBillingAccountLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "billingAccountValue"); - assert((client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBillingAccountLocationInsightTypeInsightName', () => { - const result = client.matchLocationFromBillingAccountLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightTypeFromBillingAccountLocationInsightTypeInsightName', () => { - const result = client.matchInsightTypeFromBillingAccountLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "insightTypeValue"); - assert((client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightFromBillingAccountLocationInsightTypeInsightName', () => { - const result = client.matchInsightFromBillingAccountLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "insightValue"); - assert((client.pathTemplates.billingAccountLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('billingAccountLocationRecommender', () => { - const fakePath = "/rendered/path/billingAccountLocationRecommender"; - const expectedParameters = { - billing_account: "billingAccountValue", - location: "locationValue", - recommender: "recommenderValue", - }; - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.billingAccountLocationRecommenderPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.billingAccountLocationRecommenderPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('billingAccountLocationRecommenderPath', () => { - const result = client.billingAccountLocationRecommenderPath("billingAccountValue", "locationValue", "recommenderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.billingAccountLocationRecommenderPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchBillingAccountFromBillingAccountLocationRecommenderName', () => { - const result = client.matchBillingAccountFromBillingAccountLocationRecommenderName(fakePath); - assert.strictEqual(result, "billingAccountValue"); - assert((client.pathTemplates.billingAccountLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBillingAccountLocationRecommenderName', () => { - const result = client.matchLocationFromBillingAccountLocationRecommenderName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.billingAccountLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommenderFromBillingAccountLocationRecommenderName', () => { - const result = client.matchRecommenderFromBillingAccountLocationRecommenderName(fakePath); - assert.strictEqual(result, "recommenderValue"); - assert((client.pathTemplates.billingAccountLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('billingAccountLocationRecommenderRecommendation', () => { - const fakePath = "/rendered/path/billingAccountLocationRecommenderRecommendation"; - const expectedParameters = { - billing_account: "billingAccountValue", - location: "locationValue", - recommender: "recommenderValue", - recommendation: "recommendationValue", - }; - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('billingAccountLocationRecommenderRecommendationPath', () => { - const result = client.billingAccountLocationRecommenderRecommendationPath("billingAccountValue", "locationValue", "recommenderValue", "recommendationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchBillingAccountFromBillingAccountLocationRecommenderRecommendationName', () => { - const result = client.matchBillingAccountFromBillingAccountLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "billingAccountValue"); - assert((client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBillingAccountLocationRecommenderRecommendationName', () => { - const result = client.matchLocationFromBillingAccountLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommenderFromBillingAccountLocationRecommenderRecommendationName', () => { - const result = client.matchRecommenderFromBillingAccountLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "recommenderValue"); - assert((client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommendationFromBillingAccountLocationRecommenderRecommendationName', () => { - const result = client.matchRecommendationFromBillingAccountLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "recommendationValue"); - assert((client.pathTemplates.billingAccountLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('folderLocationInsightType', () => { - const fakePath = "/rendered/path/folderLocationInsightType"; - const expectedParameters = { - folder: "folderValue", - location: "locationValue", - insight_type: "insightTypeValue", - }; - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderLocationInsightTypePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderLocationInsightTypePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderLocationInsightTypePath', () => { - const result = client.folderLocationInsightTypePath("folderValue", "locationValue", "insightTypeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderLocationInsightTypePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderLocationInsightTypeName', () => { - const result = client.matchFolderFromFolderLocationInsightTypeName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromFolderLocationInsightTypeName', () => { - const result = client.matchLocationFromFolderLocationInsightTypeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.folderLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightTypeFromFolderLocationInsightTypeName', () => { - const result = client.matchInsightTypeFromFolderLocationInsightTypeName(fakePath); - assert.strictEqual(result, "insightTypeValue"); - assert((client.pathTemplates.folderLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('folderLocationInsightTypeInsight', () => { - const fakePath = "/rendered/path/folderLocationInsightTypeInsight"; - const expectedParameters = { - folder: "folderValue", - location: "locationValue", - insight_type: "insightTypeValue", - insight: "insightValue", - }; - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderLocationInsightTypeInsightPath', () => { - const result = client.folderLocationInsightTypeInsightPath("folderValue", "locationValue", "insightTypeValue", "insightValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderLocationInsightTypeInsightName', () => { - const result = client.matchFolderFromFolderLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromFolderLocationInsightTypeInsightName', () => { - const result = client.matchLocationFromFolderLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightTypeFromFolderLocationInsightTypeInsightName', () => { - const result = client.matchInsightTypeFromFolderLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "insightTypeValue"); - assert((client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightFromFolderLocationInsightTypeInsightName', () => { - const result = client.matchInsightFromFolderLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "insightValue"); - assert((client.pathTemplates.folderLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('folderLocationRecommender', () => { - const fakePath = "/rendered/path/folderLocationRecommender"; - const expectedParameters = { - folder: "folderValue", - location: "locationValue", - recommender: "recommenderValue", - }; - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderLocationRecommenderPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderLocationRecommenderPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderLocationRecommenderPath', () => { - const result = client.folderLocationRecommenderPath("folderValue", "locationValue", "recommenderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderLocationRecommenderPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderLocationRecommenderName', () => { - const result = client.matchFolderFromFolderLocationRecommenderName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromFolderLocationRecommenderName', () => { - const result = client.matchLocationFromFolderLocationRecommenderName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.folderLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommenderFromFolderLocationRecommenderName', () => { - const result = client.matchRecommenderFromFolderLocationRecommenderName(fakePath); - assert.strictEqual(result, "recommenderValue"); - assert((client.pathTemplates.folderLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('folderLocationRecommenderRecommendation', () => { - const fakePath = "/rendered/path/folderLocationRecommenderRecommendation"; - const expectedParameters = { - folder: "folderValue", - location: "locationValue", - recommender: "recommenderValue", - recommendation: "recommendationValue", - }; - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderLocationRecommenderRecommendationPath', () => { - const result = client.folderLocationRecommenderRecommendationPath("folderValue", "locationValue", "recommenderValue", "recommendationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderLocationRecommenderRecommendationName', () => { - const result = client.matchFolderFromFolderLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromFolderLocationRecommenderRecommendationName', () => { - const result = client.matchLocationFromFolderLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommenderFromFolderLocationRecommenderRecommendationName', () => { - const result = client.matchRecommenderFromFolderLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "recommenderValue"); - assert((client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommendationFromFolderLocationRecommenderRecommendationName', () => { - const result = client.matchRecommendationFromFolderLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "recommendationValue"); - assert((client.pathTemplates.folderLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organizationLocationInsightType', () => { - const fakePath = "/rendered/path/organizationLocationInsightType"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - insight_type: "insightTypeValue", - }; - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationLocationInsightTypePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationLocationInsightTypePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationLocationInsightTypePath', () => { - const result = client.organizationLocationInsightTypePath("organizationValue", "locationValue", "insightTypeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationLocationInsightTypePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationLocationInsightTypeName', () => { - const result = client.matchOrganizationFromOrganizationLocationInsightTypeName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOrganizationLocationInsightTypeName', () => { - const result = client.matchLocationFromOrganizationLocationInsightTypeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightTypeFromOrganizationLocationInsightTypeName', () => { - const result = client.matchInsightTypeFromOrganizationLocationInsightTypeName(fakePath); - assert.strictEqual(result, "insightTypeValue"); - assert((client.pathTemplates.organizationLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organizationLocationInsightTypeConfig', () => { - const fakePath = "/rendered/path/organizationLocationInsightTypeConfig"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - insight_type: "insightTypeValue", - }; - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationLocationInsightTypeConfigPath', () => { - const result = client.organizationLocationInsightTypeConfigPath("organizationValue", "locationValue", "insightTypeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationLocationInsightTypeConfigName', () => { - const result = client.matchOrganizationFromOrganizationLocationInsightTypeConfigName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOrganizationLocationInsightTypeConfigName', () => { - const result = client.matchLocationFromOrganizationLocationInsightTypeConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightTypeFromOrganizationLocationInsightTypeConfigName', () => { - const result = client.matchInsightTypeFromOrganizationLocationInsightTypeConfigName(fakePath); - assert.strictEqual(result, "insightTypeValue"); - assert((client.pathTemplates.organizationLocationInsightTypeConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organizationLocationInsightTypeInsight', () => { - const fakePath = "/rendered/path/organizationLocationInsightTypeInsight"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - insight_type: "insightTypeValue", - insight: "insightValue", - }; - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationLocationInsightTypeInsightPath', () => { - const result = client.organizationLocationInsightTypeInsightPath("organizationValue", "locationValue", "insightTypeValue", "insightValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationLocationInsightTypeInsightName', () => { - const result = client.matchOrganizationFromOrganizationLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOrganizationLocationInsightTypeInsightName', () => { - const result = client.matchLocationFromOrganizationLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightTypeFromOrganizationLocationInsightTypeInsightName', () => { - const result = client.matchInsightTypeFromOrganizationLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "insightTypeValue"); - assert((client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightFromOrganizationLocationInsightTypeInsightName', () => { - const result = client.matchInsightFromOrganizationLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "insightValue"); - assert((client.pathTemplates.organizationLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organizationLocationRecommender', () => { - const fakePath = "/rendered/path/organizationLocationRecommender"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - recommender: "recommenderValue", - }; - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationLocationRecommenderPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationLocationRecommenderPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationLocationRecommenderPath', () => { - const result = client.organizationLocationRecommenderPath("organizationValue", "locationValue", "recommenderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationLocationRecommenderPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationLocationRecommenderName', () => { - const result = client.matchOrganizationFromOrganizationLocationRecommenderName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOrganizationLocationRecommenderName', () => { - const result = client.matchLocationFromOrganizationLocationRecommenderName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommenderFromOrganizationLocationRecommenderName', () => { - const result = client.matchRecommenderFromOrganizationLocationRecommenderName(fakePath); - assert.strictEqual(result, "recommenderValue"); - assert((client.pathTemplates.organizationLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organizationLocationRecommenderConfig', () => { - const fakePath = "/rendered/path/organizationLocationRecommenderConfig"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - recommender: "recommenderValue", - }; - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationLocationRecommenderConfigPath', () => { - const result = client.organizationLocationRecommenderConfigPath("organizationValue", "locationValue", "recommenderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationLocationRecommenderConfigName', () => { - const result = client.matchOrganizationFromOrganizationLocationRecommenderConfigName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOrganizationLocationRecommenderConfigName', () => { - const result = client.matchLocationFromOrganizationLocationRecommenderConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommenderFromOrganizationLocationRecommenderConfigName', () => { - const result = client.matchRecommenderFromOrganizationLocationRecommenderConfigName(fakePath); - assert.strictEqual(result, "recommenderValue"); - assert((client.pathTemplates.organizationLocationRecommenderConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organizationLocationRecommenderRecommendation', () => { - const fakePath = "/rendered/path/organizationLocationRecommenderRecommendation"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - recommender: "recommenderValue", - recommendation: "recommendationValue", - }; - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationLocationRecommenderRecommendationPath', () => { - const result = client.organizationLocationRecommenderRecommendationPath("organizationValue", "locationValue", "recommenderValue", "recommendationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationLocationRecommenderRecommendationName', () => { - const result = client.matchOrganizationFromOrganizationLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOrganizationLocationRecommenderRecommendationName', () => { - const result = client.matchLocationFromOrganizationLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommenderFromOrganizationLocationRecommenderRecommendationName', () => { - const result = client.matchRecommenderFromOrganizationLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "recommenderValue"); - assert((client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommendationFromOrganizationLocationRecommenderRecommendationName', () => { - const result = client.matchRecommendationFromOrganizationLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "recommendationValue"); - assert((client.pathTemplates.organizationLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationInsightType', () => { - const fakePath = "/rendered/path/projectLocationInsightType"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - insight_type: "insightTypeValue", - }; - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationInsightTypePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationInsightTypePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationInsightTypePath', () => { - const result = client.projectLocationInsightTypePath("projectValue", "locationValue", "insightTypeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationInsightTypePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationInsightTypeName', () => { - const result = client.matchProjectFromProjectLocationInsightTypeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationInsightTypeName', () => { - const result = client.matchLocationFromProjectLocationInsightTypeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightTypeFromProjectLocationInsightTypeName', () => { - const result = client.matchInsightTypeFromProjectLocationInsightTypeName(fakePath); - assert.strictEqual(result, "insightTypeValue"); - assert((client.pathTemplates.projectLocationInsightTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationInsightTypeConfig', () => { - const fakePath = "/rendered/path/projectLocationInsightTypeConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - insight_type: "insightTypeValue", - }; - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationInsightTypeConfigPath', () => { - const result = client.projectLocationInsightTypeConfigPath("projectValue", "locationValue", "insightTypeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationInsightTypeConfigName', () => { - const result = client.matchProjectFromProjectLocationInsightTypeConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationInsightTypeConfigName', () => { - const result = client.matchLocationFromProjectLocationInsightTypeConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightTypeFromProjectLocationInsightTypeConfigName', () => { - const result = client.matchInsightTypeFromProjectLocationInsightTypeConfigName(fakePath); - assert.strictEqual(result, "insightTypeValue"); - assert((client.pathTemplates.projectLocationInsightTypeConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationInsightTypeInsight', () => { - const fakePath = "/rendered/path/projectLocationInsightTypeInsight"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - insight_type: "insightTypeValue", - insight: "insightValue", - }; - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationInsightTypeInsightPath', () => { - const result = client.projectLocationInsightTypeInsightPath("projectValue", "locationValue", "insightTypeValue", "insightValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationInsightTypeInsightName', () => { - const result = client.matchProjectFromProjectLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationInsightTypeInsightName', () => { - const result = client.matchLocationFromProjectLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightTypeFromProjectLocationInsightTypeInsightName', () => { - const result = client.matchInsightTypeFromProjectLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "insightTypeValue"); - assert((client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInsightFromProjectLocationInsightTypeInsightName', () => { - const result = client.matchInsightFromProjectLocationInsightTypeInsightName(fakePath); - assert.strictEqual(result, "insightValue"); - assert((client.pathTemplates.projectLocationInsightTypeInsightPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationRecommender', () => { - const fakePath = "/rendered/path/projectLocationRecommender"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - recommender: "recommenderValue", - }; - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationRecommenderPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationRecommenderPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationRecommenderPath', () => { - const result = client.projectLocationRecommenderPath("projectValue", "locationValue", "recommenderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationRecommenderPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationRecommenderName', () => { - const result = client.matchProjectFromProjectLocationRecommenderName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationRecommenderName', () => { - const result = client.matchLocationFromProjectLocationRecommenderName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommenderFromProjectLocationRecommenderName', () => { - const result = client.matchRecommenderFromProjectLocationRecommenderName(fakePath); - assert.strictEqual(result, "recommenderValue"); - assert((client.pathTemplates.projectLocationRecommenderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationRecommenderConfig', () => { - const fakePath = "/rendered/path/projectLocationRecommenderConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - recommender: "recommenderValue", - }; - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationRecommenderConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationRecommenderConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationRecommenderConfigPath', () => { - const result = client.projectLocationRecommenderConfigPath("projectValue", "locationValue", "recommenderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationRecommenderConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationRecommenderConfigName', () => { - const result = client.matchProjectFromProjectLocationRecommenderConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationRecommenderConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationRecommenderConfigName', () => { - const result = client.matchLocationFromProjectLocationRecommenderConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationRecommenderConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommenderFromProjectLocationRecommenderConfigName', () => { - const result = client.matchRecommenderFromProjectLocationRecommenderConfigName(fakePath); - assert.strictEqual(result, "recommenderValue"); - assert((client.pathTemplates.projectLocationRecommenderConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationRecommenderRecommendation', () => { - const fakePath = "/rendered/path/projectLocationRecommenderRecommendation"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - recommender: "recommenderValue", - recommendation: "recommendationValue", - }; - const client = new recommenderModule.v1beta1.RecommenderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationRecommenderRecommendationPath', () => { - const result = client.projectLocationRecommenderRecommendationPath("projectValue", "locationValue", "recommenderValue", "recommendationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationRecommenderRecommendationName', () => { - const result = client.matchProjectFromProjectLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationRecommenderRecommendationName', () => { - const result = client.matchLocationFromProjectLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommenderFromProjectLocationRecommenderRecommendationName', () => { - const result = client.matchRecommenderFromProjectLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "recommenderValue"); - assert((client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecommendationFromProjectLocationRecommenderRecommendationName', () => { - const result = client.matchRecommendationFromProjectLocationRecommenderRecommendationName(fakePath); - assert.strictEqual(result, "recommendationValue"); - assert((client.pathTemplates.projectLocationRecommenderRecommendationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-recommender/v1beta1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-recommender/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-recommender/v1beta1/webpack.config.js deleted file mode 100644 index a74f57c48a0..00000000000 --- a/owl-bot-staging/google-cloud-recommender/v1beta1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'Recommender', - filename: './recommender.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-redis/v1/.eslintignore b/owl-bot-staging/google-cloud-redis/v1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-redis/v1/.eslintrc.json b/owl-bot-staging/google-cloud-redis/v1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-redis/v1/.gitignore b/owl-bot-staging/google-cloud-redis/v1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-redis/v1/.jsdoc.js b/owl-bot-staging/google-cloud-redis/v1/.jsdoc.js deleted file mode 100644 index 58332656788..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/.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/redis', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-redis/v1/.mocharc.js b/owl-bot-staging/google-cloud-redis/v1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/.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-redis/v1/.prettierrc.js b/owl-bot-staging/google-cloud-redis/v1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/.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-redis/v1/README.md b/owl-bot-staging/google-cloud-redis/v1/README.md deleted file mode 100644 index 3c11909fadc..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Redis: Nodejs Client diff --git a/owl-bot-staging/google-cloud-redis/v1/package.json b/owl-bot-staging/google-cloud-redis/v1/package.json deleted file mode 100644 index 0a5bbcc4645..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/redis", - "version": "0.1.0", - "description": "Redis client for Node.js", - "repository": "googleapis/nodejs-redis", - "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 redis", - "redis", - "cloud redis" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-redis/v1/protos/google/cloud/redis/v1/cloud_redis.proto b/owl-bot-staging/google-cloud-redis/v1/protos/google/cloud/redis/v1/cloud_redis.proto deleted file mode 100644 index 5ff9e9c8b4d..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/protos/google/cloud/redis/v1/cloud_redis.proto +++ /dev/null @@ -1,1000 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.redis.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/type/dayofweek.proto"; -import "google/type/timeofday.proto"; - -option go_package = "cloud.google.com/go/redis/apiv1/redispb;redispb"; -option java_multiple_files = true; -option java_outer_classname = "CloudRedisServiceV1Proto"; -option java_package = "com.google.cloud.redis.v1"; - -// Configures and manages Cloud Memorystore for Redis instances -// -// Google Cloud Memorystore for Redis v1 -// -// The `redis.googleapis.com` service implements the Google Cloud Memorystore -// for Redis API and defines the following resource model for managing Redis -// instances: -// * The service works with a collection of cloud projects, named: `/projects/*` -// * Each project has a collection of available locations, named: `/locations/*` -// * Each location has a collection of Redis instances, named: `/instances/*` -// * As such, Redis instances are resources of the form: -// `/projects/{project_id}/locations/{location_id}/instances/{instance_id}` -// -// Note that location_id must be referring to a GCP `region`; for example: -// * `projects/redpepper-1290/locations/us-central1/instances/my-redis` -service CloudRedis { - option (google.api.default_host) = "redis.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Lists all Redis instances owned by a project in either the specified - // location (region) or all locations. - // - // The location should have the following format: - // - // * `projects/{project_id}/locations/{location_id}` - // - // If `location_id` is specified as `-` (wildcard), then all regions - // available to the project are queried, and the results are aggregated. - rpc ListInstances(ListInstancesRequest) returns (ListInstancesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/instances" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets the details of a specific Redis instance. - rpc GetInstance(GetInstanceRequest) returns (Instance) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/instances/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Gets the AUTH string for a Redis instance. If AUTH is not enabled for the - // instance the response will be empty. This information is not included in - // the details returned to GetInstance. - rpc GetInstanceAuthString(GetInstanceAuthStringRequest) - returns (InstanceAuthString) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/instances/*}/authString" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a Redis instance based on the specified tier and memory size. - // - // By default, the instance is accessible from the project's - // [default network](https://cloud.google.com/vpc/docs/vpc). - // - // The creation is executed asynchronously and callers may check the returned - // operation to track its progress. Once the operation is completed the Redis - // instance will be fully functional. Completed longrunning.Operation will - // contain the new instance object in the response field. - // - // The returned operation is automatically deleted after a few hours, so there - // is no need to call DeleteOperation. - rpc CreateInstance(CreateInstanceRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/instances" - body: "instance" - }; - option (google.api.method_signature) = "parent,instance_id,instance"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.redis.v1.Instance" - metadata_type: "google.cloud.redis.v1.OperationMetadata" - }; - } - - // Updates the metadata and configuration of a specific Redis instance. - // - // Completed longrunning.Operation will contain the new instance object - // in the response field. The returned operation is automatically deleted - // after a few hours, so there is no need to call DeleteOperation. - rpc UpdateInstance(UpdateInstanceRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1/{instance.name=projects/*/locations/*/instances/*}" - body: "instance" - }; - option (google.api.method_signature) = "update_mask,instance"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.redis.v1.Instance" - metadata_type: "google.cloud.redis.v1.OperationMetadata" - }; - } - - // Upgrades Redis instance to the newer Redis version specified in the - // request. - rpc UpgradeInstance(UpgradeInstanceRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/instances/*}:upgrade" - body: "*" - }; - option (google.api.method_signature) = "name,redis_version"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.redis.v1.Instance" - metadata_type: "google.cloud.redis.v1.OperationMetadata" - }; - } - - // Import a Redis RDB snapshot file from Cloud Storage into a Redis instance. - // - // Redis may stop serving during this operation. Instance state will be - // IMPORTING for entire operation. When complete, the instance will contain - // only data from the imported file. - // - // The returned operation is automatically deleted after a few hours, so - // there is no need to call DeleteOperation. - rpc ImportInstance(ImportInstanceRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/instances/*}:import" - body: "*" - }; - option (google.api.method_signature) = "name,input_config"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.redis.v1.Instance" - metadata_type: "google.cloud.redis.v1.OperationMetadata" - }; - } - - // Export Redis instance data into a Redis RDB format file in Cloud Storage. - // - // Redis will continue serving during this operation. - // - // The returned operation is automatically deleted after a few hours, so - // there is no need to call DeleteOperation. - rpc ExportInstance(ExportInstanceRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/instances/*}:export" - body: "*" - }; - option (google.api.method_signature) = "name,output_config"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.redis.v1.Instance" - metadata_type: "google.cloud.redis.v1.OperationMetadata" - }; - } - - // Initiates a failover of the primary node to current replica node for a - // specific STANDARD tier Cloud Memorystore for Redis instance. - rpc FailoverInstance(FailoverInstanceRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/instances/*}:failover" - body: "*" - }; - option (google.api.method_signature) = "name,data_protection_mode"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.redis.v1.Instance" - metadata_type: "google.cloud.redis.v1.OperationMetadata" - }; - } - - // Deletes a specific Redis instance. Instance stops serving and data is - // deleted. - rpc DeleteInstance(DeleteInstanceRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/instances/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "google.cloud.redis.v1.OperationMetadata" - }; - } - - // Reschedule maintenance for a given instance in a given project and - // location. - rpc RescheduleMaintenance(RescheduleMaintenanceRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/instances/*}:rescheduleMaintenance" - body: "*" - }; - option (google.api.method_signature) = - "name, reschedule_type, schedule_time"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.redis.v1.Instance" - metadata_type: "google.cloud.redis.v1.OperationMetadata" - }; - } -} - -// Node specific properties. -message NodeInfo { - // Output only. Node identifying string. e.g. 'node-0', 'node-1' - string id = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Location of the node. - string zone = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A Memorystore for Redis instance. -message Instance { - option (google.api.resource) = { - type: "redis.googleapis.com/Instance" - pattern: "projects/{project}/locations/{location}/instances/{instance}" - }; - - // Represents the different states of a Redis instance. - enum State { - // Not set. - STATE_UNSPECIFIED = 0; - - // Redis instance is being created. - CREATING = 1; - - // Redis instance has been created and is fully usable. - READY = 2; - - // Redis instance configuration is being updated. Certain kinds of updates - // may cause the instance to become unusable while the update is in - // progress. - UPDATING = 3; - - // Redis instance is being deleted. - DELETING = 4; - - // Redis instance is being repaired and may be unusable. - REPAIRING = 5; - - // Maintenance is being performed on this Redis instance. - MAINTENANCE = 6; - - // Redis instance is importing data (availability may be affected). - IMPORTING = 8; - - // Redis instance is failing over (availability may be affected). - FAILING_OVER = 9; - } - - // Available service tiers to choose from - enum Tier { - // Not set. - TIER_UNSPECIFIED = 0; - - // BASIC tier: standalone instance - BASIC = 1; - - // STANDARD_HA tier: highly available primary/replica instances - STANDARD_HA = 3; - } - - // Available connection modes. - enum ConnectMode { - // Not set. - CONNECT_MODE_UNSPECIFIED = 0; - - // Connect via direct peering to the Memorystore for Redis hosted service. - DIRECT_PEERING = 1; - - // Connect your Memorystore for Redis instance using Private Service - // Access. Private services access provides an IP address range for multiple - // Google Cloud services, including Memorystore. - PRIVATE_SERVICE_ACCESS = 2; - } - - // Available TLS modes. - enum TransitEncryptionMode { - // Not set. - TRANSIT_ENCRYPTION_MODE_UNSPECIFIED = 0; - - // Client to Server traffic encryption enabled with server authentication. - SERVER_AUTHENTICATION = 1; - - // TLS is disabled for the instance. - DISABLED = 2; - } - - // Read replicas mode. - enum ReadReplicasMode { - // If not set, Memorystore Redis backend will default to - // READ_REPLICAS_DISABLED. - READ_REPLICAS_MODE_UNSPECIFIED = 0; - - // If disabled, read endpoint will not be provided and the instance cannot - // scale up or down the number of replicas. - READ_REPLICAS_DISABLED = 1; - - // If enabled, read endpoint will be provided and the instance can scale - // up and down the number of replicas. Not valid for basic tier. - READ_REPLICAS_ENABLED = 2; - } - - // Possible reasons for the instance to be in a "SUSPENDED" state. - enum SuspensionReason { - // Not set. - SUSPENSION_REASON_UNSPECIFIED = 0; - - // Something wrong with the CMEK key provided by customer. - CUSTOMER_MANAGED_KEY_ISSUE = 1; - } - - // Required. Unique name of the resource in this scope including project and - // location using the form: - // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - // - // Note: Redis instances are managed and addressed at regional level so - // location_id here refers to a GCP region; however, users may choose which - // specific zone (or collection of zones for cross-zone instances) an instance - // should be provisioned in. Refer to - // [location_id][google.cloud.redis.v1.Instance.location_id] and - // [alternative_location_id][google.cloud.redis.v1.Instance.alternative_location_id] - // fields for more details. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // An arbitrary and optional user-provided name for the instance. - string display_name = 2; - - // Resource labels to represent user provided metadata - map labels = 3; - - // Optional. The zone where the instance will be provisioned. If not provided, - // the service will choose a zone from the specified region for the instance. - // For standard tier, additional nodes will be added across multiple zones for - // protection against zonal failures. If specified, at least one node will be - // provisioned in this zone. - string location_id = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. If specified, at least one node will be provisioned in this zone - // in addition to the zone specified in location_id. Only applicable to - // standard tier. If provided, it must be a different zone from the one - // provided in [location_id]. Additional nodes beyond the first 2 will be - // placed in zones selected by the service. - string alternative_location_id = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The version of Redis software. - // If not provided, latest supported version will be used. Currently, the - // supported values are: - // - // * `REDIS_3_2` for Redis 3.2 compatibility - // * `REDIS_4_0` for Redis 4.0 compatibility (default) - // * `REDIS_5_0` for Redis 5.0 compatibility - // * `REDIS_6_X` for Redis 6.x compatibility - string redis_version = 7 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. For DIRECT_PEERING mode, the CIDR range of internal addresses - // that are reserved for this instance. Range must - // be unique and non-overlapping with existing subnets in an authorized - // network. For PRIVATE_SERVICE_ACCESS mode, the name of one allocated IP - // address ranges associated with this private service access connection. - // If not provided, the service will choose an unused /29 block, for - // example, 10.0.0.0/29 or 192.168.0.0/29. For READ_REPLICAS_ENABLED - // the default block size is /28. - string reserved_ip_range = 9 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Additional IP range for node placement. Required when enabling - // read replicas on an existing instance. For DIRECT_PEERING mode value must - // be a CIDR range of size /28, or "auto". For PRIVATE_SERVICE_ACCESS mode - // value must be the name of an allocated address range associated with the - // private service access connection, or "auto". - string secondary_ip_range = 30 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. Hostname or IP address of the exposed Redis endpoint used by - // clients to connect to the service. - string host = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The port number of the exposed Redis endpoint. - int32 port = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The current zone where the Redis primary node is located. In - // basic tier, this will always be the same as [location_id]. In - // standard tier, this can be the zone of any node in the instance. - string current_location_id = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time the instance was created. - google.protobuf.Timestamp create_time = 13 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The current state of this instance. - State state = 14 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Additional information about the current status of this - // instance, if available. - string status_message = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Redis configuration parameters, according to - // http://redis.io/topics/config. Currently, the only supported parameters - // are: - // - // Redis version 3.2 and newer: - // - // * maxmemory-policy - // * notify-keyspace-events - // - // Redis version 4.0 and newer: - // - // * activedefrag - // * lfu-decay-time - // * lfu-log-factor - // * maxmemory-gb - // - // Redis version 5.0 and newer: - // - // * stream-node-max-bytes - // * stream-node-max-entries - map redis_configs = 16 - [(google.api.field_behavior) = OPTIONAL]; - - // Required. The service tier of the instance. - Tier tier = 17 [(google.api.field_behavior) = REQUIRED]; - - // Required. Redis memory size in GiB. - int32 memory_size_gb = 18 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The full name of the Google Compute Engine - // [network](https://cloud.google.com/vpc/docs/vpc) to which the - // instance is connected. If left unspecified, the `default` network - // will be used. - string authorized_network = 20 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. Cloud IAM identity used by import / export operations to - // transfer data to/from Cloud Storage. Format is - // "serviceAccount:". The value may change over time - // for a given instance so should be checked before each import/export - // operation. - string persistence_iam_identity = 21 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. The network connect mode of the Redis instance. - // If not provided, the connect mode defaults to DIRECT_PEERING. - ConnectMode connect_mode = 22 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Indicates whether OSS Redis AUTH is enabled for the instance. If - // set to "true" AUTH is enabled on the instance. Default value is "false" - // meaning AUTH is disabled. - bool auth_enabled = 23 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. List of server CA certificates for the instance. - repeated TlsCertificate server_ca_certs = 25 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. The TLS mode of the Redis instance. - // If not provided, TLS is disabled for the instance. - TransitEncryptionMode transit_encryption_mode = 26 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The maintenance policy for the instance. If not provided, - // maintenance events can be performed at any time. - MaintenancePolicy maintenance_policy = 27 - [(google.api.field_behavior) = OPTIONAL]; - - // Output only. Date and time of upcoming maintenance events which have been - // scheduled. - MaintenanceSchedule maintenance_schedule = 28 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. The number of replica nodes. The valid range for the Standard - // Tier with read replicas enabled is [1-5] and defaults to 2. If read - // replicas are not enabled for a Standard Tier instance, the only valid value - // is 1 and the default is 1. The valid value for basic tier is 0 and the - // default is also 0. - int32 replica_count = 31 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. Info per node. - repeated NodeInfo nodes = 32 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Hostname or IP address of the exposed readonly Redis - // endpoint. Standard tier only. Targets all healthy replica nodes in - // instance. Replication is asynchronous and replica nodes will exhibit some - // lag behind the primary. Write requests must target 'host'. - string read_endpoint = 33 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The port number of the exposed readonly redis - // endpoint. Standard tier only. Write requests should target 'port'. - int32 read_endpoint_port = 34 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Read replicas mode for the instance. Defaults to - // READ_REPLICAS_DISABLED. - ReadReplicasMode read_replicas_mode = 35 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The KMS key reference that the customer provides when trying to - // create the instance. - string customer_managed_key = 36 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Persistence configuration parameters - PersistenceConfig persistence_config = 37 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. reasons that causes instance in "SUSPENDED" state. - repeated SuspensionReason suspension_reasons = 38 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The self service update maintenance version. - // The version is date based such as "20210712_00_00". - string maintenance_version = 39 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The available maintenance versions that an instance could update - // to. - repeated string available_maintenance_versions = 40 - [(google.api.field_behavior) = OPTIONAL]; -} - -// Configuration of the persistence functionality. -message PersistenceConfig { - // Available Persistence modes. - enum PersistenceMode { - // Not set. - PERSISTENCE_MODE_UNSPECIFIED = 0; - - // Persistence is disabled for the instance, - // and any existing snapshots are deleted. - DISABLED = 1; - - // RDB based Persistence is enabled. - RDB = 2; - } - - // Available snapshot periods for scheduling. - enum SnapshotPeriod { - // Not set. - SNAPSHOT_PERIOD_UNSPECIFIED = 0; - - // Snapshot every 1 hour. - ONE_HOUR = 3; - - // Snapshot every 6 hours. - SIX_HOURS = 4; - - // Snapshot every 12 hours. - TWELVE_HOURS = 5; - - // Snapshot every 24 hours. - TWENTY_FOUR_HOURS = 6; - } - - // Optional. Controls whether Persistence features are enabled. - // If not provided, the existing value will be used. - PersistenceMode persistence_mode = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Period between RDB snapshots. Snapshots will be attempted every - // period starting from the provided snapshot start time. For example, a start - // time of 01/01/2033 06:45 and SIX_HOURS snapshot period will do nothing - // until 01/01/2033, and then trigger snapshots every day at 06:45, 12:45, - // 18:45, and 00:45 the next day, and so on. If not provided, - // TWENTY_FOUR_HOURS will be used as default. - SnapshotPeriod rdb_snapshot_period = 2 - [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The next time that a snapshot attempt is scheduled to occur. - google.protobuf.Timestamp rdb_next_snapshot_time = 4 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Date and time that the first snapshot was/will be attempted, and - // to which future snapshots will be aligned. If not provided, the current - // time will be used. - google.protobuf.Timestamp rdb_snapshot_start_time = 5 - [(google.api.field_behavior) = OPTIONAL]; -} - -// Request for -// [RescheduleMaintenance][google.cloud.redis.v1.CloudRedis.RescheduleMaintenance]. -message RescheduleMaintenanceRequest { - // Reschedule options. - enum RescheduleType { - // Not set. - RESCHEDULE_TYPE_UNSPECIFIED = 0; - - // If the user wants to schedule the maintenance to happen now. - IMMEDIATE = 1; - - // If the user wants to use the existing maintenance policy to find the - // next available window. - NEXT_AVAILABLE_WINDOW = 2; - - // If the user wants to reschedule the maintenance to a specific time. - SPECIFIC_TIME = 3; - } - - // Required. Redis instance resource name using the form: - // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - // where `location_id` refers to a GCP region. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "redis.googleapis.com/Instance" } - ]; - - // Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as - // well. - RescheduleType reschedule_type = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Timestamp when the maintenance shall be rescheduled to if - // reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for - // example `2012-11-15T16:19:00.094Z`. - google.protobuf.Timestamp schedule_time = 3 - [(google.api.field_behavior) = OPTIONAL]; -} - -// Maintenance policy for an instance. -message MaintenancePolicy { - // Output only. The time when the policy was created. - google.protobuf.Timestamp create_time = 1 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time when the policy was last updated. - google.protobuf.Timestamp update_time = 2 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Description of what this policy is for. Create/Update methods - // return INVALID_ARGUMENT if the length is greater than 512. - string description = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Maintenance window that is applied to resources covered by this - // policy. Minimum 1. For the current version, the maximum number of - // weekly_window is expected to be one. - repeated WeeklyMaintenanceWindow weekly_maintenance_window = 4 - [(google.api.field_behavior) = OPTIONAL]; -} - -// Time window in which disruptive maintenance updates occur. Non-disruptive -// updates can occur inside or outside this window. -message WeeklyMaintenanceWindow { - // Required. The day of week that maintenance updates occur. - google.type.DayOfWeek day = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Start time of the window in UTC time. - google.type.TimeOfDay start_time = 2 [(google.api.field_behavior) = REQUIRED]; - - // Output only. Duration of the maintenance window. The current window is - // fixed at 1 hour. - google.protobuf.Duration duration = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Upcoming maintenance schedule. If no maintenance is scheduled, fields are not -// populated. -message MaintenanceSchedule { - // Output only. The start time of any upcoming scheduled maintenance for this - // instance. - google.protobuf.Timestamp start_time = 1 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The end time of any upcoming scheduled maintenance for this - // instance. - google.protobuf.Timestamp end_time = 2 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // If the scheduled maintenance can be rescheduled, default is true. - bool can_reschedule = 3 [deprecated = true]; - - // Output only. The deadline that the maintenance schedule start time can not - // go beyond, including reschedule. - google.protobuf.Timestamp schedule_deadline_time = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Request for [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances]. -message ListInstancesRequest { - // Required. The resource name of the instance location using the form: - // `projects/{project_id}/locations/{location_id}` - // where `location_id` refers to a GCP region. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. - // - // If not specified, a default value of 1000 will be used by the service. - // Regardless of the page_size value, the response may include a partial list - // and a caller should only rely on response's - // [`next_page_token`][google.cloud.redis.v1.ListInstancesResponse.next_page_token] - // to determine if there are more instances left to be queried. - int32 page_size = 2; - - // The `next_page_token` value returned from a previous - // [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances] request, if - // any. - string page_token = 3; -} - -// Response for [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances]. -message ListInstancesResponse { - // A list of Redis instances in the project in the specified location, - // or across all locations. - // - // If the `location_id` in the parent field of the request is "-", all regions - // available to the project are queried, and the results aggregated. - // If in such an aggregated query a location is unavailable, a placeholder - // Redis entry is included in the response with the `name` field set to a - // value of the form - // `projects/{project_id}/locations/{location_id}/instances/`- and the - // `status` field set to ERROR and `status_message` field set to "location not - // available for ListInstances". - repeated Instance instances = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; - - // Locations that could not be reached. - repeated string unreachable = 3; -} - -// Request for [GetInstance][google.cloud.redis.v1.CloudRedis.GetInstance]. -message GetInstanceRequest { - // Required. Redis instance resource name using the form: - // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - // where `location_id` refers to a GCP region. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "redis.googleapis.com/Instance" } - ]; -} - -// Request for -// [GetInstanceAuthString][google.cloud.redis.v1.CloudRedis.GetInstanceAuthString]. -message GetInstanceAuthStringRequest { - // Required. Redis instance resource name using the form: - // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - // where `location_id` refers to a GCP region. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "redis.googleapis.com/Instance" } - ]; -} - -// Instance AUTH string details. -message InstanceAuthString { - // AUTH string set on the instance. - string auth_string = 1; -} - -// Request for -// [CreateInstance][google.cloud.redis.v1.CloudRedis.CreateInstance]. -message CreateInstanceRequest { - // Required. The resource name of the instance location using the form: - // `projects/{project_id}/locations/{location_id}` - // where `location_id` refers to a GCP region. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The logical name of the Redis instance in the customer project - // with the following restrictions: - // - // * Must contain only lowercase letters, numbers, and hyphens. - // * Must start with a letter. - // * Must be between 1-40 characters. - // * Must end with a number or a letter. - // * Must be unique within the customer project / location - string instance_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. A Redis [Instance] resource - Instance instance = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for -// [UpdateInstance][google.cloud.redis.v1.CloudRedis.UpdateInstance]. -message UpdateInstanceRequest { - // Required. Mask of fields to update. At least one path must be supplied in - // this field. The elements of the repeated paths field may only include these - // fields from [Instance][google.cloud.redis.v1.Instance]: - // - // * `displayName` - // * `labels` - // * `memorySizeGb` - // * `redisConfig` - // * `replica_count` - google.protobuf.FieldMask update_mask = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. Update description. - // Only fields specified in update_mask are updated. - Instance instance = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for -// [UpgradeInstance][google.cloud.redis.v1.CloudRedis.UpgradeInstance]. -message UpgradeInstanceRequest { - // Required. Redis instance resource name using the form: - // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - // where `location_id` refers to a GCP region. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "redis.googleapis.com/Instance" } - ]; - - // Required. Specifies the target version of Redis software to upgrade to. - string redis_version = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for -// [DeleteInstance][google.cloud.redis.v1.CloudRedis.DeleteInstance]. -message DeleteInstanceRequest { - // Required. Redis instance resource name using the form: - // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - // where `location_id` refers to a GCP region. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "redis.googleapis.com/Instance" } - ]; -} - -// The Cloud Storage location for the input content -message GcsSource { - // Required. Source data URI. (e.g. 'gs://my_bucket/my_object'). - string uri = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// The input content -message InputConfig { - // Required. Specify source location of input data - oneof source { - // Google Cloud Storage location where input content is located. - GcsSource gcs_source = 1; - } -} - -// Request for [Import][google.cloud.redis.v1.CloudRedis.ImportInstance]. -message ImportInstanceRequest { - // Required. Redis instance resource name using the form: - // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - // where `location_id` refers to a GCP region. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Specify data to be imported. - InputConfig input_config = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// The Cloud Storage location for the output content -message GcsDestination { - // Required. Data destination URI (e.g. - // 'gs://my_bucket/my_object'). Existing files will be overwritten. - string uri = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// The output content -message OutputConfig { - // Required. Specify destination location of output data - oneof destination { - // Google Cloud Storage destination for output content. - GcsDestination gcs_destination = 1; - } -} - -// Request for [Export][google.cloud.redis.v1.CloudRedis.ExportInstance]. -message ExportInstanceRequest { - // Required. Redis instance resource name using the form: - // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - // where `location_id` refers to a GCP region. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Specify data to be exported. - OutputConfig output_config = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for [Failover][google.cloud.redis.v1.CloudRedis.FailoverInstance]. -message FailoverInstanceRequest { - // Specifies different modes of operation in relation to the data retention. - enum DataProtectionMode { - // Defaults to LIMITED_DATA_LOSS if a data protection mode is not - // specified. - DATA_PROTECTION_MODE_UNSPECIFIED = 0; - - // Instance failover will be protected with data loss control. More - // specifically, the failover will only be performed if the current - // replication offset diff between primary and replica is under a certain - // threshold. - LIMITED_DATA_LOSS = 1; - - // Instance failover will be performed without data loss control. - FORCE_DATA_LOSS = 2; - } - - // Required. Redis instance resource name using the form: - // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - // where `location_id` refers to a GCP region. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "redis.googleapis.com/Instance" } - ]; - - // Optional. Available data protection modes that the user can choose. If it's - // unspecified, data protection mode will be LIMITED_DATA_LOSS by default. - DataProtectionMode data_protection_mode = 2 - [(google.api.field_behavior) = OPTIONAL]; -} - -// Represents the v1 metadata of the long-running operation. -message OperationMetadata { - // Creation timestamp. - google.protobuf.Timestamp create_time = 1; - - // End timestamp. - google.protobuf.Timestamp end_time = 2; - - // Operation target. - string target = 3; - - // Operation verb. - string verb = 4; - - // Operation status details. - string status_detail = 5; - - // Specifies if cancellation was requested for the operation. - bool cancel_requested = 6; - - // API version. - string api_version = 7; -} - -// This location metadata represents additional configuration options for a -// given location where a Redis instance may be created. All fields are output -// only. It is returned as content of the -// `google.cloud.location.Location.metadata` field. -message LocationMetadata { - // Output only. The set of available zones in the location. The map is keyed - // by the lowercase ID of each zone, as defined by GCE. These keys can be - // specified in `location_id` or `alternative_location_id` fields when - // creating a Redis instance. - map available_zones = 1 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Defines specific information for a particular zone. Currently empty and -// reserved for future use only. -message ZoneMetadata {} - -// TlsCertificate Resource -message TlsCertificate { - // Serial number, as extracted from the certificate. - string serial_number = 1; - - // PEM representation. - string cert = 2; - - // Output only. The time when the certificate was created in [RFC - // 3339](https://tools.ietf.org/html/rfc3339) format, for example - // `2020-05-18T00:00:00.094Z`. - google.protobuf.Timestamp create_time = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time when the certificate expires in [RFC - // 3339](https://tools.ietf.org/html/rfc3339) format, for example - // `2020-05-18T00:00:00.094Z`. - google.protobuf.Timestamp expire_time = 4 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Sha1 Fingerprint of the certificate. - string sha1_fingerprint = 5; -} diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.create_instance.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.create_instance.js deleted file mode 100644 index 44ec7a006d1..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.create_instance.js +++ /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. ** - - - -'use strict'; - -function main(parent, instanceId, instance) { - // [START redis_v1_generated_CloudRedis_CreateInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 instance location using the form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a GCP region. - */ - // const parent = 'abc123' - /** - * Required. The logical name of the Redis instance in the customer project - * with the following restrictions: - * * Must contain only lowercase letters, numbers, and hyphens. - * * Must start with a letter. - * * Must be between 1-40 characters. - * * Must end with a number or a letter. - * * Must be unique within the customer project / location - */ - // const instanceId = 'abc123' - /** - * Required. A Redis Instance resource - */ - // const instance = {} - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callCreateInstance() { - // Construct request - const request = { - parent, - instanceId, - instance, - }; - - // Run request - const [operation] = await redisClient.createInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateInstance(); - // [END redis_v1_generated_CloudRedis_CreateInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.delete_instance.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.delete_instance.js deleted file mode 100644 index bf8aa68a10f..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.delete_instance.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 redis_v1_generated_CloudRedis_DeleteInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - */ - // const name = 'abc123' - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callDeleteInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await redisClient.deleteInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteInstance(); - // [END redis_v1_generated_CloudRedis_DeleteInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.export_instance.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.export_instance.js deleted file mode 100644 index e016826720e..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.export_instance.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(name, outputConfig) { - // [START redis_v1_generated_CloudRedis_ExportInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - */ - // const name = 'abc123' - /** - * Required. Specify data to be exported. - */ - // const outputConfig = {} - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callExportInstance() { - // Construct request - const request = { - name, - outputConfig, - }; - - // Run request - const [operation] = await redisClient.exportInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callExportInstance(); - // [END redis_v1_generated_CloudRedis_ExportInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.failover_instance.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.failover_instance.js deleted file mode 100644 index c045c6abb8c..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.failover_instance.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(name) { - // [START redis_v1_generated_CloudRedis_FailoverInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - */ - // const name = 'abc123' - /** - * Optional. Available data protection modes that the user can choose. If it's - * unspecified, data protection mode will be LIMITED_DATA_LOSS by default. - */ - // const dataProtectionMode = {} - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callFailoverInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await redisClient.failoverInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callFailoverInstance(); - // [END redis_v1_generated_CloudRedis_FailoverInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.get_instance.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.get_instance.js deleted file mode 100644 index 4d1b5de8b86..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.get_instance.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 redis_v1_generated_CloudRedis_GetInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - */ - // const name = 'abc123' - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callGetInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await redisClient.getInstance(request); - console.log(response); - } - - callGetInstance(); - // [END redis_v1_generated_CloudRedis_GetInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.get_instance_auth_string.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.get_instance_auth_string.js deleted file mode 100644 index 351348a5564..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.get_instance_auth_string.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 redis_v1_generated_CloudRedis_GetInstanceAuthString_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - */ - // const name = 'abc123' - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callGetInstanceAuthString() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await redisClient.getInstanceAuthString(request); - console.log(response); - } - - callGetInstanceAuthString(); - // [END redis_v1_generated_CloudRedis_GetInstanceAuthString_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.import_instance.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.import_instance.js deleted file mode 100644 index af82752a890..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.import_instance.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(name, inputConfig) { - // [START redis_v1_generated_CloudRedis_ImportInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - */ - // const name = 'abc123' - /** - * Required. Specify data to be imported. - */ - // const inputConfig = {} - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callImportInstance() { - // Construct request - const request = { - name, - inputConfig, - }; - - // Run request - const [operation] = await redisClient.importInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportInstance(); - // [END redis_v1_generated_CloudRedis_ImportInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.list_instances.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.list_instances.js deleted file mode 100644 index 03d418c4679..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.list_instances.js +++ /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. ** - - - -'use strict'; - -function main(parent) { - // [START redis_v1_generated_CloudRedis_ListInstances_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 instance location using the form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a GCP region. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. - * If not specified, a default value of 1000 will be used by the service. - * Regardless of the page_size value, the response may include a partial list - * and a caller should only rely on response's - * `next_page_token` google.cloud.redis.v1.ListInstancesResponse.next_page_token - * to determine if there are more instances left to be queried. - */ - // const pageSize = 1234 - /** - * The `next_page_token` value returned from a previous - * ListInstances google.cloud.redis.v1.CloudRedis.ListInstances request, if - * any. - */ - // const pageToken = 'abc123' - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callListInstances() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await redisClient.listInstancesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListInstances(); - // [END redis_v1_generated_CloudRedis_ListInstances_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.reschedule_maintenance.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.reschedule_maintenance.js deleted file mode 100644 index 99f271bcea7..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.reschedule_maintenance.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(name, rescheduleType) { - // [START redis_v1_generated_CloudRedis_RescheduleMaintenance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - */ - // const name = 'abc123' - /** - * Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as - * well. - */ - // const rescheduleType = {} - /** - * Optional. Timestamp when the maintenance shall be rescheduled to if - * reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for - * example `2012-11-15T16:19:00.094Z`. - */ - // const scheduleTime = {} - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callRescheduleMaintenance() { - // Construct request - const request = { - name, - rescheduleType, - }; - - // Run request - const [operation] = await redisClient.rescheduleMaintenance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRescheduleMaintenance(); - // [END redis_v1_generated_CloudRedis_RescheduleMaintenance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.update_instance.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.update_instance.js deleted file mode 100644 index ecff8e6f8e8..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.update_instance.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(updateMask, instance) { - // [START redis_v1_generated_CloudRedis_UpdateInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Mask of fields to update. At least one path must be supplied in - * this field. The elements of the repeated paths field may only include these - * fields from Instance google.cloud.redis.v1.Instance: - * * `displayName` - * * `labels` - * * `memorySizeGb` - * * `redisConfig` - * * `replica_count` - */ - // const updateMask = {} - /** - * Required. Update description. - * Only fields specified in update_mask are updated. - */ - // const instance = {} - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callUpdateInstance() { - // Construct request - const request = { - updateMask, - instance, - }; - - // Run request - const [operation] = await redisClient.updateInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateInstance(); - // [END redis_v1_generated_CloudRedis_UpdateInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.upgrade_instance.js b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.upgrade_instance.js deleted file mode 100644 index 7d695208636..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/cloud_redis.upgrade_instance.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(name, redisVersion) { - // [START redis_v1_generated_CloudRedis_UpgradeInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - */ - // const name = 'abc123' - /** - * Required. Specifies the target version of Redis software to upgrade to. - */ - // const redisVersion = 'abc123' - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callUpgradeInstance() { - // Construct request - const request = { - name, - redisVersion, - }; - - // Run request - const [operation] = await redisClient.upgradeInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpgradeInstance(); - // [END redis_v1_generated_CloudRedis_UpgradeInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/snippet_metadata_google.cloud.redis.v1.json b/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/snippet_metadata_google.cloud.redis.v1.json deleted file mode 100644 index 0f896b00319..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/samples/generated/v1/snippet_metadata_google.cloud.redis.v1.json +++ /dev/null @@ -1,499 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-redis", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.redis.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "redis_v1_generated_CloudRedis_ListInstances_async", - "title": "CloudRedis listInstances Sample", - "origin": "API_DEFINITION", - "description": " Lists all Redis instances owned by a project in either the specified location (region) or all locations. The location should have the following format: * `projects/{project_id}/locations/{location_id}` If `location_id` is specified as `-` (wildcard), then all regions available to the project are queried, and the results are aggregated.", - "canonical": true, - "file": "cloud_redis.list_instances.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListInstances", - "fullName": "google.cloud.redis.v1.CloudRedis.ListInstances", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.redis.v1.ListInstancesResponse", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1.CloudRedisClient" - }, - "method": { - "shortName": "ListInstances", - "fullName": "google.cloud.redis.v1.CloudRedis.ListInstances", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1.CloudRedis" - } - } - } - }, - { - "regionTag": "redis_v1_generated_CloudRedis_GetInstance_async", - "title": "CloudRedis getInstance Sample", - "origin": "API_DEFINITION", - "description": " Gets the details of a specific Redis instance.", - "canonical": true, - "file": "cloud_redis.get_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetInstance", - "fullName": "google.cloud.redis.v1.CloudRedis.GetInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.redis.v1.Instance", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1.CloudRedisClient" - }, - "method": { - "shortName": "GetInstance", - "fullName": "google.cloud.redis.v1.CloudRedis.GetInstance", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1.CloudRedis" - } - } - } - }, - { - "regionTag": "redis_v1_generated_CloudRedis_GetInstanceAuthString_async", - "title": "CloudRedis getInstanceAuthString Sample", - "origin": "API_DEFINITION", - "description": " Gets the AUTH string for a Redis instance. If AUTH is not enabled for the instance the response will be empty. This information is not included in the details returned to GetInstance.", - "canonical": true, - "file": "cloud_redis.get_instance_auth_string.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetInstanceAuthString", - "fullName": "google.cloud.redis.v1.CloudRedis.GetInstanceAuthString", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.redis.v1.InstanceAuthString", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1.CloudRedisClient" - }, - "method": { - "shortName": "GetInstanceAuthString", - "fullName": "google.cloud.redis.v1.CloudRedis.GetInstanceAuthString", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1.CloudRedis" - } - } - } - }, - { - "regionTag": "redis_v1_generated_CloudRedis_CreateInstance_async", - "title": "CloudRedis createInstance Sample", - "origin": "API_DEFINITION", - "description": " Creates a Redis instance based on the specified tier and memory size. By default, the instance is accessible from the project's [default network](https://cloud.google.com/vpc/docs/vpc). The creation is executed asynchronously and callers may check the returned operation to track its progress. Once the operation is completed the Redis instance will be fully functional. Completed longrunning.Operation will contain the new instance object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.", - "canonical": true, - "file": "cloud_redis.create_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateInstance", - "fullName": "google.cloud.redis.v1.CloudRedis.CreateInstance", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "instance_id", - "type": "TYPE_STRING" - }, - { - "name": "instance", - "type": ".google.cloud.redis.v1.Instance" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1.CloudRedisClient" - }, - "method": { - "shortName": "CreateInstance", - "fullName": "google.cloud.redis.v1.CloudRedis.CreateInstance", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1.CloudRedis" - } - } - } - }, - { - "regionTag": "redis_v1_generated_CloudRedis_UpdateInstance_async", - "title": "CloudRedis updateInstance Sample", - "origin": "API_DEFINITION", - "description": " Updates the metadata and configuration of a specific Redis instance. Completed longrunning.Operation will contain the new instance object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.", - "canonical": true, - "file": "cloud_redis.update_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateInstance", - "fullName": "google.cloud.redis.v1.CloudRedis.UpdateInstance", - "async": true, - "parameters": [ - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "instance", - "type": ".google.cloud.redis.v1.Instance" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1.CloudRedisClient" - }, - "method": { - "shortName": "UpdateInstance", - "fullName": "google.cloud.redis.v1.CloudRedis.UpdateInstance", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1.CloudRedis" - } - } - } - }, - { - "regionTag": "redis_v1_generated_CloudRedis_UpgradeInstance_async", - "title": "CloudRedis upgradeInstance Sample", - "origin": "API_DEFINITION", - "description": " Upgrades Redis instance to the newer Redis version specified in the request.", - "canonical": true, - "file": "cloud_redis.upgrade_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpgradeInstance", - "fullName": "google.cloud.redis.v1.CloudRedis.UpgradeInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "redis_version", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1.CloudRedisClient" - }, - "method": { - "shortName": "UpgradeInstance", - "fullName": "google.cloud.redis.v1.CloudRedis.UpgradeInstance", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1.CloudRedis" - } - } - } - }, - { - "regionTag": "redis_v1_generated_CloudRedis_ImportInstance_async", - "title": "CloudRedis importInstance Sample", - "origin": "API_DEFINITION", - "description": " Import a Redis RDB snapshot file from Cloud Storage into a Redis instance. Redis may stop serving during this operation. Instance state will be IMPORTING for entire operation. When complete, the instance will contain only data from the imported file. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.", - "canonical": true, - "file": "cloud_redis.import_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportInstance", - "fullName": "google.cloud.redis.v1.CloudRedis.ImportInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.redis.v1.InputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1.CloudRedisClient" - }, - "method": { - "shortName": "ImportInstance", - "fullName": "google.cloud.redis.v1.CloudRedis.ImportInstance", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1.CloudRedis" - } - } - } - }, - { - "regionTag": "redis_v1_generated_CloudRedis_ExportInstance_async", - "title": "CloudRedis exportInstance Sample", - "origin": "API_DEFINITION", - "description": " Export Redis instance data into a Redis RDB format file in Cloud Storage. Redis will continue serving during this operation. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.", - "canonical": true, - "file": "cloud_redis.export_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ExportInstance", - "fullName": "google.cloud.redis.v1.CloudRedis.ExportInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "output_config", - "type": ".google.cloud.redis.v1.OutputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1.CloudRedisClient" - }, - "method": { - "shortName": "ExportInstance", - "fullName": "google.cloud.redis.v1.CloudRedis.ExportInstance", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1.CloudRedis" - } - } - } - }, - { - "regionTag": "redis_v1_generated_CloudRedis_FailoverInstance_async", - "title": "CloudRedis failoverInstance Sample", - "origin": "API_DEFINITION", - "description": " Initiates a failover of the primary node to current replica node for a specific STANDARD tier Cloud Memorystore for Redis instance.", - "canonical": true, - "file": "cloud_redis.failover_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "FailoverInstance", - "fullName": "google.cloud.redis.v1.CloudRedis.FailoverInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "data_protection_mode", - "type": ".google.cloud.redis.v1.FailoverInstanceRequest.DataProtectionMode" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1.CloudRedisClient" - }, - "method": { - "shortName": "FailoverInstance", - "fullName": "google.cloud.redis.v1.CloudRedis.FailoverInstance", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1.CloudRedis" - } - } - } - }, - { - "regionTag": "redis_v1_generated_CloudRedis_DeleteInstance_async", - "title": "CloudRedis deleteInstance Sample", - "origin": "API_DEFINITION", - "description": " Deletes a specific Redis instance. Instance stops serving and data is deleted.", - "canonical": true, - "file": "cloud_redis.delete_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteInstance", - "fullName": "google.cloud.redis.v1.CloudRedis.DeleteInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1.CloudRedisClient" - }, - "method": { - "shortName": "DeleteInstance", - "fullName": "google.cloud.redis.v1.CloudRedis.DeleteInstance", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1.CloudRedis" - } - } - } - }, - { - "regionTag": "redis_v1_generated_CloudRedis_RescheduleMaintenance_async", - "title": "CloudRedis rescheduleMaintenance Sample", - "origin": "API_DEFINITION", - "description": " Reschedule maintenance for a given instance in a given project and location.", - "canonical": true, - "file": "cloud_redis.reschedule_maintenance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RescheduleMaintenance", - "fullName": "google.cloud.redis.v1.CloudRedis.RescheduleMaintenance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "reschedule_type", - "type": ".google.cloud.redis.v1.RescheduleMaintenanceRequest.RescheduleType" - }, - { - "name": "schedule_time", - "type": ".google.protobuf.Timestamp" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1.CloudRedisClient" - }, - "method": { - "shortName": "RescheduleMaintenance", - "fullName": "google.cloud.redis.v1.CloudRedis.RescheduleMaintenance", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1.CloudRedis" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-redis/v1/src/index.ts b/owl-bot-staging/google-cloud-redis/v1/src/index.ts deleted file mode 100644 index 634b7700cdd..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/src/index.ts +++ /dev/null @@ -1,25 +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 v1 from './v1'; -const CloudRedisClient = v1.CloudRedisClient; -type CloudRedisClient = v1.CloudRedisClient; -export {v1, CloudRedisClient}; -export default {v1, CloudRedisClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_client.ts b/owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_client.ts deleted file mode 100644 index ca0520900a5..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_client.ts +++ /dev/null @@ -1,1923 +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/v1/cloud_redis_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './cloud_redis_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Configures and manages Cloud Memorystore for Redis instances - * - * Google Cloud Memorystore for Redis v1 - * - * The `redis.googleapis.com` service implements the Google Cloud Memorystore - * for Redis API and defines the following resource model for managing Redis - * instances: - * * The service works with a collection of cloud projects, named: `/projects/*` - * * Each project has a collection of available locations, named: `/locations/*` - * * Each location has a collection of Redis instances, named: `/instances/*` - * * As such, Redis instances are resources of the form: - * `/projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * - * Note that location_id must be referring to a GCP `region`; for example: - * * `projects/redpepper-1290/locations/us-central1/instances/my-redis` - * @class - * @memberof v1 - */ -export class CloudRedisClient { - 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; - cloudRedisStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CloudRedisClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 CloudRedisClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof CloudRedisClient; - 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 { - 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 = { - instancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - }; - - // 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 = { - listInstances: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instances') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.redis.v1.Instance') as gax.protobuf.Type; - const createInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.redis.v1.OperationMetadata') as gax.protobuf.Type; - const updateInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.redis.v1.Instance') as gax.protobuf.Type; - const updateInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.redis.v1.OperationMetadata') as gax.protobuf.Type; - const upgradeInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.redis.v1.Instance') as gax.protobuf.Type; - const upgradeInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.redis.v1.OperationMetadata') as gax.protobuf.Type; - const importInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.redis.v1.Instance') as gax.protobuf.Type; - const importInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.redis.v1.OperationMetadata') as gax.protobuf.Type; - const exportInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.redis.v1.Instance') as gax.protobuf.Type; - const exportInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.redis.v1.OperationMetadata') as gax.protobuf.Type; - const failoverInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.redis.v1.Instance') as gax.protobuf.Type; - const failoverInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.redis.v1.OperationMetadata') as gax.protobuf.Type; - const deleteInstanceResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.redis.v1.OperationMetadata') as gax.protobuf.Type; - const rescheduleMaintenanceResponse = protoFilesRoot.lookup( - '.google.cloud.redis.v1.Instance') as gax.protobuf.Type; - const rescheduleMaintenanceMetadata = protoFilesRoot.lookup( - '.google.cloud.redis.v1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createInstanceResponse.decode.bind(createInstanceResponse), - createInstanceMetadata.decode.bind(createInstanceMetadata)), - updateInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateInstanceResponse.decode.bind(updateInstanceResponse), - updateInstanceMetadata.decode.bind(updateInstanceMetadata)), - upgradeInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - upgradeInstanceResponse.decode.bind(upgradeInstanceResponse), - upgradeInstanceMetadata.decode.bind(upgradeInstanceMetadata)), - importInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importInstanceResponse.decode.bind(importInstanceResponse), - importInstanceMetadata.decode.bind(importInstanceMetadata)), - exportInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - exportInstanceResponse.decode.bind(exportInstanceResponse), - exportInstanceMetadata.decode.bind(exportInstanceMetadata)), - failoverInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - failoverInstanceResponse.decode.bind(failoverInstanceResponse), - failoverInstanceMetadata.decode.bind(failoverInstanceMetadata)), - deleteInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteInstanceResponse.decode.bind(deleteInstanceResponse), - deleteInstanceMetadata.decode.bind(deleteInstanceMetadata)), - rescheduleMaintenance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - rescheduleMaintenanceResponse.decode.bind(rescheduleMaintenanceResponse), - rescheduleMaintenanceMetadata.decode.bind(rescheduleMaintenanceMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.redis.v1.CloudRedis', 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.cloudRedisStub) { - return this.cloudRedisStub; - } - - // Put together the "service stub" for - // google.cloud.redis.v1.CloudRedis. - this.cloudRedisStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.redis.v1.CloudRedis') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.redis.v1.CloudRedis, - 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 cloudRedisStubMethods = - ['listInstances', 'getInstance', 'getInstanceAuthString', 'createInstance', 'updateInstance', 'upgradeInstance', 'importInstance', 'exportInstance', 'failoverInstance', 'deleteInstance', 'rescheduleMaintenance']; - for (const methodName of cloudRedisStubMethods) { - const callPromise = this.cloudRedisStub.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.cloudRedisStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'redis.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 'redis.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 the details of a specific Redis instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.redis.v1.Instance|Instance}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_redis.get_instance.js - * region_tag:redis_v1_generated_CloudRedis_GetInstance_async - */ - getInstance( - request?: protos.google.cloud.redis.v1.IGetInstanceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.redis.v1.IInstance, - protos.google.cloud.redis.v1.IGetInstanceRequest|undefined, {}|undefined - ]>; - getInstance( - request: protos.google.cloud.redis.v1.IGetInstanceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.redis.v1.IInstance, - protos.google.cloud.redis.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; - getInstance( - request: protos.google.cloud.redis.v1.IGetInstanceRequest, - callback: Callback< - protos.google.cloud.redis.v1.IInstance, - protos.google.cloud.redis.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; - getInstance( - request?: protos.google.cloud.redis.v1.IGetInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.redis.v1.IInstance, - protos.google.cloud.redis.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.redis.v1.IInstance, - protos.google.cloud.redis.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.redis.v1.IInstance, - protos.google.cloud.redis.v1.IGetInstanceRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getInstance(request, options, callback); - } -/** - * Gets the AUTH string for a Redis instance. If AUTH is not enabled for the - * instance the response will be empty. This information is not included in - * the details returned to GetInstance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.redis.v1.InstanceAuthString|InstanceAuthString}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_redis.get_instance_auth_string.js - * region_tag:redis_v1_generated_CloudRedis_GetInstanceAuthString_async - */ - getInstanceAuthString( - request?: protos.google.cloud.redis.v1.IGetInstanceAuthStringRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.redis.v1.IInstanceAuthString, - protos.google.cloud.redis.v1.IGetInstanceAuthStringRequest|undefined, {}|undefined - ]>; - getInstanceAuthString( - request: protos.google.cloud.redis.v1.IGetInstanceAuthStringRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.redis.v1.IInstanceAuthString, - protos.google.cloud.redis.v1.IGetInstanceAuthStringRequest|null|undefined, - {}|null|undefined>): void; - getInstanceAuthString( - request: protos.google.cloud.redis.v1.IGetInstanceAuthStringRequest, - callback: Callback< - protos.google.cloud.redis.v1.IInstanceAuthString, - protos.google.cloud.redis.v1.IGetInstanceAuthStringRequest|null|undefined, - {}|null|undefined>): void; - getInstanceAuthString( - request?: protos.google.cloud.redis.v1.IGetInstanceAuthStringRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.redis.v1.IInstanceAuthString, - protos.google.cloud.redis.v1.IGetInstanceAuthStringRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.redis.v1.IInstanceAuthString, - protos.google.cloud.redis.v1.IGetInstanceAuthStringRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.redis.v1.IInstanceAuthString, - protos.google.cloud.redis.v1.IGetInstanceAuthStringRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getInstanceAuthString(request, options, callback); - } - -/** - * Creates a Redis instance based on the specified tier and memory size. - * - * By default, the instance is accessible from the project's - * [default network](https://cloud.google.com/vpc/docs/vpc). - * - * The creation is executed asynchronously and callers may check the returned - * operation to track its progress. Once the operation is completed the Redis - * instance will be fully functional. Completed longrunning.Operation will - * contain the new instance object in the response field. - * - * The returned operation is automatically deleted after a few hours, so there - * is no need to call DeleteOperation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the instance location using the form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a GCP region. - * @param {string} request.instanceId - * Required. The logical name of the Redis instance in the customer project - * with the following restrictions: - * - * * Must contain only lowercase letters, numbers, and hyphens. - * * Must start with a letter. - * * Must be between 1-40 characters. - * * Must end with a number or a letter. - * * Must be unique within the customer project / location - * @param {google.cloud.redis.v1.Instance} request.instance - * Required. A Redis [Instance] resource - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_redis.create_instance.js - * region_tag:redis_v1_generated_CloudRedis_CreateInstance_async - */ - createInstance( - request?: protos.google.cloud.redis.v1.ICreateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createInstance( - request: protos.google.cloud.redis.v1.ICreateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createInstance( - request: protos.google.cloud.redis.v1.ICreateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createInstance( - request?: protos.google.cloud.redis.v1.ICreateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_redis.create_instance.js - * region_tag:redis_v1_generated_CloudRedis_CreateInstance_async - */ - async checkCreateInstanceProgress(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.createInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the metadata and configuration of a specific Redis instance. - * - * Completed longrunning.Operation will contain the new instance object - * in the response field. The returned operation is automatically deleted - * after a few hours, so there is no need to call DeleteOperation. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields to update. At least one path must be supplied in - * this field. The elements of the repeated paths field may only include these - * fields from {@link protos.google.cloud.redis.v1.Instance|Instance}: - * - * * `displayName` - * * `labels` - * * `memorySizeGb` - * * `redisConfig` - * * `replica_count` - * @param {google.cloud.redis.v1.Instance} request.instance - * Required. Update description. - * Only fields specified in update_mask 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_redis.update_instance.js - * region_tag:redis_v1_generated_CloudRedis_UpdateInstance_async - */ - updateInstance( - request?: protos.google.cloud.redis.v1.IUpdateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateInstance( - request: protos.google.cloud.redis.v1.IUpdateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateInstance( - request: protos.google.cloud.redis.v1.IUpdateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateInstance( - request?: protos.google.cloud.redis.v1.IUpdateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'instance.name': request.instance!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_redis.update_instance.js - * region_tag:redis_v1_generated_CloudRedis_UpdateInstance_async - */ - async checkUpdateInstanceProgress(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.updateInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Upgrades Redis instance to the newer Redis version specified in the - * request. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - * @param {string} request.redisVersion - * Required. Specifies the target version of Redis software to upgrade to. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_redis.upgrade_instance.js - * region_tag:redis_v1_generated_CloudRedis_UpgradeInstance_async - */ - upgradeInstance( - request?: protos.google.cloud.redis.v1.IUpgradeInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - upgradeInstance( - request: protos.google.cloud.redis.v1.IUpgradeInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - upgradeInstance( - request: protos.google.cloud.redis.v1.IUpgradeInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - upgradeInstance( - request?: protos.google.cloud.redis.v1.IUpgradeInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.upgradeInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `upgradeInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_redis.upgrade_instance.js - * region_tag:redis_v1_generated_CloudRedis_UpgradeInstance_async - */ - async checkUpgradeInstanceProgress(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.upgradeInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Import a Redis RDB snapshot file from Cloud Storage into a Redis instance. - * - * Redis may stop serving during this operation. Instance state will be - * IMPORTING for entire operation. When complete, the instance will contain - * only data from the imported file. - * - * The returned operation is automatically deleted after a few hours, so - * there is no need to call DeleteOperation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - * @param {google.cloud.redis.v1.InputConfig} request.inputConfig - * Required. Specify data to be imported. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_redis.import_instance.js - * region_tag:redis_v1_generated_CloudRedis_ImportInstance_async - */ - importInstance( - request?: protos.google.cloud.redis.v1.IImportInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importInstance( - request: protos.google.cloud.redis.v1.IImportInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importInstance( - request: protos.google.cloud.redis.v1.IImportInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importInstance( - request?: protos.google.cloud.redis.v1.IImportInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.importInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_redis.import_instance.js - * region_tag:redis_v1_generated_CloudRedis_ImportInstance_async - */ - async checkImportInstanceProgress(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.importInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Export Redis instance data into a Redis RDB format file in Cloud Storage. - * - * Redis will continue serving during this operation. - * - * The returned operation is automatically deleted after a few hours, so - * there is no need to call DeleteOperation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - * @param {google.cloud.redis.v1.OutputConfig} request.outputConfig - * Required. Specify data to be exported. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_redis.export_instance.js - * region_tag:redis_v1_generated_CloudRedis_ExportInstance_async - */ - exportInstance( - request?: protos.google.cloud.redis.v1.IExportInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - exportInstance( - request: protos.google.cloud.redis.v1.IExportInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - exportInstance( - request: protos.google.cloud.redis.v1.IExportInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - exportInstance( - request?: protos.google.cloud.redis.v1.IExportInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.exportInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `exportInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_redis.export_instance.js - * region_tag:redis_v1_generated_CloudRedis_ExportInstance_async - */ - async checkExportInstanceProgress(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.exportInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Initiates a failover of the primary node to current replica node for a - * specific STANDARD tier Cloud Memorystore for Redis instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - * @param {google.cloud.redis.v1.FailoverInstanceRequest.DataProtectionMode} [request.dataProtectionMode] - * Optional. Available data protection modes that the user can choose. If it's - * unspecified, data protection mode will be LIMITED_DATA_LOSS by default. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_redis.failover_instance.js - * region_tag:redis_v1_generated_CloudRedis_FailoverInstance_async - */ - failoverInstance( - request?: protos.google.cloud.redis.v1.IFailoverInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - failoverInstance( - request: protos.google.cloud.redis.v1.IFailoverInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - failoverInstance( - request: protos.google.cloud.redis.v1.IFailoverInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - failoverInstance( - request?: protos.google.cloud.redis.v1.IFailoverInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.failoverInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `failoverInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_redis.failover_instance.js - * region_tag:redis_v1_generated_CloudRedis_FailoverInstance_async - */ - async checkFailoverInstanceProgress(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.failoverInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a specific Redis instance. Instance stops serving and data is - * deleted. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_redis.delete_instance.js - * region_tag:redis_v1_generated_CloudRedis_DeleteInstance_async - */ - deleteInstance( - request?: protos.google.cloud.redis.v1.IDeleteInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteInstance( - request: protos.google.cloud.redis.v1.IDeleteInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteInstance( - request: protos.google.cloud.redis.v1.IDeleteInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteInstance( - request?: protos.google.cloud.redis.v1.IDeleteInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_redis.delete_instance.js - * region_tag:redis_v1_generated_CloudRedis_DeleteInstance_async - */ - async checkDeleteInstanceProgress(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.deleteInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Reschedule maintenance for a given instance in a given project and - * location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - * @param {google.cloud.redis.v1.RescheduleMaintenanceRequest.RescheduleType} request.rescheduleType - * Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as - * well. - * @param {google.protobuf.Timestamp} [request.scheduleTime] - * Optional. Timestamp when the maintenance shall be rescheduled to if - * reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for - * example `2012-11-15T16:19:00.094Z`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_redis.reschedule_maintenance.js - * region_tag:redis_v1_generated_CloudRedis_RescheduleMaintenance_async - */ - rescheduleMaintenance( - request?: protos.google.cloud.redis.v1.IRescheduleMaintenanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - rescheduleMaintenance( - request: protos.google.cloud.redis.v1.IRescheduleMaintenanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - rescheduleMaintenance( - request: protos.google.cloud.redis.v1.IRescheduleMaintenanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - rescheduleMaintenance( - request?: protos.google.cloud.redis.v1.IRescheduleMaintenanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.rescheduleMaintenance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `rescheduleMaintenance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_redis.reschedule_maintenance.js - * region_tag:redis_v1_generated_CloudRedis_RescheduleMaintenance_async - */ - async checkRescheduleMaintenanceProgress(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.rescheduleMaintenance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists all Redis instances owned by a project in either the specified - * location (region) or all locations. - * - * The location should have the following format: - * - * * `projects/{project_id}/locations/{location_id}` - * - * If `location_id` is specified as `-` (wildcard), then all regions - * available to the project are queried, and the results are aggregated. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the instance location using the form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a GCP region. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 1000 will be used by the service. - * Regardless of the page_size value, the response may include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.redis.v1.ListInstancesResponse.next_page_token|`next_page_token`} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous - * {@link protos.google.cloud.redis.v1.CloudRedis.ListInstances|ListInstances} request, if - * any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.redis.v1.Instance|Instance}. - * 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 `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listInstances( - request?: protos.google.cloud.redis.v1.IListInstancesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.redis.v1.IInstance[], - protos.google.cloud.redis.v1.IListInstancesRequest|null, - protos.google.cloud.redis.v1.IListInstancesResponse - ]>; - listInstances( - request: protos.google.cloud.redis.v1.IListInstancesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.redis.v1.IListInstancesRequest, - protos.google.cloud.redis.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.redis.v1.IInstance>): void; - listInstances( - request: protos.google.cloud.redis.v1.IListInstancesRequest, - callback: PaginationCallback< - protos.google.cloud.redis.v1.IListInstancesRequest, - protos.google.cloud.redis.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.redis.v1.IInstance>): void; - listInstances( - request?: protos.google.cloud.redis.v1.IListInstancesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.redis.v1.IListInstancesRequest, - protos.google.cloud.redis.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.redis.v1.IInstance>, - callback?: PaginationCallback< - protos.google.cloud.redis.v1.IListInstancesRequest, - protos.google.cloud.redis.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.redis.v1.IInstance>): - Promise<[ - protos.google.cloud.redis.v1.IInstance[], - protos.google.cloud.redis.v1.IListInstancesRequest|null, - protos.google.cloud.redis.v1.IListInstancesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listInstances(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the instance location using the form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a GCP region. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 1000 will be used by the service. - * Regardless of the page_size value, the response may include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.redis.v1.ListInstancesResponse.next_page_token|`next_page_token`} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous - * {@link protos.google.cloud.redis.v1.CloudRedis.ListInstances|ListInstances} request, if - * any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.redis.v1.Instance|Instance} 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 `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listInstancesStream( - request?: protos.google.cloud.redis.v1.IListInstancesRequest, - 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['listInstances']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInstances.createStream( - this.innerApiCalls.listInstances as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listInstances`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the instance location using the form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a GCP region. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 1000 will be used by the service. - * Regardless of the page_size value, the response may include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.redis.v1.ListInstancesResponse.next_page_token|`next_page_token`} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous - * {@link protos.google.cloud.redis.v1.CloudRedis.ListInstances|ListInstances} request, if - * any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.redis.v1.Instance|Instance}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_redis.list_instances.js - * region_tag:redis_v1_generated_CloudRedis_ListInstances_async - */ - listInstancesAsync( - request?: protos.google.cloud.redis.v1.IListInstancesRequest, - 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['listInstances']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInstances.asyncIterate( - this.innerApiCalls['listInstances'] 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 instance resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} instance - * @returns {string} Resource name string. - */ - instancePath(project:string,location:string,instance:string) { - return this.pathTemplates.instancePathTemplate.render({ - project: project, - location: location, - instance: instance, - }); - } - - /** - * Parse the project from Instance resource. - * - * @param {string} instanceName - * A fully-qualified path representing Instance resource. - * @returns {string} A string representing the project. - */ - matchProjectFromInstanceName(instanceName: string) { - return this.pathTemplates.instancePathTemplate.match(instanceName).project; - } - - /** - * Parse the location from Instance resource. - * - * @param {string} instanceName - * A fully-qualified path representing Instance resource. - * @returns {string} A string representing the location. - */ - matchLocationFromInstanceName(instanceName: string) { - return this.pathTemplates.instancePathTemplate.match(instanceName).location; - } - - /** - * Parse the instance from Instance resource. - * - * @param {string} instanceName - * A fully-qualified path representing Instance resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromInstanceName(instanceName: string) { - return this.pathTemplates.instancePathTemplate.match(instanceName).instance; - } - - /** - * 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; - } - - /** - * 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.cloudRedisStub && !this._terminated) { - return this.cloudRedisStub.then(stub => { - this._terminated = true; - stub.close(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_client_config.json b/owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_client_config.json deleted file mode 100644 index 72ac0d962a3..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_client_config.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "interfaces": { - "google.cloud.redis.v1.CloudRedis": { - "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": { - "ListInstances": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetInstance": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetInstanceAuthString": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateInstance": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateInstance": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpgradeInstance": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ImportInstance": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ExportInstance": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "FailoverInstance": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteInstance": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RescheduleMaintenance": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_proto_list.json b/owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_proto_list.json deleted file mode 100644 index ddb165dbe38..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/src/v1/cloud_redis_proto_list.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "../../protos/google/cloud/redis/v1/cloud_redis.proto" -] diff --git a/owl-bot-staging/google-cloud-redis/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-redis/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 4390968e4b6..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,137 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.redis.v1", - "libraryPackage": "@google-cloud/redis", - "services": { - "CloudRedis": { - "clients": { - "grpc": { - "libraryClient": "CloudRedisClient", - "rpcs": { - "GetInstance": { - "methods": [ - "getInstance" - ] - }, - "GetInstanceAuthString": { - "methods": [ - "getInstanceAuthString" - ] - }, - "CreateInstance": { - "methods": [ - "createInstance" - ] - }, - "UpdateInstance": { - "methods": [ - "updateInstance" - ] - }, - "UpgradeInstance": { - "methods": [ - "upgradeInstance" - ] - }, - "ImportInstance": { - "methods": [ - "importInstance" - ] - }, - "ExportInstance": { - "methods": [ - "exportInstance" - ] - }, - "FailoverInstance": { - "methods": [ - "failoverInstance" - ] - }, - "DeleteInstance": { - "methods": [ - "deleteInstance" - ] - }, - "RescheduleMaintenance": { - "methods": [ - "rescheduleMaintenance" - ] - }, - "ListInstances": { - "methods": [ - "listInstances", - "listInstancesStream", - "listInstancesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CloudRedisClient", - "rpcs": { - "GetInstance": { - "methods": [ - "getInstance" - ] - }, - "GetInstanceAuthString": { - "methods": [ - "getInstanceAuthString" - ] - }, - "CreateInstance": { - "methods": [ - "createInstance" - ] - }, - "UpdateInstance": { - "methods": [ - "updateInstance" - ] - }, - "UpgradeInstance": { - "methods": [ - "upgradeInstance" - ] - }, - "ImportInstance": { - "methods": [ - "importInstance" - ] - }, - "ExportInstance": { - "methods": [ - "exportInstance" - ] - }, - "FailoverInstance": { - "methods": [ - "failoverInstance" - ] - }, - "DeleteInstance": { - "methods": [ - "deleteInstance" - ] - }, - "RescheduleMaintenance": { - "methods": [ - "rescheduleMaintenance" - ] - }, - "ListInstances": { - "methods": [ - "listInstances", - "listInstancesStream", - "listInstancesAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-redis/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-redis/v1/src/v1/index.ts deleted file mode 100644 index 036e9efba28..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +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 {CloudRedisClient} from './cloud_redis_client'; diff --git a/owl-bot-staging/google-cloud-redis/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-redis/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index bb242f40531..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const redis = require('@google-cloud/redis'); - -function main() { - const cloudRedisClient = new redis.CloudRedisClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-redis/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-redis/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index b6c5a1f5f69..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {CloudRedisClient} from '@google-cloud/redis'; - -// check that the client class type name can be used -function doStuffWithCloudRedisClient(client: CloudRedisClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const cloudRedisClient = new CloudRedisClient(); - doStuffWithCloudRedisClient(cloudRedisClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-redis/v1/system-test/install.ts b/owl-bot-staging/google-cloud-redis/v1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/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-redis/v1/test/gapic_cloud_redis_v1.ts b/owl-bot-staging/google-cloud-redis/v1/test/gapic_cloud_redis_v1.ts deleted file mode 100644 index 0e8cbab978c..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/test/gapic_cloud_redis_v1.ts +++ /dev/null @@ -1,2418 +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 cloudredisModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.CloudRedisClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = cloudredisModule.v1.CloudRedisClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = cloudredisModule.v1.CloudRedisClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = cloudredisModule.v1.CloudRedisClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new cloudredisModule.v1.CloudRedisClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudRedisStub, undefined); - await client.initialize(); - assert(client.cloudRedisStub); - }); - - it('has close method for the initialized client', done => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.cloudRedisStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudRedisStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudredisModule.v1.CloudRedisClient({ - 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 cloudredisModule.v1.CloudRedisClient({ - 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('getInstance', () => { - it('invokes getInstance without error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.redis.v1.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); - const [response] = await client.getInstance(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstance without error using callback', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.redis.v1.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstance( - request, - (err?: Error|null, result?: protos.google.cloud.redis.v1.IInstance|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstance with error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstance with closed client', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getInstance(request), expectedError); - }); - }); - - describe('getInstanceAuthString', () => { - it('invokes getInstanceAuthString without error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.GetInstanceAuthStringRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.GetInstanceAuthStringRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.redis.v1.InstanceAuthString() - ); - client.innerApiCalls.getInstanceAuthString = stubSimpleCall(expectedResponse); - const [response] = await client.getInstanceAuthString(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstanceAuthString as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstanceAuthString as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstanceAuthString without error using callback', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.GetInstanceAuthStringRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.GetInstanceAuthStringRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.redis.v1.InstanceAuthString() - ); - client.innerApiCalls.getInstanceAuthString = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstanceAuthString( - request, - (err?: Error|null, result?: protos.google.cloud.redis.v1.IInstanceAuthString|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstanceAuthString as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstanceAuthString as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstanceAuthString with error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.GetInstanceAuthStringRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.GetInstanceAuthStringRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstanceAuthString = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstanceAuthString(request), expectedError); - const actualRequest = (client.innerApiCalls.getInstanceAuthString as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstanceAuthString as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstanceAuthString with closed client', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.GetInstanceAuthStringRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.GetInstanceAuthStringRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getInstanceAuthString(request), expectedError); - }); - }); - - describe('createInstance', () => { - it('invokes createInstance without error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.createInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInstance without error using callback', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createInstance( - request, - (err?: Error|null, - result?: 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.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInstance with call error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInstance with LRO error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateInstanceProgress without error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateInstanceProgress with error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateInstance', () => { - it('invokes updateInstance without error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstance without error using callback', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateInstance( - request, - (err?: Error|null, - result?: 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.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstance with call error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstance with LRO error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateInstanceProgress without error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateInstanceProgress with error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('upgradeInstance', () => { - it('invokes upgradeInstance without error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.upgradeInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstance without error using callback', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.upgradeInstance( - request, - (err?: Error|null, - result?: 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.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstance with call error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.upgradeInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstance with LRO error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.upgradeInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpgradeInstanceProgress without error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpgradeInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpgradeInstanceProgress with error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpgradeInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('importInstance', () => { - it('invokes importInstance without error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.ImportInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.ImportInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.importInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importInstance without error using callback', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.ImportInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.ImportInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importInstance( - request, - (err?: Error|null, - result?: 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.importInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importInstance with call error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.ImportInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.ImportInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.importInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importInstance with LRO error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.ImportInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.ImportInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkImportInstanceProgress without error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportInstanceProgress with error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('exportInstance', () => { - it('invokes exportInstance without error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.ExportInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.ExportInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.exportInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.exportInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.exportInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes exportInstance without error using callback', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.ExportInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.ExportInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.exportInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.exportInstance( - request, - (err?: Error|null, - result?: 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.exportInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes exportInstance with call error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.ExportInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.ExportInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.exportInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.exportInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.exportInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes exportInstance with LRO error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.ExportInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.ExportInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.exportInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.exportInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.exportInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkExportInstanceProgress without error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkExportInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkExportInstanceProgress with error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkExportInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('failoverInstance', () => { - it('invokes failoverInstance without error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.FailoverInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.FailoverInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.failoverInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.failoverInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.failoverInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.failoverInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes failoverInstance without error using callback', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.FailoverInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.FailoverInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.failoverInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.failoverInstance( - request, - (err?: Error|null, - result?: 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.failoverInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.failoverInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes failoverInstance with call error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.FailoverInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.FailoverInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.failoverInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.failoverInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.failoverInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.failoverInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes failoverInstance with LRO error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.FailoverInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.FailoverInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.failoverInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.failoverInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.failoverInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.failoverInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkFailoverInstanceProgress without error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkFailoverInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkFailoverInstanceProgress with error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkFailoverInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteInstance', () => { - it('invokes deleteInstance without error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInstance without error using callback', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteInstance( - request, - (err?: Error|null, - result?: 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.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInstance with call error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInstance with LRO error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteInstanceProgress without error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteInstanceProgress with error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('rescheduleMaintenance', () => { - it('invokes rescheduleMaintenance without error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.RescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.RescheduleMaintenanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall(expectedResponse); - const [operation] = await client.rescheduleMaintenance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rescheduleMaintenance without error using callback', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.RescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.RescheduleMaintenanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rescheduleMaintenance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rescheduleMaintenance( - request, - (err?: Error|null, - result?: 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.rescheduleMaintenance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rescheduleMaintenance with call error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.RescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.RescheduleMaintenanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rescheduleMaintenance(request), expectedError); - const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rescheduleMaintenance with LRO error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.RescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.RescheduleMaintenanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rescheduleMaintenance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkRescheduleMaintenanceProgress without error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRescheduleMaintenanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRescheduleMaintenanceProgress with error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRescheduleMaintenanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listInstances', () => { - it('invokes listInstances without error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), - generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), - generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); - const [response] = await client.listInstances(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstances without error using callback', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), - generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), - generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInstances( - request, - (err?: Error|null, result?: protos.google.cloud.redis.v1.IInstance[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstances with error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInstances(request), expectedError); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstancesStream without error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), - generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), - generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), - ]; - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.redis.v1.Instance[] = []; - stream.on('data', (response: protos.google.cloud.redis.v1.Instance) => { - 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.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listInstancesStream with error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.redis.v1.Instance[] = []; - stream.on('data', (response: protos.google.cloud.redis.v1.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInstances without error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), - generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), - generateSampleMessage(new protos.google.cloud.redis.v1.Instance()), - ]; - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.redis.v1.IInstance[] = []; - const iterable = client.listInstancesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInstances with error', async () => { - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInstancesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.redis.v1.IInstance[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.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 cloudredisModule.v1.CloudRedisClient({ - 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 cloudredisModule.v1.CloudRedisClient({ - 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 cloudredisModule.v1.CloudRedisClient({ - 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 cloudredisModule.v1.CloudRedisClient({ - 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 cloudredisModule.v1.CloudRedisClient({ - 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 cloudredisModule.v1.CloudRedisClient({ - 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 cloudredisModule.v1.CloudRedisClient({ - 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 cloudredisModule.v1.CloudRedisClient({ - 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 cloudredisModule.v1.CloudRedisClient({ - 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 cloudredisModule.v1.CloudRedisClient({ - 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 cloudredisModule.v1.CloudRedisClient({ - 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 cloudredisModule.v1.CloudRedisClient({ - 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 cloudredisModule.v1.CloudRedisClient({ - 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 cloudredisModule.v1.CloudRedisClient({ - 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 cloudredisModule.v1.CloudRedisClient({ - 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 cloudredisModule.v1.CloudRedisClient({ - 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('instance', () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - }; - const client = new cloudredisModule.v1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "locationValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromInstanceName', () => { - const result = client.matchLocationFromInstanceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new cloudredisModule.v1.CloudRedisClient({ - 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)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-redis/v1/tsconfig.json b/owl-bot-staging/google-cloud-redis/v1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-redis/v1/webpack.config.js b/owl-bot-staging/google-cloud-redis/v1/webpack.config.js deleted file mode 100644 index c8446c2163e..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'CloudRedis', - filename: './cloud-redis.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-redis/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-redis/v1beta1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-redis/v1beta1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/.gitignore b/owl-bot-staging/google-cloud-redis/v1beta1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-redis/v1beta1/.jsdoc.js deleted file mode 100644 index 58332656788..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/.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/redis', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-redis/v1beta1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/.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-redis/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-redis/v1beta1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/.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-redis/v1beta1/README.md b/owl-bot-staging/google-cloud-redis/v1beta1/README.md deleted file mode 100644 index 3c11909fadc..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Redis: Nodejs Client diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/package.json b/owl-bot-staging/google-cloud-redis/v1beta1/package.json deleted file mode 100644 index 0a5bbcc4645..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/redis", - "version": "0.1.0", - "description": "Redis client for Node.js", - "repository": "googleapis/nodejs-redis", - "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 redis", - "redis", - "cloud redis" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/protos/google/cloud/redis/v1beta1/cloud_redis.proto b/owl-bot-staging/google-cloud-redis/v1beta1/protos/google/cloud/redis/v1beta1/cloud_redis.proto deleted file mode 100644 index 037c93aeb5c..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/protos/google/cloud/redis/v1beta1/cloud_redis.proto +++ /dev/null @@ -1,913 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.redis.v1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/type/dayofweek.proto"; -import "google/type/timeofday.proto"; - -option go_package = "cloud.google.com/go/redis/apiv1beta1/redispb;redispb"; -option java_multiple_files = true; -option java_outer_classname = "CloudRedisServiceBetaProto"; -option java_package = "com.google.cloud.redis.v1beta1"; - -// Configures and manages Cloud Memorystore for Redis instances -// -// Google Cloud Memorystore for Redis v1beta1 -// -// The `redis.googleapis.com` service implements the Google Cloud Memorystore -// for Redis API and defines the following resource model for managing Redis -// instances: -// * The service works with a collection of cloud projects, named: `/projects/*` -// * Each project has a collection of available locations, named: `/locations/*` -// * Each location has a collection of Redis instances, named: `/instances/*` -// * As such, Redis instances are resources of the form: -// `/projects/{project_id}/locations/{location_id}/instances/{instance_id}` -// -// Note that location_id must be referring to a GCP `region`; for example: -// * `projects/redpepper-1290/locations/us-central1/instances/my-redis` -service CloudRedis { - option (google.api.default_host) = "redis.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Lists all Redis instances owned by a project in either the specified - // location (region) or all locations. - // - // The location should have the following format: - // - // * `projects/{project_id}/locations/{location_id}` - // - // If `location_id` is specified as `-` (wildcard), then all regions - // available to the project are queried, and the results are aggregated. - rpc ListInstances(ListInstancesRequest) returns (ListInstancesResponse) { - option (google.api.http) = { - get: "/v1beta1/{parent=projects/*/locations/*}/instances" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets the details of a specific Redis instance. - rpc GetInstance(GetInstanceRequest) returns (Instance) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/locations/*/instances/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Gets the AUTH string for a Redis instance. If AUTH is not enabled for the - // instance the response will be empty. This information is not included in - // the details returned to GetInstance. - rpc GetInstanceAuthString(GetInstanceAuthStringRequest) returns (InstanceAuthString) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/locations/*/instances/*}/authString" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a Redis instance based on the specified tier and memory size. - // - // By default, the instance is accessible from the project's - // [default network](https://cloud.google.com/vpc/docs/vpc). - // - // The creation is executed asynchronously and callers may check the returned - // operation to track its progress. Once the operation is completed the Redis - // instance will be fully functional. The completed longrunning.Operation will - // contain the new instance object in the response field. - // - // The returned operation is automatically deleted after a few hours, so there - // is no need to call DeleteOperation. - rpc CreateInstance(CreateInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*/locations/*}/instances" - body: "instance" - }; - option (google.api.method_signature) = "parent,instance_id,instance"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.redis.v1beta1.Instance" - metadata_type: "google.protobuf.Any" - }; - } - - // Updates the metadata and configuration of a specific Redis instance. - // - // Completed longrunning.Operation will contain the new instance object - // in the response field. The returned operation is automatically deleted - // after a few hours, so there is no need to call DeleteOperation. - rpc UpdateInstance(UpdateInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1beta1/{instance.name=projects/*/locations/*/instances/*}" - body: "instance" - }; - option (google.api.method_signature) = "update_mask,instance"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.redis.v1beta1.Instance" - metadata_type: "google.protobuf.Any" - }; - } - - // Upgrades Redis instance to the newer Redis version specified in the - // request. - rpc UpgradeInstance(UpgradeInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/instances/*}:upgrade" - body: "*" - }; - option (google.api.method_signature) = "name,redis_version"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.redis.v1beta1.Instance" - metadata_type: "google.protobuf.Any" - }; - } - - // Import a Redis RDB snapshot file from Cloud Storage into a Redis instance. - // - // Redis may stop serving during this operation. Instance state will be - // IMPORTING for entire operation. When complete, the instance will contain - // only data from the imported file. - // - // The returned operation is automatically deleted after a few hours, so - // there is no need to call DeleteOperation. - rpc ImportInstance(ImportInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/instances/*}:import" - body: "*" - }; - option (google.api.method_signature) = "name,input_config"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.redis.v1beta1.Instance" - metadata_type: "google.protobuf.Any" - }; - } - - // Export Redis instance data into a Redis RDB format file in Cloud Storage. - // - // Redis will continue serving during this operation. - // - // The returned operation is automatically deleted after a few hours, so - // there is no need to call DeleteOperation. - rpc ExportInstance(ExportInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/instances/*}:export" - body: "*" - }; - option (google.api.method_signature) = "name,output_config"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.redis.v1beta1.Instance" - metadata_type: "google.protobuf.Any" - }; - } - - // Initiates a failover of the primary node to current replica node for a - // specific STANDARD tier Cloud Memorystore for Redis instance. - rpc FailoverInstance(FailoverInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/instances/*}:failover" - body: "*" - }; - option (google.api.method_signature) = "name,data_protection_mode"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.redis.v1beta1.Instance" - metadata_type: "google.protobuf.Any" - }; - } - - // Deletes a specific Redis instance. Instance stops serving and data is - // deleted. - rpc DeleteInstance(DeleteInstanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1beta1/{name=projects/*/locations/*/instances/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "google.protobuf.Any" - }; - } - - // Reschedule maintenance for a given instance in a given project and - // location. - rpc RescheduleMaintenance(RescheduleMaintenanceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/instances/*}:rescheduleMaintenance" - body: "*" - }; - option (google.api.method_signature) = "name, reschedule_type, schedule_time"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.redis.v1beta1.Instance" - metadata_type: "google.protobuf.Any" - }; - } -} - -// Node specific properties. -message NodeInfo { - // Output only. Node identifying string. e.g. 'node-0', 'node-1' - string id = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Location of the node. - string zone = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A Memorystore for Redis instance. -message Instance { - option (google.api.resource) = { - type: "redis.googleapis.com/Instance" - pattern: "projects/{project}/locations/{location}/instances/{instance}" - }; - - // Represents the different states of a Redis instance. - enum State { - // Not set. - STATE_UNSPECIFIED = 0; - - // Redis instance is being created. - CREATING = 1; - - // Redis instance has been created and is fully usable. - READY = 2; - - // Redis instance configuration is being updated. Certain kinds of updates - // may cause the instance to become unusable while the update is in - // progress. - UPDATING = 3; - - // Redis instance is being deleted. - DELETING = 4; - - // Redis instance is being repaired and may be unusable. - REPAIRING = 5; - - // Maintenance is being performed on this Redis instance. - MAINTENANCE = 6; - - // Redis instance is importing data (availability may be affected). - IMPORTING = 8; - - // Redis instance is failing over (availability may be affected). - FAILING_OVER = 10; - } - - // Available service tiers to choose from - enum Tier { - // Not set. - TIER_UNSPECIFIED = 0; - - // BASIC tier: standalone instance - BASIC = 1; - - // STANDARD_HA tier: highly available primary/replica instances - STANDARD_HA = 3; - } - - // Available connection modes. - enum ConnectMode { - // Not set. - CONNECT_MODE_UNSPECIFIED = 0; - - // Connect via direct peering to the Memorystore for Redis hosted service. - DIRECT_PEERING = 1; - - // Connect your Memorystore for Redis instance using Private Service - // Access. Private services access provides an IP address range for multiple - // Google Cloud services, including Memorystore. - PRIVATE_SERVICE_ACCESS = 2; - } - - // Available TLS modes. - enum TransitEncryptionMode { - // Not set. - TRANSIT_ENCRYPTION_MODE_UNSPECIFIED = 0; - - // Client to Server traffic encryption enabled with server authentication. - SERVER_AUTHENTICATION = 1; - - // TLS is disabled for the instance. - DISABLED = 2; - } - - // Read replicas mode. - enum ReadReplicasMode { - // If not set, Memorystore Redis backend will default to - // READ_REPLICAS_DISABLED. - READ_REPLICAS_MODE_UNSPECIFIED = 0; - - // If disabled, read endpoint will not be provided and the instance cannot - // scale up or down the number of replicas. - READ_REPLICAS_DISABLED = 1; - - // If enabled, read endpoint will be provided and the instance can scale - // up and down the number of replicas. Not valid for basic tier. - READ_REPLICAS_ENABLED = 2; - } - - // Required. Unique name of the resource in this scope including project and - // location using the form: - // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - // - // Note: Redis instances are managed and addressed at regional level so - // location_id here refers to a GCP region; however, users may choose which - // specific zone (or collection of zones for cross-zone instances) an instance - // should be provisioned in. Refer to [location_id][google.cloud.redis.v1beta1.Instance.location_id] and - // [alternative_location_id][google.cloud.redis.v1beta1.Instance.alternative_location_id] fields for more details. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // An arbitrary and optional user-provided name for the instance. - string display_name = 2; - - // Resource labels to represent user provided metadata - map labels = 3; - - // Optional. The zone where the instance will be provisioned. If not provided, - // the service will choose a zone from the specified region for the instance. - // For standard tier, additional nodes will be added across multiple zones for - // protection against zonal failures. If specified, at least one node will be - // provisioned in this zone. - string location_id = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. If specified, at least one node will be provisioned in this zone - // in addition to the zone specified in location_id. Only applicable to - // standard tier. If provided, it must be a different zone from the one - // provided in [location_id]. Additional nodes beyond the first 2 will be - // placed in zones selected by the service. - string alternative_location_id = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The version of Redis software. - // If not provided, latest supported version will be used. Currently, the - // supported values are: - // - // * `REDIS_3_2` for Redis 3.2 compatibility - // * `REDIS_4_0` for Redis 4.0 compatibility (default) - // * `REDIS_5_0` for Redis 5.0 compatibility - // * `REDIS_6_X` for Redis 6.x compatibility - string redis_version = 7 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. For DIRECT_PEERING mode, the CIDR range of internal addresses - // that are reserved for this instance. Range must - // be unique and non-overlapping with existing subnets in an authorized - // network. For PRIVATE_SERVICE_ACCESS mode, the name of one allocated IP - // address ranges associated with this private service access connection. - // If not provided, the service will choose an unused /29 block, for - // example, 10.0.0.0/29 or 192.168.0.0/29. For READ_REPLICAS_ENABLED - // the default block size is /28. - string reserved_ip_range = 9 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Additional IP range for node placement. Required when enabling read - // replicas on an existing instance. For DIRECT_PEERING mode value must be a - // CIDR range of size /28, or "auto". For PRIVATE_SERVICE_ACCESS mode value - // must be the name of an allocated address range associated with the private - // service access connection, or "auto". - string secondary_ip_range = 30 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. Hostname or IP address of the exposed Redis endpoint used by - // clients to connect to the service. - string host = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The port number of the exposed Redis endpoint. - int32 port = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The current zone where the Redis primary node is located. In - // basic tier, this will always be the same as [location_id]. In - // standard tier, this can be the zone of any node in the instance. - string current_location_id = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time the instance was created. - google.protobuf.Timestamp create_time = 13 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The current state of this instance. - State state = 14 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Additional information about the current status of this - // instance, if available. - string status_message = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Redis configuration parameters, according to - // http://redis.io/topics/config. Currently, the only supported parameters - // are: - // - // Redis version 3.2 and newer: - // - // * maxmemory-policy - // * notify-keyspace-events - // - // Redis version 4.0 and newer: - // - // * activedefrag - // * lfu-decay-time - // * lfu-log-factor - // * maxmemory-gb - // - // Redis version 5.0 and newer: - // - // * stream-node-max-bytes - // * stream-node-max-entries - map redis_configs = 16 [(google.api.field_behavior) = OPTIONAL]; - - // Required. The service tier of the instance. - Tier tier = 17 [(google.api.field_behavior) = REQUIRED]; - - // Required. Redis memory size in GiB. - int32 memory_size_gb = 18 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The full name of the Google Compute Engine - // [network](https://cloud.google.com/vpc/docs/vpc) to which the - // instance is connected. If left unspecified, the `default` network - // will be used. - string authorized_network = 20 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. Cloud IAM identity used by import / export operations to - // transfer data to/from Cloud Storage. Format is - // "serviceAccount:". The value may change over time - // for a given instance so should be checked before each import/export - // operation. - string persistence_iam_identity = 21 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. The network connect mode of the Redis instance. - // If not provided, the connect mode defaults to DIRECT_PEERING. - ConnectMode connect_mode = 22 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Indicates whether OSS Redis AUTH is enabled for the instance. If set to - // "true" AUTH is enabled on the instance. Default value is "false" meaning - // AUTH is disabled. - bool auth_enabled = 23 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. List of server CA certificates for the instance. - repeated TlsCertificate server_ca_certs = 25 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. The TLS mode of the Redis instance. - // If not provided, TLS is disabled for the instance. - TransitEncryptionMode transit_encryption_mode = 26 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The maintenance policy for the instance. If not provided, - // maintenance events can be performed at any time. - MaintenancePolicy maintenance_policy = 27 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. Date and time of upcoming maintenance events which have been - // scheduled. - MaintenanceSchedule maintenance_schedule = 28 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. The number of replica nodes. The valid range for the Standard Tier with - // read replicas enabled is [1-5] and defaults to 2. If read replicas are not - // enabled for a Standard Tier instance, the only valid value is 1 and the - // default is 1. The valid value for basic tier is 0 and the default is also - // 0. - int32 replica_count = 31 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. Info per node. - repeated NodeInfo nodes = 32 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Hostname or IP address of the exposed readonly Redis - // endpoint. Standard tier only. Targets all healthy replica nodes in - // instance. Replication is asynchronous and replica nodes will exhibit some - // lag behind the primary. Write requests must target 'host'. - string read_endpoint = 33 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The port number of the exposed readonly redis - // endpoint. Standard tier only. Write requests should target 'port'. - int32 read_endpoint_port = 34 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Read replicas mode for the instance. Defaults to READ_REPLICAS_DISABLED. - ReadReplicasMode read_replicas_mode = 35 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Persistence configuration parameters - PersistenceConfig persistence_config = 37 [(google.api.field_behavior) = OPTIONAL]; -} - -// Configuration of the persistence functionality. -message PersistenceConfig { - // Available Persistence modes. - enum PersistenceMode { - // Not set. - PERSISTENCE_MODE_UNSPECIFIED = 0; - - // Persistence is disabled for the instance, - // and any existing snapshots are deleted. - DISABLED = 1; - - // RDB based Persistence is enabled. - RDB = 2; - } - - // Available snapshot periods for scheduling. - enum SnapshotPeriod { - // Not set. - SNAPSHOT_PERIOD_UNSPECIFIED = 0; - - // Snapshot every 1 hour. - ONE_HOUR = 3; - - // Snapshot every 6 hours. - SIX_HOURS = 4; - - // Snapshot every 12 hours. - TWELVE_HOURS = 5; - - // Snapshot every 24 hours. - TWENTY_FOUR_HOURS = 6; - } - - // Optional. Controls whether Persistence features are enabled. - // If not provided, the existing value will be used. - PersistenceMode persistence_mode = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Period between RDB snapshots. Snapshots will be attempted every period - // starting from the provided snapshot start time. For example, a start time - // of 01/01/2033 06:45 and SIX_HOURS snapshot period will do nothing until - // 01/01/2033, and then trigger snapshots every day at 06:45, 12:45, 18:45, - // and 00:45 the next day, and so on. - // If not provided, TWENTY_FOUR_HOURS will be used as default. - SnapshotPeriod rdb_snapshot_period = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The next time that a snapshot attempt is scheduled to occur. - google.protobuf.Timestamp rdb_next_snapshot_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Date and time that the first snapshot was/will be attempted, and to which - // future snapshots will be aligned. - // If not provided, the current time will be used. - google.protobuf.Timestamp rdb_snapshot_start_time = 5 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request for [RescheduleMaintenance][google.cloud.redis.v1beta1.CloudRedis.RescheduleMaintenance]. -message RescheduleMaintenanceRequest { - // Reschedule options. - enum RescheduleType { - // Not set. - RESCHEDULE_TYPE_UNSPECIFIED = 0; - - // If the user wants to schedule the maintenance to happen now. - IMMEDIATE = 1; - - // If the user wants to use the existing maintenance policy to find the - // next available window. - NEXT_AVAILABLE_WINDOW = 2; - - // If the user wants to reschedule the maintenance to a specific time. - SPECIFIC_TIME = 3; - } - - // Required. Redis instance resource name using the form: - // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - // where `location_id` refers to a GCP region. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "redis.googleapis.com/Instance" - } - ]; - - // Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well. - RescheduleType reschedule_type = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Timestamp when the maintenance shall be rescheduled to if - // reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for - // example `2012-11-15T16:19:00.094Z`. - google.protobuf.Timestamp schedule_time = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Maintenance policy for an instance. -message MaintenancePolicy { - // Output only. The time when the policy was created. - google.protobuf.Timestamp create_time = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time when the policy was last updated. - google.protobuf.Timestamp update_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Description of what this policy is for. Create/Update methods - // return INVALID_ARGUMENT if the length is greater than 512. - string description = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Maintenance window that is applied to resources covered by this - // policy. Minimum 1. For the current version, the maximum number of - // weekly_window is expected to be one. - repeated WeeklyMaintenanceWindow weekly_maintenance_window = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// Time window in which disruptive maintenance updates occur. Non-disruptive -// updates can occur inside or outside this window. -message WeeklyMaintenanceWindow { - // Required. The day of week that maintenance updates occur. - google.type.DayOfWeek day = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Start time of the window in UTC time. - google.type.TimeOfDay start_time = 2 [(google.api.field_behavior) = REQUIRED]; - - // Output only. Duration of the maintenance window. The current window is fixed at 1 hour. - google.protobuf.Duration duration = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Upcoming maintenance schedule. If no maintenance is scheduled, fields are not -// populated. -message MaintenanceSchedule { - // Output only. The start time of any upcoming scheduled maintenance for this instance. - google.protobuf.Timestamp start_time = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The end time of any upcoming scheduled maintenance for this instance. - google.protobuf.Timestamp end_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // If the scheduled maintenance can be rescheduled, default is true. - bool can_reschedule = 3 [deprecated = true]; - - // Output only. The deadline that the maintenance schedule start time can not go beyond, - // including reschedule. - google.protobuf.Timestamp schedule_deadline_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Request for [ListInstances][google.cloud.redis.v1beta1.CloudRedis.ListInstances]. -message ListInstancesRequest { - // Required. The resource name of the instance location using the form: - // `projects/{project_id}/locations/{location_id}` - // where `location_id` refers to a GCP region. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. - // - // If not specified, a default value of 1000 will be used by the service. - // Regardless of the page_size value, the response may include a partial list - // and a caller should only rely on response's - // [`next_page_token`][google.cloud.redis.v1beta1.ListInstancesResponse.next_page_token] - // to determine if there are more instances left to be queried. - int32 page_size = 2; - - // The `next_page_token` value returned from a previous - // [ListInstances][google.cloud.redis.v1beta1.CloudRedis.ListInstances] request, if any. - string page_token = 3; -} - -// Response for [ListInstances][google.cloud.redis.v1beta1.CloudRedis.ListInstances]. -message ListInstancesResponse { - // A list of Redis instances in the project in the specified location, - // or across all locations. - // - // If the `location_id` in the parent field of the request is "-", all regions - // available to the project are queried, and the results aggregated. - // If in such an aggregated query a location is unavailable, a placeholder - // Redis entry is included in the response with the `name` field set to a - // value of the form - // `projects/{project_id}/locations/{location_id}/instances/`- and the - // `status` field set to ERROR and `status_message` field set to "location not - // available for ListInstances". - repeated Instance instances = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; - - // Locations that could not be reached. - repeated string unreachable = 3; -} - -// Request for [GetInstance][google.cloud.redis.v1beta1.CloudRedis.GetInstance]. -message GetInstanceRequest { - // Required. Redis instance resource name using the form: - // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - // where `location_id` refers to a GCP region. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "redis.googleapis.com/Instance" - } - ]; -} - -// Request for [GetInstanceAuthString][google.cloud.redis.v1beta1.CloudRedis.GetInstanceAuthString]. -message GetInstanceAuthStringRequest { - // Required. Redis instance resource name using the form: - // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - // where `location_id` refers to a GCP region. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "redis.googleapis.com/Instance" - } - ]; -} - -// Instance AUTH string details. -message InstanceAuthString { - // AUTH string set on the instance. - string auth_string = 1; -} - -// Request for [CreateInstance][google.cloud.redis.v1beta1.CloudRedis.CreateInstance]. -message CreateInstanceRequest { - // Required. The resource name of the instance location using the form: - // `projects/{project_id}/locations/{location_id}` - // where `location_id` refers to a GCP region. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The logical name of the Redis instance in the customer project - // with the following restrictions: - // - // * Must contain only lowercase letters, numbers, and hyphens. - // * Must start with a letter. - // * Must be between 1-40 characters. - // * Must end with a number or a letter. - // * Must be unique within the customer project / location - string instance_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. A Redis [Instance] resource - Instance instance = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for [UpdateInstance][google.cloud.redis.v1beta1.CloudRedis.UpdateInstance]. -message UpdateInstanceRequest { - // Required. Mask of fields to update. At least one path must be supplied in - // this field. The elements of the repeated paths field may only include these - // fields from [Instance][google.cloud.redis.v1beta1.Instance]: - // - // * `displayName` - // * `labels` - // * `memorySizeGb` - // * `redisConfig` - // * `replica_count` - google.protobuf.FieldMask update_mask = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Update description. - // Only fields specified in update_mask are updated. - Instance instance = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for [UpgradeInstance][google.cloud.redis.v1beta1.CloudRedis.UpgradeInstance]. -message UpgradeInstanceRequest { - // Required. Redis instance resource name using the form: - // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - // where `location_id` refers to a GCP region. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "redis.googleapis.com/Instance" - } - ]; - - // Required. Specifies the target version of Redis software to upgrade to. - string redis_version = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for [DeleteInstance][google.cloud.redis.v1beta1.CloudRedis.DeleteInstance]. -message DeleteInstanceRequest { - // Required. Redis instance resource name using the form: - // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - // where `location_id` refers to a GCP region. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "redis.googleapis.com/Instance" - } - ]; -} - -// The Cloud Storage location for the input content -message GcsSource { - // Required. Source data URI. (e.g. 'gs://my_bucket/my_object'). - string uri = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// The input content -message InputConfig { - // Required. Specify source location of input data - oneof source { - // Google Cloud Storage location where input content is located. - GcsSource gcs_source = 1; - } -} - -// Request for [Import][google.cloud.redis.v1beta1.CloudRedis.ImportInstance]. -message ImportInstanceRequest { - // Required. Redis instance resource name using the form: - // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - // where `location_id` refers to a GCP region. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Specify data to be imported. - InputConfig input_config = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// The Cloud Storage location for the output content -message GcsDestination { - // Required. Data destination URI (e.g. - // 'gs://my_bucket/my_object'). Existing files will be overwritten. - string uri = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// The output content -message OutputConfig { - // Required. Specify destination location of output data - oneof destination { - // Google Cloud Storage destination for output content. - GcsDestination gcs_destination = 1; - } -} - -// Request for [Export][google.cloud.redis.v1beta1.CloudRedis.ExportInstance]. -message ExportInstanceRequest { - // Required. Redis instance resource name using the form: - // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - // where `location_id` refers to a GCP region. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Specify data to be exported. - OutputConfig output_config = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for [Failover][google.cloud.redis.v1beta1.CloudRedis.FailoverInstance]. -message FailoverInstanceRequest { - // Specifies different modes of operation in relation to the data retention. - enum DataProtectionMode { - // Defaults to LIMITED_DATA_LOSS if a data protection mode is not - // specified. - DATA_PROTECTION_MODE_UNSPECIFIED = 0; - - // Instance failover will be protected with data loss control. More - // specifically, the failover will only be performed if the current - // replication offset diff between primary and replica is under a certain - // threshold. - LIMITED_DATA_LOSS = 1; - - // Instance failover will be performed without data loss control. - FORCE_DATA_LOSS = 2; - } - - // Required. Redis instance resource name using the form: - // `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - // where `location_id` refers to a GCP region. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "redis.googleapis.com/Instance" - } - ]; - - // Optional. Available data protection modes that the user can choose. If it's - // unspecified, data protection mode will be LIMITED_DATA_LOSS by default. - DataProtectionMode data_protection_mode = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// This location metadata represents additional configuration options for a -// given location where a Redis instance may be created. All fields are output -// only. It is returned as content of the -// `google.cloud.location.Location.metadata` field. -message LocationMetadata { - // Output only. The set of available zones in the location. The map is keyed - // by the lowercase ID of each zone, as defined by GCE. These keys can be - // specified in `location_id` or `alternative_location_id` fields when - // creating a Redis instance. - map available_zones = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Defines specific information for a particular zone. Currently empty and -// reserved for future use only. -message ZoneMetadata { - -} - -// TlsCertificate Resource -message TlsCertificate { - // Serial number, as extracted from the certificate. - string serial_number = 1; - - // PEM representation. - string cert = 2; - - // Output only. The time when the certificate was created in [RFC - // 3339](https://tools.ietf.org/html/rfc3339) format, for example - // `2020-05-18T00:00:00.094Z`. - google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time when the certificate expires in [RFC - // 3339](https://tools.ietf.org/html/rfc3339) format, for example - // `2020-05-18T00:00:00.094Z`. - google.protobuf.Timestamp expire_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Sha1 Fingerprint of the certificate. - string sha1_fingerprint = 5; -} diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.create_instance.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.create_instance.js deleted file mode 100644 index 0f58130158a..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.create_instance.js +++ /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. ** - - - -'use strict'; - -function main(parent, instanceId, instance) { - // [START redis_v1beta1_generated_CloudRedis_CreateInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 instance location using the form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a GCP region. - */ - // const parent = 'abc123' - /** - * Required. The logical name of the Redis instance in the customer project - * with the following restrictions: - * * Must contain only lowercase letters, numbers, and hyphens. - * * Must start with a letter. - * * Must be between 1-40 characters. - * * Must end with a number or a letter. - * * Must be unique within the customer project / location - */ - // const instanceId = 'abc123' - /** - * Required. A Redis Instance resource - */ - // const instance = {} - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callCreateInstance() { - // Construct request - const request = { - parent, - instanceId, - instance, - }; - - // Run request - const [operation] = await redisClient.createInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateInstance(); - // [END redis_v1beta1_generated_CloudRedis_CreateInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.delete_instance.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.delete_instance.js deleted file mode 100644 index f6cb7ce1609..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.delete_instance.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 redis_v1beta1_generated_CloudRedis_DeleteInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - */ - // const name = 'abc123' - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callDeleteInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await redisClient.deleteInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteInstance(); - // [END redis_v1beta1_generated_CloudRedis_DeleteInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.export_instance.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.export_instance.js deleted file mode 100644 index f7b3d6fc38c..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.export_instance.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(name, outputConfig) { - // [START redis_v1beta1_generated_CloudRedis_ExportInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - */ - // const name = 'abc123' - /** - * Required. Specify data to be exported. - */ - // const outputConfig = {} - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callExportInstance() { - // Construct request - const request = { - name, - outputConfig, - }; - - // Run request - const [operation] = await redisClient.exportInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callExportInstance(); - // [END redis_v1beta1_generated_CloudRedis_ExportInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.failover_instance.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.failover_instance.js deleted file mode 100644 index 601319e7ebc..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.failover_instance.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(name) { - // [START redis_v1beta1_generated_CloudRedis_FailoverInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - */ - // const name = 'abc123' - /** - * Optional. Available data protection modes that the user can choose. If it's - * unspecified, data protection mode will be LIMITED_DATA_LOSS by default. - */ - // const dataProtectionMode = {} - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callFailoverInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await redisClient.failoverInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callFailoverInstance(); - // [END redis_v1beta1_generated_CloudRedis_FailoverInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.get_instance.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.get_instance.js deleted file mode 100644 index aede7491307..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.get_instance.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 redis_v1beta1_generated_CloudRedis_GetInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - */ - // const name = 'abc123' - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callGetInstance() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await redisClient.getInstance(request); - console.log(response); - } - - callGetInstance(); - // [END redis_v1beta1_generated_CloudRedis_GetInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.get_instance_auth_string.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.get_instance_auth_string.js deleted file mode 100644 index ce4f6592647..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.get_instance_auth_string.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 redis_v1beta1_generated_CloudRedis_GetInstanceAuthString_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - */ - // const name = 'abc123' - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callGetInstanceAuthString() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await redisClient.getInstanceAuthString(request); - console.log(response); - } - - callGetInstanceAuthString(); - // [END redis_v1beta1_generated_CloudRedis_GetInstanceAuthString_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.import_instance.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.import_instance.js deleted file mode 100644 index 74756e85745..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.import_instance.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(name, inputConfig) { - // [START redis_v1beta1_generated_CloudRedis_ImportInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - */ - // const name = 'abc123' - /** - * Required. Specify data to be imported. - */ - // const inputConfig = {} - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callImportInstance() { - // Construct request - const request = { - name, - inputConfig, - }; - - // Run request - const [operation] = await redisClient.importInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportInstance(); - // [END redis_v1beta1_generated_CloudRedis_ImportInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.list_instances.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.list_instances.js deleted file mode 100644 index 1914b707c71..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.list_instances.js +++ /dev/null @@ -1,79 +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 redis_v1beta1_generated_CloudRedis_ListInstances_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 instance location using the form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a GCP region. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. - * If not specified, a default value of 1000 will be used by the service. - * Regardless of the page_size value, the response may include a partial list - * and a caller should only rely on response's - * `next_page_token` google.cloud.redis.v1beta1.ListInstancesResponse.next_page_token - * to determine if there are more instances left to be queried. - */ - // const pageSize = 1234 - /** - * The `next_page_token` value returned from a previous - * ListInstances google.cloud.redis.v1beta1.CloudRedis.ListInstances request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callListInstances() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await redisClient.listInstancesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListInstances(); - // [END redis_v1beta1_generated_CloudRedis_ListInstances_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.reschedule_maintenance.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.reschedule_maintenance.js deleted file mode 100644 index c7b2b459326..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.reschedule_maintenance.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(name, rescheduleType) { - // [START redis_v1beta1_generated_CloudRedis_RescheduleMaintenance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - */ - // const name = 'abc123' - /** - * Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well. - */ - // const rescheduleType = {} - /** - * Optional. Timestamp when the maintenance shall be rescheduled to if - * reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for - * example `2012-11-15T16:19:00.094Z`. - */ - // const scheduleTime = {} - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callRescheduleMaintenance() { - // Construct request - const request = { - name, - rescheduleType, - }; - - // Run request - const [operation] = await redisClient.rescheduleMaintenance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRescheduleMaintenance(); - // [END redis_v1beta1_generated_CloudRedis_RescheduleMaintenance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.update_instance.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.update_instance.js deleted file mode 100644 index 3024cd3c736..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.update_instance.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(updateMask, instance) { - // [START redis_v1beta1_generated_CloudRedis_UpdateInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Mask of fields to update. At least one path must be supplied in - * this field. The elements of the repeated paths field may only include these - * fields from Instance google.cloud.redis.v1beta1.Instance: - * * `displayName` - * * `labels` - * * `memorySizeGb` - * * `redisConfig` - * * `replica_count` - */ - // const updateMask = {} - /** - * Required. Update description. - * Only fields specified in update_mask are updated. - */ - // const instance = {} - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callUpdateInstance() { - // Construct request - const request = { - updateMask, - instance, - }; - - // Run request - const [operation] = await redisClient.updateInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateInstance(); - // [END redis_v1beta1_generated_CloudRedis_UpdateInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.upgrade_instance.js b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.upgrade_instance.js deleted file mode 100644 index 85c9c26c058..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/cloud_redis.upgrade_instance.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(name, redisVersion) { - // [START redis_v1beta1_generated_CloudRedis_UpgradeInstance_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - */ - // const name = 'abc123' - /** - * Required. Specifies the target version of Redis software to upgrade to. - */ - // const redisVersion = 'abc123' - - // Imports the Redis library - const {CloudRedisClient} = require('@google-cloud/redis').v1beta1; - - // Instantiates a client - const redisClient = new CloudRedisClient(); - - async function callUpgradeInstance() { - // Construct request - const request = { - name, - redisVersion, - }; - - // Run request - const [operation] = await redisClient.upgradeInstance(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpgradeInstance(); - // [END redis_v1beta1_generated_CloudRedis_UpgradeInstance_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.redis.v1beta1.json b/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.redis.v1beta1.json deleted file mode 100644 index 8354487f3c4..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.redis.v1beta1.json +++ /dev/null @@ -1,499 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-redis", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.redis.v1beta1", - "version": "v1beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "redis_v1beta1_generated_CloudRedis_ListInstances_async", - "title": "CloudRedis listInstances Sample", - "origin": "API_DEFINITION", - "description": " Lists all Redis instances owned by a project in either the specified location (region) or all locations. The location should have the following format: * `projects/{project_id}/locations/{location_id}` If `location_id` is specified as `-` (wildcard), then all regions available to the project are queried, and the results are aggregated.", - "canonical": true, - "file": "cloud_redis.list_instances.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListInstances", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.ListInstances", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.redis.v1beta1.ListInstancesResponse", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" - }, - "method": { - "shortName": "ListInstances", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.ListInstances", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1beta1.CloudRedis" - } - } - } - }, - { - "regionTag": "redis_v1beta1_generated_CloudRedis_GetInstance_async", - "title": "CloudRedis getInstance Sample", - "origin": "API_DEFINITION", - "description": " Gets the details of a specific Redis instance.", - "canonical": true, - "file": "cloud_redis.get_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetInstance", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.GetInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.redis.v1beta1.Instance", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" - }, - "method": { - "shortName": "GetInstance", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.GetInstance", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1beta1.CloudRedis" - } - } - } - }, - { - "regionTag": "redis_v1beta1_generated_CloudRedis_GetInstanceAuthString_async", - "title": "CloudRedis getInstanceAuthString Sample", - "origin": "API_DEFINITION", - "description": " Gets the AUTH string for a Redis instance. If AUTH is not enabled for the instance the response will be empty. This information is not included in the details returned to GetInstance.", - "canonical": true, - "file": "cloud_redis.get_instance_auth_string.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetInstanceAuthString", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.GetInstanceAuthString", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.redis.v1beta1.InstanceAuthString", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" - }, - "method": { - "shortName": "GetInstanceAuthString", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.GetInstanceAuthString", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1beta1.CloudRedis" - } - } - } - }, - { - "regionTag": "redis_v1beta1_generated_CloudRedis_CreateInstance_async", - "title": "CloudRedis createInstance Sample", - "origin": "API_DEFINITION", - "description": " Creates a Redis instance based on the specified tier and memory size. By default, the instance is accessible from the project's [default network](https://cloud.google.com/vpc/docs/vpc). The creation is executed asynchronously and callers may check the returned operation to track its progress. Once the operation is completed the Redis instance will be fully functional. The completed longrunning.Operation will contain the new instance object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.", - "canonical": true, - "file": "cloud_redis.create_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateInstance", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.CreateInstance", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "instance_id", - "type": "TYPE_STRING" - }, - { - "name": "instance", - "type": ".google.cloud.redis.v1beta1.Instance" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" - }, - "method": { - "shortName": "CreateInstance", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.CreateInstance", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1beta1.CloudRedis" - } - } - } - }, - { - "regionTag": "redis_v1beta1_generated_CloudRedis_UpdateInstance_async", - "title": "CloudRedis updateInstance Sample", - "origin": "API_DEFINITION", - "description": " Updates the metadata and configuration of a specific Redis instance. Completed longrunning.Operation will contain the new instance object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.", - "canonical": true, - "file": "cloud_redis.update_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateInstance", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.UpdateInstance", - "async": true, - "parameters": [ - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "instance", - "type": ".google.cloud.redis.v1beta1.Instance" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" - }, - "method": { - "shortName": "UpdateInstance", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.UpdateInstance", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1beta1.CloudRedis" - } - } - } - }, - { - "regionTag": "redis_v1beta1_generated_CloudRedis_UpgradeInstance_async", - "title": "CloudRedis upgradeInstance Sample", - "origin": "API_DEFINITION", - "description": " Upgrades Redis instance to the newer Redis version specified in the request.", - "canonical": true, - "file": "cloud_redis.upgrade_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpgradeInstance", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.UpgradeInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "redis_version", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" - }, - "method": { - "shortName": "UpgradeInstance", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.UpgradeInstance", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1beta1.CloudRedis" - } - } - } - }, - { - "regionTag": "redis_v1beta1_generated_CloudRedis_ImportInstance_async", - "title": "CloudRedis importInstance Sample", - "origin": "API_DEFINITION", - "description": " Import a Redis RDB snapshot file from Cloud Storage into a Redis instance. Redis may stop serving during this operation. Instance state will be IMPORTING for entire operation. When complete, the instance will contain only data from the imported file. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.", - "canonical": true, - "file": "cloud_redis.import_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportInstance", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.ImportInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.redis.v1beta1.InputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" - }, - "method": { - "shortName": "ImportInstance", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.ImportInstance", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1beta1.CloudRedis" - } - } - } - }, - { - "regionTag": "redis_v1beta1_generated_CloudRedis_ExportInstance_async", - "title": "CloudRedis exportInstance Sample", - "origin": "API_DEFINITION", - "description": " Export Redis instance data into a Redis RDB format file in Cloud Storage. Redis will continue serving during this operation. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.", - "canonical": true, - "file": "cloud_redis.export_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ExportInstance", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.ExportInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "output_config", - "type": ".google.cloud.redis.v1beta1.OutputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" - }, - "method": { - "shortName": "ExportInstance", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.ExportInstance", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1beta1.CloudRedis" - } - } - } - }, - { - "regionTag": "redis_v1beta1_generated_CloudRedis_FailoverInstance_async", - "title": "CloudRedis failoverInstance Sample", - "origin": "API_DEFINITION", - "description": " Initiates a failover of the primary node to current replica node for a specific STANDARD tier Cloud Memorystore for Redis instance.", - "canonical": true, - "file": "cloud_redis.failover_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "FailoverInstance", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.FailoverInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "data_protection_mode", - "type": ".google.cloud.redis.v1beta1.FailoverInstanceRequest.DataProtectionMode" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" - }, - "method": { - "shortName": "FailoverInstance", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.FailoverInstance", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1beta1.CloudRedis" - } - } - } - }, - { - "regionTag": "redis_v1beta1_generated_CloudRedis_DeleteInstance_async", - "title": "CloudRedis deleteInstance Sample", - "origin": "API_DEFINITION", - "description": " Deletes a specific Redis instance. Instance stops serving and data is deleted.", - "canonical": true, - "file": "cloud_redis.delete_instance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteInstance", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.DeleteInstance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" - }, - "method": { - "shortName": "DeleteInstance", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.DeleteInstance", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1beta1.CloudRedis" - } - } - } - }, - { - "regionTag": "redis_v1beta1_generated_CloudRedis_RescheduleMaintenance_async", - "title": "CloudRedis rescheduleMaintenance Sample", - "origin": "API_DEFINITION", - "description": " Reschedule maintenance for a given instance in a given project and location.", - "canonical": true, - "file": "cloud_redis.reschedule_maintenance.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RescheduleMaintenance", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.RescheduleMaintenance", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "reschedule_type", - "type": ".google.cloud.redis.v1beta1.RescheduleMaintenanceRequest.RescheduleType" - }, - { - "name": "schedule_time", - "type": ".google.protobuf.Timestamp" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CloudRedisClient", - "fullName": "google.cloud.redis.v1beta1.CloudRedisClient" - }, - "method": { - "shortName": "RescheduleMaintenance", - "fullName": "google.cloud.redis.v1beta1.CloudRedis.RescheduleMaintenance", - "service": { - "shortName": "CloudRedis", - "fullName": "google.cloud.redis.v1beta1.CloudRedis" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-redis/v1beta1/src/index.ts deleted file mode 100644 index 2ece0fa6907..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/src/index.ts +++ /dev/null @@ -1,25 +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 v1beta1 from './v1beta1'; -const CloudRedisClient = v1beta1.CloudRedisClient; -type CloudRedisClient = v1beta1.CloudRedisClient; -export {v1beta1, CloudRedisClient}; -export default {v1beta1, CloudRedisClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_client.ts b/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_client.ts deleted file mode 100644 index 01fe717f251..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_client.ts +++ /dev/null @@ -1,1659 +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} 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/v1beta1/cloud_redis_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './cloud_redis_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Configures and manages Cloud Memorystore for Redis instances - * - * Google Cloud Memorystore for Redis v1beta1 - * - * The `redis.googleapis.com` service implements the Google Cloud Memorystore - * for Redis API and defines the following resource model for managing Redis - * instances: - * * The service works with a collection of cloud projects, named: `/projects/*` - * * Each project has a collection of available locations, named: `/locations/*` - * * Each location has a collection of Redis instances, named: `/instances/*` - * * As such, Redis instances are resources of the form: - * `/projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * - * Note that location_id must be referring to a GCP `region`; for example: - * * `projects/redpepper-1290/locations/us-central1/instances/my-redis` - * @class - * @memberof v1beta1 - */ -export class CloudRedisClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - cloudRedisStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CloudRedisClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 CloudRedisClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof CloudRedisClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - instancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - }; - - // 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 = { - listInstances: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instances') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta1/{name=projects/*}/locations',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta1/{name=projects/*/locations/*/operations/*}:cancel',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta1/{name=projects/*/locations/*}/operations',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.redis.v1beta1.Instance') as gax.protobuf.Type; - const createInstanceMetadata = protoFilesRoot.lookup( - '.google.protobuf.Any') as gax.protobuf.Type; - const updateInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.redis.v1beta1.Instance') as gax.protobuf.Type; - const updateInstanceMetadata = protoFilesRoot.lookup( - '.google.protobuf.Any') as gax.protobuf.Type; - const upgradeInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.redis.v1beta1.Instance') as gax.protobuf.Type; - const upgradeInstanceMetadata = protoFilesRoot.lookup( - '.google.protobuf.Any') as gax.protobuf.Type; - const importInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.redis.v1beta1.Instance') as gax.protobuf.Type; - const importInstanceMetadata = protoFilesRoot.lookup( - '.google.protobuf.Any') as gax.protobuf.Type; - const exportInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.redis.v1beta1.Instance') as gax.protobuf.Type; - const exportInstanceMetadata = protoFilesRoot.lookup( - '.google.protobuf.Any') as gax.protobuf.Type; - const failoverInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.redis.v1beta1.Instance') as gax.protobuf.Type; - const failoverInstanceMetadata = protoFilesRoot.lookup( - '.google.protobuf.Any') as gax.protobuf.Type; - const deleteInstanceResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteInstanceMetadata = protoFilesRoot.lookup( - '.google.protobuf.Any') as gax.protobuf.Type; - const rescheduleMaintenanceResponse = protoFilesRoot.lookup( - '.google.cloud.redis.v1beta1.Instance') as gax.protobuf.Type; - const rescheduleMaintenanceMetadata = protoFilesRoot.lookup( - '.google.protobuf.Any') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createInstanceResponse.decode.bind(createInstanceResponse), - createInstanceMetadata.decode.bind(createInstanceMetadata)), - updateInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateInstanceResponse.decode.bind(updateInstanceResponse), - updateInstanceMetadata.decode.bind(updateInstanceMetadata)), - upgradeInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - upgradeInstanceResponse.decode.bind(upgradeInstanceResponse), - upgradeInstanceMetadata.decode.bind(upgradeInstanceMetadata)), - importInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importInstanceResponse.decode.bind(importInstanceResponse), - importInstanceMetadata.decode.bind(importInstanceMetadata)), - exportInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - exportInstanceResponse.decode.bind(exportInstanceResponse), - exportInstanceMetadata.decode.bind(exportInstanceMetadata)), - failoverInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - failoverInstanceResponse.decode.bind(failoverInstanceResponse), - failoverInstanceMetadata.decode.bind(failoverInstanceMetadata)), - deleteInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteInstanceResponse.decode.bind(deleteInstanceResponse), - deleteInstanceMetadata.decode.bind(deleteInstanceMetadata)), - rescheduleMaintenance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - rescheduleMaintenanceResponse.decode.bind(rescheduleMaintenanceResponse), - rescheduleMaintenanceMetadata.decode.bind(rescheduleMaintenanceMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.redis.v1beta1.CloudRedis', 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.cloudRedisStub) { - return this.cloudRedisStub; - } - - // Put together the "service stub" for - // google.cloud.redis.v1beta1.CloudRedis. - this.cloudRedisStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.redis.v1beta1.CloudRedis') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.redis.v1beta1.CloudRedis, - 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 cloudRedisStubMethods = - ['listInstances', 'getInstance', 'getInstanceAuthString', 'createInstance', 'updateInstance', 'upgradeInstance', 'importInstance', 'exportInstance', 'failoverInstance', 'deleteInstance', 'rescheduleMaintenance']; - for (const methodName of cloudRedisStubMethods) { - const callPromise = this.cloudRedisStub.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.cloudRedisStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'redis.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 'redis.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 the details of a specific Redis instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.redis.v1beta1.Instance|Instance}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_redis.get_instance.js - * region_tag:redis_v1beta1_generated_CloudRedis_GetInstance_async - */ - getInstance( - request?: protos.google.cloud.redis.v1beta1.IGetInstanceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.redis.v1beta1.IInstance, - protos.google.cloud.redis.v1beta1.IGetInstanceRequest|undefined, {}|undefined - ]>; - getInstance( - request: protos.google.cloud.redis.v1beta1.IGetInstanceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.redis.v1beta1.IInstance, - protos.google.cloud.redis.v1beta1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; - getInstance( - request: protos.google.cloud.redis.v1beta1.IGetInstanceRequest, - callback: Callback< - protos.google.cloud.redis.v1beta1.IInstance, - protos.google.cloud.redis.v1beta1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; - getInstance( - request?: protos.google.cloud.redis.v1beta1.IGetInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.redis.v1beta1.IInstance, - protos.google.cloud.redis.v1beta1.IGetInstanceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.redis.v1beta1.IInstance, - protos.google.cloud.redis.v1beta1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.redis.v1beta1.IInstance, - protos.google.cloud.redis.v1beta1.IGetInstanceRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getInstance(request, options, callback); - } -/** - * Gets the AUTH string for a Redis instance. If AUTH is not enabled for the - * instance the response will be empty. This information is not included in - * the details returned to GetInstance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.redis.v1beta1.InstanceAuthString|InstanceAuthString}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_redis.get_instance_auth_string.js - * region_tag:redis_v1beta1_generated_CloudRedis_GetInstanceAuthString_async - */ - getInstanceAuthString( - request?: protos.google.cloud.redis.v1beta1.IGetInstanceAuthStringRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.redis.v1beta1.IInstanceAuthString, - protos.google.cloud.redis.v1beta1.IGetInstanceAuthStringRequest|undefined, {}|undefined - ]>; - getInstanceAuthString( - request: protos.google.cloud.redis.v1beta1.IGetInstanceAuthStringRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.redis.v1beta1.IInstanceAuthString, - protos.google.cloud.redis.v1beta1.IGetInstanceAuthStringRequest|null|undefined, - {}|null|undefined>): void; - getInstanceAuthString( - request: protos.google.cloud.redis.v1beta1.IGetInstanceAuthStringRequest, - callback: Callback< - protos.google.cloud.redis.v1beta1.IInstanceAuthString, - protos.google.cloud.redis.v1beta1.IGetInstanceAuthStringRequest|null|undefined, - {}|null|undefined>): void; - getInstanceAuthString( - request?: protos.google.cloud.redis.v1beta1.IGetInstanceAuthStringRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.redis.v1beta1.IInstanceAuthString, - protos.google.cloud.redis.v1beta1.IGetInstanceAuthStringRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.redis.v1beta1.IInstanceAuthString, - protos.google.cloud.redis.v1beta1.IGetInstanceAuthStringRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.redis.v1beta1.IInstanceAuthString, - protos.google.cloud.redis.v1beta1.IGetInstanceAuthStringRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getInstanceAuthString(request, options, callback); - } - -/** - * Creates a Redis instance based on the specified tier and memory size. - * - * By default, the instance is accessible from the project's - * [default network](https://cloud.google.com/vpc/docs/vpc). - * - * The creation is executed asynchronously and callers may check the returned - * operation to track its progress. Once the operation is completed the Redis - * instance will be fully functional. The completed longrunning.Operation will - * contain the new instance object in the response field. - * - * The returned operation is automatically deleted after a few hours, so there - * is no need to call DeleteOperation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the instance location using the form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a GCP region. - * @param {string} request.instanceId - * Required. The logical name of the Redis instance in the customer project - * with the following restrictions: - * - * * Must contain only lowercase letters, numbers, and hyphens. - * * Must start with a letter. - * * Must be between 1-40 characters. - * * Must end with a number or a letter. - * * Must be unique within the customer project / location - * @param {google.cloud.redis.v1beta1.Instance} request.instance - * Required. A Redis [Instance] resource - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_redis.create_instance.js - * region_tag:redis_v1beta1_generated_CloudRedis_CreateInstance_async - */ - createInstance( - request?: protos.google.cloud.redis.v1beta1.ICreateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createInstance( - request: protos.google.cloud.redis.v1beta1.ICreateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createInstance( - request: protos.google.cloud.redis.v1beta1.ICreateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createInstance( - request?: protos.google.cloud.redis.v1beta1.ICreateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_redis.create_instance.js - * region_tag:redis_v1beta1_generated_CloudRedis_CreateInstance_async - */ - async checkCreateInstanceProgress(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.createInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the metadata and configuration of a specific Redis instance. - * - * Completed longrunning.Operation will contain the new instance object - * in the response field. The returned operation is automatically deleted - * after a few hours, so there is no need to call DeleteOperation. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields to update. At least one path must be supplied in - * this field. The elements of the repeated paths field may only include these - * fields from {@link protos.google.cloud.redis.v1beta1.Instance|Instance}: - * - * * `displayName` - * * `labels` - * * `memorySizeGb` - * * `redisConfig` - * * `replica_count` - * @param {google.cloud.redis.v1beta1.Instance} request.instance - * Required. Update description. - * Only fields specified in update_mask 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_redis.update_instance.js - * region_tag:redis_v1beta1_generated_CloudRedis_UpdateInstance_async - */ - updateInstance( - request?: protos.google.cloud.redis.v1beta1.IUpdateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateInstance( - request: protos.google.cloud.redis.v1beta1.IUpdateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateInstance( - request: protos.google.cloud.redis.v1beta1.IUpdateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateInstance( - request?: protos.google.cloud.redis.v1beta1.IUpdateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'instance.name': request.instance!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_redis.update_instance.js - * region_tag:redis_v1beta1_generated_CloudRedis_UpdateInstance_async - */ - async checkUpdateInstanceProgress(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.updateInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Upgrades Redis instance to the newer Redis version specified in the - * request. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - * @param {string} request.redisVersion - * Required. Specifies the target version of Redis software to upgrade to. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_redis.upgrade_instance.js - * region_tag:redis_v1beta1_generated_CloudRedis_UpgradeInstance_async - */ - upgradeInstance( - request?: protos.google.cloud.redis.v1beta1.IUpgradeInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - upgradeInstance( - request: protos.google.cloud.redis.v1beta1.IUpgradeInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - upgradeInstance( - request: protos.google.cloud.redis.v1beta1.IUpgradeInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - upgradeInstance( - request?: protos.google.cloud.redis.v1beta1.IUpgradeInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.upgradeInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `upgradeInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_redis.upgrade_instance.js - * region_tag:redis_v1beta1_generated_CloudRedis_UpgradeInstance_async - */ - async checkUpgradeInstanceProgress(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.upgradeInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Import a Redis RDB snapshot file from Cloud Storage into a Redis instance. - * - * Redis may stop serving during this operation. Instance state will be - * IMPORTING for entire operation. When complete, the instance will contain - * only data from the imported file. - * - * The returned operation is automatically deleted after a few hours, so - * there is no need to call DeleteOperation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - * @param {google.cloud.redis.v1beta1.InputConfig} request.inputConfig - * Required. Specify data to be imported. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_redis.import_instance.js - * region_tag:redis_v1beta1_generated_CloudRedis_ImportInstance_async - */ - importInstance( - request?: protos.google.cloud.redis.v1beta1.IImportInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importInstance( - request: protos.google.cloud.redis.v1beta1.IImportInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importInstance( - request: protos.google.cloud.redis.v1beta1.IImportInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importInstance( - request?: protos.google.cloud.redis.v1beta1.IImportInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.importInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_redis.import_instance.js - * region_tag:redis_v1beta1_generated_CloudRedis_ImportInstance_async - */ - async checkImportInstanceProgress(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.importInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Export Redis instance data into a Redis RDB format file in Cloud Storage. - * - * Redis will continue serving during this operation. - * - * The returned operation is automatically deleted after a few hours, so - * there is no need to call DeleteOperation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - * @param {google.cloud.redis.v1beta1.OutputConfig} request.outputConfig - * Required. Specify data to be exported. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_redis.export_instance.js - * region_tag:redis_v1beta1_generated_CloudRedis_ExportInstance_async - */ - exportInstance( - request?: protos.google.cloud.redis.v1beta1.IExportInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - exportInstance( - request: protos.google.cloud.redis.v1beta1.IExportInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - exportInstance( - request: protos.google.cloud.redis.v1beta1.IExportInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - exportInstance( - request?: protos.google.cloud.redis.v1beta1.IExportInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.exportInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `exportInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_redis.export_instance.js - * region_tag:redis_v1beta1_generated_CloudRedis_ExportInstance_async - */ - async checkExportInstanceProgress(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.exportInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Initiates a failover of the primary node to current replica node for a - * specific STANDARD tier Cloud Memorystore for Redis instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - * @param {google.cloud.redis.v1beta1.FailoverInstanceRequest.DataProtectionMode} [request.dataProtectionMode] - * Optional. Available data protection modes that the user can choose. If it's - * unspecified, data protection mode will be LIMITED_DATA_LOSS by default. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_redis.failover_instance.js - * region_tag:redis_v1beta1_generated_CloudRedis_FailoverInstance_async - */ - failoverInstance( - request?: protos.google.cloud.redis.v1beta1.IFailoverInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - failoverInstance( - request: protos.google.cloud.redis.v1beta1.IFailoverInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - failoverInstance( - request: protos.google.cloud.redis.v1beta1.IFailoverInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - failoverInstance( - request?: protos.google.cloud.redis.v1beta1.IFailoverInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.failoverInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `failoverInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_redis.failover_instance.js - * region_tag:redis_v1beta1_generated_CloudRedis_FailoverInstance_async - */ - async checkFailoverInstanceProgress(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.failoverInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a specific Redis instance. Instance stops serving and data is - * deleted. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_redis.delete_instance.js - * region_tag:redis_v1beta1_generated_CloudRedis_DeleteInstance_async - */ - deleteInstance( - request?: protos.google.cloud.redis.v1beta1.IDeleteInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteInstance( - request: protos.google.cloud.redis.v1beta1.IDeleteInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteInstance( - request: protos.google.cloud.redis.v1beta1.IDeleteInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteInstance( - request?: protos.google.cloud.redis.v1beta1.IDeleteInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_redis.delete_instance.js - * region_tag:redis_v1beta1_generated_CloudRedis_DeleteInstance_async - */ - async checkDeleteInstanceProgress(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.deleteInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Reschedule maintenance for a given instance in a given project and - * location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Redis instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - * @param {google.cloud.redis.v1beta1.RescheduleMaintenanceRequest.RescheduleType} request.rescheduleType - * Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well. - * @param {google.protobuf.Timestamp} [request.scheduleTime] - * Optional. Timestamp when the maintenance shall be rescheduled to if - * reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for - * example `2012-11-15T16:19:00.094Z`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_redis.reschedule_maintenance.js - * region_tag:redis_v1beta1_generated_CloudRedis_RescheduleMaintenance_async - */ - rescheduleMaintenance( - request?: protos.google.cloud.redis.v1beta1.IRescheduleMaintenanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - rescheduleMaintenance( - request: protos.google.cloud.redis.v1beta1.IRescheduleMaintenanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - rescheduleMaintenance( - request: protos.google.cloud.redis.v1beta1.IRescheduleMaintenanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - rescheduleMaintenance( - request?: protos.google.cloud.redis.v1beta1.IRescheduleMaintenanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.rescheduleMaintenance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `rescheduleMaintenance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_redis.reschedule_maintenance.js - * region_tag:redis_v1beta1_generated_CloudRedis_RescheduleMaintenance_async - */ - async checkRescheduleMaintenanceProgress(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.rescheduleMaintenance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists all Redis instances owned by a project in either the specified - * location (region) or all locations. - * - * The location should have the following format: - * - * * `projects/{project_id}/locations/{location_id}` - * - * If `location_id` is specified as `-` (wildcard), then all regions - * available to the project are queried, and the results are aggregated. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the instance location using the form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a GCP region. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 1000 will be used by the service. - * Regardless of the page_size value, the response may include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.redis.v1beta1.ListInstancesResponse.next_page_token|`next_page_token`} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous - * {@link protos.google.cloud.redis.v1beta1.CloudRedis.ListInstances|ListInstances} request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.redis.v1beta1.Instance|Instance}. - * 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 `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listInstances( - request?: protos.google.cloud.redis.v1beta1.IListInstancesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.redis.v1beta1.IInstance[], - protos.google.cloud.redis.v1beta1.IListInstancesRequest|null, - protos.google.cloud.redis.v1beta1.IListInstancesResponse - ]>; - listInstances( - request: protos.google.cloud.redis.v1beta1.IListInstancesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.redis.v1beta1.IListInstancesRequest, - protos.google.cloud.redis.v1beta1.IListInstancesResponse|null|undefined, - protos.google.cloud.redis.v1beta1.IInstance>): void; - listInstances( - request: protos.google.cloud.redis.v1beta1.IListInstancesRequest, - callback: PaginationCallback< - protos.google.cloud.redis.v1beta1.IListInstancesRequest, - protos.google.cloud.redis.v1beta1.IListInstancesResponse|null|undefined, - protos.google.cloud.redis.v1beta1.IInstance>): void; - listInstances( - request?: protos.google.cloud.redis.v1beta1.IListInstancesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.redis.v1beta1.IListInstancesRequest, - protos.google.cloud.redis.v1beta1.IListInstancesResponse|null|undefined, - protos.google.cloud.redis.v1beta1.IInstance>, - callback?: PaginationCallback< - protos.google.cloud.redis.v1beta1.IListInstancesRequest, - protos.google.cloud.redis.v1beta1.IListInstancesResponse|null|undefined, - protos.google.cloud.redis.v1beta1.IInstance>): - Promise<[ - protos.google.cloud.redis.v1beta1.IInstance[], - protos.google.cloud.redis.v1beta1.IListInstancesRequest|null, - protos.google.cloud.redis.v1beta1.IListInstancesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listInstances(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the instance location using the form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a GCP region. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 1000 will be used by the service. - * Regardless of the page_size value, the response may include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.redis.v1beta1.ListInstancesResponse.next_page_token|`next_page_token`} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous - * {@link protos.google.cloud.redis.v1beta1.CloudRedis.ListInstances|ListInstances} request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.redis.v1beta1.Instance|Instance} 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 `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listInstancesStream( - request?: protos.google.cloud.redis.v1beta1.IListInstancesRequest, - 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['listInstances']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInstances.createStream( - this.innerApiCalls.listInstances as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listInstances`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the instance location using the form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a GCP region. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 1000 will be used by the service. - * Regardless of the page_size value, the response may include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.redis.v1beta1.ListInstancesResponse.next_page_token|`next_page_token`} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous - * {@link protos.google.cloud.redis.v1beta1.CloudRedis.ListInstances|ListInstances} request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.redis.v1beta1.Instance|Instance}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_redis.list_instances.js - * region_tag:redis_v1beta1_generated_CloudRedis_ListInstances_async - */ - listInstancesAsync( - request?: protos.google.cloud.redis.v1beta1.IListInstancesRequest, - 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['listInstances']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInstances.asyncIterate( - this.innerApiCalls['listInstances'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified instance resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} instance - * @returns {string} Resource name string. - */ - instancePath(project:string,location:string,instance:string) { - return this.pathTemplates.instancePathTemplate.render({ - project: project, - location: location, - instance: instance, - }); - } - - /** - * Parse the project from Instance resource. - * - * @param {string} instanceName - * A fully-qualified path representing Instance resource. - * @returns {string} A string representing the project. - */ - matchProjectFromInstanceName(instanceName: string) { - return this.pathTemplates.instancePathTemplate.match(instanceName).project; - } - - /** - * Parse the location from Instance resource. - * - * @param {string} instanceName - * A fully-qualified path representing Instance resource. - * @returns {string} A string representing the location. - */ - matchLocationFromInstanceName(instanceName: string) { - return this.pathTemplates.instancePathTemplate.match(instanceName).location; - } - - /** - * Parse the instance from Instance resource. - * - * @param {string} instanceName - * A fully-qualified path representing Instance resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromInstanceName(instanceName: string) { - return this.pathTemplates.instancePathTemplate.match(instanceName).instance; - } - - /** - * 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; - } - - /** - * 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.cloudRedisStub && !this._terminated) { - return this.cloudRedisStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_client_config.json b/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_client_config.json deleted file mode 100644 index fc33fa45d6f..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_client_config.json +++ /dev/null @@ -1,80 +0,0 @@ -{ - "interfaces": { - "google.cloud.redis.v1beta1.CloudRedis": { - "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": { - "ListInstances": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetInstance": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetInstanceAuthString": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateInstance": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateInstance": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpgradeInstance": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ImportInstance": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ExportInstance": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "FailoverInstance": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteInstance": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RescheduleMaintenance": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_proto_list.json b/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_proto_list.json deleted file mode 100644 index 6cd14735515..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/cloud_redis_proto_list.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "../../protos/google/cloud/redis/v1beta1/cloud_redis.proto" -] diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/gapic_metadata.json deleted file mode 100644 index 6ec65068a1d..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/gapic_metadata.json +++ /dev/null @@ -1,137 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.redis.v1beta1", - "libraryPackage": "@google-cloud/redis", - "services": { - "CloudRedis": { - "clients": { - "grpc": { - "libraryClient": "CloudRedisClient", - "rpcs": { - "GetInstance": { - "methods": [ - "getInstance" - ] - }, - "GetInstanceAuthString": { - "methods": [ - "getInstanceAuthString" - ] - }, - "CreateInstance": { - "methods": [ - "createInstance" - ] - }, - "UpdateInstance": { - "methods": [ - "updateInstance" - ] - }, - "UpgradeInstance": { - "methods": [ - "upgradeInstance" - ] - }, - "ImportInstance": { - "methods": [ - "importInstance" - ] - }, - "ExportInstance": { - "methods": [ - "exportInstance" - ] - }, - "FailoverInstance": { - "methods": [ - "failoverInstance" - ] - }, - "DeleteInstance": { - "methods": [ - "deleteInstance" - ] - }, - "RescheduleMaintenance": { - "methods": [ - "rescheduleMaintenance" - ] - }, - "ListInstances": { - "methods": [ - "listInstances", - "listInstancesStream", - "listInstancesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CloudRedisClient", - "rpcs": { - "GetInstance": { - "methods": [ - "getInstance" - ] - }, - "GetInstanceAuthString": { - "methods": [ - "getInstanceAuthString" - ] - }, - "CreateInstance": { - "methods": [ - "createInstance" - ] - }, - "UpdateInstance": { - "methods": [ - "updateInstance" - ] - }, - "UpgradeInstance": { - "methods": [ - "upgradeInstance" - ] - }, - "ImportInstance": { - "methods": [ - "importInstance" - ] - }, - "ExportInstance": { - "methods": [ - "exportInstance" - ] - }, - "FailoverInstance": { - "methods": [ - "failoverInstance" - ] - }, - "DeleteInstance": { - "methods": [ - "deleteInstance" - ] - }, - "RescheduleMaintenance": { - "methods": [ - "rescheduleMaintenance" - ] - }, - "ListInstances": { - "methods": [ - "listInstances", - "listInstancesStream", - "listInstancesAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/index.ts deleted file mode 100644 index 036e9efba28..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/src/v1beta1/index.ts +++ /dev/null @@ -1,19 +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 {CloudRedisClient} from './cloud_redis_client'; diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-redis/v1beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index bb242f40531..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const redis = require('@google-cloud/redis'); - -function main() { - const cloudRedisClient = new redis.CloudRedisClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-redis/v1beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index b6c5a1f5f69..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {CloudRedisClient} from '@google-cloud/redis'; - -// check that the client class type name can be used -function doStuffWithCloudRedisClient(client: CloudRedisClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const cloudRedisClient = new CloudRedisClient(); - doStuffWithCloudRedisClient(cloudRedisClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-redis/v1beta1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/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-redis/v1beta1/test/gapic_cloud_redis_v1beta1.ts b/owl-bot-staging/google-cloud-redis/v1beta1/test/gapic_cloud_redis_v1beta1.ts deleted file mode 100644 index 18ca04c7686..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/test/gapic_cloud_redis_v1beta1.ts +++ /dev/null @@ -1,1997 +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 cloudredisModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1beta1.CloudRedisClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = cloudredisModule.v1beta1.CloudRedisClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = cloudredisModule.v1beta1.CloudRedisClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = cloudredisModule.v1beta1.CloudRedisClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudRedisStub, undefined); - await client.initialize(); - assert(client.cloudRedisStub); - }); - - it('has close method for the initialized client', done => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.cloudRedisStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudRedisStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - 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 cloudredisModule.v1beta1.CloudRedisClient({ - 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('getInstance', () => { - it('invokes getInstance without error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); - const [response] = await client.getInstance(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstance without error using callback', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstance( - request, - (err?: Error|null, result?: protos.google.cloud.redis.v1beta1.IInstance|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstance with error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstance with closed client', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getInstance(request), expectedError); - }); - }); - - describe('getInstanceAuthString', () => { - it('invokes getInstanceAuthString without error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.GetInstanceAuthStringRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.GetInstanceAuthStringRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.InstanceAuthString() - ); - client.innerApiCalls.getInstanceAuthString = stubSimpleCall(expectedResponse); - const [response] = await client.getInstanceAuthString(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstanceAuthString as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstanceAuthString as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstanceAuthString without error using callback', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.GetInstanceAuthStringRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.GetInstanceAuthStringRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.InstanceAuthString() - ); - client.innerApiCalls.getInstanceAuthString = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstanceAuthString( - request, - (err?: Error|null, result?: protos.google.cloud.redis.v1beta1.IInstanceAuthString|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstanceAuthString as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstanceAuthString as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstanceAuthString with error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.GetInstanceAuthStringRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.GetInstanceAuthStringRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstanceAuthString = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstanceAuthString(request), expectedError); - const actualRequest = (client.innerApiCalls.getInstanceAuthString as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstanceAuthString as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstanceAuthString with closed client', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.GetInstanceAuthStringRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.GetInstanceAuthStringRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getInstanceAuthString(request), expectedError); - }); - }); - - describe('createInstance', () => { - it('invokes createInstance without error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.createInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInstance without error using callback', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createInstance( - request, - (err?: Error|null, - result?: 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.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInstance with call error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInstance with LRO error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateInstanceProgress without error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateInstanceProgress with error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateInstance', () => { - it('invokes updateInstance without error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstance without error using callback', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateInstance( - request, - (err?: Error|null, - result?: 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.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstance with call error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstance with LRO error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateInstanceProgress without error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateInstanceProgress with error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('upgradeInstance', () => { - it('invokes upgradeInstance without error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.upgradeInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstance without error using callback', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.upgradeInstance( - request, - (err?: Error|null, - result?: 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.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstance with call error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.upgradeInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstance with LRO error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.upgradeInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpgradeInstanceProgress without error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpgradeInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpgradeInstanceProgress with error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpgradeInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('importInstance', () => { - it('invokes importInstance without error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.ImportInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.ImportInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.importInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importInstance without error using callback', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.ImportInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.ImportInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importInstance( - request, - (err?: Error|null, - result?: 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.importInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importInstance with call error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.ImportInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.ImportInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.importInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importInstance with LRO error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.ImportInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.ImportInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkImportInstanceProgress without error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportInstanceProgress with error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('exportInstance', () => { - it('invokes exportInstance without error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.ExportInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.ExportInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.exportInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.exportInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.exportInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes exportInstance without error using callback', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.ExportInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.ExportInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.exportInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.exportInstance( - request, - (err?: Error|null, - result?: 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.exportInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes exportInstance with call error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.ExportInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.ExportInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.exportInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.exportInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.exportInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes exportInstance with LRO error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.ExportInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.ExportInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.exportInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.exportInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.exportInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkExportInstanceProgress without error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkExportInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkExportInstanceProgress with error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkExportInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('failoverInstance', () => { - it('invokes failoverInstance without error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.FailoverInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.FailoverInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.failoverInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.failoverInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.failoverInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.failoverInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes failoverInstance without error using callback', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.FailoverInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.FailoverInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.failoverInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.failoverInstance( - request, - (err?: Error|null, - result?: 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.failoverInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.failoverInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes failoverInstance with call error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.FailoverInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.FailoverInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.failoverInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.failoverInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.failoverInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.failoverInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes failoverInstance with LRO error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.FailoverInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.FailoverInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.failoverInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.failoverInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.failoverInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.failoverInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkFailoverInstanceProgress without error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkFailoverInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkFailoverInstanceProgress with error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkFailoverInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteInstance', () => { - it('invokes deleteInstance without error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInstance without error using callback', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteInstance( - request, - (err?: Error|null, - result?: 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.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInstance with call error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInstance with LRO error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteInstanceProgress without error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteInstanceProgress with error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('rescheduleMaintenance', () => { - it('invokes rescheduleMaintenance without error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.RescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.RescheduleMaintenanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall(expectedResponse); - const [operation] = await client.rescheduleMaintenance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rescheduleMaintenance without error using callback', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.RescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.RescheduleMaintenanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rescheduleMaintenance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rescheduleMaintenance( - request, - (err?: Error|null, - result?: 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.rescheduleMaintenance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rescheduleMaintenance with call error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.RescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.RescheduleMaintenanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rescheduleMaintenance(request), expectedError); - const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rescheduleMaintenance with LRO error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.RescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.RescheduleMaintenanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rescheduleMaintenance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkRescheduleMaintenanceProgress without error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRescheduleMaintenanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRescheduleMaintenanceProgress with error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRescheduleMaintenanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listInstances', () => { - it('invokes listInstances without error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); - const [response] = await client.listInstances(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstances without error using callback', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInstances( - request, - (err?: Error|null, result?: protos.google.cloud.redis.v1beta1.IInstance[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstances with error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInstances(request), expectedError); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstancesStream without error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), - ]; - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.redis.v1beta1.Instance[] = []; - stream.on('data', (response: protos.google.cloud.redis.v1beta1.Instance) => { - 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.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listInstancesStream with error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.redis.v1beta1.Instance[] = []; - stream.on('data', (response: protos.google.cloud.redis.v1beta1.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInstances without error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), - ]; - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.redis.v1beta1.IInstance[] = []; - const iterable = client.listInstancesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInstances with error', async () => { - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.redis.v1beta1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.redis.v1beta1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInstancesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.redis.v1beta1.IInstance[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('instance', () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - }; - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "locationValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromInstanceName', () => { - const result = client.matchLocationFromInstanceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new cloudredisModule.v1beta1.CloudRedisClient({ - 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)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-redis/v1beta1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-redis/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-redis/v1beta1/webpack.config.js deleted file mode 100644 index c8446c2163e..00000000000 --- a/owl-bot-staging/google-cloud-redis/v1beta1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'CloudRedis', - filename: './cloud-redis.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-resourcemanager/v3/.eslintignore b/owl-bot-staging/google-cloud-resourcemanager/v3/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/.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-resourcemanager/v3/.eslintrc.json b/owl-bot-staging/google-cloud-resourcemanager/v3/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/.gitignore b/owl-bot-staging/google-cloud-resourcemanager/v3/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/.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-resourcemanager/v3/.jsdoc.js b/owl-bot-staging/google-cloud-resourcemanager/v3/.jsdoc.js deleted file mode 100644 index fb2b789c019..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/.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/resource-manager', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/.mocharc.js b/owl-bot-staging/google-cloud-resourcemanager/v3/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/.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-resourcemanager/v3/.prettierrc.js b/owl-bot-staging/google-cloud-resourcemanager/v3/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/.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-resourcemanager/v3/README.md b/owl-bot-staging/google-cloud-resourcemanager/v3/README.md deleted file mode 100644 index 3dd631a1a59..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/README.md +++ /dev/null @@ -1 +0,0 @@ -Resourcemanager: Nodejs Client diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/package.json b/owl-bot-staging/google-cloud-resourcemanager/v3/package.json deleted file mode 100644 index ce74d8d0989..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/resource-manager", - "version": "0.1.0", - "description": "Resourcemanager client for Node.js", - "repository": "googleapis/nodejs-resourcemanager", - "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 resourcemanager", - "resourcemanager", - "folders", - "organizations", - "projects", - "tag bindings", - "tag holds", - "tag keys", - "tag values" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/folders.proto b/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/folders.proto deleted file mode 100644 index 036bf4e6daf..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/folders.proto +++ /dev/null @@ -1,546 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.resourcemanager.v3; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.ResourceManager.V3"; -option go_package = "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb;resourcemanagerpb"; -option java_multiple_files = true; -option java_outer_classname = "FoldersProto"; -option java_package = "com.google.cloud.resourcemanager.v3"; -option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; -option ruby_package = "Google::Cloud::ResourceManager::V3"; - -// Manages Cloud Platform folder resources. -// Folders can be used to organize the resources under an -// organization and to control the policies applied to groups of resources. -service Folders { - option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-platform.read-only"; - - // Retrieves a folder identified by the supplied resource name. - // Valid folder resource names have the format `folders/{folder_id}` - // (for example, `folders/1234`). - // The caller must have `resourcemanager.folders.get` permission on the - // identified folder. - rpc GetFolder(GetFolderRequest) returns (Folder) { - option (google.api.http) = { - get: "/v3/{name=folders/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists the folders that are direct descendants of supplied parent resource. - // `list()` provides a strongly consistent view of the folders underneath - // the specified parent resource. - // `list()` returns folders sorted based upon the (ascending) lexical ordering - // of their display_name. - // The caller must have `resourcemanager.folders.list` permission on the - // identified parent. - rpc ListFolders(ListFoldersRequest) returns (ListFoldersResponse) { - option (google.api.http) = { - get: "/v3/folders" - }; - option (google.api.method_signature) = "parent"; - } - - // Search for folders that match specific filter criteria. - // `search()` provides an eventually consistent view of the folders a user has - // access to which meet the specified filter criteria. - // - // This will only return folders on which the caller has the - // permission `resourcemanager.folders.get`. - rpc SearchFolders(SearchFoldersRequest) returns (SearchFoldersResponse) { - option (google.api.http) = { - get: "/v3/folders:search" - }; - option (google.api.method_signature) = "query"; - } - - // Creates a folder in the resource hierarchy. - // Returns an `Operation` which can be used to track the progress of the - // folder creation workflow. - // Upon success, the `Operation.response` field will be populated with the - // created Folder. - // - // In order to succeed, the addition of this new folder must not violate - // the folder naming, height, or fanout constraints. - // - // + The folder's `display_name` must be distinct from all other folders that - // share its parent. - // + The addition of the folder must not cause the active folder hierarchy - // to exceed a height of 10. Note, the full active + deleted folder hierarchy - // is allowed to reach a height of 20; this provides additional headroom when - // moving folders that contain deleted folders. - // + The addition of the folder must not cause the total number of folders - // under its parent to exceed 300. - // - // If the operation fails due to a folder constraint violation, some errors - // may be returned by the `CreateFolder` request, with status code - // `FAILED_PRECONDITION` and an error description. Other folder constraint - // violations will be communicated in the `Operation`, with the specific - // `PreconditionFailure` returned in the details list in the `Operation.error` - // field. - // - // The caller must have `resourcemanager.folders.create` permission on the - // identified parent. - rpc CreateFolder(CreateFolderRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v3/folders" - body: "folder" - }; - option (google.api.method_signature) = "folder"; - option (google.longrunning.operation_info) = { - response_type: "Folder" - metadata_type: "CreateFolderMetadata" - }; - } - - // Updates a folder, changing its `display_name`. - // Changes to the folder `display_name` will be rejected if they violate - // either the `display_name` formatting rules or the naming constraints - // described in the - // [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] - // documentation. - // - // The folder's `display_name` must start and end with a letter or digit, - // may contain letters, digits, spaces, hyphens and underscores and can be - // between 3 and 30 characters. This is captured by the regular expression: - // `[\p{L}\p{N}][\p{L}\p{N}_- ]{1,28}[\p{L}\p{N}]`. - // The caller must have `resourcemanager.folders.update` permission on the - // identified folder. - // - // If the update fails due to the unique name constraint then a - // `PreconditionFailure` explaining this violation will be returned - // in the Status.details field. - rpc UpdateFolder(UpdateFolderRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v3/{folder.name=folders/*}" - body: "folder" - }; - option (google.api.method_signature) = "folder,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "Folder" - metadata_type: "UpdateFolderMetadata" - }; - } - - // Moves a folder under a new resource parent. - // Returns an `Operation` which can be used to track the progress of the - // folder move workflow. - // Upon success, the `Operation.response` field will be populated with the - // moved folder. - // Upon failure, a `FolderOperationError` categorizing the failure cause will - // be returned - if the failure occurs synchronously then the - // `FolderOperationError` will be returned in the `Status.details` field. - // If it occurs asynchronously, then the FolderOperation will be returned - // in the `Operation.error` field. - // In addition, the `Operation.metadata` field will be populated with a - // `FolderOperation` message as an aid to stateless clients. - // Folder moves will be rejected if they violate either the naming, height, - // or fanout constraints described in the - // [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] - // documentation. The caller must have `resourcemanager.folders.move` - // permission on the folder's current and proposed new parent. - rpc MoveFolder(MoveFolderRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v3/{name=folders/*}:move" - body: "*" - }; - option (google.api.method_signature) = "name,destination_parent"; - option (google.longrunning.operation_info) = { - response_type: "Folder" - metadata_type: "MoveFolderMetadata" - }; - } - - // Requests deletion of a folder. The folder is moved into the - // [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] - // state immediately, and is deleted approximately 30 days later. This method - // may only be called on an empty folder, where a folder is empty if it - // doesn't contain any folders or projects in the - // [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. If - // called on a folder in - // [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] - // state the operation will result in a no-op success. - // The caller must have `resourcemanager.folders.delete` permission on the - // identified folder. - rpc DeleteFolder(DeleteFolderRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v3/{name=folders/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Folder" - metadata_type: "DeleteFolderMetadata" - }; - } - - // Cancels the deletion request for a folder. This method may be called on a - // folder in any state. If the folder is in the - // [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state the - // result will be a no-op success. In order to succeed, the folder's parent - // must be in the - // [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. In - // addition, reintroducing the folder into the tree must not violate folder - // naming, height, and fanout constraints described in the - // [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] - // documentation. The caller must have `resourcemanager.folders.undelete` - // permission on the identified folder. - rpc UndeleteFolder(UndeleteFolderRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v3/{name=folders/*}:undelete" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Folder" - metadata_type: "UndeleteFolderMetadata" - }; - } - - // Gets the access control policy for a folder. The returned policy may be - // empty if no such policy or resource exists. The `resource` field should - // be the folder's resource name, for example: "folders/1234". - // The caller must have `resourcemanager.folders.getIamPolicy` permission - // on the identified folder. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) - returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v3/{resource=folders/*}:getIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource"; - } - - // Sets the access control policy on a folder, replacing any existing policy. - // The `resource` field should be the folder's resource name, for example: - // "folders/1234". - // The caller must have `resourcemanager.folders.setIamPolicy` permission - // on the identified folder. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) - returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v3/{resource=folders/*}:setIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource,policy"; - } - - // Returns permissions that a caller has on the specified folder. - // The `resource` field should be the folder's resource name, - // for example: "folders/1234". - // - // There are no permissions required for making this API call. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) - returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v3/{resource=folders/*}:testIamPermissions" - body: "*" - }; - option (google.api.method_signature) = "resource,permissions"; - } -} - -// A folder in an organization's resource hierarchy, used to -// organize that organization's resources. -message Folder { - option (google.api.resource) = { - type: "cloudresourcemanager.googleapis.com/Folder" - pattern: "folders/{folder}" - style: DECLARATIVE_FRIENDLY - }; - - // Folder lifecycle states. - enum State { - // Unspecified state. - STATE_UNSPECIFIED = 0; - - // The normal and active state. - ACTIVE = 1; - - // The folder has been marked for deletion by the user. - DELETE_REQUESTED = 2; - } - - // Output only. The resource name of the folder. - // Its format is `folders/{folder_id}`, for example: "folders/1234". - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Required. The folder's parent's resource name. - // Updates to the folder's parent must be performed using - // [MoveFolder][google.cloud.resourcemanager.v3.Folders.MoveFolder]. - string parent = 2 [(google.api.field_behavior) = REQUIRED]; - - // The folder's display name. - // A folder's display name must be unique amongst its siblings. For example, - // no two folders with the same parent can share the same display name. - // The display name must start and end with a letter or digit, may contain - // letters, digits, spaces, hyphens and underscores and can be no longer - // than 30 characters. This is captured by the regular expression: - // `[\p{L}\p{N}]([\p{L}\p{N}_- ]{0,28}[\p{L}\p{N}])?`. - string display_name = 3; - - // Output only. The lifecycle state of the folder. - // Updates to the state must be performed using - // [DeleteFolder][google.cloud.resourcemanager.v3.Folders.DeleteFolder] and - // [UndeleteFolder][google.cloud.resourcemanager.v3.Folders.UndeleteFolder]. - State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Timestamp when the folder was created. - google.protobuf.Timestamp create_time = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Timestamp when the folder was last modified. - google.protobuf.Timestamp update_time = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Timestamp when the folder was requested to be deleted. - google.protobuf.Timestamp delete_time = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A checksum computed by the server based on the current value - // of the folder resource. This may be sent on update and delete requests to - // ensure the client has an up-to-date value before proceeding. - string etag = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// The GetFolder request message. -message GetFolderRequest { - // Required. The resource name of the folder to retrieve. - // Must be of the form `folders/{folder_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Folder" - } - ]; -} - -// The ListFolders request message. -message ListFoldersRequest { - // Required. The name of the parent resource whose folders are being listed. - // Only children of this parent resource are listed; descendants are not - // listed. - // - // If the parent is a folder, use the value `folders/{folder_id}`. If the - // parent is an organization, use the value `organizations/{org_id}`. - // - // Access to this method is controlled by checking the - // `resourcemanager.folders.list` permission on the `parent`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { child_type: "*" } - ]; - - // Optional. The maximum number of folders to return in the response. The - // server can return fewer folders than requested. If unspecified, server - // picks an appropriate default. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A pagination token returned from a previous call to `ListFolders` - // that indicates where this listing should continue from. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Controls whether folders in the - // [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] - // state should be returned. Defaults to false. - bool show_deleted = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// The ListFolders response message. -message ListFoldersResponse { - // A possibly paginated list of folders that are direct descendants of - // the specified parent resource. - repeated Folder folders = 1; - - // A pagination token returned from a previous call to `ListFolders` - // that indicates from where listing should continue. - string next_page_token = 2; -} - -// The request message for searching folders. -message SearchFoldersRequest { - // Optional. The maximum number of folders to return in the response. The - // server can return fewer folders than requested. If unspecified, server - // picks an appropriate default. - int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A pagination token returned from a previous call to - // `SearchFolders` that indicates from where search should continue. - string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Search criteria used to select the folders to return. - // If no search criteria is specified then all accessible folders will be - // returned. - // - // Query expressions can be used to restrict results based upon displayName, - // state and parent, where the operators `=` (`:`) `NOT`, `AND` and `OR` - // can be used along with the suffix wildcard symbol `*`. - // - // The `displayName` field in a query expression should use escaped quotes - // for values that include whitespace to prevent unexpected behavior. - // - // ``` - // | Field | Description | - // |-------------------------|----------------------------------------| - // | displayName | Filters by displayName. | - // | parent | Filters by parent (for example: folders/123). | - // | state, lifecycleState | Filters by state. | - // ``` - // - // Some example queries are: - // - // * Query `displayName=Test*` returns Folder resources whose display name - // starts with "Test". - // * Query `state=ACTIVE` returns Folder resources with - // `state` set to `ACTIVE`. - // * Query `parent=folders/123` returns Folder resources that have - // `folders/123` as a parent resource. - // * Query `parent=folders/123 AND state=ACTIVE` returns active - // Folder resources that have `folders/123` as a parent resource. - // * Query `displayName=\\"Test String\\"` returns Folder resources with - // display names that include both "Test" and "String". - string query = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// The response message for searching folders. -message SearchFoldersResponse { - // A possibly paginated folder search results. - // the specified parent resource. - repeated Folder folders = 1; - - // A pagination token returned from a previous call to `SearchFolders` - // that indicates from where searching should continue. - string next_page_token = 2; -} - -// The CreateFolder request message. -message CreateFolderRequest { - // Required. The folder being created, only the display name and parent will - // be consulted. All other fields will be ignored. - Folder folder = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Metadata pertaining to the Folder creation process. -message CreateFolderMetadata { - // The display name of the folder. - string display_name = 1; - - // The resource name of the folder or organization we are creating the folder - // under. - string parent = 2; -} - -// The request sent to the -// [UpdateFolder][google.cloud.resourcemanager.v3.Folder.UpdateFolder] -// method. -// -// Only the `display_name` field can be changed. All other fields will be -// ignored. Use the -// [MoveFolder][google.cloud.resourcemanager.v3.Folders.MoveFolder] method to -// change the `parent` field. -message UpdateFolderRequest { - // Required. The new definition of the Folder. It must include the `name` - // field, which cannot be changed. - Folder folder = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Fields to be updated. - // Only the `display_name` can be updated. - google.protobuf.FieldMask update_mask = 2 - [(google.api.field_behavior) = REQUIRED]; -} - -// A status object which is used as the `metadata` field for the Operation -// returned by UpdateFolder. -message UpdateFolderMetadata {} - -// The MoveFolder request message. -message MoveFolderRequest { - // Required. The resource name of the Folder to move. - // Must be of the form folders/{folder_id} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Folder" - } - ]; - - // Required. The resource name of the folder or organization which should be - // the folder's new parent. Must be of the form `folders/{folder_id}` or - // `organizations/{org_id}`. - string destination_parent = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { child_type: "*" } - ]; -} - -// Metadata pertaining to the folder move process. -message MoveFolderMetadata { - // The display name of the folder. - string display_name = 1; - - // The resource name of the folder's parent. - string source_parent = 2; - - // The resource name of the folder or organization to move the folder to. - string destination_parent = 3; -} - -// The DeleteFolder request message. -message DeleteFolderRequest { - // Required. The resource name of the folder to be deleted. - // Must be of the form `folders/{folder_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Folder" - } - ]; -} - -// A status object which is used as the `metadata` field for the `Operation` -// returned by `DeleteFolder`. -message DeleteFolderMetadata {} - -// The UndeleteFolder request message. -message UndeleteFolderRequest { - // Required. The resource name of the folder to undelete. - // Must be of the form `folders/{folder_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Folder" - } - ]; -} - -// A status object which is used as the `metadata` field for the `Operation` -// returned by `UndeleteFolder`. -message UndeleteFolderMetadata {} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/organizations.proto b/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/organizations.proto deleted file mode 100644 index 7b0ed95a501..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/organizations.proto +++ /dev/null @@ -1,241 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.resourcemanager.v3; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.ResourceManager.V3"; -option go_package = "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb;resourcemanagerpb"; -option java_multiple_files = true; -option java_outer_classname = "OrganizationsProto"; -option java_package = "com.google.cloud.resourcemanager.v3"; -option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; -option ruby_package = "Google::Cloud::ResourceManager::V3"; - -// Allows users to manage their organization resources. -service Organizations { - option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-platform.read-only"; - - // Fetches an organization resource identified by the specified resource name. - rpc GetOrganization(GetOrganizationRequest) returns (Organization) { - option (google.api.http) = { - get: "/v3/{name=organizations/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Searches organization resources that are visible to the user and satisfy - // the specified filter. This method returns organizations in an unspecified - // order. New organizations do not necessarily appear at the end of the - // results, and may take a small amount of time to appear. - // - // Search will only return organizations on which the user has the permission - // `resourcemanager.organizations.get` - rpc SearchOrganizations(SearchOrganizationsRequest) - returns (SearchOrganizationsResponse) { - option (google.api.http) = { - get: "/v3/organizations:search" - }; - option (google.api.method_signature) = "query"; - } - - // Gets the access control policy for an organization resource. The policy may - // be empty if no such policy or resource exists. The `resource` field should - // be the organization's resource name, for example: "organizations/123". - // - // Authorization requires the IAM permission - // `resourcemanager.organizations.getIamPolicy` on the specified organization. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) - returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v3/{resource=organizations/*}:getIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource"; - } - - // Sets the access control policy on an organization resource. Replaces any - // existing policy. The `resource` field should be the organization's resource - // name, for example: "organizations/123". - // - // Authorization requires the IAM permission - // `resourcemanager.organizations.setIamPolicy` on the specified organization. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) - returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v3/{resource=organizations/*}:setIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource"; - } - - // Returns the permissions that a caller has on the specified organization. - // The `resource` field should be the organization's resource name, - // for example: "organizations/123". - // - // There are no permissions required for making this API call. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) - returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v3/{resource=organizations/*}:testIamPermissions" - body: "*" - }; - option (google.api.method_signature) = "resource,permissions"; - } -} - -// The root node in the resource hierarchy to which a particular entity's -// (a company, for example) resources belong. -message Organization { - option (google.api.resource) = { - type: "cloudresourcemanager.googleapis.com/Organization" - pattern: "organizations/{organization}" - style: DECLARATIVE_FRIENDLY - }; - - // Organization lifecycle states. - enum State { - // Unspecified state. This is only useful for distinguishing unset values. - STATE_UNSPECIFIED = 0; - - // The normal and active state. - ACTIVE = 1; - - // The organization has been marked for deletion by the user. - DELETE_REQUESTED = 2; - } - - // Output only. The resource name of the organization. This is the - // organization's relative path in the API. Its format is - // "organizations/[organization_id]". For example, "organizations/1234". - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A human-readable string that refers to the organization in the - // Google Cloud Console. This string is set by the server and cannot be - // changed. The string will be set to the primary domain (for example, - // "google.com") of the Google Workspace customer that owns the organization. - string display_name = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The owner of this organization. The owner should be specified on - // creation. Once set, it cannot be changed. - // - // The lifetime of the organization and all of its descendants are bound to - // the owner. If the owner is deleted, the organization and all its - // descendants will be deleted. - oneof owner { - // Immutable. The G Suite / Workspace customer id used in the Directory API. - string directory_customer_id = 3 [(google.api.field_behavior) = IMMUTABLE]; - } - - // Output only. The organization's current lifecycle state. - State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Timestamp when the Organization was created. - google.protobuf.Timestamp create_time = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Timestamp when the Organization was last modified. - google.protobuf.Timestamp update_time = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Timestamp when the Organization was requested for deletion. - google.protobuf.Timestamp delete_time = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A checksum computed by the server based on the current value - // of the Organization resource. This may be sent on update and delete - // requests to ensure the client has an up-to-date value before proceeding. - string etag = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// The request sent to the `GetOrganization` method. The `name` field is -// required. `organization_id` is no longer accepted. -message GetOrganizationRequest { - // Required. The resource name of the Organization to fetch. This is the - // organization's relative path in the API, formatted as - // "organizations/[organizationId]". For example, "organizations/1234". - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Organization" - } - ]; -} - -// The request sent to the `SearchOrganizations` method. -message SearchOrganizationsRequest { - // Optional. The maximum number of organizations to return in the response. - // The server can return fewer organizations than requested. If unspecified, - // server picks an appropriate default. - int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A pagination token returned from a previous call to - // `SearchOrganizations` that indicates from where listing should continue. - string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. An optional query string used to filter the Organizations to - // return in the response. Query rules are case-insensitive. - // - // - // ``` - // | Field | Description | - // |------------------|--------------------------------------------| - // | directoryCustomerId, owner.directoryCustomerId | Filters by directory - // customer id. | - // | domain | Filters by domain. | - // ``` - // - // Organizations may be queried by `directoryCustomerId` or by - // `domain`, where the domain is a G Suite domain, for example: - // - // * Query `directorycustomerid:123456789` returns Organization - // resources with `owner.directory_customer_id` equal to `123456789`. - // * Query `domain:google.com` returns Organization resources corresponding - // to the domain `google.com`. - string query = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// The response returned from the `SearchOrganizations` method. -message SearchOrganizationsResponse { - // The list of Organizations that matched the search query, possibly - // paginated. - repeated Organization organizations = 1; - - // A pagination token to be used to retrieve the next page of results. If the - // result is too large to fit within the page size specified in the request, - // this field will be set with a token that can be used to fetch the next page - // of results. If this field is empty, it indicates that this response - // contains the last page of results. - string next_page_token = 2; -} - -// A status object which is used as the `metadata` field for the operation -// returned by DeleteOrganization. -message DeleteOrganizationMetadata {} - -// A status object which is used as the `metadata` field for the Operation -// returned by UndeleteOrganization. -message UndeleteOrganizationMetadata {} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/projects.proto b/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/projects.proto deleted file mode 100644 index 5128147109a..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/projects.proto +++ /dev/null @@ -1,638 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.resourcemanager.v3; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.ResourceManager.V3"; -option go_package = "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb;resourcemanagerpb"; -option java_multiple_files = true; -option java_outer_classname = "ProjectsProto"; -option java_package = "com.google.cloud.resourcemanager.v3"; -option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; -option ruby_package = "Google::Cloud::ResourceManager::V3"; - -// Manages Google Cloud Projects. -service Projects { - option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-platform.read-only"; - - // Retrieves the project identified by the specified `name` (for example, - // `projects/415104041262`). - // - // The caller must have `resourcemanager.projects.get` permission - // for this project. - rpc GetProject(GetProjectRequest) returns (Project) { - option (google.api.http) = { - get: "/v3/{name=projects/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists projects that are direct children of the specified folder or - // organization resource. `list()` provides a strongly consistent view of the - // projects underneath the specified parent resource. `list()` returns - // projects sorted based upon the (ascending) lexical ordering of their - // `display_name`. The caller must have `resourcemanager.projects.list` - // permission on the identified parent. - rpc ListProjects(ListProjectsRequest) returns (ListProjectsResponse) { - option (google.api.http) = { - get: "/v3/projects" - }; - option (google.api.method_signature) = "parent"; - } - - // Search for projects that the caller has both `resourcemanager.projects.get` - // permission on, and also satisfy the specified query. - // - // This method returns projects in an unspecified order. - // - // This method is eventually consistent with project mutations; this means - // that a newly created project may not appear in the results or recent - // updates to an existing project may not be reflected in the results. To - // retrieve the latest state of a project, use the - // [GetProject][google.cloud.resourcemanager.v3.Projects.GetProject] method. - rpc SearchProjects(SearchProjectsRequest) returns (SearchProjectsResponse) { - option (google.api.http) = { - get: "/v3/projects:search" - }; - option (google.api.method_signature) = "query"; - } - - // Request that a new project be created. The result is an `Operation` which - // can be used to track the creation process. This process usually takes a few - // seconds, but can sometimes take much longer. The tracking `Operation` is - // automatically deleted after a few hours, so there is no need to call - // `DeleteOperation`. - rpc CreateProject(CreateProjectRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v3/projects" - body: "project" - }; - option (google.api.method_signature) = "project"; - option (google.longrunning.operation_info) = { - response_type: "Project" - metadata_type: "CreateProjectMetadata" - }; - } - - // Updates the `display_name` and labels of the project identified by the - // specified `name` (for example, `projects/415104041262`). Deleting all - // labels requires an update mask for labels field. - // - // The caller must have `resourcemanager.projects.update` permission for this - // project. - rpc UpdateProject(UpdateProjectRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v3/{project.name=projects/*}" - body: "project" - }; - option (google.api.method_signature) = "project,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "Project" - metadata_type: "UpdateProjectMetadata" - }; - } - - // Move a project to another place in your resource hierarchy, under a new - // resource parent. - // - // Returns an operation which can be used to track the process of the project - // move workflow. - // Upon success, the `Operation.response` field will be populated with the - // moved project. - // - // The caller must have `resourcemanager.projects.move` permission on the - // project, on the project's current and proposed new parent. - // - // If project has no current parent, or it currently does not have an - // associated organization resource, you will also need the - // `resourcemanager.projects.setIamPolicy` permission in the project. - // - // - rpc MoveProject(MoveProjectRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v3/{name=projects/*}:move" - body: "*" - }; - option (google.api.method_signature) = "name, destination_parent"; - option (google.longrunning.operation_info) = { - response_type: "Project" - metadata_type: "MoveProjectMetadata" - }; - } - - // Marks the project identified by the specified - // `name` (for example, `projects/415104041262`) for deletion. - // - // This method will only affect the project if it has a lifecycle state of - // [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE]. - // - // This method changes the Project's lifecycle state from - // [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE] - // to - // [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Project.State.DELETE_REQUESTED]. - // The deletion starts at an unspecified time, - // at which point the Project is no longer accessible. - // - // Until the deletion completes, you can check the lifecycle state - // checked by retrieving the project with [GetProject] - // [google.cloud.resourcemanager.v3.Projects.GetProject], - // and the project remains visible to [ListProjects] - // [google.cloud.resourcemanager.v3.Projects.ListProjects]. - // However, you cannot update the project. - // - // After the deletion completes, the project is not retrievable by - // the [GetProject] - // [google.cloud.resourcemanager.v3.Projects.GetProject], - // [ListProjects] - // [google.cloud.resourcemanager.v3.Projects.ListProjects], and - // [SearchProjects][google.cloud.resourcemanager.v3.Projects.SearchProjects] - // methods. - // - // This method behaves idempotently, such that deleting a `DELETE_REQUESTED` - // project will not cause an error, but also won't do anything. - // - // The caller must have `resourcemanager.projects.delete` permissions for this - // project. - rpc DeleteProject(DeleteProjectRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v3/{name=projects/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Project" - metadata_type: "DeleteProjectMetadata" - }; - } - - // Restores the project identified by the specified - // `name` (for example, `projects/415104041262`). - // You can only use this method for a project that has a lifecycle state of - // [DELETE_REQUESTED] - // [Projects.State.DELETE_REQUESTED]. - // After deletion starts, the project cannot be restored. - // - // The caller must have `resourcemanager.projects.undelete` permission for - // this project. - rpc UndeleteProject(UndeleteProjectRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v3/{name=projects/*}:undelete" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Project" - metadata_type: "UndeleteProjectMetadata" - }; - } - - // Returns the IAM access control policy for the specified project, in the - // format `projects/{ProjectIdOrNumber}` e.g. projects/123. - // Permission is denied if the policy or the resource do not exist. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) - returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v3/{resource=projects/*}:getIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource"; - } - - // Sets the IAM access control policy for the specified project, in the - // format `projects/{ProjectIdOrNumber}` e.g. projects/123. - // - // CAUTION: This method will replace the existing policy, and cannot be used - // to append additional IAM settings. - // - // Note: Removing service accounts from policies or changing their roles can - // render services completely inoperable. It is important to understand how - // the service account is being used before removing or updating its roles. - // - // The following constraints apply when using `setIamPolicy()`: - // - // + Project does not support `allUsers` and `allAuthenticatedUsers` as - // `members` in a `Binding` of a `Policy`. - // - // + The owner role can be granted to a `user`, `serviceAccount`, or a group - // that is part of an organization. For example, - // group@myownpersonaldomain.com could be added as an owner to a project in - // the myownpersonaldomain.com organization, but not the examplepetstore.com - // organization. - // - // + Service accounts can be made owners of a project directly - // without any restrictions. However, to be added as an owner, a user must be - // invited using the Cloud Platform console and must accept the invitation. - // - // + A user cannot be granted the owner role using `setIamPolicy()`. The user - // must be granted the owner role using the Cloud Platform Console and must - // explicitly accept the invitation. - // - // + Invitations to grant the owner role cannot be sent using - // `setIamPolicy()`; - // they must be sent only using the Cloud Platform Console. - // - // + If the project is not part of an organization, there must be at least - // one owner who has accepted the Terms of Service (ToS) agreement in the - // policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner - // from the policy will fail. This restriction also applies to legacy - // projects that no longer have owners who have accepted the ToS. Edits to - // IAM policies will be rejected until the lack of a ToS-accepting owner is - // rectified. If the project is part of an organization, you can remove all - // owners, potentially making the organization inaccessible. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) - returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v3/{resource=projects/*}:setIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource, policy"; - } - - // Returns permissions that a caller has on the specified project, in the - // format `projects/{ProjectIdOrNumber}` e.g. projects/123.. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) - returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v3/{resource=projects/*}:testIamPermissions" - body: "*" - }; - option (google.api.method_signature) = "resource, permissions"; - } -} - -// A project is a high-level Google Cloud entity. It is a -// container for ACLs, APIs, App Engine Apps, VMs, and other -// Google Cloud Platform resources. -message Project { - option (google.api.resource) = { - type: "cloudresourcemanager.googleapis.com/Project" - pattern: "projects/{project}" - style: DECLARATIVE_FRIENDLY - }; - - // Project lifecycle states. - enum State { - // Unspecified state. This is only used/useful for distinguishing - // unset values. - STATE_UNSPECIFIED = 0; - - // The normal and active state. - ACTIVE = 1; - - // The project has been marked for deletion by the user - // (by invoking - // [DeleteProject][google.cloud.resourcemanager.v3.Projects.DeleteProject]) - // or by the system (Google Cloud Platform). - // This can generally be reversed by invoking [UndeleteProject] - // [google.cloud.resourcemanager.v3.Projects.UndeleteProject]. - DELETE_REQUESTED = 2; - } - - // Output only. The unique resource name of the project. It is an int64 - // generated number prefixed by "projects/". - // - // Example: `projects/415104041262` - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. A reference to a parent Resource. eg., `organizations/123` or - // `folders/876`. - string parent = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Immutable. The unique, user-assigned id of the project. - // It must be 6 to 30 lowercase ASCII letters, digits, or hyphens. - // It must start with a letter. - // Trailing hyphens are prohibited. - // - // Example: `tokyo-rain-123` - string project_id = 3 [(google.api.field_behavior) = IMMUTABLE]; - - // Output only. The project lifecycle state. - State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. A user-assigned display name of the project. - // When present it must be between 4 to 30 characters. - // Allowed characters are: lowercase and uppercase letters, numbers, - // hyphen, single-quote, double-quote, space, and exclamation point. - // - // Example: `My Project` - string display_name = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. Creation time. - google.protobuf.Timestamp create_time = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The most recent time this resource was modified. - google.protobuf.Timestamp update_time = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time at which this resource was requested for deletion. - google.protobuf.Timestamp delete_time = 8 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A checksum computed by the server based on the current value - // of the Project resource. This may be sent on update and delete requests to - // ensure the client has an up-to-date value before proceeding. - string etag = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. The labels associated with this project. - // - // Label keys must be between 1 and 63 characters long and must conform - // to the following regular expression: \[a-z\](\[-a-z0-9\]*\[a-z0-9\])?. - // - // Label values must be between 0 and 63 characters long and must conform - // to the regular expression (\[a-z\](\[-a-z0-9\]*\[a-z0-9\])?)?. - // - // No more than 64 labels can be associated with a given resource. - // - // Clients should store labels in a representation such as JSON that does not - // depend on specific characters being disallowed. - // - // Example: `"myBusinessDimension" : "businessValue"` - map labels = 10 [(google.api.field_behavior) = OPTIONAL]; -} - -// The request sent to the -// [GetProject][google.cloud.resourcemanager.v3.Projects.GetProject] -// method. -message GetProjectRequest { - // Required. The name of the project (for example, `projects/415104041262`). - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; -} - -// The request sent to the -// [ListProjects][google.cloud.resourcemanager.v3.Projects.ListProjects] -// method. -message ListProjectsRequest { - // Required. The name of the parent resource whose projects are being listed. - // Only children of this parent resource are listed; descendants are not - // listed. - // - // If the parent is a folder, use the value `folders/{folder_id}`. If the - // parent is an organization, use the value `organizations/{org_id}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { child_type: "*" } - ]; - - // Optional. A pagination token returned from a previous call to - // [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects] that - // indicates from where listing should continue. - string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The maximum number of projects to return in the response. - // The server can return fewer projects than requested. - // If unspecified, server picks an appropriate default. - int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Indicate that projects in the `DELETE_REQUESTED` state should - // also be returned. Normally only `ACTIVE` projects are returned. - bool show_deleted = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// A page of the response received from the -// [ListProjects][google.cloud.resourcemanager.v3.Projects.ListProjects] -// method. -// -// A paginated response where more pages are available has -// `next_page_token` set. This token can be used in a subsequent request to -// retrieve the next request page. -// -// NOTE: A response may contain fewer elements than the request `page_size` and -// still have a `next_page_token`. -message ListProjectsResponse { - // The list of Projects under the parent. This list can be paginated. - repeated Project projects = 1; - - // Pagination token. - // - // If the result set is too large to fit in a single response, this token - // is returned. It encodes the position of the current result cursor. - // Feeding this value into a new list request with the `page_token` parameter - // gives the next page of the results. - // - // When `next_page_token` is not filled in, there is no next page and - // the list returned is the last page in the result set. - // - // Pagination tokens have a limited lifetime. - string next_page_token = 2; -} - -// The request sent to the -// [SearchProjects][google.cloud.resourcemanager.v3.Projects.SearchProjects] -// method. -message SearchProjectsRequest { - // Optional. A query string for searching for projects that the caller has - // `resourcemanager.projects.get` permission to. If multiple fields are - // included in the query, then it will return results that match any of the - // fields. Some eligible fields are: - // - // - **`displayName`, `name`**: Filters by displayName. - // - **`parent`**: Project's parent (for example: `folders/123`, - // `organizations/*`). Prefer `parent` field over `parent.type` and - // `parent.id`. - // - **`parent.type`**: Parent's type: `folder` or `organization`. - // - **`parent.id`**: Parent's id number (for example: `123`). - // - **`id`, `projectId`**: Filters by projectId. - // - **`state`, `lifecycleState`**: Filters by state. - // - **`labels`**: Filters by label name or value. - // - **`labels.` (where `` is the name of a label)**: Filters by label - // name. - // - // Search expressions are case insensitive. - // - // Some examples queries: - // - // - // - **`name:how*`**: The project's name starts with "how". - // - **`name:Howl`**: The project's name is `Howl` or `howl`. - // - **`name:HOWL`**: Equivalent to above. - // - **`NAME:howl`**: Equivalent to above. - // - **`labels.color:*`**: The project has the label `color`. - // - **`labels.color:red`**: The project's label `color` has the value `red`. - // - **`labels.color:red labels.size:big`**: The project's label `color` has - // the value `red` or its label `size` has the value `big`. - // - // If no query is specified, the call will return projects for which the user - // has the `resourcemanager.projects.get` permission. - string query = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A pagination token returned from a previous call to - // [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects] that - // indicates from where listing should continue. - string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The maximum number of projects to return in the response. - // The server can return fewer projects than requested. - // If unspecified, server picks an appropriate default. - int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// A page of the response received from the -// [SearchProjects][google.cloud.resourcemanager.v3.Projects.SearchProjects] -// method. -// -// A paginated response where more pages are available has -// `next_page_token` set. This token can be used in a subsequent request to -// retrieve the next request page. -message SearchProjectsResponse { - // The list of Projects that matched the list filter query. This list can - // be paginated. - repeated Project projects = 1; - - // Pagination token. - // - // If the result set is too large to fit in a single response, this token - // is returned. It encodes the position of the current result cursor. - // Feeding this value into a new list request with the `page_token` parameter - // gives the next page of the results. - // - // When `next_page_token` is not filled in, there is no next page and - // the list returned is the last page in the result set. - // - // Pagination tokens have a limited lifetime. - string next_page_token = 2; -} - -// The request sent to the -// [CreateProject][google.cloud.resourcemanager.v3.Projects.CreateProject] -// method. -message CreateProjectRequest { - // Required. The Project to create. - // - // Project ID is required. If the requested ID is unavailable, the request - // fails. - // - // If the `parent` field is set, the `resourcemanager.projects.create` - // permission is checked on the parent resource. If no parent is set and - // the authorization credentials belong to an Organization, the parent - // will be set to that Organization. - Project project = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// A status object which is used as the `metadata` field for the Operation -// returned by CreateProject. It provides insight for when significant phases of -// Project creation have completed. -message CreateProjectMetadata { - // Creation time of the project creation workflow. - google.protobuf.Timestamp create_time = 1; - - // True if the project can be retrieved using `GetProject`. No other - // operations on the project are guaranteed to work until the project creation - // is complete. - bool gettable = 2; - - // True if the project creation process is complete. - bool ready = 3; -} - -// The request sent to the -// [UpdateProject][google.cloud.resourcemanager.v3.Projects.UpdateProject] -// method. -// -// Only the `display_name` and `labels` fields can be change. Use the -// [MoveProject][google.cloud.resourcemanager.v3.Projects.MoveProject] method to -// change the `parent` field. -message UpdateProjectRequest { - // Required. The new definition of the project. - Project project = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. An update mask to selectively update fields. - google.protobuf.FieldMask update_mask = 2 - [(google.api.field_behavior) = OPTIONAL]; -} - -// A status object which is used as the `metadata` field for the Operation -// returned by UpdateProject. -message UpdateProjectMetadata {} - -// The request sent to -// [MoveProject][google.cloud.resourcemanager.v3.Projects.MoveProject] -// method. -message MoveProjectRequest { - // Required. The name of the project to move. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Required. The new parent to move the Project under. - string destination_parent = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { child_type: "*" } - ]; -} - -// A status object which is used as the `metadata` field for the Operation -// returned by MoveProject. -message MoveProjectMetadata {} - -// [DeleteProject][google.cloud.resourcemanager.v3.Projects.DeleteProject] -// method. -message DeleteProjectRequest { - // Required. The name of the Project (for example, `projects/415104041262`). - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; -} - -// A status object which is used as the `metadata` field for the Operation -// returned by `DeleteProject`. -message DeleteProjectMetadata {} - -// The request sent to the [UndeleteProject] -// [google.cloud.resourcemanager.v3.Projects.UndeleteProject] -// method. -message UndeleteProjectRequest { - // Required. The name of the project (for example, `projects/415104041262`). - // - // Required. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; -} - -// A status object which is used as the `metadata` field for the Operation -// returned by `UndeleteProject`. -message UndeleteProjectMetadata {} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_bindings.proto b/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_bindings.proto deleted file mode 100644 index 6e94b888459..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_bindings.proto +++ /dev/null @@ -1,268 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.resourcemanager.v3; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; - -option csharp_namespace = "Google.Cloud.ResourceManager.V3"; -option go_package = "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb;resourcemanagerpb"; -option java_multiple_files = true; -option java_outer_classname = "TagBindingsProto"; -option java_package = "com.google.cloud.resourcemanager.v3"; -option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; -option ruby_package = "Google::Cloud::ResourceManager::V3"; - -// Allow users to create and manage TagBindings between TagValues and -// different Google Cloud resources throughout the GCP resource hierarchy. -service TagBindings { - option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-platform.read-only"; - - // Lists the TagBindings for the given Google Cloud resource, as specified - // with `parent`. - // - // NOTE: The `parent` field is expected to be a full resource name: - // https://cloud.google.com/apis/design/resource_names#full_resource_name - rpc ListTagBindings(ListTagBindingsRequest) - returns (ListTagBindingsResponse) { - option (google.api.http) = { - get: "/v3/tagBindings" - }; - option (google.api.method_signature) = "parent"; - } - - // Creates a TagBinding between a TagValue and a Google Cloud resource. - rpc CreateTagBinding(CreateTagBindingRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v3/tagBindings" - body: "tag_binding" - }; - option (google.api.method_signature) = "tag_binding"; - option (google.longrunning.operation_info) = { - response_type: "TagBinding" - metadata_type: "CreateTagBindingMetadata" - }; - } - - // Deletes a TagBinding. - rpc DeleteTagBinding(DeleteTagBindingRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v3/{name=tagBindings/**}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "DeleteTagBindingMetadata" - }; - } - - // Return a list of effective tags for the given Google Cloud resource, as - // specified in `parent`. - rpc ListEffectiveTags(ListEffectiveTagsRequest) - returns (ListEffectiveTagsResponse) { - option (google.api.http) = { - get: "/v3/effectiveTags" - }; - option (google.api.method_signature) = "parent"; - } -} - -// A TagBinding represents a connection between a TagValue and a cloud -// resource Once a TagBinding is created, the TagValue is applied to all the -// descendants of the Google Cloud resource. -message TagBinding { - option (google.api.resource) = { - type: "cloudresourcemanager.googleapis.com/TagBinding" - pattern: "tagBindings/{tag_binding}" - }; - - // Output only. The name of the TagBinding. This is a String of the form: - // `tagBindings/{full-resource-name}/{tag-value-name}` (e.g. - // `tagBindings/%2F%2Fcloudresourcemanager.googleapis.com%2Fprojects%2F123/tagValues/456`). - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The full resource name of the resource the TagValue is bound to. - // E.g. `//cloudresourcemanager.googleapis.com/projects/123` - string parent = 2; - - // The TagValue of the TagBinding. - // Must be of the form `tagValues/456`. - string tag_value = 3; - - // The namespaced name for the TagValue of the TagBinding. - // Must be in the format - // `{parent_id}/{tag_key_short_name}/{short_name}`. - // - // For methods that support TagValue namespaced name, only one of - // tag_value_namespaced_name or tag_value may be filled. Requests with both - // fields will be rejected. - string tag_value_namespaced_name = 4; -} - -// Runtime operation information for creating a TagValue. -message CreateTagBindingMetadata {} - -// The request message to create a TagBinding. -message CreateTagBindingRequest { - // Required. The TagBinding to be created. - TagBinding tag_binding = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Set to true to perform the validations necessary for creating the - // resource, but not actually perform the action. - bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// Runtime operation information for deleting a TagBinding. -message DeleteTagBindingMetadata {} - -// The request message to delete a TagBinding. -message DeleteTagBindingRequest { - // Required. The name of the TagBinding. This is a String of the form: - // `tagBindings/{id}` (e.g. - // `tagBindings/%2F%2Fcloudresourcemanager.googleapis.com%2Fprojects%2F123/tagValues/456`). - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/TagBinding" - } - ]; -} - -// The request message to list all TagBindings for a parent. -message ListTagBindingsRequest { - // Required. The full resource name of a resource for which you want to list - // existing TagBindings. E.g. - // "//cloudresourcemanager.googleapis.com/projects/123" - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { child_type: "*" } - ]; - - // Optional. The maximum number of TagBindings to return in the response. The - // server allows a maximum of 300 TagBindings to return. If unspecified, the - // server will use 100 as the default. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A pagination token returned from a previous call to - // `ListTagBindings` that indicates where this listing should continue from. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// The ListTagBindings response. -message ListTagBindingsResponse { - // A possibly paginated list of TagBindings for the specified resource. - repeated TagBinding tag_bindings = 1; - - // Pagination token. - // - // If the result set is too large to fit in a single response, this token - // is returned. It encodes the position of the current result cursor. - // Feeding this value into a new list request with the `page_token` parameter - // gives the next page of the results. - // - // When `next_page_token` is not filled in, there is no next page and - // the list returned is the last page in the result set. - // - // Pagination tokens have a limited lifetime. - string next_page_token = 2; -} - -// The request message to ListEffectiveTags -message ListEffectiveTagsRequest { - // Required. The full resource name of a resource for which you want to list - // the effective tags. E.g. - // "//cloudresourcemanager.googleapis.com/projects/123" - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The maximum number of effective tags to return in the response. - // The server allows a maximum of 300 effective tags to return in a single - // page. If unspecified, the server will use 100 as the default. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A pagination token returned from a previous call to - // `ListEffectiveTags` that indicates from where this listing should continue. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// The response of ListEffectiveTags. -message ListEffectiveTagsResponse { - // A possibly paginated list of effective tags for the specified resource. - repeated EffectiveTag effective_tags = 1; - - // Pagination token. - // - // If the result set is too large to fit in a single response, this token - // is returned. It encodes the position of the current result cursor. - // Feeding this value into a new list request with the `page_token` parameter - // gives the next page of the results. - // - // When `next_page_token` is not filled in, there is no next page and - // the list returned is the last page in the result set. - // - // Pagination tokens have a limited lifetime. - string next_page_token = 2; -} - -// An EffectiveTag represents a tag that applies to a resource during policy -// evaluation. Tags can be either directly bound to a resource or inherited from -// its ancestor. EffectiveTag contains the name and -// namespaced_name of the tag value and tag key, with additional fields of -// `inherited` to indicate the inheritance status of the effective tag. -message EffectiveTag { - // Resource name for TagValue in the format `tagValues/456`. - string tag_value = 1 [(google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/TagValue" - }]; - - // The namespaced name of the TagValue. Can be in the form - // `{organization_id}/{tag_key_short_name}/{tag_value_short_name}` or - // `{project_id}/{tag_key_short_name}/{tag_value_short_name}` or - // `{project_number}/{tag_key_short_name}/{tag_value_short_name}`. - string namespaced_tag_value = 2; - - // The name of the TagKey, in the format `tagKeys/{id}`, such as - // `tagKeys/123`. - string tag_key = 3 [(google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/TagKey" - }]; - - // The namespaced name of the TagKey. Can be in the form - // `{organization_id}/{tag_key_short_name}` or - // `{project_id}/{tag_key_short_name}` or - // `{project_number}/{tag_key_short_name}`. - string namespaced_tag_key = 4; - - // The parent name of the tag key. - // Must be in the format `organizations/{organization_id}` or - // `projects/{project_number}` - string tag_key_parent_name = 6; - - // Indicates the inheritance status of a tag value - // attached to the given resource. If the tag value is inherited from one of - // the resource's ancestors, inherited will be true. If false, then the tag - // value is directly attached to the resource, inherited will be false. - bool inherited = 5; -} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_holds.proto b/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_holds.proto deleted file mode 100644 index 15c446913f2..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_holds.proto +++ /dev/null @@ -1,216 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.resourcemanager.v3; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.ResourceManager.V3"; -option go_package = "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb;resourcemanagerpb"; -option java_multiple_files = true; -option java_outer_classname = "TagHoldsProto"; -option java_package = "com.google.cloud.resourcemanager.v3"; -option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; -option ruby_package = "Google::Cloud::ResourceManager::V3"; - -// Allow users to create and manage TagHolds for TagValues. TagHolds represent -// the use of a Tag Value that is not captured by TagBindings but -// should still block TagValue deletion (such as a reference in a policy -// condition). This service provides isolated failure domains by cloud location -// so that TagHolds can be managed in the same location as their usage. -service TagHolds { - option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-platform.read-only"; - - // Creates a TagHold. Returns ALREADY_EXISTS if a TagHold with the same - // resource and origin exists under the same TagValue. - rpc CreateTagHold(CreateTagHoldRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v3/{parent=tagValues/*}/tagHolds" - body: "tag_hold" - }; - option (google.api.method_signature) = "parent,tag_hold"; - option (google.longrunning.operation_info) = { - response_type: "TagHold" - metadata_type: "CreateTagHoldMetadata" - }; - } - - // Deletes a TagHold. - rpc DeleteTagHold(DeleteTagHoldRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v3/{name=tagValues/*/tagHolds/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "DeleteTagHoldMetadata" - }; - } - - // Lists TagHolds under a TagValue. - rpc ListTagHolds(ListTagHoldsRequest) returns (ListTagHoldsResponse) { - option (google.api.http) = { - get: "/v3/{parent=tagValues/*}/tagHolds" - }; - option (google.api.method_signature) = "parent"; - } -} - -// A TagHold represents the use of a TagValue that is not captured by -// TagBindings. If a TagValue has any TagHolds, deletion will be blocked. -// This resource is intended to be created in the same cloud location as the -// `holder`. -message TagHold { - option (google.api.resource) = { - type: "cloudresourcemanager.googleapis.com/TagHold" - pattern: "tagValues/{tag_value}/tagHolds/{tag_hold}" - }; - - // Output only. The resource name of a TagHold. This is a String of the form: - // `tagValues/{tag-value-id}/tagHolds/{tag-hold-id}` - // (e.g. `tagValues/123/tagHolds/456`). This resource name is generated by - // the server. - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Required. The name of the resource where the TagValue is being used. Must - // be less than 200 characters. E.g. - // `//compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group` - string holder = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. An optional string representing the origin of this request. This - // field should include human-understandable information to distinguish - // origins from each other. Must be less than 200 characters. E.g. - // `migs-35678234` - string origin = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A URL where an end user can learn more about removing this hold. - // E.g. - // `https://cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing` - string help_link = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The time this TagHold was created. - google.protobuf.Timestamp create_time = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// The request message to create a TagHold. -message CreateTagHoldRequest { - // Required. The resource name of the TagHold's parent TagValue. Must be of - // the form: `tagValues/{tag-value-id}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "cloudresourcemanager.googleapis.com/TagHold" - } - ]; - - // Required. The TagHold to be created. - TagHold tag_hold = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Set to true to perform the validations necessary for creating the - // resource, but not actually perform the action. - bool validate_only = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Runtime operation information for creating a TagHold. -// (-- The metadata is currently empty, but may include information in the -// future. --) -message CreateTagHoldMetadata {} - -// The request message to delete a TagHold. -message DeleteTagHoldRequest { - // Required. The resource name of the TagHold to delete. Must be of the form: - // `tagValues/{tag-value-id}/tagHolds/{tag-hold-id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/TagHold" - } - ]; - - // Optional. Set to true to perform the validations necessary for deleting the - // resource, but not actually perform the action. - bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// Runtime operation information for deleting a TagHold. -// (-- The metadata is currently empty, but may include information in the -// future. --) -message DeleteTagHoldMetadata {} - -// The request message for listing the TagHolds under a TagValue. -message ListTagHoldsRequest { - // Required. The resource name of the parent TagValue. Must be of the form: - // `tagValues/{tag-value-id}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "cloudresourcemanager.googleapis.com/TagHold" - } - ]; - - // Optional. The maximum number of TagHolds to return in the response. The - // server allows a maximum of 300 TagHolds to return. If unspecified, the - // server will use 100 as the default. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A pagination token returned from a previous call to - // `ListTagHolds` that indicates where this listing should continue from. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Criteria used to select a subset of TagHolds parented by the - // TagValue to return. This field follows the syntax defined by aip.dev/160; - // the `holder` and `origin` fields are supported for filtering. Currently - // only `AND` syntax is supported. Some example queries are: - // - // * `holder = - // //compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group` - // * `origin = 35678234` - // * `holder = - // //compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group - // AND origin = 35678234` - string filter = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// The ListTagHolds response. -message ListTagHoldsResponse { - // A possibly paginated list of TagHolds. - repeated TagHold tag_holds = 1; - - // Pagination token. - // - // If the result set is too large to fit in a single response, this token - // is returned. It encodes the position of the current result cursor. - // Feeding this value into a new list request with the `page_token` parameter - // gives the next page of the results. - // - // When `next_page_token` is not filled in, there is no next page and - // the list returned is the last page in the result set. - // - // Pagination tokens have a limited lifetime. - string next_page_token = 2; -} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_keys.proto b/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_keys.proto deleted file mode 100644 index 72881b22659..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_keys.proto +++ /dev/null @@ -1,367 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.resourcemanager.v3; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.ResourceManager.V3"; -option go_package = "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb;resourcemanagerpb"; -option java_multiple_files = true; -option java_outer_classname = "TagKeysProto"; -option java_package = "com.google.cloud.resourcemanager.v3"; -option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; -option ruby_package = "Google::Cloud::ResourceManager::V3"; - -// Allow users to create and manage tag keys. -service TagKeys { - option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-platform.read-only"; - - // Lists all TagKeys for a parent resource. - rpc ListTagKeys(ListTagKeysRequest) returns (ListTagKeysResponse) { - option (google.api.http) = { - get: "/v3/tagKeys" - }; - option (google.api.method_signature) = "parent"; - } - - // Retrieves a TagKey. This method will return `PERMISSION_DENIED` if the - // key does not exist or the user does not have permission to view it. - rpc GetTagKey(GetTagKeyRequest) returns (TagKey) { - option (google.api.http) = { - get: "/v3/{name=tagKeys/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Retrieves a TagKey by its namespaced name. - // This method will return `PERMISSION_DENIED` if the key does not exist - // or the user does not have permission to view it. - rpc GetNamespacedTagKey(GetNamespacedTagKeyRequest) returns (TagKey) { - option (google.api.http) = { - get: "/v3/tagKeys/namespaced" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a new TagKey. If another request with the same parameters is - // sent while the original request is in process, the second request - // will receive an error. A maximum of 1000 TagKeys can exist under a parent - // at any given time. - rpc CreateTagKey(CreateTagKeyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v3/tagKeys" - body: "tag_key" - }; - option (google.api.method_signature) = "tag_key"; - option (google.longrunning.operation_info) = { - response_type: "TagKey" - metadata_type: "CreateTagKeyMetadata" - }; - } - - // Updates the attributes of the TagKey resource. - rpc UpdateTagKey(UpdateTagKeyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v3/{tag_key.name=tagKeys/*}" - body: "tag_key" - }; - option (google.api.method_signature) = "tag_key,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "TagKey" - metadata_type: "UpdateTagKeyMetadata" - }; - } - - // Deletes a TagKey. The TagKey cannot be deleted if it has any child - // TagValues. - rpc DeleteTagKey(DeleteTagKeyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v3/{name=tagKeys/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "TagKey" - metadata_type: "DeleteTagKeyMetadata" - }; - } - - // Gets the access control policy for a TagKey. The returned policy may be - // empty if no such policy or resource exists. The `resource` field should - // be the TagKey's resource name. For example, "tagKeys/1234". - // The caller must have - // `cloudresourcemanager.googleapis.com/tagKeys.getIamPolicy` permission on - // the specified TagKey. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) - returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v3/{resource=tagKeys/*}:getIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource"; - } - - // Sets the access control policy on a TagKey, replacing any existing - // policy. The `resource` field should be the TagKey's resource name. - // For example, "tagKeys/1234". - // The caller must have `resourcemanager.tagKeys.setIamPolicy` permission - // on the identified tagValue. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) - returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v3/{resource=tagKeys/*}:setIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource,policy"; - } - - // Returns permissions that a caller has on the specified TagKey. - // The `resource` field should be the TagKey's resource name. - // For example, "tagKeys/1234". - // - // There are no permissions required for making this API call. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) - returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v3/{resource=tagKeys/*}:testIamPermissions" - body: "*" - }; - option (google.api.method_signature) = "resource,permissions"; - } -} - -// A TagKey, used to group a set of TagValues. -message TagKey { - option (google.api.resource) = { - type: "cloudresourcemanager.googleapis.com/TagKey" - pattern: "tagKeys/{tag_key}" - style: DECLARATIVE_FRIENDLY - }; - - // Immutable. The resource name for a TagKey. Must be in the format - // `tagKeys/{tag_key_id}`, where `tag_key_id` is the generated numeric id for - // the TagKey. - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Immutable. The resource name of the TagKey's parent. A TagKey can be - // parented by an Organization or a Project. For a TagKey parented by an - // Organization, its parent must be in the form `organizations/{org_id}`. For - // a TagKey parented by a Project, its parent can be in the form - // `projects/{project_id}` or `projects/{project_number}`. - string parent = 2 [(google.api.field_behavior) = IMMUTABLE]; - - // Required. Immutable. The user friendly name for a TagKey. The short name - // should be unique for TagKeys within the same tag namespace. - // - // The short name must be 1-63 characters, beginning and ending with - // an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), - // dots (.), and alphanumerics between. - string short_name = 3 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Output only. Immutable. Namespaced name of the TagKey. - string namespaced_name = 4 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Optional. User-assigned description of the TagKey. Must not exceed 256 - // characters. - // - // Read-write. - string description = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. Creation time. - google.protobuf.Timestamp create_time = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Update time. - google.protobuf.Timestamp update_time = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Entity tag which users can pass to prevent race conditions. This - // field is always set in server responses. See UpdateTagKeyRequest for - // details. - string etag = 8 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A purpose denotes that this Tag is intended for use in policies - // of a specific policy engine, and will involve that policy engine in - // management operations involving this Tag. A purpose does not grant a - // policy engine exclusive rights to the Tag, and it may be referenced by - // other policy engines. - // - // A purpose cannot be changed once set. - Purpose purpose = 11 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Purpose data corresponds to the policy system that the tag is - // intended for. See documentation for `Purpose` for formatting of this field. - // - // Purpose data cannot be changed once set. - map purpose_data = 12 - [(google.api.field_behavior) = OPTIONAL]; -} - -// The request message for listing all TagKeys under a parent resource. -message ListTagKeysRequest { - // Required. The resource name of the TagKey's parent. - // Must be of the form `organizations/{org_id}` or `projects/{project_id}` or - // `projects/{project_number}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { child_type: "*" } - ]; - - // Optional. The maximum number of TagKeys to return in the response. The - // server allows a maximum of 300 TagKeys to return. If unspecified, the - // server will use 100 as the default. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A pagination token returned from a previous call to `ListTagKey` - // that indicates where this listing should continue from. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// The ListTagKeys response message. -message ListTagKeysResponse { - // List of TagKeys that live under the specified parent in the request. - repeated TagKey tag_keys = 1; - - // A pagination token returned from a previous call to `ListTagKeys` - // that indicates from where listing should continue. - string next_page_token = 2; -} - -// The request message for getting a TagKey. -message GetTagKeyRequest { - // Required. A resource name in the format `tagKeys/{id}`, such as - // `tagKeys/123`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/TagKey" - } - ]; -} - -// The request message for getting a TagKey by its namespaced name. -message GetNamespacedTagKeyRequest { - // Required. A namespaced tag key name in the format - // `{parentId}/{tagKeyShort}`, such as `42/foo` for a key with short name - // "foo" under the organization with ID 42 or `r2-d2/bar` for a key with short - // name "bar" under the project `r2-d2`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/TagKey" - } - ]; -} - -// The request message for creating a TagKey. -message CreateTagKeyRequest { - // Required. The TagKey to be created. Only fields `short_name`, - // `description`, and `parent` are considered during the creation request. - TagKey tag_key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Set to true to perform validations necessary for creating the - // resource, but not actually perform the action. - bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// Runtime operation information for creating a TagKey. -message CreateTagKeyMetadata {} - -// The request message for updating a TagKey. -message UpdateTagKeyRequest { - // Required. The new definition of the TagKey. Only the `description` and - // `etag` fields can be updated by this request. If the `etag` field is not - // empty, it must match the `etag` field of the existing tag key. Otherwise, - // `ABORTED` will be returned. - TagKey tag_key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Fields to be updated. The mask may only contain `description` or - // `etag`. If omitted entirely, both `description` and `etag` are assumed to - // be significant. - google.protobuf.FieldMask update_mask = 2; - - // Set as true to perform validations necessary for updating the resource, but - // not actually perform the action. - bool validate_only = 3; -} - -// Runtime operation information for updating a TagKey. -message UpdateTagKeyMetadata {} - -// The request message for deleting a TagKey. -message DeleteTagKeyRequest { - // Required. The resource name of a TagKey to be deleted in the format - // `tagKeys/123`. The TagKey cannot be a parent of any existing TagValues or - // it will not be deleted successfully. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/TagKey" - } - ]; - - // Optional. Set as true to perform validations necessary for deletion, but - // not actually perform the action. - bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The etag known to the client for the expected state of the - // TagKey. This is to be used for optimistic concurrency. - string etag = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Runtime operation information for deleting a TagKey. -message DeleteTagKeyMetadata {} - -// A purpose for each policy engine requiring such an integration. A single -// policy engine may have multiple purposes defined, however a TagKey may only -// specify a single purpose. -enum Purpose { - // Unspecified purpose. - PURPOSE_UNSPECIFIED = 0; - - // Purpose for Compute Engine firewalls. - // A corresponding `purpose_data` should be set for the network the tag is - // intended for. The key should be `network` and the value should be in - // either of these two formats: - // - // - - // `https://www.googleapis.com/compute/{compute_version}/projects/{project_id}/global/networks/{network_id}` - // - `{project_id}/{network_name}` - // - // Examples: - // - // - - // `https://www.googleapis.com/compute/staging_v1/projects/fail-closed-load-testing/global/networks/6992953698831725600` - // - `fail-closed-load-testing/load-testing-network` - GCE_FIREWALL = 1; -} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_values.proto b/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_values.proto deleted file mode 100644 index 9a5bd7f1ffb..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/protos/google/cloud/resourcemanager/v3/tag_values.proto +++ /dev/null @@ -1,331 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.resourcemanager.v3; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.ResourceManager.V3"; -option go_package = "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb;resourcemanagerpb"; -option java_multiple_files = true; -option java_outer_classname = "TagValuesProto"; -option java_package = "com.google.cloud.resourcemanager.v3"; -option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; -option ruby_package = "Google::Cloud::ResourceManager::V3"; - -// Allow users to create and manage tag values. -service TagValues { - option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-platform.read-only"; - - // Lists all TagValues for a specific TagKey. - rpc ListTagValues(ListTagValuesRequest) returns (ListTagValuesResponse) { - option (google.api.http) = { - get: "/v3/tagValues" - }; - option (google.api.method_signature) = "parent"; - } - - // Retrieves a TagValue. This method will return `PERMISSION_DENIED` if the - // value does not exist or the user does not have permission to view it. - rpc GetTagValue(GetTagValueRequest) returns (TagValue) { - option (google.api.http) = { - get: "/v3/{name=tagValues/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Retrieves a TagValue by its namespaced name. - // This method will return `PERMISSION_DENIED` if the value does not exist - // or the user does not have permission to view it. - rpc GetNamespacedTagValue(GetNamespacedTagValueRequest) returns (TagValue) { - option (google.api.http) = { - get: "/v3/tagValues/namespaced" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a TagValue as a child of the specified TagKey. If a another - // request with the same parameters is sent while the original request is in - // process the second request will receive an error. A maximum of 1000 - // TagValues can exist under a TagKey at any given time. - rpc CreateTagValue(CreateTagValueRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v3/tagValues" - body: "tag_value" - }; - option (google.api.method_signature) = "tag_value"; - option (google.longrunning.operation_info) = { - response_type: "TagValue" - metadata_type: "CreateTagValueMetadata" - }; - } - - // Updates the attributes of the TagValue resource. - rpc UpdateTagValue(UpdateTagValueRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v3/{tag_value.name=tagValues/*}" - body: "tag_value" - }; - option (google.api.method_signature) = "tag_value,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "TagValue" - metadata_type: "UpdateTagValueMetadata" - }; - } - - // Deletes a TagValue. The TagValue cannot have any bindings when it is - // deleted. - rpc DeleteTagValue(DeleteTagValueRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v3/{name=tagValues/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "TagValue" - metadata_type: "DeleteTagValueMetadata" - }; - } - - // Gets the access control policy for a TagValue. The returned policy may be - // empty if no such policy or resource exists. The `resource` field should - // be the TagValue's resource name. For example: `tagValues/1234`. - // The caller must have the - // `cloudresourcemanager.googleapis.com/tagValues.getIamPolicy` permission on - // the identified TagValue to get the access control policy. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) - returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v3/{resource=tagValues/*}:getIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource"; - } - - // Sets the access control policy on a TagValue, replacing any existing - // policy. The `resource` field should be the TagValue's resource name. - // For example: `tagValues/1234`. - // The caller must have `resourcemanager.tagValues.setIamPolicy` permission - // on the identified tagValue. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) - returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v3/{resource=tagValues/*}:setIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource,policy"; - } - - // Returns permissions that a caller has on the specified TagValue. - // The `resource` field should be the TagValue's resource name. For example: - // `tagValues/1234`. - // - // There are no permissions required for making this API call. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) - returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v3/{resource=tagValues/*}:testIamPermissions" - body: "*" - }; - option (google.api.method_signature) = "resource,permissions"; - } -} - -// A TagValue is a child of a particular TagKey. This is used to group -// cloud resources for the purpose of controlling them using policies. -message TagValue { - option (google.api.resource) = { - type: "cloudresourcemanager.googleapis.com/TagValue" - pattern: "tagValues/{tag_value}" - style: DECLARATIVE_FRIENDLY - }; - - // Immutable. Resource name for TagValue in the format `tagValues/456`. - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Immutable. The resource name of the new TagValue's parent TagKey. - // Must be of the form `tagKeys/{tag_key_id}`. - string parent = 2 [(google.api.field_behavior) = IMMUTABLE]; - - // Required. Immutable. User-assigned short name for TagValue. The short name - // should be unique for TagValues within the same parent TagKey. - // - // The short name must be 63 characters or less, beginning and ending with - // an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), - // dots (.), and alphanumerics between. - string short_name = 3 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Output only. The namespaced name of the TagValue. Can be in the form - // `{organization_id}/{tag_key_short_name}/{tag_value_short_name}` or - // `{project_id}/{tag_key_short_name}/{tag_value_short_name}` or - // `{project_number}/{tag_key_short_name}/{tag_value_short_name}`. - string namespaced_name = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. User-assigned description of the TagValue. - // Must not exceed 256 characters. - // - // Read-write. - string description = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. Creation time. - google.protobuf.Timestamp create_time = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Update time. - google.protobuf.Timestamp update_time = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Entity tag which users can pass to prevent race conditions. This - // field is always set in server responses. See UpdateTagValueRequest for - // details. - string etag = 8 [(google.api.field_behavior) = OPTIONAL]; -} - -// The request message for listing TagValues for the specified TagKey. -// Resource name for TagKey, parent of the TagValues to be listed, -// in the format `tagKeys/123`. -message ListTagValuesRequest { - // Required. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { child_type: "*" } - ]; - - // Optional. The maximum number of TagValues to return in the response. The - // server allows a maximum of 300 TagValues to return. If unspecified, the - // server will use 100 as the default. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A pagination token returned from a previous call to - // `ListTagValues` that indicates where this listing should continue from. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// The ListTagValues response. -message ListTagValuesResponse { - // A possibly paginated list of TagValues that are direct descendants of - // the specified parent TagKey. - repeated TagValue tag_values = 1; - - // A pagination token returned from a previous call to `ListTagValues` - // that indicates from where listing should continue. This is currently not - // used, but the server may at any point start supplying a valid token. - string next_page_token = 2; -} - -// The request message for getting a TagValue. -message GetTagValueRequest { - // Required. Resource name for TagValue to be fetched in the format - // `tagValues/456`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/TagValue" - } - ]; -} - -// The request message for getting a TagValue by its namespaced name. -message GetNamespacedTagValueRequest { - // Required. A namespaced tag value name in the following format: - // - // `{parentId}/{tagKeyShort}/{tagValueShort}` - // - // Examples: - // - `42/foo/abc` for a value with short name "abc" under the key with short - // name "foo" under the organization with ID 42 - // - `r2-d2/bar/xyz` for a value with short name "xyz" under the key with - // short name "bar" under the project with ID "r2-d2" - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/TagValue" - } - ]; -} - -// The request message for creating a TagValue. -message CreateTagValueRequest { - // Required. The TagValue to be created. Only fields `short_name`, - // `description`, and `parent` are considered during the creation request. - TagValue tag_value = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Set as true to perform the validations necessary for creating the - // resource, but not actually perform the action. - bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// Runtime operation information for creating a TagValue. -message CreateTagValueMetadata {} - -// The request message for updating a TagValue. -message UpdateTagValueRequest { - // Required. The new definition of the TagValue. Only fields `description` and - // `etag` fields can be updated by this request. If the `etag` field is - // nonempty, it must match the `etag` field of the existing ControlGroup. - // Otherwise, `ABORTED` will be returned. - TagValue tag_value = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Fields to be updated. - google.protobuf.FieldMask update_mask = 2 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. True to perform validations necessary for updating the resource, - // but not actually perform the action. - bool validate_only = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Runtime operation information for updating a TagValue. -message UpdateTagValueMetadata {} - -// The request message for deleting a TagValue. -message DeleteTagValueRequest { - // Required. Resource name for TagValue to be deleted in the format - // tagValues/456. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/TagValue" - } - ]; - - // Optional. Set as true to perform the validations necessary for deletion, - // but not actually perform the action. - bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The etag known to the client for the expected state of the - // TagValue. This is to be used for optimistic concurrency. - string etag = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Runtime operation information for deleting a TagValue. -message DeleteTagValueMetadata {} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.create_folder.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.create_folder.js deleted file mode 100644 index 8a5c3872277..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.create_folder.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(folder) { - // [START cloudresourcemanager_v3_generated_Folders_CreateFolder_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The folder being created, only the display name and parent will - * be consulted. All other fields will be ignored. - */ - // const folder = {} - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callCreateFolder() { - // Construct request - const request = { - folder, - }; - - // Run request - const [operation] = await resourcemanagerClient.createFolder(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateFolder(); - // [END cloudresourcemanager_v3_generated_Folders_CreateFolder_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.delete_folder.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.delete_folder.js deleted file mode 100644 index fa200d20783..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.delete_folder.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 cloudresourcemanager_v3_generated_Folders_DeleteFolder_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 folder to be deleted. - * Must be of the form `folders/{folder_id}`. - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callDeleteFolder() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await resourcemanagerClient.deleteFolder(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteFolder(); - // [END cloudresourcemanager_v3_generated_Folders_DeleteFolder_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.get_folder.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.get_folder.js deleted file mode 100644 index 1ae3c1fd09e..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.get_folder.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 cloudresourcemanager_v3_generated_Folders_GetFolder_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 folder to retrieve. - * Must be of the form `folders/{folder_id}`. - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callGetFolder() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await resourcemanagerClient.getFolder(request); - console.log(response); - } - - callGetFolder(); - // [END cloudresourcemanager_v3_generated_Folders_GetFolder_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.get_iam_policy.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.get_iam_policy.js deleted file mode 100644 index 325e23e3e20..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.get_iam_policy.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(resource) { - // [START cloudresourcemanager_v3_generated_Folders_GetIamPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - */ - // const options = {} - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callGetIamPolicy() { - // Construct request - const request = { - resource, - }; - - // Run request - const response = await resourcemanagerClient.getIamPolicy(request); - console.log(response); - } - - callGetIamPolicy(); - // [END cloudresourcemanager_v3_generated_Folders_GetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.list_folders.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.list_folders.js deleted file mode 100644 index ace19a6ceb7..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.list_folders.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 cloudresourcemanager_v3_generated_Folders_ListFolders_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 parent resource whose folders are being listed. - * Only children of this parent resource are listed; descendants are not - * listed. - * If the parent is a folder, use the value `folders/{folder_id}`. If the - * parent is an organization, use the value `organizations/{org_id}`. - * Access to this method is controlled by checking the - * `resourcemanager.folders.list` permission on the `parent`. - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of folders to return in the response. The - * server can return fewer folders than requested. If unspecified, server - * picks an appropriate default. - */ - // const pageSize = 1234 - /** - * Optional. A pagination token returned from a previous call to `ListFolders` - * that indicates where this listing should continue from. - */ - // const pageToken = 'abc123' - /** - * Optional. Controls whether folders in the - * DELETE_REQUESTED google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED - * state should be returned. Defaults to false. - */ - // const showDeleted = true - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callListFolders() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await resourcemanagerClient.listFoldersAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListFolders(); - // [END cloudresourcemanager_v3_generated_Folders_ListFolders_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.move_folder.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.move_folder.js deleted file mode 100644 index b279ea6393a..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.move_folder.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(name, destinationParent) { - // [START cloudresourcemanager_v3_generated_Folders_MoveFolder_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 Folder to move. - * Must be of the form folders/{folder_id} - */ - // const name = 'abc123' - /** - * Required. The resource name of the folder or organization which should be - * the folder's new parent. Must be of the form `folders/{folder_id}` or - * `organizations/{org_id}`. - */ - // const destinationParent = 'abc123' - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callMoveFolder() { - // Construct request - const request = { - name, - destinationParent, - }; - - // Run request - const [operation] = await resourcemanagerClient.moveFolder(request); - const [response] = await operation.promise(); - console.log(response); - } - - callMoveFolder(); - // [END cloudresourcemanager_v3_generated_Folders_MoveFolder_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.search_folders.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.search_folders.js deleted file mode 100644 index 4cc9c93c7f3..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.search_folders.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() { - // [START cloudresourcemanager_v3_generated_Folders_SearchFolders_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Optional. The maximum number of folders to return in the response. The - * server can return fewer folders than requested. If unspecified, server - * picks an appropriate default. - */ - // const pageSize = 1234 - /** - * Optional. A pagination token returned from a previous call to - * `SearchFolders` that indicates from where search should continue. - */ - // const pageToken = 'abc123' - /** - * Optional. Search criteria used to select the folders to return. - * If no search criteria is specified then all accessible folders will be - * returned. - * Query expressions can be used to restrict results based upon displayName, - * state and parent, where the operators `=` (`:`) `NOT`, `AND` and `OR` - * can be used along with the suffix wildcard symbol `*`. - * The `displayName` field in a query expression should use escaped quotes - * for values that include whitespace to prevent unexpected behavior. - * ``` - * | Field | Description | - * |-------------------------|----------------------------------------| - * | displayName | Filters by displayName. | - * | parent | Filters by parent (for example: folders/123). | - * | state, lifecycleState | Filters by state. | - * ``` - * Some example queries are: - * * Query `displayName=Test*` returns Folder resources whose display name - * starts with "Test". - * * Query `state=ACTIVE` returns Folder resources with - * `state` set to `ACTIVE`. - * * Query `parent=folders/123` returns Folder resources that have - * `folders/123` as a parent resource. - * * Query `parent=folders/123 AND state=ACTIVE` returns active - * Folder resources that have `folders/123` as a parent resource. - * * Query `displayName=\\"Test String\\"` returns Folder resources with - * display names that include both "Test" and "String". - */ - // const query = 'abc123' - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callSearchFolders() { - // Construct request - const request = { - }; - - // Run request - const iterable = await resourcemanagerClient.searchFoldersAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callSearchFolders(); - // [END cloudresourcemanager_v3_generated_Folders_SearchFolders_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.set_iam_policy.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.set_iam_policy.js deleted file mode 100644 index 7f681424e22..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.set_iam_policy.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(resource, policy) { - // [START cloudresourcemanager_v3_generated_Folders_SetIamPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - */ - // const policy = {} - /** - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * `paths: "bindings, etag"` - */ - // const updateMask = {} - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callSetIamPolicy() { - // Construct request - const request = { - resource, - policy, - }; - - // Run request - const response = await resourcemanagerClient.setIamPolicy(request); - console.log(response); - } - - callSetIamPolicy(); - // [END cloudresourcemanager_v3_generated_Folders_SetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.test_iam_permissions.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.test_iam_permissions.js deleted file mode 100644 index 2a5cedde3a1..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.test_iam_permissions.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(resource, permissions) { - // [START cloudresourcemanager_v3_generated_Folders_TestIamPermissions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). - */ - // const permissions = ['abc','def'] - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callTestIamPermissions() { - // Construct request - const request = { - resource, - permissions, - }; - - // Run request - const response = await resourcemanagerClient.testIamPermissions(request); - console.log(response); - } - - callTestIamPermissions(); - // [END cloudresourcemanager_v3_generated_Folders_TestIamPermissions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.undelete_folder.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.undelete_folder.js deleted file mode 100644 index 0173813c8be..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.undelete_folder.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 cloudresourcemanager_v3_generated_Folders_UndeleteFolder_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 folder to undelete. - * Must be of the form `folders/{folder_id}`. - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callUndeleteFolder() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await resourcemanagerClient.undeleteFolder(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUndeleteFolder(); - // [END cloudresourcemanager_v3_generated_Folders_UndeleteFolder_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.update_folder.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.update_folder.js deleted file mode 100644 index 40d265b5847..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/folders.update_folder.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(folder, updateMask) { - // [START cloudresourcemanager_v3_generated_Folders_UpdateFolder_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The new definition of the Folder. It must include the `name` - * field, which cannot be changed. - */ - // const folder = {} - /** - * Required. Fields to be updated. - * Only the `display_name` can be updated. - */ - // const updateMask = {} - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callUpdateFolder() { - // Construct request - const request = { - folder, - updateMask, - }; - - // Run request - const [operation] = await resourcemanagerClient.updateFolder(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateFolder(); - // [END cloudresourcemanager_v3_generated_Folders_UpdateFolder_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.get_iam_policy.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.get_iam_policy.js deleted file mode 100644 index ed4e78879f2..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.get_iam_policy.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(resource) { - // [START cloudresourcemanager_v3_generated_Organizations_GetIamPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - */ - // const options = {} - - // Imports the Resourcemanager library - const {OrganizationsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new OrganizationsClient(); - - async function callGetIamPolicy() { - // Construct request - const request = { - resource, - }; - - // Run request - const response = await resourcemanagerClient.getIamPolicy(request); - console.log(response); - } - - callGetIamPolicy(); - // [END cloudresourcemanager_v3_generated_Organizations_GetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.get_organization.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.get_organization.js deleted file mode 100644 index 674d25d155a..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.get_organization.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 cloudresourcemanager_v3_generated_Organizations_GetOrganization_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 Organization to fetch. This is the - * organization's relative path in the API, formatted as - * "organizations/[organizationId]". For example, "organizations/1234". - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {OrganizationsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new OrganizationsClient(); - - async function callGetOrganization() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await resourcemanagerClient.getOrganization(request); - console.log(response); - } - - callGetOrganization(); - // [END cloudresourcemanager_v3_generated_Organizations_GetOrganization_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.search_organizations.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.search_organizations.js deleted file mode 100644 index 25a484a1d21..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.search_organizations.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() { - // [START cloudresourcemanager_v3_generated_Organizations_SearchOrganizations_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Optional. The maximum number of organizations to return in the response. - * The server can return fewer organizations than requested. If unspecified, - * server picks an appropriate default. - */ - // const pageSize = 1234 - /** - * Optional. A pagination token returned from a previous call to - * `SearchOrganizations` that indicates from where listing should continue. - */ - // const pageToken = 'abc123' - /** - * Optional. An optional query string used to filter the Organizations to - * return in the response. Query rules are case-insensitive. - * ``` - * | Field | Description | - * |------------------|--------------------------------------------| - * | directoryCustomerId, owner.directoryCustomerId | Filters by directory - * customer id. | - * | domain | Filters by domain. | - * ``` - * Organizations may be queried by `directoryCustomerId` or by - * `domain`, where the domain is a G Suite domain, for example: - * * Query `directorycustomerid:123456789` returns Organization - * resources with `owner.directory_customer_id` equal to `123456789`. - * * Query `domain:google.com` returns Organization resources corresponding - * to the domain `google.com`. - */ - // const query = 'abc123' - - // Imports the Resourcemanager library - const {OrganizationsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new OrganizationsClient(); - - async function callSearchOrganizations() { - // Construct request - const request = { - }; - - // Run request - const iterable = await resourcemanagerClient.searchOrganizationsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callSearchOrganizations(); - // [END cloudresourcemanager_v3_generated_Organizations_SearchOrganizations_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.set_iam_policy.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.set_iam_policy.js deleted file mode 100644 index 2ff146e29d2..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.set_iam_policy.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(resource, policy) { - // [START cloudresourcemanager_v3_generated_Organizations_SetIamPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - */ - // const policy = {} - /** - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * `paths: "bindings, etag"` - */ - // const updateMask = {} - - // Imports the Resourcemanager library - const {OrganizationsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new OrganizationsClient(); - - async function callSetIamPolicy() { - // Construct request - const request = { - resource, - policy, - }; - - // Run request - const response = await resourcemanagerClient.setIamPolicy(request); - console.log(response); - } - - callSetIamPolicy(); - // [END cloudresourcemanager_v3_generated_Organizations_SetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.test_iam_permissions.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.test_iam_permissions.js deleted file mode 100644 index b2745aba020..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/organizations.test_iam_permissions.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(resource, permissions) { - // [START cloudresourcemanager_v3_generated_Organizations_TestIamPermissions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). - */ - // const permissions = ['abc','def'] - - // Imports the Resourcemanager library - const {OrganizationsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new OrganizationsClient(); - - async function callTestIamPermissions() { - // Construct request - const request = { - resource, - permissions, - }; - - // Run request - const response = await resourcemanagerClient.testIamPermissions(request); - console.log(response); - } - - callTestIamPermissions(); - // [END cloudresourcemanager_v3_generated_Organizations_TestIamPermissions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.create_project.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.create_project.js deleted file mode 100644 index 73a6f5a6e67..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.create_project.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(project) { - // [START cloudresourcemanager_v3_generated_Projects_CreateProject_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Project to create. - * Project ID is required. If the requested ID is unavailable, the request - * fails. - * If the `parent` field is set, the `resourcemanager.projects.create` - * permission is checked on the parent resource. If no parent is set and - * the authorization credentials belong to an Organization, the parent - * will be set to that Organization. - */ - // const project = 'my-project' - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callCreateProject() { - // Construct request - const request = { - project, - }; - - // Run request - const [operation] = await resourcemanagerClient.createProject(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateProject(); - // [END cloudresourcemanager_v3_generated_Projects_CreateProject_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.delete_project.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.delete_project.js deleted file mode 100644 index 7f8e2b71edd..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.delete_project.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 cloudresourcemanager_v3_generated_Projects_DeleteProject_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 Project (for example, `projects/415104041262`). - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callDeleteProject() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await resourcemanagerClient.deleteProject(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteProject(); - // [END cloudresourcemanager_v3_generated_Projects_DeleteProject_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.get_iam_policy.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.get_iam_policy.js deleted file mode 100644 index 7caeec14912..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.get_iam_policy.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(resource) { - // [START cloudresourcemanager_v3_generated_Projects_GetIamPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - */ - // const options = {} - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callGetIamPolicy() { - // Construct request - const request = { - resource, - }; - - // Run request - const response = await resourcemanagerClient.getIamPolicy(request); - console.log(response); - } - - callGetIamPolicy(); - // [END cloudresourcemanager_v3_generated_Projects_GetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.get_project.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.get_project.js deleted file mode 100644 index 7e7a5b05c38..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.get_project.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(name) { - // [START cloudresourcemanager_v3_generated_Projects_GetProject_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 project (for example, `projects/415104041262`). - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callGetProject() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await resourcemanagerClient.getProject(request); - console.log(response); - } - - callGetProject(); - // [END cloudresourcemanager_v3_generated_Projects_GetProject_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.list_projects.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.list_projects.js deleted file mode 100644 index 826637d500b..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.list_projects.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(parent) { - // [START cloudresourcemanager_v3_generated_Projects_ListProjects_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 parent resource whose projects are being listed. - * Only children of this parent resource are listed; descendants are not - * listed. - * If the parent is a folder, use the value `folders/{folder_id}`. If the - * parent is an organization, use the value `organizations/{org_id}`. - */ - // const parent = 'abc123' - /** - * Optional. A pagination token returned from a previous call to - * ListProjects google.cloud.resourcemanager.v3.Projects.ListProjects that - * indicates from where listing should continue. - */ - // const pageToken = 'abc123' - /** - * Optional. The maximum number of projects to return in the response. - * The server can return fewer projects than requested. - * If unspecified, server picks an appropriate default. - */ - // const pageSize = 1234 - /** - * Optional. Indicate that projects in the `DELETE_REQUESTED` state should - * also be returned. Normally only `ACTIVE` projects are returned. - */ - // const showDeleted = true - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callListProjects() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await resourcemanagerClient.listProjectsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProjects(); - // [END cloudresourcemanager_v3_generated_Projects_ListProjects_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.move_project.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.move_project.js deleted file mode 100644 index ce98dbc473e..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.move_project.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(name, destinationParent) { - // [START cloudresourcemanager_v3_generated_Projects_MoveProject_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 project to move. - */ - // const name = 'abc123' - /** - * Required. The new parent to move the Project under. - */ - // const destinationParent = 'abc123' - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callMoveProject() { - // Construct request - const request = { - name, - destinationParent, - }; - - // Run request - const [operation] = await resourcemanagerClient.moveProject(request); - const [response] = await operation.promise(); - console.log(response); - } - - callMoveProject(); - // [END cloudresourcemanager_v3_generated_Projects_MoveProject_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.search_projects.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.search_projects.js deleted file mode 100644 index e6faf50a836..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.search_projects.js +++ /dev/null @@ -1,100 +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 cloudresourcemanager_v3_generated_Projects_SearchProjects_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Optional. A query string for searching for projects that the caller has - * `resourcemanager.projects.get` permission to. If multiple fields are - * included in the query, then it will return results that match any of the - * fields. Some eligible fields are: - * - **`displayName`, `name`**: Filters by displayName. - * - **`parent`**: Project's parent (for example: `folders/123`, - * `organizations/*`). Prefer `parent` field over `parent.type` and - * `parent.id`. - * - **`parent.type`**: Parent's type: `folder` or `organization`. - * - **`parent.id`**: Parent's id number (for example: `123`). - * - **`id`, `projectId`**: Filters by projectId. - * - **`state`, `lifecycleState`**: Filters by state. - * - **`labels`**: Filters by label name or value. - * - **`labels.` (where `` is the name of a label)**: Filters by label - * name. - * Search expressions are case insensitive. - * Some examples queries: - * - **`name:how*`**: The project's name starts with "how". - * - **`name:Howl`**: The project's name is `Howl` or `howl`. - * - **`name:HOWL`**: Equivalent to above. - * - **`NAME:howl`**: Equivalent to above. - * - **`labels.color:*`**: The project has the label `color`. - * - **`labels.color:red`**: The project's label `color` has the value `red`. - * - **`labels.color:red labels.size:big`**: The project's label `color` has - * the value `red` or its label `size` has the value `big`. - * If no query is specified, the call will return projects for which the user - * has the `resourcemanager.projects.get` permission. - */ - // const query = 'abc123' - /** - * Optional. A pagination token returned from a previous call to - * ListProjects google.cloud.resourcemanager.v3.Projects.ListProjects that - * indicates from where listing should continue. - */ - // const pageToken = 'abc123' - /** - * Optional. The maximum number of projects to return in the response. - * The server can return fewer projects than requested. - * If unspecified, server picks an appropriate default. - */ - // const pageSize = 1234 - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callSearchProjects() { - // Construct request - const request = { - }; - - // Run request - const iterable = await resourcemanagerClient.searchProjectsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callSearchProjects(); - // [END cloudresourcemanager_v3_generated_Projects_SearchProjects_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.set_iam_policy.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.set_iam_policy.js deleted file mode 100644 index dfa4711b253..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.set_iam_policy.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(resource, policy) { - // [START cloudresourcemanager_v3_generated_Projects_SetIamPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - */ - // const policy = {} - /** - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * `paths: "bindings, etag"` - */ - // const updateMask = {} - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callSetIamPolicy() { - // Construct request - const request = { - resource, - policy, - }; - - // Run request - const response = await resourcemanagerClient.setIamPolicy(request); - console.log(response); - } - - callSetIamPolicy(); - // [END cloudresourcemanager_v3_generated_Projects_SetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.test_iam_permissions.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.test_iam_permissions.js deleted file mode 100644 index acdf505b3a0..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.test_iam_permissions.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(resource, permissions) { - // [START cloudresourcemanager_v3_generated_Projects_TestIamPermissions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). - */ - // const permissions = ['abc','def'] - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callTestIamPermissions() { - // Construct request - const request = { - resource, - permissions, - }; - - // Run request - const response = await resourcemanagerClient.testIamPermissions(request); - console.log(response); - } - - callTestIamPermissions(); - // [END cloudresourcemanager_v3_generated_Projects_TestIamPermissions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.undelete_project.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.undelete_project.js deleted file mode 100644 index 44a3a80bbac..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.undelete_project.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 cloudresourcemanager_v3_generated_Projects_UndeleteProject_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 project (for example, `projects/415104041262`). - * Required. - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callUndeleteProject() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await resourcemanagerClient.undeleteProject(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUndeleteProject(); - // [END cloudresourcemanager_v3_generated_Projects_UndeleteProject_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.update_project.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.update_project.js deleted file mode 100644 index 45bb46af51c..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/projects.update_project.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(project) { - // [START cloudresourcemanager_v3_generated_Projects_UpdateProject_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The new definition of the project. - */ - // const project = 'my-project' - /** - * Optional. An update mask to selectively update fields. - */ - // const updateMask = {} - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callUpdateProject() { - // Construct request - const request = { - project, - }; - - // Run request - const [operation] = await resourcemanagerClient.updateProject(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateProject(); - // [END cloudresourcemanager_v3_generated_Projects_UpdateProject_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/snippet_metadata_google.cloud.resourcemanager.v3.json b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/snippet_metadata_google.cloud.resourcemanager.v3.json deleted file mode 100644 index 289856dddca..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/snippet_metadata_google.cloud.resourcemanager.v3.json +++ /dev/null @@ -1,2339 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-resourcemanager", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.resourcemanager.v3", - "version": "v3" - } - ] - }, - "snippets": [ - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_GetFolder_async", - "title": "Folders getFolder Sample", - "origin": "API_DEFINITION", - "description": " Retrieves a folder identified by the supplied resource name. Valid folder resource names have the format `folders/{folder_id}` (for example, `folders/1234`). The caller must have `resourcemanager.folders.get` permission on the identified folder.", - "canonical": true, - "file": "folders.get_folder.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.GetFolder", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.Folder", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "GetFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.GetFolder", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_ListFolders_async", - "title": "Folders listFolders Sample", - "origin": "API_DEFINITION", - "description": " Lists the folders that are direct descendants of supplied parent resource. `list()` provides a strongly consistent view of the folders underneath the specified parent resource. `list()` returns folders sorted based upon the (ascending) lexical ordering of their display_name. The caller must have `resourcemanager.folders.list` permission on the identified parent.", - "canonical": true, - "file": "folders.list_folders.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 78, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListFolders", - "fullName": "google.cloud.resourcemanager.v3.Folders.ListFolders", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "show_deleted", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.ListFoldersResponse", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "ListFolders", - "fullName": "google.cloud.resourcemanager.v3.Folders.ListFolders", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_SearchFolders_async", - "title": "Folders searchFolders Sample", - "origin": "API_DEFINITION", - "description": " Search for folders that match specific filter criteria. `search()` provides an eventually consistent view of the folders a user has access to which meet the specified filter criteria. This will only return folders on which the caller has the permission `resourcemanager.folders.get`.", - "canonical": true, - "file": "folders.search_folders.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 90, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SearchFolders", - "fullName": "google.cloud.resourcemanager.v3.Folders.SearchFolders", - "async": true, - "parameters": [ - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.SearchFoldersResponse", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "SearchFolders", - "fullName": "google.cloud.resourcemanager.v3.Folders.SearchFolders", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_CreateFolder_async", - "title": "Folders createFolder Sample", - "origin": "API_DEFINITION", - "description": " Creates a folder in the resource hierarchy. Returns an `Operation` which can be used to track the progress of the folder creation workflow. Upon success, the `Operation.response` field will be populated with the created Folder. In order to succeed, the addition of this new folder must not violate the folder naming, height, or fanout constraints. + The folder's `display_name` must be distinct from all other folders that share its parent. + The addition of the folder must not cause the active folder hierarchy to exceed a height of 10. Note, the full active + deleted folder hierarchy is allowed to reach a height of 20; this provides additional headroom when moving folders that contain deleted folders. + The addition of the folder must not cause the total number of folders under its parent to exceed 300. If the operation fails due to a folder constraint violation, some errors may be returned by the `CreateFolder` request, with status code `FAILED_PRECONDITION` and an error description. Other folder constraint violations will be communicated in the `Operation`, with the specific `PreconditionFailure` returned in the details list in the `Operation.error` field. The caller must have `resourcemanager.folders.create` permission on the identified parent.", - "canonical": true, - "file": "folders.create_folder.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.CreateFolder", - "async": true, - "parameters": [ - { - "name": "folder", - "type": ".google.cloud.resourcemanager.v3.Folder" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "CreateFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.CreateFolder", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_UpdateFolder_async", - "title": "Folders updateFolder Sample", - "origin": "API_DEFINITION", - "description": " Updates a folder, changing its `display_name`. Changes to the folder `display_name` will be rejected if they violate either the `display_name` formatting rules or the naming constraints described in the [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] documentation. The folder's `display_name` must start and end with a letter or digit, may contain letters, digits, spaces, hyphens and underscores and can be between 3 and 30 characters. This is captured by the regular expression: `[\\p{L}\\p{N}][\\p{L}\\p{N}_- ]{1,28}[\\p{L}\\p{N}]`. The caller must have `resourcemanager.folders.update` permission on the identified folder. If the update fails due to the unique name constraint then a `PreconditionFailure` explaining this violation will be returned in the Status.details field.", - "canonical": true, - "file": "folders.update_folder.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.UpdateFolder", - "async": true, - "parameters": [ - { - "name": "folder", - "type": ".google.cloud.resourcemanager.v3.Folder" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "UpdateFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.UpdateFolder", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_MoveFolder_async", - "title": "Folders moveFolder Sample", - "origin": "API_DEFINITION", - "description": " Moves a folder under a new resource parent. Returns an `Operation` which can be used to track the progress of the folder move workflow. Upon success, the `Operation.response` field will be populated with the moved folder. Upon failure, a `FolderOperationError` categorizing the failure cause will be returned - if the failure occurs synchronously then the `FolderOperationError` will be returned in the `Status.details` field. If it occurs asynchronously, then the FolderOperation will be returned in the `Operation.error` field. In addition, the `Operation.metadata` field will be populated with a `FolderOperation` message as an aid to stateless clients. Folder moves will be rejected if they violate either the naming, height, or fanout constraints described in the [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] documentation. The caller must have `resourcemanager.folders.move` permission on the folder's current and proposed new parent.", - "canonical": true, - "file": "folders.move_folder.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "MoveFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.MoveFolder", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "destination_parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "MoveFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.MoveFolder", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_DeleteFolder_async", - "title": "Folders deleteFolder Sample", - "origin": "API_DEFINITION", - "description": " Requests deletion of a folder. The folder is moved into the [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] state immediately, and is deleted approximately 30 days later. This method may only be called on an empty folder, where a folder is empty if it doesn't contain any folders or projects in the [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. If called on a folder in [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] state the operation will result in a no-op success. The caller must have `resourcemanager.folders.delete` permission on the identified folder.", - "canonical": true, - "file": "folders.delete_folder.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.DeleteFolder", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "DeleteFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.DeleteFolder", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_UndeleteFolder_async", - "title": "Folders undeleteFolder Sample", - "origin": "API_DEFINITION", - "description": " Cancels the deletion request for a folder. This method may be called on a folder in any state. If the folder is in the [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state the result will be a no-op success. In order to succeed, the folder's parent must be in the [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. In addition, reintroducing the folder into the tree must not violate folder naming, height, and fanout constraints described in the [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] documentation. The caller must have `resourcemanager.folders.undelete` permission on the identified folder.", - "canonical": true, - "file": "folders.undelete_folder.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UndeleteFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.UndeleteFolder", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "UndeleteFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.UndeleteFolder", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_GetIamPolicy_async", - "title": "Folders getIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Gets the access control policy for a folder. The returned policy may be empty if no such policy or resource exists. The `resource` field should be the folder's resource name, for example: \"folders/1234\". The caller must have `resourcemanager.folders.getIamPolicy` permission on the identified folder.", - "canonical": true, - "file": "folders.get_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Folders.GetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "options", - "type": ".google.iam.v1.GetPolicyOptions" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Folders.GetIamPolicy", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_SetIamPolicy_async", - "title": "Folders setIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Sets the access control policy on a folder, replacing any existing policy. The `resource` field should be the folder's resource name, for example: \"folders/1234\". The caller must have `resourcemanager.folders.setIamPolicy` permission on the identified folder.", - "canonical": true, - "file": "folders.set_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Folders.SetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "policy", - "type": ".google.iam.v1.Policy" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Folders.SetIamPolicy", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_TestIamPermissions_async", - "title": "Folders testIamPermissions Sample", - "origin": "API_DEFINITION", - "description": " Returns permissions that a caller has on the specified folder. The `resource` field should be the folder's resource name, for example: \"folders/1234\". There are no permissions required for making this API call.", - "canonical": true, - "file": "folders.test_iam_permissions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.resourcemanager.v3.Folders.TestIamPermissions", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "permissions", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.iam.v1.TestIamPermissionsResponse", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.resourcemanager.v3.Folders.TestIamPermissions", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Organizations_GetOrganization_async", - "title": "Folders getOrganization Sample", - "origin": "API_DEFINITION", - "description": " Fetches an organization resource identified by the specified resource name.", - "canonical": true, - "file": "organizations.get_organization.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetOrganization", - "fullName": "google.cloud.resourcemanager.v3.Organizations.GetOrganization", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.Organization", - "client": { - "shortName": "OrganizationsClient", - "fullName": "google.cloud.resourcemanager.v3.OrganizationsClient" - }, - "method": { - "shortName": "GetOrganization", - "fullName": "google.cloud.resourcemanager.v3.Organizations.GetOrganization", - "service": { - "shortName": "Organizations", - "fullName": "google.cloud.resourcemanager.v3.Organizations" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Organizations_SearchOrganizations_async", - "title": "Folders searchOrganizations Sample", - "origin": "API_DEFINITION", - "description": " Searches organization resources that are visible to the user and satisfy the specified filter. This method returns organizations in an unspecified order. New organizations do not necessarily appear at the end of the results, and may take a small amount of time to appear. Search will only return organizations on which the user has the permission `resourcemanager.organizations.get`", - "canonical": true, - "file": "organizations.search_organizations.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 79, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SearchOrganizations", - "fullName": "google.cloud.resourcemanager.v3.Organizations.SearchOrganizations", - "async": true, - "parameters": [ - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.SearchOrganizationsResponse", - "client": { - "shortName": "OrganizationsClient", - "fullName": "google.cloud.resourcemanager.v3.OrganizationsClient" - }, - "method": { - "shortName": "SearchOrganizations", - "fullName": "google.cloud.resourcemanager.v3.Organizations.SearchOrganizations", - "service": { - "shortName": "Organizations", - "fullName": "google.cloud.resourcemanager.v3.Organizations" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Organizations_GetIamPolicy_async", - "title": "Folders getIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Gets the access control policy for an organization resource. The policy may be empty if no such policy or resource exists. The `resource` field should be the organization's resource name, for example: \"organizations/123\". Authorization requires the IAM permission `resourcemanager.organizations.getIamPolicy` on the specified organization.", - "canonical": true, - "file": "organizations.get_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Organizations.GetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "options", - "type": ".google.iam.v1.GetPolicyOptions" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "OrganizationsClient", - "fullName": "google.cloud.resourcemanager.v3.OrganizationsClient" - }, - "method": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Organizations.GetIamPolicy", - "service": { - "shortName": "Organizations", - "fullName": "google.cloud.resourcemanager.v3.Organizations" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Organizations_SetIamPolicy_async", - "title": "Folders setIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Sets the access control policy on an organization resource. Replaces any existing policy. The `resource` field should be the organization's resource name, for example: \"organizations/123\". Authorization requires the IAM permission `resourcemanager.organizations.setIamPolicy` on the specified organization.", - "canonical": true, - "file": "organizations.set_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Organizations.SetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "policy", - "type": ".google.iam.v1.Policy" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "OrganizationsClient", - "fullName": "google.cloud.resourcemanager.v3.OrganizationsClient" - }, - "method": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Organizations.SetIamPolicy", - "service": { - "shortName": "Organizations", - "fullName": "google.cloud.resourcemanager.v3.Organizations" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Organizations_TestIamPermissions_async", - "title": "Folders testIamPermissions Sample", - "origin": "API_DEFINITION", - "description": " Returns the permissions that a caller has on the specified organization. The `resource` field should be the organization's resource name, for example: \"organizations/123\". There are no permissions required for making this API call.", - "canonical": true, - "file": "organizations.test_iam_permissions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.resourcemanager.v3.Organizations.TestIamPermissions", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "permissions", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.iam.v1.TestIamPermissionsResponse", - "client": { - "shortName": "OrganizationsClient", - "fullName": "google.cloud.resourcemanager.v3.OrganizationsClient" - }, - "method": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.resourcemanager.v3.Organizations.TestIamPermissions", - "service": { - "shortName": "Organizations", - "fullName": "google.cloud.resourcemanager.v3.Organizations" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_GetProject_async", - "title": "Folders getProject Sample", - "origin": "API_DEFINITION", - "description": " Retrieves the project identified by the specified `name` (for example, `projects/415104041262`). The caller must have `resourcemanager.projects.get` permission for this project.", - "canonical": true, - "file": "projects.get_project.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.GetProject", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.Project", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "GetProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.GetProject", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_ListProjects_async", - "title": "Folders listProjects Sample", - "origin": "API_DEFINITION", - "description": " Lists projects that are direct children of the specified folder or organization resource. `list()` provides a strongly consistent view of the projects underneath the specified parent resource. `list()` returns projects sorted based upon the (ascending) lexical ordering of their `display_name`. The caller must have `resourcemanager.projects.list` permission on the identified parent.", - "canonical": true, - "file": "projects.list_projects.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 76, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProjects", - "fullName": "google.cloud.resourcemanager.v3.Projects.ListProjects", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "show_deleted", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.ListProjectsResponse", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "ListProjects", - "fullName": "google.cloud.resourcemanager.v3.Projects.ListProjects", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_SearchProjects_async", - "title": "Folders searchProjects Sample", - "origin": "API_DEFINITION", - "description": " Search for projects that the caller has both `resourcemanager.projects.get` permission on, and also satisfy the specified query. This method returns projects in an unspecified order. This method is eventually consistent with project mutations; this means that a newly created project may not appear in the results or recent updates to an existing project may not be reflected in the results. To retrieve the latest state of a project, use the [GetProject][google.cloud.resourcemanager.v3.Projects.GetProject] method.", - "canonical": true, - "file": "projects.search_projects.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 92, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SearchProjects", - "fullName": "google.cloud.resourcemanager.v3.Projects.SearchProjects", - "async": true, - "parameters": [ - { - "name": "query", - "type": "TYPE_STRING" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.SearchProjectsResponse", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "SearchProjects", - "fullName": "google.cloud.resourcemanager.v3.Projects.SearchProjects", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_CreateProject_async", - "title": "Folders createProject Sample", - "origin": "API_DEFINITION", - "description": " Request that a new project be created. The result is an `Operation` which can be used to track the creation process. This process usually takes a few seconds, but can sometimes take much longer. The tracking `Operation` is automatically deleted after a few hours, so there is no need to call `DeleteOperation`.", - "canonical": true, - "file": "projects.create_project.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.CreateProject", - "async": true, - "parameters": [ - { - "name": "project", - "type": ".google.cloud.resourcemanager.v3.Project" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "CreateProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.CreateProject", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_UpdateProject_async", - "title": "Folders updateProject Sample", - "origin": "API_DEFINITION", - "description": " Updates the `display_name` and labels of the project identified by the specified `name` (for example, `projects/415104041262`). Deleting all labels requires an update mask for labels field. The caller must have `resourcemanager.projects.update` permission for this project.", - "canonical": true, - "file": "projects.update_project.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.UpdateProject", - "async": true, - "parameters": [ - { - "name": "project", - "type": ".google.cloud.resourcemanager.v3.Project" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "UpdateProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.UpdateProject", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_MoveProject_async", - "title": "Folders moveProject Sample", - "origin": "API_DEFINITION", - "description": " Move a project to another place in your resource hierarchy, under a new resource parent. Returns an operation which can be used to track the process of the project move workflow. Upon success, the `Operation.response` field will be populated with the moved project. The caller must have `resourcemanager.projects.move` permission on the project, on the project's current and proposed new parent. If project has no current parent, or it currently does not have an associated organization resource, you will also need the `resourcemanager.projects.setIamPolicy` permission in the project.", - "canonical": true, - "file": "projects.move_project.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "MoveProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.MoveProject", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "destination_parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "MoveProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.MoveProject", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_DeleteProject_async", - "title": "Folders deleteProject Sample", - "origin": "API_DEFINITION", - "description": " Marks the project identified by the specified `name` (for example, `projects/415104041262`) for deletion. This method will only affect the project if it has a lifecycle state of [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE]. This method changes the Project's lifecycle state from [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE] to [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Project.State.DELETE_REQUESTED]. The deletion starts at an unspecified time, at which point the Project is no longer accessible. Until the deletion completes, you can check the lifecycle state checked by retrieving the project with [GetProject] [google.cloud.resourcemanager.v3.Projects.GetProject], and the project remains visible to [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects]. However, you cannot update the project. After the deletion completes, the project is not retrievable by the [GetProject] [google.cloud.resourcemanager.v3.Projects.GetProject], [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects], and [SearchProjects][google.cloud.resourcemanager.v3.Projects.SearchProjects] methods. This method behaves idempotently, such that deleting a `DELETE_REQUESTED` project will not cause an error, but also won't do anything. The caller must have `resourcemanager.projects.delete` permissions for this project.", - "canonical": true, - "file": "projects.delete_project.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.DeleteProject", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "DeleteProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.DeleteProject", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_UndeleteProject_async", - "title": "Folders undeleteProject Sample", - "origin": "API_DEFINITION", - "description": " Restores the project identified by the specified `name` (for example, `projects/415104041262`). You can only use this method for a project that has a lifecycle state of [DELETE_REQUESTED] [Projects.State.DELETE_REQUESTED]. After deletion starts, the project cannot be restored. The caller must have `resourcemanager.projects.undelete` permission for this project.", - "canonical": true, - "file": "projects.undelete_project.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UndeleteProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.UndeleteProject", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "UndeleteProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.UndeleteProject", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_GetIamPolicy_async", - "title": "Folders getIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Returns the IAM access control policy for the specified project, in the format `projects/{ProjectIdOrNumber}` e.g. projects/123. Permission is denied if the policy or the resource do not exist.", - "canonical": true, - "file": "projects.get_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Projects.GetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "options", - "type": ".google.iam.v1.GetPolicyOptions" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Projects.GetIamPolicy", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_SetIamPolicy_async", - "title": "Folders setIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Sets the IAM access control policy for the specified project, in the format `projects/{ProjectIdOrNumber}` e.g. projects/123. CAUTION: This method will replace the existing policy, and cannot be used to append additional IAM settings. Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles. The following constraints apply when using `setIamPolicy()`: + Project does not support `allUsers` and `allAuthenticatedUsers` as `members` in a `Binding` of a `Policy`. + The owner role can be granted to a `user`, `serviceAccount`, or a group that is part of an organization. For example, group@myownpersonaldomain.com could be added as an owner to a project in the myownpersonaldomain.com organization, but not the examplepetstore.com organization. + Service accounts can be made owners of a project directly without any restrictions. However, to be added as an owner, a user must be invited using the Cloud Platform console and must accept the invitation. + A user cannot be granted the owner role using `setIamPolicy()`. The user must be granted the owner role using the Cloud Platform Console and must explicitly accept the invitation. + Invitations to grant the owner role cannot be sent using `setIamPolicy()`; they must be sent only using the Cloud Platform Console. + If the project is not part of an organization, there must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner from the policy will fail. This restriction also applies to legacy projects that no longer have owners who have accepted the ToS. Edits to IAM policies will be rejected until the lack of a ToS-accepting owner is rectified. If the project is part of an organization, you can remove all owners, potentially making the organization inaccessible.", - "canonical": true, - "file": "projects.set_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Projects.SetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "policy", - "type": ".google.iam.v1.Policy" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Projects.SetIamPolicy", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_TestIamPermissions_async", - "title": "Folders testIamPermissions Sample", - "origin": "API_DEFINITION", - "description": " Returns permissions that a caller has on the specified project, in the format `projects/{ProjectIdOrNumber}` e.g. projects/123..", - "canonical": true, - "file": "projects.test_iam_permissions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.resourcemanager.v3.Projects.TestIamPermissions", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "permissions", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.iam.v1.TestIamPermissionsResponse", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.resourcemanager.v3.Projects.TestIamPermissions", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagBindings_ListTagBindings_async", - "title": "Folders listTagBindings Sample", - "origin": "API_DEFINITION", - "description": " Lists the TagBindings for the given Google Cloud resource, as specified with `parent`. NOTE: The `parent` field is expected to be a full resource name: https://cloud.google.com/apis/design/resource_names#full_resource_name", - "canonical": true, - "file": "tag_bindings.list_tag_bindings.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListTagBindings", - "fullName": "google.cloud.resourcemanager.v3.TagBindings.ListTagBindings", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.ListTagBindingsResponse", - "client": { - "shortName": "TagBindingsClient", - "fullName": "google.cloud.resourcemanager.v3.TagBindingsClient" - }, - "method": { - "shortName": "ListTagBindings", - "fullName": "google.cloud.resourcemanager.v3.TagBindings.ListTagBindings", - "service": { - "shortName": "TagBindings", - "fullName": "google.cloud.resourcemanager.v3.TagBindings" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagBindings_CreateTagBinding_async", - "title": "Folders createTagBinding Sample", - "origin": "API_DEFINITION", - "description": " Creates a TagBinding between a TagValue and a Google Cloud resource.", - "canonical": true, - "file": "tag_bindings.create_tag_binding.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateTagBinding", - "fullName": "google.cloud.resourcemanager.v3.TagBindings.CreateTagBinding", - "async": true, - "parameters": [ - { - "name": "tag_binding", - "type": ".google.cloud.resourcemanager.v3.TagBinding" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TagBindingsClient", - "fullName": "google.cloud.resourcemanager.v3.TagBindingsClient" - }, - "method": { - "shortName": "CreateTagBinding", - "fullName": "google.cloud.resourcemanager.v3.TagBindings.CreateTagBinding", - "service": { - "shortName": "TagBindings", - "fullName": "google.cloud.resourcemanager.v3.TagBindings" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagBindings_DeleteTagBinding_async", - "title": "Folders deleteTagBinding Sample", - "origin": "API_DEFINITION", - "description": " Deletes a TagBinding.", - "canonical": true, - "file": "tag_bindings.delete_tag_binding.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteTagBinding", - "fullName": "google.cloud.resourcemanager.v3.TagBindings.DeleteTagBinding", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TagBindingsClient", - "fullName": "google.cloud.resourcemanager.v3.TagBindingsClient" - }, - "method": { - "shortName": "DeleteTagBinding", - "fullName": "google.cloud.resourcemanager.v3.TagBindings.DeleteTagBinding", - "service": { - "shortName": "TagBindings", - "fullName": "google.cloud.resourcemanager.v3.TagBindings" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagBindings_ListEffectiveTags_async", - "title": "Folders listEffectiveTags Sample", - "origin": "API_DEFINITION", - "description": " Return a list of effective tags for the given Google Cloud resource, as specified in `parent`.", - "canonical": true, - "file": "tag_bindings.list_effective_tags.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListEffectiveTags", - "fullName": "google.cloud.resourcemanager.v3.TagBindings.ListEffectiveTags", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.ListEffectiveTagsResponse", - "client": { - "shortName": "TagBindingsClient", - "fullName": "google.cloud.resourcemanager.v3.TagBindingsClient" - }, - "method": { - "shortName": "ListEffectiveTags", - "fullName": "google.cloud.resourcemanager.v3.TagBindings.ListEffectiveTags", - "service": { - "shortName": "TagBindings", - "fullName": "google.cloud.resourcemanager.v3.TagBindings" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagHolds_CreateTagHold_async", - "title": "Folders createTagHold Sample", - "origin": "API_DEFINITION", - "description": " Creates a TagHold. Returns ALREADY_EXISTS if a TagHold with the same resource and origin exists under the same TagValue.", - "canonical": true, - "file": "tag_holds.create_tag_hold.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateTagHold", - "fullName": "google.cloud.resourcemanager.v3.TagHolds.CreateTagHold", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "tag_hold", - "type": ".google.cloud.resourcemanager.v3.TagHold" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TagHoldsClient", - "fullName": "google.cloud.resourcemanager.v3.TagHoldsClient" - }, - "method": { - "shortName": "CreateTagHold", - "fullName": "google.cloud.resourcemanager.v3.TagHolds.CreateTagHold", - "service": { - "shortName": "TagHolds", - "fullName": "google.cloud.resourcemanager.v3.TagHolds" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagHolds_DeleteTagHold_async", - "title": "Folders deleteTagHold Sample", - "origin": "API_DEFINITION", - "description": " Deletes a TagHold.", - "canonical": true, - "file": "tag_holds.delete_tag_hold.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteTagHold", - "fullName": "google.cloud.resourcemanager.v3.TagHolds.DeleteTagHold", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TagHoldsClient", - "fullName": "google.cloud.resourcemanager.v3.TagHoldsClient" - }, - "method": { - "shortName": "DeleteTagHold", - "fullName": "google.cloud.resourcemanager.v3.TagHolds.DeleteTagHold", - "service": { - "shortName": "TagHolds", - "fullName": "google.cloud.resourcemanager.v3.TagHolds" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagHolds_ListTagHolds_async", - "title": "Folders listTagHolds Sample", - "origin": "API_DEFINITION", - "description": " Lists TagHolds under a TagValue.", - "canonical": true, - "file": "tag_holds.list_tag_holds.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 80, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListTagHolds", - "fullName": "google.cloud.resourcemanager.v3.TagHolds.ListTagHolds", - "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.resourcemanager.v3.ListTagHoldsResponse", - "client": { - "shortName": "TagHoldsClient", - "fullName": "google.cloud.resourcemanager.v3.TagHoldsClient" - }, - "method": { - "shortName": "ListTagHolds", - "fullName": "google.cloud.resourcemanager.v3.TagHolds.ListTagHolds", - "service": { - "shortName": "TagHolds", - "fullName": "google.cloud.resourcemanager.v3.TagHolds" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagKeys_ListTagKeys_async", - "title": "Folders listTagKeys Sample", - "origin": "API_DEFINITION", - "description": " Lists all TagKeys for a parent resource.", - "canonical": true, - "file": "tag_keys.list_tag_keys.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListTagKeys", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.ListTagKeys", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.ListTagKeysResponse", - "client": { - "shortName": "TagKeysClient", - "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" - }, - "method": { - "shortName": "ListTagKeys", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.ListTagKeys", - "service": { - "shortName": "TagKeys", - "fullName": "google.cloud.resourcemanager.v3.TagKeys" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagKeys_GetTagKey_async", - "title": "Folders getTagKey Sample", - "origin": "API_DEFINITION", - "description": " Retrieves a TagKey. This method will return `PERMISSION_DENIED` if the key does not exist or the user does not have permission to view it.", - "canonical": true, - "file": "tag_keys.get_tag_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetTagKey", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.GetTagKey", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.TagKey", - "client": { - "shortName": "TagKeysClient", - "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" - }, - "method": { - "shortName": "GetTagKey", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.GetTagKey", - "service": { - "shortName": "TagKeys", - "fullName": "google.cloud.resourcemanager.v3.TagKeys" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagKeys_GetNamespacedTagKey_async", - "title": "Folders getNamespacedTagKey Sample", - "origin": "API_DEFINITION", - "description": " Retrieves a TagKey by its namespaced name. This method will return `PERMISSION_DENIED` if the key does not exist or the user does not have permission to view it.", - "canonical": true, - "file": "tag_keys.get_namespaced_tag_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetNamespacedTagKey", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.GetNamespacedTagKey", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.TagKey", - "client": { - "shortName": "TagKeysClient", - "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" - }, - "method": { - "shortName": "GetNamespacedTagKey", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.GetNamespacedTagKey", - "service": { - "shortName": "TagKeys", - "fullName": "google.cloud.resourcemanager.v3.TagKeys" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagKeys_CreateTagKey_async", - "title": "Folders createTagKey Sample", - "origin": "API_DEFINITION", - "description": " Creates a new TagKey. If another request with the same parameters is sent while the original request is in process, the second request will receive an error. A maximum of 1000 TagKeys can exist under a parent at any given time.", - "canonical": true, - "file": "tag_keys.create_tag_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateTagKey", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.CreateTagKey", - "async": true, - "parameters": [ - { - "name": "tag_key", - "type": ".google.cloud.resourcemanager.v3.TagKey" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TagKeysClient", - "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" - }, - "method": { - "shortName": "CreateTagKey", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.CreateTagKey", - "service": { - "shortName": "TagKeys", - "fullName": "google.cloud.resourcemanager.v3.TagKeys" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagKeys_UpdateTagKey_async", - "title": "Folders updateTagKey Sample", - "origin": "API_DEFINITION", - "description": " Updates the attributes of the TagKey resource.", - "canonical": true, - "file": "tag_keys.update_tag_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateTagKey", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.UpdateTagKey", - "async": true, - "parameters": [ - { - "name": "tag_key", - "type": ".google.cloud.resourcemanager.v3.TagKey" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TagKeysClient", - "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" - }, - "method": { - "shortName": "UpdateTagKey", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.UpdateTagKey", - "service": { - "shortName": "TagKeys", - "fullName": "google.cloud.resourcemanager.v3.TagKeys" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagKeys_DeleteTagKey_async", - "title": "Folders deleteTagKey Sample", - "origin": "API_DEFINITION", - "description": " Deletes a TagKey. The TagKey cannot be deleted if it has any child TagValues.", - "canonical": true, - "file": "tag_keys.delete_tag_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteTagKey", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.DeleteTagKey", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "etag", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TagKeysClient", - "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" - }, - "method": { - "shortName": "DeleteTagKey", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.DeleteTagKey", - "service": { - "shortName": "TagKeys", - "fullName": "google.cloud.resourcemanager.v3.TagKeys" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagKeys_GetIamPolicy_async", - "title": "Folders getIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Gets the access control policy for a TagKey. The returned policy may be empty if no such policy or resource exists. The `resource` field should be the TagKey's resource name. For example, \"tagKeys/1234\". The caller must have `cloudresourcemanager.googleapis.com/tagKeys.getIamPolicy` permission on the specified TagKey.", - "canonical": true, - "file": "tag_keys.get_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.GetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "options", - "type": ".google.iam.v1.GetPolicyOptions" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "TagKeysClient", - "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" - }, - "method": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.GetIamPolicy", - "service": { - "shortName": "TagKeys", - "fullName": "google.cloud.resourcemanager.v3.TagKeys" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagKeys_SetIamPolicy_async", - "title": "Folders setIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Sets the access control policy on a TagKey, replacing any existing policy. The `resource` field should be the TagKey's resource name. For example, \"tagKeys/1234\". The caller must have `resourcemanager.tagKeys.setIamPolicy` permission on the identified tagValue.", - "canonical": true, - "file": "tag_keys.set_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.SetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "policy", - "type": ".google.iam.v1.Policy" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "TagKeysClient", - "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" - }, - "method": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.SetIamPolicy", - "service": { - "shortName": "TagKeys", - "fullName": "google.cloud.resourcemanager.v3.TagKeys" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagKeys_TestIamPermissions_async", - "title": "Folders testIamPermissions Sample", - "origin": "API_DEFINITION", - "description": " Returns permissions that a caller has on the specified TagKey. The `resource` field should be the TagKey's resource name. For example, \"tagKeys/1234\". There are no permissions required for making this API call.", - "canonical": true, - "file": "tag_keys.test_iam_permissions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.TestIamPermissions", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "permissions", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.iam.v1.TestIamPermissionsResponse", - "client": { - "shortName": "TagKeysClient", - "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" - }, - "method": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.TestIamPermissions", - "service": { - "shortName": "TagKeys", - "fullName": "google.cloud.resourcemanager.v3.TagKeys" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagValues_ListTagValues_async", - "title": "Folders listTagValues Sample", - "origin": "API_DEFINITION", - "description": " Lists all TagValues for a specific TagKey.", - "canonical": true, - "file": "tag_values.list_tag_values.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListTagValues", - "fullName": "google.cloud.resourcemanager.v3.TagValues.ListTagValues", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.ListTagValuesResponse", - "client": { - "shortName": "TagValuesClient", - "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" - }, - "method": { - "shortName": "ListTagValues", - "fullName": "google.cloud.resourcemanager.v3.TagValues.ListTagValues", - "service": { - "shortName": "TagValues", - "fullName": "google.cloud.resourcemanager.v3.TagValues" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagValues_GetTagValue_async", - "title": "Folders getTagValue Sample", - "origin": "API_DEFINITION", - "description": " Retrieves a TagValue. This method will return `PERMISSION_DENIED` if the value does not exist or the user does not have permission to view it.", - "canonical": true, - "file": "tag_values.get_tag_value.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetTagValue", - "fullName": "google.cloud.resourcemanager.v3.TagValues.GetTagValue", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.TagValue", - "client": { - "shortName": "TagValuesClient", - "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" - }, - "method": { - "shortName": "GetTagValue", - "fullName": "google.cloud.resourcemanager.v3.TagValues.GetTagValue", - "service": { - "shortName": "TagValues", - "fullName": "google.cloud.resourcemanager.v3.TagValues" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagValues_GetNamespacedTagValue_async", - "title": "Folders getNamespacedTagValue Sample", - "origin": "API_DEFINITION", - "description": " Retrieves a TagValue by its namespaced name. This method will return `PERMISSION_DENIED` if the value does not exist or the user does not have permission to view it.", - "canonical": true, - "file": "tag_values.get_namespaced_tag_value.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetNamespacedTagValue", - "fullName": "google.cloud.resourcemanager.v3.TagValues.GetNamespacedTagValue", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.TagValue", - "client": { - "shortName": "TagValuesClient", - "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" - }, - "method": { - "shortName": "GetNamespacedTagValue", - "fullName": "google.cloud.resourcemanager.v3.TagValues.GetNamespacedTagValue", - "service": { - "shortName": "TagValues", - "fullName": "google.cloud.resourcemanager.v3.TagValues" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagValues_CreateTagValue_async", - "title": "Folders createTagValue Sample", - "origin": "API_DEFINITION", - "description": " Creates a TagValue as a child of the specified TagKey. If a another request with the same parameters is sent while the original request is in process the second request will receive an error. A maximum of 1000 TagValues can exist under a TagKey at any given time.", - "canonical": true, - "file": "tag_values.create_tag_value.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateTagValue", - "fullName": "google.cloud.resourcemanager.v3.TagValues.CreateTagValue", - "async": true, - "parameters": [ - { - "name": "tag_value", - "type": ".google.cloud.resourcemanager.v3.TagValue" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TagValuesClient", - "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" - }, - "method": { - "shortName": "CreateTagValue", - "fullName": "google.cloud.resourcemanager.v3.TagValues.CreateTagValue", - "service": { - "shortName": "TagValues", - "fullName": "google.cloud.resourcemanager.v3.TagValues" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagValues_UpdateTagValue_async", - "title": "Folders updateTagValue Sample", - "origin": "API_DEFINITION", - "description": " Updates the attributes of the TagValue resource.", - "canonical": true, - "file": "tag_values.update_tag_value.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateTagValue", - "fullName": "google.cloud.resourcemanager.v3.TagValues.UpdateTagValue", - "async": true, - "parameters": [ - { - "name": "tag_value", - "type": ".google.cloud.resourcemanager.v3.TagValue" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TagValuesClient", - "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" - }, - "method": { - "shortName": "UpdateTagValue", - "fullName": "google.cloud.resourcemanager.v3.TagValues.UpdateTagValue", - "service": { - "shortName": "TagValues", - "fullName": "google.cloud.resourcemanager.v3.TagValues" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagValues_DeleteTagValue_async", - "title": "Folders deleteTagValue Sample", - "origin": "API_DEFINITION", - "description": " Deletes a TagValue. The TagValue cannot have any bindings when it is deleted.", - "canonical": true, - "file": "tag_values.delete_tag_value.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteTagValue", - "fullName": "google.cloud.resourcemanager.v3.TagValues.DeleteTagValue", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "etag", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TagValuesClient", - "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" - }, - "method": { - "shortName": "DeleteTagValue", - "fullName": "google.cloud.resourcemanager.v3.TagValues.DeleteTagValue", - "service": { - "shortName": "TagValues", - "fullName": "google.cloud.resourcemanager.v3.TagValues" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagValues_GetIamPolicy_async", - "title": "Folders getIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Gets the access control policy for a TagValue. The returned policy may be empty if no such policy or resource exists. The `resource` field should be the TagValue's resource name. For example: `tagValues/1234`. The caller must have the `cloudresourcemanager.googleapis.com/tagValues.getIamPolicy` permission on the identified TagValue to get the access control policy.", - "canonical": true, - "file": "tag_values.get_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.TagValues.GetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "options", - "type": ".google.iam.v1.GetPolicyOptions" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "TagValuesClient", - "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" - }, - "method": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.TagValues.GetIamPolicy", - "service": { - "shortName": "TagValues", - "fullName": "google.cloud.resourcemanager.v3.TagValues" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagValues_SetIamPolicy_async", - "title": "Folders setIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Sets the access control policy on a TagValue, replacing any existing policy. The `resource` field should be the TagValue's resource name. For example: `tagValues/1234`. The caller must have `resourcemanager.tagValues.setIamPolicy` permission on the identified tagValue.", - "canonical": true, - "file": "tag_values.set_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.TagValues.SetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "policy", - "type": ".google.iam.v1.Policy" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "TagValuesClient", - "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" - }, - "method": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.TagValues.SetIamPolicy", - "service": { - "shortName": "TagValues", - "fullName": "google.cloud.resourcemanager.v3.TagValues" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagValues_TestIamPermissions_async", - "title": "Folders testIamPermissions Sample", - "origin": "API_DEFINITION", - "description": " Returns permissions that a caller has on the specified TagValue. The `resource` field should be the TagValue's resource name. For example: `tagValues/1234`. There are no permissions required for making this API call.", - "canonical": true, - "file": "tag_values.test_iam_permissions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.resourcemanager.v3.TagValues.TestIamPermissions", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "permissions", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.iam.v1.TestIamPermissionsResponse", - "client": { - "shortName": "TagValuesClient", - "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" - }, - "method": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.resourcemanager.v3.TagValues.TestIamPermissions", - "service": { - "shortName": "TagValues", - "fullName": "google.cloud.resourcemanager.v3.TagValues" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.create_tag_binding.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.create_tag_binding.js deleted file mode 100644 index ad6a2166043..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.create_tag_binding.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(tagBinding) { - // [START cloudresourcemanager_v3_generated_TagBindings_CreateTagBinding_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The TagBinding to be created. - */ - // const tagBinding = {} - /** - * Optional. Set to true to perform the validations necessary for creating the - * resource, but not actually perform the action. - */ - // const validateOnly = true - - // Imports the Resourcemanager library - const {TagBindingsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagBindingsClient(); - - async function callCreateTagBinding() { - // Construct request - const request = { - tagBinding, - }; - - // Run request - const [operation] = await resourcemanagerClient.createTagBinding(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateTagBinding(); - // [END cloudresourcemanager_v3_generated_TagBindings_CreateTagBinding_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.delete_tag_binding.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.delete_tag_binding.js deleted file mode 100644 index aa7e97c641d..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.delete_tag_binding.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 cloudresourcemanager_v3_generated_TagBindings_DeleteTagBinding_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 TagBinding. This is a String of the form: - * `tagBindings/{id}` (e.g. - * `tagBindings/%2F%2Fcloudresourcemanager.googleapis.com%2Fprojects%2F123/tagValues/456`). - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {TagBindingsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagBindingsClient(); - - async function callDeleteTagBinding() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await resourcemanagerClient.deleteTagBinding(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteTagBinding(); - // [END cloudresourcemanager_v3_generated_TagBindings_DeleteTagBinding_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.list_effective_tags.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.list_effective_tags.js deleted file mode 100644 index fb1d0a24397..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.list_effective_tags.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) { - // [START cloudresourcemanager_v3_generated_TagBindings_ListEffectiveTags_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The full resource name of a resource for which you want to list - * the effective tags. E.g. - * "//cloudresourcemanager.googleapis.com/projects/123" - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of effective tags to return in the response. - * The server allows a maximum of 300 effective tags to return in a single - * page. If unspecified, the server will use 100 as the default. - */ - // const pageSize = 1234 - /** - * Optional. A pagination token returned from a previous call to - * `ListEffectiveTags` that indicates from where this listing should continue. - */ - // const pageToken = 'abc123' - - // Imports the Resourcemanager library - const {TagBindingsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagBindingsClient(); - - async function callListEffectiveTags() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await resourcemanagerClient.listEffectiveTagsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListEffectiveTags(); - // [END cloudresourcemanager_v3_generated_TagBindings_ListEffectiveTags_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.list_tag_bindings.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.list_tag_bindings.js deleted file mode 100644 index 5858d932c6c..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_bindings.list_tag_bindings.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) { - // [START cloudresourcemanager_v3_generated_TagBindings_ListTagBindings_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The full resource name of a resource for which you want to list - * existing TagBindings. E.g. - * "//cloudresourcemanager.googleapis.com/projects/123" - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of TagBindings to return in the response. The - * server allows a maximum of 300 TagBindings to return. If unspecified, the - * server will use 100 as the default. - */ - // const pageSize = 1234 - /** - * Optional. A pagination token returned from a previous call to - * `ListTagBindings` that indicates where this listing should continue from. - */ - // const pageToken = 'abc123' - - // Imports the Resourcemanager library - const {TagBindingsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagBindingsClient(); - - async function callListTagBindings() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await resourcemanagerClient.listTagBindingsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListTagBindings(); - // [END cloudresourcemanager_v3_generated_TagBindings_ListTagBindings_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.create_tag_hold.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.create_tag_hold.js deleted file mode 100644 index ff05a49aa50..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.create_tag_hold.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(parent, tagHold) { - // [START cloudresourcemanager_v3_generated_TagHolds_CreateTagHold_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 TagHold's parent TagValue. Must be of - * the form: `tagValues/{tag-value-id}`. - */ - // const parent = 'abc123' - /** - * Required. The TagHold to be created. - */ - // const tagHold = {} - /** - * Optional. Set to true to perform the validations necessary for creating the - * resource, but not actually perform the action. - */ - // const validateOnly = true - - // Imports the Resourcemanager library - const {TagHoldsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagHoldsClient(); - - async function callCreateTagHold() { - // Construct request - const request = { - parent, - tagHold, - }; - - // Run request - const [operation] = await resourcemanagerClient.createTagHold(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateTagHold(); - // [END cloudresourcemanager_v3_generated_TagHolds_CreateTagHold_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.delete_tag_hold.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.delete_tag_hold.js deleted file mode 100644 index 4d6a10c5f97..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.delete_tag_hold.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 cloudresourcemanager_v3_generated_TagHolds_DeleteTagHold_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 TagHold to delete. Must be of the form: - * `tagValues/{tag-value-id}/tagHolds/{tag-hold-id}`. - */ - // const name = 'abc123' - /** - * Optional. Set to true to perform the validations necessary for deleting the - * resource, but not actually perform the action. - */ - // const validateOnly = true - - // Imports the Resourcemanager library - const {TagHoldsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagHoldsClient(); - - async function callDeleteTagHold() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await resourcemanagerClient.deleteTagHold(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteTagHold(); - // [END cloudresourcemanager_v3_generated_TagHolds_DeleteTagHold_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.list_tag_holds.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.list_tag_holds.js deleted file mode 100644 index d40a1c095ce..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_holds.list_tag_holds.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(parent) { - // [START cloudresourcemanager_v3_generated_TagHolds_ListTagHolds_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 parent TagValue. Must be of the form: - * `tagValues/{tag-value-id}`. - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of TagHolds to return in the response. The - * server allows a maximum of 300 TagHolds to return. If unspecified, the - * server will use 100 as the default. - */ - // const pageSize = 1234 - /** - * Optional. A pagination token returned from a previous call to - * `ListTagHolds` that indicates where this listing should continue from. - */ - // const pageToken = 'abc123' - /** - * Optional. Criteria used to select a subset of TagHolds parented by the - * TagValue to return. This field follows the syntax defined by aip.dev/160; - * the `holder` and `origin` fields are supported for filtering. Currently - * only `AND` syntax is supported. Some example queries are: - * * `holder = - * //compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group` - * * `origin = 35678234` - * * `holder = - * //compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group - * AND origin = 35678234` - */ - // const filter = 'abc123' - - // Imports the Resourcemanager library - const {TagHoldsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagHoldsClient(); - - async function callListTagHolds() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await resourcemanagerClient.listTagHoldsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListTagHolds(); - // [END cloudresourcemanager_v3_generated_TagHolds_ListTagHolds_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.create_tag_key.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.create_tag_key.js deleted file mode 100644 index b54df253335..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.create_tag_key.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(tagKey) { - // [START cloudresourcemanager_v3_generated_TagKeys_CreateTagKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The TagKey to be created. Only fields `short_name`, - * `description`, and `parent` are considered during the creation request. - */ - // const tagKey = {} - /** - * Optional. Set to true to perform validations necessary for creating the - * resource, but not actually perform the action. - */ - // const validateOnly = true - - // Imports the Resourcemanager library - const {TagKeysClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagKeysClient(); - - async function callCreateTagKey() { - // Construct request - const request = { - tagKey, - }; - - // Run request - const [operation] = await resourcemanagerClient.createTagKey(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateTagKey(); - // [END cloudresourcemanager_v3_generated_TagKeys_CreateTagKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.delete_tag_key.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.delete_tag_key.js deleted file mode 100644 index d9b671be828..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.delete_tag_key.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(name) { - // [START cloudresourcemanager_v3_generated_TagKeys_DeleteTagKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 a TagKey to be deleted in the format - * `tagKeys/123`. The TagKey cannot be a parent of any existing TagValues or - * it will not be deleted successfully. - */ - // const name = 'abc123' - /** - * Optional. Set as true to perform validations necessary for deletion, but - * not actually perform the action. - */ - // const validateOnly = true - /** - * Optional. The etag known to the client for the expected state of the - * TagKey. This is to be used for optimistic concurrency. - */ - // const etag = 'abc123' - - // Imports the Resourcemanager library - const {TagKeysClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagKeysClient(); - - async function callDeleteTagKey() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await resourcemanagerClient.deleteTagKey(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteTagKey(); - // [END cloudresourcemanager_v3_generated_TagKeys_DeleteTagKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_iam_policy.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_iam_policy.js deleted file mode 100644 index 14cedb29219..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_iam_policy.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(resource) { - // [START cloudresourcemanager_v3_generated_TagKeys_GetIamPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - */ - // const options = {} - - // Imports the Resourcemanager library - const {TagKeysClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagKeysClient(); - - async function callGetIamPolicy() { - // Construct request - const request = { - resource, - }; - - // Run request - const response = await resourcemanagerClient.getIamPolicy(request); - console.log(response); - } - - callGetIamPolicy(); - // [END cloudresourcemanager_v3_generated_TagKeys_GetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_namespaced_tag_key.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_namespaced_tag_key.js deleted file mode 100644 index 7861fabb92b..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_namespaced_tag_key.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 cloudresourcemanager_v3_generated_TagKeys_GetNamespacedTagKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A namespaced tag key name in the format - * `{parentId}/{tagKeyShort}`, such as `42/foo` for a key with short name - * "foo" under the organization with ID 42 or `r2-d2/bar` for a key with short - * name "bar" under the project `r2-d2`. - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {TagKeysClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagKeysClient(); - - async function callGetNamespacedTagKey() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await resourcemanagerClient.getNamespacedTagKey(request); - console.log(response); - } - - callGetNamespacedTagKey(); - // [END cloudresourcemanager_v3_generated_TagKeys_GetNamespacedTagKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_tag_key.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_tag_key.js deleted file mode 100644 index a0823e8df19..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.get_tag_key.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 cloudresourcemanager_v3_generated_TagKeys_GetTagKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A resource name in the format `tagKeys/{id}`, such as - * `tagKeys/123`. - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {TagKeysClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagKeysClient(); - - async function callGetTagKey() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await resourcemanagerClient.getTagKey(request); - console.log(response); - } - - callGetTagKey(); - // [END cloudresourcemanager_v3_generated_TagKeys_GetTagKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.list_tag_keys.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.list_tag_keys.js deleted file mode 100644 index d141a4cfa26..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.list_tag_keys.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) { - // [START cloudresourcemanager_v3_generated_TagKeys_ListTagKeys_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 TagKey's parent. - * Must be of the form `organizations/{org_id}` or `projects/{project_id}` or - * `projects/{project_number}` - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of TagKeys to return in the response. The - * server allows a maximum of 300 TagKeys to return. If unspecified, the - * server will use 100 as the default. - */ - // const pageSize = 1234 - /** - * Optional. A pagination token returned from a previous call to `ListTagKey` - * that indicates where this listing should continue from. - */ - // const pageToken = 'abc123' - - // Imports the Resourcemanager library - const {TagKeysClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagKeysClient(); - - async function callListTagKeys() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await resourcemanagerClient.listTagKeysAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListTagKeys(); - // [END cloudresourcemanager_v3_generated_TagKeys_ListTagKeys_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.set_iam_policy.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.set_iam_policy.js deleted file mode 100644 index 603a420647b..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.set_iam_policy.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(resource, policy) { - // [START cloudresourcemanager_v3_generated_TagKeys_SetIamPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - */ - // const policy = {} - /** - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * `paths: "bindings, etag"` - */ - // const updateMask = {} - - // Imports the Resourcemanager library - const {TagKeysClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagKeysClient(); - - async function callSetIamPolicy() { - // Construct request - const request = { - resource, - policy, - }; - - // Run request - const response = await resourcemanagerClient.setIamPolicy(request); - console.log(response); - } - - callSetIamPolicy(); - // [END cloudresourcemanager_v3_generated_TagKeys_SetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.test_iam_permissions.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.test_iam_permissions.js deleted file mode 100644 index be64a032154..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.test_iam_permissions.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(resource, permissions) { - // [START cloudresourcemanager_v3_generated_TagKeys_TestIamPermissions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). - */ - // const permissions = ['abc','def'] - - // Imports the Resourcemanager library - const {TagKeysClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagKeysClient(); - - async function callTestIamPermissions() { - // Construct request - const request = { - resource, - permissions, - }; - - // Run request - const response = await resourcemanagerClient.testIamPermissions(request); - console.log(response); - } - - callTestIamPermissions(); - // [END cloudresourcemanager_v3_generated_TagKeys_TestIamPermissions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.update_tag_key.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.update_tag_key.js deleted file mode 100644 index 3c3eca4f3a7..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_keys.update_tag_key.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(tagKey) { - // [START cloudresourcemanager_v3_generated_TagKeys_UpdateTagKey_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The new definition of the TagKey. Only the `description` and - * `etag` fields can be updated by this request. If the `etag` field is not - * empty, it must match the `etag` field of the existing tag key. Otherwise, - * `ABORTED` will be returned. - */ - // const tagKey = {} - /** - * Fields to be updated. The mask may only contain `description` or - * `etag`. If omitted entirely, both `description` and `etag` are assumed to - * be significant. - */ - // const updateMask = {} - /** - * Set as true to perform validations necessary for updating the resource, but - * not actually perform the action. - */ - // const validateOnly = true - - // Imports the Resourcemanager library - const {TagKeysClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagKeysClient(); - - async function callUpdateTagKey() { - // Construct request - const request = { - tagKey, - }; - - // Run request - const [operation] = await resourcemanagerClient.updateTagKey(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateTagKey(); - // [END cloudresourcemanager_v3_generated_TagKeys_UpdateTagKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.create_tag_value.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.create_tag_value.js deleted file mode 100644 index 63f9675d3ef..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.create_tag_value.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(tagValue) { - // [START cloudresourcemanager_v3_generated_TagValues_CreateTagValue_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The TagValue to be created. Only fields `short_name`, - * `description`, and `parent` are considered during the creation request. - */ - // const tagValue = {} - /** - * Optional. Set as true to perform the validations necessary for creating the - * resource, but not actually perform the action. - */ - // const validateOnly = true - - // Imports the Resourcemanager library - const {TagValuesClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagValuesClient(); - - async function callCreateTagValue() { - // Construct request - const request = { - tagValue, - }; - - // Run request - const [operation] = await resourcemanagerClient.createTagValue(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateTagValue(); - // [END cloudresourcemanager_v3_generated_TagValues_CreateTagValue_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.delete_tag_value.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.delete_tag_value.js deleted file mode 100644 index 1f0b1b768ad..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.delete_tag_value.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(name) { - // [START cloudresourcemanager_v3_generated_TagValues_DeleteTagValue_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name for TagValue to be deleted in the format - * tagValues/456. - */ - // const name = 'abc123' - /** - * Optional. Set as true to perform the validations necessary for deletion, - * but not actually perform the action. - */ - // const validateOnly = true - /** - * Optional. The etag known to the client for the expected state of the - * TagValue. This is to be used for optimistic concurrency. - */ - // const etag = 'abc123' - - // Imports the Resourcemanager library - const {TagValuesClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagValuesClient(); - - async function callDeleteTagValue() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await resourcemanagerClient.deleteTagValue(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteTagValue(); - // [END cloudresourcemanager_v3_generated_TagValues_DeleteTagValue_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_iam_policy.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_iam_policy.js deleted file mode 100644 index fc92e14923a..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_iam_policy.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(resource) { - // [START cloudresourcemanager_v3_generated_TagValues_GetIamPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - */ - // const options = {} - - // Imports the Resourcemanager library - const {TagValuesClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagValuesClient(); - - async function callGetIamPolicy() { - // Construct request - const request = { - resource, - }; - - // Run request - const response = await resourcemanagerClient.getIamPolicy(request); - console.log(response); - } - - callGetIamPolicy(); - // [END cloudresourcemanager_v3_generated_TagValues_GetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_namespaced_tag_value.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_namespaced_tag_value.js deleted file mode 100644 index 019c16379c3..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_namespaced_tag_value.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(name) { - // [START cloudresourcemanager_v3_generated_TagValues_GetNamespacedTagValue_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A namespaced tag value name in the following format: - * `{parentId}/{tagKeyShort}/{tagValueShort}` - * Examples: - * - `42/foo/abc` for a value with short name "abc" under the key with short - * name "foo" under the organization with ID 42 - * - `r2-d2/bar/xyz` for a value with short name "xyz" under the key with - * short name "bar" under the project with ID "r2-d2" - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {TagValuesClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagValuesClient(); - - async function callGetNamespacedTagValue() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await resourcemanagerClient.getNamespacedTagValue(request); - console.log(response); - } - - callGetNamespacedTagValue(); - // [END cloudresourcemanager_v3_generated_TagValues_GetNamespacedTagValue_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_tag_value.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_tag_value.js deleted file mode 100644 index 42eedb7b807..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.get_tag_value.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 cloudresourcemanager_v3_generated_TagValues_GetTagValue_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name for TagValue to be fetched in the format - * `tagValues/456`. - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {TagValuesClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagValuesClient(); - - async function callGetTagValue() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await resourcemanagerClient.getTagValue(request); - console.log(response); - } - - callGetTagValue(); - // [END cloudresourcemanager_v3_generated_TagValues_GetTagValue_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.list_tag_values.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.list_tag_values.js deleted file mode 100644 index fef7f2b88b1..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.list_tag_values.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) { - // [START cloudresourcemanager_v3_generated_TagValues_ListTagValues_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of TagValues to return in the response. The - * server allows a maximum of 300 TagValues to return. If unspecified, the - * server will use 100 as the default. - */ - // const pageSize = 1234 - /** - * Optional. A pagination token returned from a previous call to - * `ListTagValues` that indicates where this listing should continue from. - */ - // const pageToken = 'abc123' - - // Imports the Resourcemanager library - const {TagValuesClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagValuesClient(); - - async function callListTagValues() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await resourcemanagerClient.listTagValuesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListTagValues(); - // [END cloudresourcemanager_v3_generated_TagValues_ListTagValues_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.set_iam_policy.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.set_iam_policy.js deleted file mode 100644 index ba06fbe4b79..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.set_iam_policy.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(resource, policy) { - // [START cloudresourcemanager_v3_generated_TagValues_SetIamPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - */ - // const policy = {} - /** - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * `paths: "bindings, etag"` - */ - // const updateMask = {} - - // Imports the Resourcemanager library - const {TagValuesClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagValuesClient(); - - async function callSetIamPolicy() { - // Construct request - const request = { - resource, - policy, - }; - - // Run request - const response = await resourcemanagerClient.setIamPolicy(request); - console.log(response); - } - - callSetIamPolicy(); - // [END cloudresourcemanager_v3_generated_TagValues_SetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.test_iam_permissions.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.test_iam_permissions.js deleted file mode 100644 index 2e491e73c76..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.test_iam_permissions.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(resource, permissions) { - // [START cloudresourcemanager_v3_generated_TagValues_TestIamPermissions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). - */ - // const permissions = ['abc','def'] - - // Imports the Resourcemanager library - const {TagValuesClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagValuesClient(); - - async function callTestIamPermissions() { - // Construct request - const request = { - resource, - permissions, - }; - - // Run request - const response = await resourcemanagerClient.testIamPermissions(request); - console.log(response); - } - - callTestIamPermissions(); - // [END cloudresourcemanager_v3_generated_TagValues_TestIamPermissions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.update_tag_value.js b/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.update_tag_value.js deleted file mode 100644 index 8bc38601371..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/samples/generated/v3/tag_values.update_tag_value.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(tagValue) { - // [START cloudresourcemanager_v3_generated_TagValues_UpdateTagValue_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The new definition of the TagValue. Only fields `description` and - * `etag` fields can be updated by this request. If the `etag` field is - * nonempty, it must match the `etag` field of the existing ControlGroup. - * Otherwise, `ABORTED` will be returned. - */ - // const tagValue = {} - /** - * Optional. Fields to be updated. - */ - // const updateMask = {} - /** - * Optional. True to perform validations necessary for updating the resource, - * but not actually perform the action. - */ - // const validateOnly = true - - // Imports the Resourcemanager library - const {TagValuesClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagValuesClient(); - - async function callUpdateTagValue() { - // Construct request - const request = { - tagValue, - }; - - // Run request - const [operation] = await resourcemanagerClient.updateTagValue(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateTagValue(); - // [END cloudresourcemanager_v3_generated_TagValues_UpdateTagValue_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/index.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/src/index.ts deleted file mode 100644 index 59cb34f53d5..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/index.ts +++ /dev/null @@ -1,37 +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 v3 from './v3'; -const FoldersClient = v3.FoldersClient; -type FoldersClient = v3.FoldersClient; -const OrganizationsClient = v3.OrganizationsClient; -type OrganizationsClient = v3.OrganizationsClient; -const ProjectsClient = v3.ProjectsClient; -type ProjectsClient = v3.ProjectsClient; -const TagBindingsClient = v3.TagBindingsClient; -type TagBindingsClient = v3.TagBindingsClient; -const TagHoldsClient = v3.TagHoldsClient; -type TagHoldsClient = v3.TagHoldsClient; -const TagKeysClient = v3.TagKeysClient; -type TagKeysClient = v3.TagKeysClient; -const TagValuesClient = v3.TagValuesClient; -type TagValuesClient = v3.TagValuesClient; -export {v3, FoldersClient, OrganizationsClient, ProjectsClient, TagBindingsClient, TagHoldsClient, TagKeysClient, TagValuesClient}; -export default {v3, FoldersClient, OrganizationsClient, ProjectsClient, TagBindingsClient, TagHoldsClient, TagKeysClient, TagValuesClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_client.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_client.ts deleted file mode 100644 index 04ba3a356af..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_client.ts +++ /dev/null @@ -1,2074 +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} 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/v3/folders_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './folders_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Manages Cloud Platform folder resources. - * Folders can be used to organize the resources under an - * organization and to control the policies applied to groups of resources. - * @class - * @memberof v3 - */ -export class FoldersClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - foldersStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of FoldersClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 FoldersClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof FoldersClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - folderPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}' - ), - organizationPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - tagBindingPathTemplate: new this._gaxModule.PathTemplate( - 'tagBindings/{tag_binding}' - ), - tagHoldPathTemplate: new this._gaxModule.PathTemplate( - 'tagValues/{tag_value}/tagHolds/{tag_hold}' - ), - tagKeyPathTemplate: new this._gaxModule.PathTemplate( - 'tagKeys/{tag_key}' - ), - tagValuePathTemplate: new this._gaxModule.PathTemplate( - 'tagValues/{tag_value}' - ), - }; - - // 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 = { - listFolders: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'folders'), - searchFolders: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'folders') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v3/{name=operations/**}',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createFolderResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.Folder') as gax.protobuf.Type; - const createFolderMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.CreateFolderMetadata') as gax.protobuf.Type; - const updateFolderResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.Folder') as gax.protobuf.Type; - const updateFolderMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.UpdateFolderMetadata') as gax.protobuf.Type; - const moveFolderResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.Folder') as gax.protobuf.Type; - const moveFolderMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.MoveFolderMetadata') as gax.protobuf.Type; - const deleteFolderResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.Folder') as gax.protobuf.Type; - const deleteFolderMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.DeleteFolderMetadata') as gax.protobuf.Type; - const undeleteFolderResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.Folder') as gax.protobuf.Type; - const undeleteFolderMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.UndeleteFolderMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createFolder: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createFolderResponse.decode.bind(createFolderResponse), - createFolderMetadata.decode.bind(createFolderMetadata)), - updateFolder: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateFolderResponse.decode.bind(updateFolderResponse), - updateFolderMetadata.decode.bind(updateFolderMetadata)), - moveFolder: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - moveFolderResponse.decode.bind(moveFolderResponse), - moveFolderMetadata.decode.bind(moveFolderMetadata)), - deleteFolder: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteFolderResponse.decode.bind(deleteFolderResponse), - deleteFolderMetadata.decode.bind(deleteFolderMetadata)), - undeleteFolder: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - undeleteFolderResponse.decode.bind(undeleteFolderResponse), - undeleteFolderMetadata.decode.bind(undeleteFolderMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.resourcemanager.v3.Folders', 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.foldersStub) { - return this.foldersStub; - } - - // Put together the "service stub" for - // google.cloud.resourcemanager.v3.Folders. - this.foldersStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.Folders') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.resourcemanager.v3.Folders, - 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 foldersStubMethods = - ['getFolder', 'listFolders', 'searchFolders', 'createFolder', 'updateFolder', 'moveFolder', 'deleteFolder', 'undeleteFolder', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; - for (const methodName of foldersStubMethods) { - const callPromise = this.foldersStub.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.foldersStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudresourcemanager.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 'cloudresourcemanager.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only' - ]; - } - - 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 -- - // ------------------- -/** - * Retrieves a folder identified by the supplied resource name. - * Valid folder resource names have the format `folders/{folder_id}` - * (for example, `folders/1234`). - * The caller must have `resourcemanager.folders.get` permission on the - * identified folder. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the folder to retrieve. - * Must be of the form `folders/{folder_id}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.resourcemanager.v3.Folder|Folder}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/folders.get_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_GetFolder_async - */ - getFolder( - request?: protos.google.cloud.resourcemanager.v3.IGetFolderRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.IFolder, - protos.google.cloud.resourcemanager.v3.IGetFolderRequest|undefined, {}|undefined - ]>; - getFolder( - request: protos.google.cloud.resourcemanager.v3.IGetFolderRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.resourcemanager.v3.IFolder, - protos.google.cloud.resourcemanager.v3.IGetFolderRequest|null|undefined, - {}|null|undefined>): void; - getFolder( - request: protos.google.cloud.resourcemanager.v3.IGetFolderRequest, - callback: Callback< - protos.google.cloud.resourcemanager.v3.IFolder, - protos.google.cloud.resourcemanager.v3.IGetFolderRequest|null|undefined, - {}|null|undefined>): void; - getFolder( - request?: protos.google.cloud.resourcemanager.v3.IGetFolderRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.resourcemanager.v3.IFolder, - protos.google.cloud.resourcemanager.v3.IGetFolderRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.resourcemanager.v3.IFolder, - protos.google.cloud.resourcemanager.v3.IGetFolderRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.resourcemanager.v3.IFolder, - protos.google.cloud.resourcemanager.v3.IGetFolderRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getFolder(request, options, callback); - } -/** - * Gets the access control policy for a folder. The returned policy may be - * empty if no such policy or resource exists. The `resource` field should - * be the folder's resource name, for example: "folders/1234". - * The caller must have `resourcemanager.folders.getIamPolicy` permission - * on the identified folder. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/folders.get_iam_policy.js - * region_tag:cloudresourcemanager_v3_generated_Folders_GetIamPolicy_async - */ - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.getIamPolicy(request, options, callback); - } -/** - * Sets the access control policy on a folder, replacing any existing policy. - * The `resource` field should be the folder's resource name, for example: - * "folders/1234". - * The caller must have `resourcemanager.folders.setIamPolicy` permission - * on the identified folder. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/folders.set_iam_policy.js - * region_tag:cloudresourcemanager_v3_generated_Folders_SetIamPolicy_async - */ - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.setIamPolicy(request, options, callback); - } -/** - * Returns permissions that a caller has on the specified folder. - * The `resource` field should be the folder's resource name, - * for example: "folders/1234". - * - * There are no permissions required for making this API call. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/folders.test_iam_permissions.js - * region_tag:cloudresourcemanager_v3_generated_Folders_TestIamPermissions_async - */ - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.testIamPermissions(request, options, callback); - } - -/** - * Creates a folder in the resource hierarchy. - * Returns an `Operation` which can be used to track the progress of the - * folder creation workflow. - * Upon success, the `Operation.response` field will be populated with the - * created Folder. - * - * In order to succeed, the addition of this new folder must not violate - * the folder naming, height, or fanout constraints. - * - * + The folder's `display_name` must be distinct from all other folders that - * share its parent. - * + The addition of the folder must not cause the active folder hierarchy - * to exceed a height of 10. Note, the full active + deleted folder hierarchy - * is allowed to reach a height of 20; this provides additional headroom when - * moving folders that contain deleted folders. - * + The addition of the folder must not cause the total number of folders - * under its parent to exceed 300. - * - * If the operation fails due to a folder constraint violation, some errors - * may be returned by the `CreateFolder` request, with status code - * `FAILED_PRECONDITION` and an error description. Other folder constraint - * violations will be communicated in the `Operation`, with the specific - * `PreconditionFailure` returned in the details list in the `Operation.error` - * field. - * - * The caller must have `resourcemanager.folders.create` permission on the - * identified parent. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.resourcemanager.v3.Folder} request.folder - * Required. The folder being created, only the display name and parent will - * be consulted. All other fields will be 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/folders.create_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_CreateFolder_async - */ - createFolder( - request?: protos.google.cloud.resourcemanager.v3.ICreateFolderRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createFolder( - request: protos.google.cloud.resourcemanager.v3.ICreateFolderRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createFolder( - request: protos.google.cloud.resourcemanager.v3.ICreateFolderRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createFolder( - request?: protos.google.cloud.resourcemanager.v3.ICreateFolderRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.createFolder(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createFolder()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/folders.create_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_CreateFolder_async - */ - async checkCreateFolderProgress(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.createFolder, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates a folder, changing its `display_name`. - * Changes to the folder `display_name` will be rejected if they violate - * either the `display_name` formatting rules or the naming constraints - * described in the - * {@link protos.google.cloud.resourcemanager.v3.Folders.CreateFolder|CreateFolder} - * documentation. - * - * The folder's `display_name` must start and end with a letter or digit, - * may contain letters, digits, spaces, hyphens and underscores and can be - * between 3 and 30 characters. This is captured by the regular expression: - * `{@link protos.\p{L}\p{N}_- |\p{L}\p{N}}{1,28}[\p{L}\p{N}]`. - * The caller must have `resourcemanager.folders.update` permission on the - * identified folder. - * - * If the update fails due to the unique name constraint then a - * `PreconditionFailure` explaining this violation will be returned - * in the Status.details field. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.resourcemanager.v3.Folder} request.folder - * Required. The new definition of the Folder. It must include the `name` - * field, which cannot be changed. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Fields to be updated. - * Only the `display_name` can be 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/folders.update_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_UpdateFolder_async - */ - updateFolder( - request?: protos.google.cloud.resourcemanager.v3.IUpdateFolderRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateFolder( - request: protos.google.cloud.resourcemanager.v3.IUpdateFolderRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateFolder( - request: protos.google.cloud.resourcemanager.v3.IUpdateFolderRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateFolder( - request?: protos.google.cloud.resourcemanager.v3.IUpdateFolderRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'folder.name': request.folder!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateFolder(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateFolder()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/folders.update_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_UpdateFolder_async - */ - async checkUpdateFolderProgress(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.updateFolder, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Moves a folder under a new resource parent. - * Returns an `Operation` which can be used to track the progress of the - * folder move workflow. - * Upon success, the `Operation.response` field will be populated with the - * moved folder. - * Upon failure, a `FolderOperationError` categorizing the failure cause will - * be returned - if the failure occurs synchronously then the - * `FolderOperationError` will be returned in the `Status.details` field. - * If it occurs asynchronously, then the FolderOperation will be returned - * in the `Operation.error` field. - * In addition, the `Operation.metadata` field will be populated with a - * `FolderOperation` message as an aid to stateless clients. - * Folder moves will be rejected if they violate either the naming, height, - * or fanout constraints described in the - * {@link protos.google.cloud.resourcemanager.v3.Folders.CreateFolder|CreateFolder} - * documentation. The caller must have `resourcemanager.folders.move` - * permission on the folder's current and proposed new parent. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Folder to move. - * Must be of the form folders/{folder_id} - * @param {string} request.destinationParent - * Required. The resource name of the folder or organization which should be - * the folder's new parent. Must be of the form `folders/{folder_id}` or - * `organizations/{org_id}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/folders.move_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_MoveFolder_async - */ - moveFolder( - request?: protos.google.cloud.resourcemanager.v3.IMoveFolderRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - moveFolder( - request: protos.google.cloud.resourcemanager.v3.IMoveFolderRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - moveFolder( - request: protos.google.cloud.resourcemanager.v3.IMoveFolderRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - moveFolder( - request?: protos.google.cloud.resourcemanager.v3.IMoveFolderRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.moveFolder(request, options, callback); - } -/** - * Check the status of the long running operation returned by `moveFolder()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/folders.move_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_MoveFolder_async - */ - async checkMoveFolderProgress(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.moveFolder, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Requests deletion of a folder. The folder is moved into the - * {@link protos.google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED|DELETE_REQUESTED} - * state immediately, and is deleted approximately 30 days later. This method - * may only be called on an empty folder, where a folder is empty if it - * doesn't contain any folders or projects in the - * {@link protos.google.cloud.resourcemanager.v3.Folder.State.ACTIVE|ACTIVE} state. If - * called on a folder in - * {@link protos.google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED|DELETE_REQUESTED} - * state the operation will result in a no-op success. - * The caller must have `resourcemanager.folders.delete` permission on the - * identified folder. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the folder to be deleted. - * Must be of the form `folders/{folder_id}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/folders.delete_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_DeleteFolder_async - */ - deleteFolder( - request?: protos.google.cloud.resourcemanager.v3.IDeleteFolderRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteFolder( - request: protos.google.cloud.resourcemanager.v3.IDeleteFolderRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteFolder( - request: protos.google.cloud.resourcemanager.v3.IDeleteFolderRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteFolder( - request?: protos.google.cloud.resourcemanager.v3.IDeleteFolderRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteFolder(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteFolder()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/folders.delete_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_DeleteFolder_async - */ - async checkDeleteFolderProgress(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.deleteFolder, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Cancels the deletion request for a folder. This method may be called on a - * folder in any state. If the folder is in the - * {@link protos.google.cloud.resourcemanager.v3.Folder.State.ACTIVE|ACTIVE} state the - * result will be a no-op success. In order to succeed, the folder's parent - * must be in the - * {@link protos.google.cloud.resourcemanager.v3.Folder.State.ACTIVE|ACTIVE} state. In - * addition, reintroducing the folder into the tree must not violate folder - * naming, height, and fanout constraints described in the - * {@link protos.google.cloud.resourcemanager.v3.Folders.CreateFolder|CreateFolder} - * documentation. The caller must have `resourcemanager.folders.undelete` - * permission on the identified folder. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the folder to undelete. - * Must be of the form `folders/{folder_id}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/folders.undelete_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_UndeleteFolder_async - */ - undeleteFolder( - request?: protos.google.cloud.resourcemanager.v3.IUndeleteFolderRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - undeleteFolder( - request: protos.google.cloud.resourcemanager.v3.IUndeleteFolderRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - undeleteFolder( - request: protos.google.cloud.resourcemanager.v3.IUndeleteFolderRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - undeleteFolder( - request?: protos.google.cloud.resourcemanager.v3.IUndeleteFolderRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.undeleteFolder(request, options, callback); - } -/** - * Check the status of the long running operation returned by `undeleteFolder()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/folders.undelete_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_UndeleteFolder_async - */ - async checkUndeleteFolderProgress(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.undeleteFolder, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists the folders that are direct descendants of supplied parent resource. - * `list()` provides a strongly consistent view of the folders underneath - * the specified parent resource. - * `list()` returns folders sorted based upon the (ascending) lexical ordering - * of their display_name. - * The caller must have `resourcemanager.folders.list` permission on the - * identified parent. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource whose folders are being listed. - * Only children of this parent resource are listed; descendants are not - * listed. - * - * If the parent is a folder, use the value `folders/{folder_id}`. If the - * parent is an organization, use the value `organizations/{org_id}`. - * - * Access to this method is controlled by checking the - * `resourcemanager.folders.list` permission on the `parent`. - * @param {number} [request.pageSize] - * Optional. The maximum number of folders to return in the response. The - * server can return fewer folders than requested. If unspecified, server - * picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `ListFolders` - * that indicates where this listing should continue from. - * @param {boolean} [request.showDeleted] - * Optional. Controls whether folders in the - * {@link protos.google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED|DELETE_REQUESTED} - * state should be returned. Defaults to false. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.resourcemanager.v3.Folder|Folder}. - * 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 `listFoldersAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listFolders( - request?: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.IFolder[], - protos.google.cloud.resourcemanager.v3.IListFoldersRequest|null, - protos.google.cloud.resourcemanager.v3.IListFoldersResponse - ]>; - listFolders( - request: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListFoldersRequest, - protos.google.cloud.resourcemanager.v3.IListFoldersResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IFolder>): void; - listFolders( - request: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListFoldersRequest, - protos.google.cloud.resourcemanager.v3.IListFoldersResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IFolder>): void; - listFolders( - request?: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListFoldersRequest, - protos.google.cloud.resourcemanager.v3.IListFoldersResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IFolder>, - callback?: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListFoldersRequest, - protos.google.cloud.resourcemanager.v3.IListFoldersResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IFolder>): - Promise<[ - protos.google.cloud.resourcemanager.v3.IFolder[], - protos.google.cloud.resourcemanager.v3.IListFoldersRequest|null, - protos.google.cloud.resourcemanager.v3.IListFoldersResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.listFolders(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 name of the parent resource whose folders are being listed. - * Only children of this parent resource are listed; descendants are not - * listed. - * - * If the parent is a folder, use the value `folders/{folder_id}`. If the - * parent is an organization, use the value `organizations/{org_id}`. - * - * Access to this method is controlled by checking the - * `resourcemanager.folders.list` permission on the `parent`. - * @param {number} [request.pageSize] - * Optional. The maximum number of folders to return in the response. The - * server can return fewer folders than requested. If unspecified, server - * picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `ListFolders` - * that indicates where this listing should continue from. - * @param {boolean} [request.showDeleted] - * Optional. Controls whether folders in the - * {@link protos.google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED|DELETE_REQUESTED} - * state should be returned. Defaults to false. - * @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 protos.google.cloud.resourcemanager.v3.Folder|Folder} 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 `listFoldersAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listFoldersStream( - request?: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listFolders']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listFolders.createStream( - this.innerApiCalls.listFolders as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listFolders`, 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 name of the parent resource whose folders are being listed. - * Only children of this parent resource are listed; descendants are not - * listed. - * - * If the parent is a folder, use the value `folders/{folder_id}`. If the - * parent is an organization, use the value `organizations/{org_id}`. - * - * Access to this method is controlled by checking the - * `resourcemanager.folders.list` permission on the `parent`. - * @param {number} [request.pageSize] - * Optional. The maximum number of folders to return in the response. The - * server can return fewer folders than requested. If unspecified, server - * picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `ListFolders` - * that indicates where this listing should continue from. - * @param {boolean} [request.showDeleted] - * Optional. Controls whether folders in the - * {@link protos.google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED|DELETE_REQUESTED} - * state should be returned. Defaults to false. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.resourcemanager.v3.Folder|Folder}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v3/folders.list_folders.js - * region_tag:cloudresourcemanager_v3_generated_Folders_ListFolders_async - */ - listFoldersAsync( - request?: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listFolders']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listFolders.asyncIterate( - this.innerApiCalls['listFolders'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Search for folders that match specific filter criteria. - * `search()` provides an eventually consistent view of the folders a user has - * access to which meet the specified filter criteria. - * - * This will only return folders on which the caller has the - * permission `resourcemanager.folders.get`. - * - * @param {Object} request - * The request object that will be sent. - * @param {number} [request.pageSize] - * Optional. The maximum number of folders to return in the response. The - * server can return fewer folders than requested. If unspecified, server - * picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * `SearchFolders` that indicates from where search should continue. - * @param {string} [request.query] - * Optional. Search criteria used to select the folders to return. - * If no search criteria is specified then all accessible folders will be - * returned. - * - * Query expressions can be used to restrict results based upon displayName, - * state and parent, where the operators `=` (`:`) `NOT`, `AND` and `OR` - * can be used along with the suffix wildcard symbol `*`. - * - * The `displayName` field in a query expression should use escaped quotes - * for values that include whitespace to prevent unexpected behavior. - * - * ``` - * | Field | Description | - * |-------------------------|----------------------------------------| - * | displayName | Filters by displayName. | - * | parent | Filters by parent (for example: folders/123). | - * | state, lifecycleState | Filters by state. | - * ``` - * - * Some example queries are: - * - * * Query `displayName=Test*` returns Folder resources whose display name - * starts with "Test". - * * Query `state=ACTIVE` returns Folder resources with - * `state` set to `ACTIVE`. - * * Query `parent=folders/123` returns Folder resources that have - * `folders/123` as a parent resource. - * * Query `parent=folders/123 AND state=ACTIVE` returns active - * Folder resources that have `folders/123` as a parent resource. - * * Query `displayName=\\"Test String\\"` returns Folder resources with - * display names that include both "Test" and "String". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.resourcemanager.v3.Folder|Folder}. - * 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 `searchFoldersAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - searchFolders( - request?: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.IFolder[], - protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest|null, - protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse - ]>; - searchFolders( - request: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, - protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IFolder>): void; - searchFolders( - request: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, - protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IFolder>): void; - searchFolders( - request?: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, - protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IFolder>, - callback?: PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, - protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IFolder>): - Promise<[ - protos.google.cloud.resourcemanager.v3.IFolder[], - protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest|null, - protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.searchFolders(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 {number} [request.pageSize] - * Optional. The maximum number of folders to return in the response. The - * server can return fewer folders than requested. If unspecified, server - * picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * `SearchFolders` that indicates from where search should continue. - * @param {string} [request.query] - * Optional. Search criteria used to select the folders to return. - * If no search criteria is specified then all accessible folders will be - * returned. - * - * Query expressions can be used to restrict results based upon displayName, - * state and parent, where the operators `=` (`:`) `NOT`, `AND` and `OR` - * can be used along with the suffix wildcard symbol `*`. - * - * The `displayName` field in a query expression should use escaped quotes - * for values that include whitespace to prevent unexpected behavior. - * - * ``` - * | Field | Description | - * |-------------------------|----------------------------------------| - * | displayName | Filters by displayName. | - * | parent | Filters by parent (for example: folders/123). | - * | state, lifecycleState | Filters by state. | - * ``` - * - * Some example queries are: - * - * * Query `displayName=Test*` returns Folder resources whose display name - * starts with "Test". - * * Query `state=ACTIVE` returns Folder resources with - * `state` set to `ACTIVE`. - * * Query `parent=folders/123` returns Folder resources that have - * `folders/123` as a parent resource. - * * Query `parent=folders/123 AND state=ACTIVE` returns active - * Folder resources that have `folders/123` as a parent resource. - * * Query `displayName=\\"Test String\\"` returns Folder resources with - * display names that include both "Test" and "String". - * @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 protos.google.cloud.resourcemanager.v3.Folder|Folder} 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 `searchFoldersAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - searchFoldersStream( - request?: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['searchFolders']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchFolders.createStream( - this.innerApiCalls.searchFolders as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `searchFolders`, 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 {number} [request.pageSize] - * Optional. The maximum number of folders to return in the response. The - * server can return fewer folders than requested. If unspecified, server - * picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * `SearchFolders` that indicates from where search should continue. - * @param {string} [request.query] - * Optional. Search criteria used to select the folders to return. - * If no search criteria is specified then all accessible folders will be - * returned. - * - * Query expressions can be used to restrict results based upon displayName, - * state and parent, where the operators `=` (`:`) `NOT`, `AND` and `OR` - * can be used along with the suffix wildcard symbol `*`. - * - * The `displayName` field in a query expression should use escaped quotes - * for values that include whitespace to prevent unexpected behavior. - * - * ``` - * | Field | Description | - * |-------------------------|----------------------------------------| - * | displayName | Filters by displayName. | - * | parent | Filters by parent (for example: folders/123). | - * | state, lifecycleState | Filters by state. | - * ``` - * - * Some example queries are: - * - * * Query `displayName=Test*` returns Folder resources whose display name - * starts with "Test". - * * Query `state=ACTIVE` returns Folder resources with - * `state` set to `ACTIVE`. - * * Query `parent=folders/123` returns Folder resources that have - * `folders/123` as a parent resource. - * * Query `parent=folders/123 AND state=ACTIVE` returns active - * Folder resources that have `folders/123` as a parent resource. - * * Query `displayName=\\"Test String\\"` returns Folder resources with - * display names that include both "Test" and "String". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.resourcemanager.v3.Folder|Folder}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v3/folders.search_folders.js - * region_tag:cloudresourcemanager_v3_generated_Folders_SearchFolders_async - */ - searchFoldersAsync( - request?: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['searchFolders']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchFolders.asyncIterate( - this.innerApiCalls['searchFolders'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * 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 folder resource name string. - * - * @param {string} folder - * @returns {string} Resource name string. - */ - folderPath(folder:string) { - return this.pathTemplates.folderPathTemplate.render({ - folder: folder, - }); - } - - /** - * Parse the folder from Folder resource. - * - * @param {string} folderName - * A fully-qualified path representing Folder resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderName(folderName: string) { - return this.pathTemplates.folderPathTemplate.match(folderName).folder; - } - - /** - * Return a fully-qualified organization resource name string. - * - * @param {string} organization - * @returns {string} Resource name string. - */ - organizationPath(organization:string) { - return this.pathTemplates.organizationPathTemplate.render({ - organization: organization, - }); - } - - /** - * Parse the organization from Organization resource. - * - * @param {string} organizationName - * A fully-qualified path representing Organization resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationName(organizationName: string) { - return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified tagBinding resource name string. - * - * @param {string} tag_binding - * @returns {string} Resource name string. - */ - tagBindingPath(tagBinding:string) { - return this.pathTemplates.tagBindingPathTemplate.render({ - tag_binding: tagBinding, - }); - } - - /** - * Parse the tag_binding from TagBinding resource. - * - * @param {string} tagBindingName - * A fully-qualified path representing TagBinding resource. - * @returns {string} A string representing the tag_binding. - */ - matchTagBindingFromTagBindingName(tagBindingName: string) { - return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; - } - - /** - * Return a fully-qualified tagHold resource name string. - * - * @param {string} tag_value - * @param {string} tag_hold - * @returns {string} Resource name string. - */ - tagHoldPath(tagValue:string,tagHold:string) { - return this.pathTemplates.tagHoldPathTemplate.render({ - tag_value: tagValue, - tag_hold: tagHold, - }); - } - - /** - * Parse the tag_value from TagHold resource. - * - * @param {string} tagHoldName - * A fully-qualified path representing TagHold resource. - * @returns {string} A string representing the tag_value. - */ - matchTagValueFromTagHoldName(tagHoldName: string) { - return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_value; - } - - /** - * Parse the tag_hold from TagHold resource. - * - * @param {string} tagHoldName - * A fully-qualified path representing TagHold resource. - * @returns {string} A string representing the tag_hold. - */ - matchTagHoldFromTagHoldName(tagHoldName: string) { - return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_hold; - } - - /** - * Return a fully-qualified tagKey resource name string. - * - * @param {string} tag_key - * @returns {string} Resource name string. - */ - tagKeyPath(tagKey:string) { - return this.pathTemplates.tagKeyPathTemplate.render({ - tag_key: tagKey, - }); - } - - /** - * Parse the tag_key from TagKey resource. - * - * @param {string} tagKeyName - * A fully-qualified path representing TagKey resource. - * @returns {string} A string representing the tag_key. - */ - matchTagKeyFromTagKeyName(tagKeyName: string) { - return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; - } - - /** - * Return a fully-qualified tagValue resource name string. - * - * @param {string} tag_value - * @returns {string} Resource name string. - */ - tagValuePath(tagValue:string) { - return this.pathTemplates.tagValuePathTemplate.render({ - tag_value: tagValue, - }); - } - - /** - * Parse the tag_value from TagValue resource. - * - * @param {string} tagValueName - * A fully-qualified path representing TagValue resource. - * @returns {string} A string representing the tag_value. - */ - matchTagValueFromTagValueName(tagValueName: string) { - return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; - } - - /** - * 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.foldersStub && !this._terminated) { - return this.foldersStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_client_config.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_client_config.json deleted file mode 100644 index a2bed85d6e8..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_client_config.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "interfaces": { - "google.cloud.resourcemanager.v3.Folders": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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": { - "GetFolder": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "ListFolders": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "SearchFolders": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateFolder": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateFolder": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "MoveFolder": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteFolder": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UndeleteFolder": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "SetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "TestIamPermissions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_proto_list.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_proto_list.json deleted file mode 100644 index 639794aadd4..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/folders_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/cloud/resourcemanager/v3/folders.proto", - "../../protos/google/cloud/resourcemanager/v3/organizations.proto", - "../../protos/google/cloud/resourcemanager/v3/projects.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_holds.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" -] diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/gapic_metadata.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/gapic_metadata.json deleted file mode 100644 index c68b1fa08e0..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/gapic_metadata.json +++ /dev/null @@ -1,667 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.resourcemanager.v3", - "libraryPackage": "@google-cloud/resource-manager", - "services": { - "Folders": { - "clients": { - "grpc": { - "libraryClient": "FoldersClient", - "rpcs": { - "GetFolder": { - "methods": [ - "getFolder" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateFolder": { - "methods": [ - "createFolder" - ] - }, - "UpdateFolder": { - "methods": [ - "updateFolder" - ] - }, - "MoveFolder": { - "methods": [ - "moveFolder" - ] - }, - "DeleteFolder": { - "methods": [ - "deleteFolder" - ] - }, - "UndeleteFolder": { - "methods": [ - "undeleteFolder" - ] - }, - "ListFolders": { - "methods": [ - "listFolders", - "listFoldersStream", - "listFoldersAsync" - ] - }, - "SearchFolders": { - "methods": [ - "searchFolders", - "searchFoldersStream", - "searchFoldersAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "FoldersClient", - "rpcs": { - "GetFolder": { - "methods": [ - "getFolder" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateFolder": { - "methods": [ - "createFolder" - ] - }, - "UpdateFolder": { - "methods": [ - "updateFolder" - ] - }, - "MoveFolder": { - "methods": [ - "moveFolder" - ] - }, - "DeleteFolder": { - "methods": [ - "deleteFolder" - ] - }, - "UndeleteFolder": { - "methods": [ - "undeleteFolder" - ] - }, - "ListFolders": { - "methods": [ - "listFolders", - "listFoldersStream", - "listFoldersAsync" - ] - }, - "SearchFolders": { - "methods": [ - "searchFolders", - "searchFoldersStream", - "searchFoldersAsync" - ] - } - } - } - } - }, - "Organizations": { - "clients": { - "grpc": { - "libraryClient": "OrganizationsClient", - "rpcs": { - "GetOrganization": { - "methods": [ - "getOrganization" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "SearchOrganizations": { - "methods": [ - "searchOrganizations", - "searchOrganizationsStream", - "searchOrganizationsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "OrganizationsClient", - "rpcs": { - "GetOrganization": { - "methods": [ - "getOrganization" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "SearchOrganizations": { - "methods": [ - "searchOrganizations", - "searchOrganizationsStream", - "searchOrganizationsAsync" - ] - } - } - } - } - }, - "Projects": { - "clients": { - "grpc": { - "libraryClient": "ProjectsClient", - "rpcs": { - "GetProject": { - "methods": [ - "getProject" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateProject": { - "methods": [ - "createProject" - ] - }, - "UpdateProject": { - "methods": [ - "updateProject" - ] - }, - "MoveProject": { - "methods": [ - "moveProject" - ] - }, - "DeleteProject": { - "methods": [ - "deleteProject" - ] - }, - "UndeleteProject": { - "methods": [ - "undeleteProject" - ] - }, - "ListProjects": { - "methods": [ - "listProjects", - "listProjectsStream", - "listProjectsAsync" - ] - }, - "SearchProjects": { - "methods": [ - "searchProjects", - "searchProjectsStream", - "searchProjectsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ProjectsClient", - "rpcs": { - "GetProject": { - "methods": [ - "getProject" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateProject": { - "methods": [ - "createProject" - ] - }, - "UpdateProject": { - "methods": [ - "updateProject" - ] - }, - "MoveProject": { - "methods": [ - "moveProject" - ] - }, - "DeleteProject": { - "methods": [ - "deleteProject" - ] - }, - "UndeleteProject": { - "methods": [ - "undeleteProject" - ] - }, - "ListProjects": { - "methods": [ - "listProjects", - "listProjectsStream", - "listProjectsAsync" - ] - }, - "SearchProjects": { - "methods": [ - "searchProjects", - "searchProjectsStream", - "searchProjectsAsync" - ] - } - } - } - } - }, - "TagBindings": { - "clients": { - "grpc": { - "libraryClient": "TagBindingsClient", - "rpcs": { - "CreateTagBinding": { - "methods": [ - "createTagBinding" - ] - }, - "DeleteTagBinding": { - "methods": [ - "deleteTagBinding" - ] - }, - "ListTagBindings": { - "methods": [ - "listTagBindings", - "listTagBindingsStream", - "listTagBindingsAsync" - ] - }, - "ListEffectiveTags": { - "methods": [ - "listEffectiveTags", - "listEffectiveTagsStream", - "listEffectiveTagsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "TagBindingsClient", - "rpcs": { - "CreateTagBinding": { - "methods": [ - "createTagBinding" - ] - }, - "DeleteTagBinding": { - "methods": [ - "deleteTagBinding" - ] - }, - "ListTagBindings": { - "methods": [ - "listTagBindings", - "listTagBindingsStream", - "listTagBindingsAsync" - ] - }, - "ListEffectiveTags": { - "methods": [ - "listEffectiveTags", - "listEffectiveTagsStream", - "listEffectiveTagsAsync" - ] - } - } - } - } - }, - "TagHolds": { - "clients": { - "grpc": { - "libraryClient": "TagHoldsClient", - "rpcs": { - "CreateTagHold": { - "methods": [ - "createTagHold" - ] - }, - "DeleteTagHold": { - "methods": [ - "deleteTagHold" - ] - }, - "ListTagHolds": { - "methods": [ - "listTagHolds", - "listTagHoldsStream", - "listTagHoldsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "TagHoldsClient", - "rpcs": { - "CreateTagHold": { - "methods": [ - "createTagHold" - ] - }, - "DeleteTagHold": { - "methods": [ - "deleteTagHold" - ] - }, - "ListTagHolds": { - "methods": [ - "listTagHolds", - "listTagHoldsStream", - "listTagHoldsAsync" - ] - } - } - } - } - }, - "TagKeys": { - "clients": { - "grpc": { - "libraryClient": "TagKeysClient", - "rpcs": { - "GetTagKey": { - "methods": [ - "getTagKey" - ] - }, - "GetNamespacedTagKey": { - "methods": [ - "getNamespacedTagKey" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateTagKey": { - "methods": [ - "createTagKey" - ] - }, - "UpdateTagKey": { - "methods": [ - "updateTagKey" - ] - }, - "DeleteTagKey": { - "methods": [ - "deleteTagKey" - ] - }, - "ListTagKeys": { - "methods": [ - "listTagKeys", - "listTagKeysStream", - "listTagKeysAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "TagKeysClient", - "rpcs": { - "GetTagKey": { - "methods": [ - "getTagKey" - ] - }, - "GetNamespacedTagKey": { - "methods": [ - "getNamespacedTagKey" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateTagKey": { - "methods": [ - "createTagKey" - ] - }, - "UpdateTagKey": { - "methods": [ - "updateTagKey" - ] - }, - "DeleteTagKey": { - "methods": [ - "deleteTagKey" - ] - }, - "ListTagKeys": { - "methods": [ - "listTagKeys", - "listTagKeysStream", - "listTagKeysAsync" - ] - } - } - } - } - }, - "TagValues": { - "clients": { - "grpc": { - "libraryClient": "TagValuesClient", - "rpcs": { - "GetTagValue": { - "methods": [ - "getTagValue" - ] - }, - "GetNamespacedTagValue": { - "methods": [ - "getNamespacedTagValue" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateTagValue": { - "methods": [ - "createTagValue" - ] - }, - "UpdateTagValue": { - "methods": [ - "updateTagValue" - ] - }, - "DeleteTagValue": { - "methods": [ - "deleteTagValue" - ] - }, - "ListTagValues": { - "methods": [ - "listTagValues", - "listTagValuesStream", - "listTagValuesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "TagValuesClient", - "rpcs": { - "GetTagValue": { - "methods": [ - "getTagValue" - ] - }, - "GetNamespacedTagValue": { - "methods": [ - "getNamespacedTagValue" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateTagValue": { - "methods": [ - "createTagValue" - ] - }, - "UpdateTagValue": { - "methods": [ - "updateTagValue" - ] - }, - "DeleteTagValue": { - "methods": [ - "deleteTagValue" - ] - }, - "ListTagValues": { - "methods": [ - "listTagValues", - "listTagValuesStream", - "listTagValuesAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/index.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/index.ts deleted file mode 100644 index a6fde064886..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/index.ts +++ /dev/null @@ -1,25 +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 {FoldersClient} from './folders_client'; -export {OrganizationsClient} from './organizations_client'; -export {ProjectsClient} from './projects_client'; -export {TagBindingsClient} from './tag_bindings_client'; -export {TagHoldsClient} from './tag_holds_client'; -export {TagKeysClient} from './tag_keys_client'; -export {TagValuesClient} from './tag_values_client'; diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_client.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_client.ts deleted file mode 100644 index 71e727d549f..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_client.ts +++ /dev/null @@ -1,1063 +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, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v3/organizations_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './organizations_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Allows users to manage their organization resources. - * @class - * @memberof v3 - */ -export class OrganizationsClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - organizationsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of OrganizationsClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 OrganizationsClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof OrganizationsClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - folderPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}' - ), - organizationPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - tagBindingPathTemplate: new this._gaxModule.PathTemplate( - 'tagBindings/{tag_binding}' - ), - tagHoldPathTemplate: new this._gaxModule.PathTemplate( - 'tagValues/{tag_value}/tagHolds/{tag_hold}' - ), - tagKeyPathTemplate: new this._gaxModule.PathTemplate( - 'tagKeys/{tag_key}' - ), - tagValuePathTemplate: new this._gaxModule.PathTemplate( - 'tagValues/{tag_value}' - ), - }; - - // 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 = { - searchOrganizations: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'organizations') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.resourcemanager.v3.Organizations', 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.organizationsStub) { - return this.organizationsStub; - } - - // Put together the "service stub" for - // google.cloud.resourcemanager.v3.Organizations. - this.organizationsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.Organizations') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.resourcemanager.v3.Organizations, - 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 organizationsStubMethods = - ['getOrganization', 'searchOrganizations', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; - for (const methodName of organizationsStubMethods) { - const callPromise = this.organizationsStub.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.organizationsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudresourcemanager.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 'cloudresourcemanager.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only' - ]; - } - - 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 -- - // ------------------- -/** - * Fetches an organization resource identified by the specified resource name. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Organization to fetch. This is the - * organization's relative path in the API, formatted as - * "organizations/[organizationId]". For example, "organizations/1234". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.resourcemanager.v3.Organization|Organization}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/organizations.get_organization.js - * region_tag:cloudresourcemanager_v3_generated_Organizations_GetOrganization_async - */ - getOrganization( - request?: protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.IOrganization, - protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|undefined, {}|undefined - ]>; - getOrganization( - request: protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.resourcemanager.v3.IOrganization, - protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|null|undefined, - {}|null|undefined>): void; - getOrganization( - request: protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest, - callback: Callback< - protos.google.cloud.resourcemanager.v3.IOrganization, - protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|null|undefined, - {}|null|undefined>): void; - getOrganization( - request?: protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.resourcemanager.v3.IOrganization, - protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.resourcemanager.v3.IOrganization, - protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.resourcemanager.v3.IOrganization, - protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getOrganization(request, options, callback); - } -/** - * Gets the access control policy for an organization resource. The policy may - * be empty if no such policy or resource exists. The `resource` field should - * be the organization's resource name, for example: "organizations/123". - * - * Authorization requires the IAM permission - * `resourcemanager.organizations.getIamPolicy` on the specified organization. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/organizations.get_iam_policy.js - * region_tag:cloudresourcemanager_v3_generated_Organizations_GetIamPolicy_async - */ - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.getIamPolicy(request, options, callback); - } -/** - * Sets the access control policy on an organization resource. Replaces any - * existing policy. The `resource` field should be the organization's resource - * name, for example: "organizations/123". - * - * Authorization requires the IAM permission - * `resourcemanager.organizations.setIamPolicy` on the specified organization. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/organizations.set_iam_policy.js - * region_tag:cloudresourcemanager_v3_generated_Organizations_SetIamPolicy_async - */ - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.setIamPolicy(request, options, callback); - } -/** - * Returns the permissions that a caller has on the specified organization. - * The `resource` field should be the organization's resource name, - * for example: "organizations/123". - * - * There are no permissions required for making this API call. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/organizations.test_iam_permissions.js - * region_tag:cloudresourcemanager_v3_generated_Organizations_TestIamPermissions_async - */ - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.testIamPermissions(request, options, callback); - } - - /** - * Searches organization resources that are visible to the user and satisfy - * the specified filter. This method returns organizations in an unspecified - * order. New organizations do not necessarily appear at the end of the - * results, and may take a small amount of time to appear. - * - * Search will only return organizations on which the user has the permission - * `resourcemanager.organizations.get` - * - * @param {Object} request - * The request object that will be sent. - * @param {number} [request.pageSize] - * Optional. The maximum number of organizations to return in the response. - * The server can return fewer organizations than requested. If unspecified, - * server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * `SearchOrganizations` that indicates from where listing should continue. - * @param {string} [request.query] - * Optional. An optional query string used to filter the Organizations to - * return in the response. Query rules are case-insensitive. - * - * - * ``` - * | Field | Description | - * |------------------|--------------------------------------------| - * | directoryCustomerId, owner.directoryCustomerId | Filters by directory - * customer id. | - * | domain | Filters by domain. | - * ``` - * - * Organizations may be queried by `directoryCustomerId` or by - * `domain`, where the domain is a G Suite domain, for example: - * - * * Query `directorycustomerid:123456789` returns Organization - * resources with `owner.directory_customer_id` equal to `123456789`. - * * Query `domain:google.com` returns Organization resources corresponding - * to the domain `google.com`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.resourcemanager.v3.Organization|Organization}. - * 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 `searchOrganizationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - searchOrganizations( - request?: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.IOrganization[], - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest|null, - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse - ]>; - searchOrganizations( - request: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IOrganization>): void; - searchOrganizations( - request: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IOrganization>): void; - searchOrganizations( - request?: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IOrganization>, - callback?: PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IOrganization>): - Promise<[ - protos.google.cloud.resourcemanager.v3.IOrganization[], - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest|null, - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.searchOrganizations(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 {number} [request.pageSize] - * Optional. The maximum number of organizations to return in the response. - * The server can return fewer organizations than requested. If unspecified, - * server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * `SearchOrganizations` that indicates from where listing should continue. - * @param {string} [request.query] - * Optional. An optional query string used to filter the Organizations to - * return in the response. Query rules are case-insensitive. - * - * - * ``` - * | Field | Description | - * |------------------|--------------------------------------------| - * | directoryCustomerId, owner.directoryCustomerId | Filters by directory - * customer id. | - * | domain | Filters by domain. | - * ``` - * - * Organizations may be queried by `directoryCustomerId` or by - * `domain`, where the domain is a G Suite domain, for example: - * - * * Query `directorycustomerid:123456789` returns Organization - * resources with `owner.directory_customer_id` equal to `123456789`. - * * Query `domain:google.com` returns Organization resources corresponding - * to the domain `google.com`. - * @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 protos.google.cloud.resourcemanager.v3.Organization|Organization} 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 `searchOrganizationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - searchOrganizationsStream( - request?: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['searchOrganizations']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchOrganizations.createStream( - this.innerApiCalls.searchOrganizations as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `searchOrganizations`, 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 {number} [request.pageSize] - * Optional. The maximum number of organizations to return in the response. - * The server can return fewer organizations than requested. If unspecified, - * server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * `SearchOrganizations` that indicates from where listing should continue. - * @param {string} [request.query] - * Optional. An optional query string used to filter the Organizations to - * return in the response. Query rules are case-insensitive. - * - * - * ``` - * | Field | Description | - * |------------------|--------------------------------------------| - * | directoryCustomerId, owner.directoryCustomerId | Filters by directory - * customer id. | - * | domain | Filters by domain. | - * ``` - * - * Organizations may be queried by `directoryCustomerId` or by - * `domain`, where the domain is a G Suite domain, for example: - * - * * Query `directorycustomerid:123456789` returns Organization - * resources with `owner.directory_customer_id` equal to `123456789`. - * * Query `domain:google.com` returns Organization resources corresponding - * to the domain `google.com`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.resourcemanager.v3.Organization|Organization}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v3/organizations.search_organizations.js - * region_tag:cloudresourcemanager_v3_generated_Organizations_SearchOrganizations_async - */ - searchOrganizationsAsync( - request?: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['searchOrganizations']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchOrganizations.asyncIterate( - this.innerApiCalls['searchOrganizations'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified folder resource name string. - * - * @param {string} folder - * @returns {string} Resource name string. - */ - folderPath(folder:string) { - return this.pathTemplates.folderPathTemplate.render({ - folder: folder, - }); - } - - /** - * Parse the folder from Folder resource. - * - * @param {string} folderName - * A fully-qualified path representing Folder resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderName(folderName: string) { - return this.pathTemplates.folderPathTemplate.match(folderName).folder; - } - - /** - * Return a fully-qualified organization resource name string. - * - * @param {string} organization - * @returns {string} Resource name string. - */ - organizationPath(organization:string) { - return this.pathTemplates.organizationPathTemplate.render({ - organization: organization, - }); - } - - /** - * Parse the organization from Organization resource. - * - * @param {string} organizationName - * A fully-qualified path representing Organization resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationName(organizationName: string) { - return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified tagBinding resource name string. - * - * @param {string} tag_binding - * @returns {string} Resource name string. - */ - tagBindingPath(tagBinding:string) { - return this.pathTemplates.tagBindingPathTemplate.render({ - tag_binding: tagBinding, - }); - } - - /** - * Parse the tag_binding from TagBinding resource. - * - * @param {string} tagBindingName - * A fully-qualified path representing TagBinding resource. - * @returns {string} A string representing the tag_binding. - */ - matchTagBindingFromTagBindingName(tagBindingName: string) { - return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; - } - - /** - * Return a fully-qualified tagHold resource name string. - * - * @param {string} tag_value - * @param {string} tag_hold - * @returns {string} Resource name string. - */ - tagHoldPath(tagValue:string,tagHold:string) { - return this.pathTemplates.tagHoldPathTemplate.render({ - tag_value: tagValue, - tag_hold: tagHold, - }); - } - - /** - * Parse the tag_value from TagHold resource. - * - * @param {string} tagHoldName - * A fully-qualified path representing TagHold resource. - * @returns {string} A string representing the tag_value. - */ - matchTagValueFromTagHoldName(tagHoldName: string) { - return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_value; - } - - /** - * Parse the tag_hold from TagHold resource. - * - * @param {string} tagHoldName - * A fully-qualified path representing TagHold resource. - * @returns {string} A string representing the tag_hold. - */ - matchTagHoldFromTagHoldName(tagHoldName: string) { - return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_hold; - } - - /** - * Return a fully-qualified tagKey resource name string. - * - * @param {string} tag_key - * @returns {string} Resource name string. - */ - tagKeyPath(tagKey:string) { - return this.pathTemplates.tagKeyPathTemplate.render({ - tag_key: tagKey, - }); - } - - /** - * Parse the tag_key from TagKey resource. - * - * @param {string} tagKeyName - * A fully-qualified path representing TagKey resource. - * @returns {string} A string representing the tag_key. - */ - matchTagKeyFromTagKeyName(tagKeyName: string) { - return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; - } - - /** - * Return a fully-qualified tagValue resource name string. - * - * @param {string} tag_value - * @returns {string} Resource name string. - */ - tagValuePath(tagValue:string) { - return this.pathTemplates.tagValuePathTemplate.render({ - tag_value: tagValue, - }); - } - - /** - * Parse the tag_value from TagValue resource. - * - * @param {string} tagValueName - * A fully-qualified path representing TagValue resource. - * @returns {string} A string representing the tag_value. - */ - matchTagValueFromTagValueName(tagValueName: string) { - return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; - } - - /** - * 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.organizationsStub && !this._terminated) { - return this.organizationsStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_client_config.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_client_config.json deleted file mode 100644 index ca62d9146f1..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_client_config.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "interfaces": { - "google.cloud.resourcemanager.v3.Organizations": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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": { - "GetOrganization": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "SearchOrganizations": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "SetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "TestIamPermissions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_proto_list.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_proto_list.json deleted file mode 100644 index 639794aadd4..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/organizations_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/cloud/resourcemanager/v3/folders.proto", - "../../protos/google/cloud/resourcemanager/v3/organizations.proto", - "../../protos/google/cloud/resourcemanager/v3/projects.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_holds.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" -] diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_client.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_client.ts deleted file mode 100644 index e30e12dcbf6..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_client.ts +++ /dev/null @@ -1,2093 +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} 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/v3/projects_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './projects_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Manages Google Cloud Projects. - * @class - * @memberof v3 - */ -export class ProjectsClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - projectsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ProjectsClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 ProjectsClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ProjectsClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - folderPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}' - ), - organizationPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - tagBindingPathTemplate: new this._gaxModule.PathTemplate( - 'tagBindings/{tag_binding}' - ), - tagHoldPathTemplate: new this._gaxModule.PathTemplate( - 'tagValues/{tag_value}/tagHolds/{tag_hold}' - ), - tagKeyPathTemplate: new this._gaxModule.PathTemplate( - 'tagKeys/{tag_key}' - ), - tagValuePathTemplate: new this._gaxModule.PathTemplate( - 'tagValues/{tag_value}' - ), - }; - - // 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 = { - listProjects: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'projects'), - searchProjects: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'projects') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v3/{name=operations/**}',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createProjectResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.Project') as gax.protobuf.Type; - const createProjectMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.CreateProjectMetadata') as gax.protobuf.Type; - const updateProjectResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.Project') as gax.protobuf.Type; - const updateProjectMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.UpdateProjectMetadata') as gax.protobuf.Type; - const moveProjectResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.Project') as gax.protobuf.Type; - const moveProjectMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.MoveProjectMetadata') as gax.protobuf.Type; - const deleteProjectResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.Project') as gax.protobuf.Type; - const deleteProjectMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.DeleteProjectMetadata') as gax.protobuf.Type; - const undeleteProjectResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.Project') as gax.protobuf.Type; - const undeleteProjectMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.UndeleteProjectMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createProject: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createProjectResponse.decode.bind(createProjectResponse), - createProjectMetadata.decode.bind(createProjectMetadata)), - updateProject: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateProjectResponse.decode.bind(updateProjectResponse), - updateProjectMetadata.decode.bind(updateProjectMetadata)), - moveProject: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - moveProjectResponse.decode.bind(moveProjectResponse), - moveProjectMetadata.decode.bind(moveProjectMetadata)), - deleteProject: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteProjectResponse.decode.bind(deleteProjectResponse), - deleteProjectMetadata.decode.bind(deleteProjectMetadata)), - undeleteProject: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - undeleteProjectResponse.decode.bind(undeleteProjectResponse), - undeleteProjectMetadata.decode.bind(undeleteProjectMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.resourcemanager.v3.Projects', 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.projectsStub) { - return this.projectsStub; - } - - // Put together the "service stub" for - // google.cloud.resourcemanager.v3.Projects. - this.projectsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.Projects') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.resourcemanager.v3.Projects, - 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 projectsStubMethods = - ['getProject', 'listProjects', 'searchProjects', 'createProject', 'updateProject', 'moveProject', 'deleteProject', 'undeleteProject', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; - for (const methodName of projectsStubMethods) { - const callPromise = this.projectsStub.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.projectsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudresourcemanager.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 'cloudresourcemanager.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only' - ]; - } - - 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 -- - // ------------------- -/** - * Retrieves the project identified by the specified `name` (for example, - * `projects/415104041262`). - * - * The caller must have `resourcemanager.projects.get` permission - * for this project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the project (for example, `projects/415104041262`). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.resourcemanager.v3.Project|Project}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/projects.get_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_GetProject_async - */ - getProject( - request?: protos.google.cloud.resourcemanager.v3.IGetProjectRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.IProject, - protos.google.cloud.resourcemanager.v3.IGetProjectRequest|undefined, {}|undefined - ]>; - getProject( - request: protos.google.cloud.resourcemanager.v3.IGetProjectRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.resourcemanager.v3.IProject, - protos.google.cloud.resourcemanager.v3.IGetProjectRequest|null|undefined, - {}|null|undefined>): void; - getProject( - request: protos.google.cloud.resourcemanager.v3.IGetProjectRequest, - callback: Callback< - protos.google.cloud.resourcemanager.v3.IProject, - protos.google.cloud.resourcemanager.v3.IGetProjectRequest|null|undefined, - {}|null|undefined>): void; - getProject( - request?: protos.google.cloud.resourcemanager.v3.IGetProjectRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.resourcemanager.v3.IProject, - protos.google.cloud.resourcemanager.v3.IGetProjectRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.resourcemanager.v3.IProject, - protos.google.cloud.resourcemanager.v3.IGetProjectRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.resourcemanager.v3.IProject, - protos.google.cloud.resourcemanager.v3.IGetProjectRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getProject(request, options, callback); - } -/** - * Returns the IAM access control policy for the specified project, in the - * format `projects/{ProjectIdOrNumber}` e.g. projects/123. - * Permission is denied if the policy or the resource do not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/projects.get_iam_policy.js - * region_tag:cloudresourcemanager_v3_generated_Projects_GetIamPolicy_async - */ - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.getIamPolicy(request, options, callback); - } -/** - * Sets the IAM access control policy for the specified project, in the - * format `projects/{ProjectIdOrNumber}` e.g. projects/123. - * - * CAUTION: This method will replace the existing policy, and cannot be used - * to append additional IAM settings. - * - * Note: Removing service accounts from policies or changing their roles can - * render services completely inoperable. It is important to understand how - * the service account is being used before removing or updating its roles. - * - * The following constraints apply when using `setIamPolicy()`: - * - * + Project does not support `allUsers` and `allAuthenticatedUsers` as - * `members` in a `Binding` of a `Policy`. - * - * + The owner role can be granted to a `user`, `serviceAccount`, or a group - * that is part of an organization. For example, - * group@myownpersonaldomain.com could be added as an owner to a project in - * the myownpersonaldomain.com organization, but not the examplepetstore.com - * organization. - * - * + Service accounts can be made owners of a project directly - * without any restrictions. However, to be added as an owner, a user must be - * invited using the Cloud Platform console and must accept the invitation. - * - * + A user cannot be granted the owner role using `setIamPolicy()`. The user - * must be granted the owner role using the Cloud Platform Console and must - * explicitly accept the invitation. - * - * + Invitations to grant the owner role cannot be sent using - * `setIamPolicy()`; - * they must be sent only using the Cloud Platform Console. - * - * + If the project is not part of an organization, there must be at least - * one owner who has accepted the Terms of Service (ToS) agreement in the - * policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner - * from the policy will fail. This restriction also applies to legacy - * projects that no longer have owners who have accepted the ToS. Edits to - * IAM policies will be rejected until the lack of a ToS-accepting owner is - * rectified. If the project is part of an organization, you can remove all - * owners, potentially making the organization inaccessible. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/projects.set_iam_policy.js - * region_tag:cloudresourcemanager_v3_generated_Projects_SetIamPolicy_async - */ - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.setIamPolicy(request, options, callback); - } -/** - * Returns permissions that a caller has on the specified project, in the - * format `projects/{ProjectIdOrNumber}` e.g. projects/123.. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/projects.test_iam_permissions.js - * region_tag:cloudresourcemanager_v3_generated_Projects_TestIamPermissions_async - */ - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.testIamPermissions(request, options, callback); - } - -/** - * Request that a new project be created. The result is an `Operation` which - * can be used to track the creation process. This process usually takes a few - * seconds, but can sometimes take much longer. The tracking `Operation` is - * automatically deleted after a few hours, so there is no need to call - * `DeleteOperation`. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.resourcemanager.v3.Project} request.project - * Required. The Project to create. - * - * Project ID is required. If the requested ID is unavailable, the request - * fails. - * - * If the `parent` field is set, the `resourcemanager.projects.create` - * permission is checked on the parent resource. If no parent is set and - * the authorization credentials belong to an Organization, the parent - * will be set to that Organization. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/projects.create_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_CreateProject_async - */ - createProject( - request?: protos.google.cloud.resourcemanager.v3.ICreateProjectRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createProject( - request: protos.google.cloud.resourcemanager.v3.ICreateProjectRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createProject( - request: protos.google.cloud.resourcemanager.v3.ICreateProjectRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createProject( - request?: protos.google.cloud.resourcemanager.v3.ICreateProjectRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.createProject(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createProject()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/projects.create_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_CreateProject_async - */ - async checkCreateProjectProgress(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.createProject, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the `display_name` and labels of the project identified by the - * specified `name` (for example, `projects/415104041262`). Deleting all - * labels requires an update mask for labels field. - * - * The caller must have `resourcemanager.projects.update` permission for this - * project. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.resourcemanager.v3.Project} request.project - * Required. The new definition of the project. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. An update mask to selectively update 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/projects.update_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_UpdateProject_async - */ - updateProject( - request?: protos.google.cloud.resourcemanager.v3.IUpdateProjectRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateProject( - request: protos.google.cloud.resourcemanager.v3.IUpdateProjectRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateProject( - request: protos.google.cloud.resourcemanager.v3.IUpdateProjectRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateProject( - request?: protos.google.cloud.resourcemanager.v3.IUpdateProjectRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project.name': request.project!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateProject(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateProject()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/projects.update_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_UpdateProject_async - */ - async checkUpdateProjectProgress(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.updateProject, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Move a project to another place in your resource hierarchy, under a new - * resource parent. - * - * Returns an operation which can be used to track the process of the project - * move workflow. - * Upon success, the `Operation.response` field will be populated with the - * moved project. - * - * The caller must have `resourcemanager.projects.move` permission on the - * project, on the project's current and proposed new parent. - * - * If project has no current parent, or it currently does not have an - * associated organization resource, you will also need the - * `resourcemanager.projects.setIamPolicy` permission in the project. - * - * - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the project to move. - * @param {string} request.destinationParent - * Required. The new parent to move the Project under. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/projects.move_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_MoveProject_async - */ - moveProject( - request?: protos.google.cloud.resourcemanager.v3.IMoveProjectRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - moveProject( - request: protos.google.cloud.resourcemanager.v3.IMoveProjectRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - moveProject( - request: protos.google.cloud.resourcemanager.v3.IMoveProjectRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - moveProject( - request?: protos.google.cloud.resourcemanager.v3.IMoveProjectRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.moveProject(request, options, callback); - } -/** - * Check the status of the long running operation returned by `moveProject()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/projects.move_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_MoveProject_async - */ - async checkMoveProjectProgress(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.moveProject, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Marks the project identified by the specified - * `name` (for example, `projects/415104041262`) for deletion. - * - * This method will only affect the project if it has a lifecycle state of - * {@link protos.google.cloud.resourcemanager.v3.Project.State.ACTIVE|ACTIVE}. - * - * This method changes the Project's lifecycle state from - * {@link protos.google.cloud.resourcemanager.v3.Project.State.ACTIVE|ACTIVE} - * to - * {@link protos.google.cloud.resourcemanager.v3.Project.State.DELETE_REQUESTED|DELETE_REQUESTED}. - * The deletion starts at an unspecified time, - * at which point the Project is no longer accessible. - * - * Until the deletion completes, you can check the lifecycle state - * checked by retrieving the project with [GetProject] - * [google.cloud.resourcemanager.v3.Projects.GetProject], - * and the project remains visible to [ListProjects] - * [google.cloud.resourcemanager.v3.Projects.ListProjects]. - * However, you cannot update the project. - * - * After the deletion completes, the project is not retrievable by - * the [GetProject] - * [google.cloud.resourcemanager.v3.Projects.GetProject], - * [ListProjects] - * [google.cloud.resourcemanager.v3.Projects.ListProjects], and - * {@link protos.google.cloud.resourcemanager.v3.Projects.SearchProjects|SearchProjects} - * methods. - * - * This method behaves idempotently, such that deleting a `DELETE_REQUESTED` - * project will not cause an error, but also won't do anything. - * - * The caller must have `resourcemanager.projects.delete` permissions for this - * project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Project (for example, `projects/415104041262`). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/projects.delete_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_DeleteProject_async - */ - deleteProject( - request?: protos.google.cloud.resourcemanager.v3.IDeleteProjectRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteProject( - request: protos.google.cloud.resourcemanager.v3.IDeleteProjectRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteProject( - request: protos.google.cloud.resourcemanager.v3.IDeleteProjectRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteProject( - request?: protos.google.cloud.resourcemanager.v3.IDeleteProjectRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteProject(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteProject()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/projects.delete_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_DeleteProject_async - */ - async checkDeleteProjectProgress(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.deleteProject, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Restores the project identified by the specified - * `name` (for example, `projects/415104041262`). - * You can only use this method for a project that has a lifecycle state of - * [DELETE_REQUESTED] - * [Projects.State.DELETE_REQUESTED]. - * After deletion starts, the project cannot be restored. - * - * The caller must have `resourcemanager.projects.undelete` permission for - * this project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the project (for example, `projects/415104041262`). - * - * Required. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/projects.undelete_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_UndeleteProject_async - */ - undeleteProject( - request?: protos.google.cloud.resourcemanager.v3.IUndeleteProjectRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - undeleteProject( - request: protos.google.cloud.resourcemanager.v3.IUndeleteProjectRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - undeleteProject( - request: protos.google.cloud.resourcemanager.v3.IUndeleteProjectRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - undeleteProject( - request?: protos.google.cloud.resourcemanager.v3.IUndeleteProjectRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.undeleteProject(request, options, callback); - } -/** - * Check the status of the long running operation returned by `undeleteProject()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/projects.undelete_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_UndeleteProject_async - */ - async checkUndeleteProjectProgress(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.undeleteProject, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists projects that are direct children of the specified folder or - * organization resource. `list()` provides a strongly consistent view of the - * projects underneath the specified parent resource. `list()` returns - * projects sorted based upon the (ascending) lexical ordering of their - * `display_name`. The caller must have `resourcemanager.projects.list` - * permission on the identified parent. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource whose projects are being listed. - * Only children of this parent resource are listed; descendants are not - * listed. - * - * If the parent is a folder, use the value `folders/{folder_id}`. If the - * parent is an organization, use the value `organizations/{org_id}`. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects] that - * indicates from where listing should continue. - * @param {number} [request.pageSize] - * Optional. The maximum number of projects to return in the response. - * The server can return fewer projects than requested. - * If unspecified, server picks an appropriate default. - * @param {boolean} [request.showDeleted] - * Optional. Indicate that projects in the `DELETE_REQUESTED` state should - * also be returned. Normally only `ACTIVE` projects are 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 protos.google.cloud.resourcemanager.v3.Project|Project}. - * 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 `listProjectsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listProjects( - request?: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.IProject[], - protos.google.cloud.resourcemanager.v3.IListProjectsRequest|null, - protos.google.cloud.resourcemanager.v3.IListProjectsResponse - ]>; - listProjects( - request: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListProjectsRequest, - protos.google.cloud.resourcemanager.v3.IListProjectsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IProject>): void; - listProjects( - request: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListProjectsRequest, - protos.google.cloud.resourcemanager.v3.IListProjectsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IProject>): void; - listProjects( - request?: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListProjectsRequest, - protos.google.cloud.resourcemanager.v3.IListProjectsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IProject>, - callback?: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListProjectsRequest, - protos.google.cloud.resourcemanager.v3.IListProjectsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IProject>): - Promise<[ - protos.google.cloud.resourcemanager.v3.IProject[], - protos.google.cloud.resourcemanager.v3.IListProjectsRequest|null, - protos.google.cloud.resourcemanager.v3.IListProjectsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.listProjects(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 name of the parent resource whose projects are being listed. - * Only children of this parent resource are listed; descendants are not - * listed. - * - * If the parent is a folder, use the value `folders/{folder_id}`. If the - * parent is an organization, use the value `organizations/{org_id}`. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects] that - * indicates from where listing should continue. - * @param {number} [request.pageSize] - * Optional. The maximum number of projects to return in the response. - * The server can return fewer projects than requested. - * If unspecified, server picks an appropriate default. - * @param {boolean} [request.showDeleted] - * Optional. Indicate that projects in the `DELETE_REQUESTED` state should - * also be returned. Normally only `ACTIVE` projects are 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 protos.google.cloud.resourcemanager.v3.Project|Project} 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 `listProjectsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listProjectsStream( - request?: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listProjects']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProjects.createStream( - this.innerApiCalls.listProjects as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProjects`, 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 name of the parent resource whose projects are being listed. - * Only children of this parent resource are listed; descendants are not - * listed. - * - * If the parent is a folder, use the value `folders/{folder_id}`. If the - * parent is an organization, use the value `organizations/{org_id}`. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects] that - * indicates from where listing should continue. - * @param {number} [request.pageSize] - * Optional. The maximum number of projects to return in the response. - * The server can return fewer projects than requested. - * If unspecified, server picks an appropriate default. - * @param {boolean} [request.showDeleted] - * Optional. Indicate that projects in the `DELETE_REQUESTED` state should - * also be returned. Normally only `ACTIVE` projects are 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.resourcemanager.v3.Project|Project}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v3/projects.list_projects.js - * region_tag:cloudresourcemanager_v3_generated_Projects_ListProjects_async - */ - listProjectsAsync( - request?: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listProjects']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProjects.asyncIterate( - this.innerApiCalls['listProjects'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Search for projects that the caller has both `resourcemanager.projects.get` - * permission on, and also satisfy the specified query. - * - * This method returns projects in an unspecified order. - * - * This method is eventually consistent with project mutations; this means - * that a newly created project may not appear in the results or recent - * updates to an existing project may not be reflected in the results. To - * retrieve the latest state of a project, use the - * {@link protos.google.cloud.resourcemanager.v3.Projects.GetProject|GetProject} method. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} [request.query] - * Optional. A query string for searching for projects that the caller has - * `resourcemanager.projects.get` permission to. If multiple fields are - * included in the query, then it will return results that match any of the - * fields. Some eligible fields are: - * - * - **`displayName`, `name`**: Filters by displayName. - * - **`parent`**: Project's parent (for example: `folders/123`, - * `organizations/*`). Prefer `parent` field over `parent.type` and - * `parent.id`. - * - **`parent.type`**: Parent's type: `folder` or `organization`. - * - **`parent.id`**: Parent's id number (for example: `123`). - * - **`id`, `projectId`**: Filters by projectId. - * - **`state`, `lifecycleState`**: Filters by state. - * - **`labels`**: Filters by label name or value. - * - **`labels.` (where `` is the name of a label)**: Filters by label - * name. - * - * Search expressions are case insensitive. - * - * Some examples queries: - * - * - * - **`name:how*`**: The project's name starts with "how". - * - **`name:Howl`**: The project's name is `Howl` or `howl`. - * - **`name:HOWL`**: Equivalent to above. - * - **`NAME:howl`**: Equivalent to above. - * - **`labels.color:*`**: The project has the label `color`. - * - **`labels.color:red`**: The project's label `color` has the value `red`. - * - **`labels.color:red labels.size:big`**: The project's label `color` has - * the value `red` or its label `size` has the value `big`. - * - * If no query is specified, the call will return projects for which the user - * has the `resourcemanager.projects.get` permission. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects] that - * indicates from where listing should continue. - * @param {number} [request.pageSize] - * Optional. The maximum number of projects to return in the response. - * The server can return fewer projects than requested. - * If unspecified, server picks an appropriate default. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.resourcemanager.v3.Project|Project}. - * 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 `searchProjectsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - searchProjects( - request?: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.IProject[], - protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest|null, - protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse - ]>; - searchProjects( - request: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, - protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IProject>): void; - searchProjects( - request: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, - protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IProject>): void; - searchProjects( - request?: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, - protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IProject>, - callback?: PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, - protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IProject>): - Promise<[ - protos.google.cloud.resourcemanager.v3.IProject[], - protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest|null, - protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.searchProjects(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.query] - * Optional. A query string for searching for projects that the caller has - * `resourcemanager.projects.get` permission to. If multiple fields are - * included in the query, then it will return results that match any of the - * fields. Some eligible fields are: - * - * - **`displayName`, `name`**: Filters by displayName. - * - **`parent`**: Project's parent (for example: `folders/123`, - * `organizations/*`). Prefer `parent` field over `parent.type` and - * `parent.id`. - * - **`parent.type`**: Parent's type: `folder` or `organization`. - * - **`parent.id`**: Parent's id number (for example: `123`). - * - **`id`, `projectId`**: Filters by projectId. - * - **`state`, `lifecycleState`**: Filters by state. - * - **`labels`**: Filters by label name or value. - * - **`labels.` (where `` is the name of a label)**: Filters by label - * name. - * - * Search expressions are case insensitive. - * - * Some examples queries: - * - * - * - **`name:how*`**: The project's name starts with "how". - * - **`name:Howl`**: The project's name is `Howl` or `howl`. - * - **`name:HOWL`**: Equivalent to above. - * - **`NAME:howl`**: Equivalent to above. - * - **`labels.color:*`**: The project has the label `color`. - * - **`labels.color:red`**: The project's label `color` has the value `red`. - * - **`labels.color:red labels.size:big`**: The project's label `color` has - * the value `red` or its label `size` has the value `big`. - * - * If no query is specified, the call will return projects for which the user - * has the `resourcemanager.projects.get` permission. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects] that - * indicates from where listing should continue. - * @param {number} [request.pageSize] - * Optional. The maximum number of projects to return in the response. - * The server can return fewer projects than requested. - * If unspecified, server picks an appropriate default. - * @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 protos.google.cloud.resourcemanager.v3.Project|Project} 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 `searchProjectsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - searchProjectsStream( - request?: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['searchProjects']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchProjects.createStream( - this.innerApiCalls.searchProjects as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `searchProjects`, 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.query] - * Optional. A query string for searching for projects that the caller has - * `resourcemanager.projects.get` permission to. If multiple fields are - * included in the query, then it will return results that match any of the - * fields. Some eligible fields are: - * - * - **`displayName`, `name`**: Filters by displayName. - * - **`parent`**: Project's parent (for example: `folders/123`, - * `organizations/*`). Prefer `parent` field over `parent.type` and - * `parent.id`. - * - **`parent.type`**: Parent's type: `folder` or `organization`. - * - **`parent.id`**: Parent's id number (for example: `123`). - * - **`id`, `projectId`**: Filters by projectId. - * - **`state`, `lifecycleState`**: Filters by state. - * - **`labels`**: Filters by label name or value. - * - **`labels.` (where `` is the name of a label)**: Filters by label - * name. - * - * Search expressions are case insensitive. - * - * Some examples queries: - * - * - * - **`name:how*`**: The project's name starts with "how". - * - **`name:Howl`**: The project's name is `Howl` or `howl`. - * - **`name:HOWL`**: Equivalent to above. - * - **`NAME:howl`**: Equivalent to above. - * - **`labels.color:*`**: The project has the label `color`. - * - **`labels.color:red`**: The project's label `color` has the value `red`. - * - **`labels.color:red labels.size:big`**: The project's label `color` has - * the value `red` or its label `size` has the value `big`. - * - * If no query is specified, the call will return projects for which the user - * has the `resourcemanager.projects.get` permission. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects] that - * indicates from where listing should continue. - * @param {number} [request.pageSize] - * Optional. The maximum number of projects to return in the response. - * The server can return fewer projects than requested. - * If unspecified, server picks an appropriate default. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.resourcemanager.v3.Project|Project}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v3/projects.search_projects.js - * region_tag:cloudresourcemanager_v3_generated_Projects_SearchProjects_async - */ - searchProjectsAsync( - request?: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['searchProjects']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchProjects.asyncIterate( - this.innerApiCalls['searchProjects'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * 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 folder resource name string. - * - * @param {string} folder - * @returns {string} Resource name string. - */ - folderPath(folder:string) { - return this.pathTemplates.folderPathTemplate.render({ - folder: folder, - }); - } - - /** - * Parse the folder from Folder resource. - * - * @param {string} folderName - * A fully-qualified path representing Folder resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderName(folderName: string) { - return this.pathTemplates.folderPathTemplate.match(folderName).folder; - } - - /** - * Return a fully-qualified organization resource name string. - * - * @param {string} organization - * @returns {string} Resource name string. - */ - organizationPath(organization:string) { - return this.pathTemplates.organizationPathTemplate.render({ - organization: organization, - }); - } - - /** - * Parse the organization from Organization resource. - * - * @param {string} organizationName - * A fully-qualified path representing Organization resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationName(organizationName: string) { - return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified tagBinding resource name string. - * - * @param {string} tag_binding - * @returns {string} Resource name string. - */ - tagBindingPath(tagBinding:string) { - return this.pathTemplates.tagBindingPathTemplate.render({ - tag_binding: tagBinding, - }); - } - - /** - * Parse the tag_binding from TagBinding resource. - * - * @param {string} tagBindingName - * A fully-qualified path representing TagBinding resource. - * @returns {string} A string representing the tag_binding. - */ - matchTagBindingFromTagBindingName(tagBindingName: string) { - return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; - } - - /** - * Return a fully-qualified tagHold resource name string. - * - * @param {string} tag_value - * @param {string} tag_hold - * @returns {string} Resource name string. - */ - tagHoldPath(tagValue:string,tagHold:string) { - return this.pathTemplates.tagHoldPathTemplate.render({ - tag_value: tagValue, - tag_hold: tagHold, - }); - } - - /** - * Parse the tag_value from TagHold resource. - * - * @param {string} tagHoldName - * A fully-qualified path representing TagHold resource. - * @returns {string} A string representing the tag_value. - */ - matchTagValueFromTagHoldName(tagHoldName: string) { - return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_value; - } - - /** - * Parse the tag_hold from TagHold resource. - * - * @param {string} tagHoldName - * A fully-qualified path representing TagHold resource. - * @returns {string} A string representing the tag_hold. - */ - matchTagHoldFromTagHoldName(tagHoldName: string) { - return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_hold; - } - - /** - * Return a fully-qualified tagKey resource name string. - * - * @param {string} tag_key - * @returns {string} Resource name string. - */ - tagKeyPath(tagKey:string) { - return this.pathTemplates.tagKeyPathTemplate.render({ - tag_key: tagKey, - }); - } - - /** - * Parse the tag_key from TagKey resource. - * - * @param {string} tagKeyName - * A fully-qualified path representing TagKey resource. - * @returns {string} A string representing the tag_key. - */ - matchTagKeyFromTagKeyName(tagKeyName: string) { - return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; - } - - /** - * Return a fully-qualified tagValue resource name string. - * - * @param {string} tag_value - * @returns {string} Resource name string. - */ - tagValuePath(tagValue:string) { - return this.pathTemplates.tagValuePathTemplate.render({ - tag_value: tagValue, - }); - } - - /** - * Parse the tag_value from TagValue resource. - * - * @param {string} tagValueName - * A fully-qualified path representing TagValue resource. - * @returns {string} A string representing the tag_value. - */ - matchTagValueFromTagValueName(tagValueName: string) { - return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; - } - - /** - * 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.projectsStub && !this._terminated) { - return this.projectsStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_client_config.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_client_config.json deleted file mode 100644 index f1308d45931..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_client_config.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "interfaces": { - "google.cloud.resourcemanager.v3.Projects": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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": { - "GetProject": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "ListProjects": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "SearchProjects": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateProject": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateProject": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "MoveProject": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteProject": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UndeleteProject": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "SetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "TestIamPermissions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_proto_list.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_proto_list.json deleted file mode 100644 index 639794aadd4..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/projects_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/cloud/resourcemanager/v3/folders.proto", - "../../protos/google/cloud/resourcemanager/v3/organizations.proto", - "../../protos/google/cloud/resourcemanager/v3/projects.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_holds.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" -] diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_client.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_client.ts deleted file mode 100644 index 8ea49ac9dbd..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_client.ts +++ /dev/null @@ -1,1258 +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} 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/v3/tag_bindings_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './tag_bindings_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Allow users to create and manage TagBindings between TagValues and - * different Google Cloud resources throughout the GCP resource hierarchy. - * @class - * @memberof v3 - */ -export class TagBindingsClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - tagBindingsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of TagBindingsClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 TagBindingsClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof TagBindingsClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - folderPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}' - ), - organizationPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - tagBindingPathTemplate: new this._gaxModule.PathTemplate( - 'tagBindings/{tag_binding}' - ), - tagHoldPathTemplate: new this._gaxModule.PathTemplate( - 'tagValues/{tag_value}/tagHolds/{tag_hold}' - ), - tagKeyPathTemplate: new this._gaxModule.PathTemplate( - 'tagKeys/{tag_key}' - ), - tagValuePathTemplate: new this._gaxModule.PathTemplate( - 'tagValues/{tag_value}' - ), - }; - - // 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 = { - listTagBindings: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tagBindings'), - listEffectiveTags: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'effectiveTags') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v3/{name=operations/**}',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createTagBindingResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.TagBinding') as gax.protobuf.Type; - const createTagBindingMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.CreateTagBindingMetadata') as gax.protobuf.Type; - const deleteTagBindingResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteTagBindingMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.DeleteTagBindingMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createTagBinding: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createTagBindingResponse.decode.bind(createTagBindingResponse), - createTagBindingMetadata.decode.bind(createTagBindingMetadata)), - deleteTagBinding: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteTagBindingResponse.decode.bind(deleteTagBindingResponse), - deleteTagBindingMetadata.decode.bind(deleteTagBindingMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.resourcemanager.v3.TagBindings', 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.tagBindingsStub) { - return this.tagBindingsStub; - } - - // Put together the "service stub" for - // google.cloud.resourcemanager.v3.TagBindings. - this.tagBindingsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.TagBindings') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.resourcemanager.v3.TagBindings, - 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 tagBindingsStubMethods = - ['listTagBindings', 'createTagBinding', 'deleteTagBinding', 'listEffectiveTags']; - for (const methodName of tagBindingsStubMethods) { - const callPromise = this.tagBindingsStub.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.tagBindingsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudresourcemanager.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 'cloudresourcemanager.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only' - ]; - } - - 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 TagBinding between a TagValue and a Google Cloud resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.resourcemanager.v3.TagBinding} request.tagBinding - * Required. The TagBinding to be created. - * @param {boolean} [request.validateOnly] - * Optional. Set to true to perform the validations necessary for creating the - * resource, but not actually perform the action. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_bindings.create_tag_binding.js - * region_tag:cloudresourcemanager_v3_generated_TagBindings_CreateTagBinding_async - */ - createTagBinding( - request?: protos.google.cloud.resourcemanager.v3.ICreateTagBindingRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createTagBinding( - request: protos.google.cloud.resourcemanager.v3.ICreateTagBindingRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createTagBinding( - request: protos.google.cloud.resourcemanager.v3.ICreateTagBindingRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createTagBinding( - request?: protos.google.cloud.resourcemanager.v3.ICreateTagBindingRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.createTagBinding(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createTagBinding()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_bindings.create_tag_binding.js - * region_tag:cloudresourcemanager_v3_generated_TagBindings_CreateTagBinding_async - */ - async checkCreateTagBindingProgress(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.createTagBinding, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a TagBinding. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the TagBinding. This is a String of the form: - * `tagBindings/{id}` (e.g. - * `tagBindings/%2F%2Fcloudresourcemanager.googleapis.com%2Fprojects%2F123/tagValues/456`). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_bindings.delete_tag_binding.js - * region_tag:cloudresourcemanager_v3_generated_TagBindings_DeleteTagBinding_async - */ - deleteTagBinding( - request?: protos.google.cloud.resourcemanager.v3.IDeleteTagBindingRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteTagBinding( - request: protos.google.cloud.resourcemanager.v3.IDeleteTagBindingRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteTagBinding( - request: protos.google.cloud.resourcemanager.v3.IDeleteTagBindingRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteTagBinding( - request?: protos.google.cloud.resourcemanager.v3.IDeleteTagBindingRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteTagBinding(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteTagBinding()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_bindings.delete_tag_binding.js - * region_tag:cloudresourcemanager_v3_generated_TagBindings_DeleteTagBinding_async - */ - async checkDeleteTagBindingProgress(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.deleteTagBinding, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists the TagBindings for the given Google Cloud resource, as specified - * with `parent`. - * - * NOTE: The `parent` field is expected to be a full resource name: - * https://cloud.google.com/apis/design/resource_names#full_resource_name - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The full resource name of a resource for which you want to list - * existing TagBindings. E.g. - * "//cloudresourcemanager.googleapis.com/projects/123" - * @param {number} [request.pageSize] - * Optional. The maximum number of TagBindings to return in the response. The - * server allows a maximum of 300 TagBindings to return. If unspecified, the - * server will use 100 as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * `ListTagBindings` that indicates where this listing should continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.resourcemanager.v3.TagBinding|TagBinding}. - * 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 `listTagBindingsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listTagBindings( - request?: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagBinding[], - protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest|null, - protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse - ]>; - listTagBindings( - request: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, - protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagBinding>): void; - listTagBindings( - request: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, - protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagBinding>): void; - listTagBindings( - request?: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, - protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagBinding>, - callback?: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, - protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagBinding>): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagBinding[], - protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest|null, - protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.listTagBindings(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 full resource name of a resource for which you want to list - * existing TagBindings. E.g. - * "//cloudresourcemanager.googleapis.com/projects/123" - * @param {number} [request.pageSize] - * Optional. The maximum number of TagBindings to return in the response. The - * server allows a maximum of 300 TagBindings to return. If unspecified, the - * server will use 100 as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * `ListTagBindings` that indicates where this listing should continue from. - * @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 protos.google.cloud.resourcemanager.v3.TagBinding|TagBinding} 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 `listTagBindingsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listTagBindingsStream( - request?: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listTagBindings']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTagBindings.createStream( - this.innerApiCalls.listTagBindings as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listTagBindings`, 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 full resource name of a resource for which you want to list - * existing TagBindings. E.g. - * "//cloudresourcemanager.googleapis.com/projects/123" - * @param {number} [request.pageSize] - * Optional. The maximum number of TagBindings to return in the response. The - * server allows a maximum of 300 TagBindings to return. If unspecified, the - * server will use 100 as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * `ListTagBindings` that indicates where this listing should continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.resourcemanager.v3.TagBinding|TagBinding}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_bindings.list_tag_bindings.js - * region_tag:cloudresourcemanager_v3_generated_TagBindings_ListTagBindings_async - */ - listTagBindingsAsync( - request?: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listTagBindings']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTagBindings.asyncIterate( - this.innerApiCalls['listTagBindings'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Return a list of effective tags for the given Google Cloud resource, as - * specified in `parent`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The full resource name of a resource for which you want to list - * the effective tags. E.g. - * "//cloudresourcemanager.googleapis.com/projects/123" - * @param {number} [request.pageSize] - * Optional. The maximum number of effective tags to return in the response. - * The server allows a maximum of 300 effective tags to return in a single - * page. If unspecified, the server will use 100 as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * `ListEffectiveTags` that indicates from where this listing should continue. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.resourcemanager.v3.EffectiveTag|EffectiveTag}. - * 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 `listEffectiveTagsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listEffectiveTags( - request?: protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.IEffectiveTag[], - protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest|null, - protos.google.cloud.resourcemanager.v3.IListEffectiveTagsResponse - ]>; - listEffectiveTags( - request: protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest, - protos.google.cloud.resourcemanager.v3.IListEffectiveTagsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IEffectiveTag>): void; - listEffectiveTags( - request: protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest, - protos.google.cloud.resourcemanager.v3.IListEffectiveTagsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IEffectiveTag>): void; - listEffectiveTags( - request?: protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest, - protos.google.cloud.resourcemanager.v3.IListEffectiveTagsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IEffectiveTag>, - callback?: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest, - protos.google.cloud.resourcemanager.v3.IListEffectiveTagsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IEffectiveTag>): - Promise<[ - protos.google.cloud.resourcemanager.v3.IEffectiveTag[], - protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest|null, - protos.google.cloud.resourcemanager.v3.IListEffectiveTagsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.listEffectiveTags(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 full resource name of a resource for which you want to list - * the effective tags. E.g. - * "//cloudresourcemanager.googleapis.com/projects/123" - * @param {number} [request.pageSize] - * Optional. The maximum number of effective tags to return in the response. - * The server allows a maximum of 300 effective tags to return in a single - * page. If unspecified, the server will use 100 as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * `ListEffectiveTags` that indicates from where this listing should continue. - * @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 protos.google.cloud.resourcemanager.v3.EffectiveTag|EffectiveTag} 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 `listEffectiveTagsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listEffectiveTagsStream( - request?: protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listEffectiveTags']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listEffectiveTags.createStream( - this.innerApiCalls.listEffectiveTags as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listEffectiveTags`, 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 full resource name of a resource for which you want to list - * the effective tags. E.g. - * "//cloudresourcemanager.googleapis.com/projects/123" - * @param {number} [request.pageSize] - * Optional. The maximum number of effective tags to return in the response. - * The server allows a maximum of 300 effective tags to return in a single - * page. If unspecified, the server will use 100 as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * `ListEffectiveTags` that indicates from where this listing should continue. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.resourcemanager.v3.EffectiveTag|EffectiveTag}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_bindings.list_effective_tags.js - * region_tag:cloudresourcemanager_v3_generated_TagBindings_ListEffectiveTags_async - */ - listEffectiveTagsAsync( - request?: protos.google.cloud.resourcemanager.v3.IListEffectiveTagsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listEffectiveTags']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listEffectiveTags.asyncIterate( - this.innerApiCalls['listEffectiveTags'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * 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 folder resource name string. - * - * @param {string} folder - * @returns {string} Resource name string. - */ - folderPath(folder:string) { - return this.pathTemplates.folderPathTemplate.render({ - folder: folder, - }); - } - - /** - * Parse the folder from Folder resource. - * - * @param {string} folderName - * A fully-qualified path representing Folder resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderName(folderName: string) { - return this.pathTemplates.folderPathTemplate.match(folderName).folder; - } - - /** - * Return a fully-qualified organization resource name string. - * - * @param {string} organization - * @returns {string} Resource name string. - */ - organizationPath(organization:string) { - return this.pathTemplates.organizationPathTemplate.render({ - organization: organization, - }); - } - - /** - * Parse the organization from Organization resource. - * - * @param {string} organizationName - * A fully-qualified path representing Organization resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationName(organizationName: string) { - return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified tagBinding resource name string. - * - * @param {string} tag_binding - * @returns {string} Resource name string. - */ - tagBindingPath(tagBinding:string) { - return this.pathTemplates.tagBindingPathTemplate.render({ - tag_binding: tagBinding, - }); - } - - /** - * Parse the tag_binding from TagBinding resource. - * - * @param {string} tagBindingName - * A fully-qualified path representing TagBinding resource. - * @returns {string} A string representing the tag_binding. - */ - matchTagBindingFromTagBindingName(tagBindingName: string) { - return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; - } - - /** - * Return a fully-qualified tagHold resource name string. - * - * @param {string} tag_value - * @param {string} tag_hold - * @returns {string} Resource name string. - */ - tagHoldPath(tagValue:string,tagHold:string) { - return this.pathTemplates.tagHoldPathTemplate.render({ - tag_value: tagValue, - tag_hold: tagHold, - }); - } - - /** - * Parse the tag_value from TagHold resource. - * - * @param {string} tagHoldName - * A fully-qualified path representing TagHold resource. - * @returns {string} A string representing the tag_value. - */ - matchTagValueFromTagHoldName(tagHoldName: string) { - return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_value; - } - - /** - * Parse the tag_hold from TagHold resource. - * - * @param {string} tagHoldName - * A fully-qualified path representing TagHold resource. - * @returns {string} A string representing the tag_hold. - */ - matchTagHoldFromTagHoldName(tagHoldName: string) { - return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_hold; - } - - /** - * Return a fully-qualified tagKey resource name string. - * - * @param {string} tag_key - * @returns {string} Resource name string. - */ - tagKeyPath(tagKey:string) { - return this.pathTemplates.tagKeyPathTemplate.render({ - tag_key: tagKey, - }); - } - - /** - * Parse the tag_key from TagKey resource. - * - * @param {string} tagKeyName - * A fully-qualified path representing TagKey resource. - * @returns {string} A string representing the tag_key. - */ - matchTagKeyFromTagKeyName(tagKeyName: string) { - return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; - } - - /** - * Return a fully-qualified tagValue resource name string. - * - * @param {string} tag_value - * @returns {string} Resource name string. - */ - tagValuePath(tagValue:string) { - return this.pathTemplates.tagValuePathTemplate.render({ - tag_value: tagValue, - }); - } - - /** - * Parse the tag_value from TagValue resource. - * - * @param {string} tagValueName - * A fully-qualified path representing TagValue resource. - * @returns {string} A string representing the tag_value. - */ - matchTagValueFromTagValueName(tagValueName: string) { - return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; - } - - /** - * 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.tagBindingsStub && !this._terminated) { - return this.tagBindingsStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_client_config.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_client_config.json deleted file mode 100644 index 5a1182f0c9e..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_client_config.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "interfaces": { - "google.cloud.resourcemanager.v3.TagBindings": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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": { - "ListTagBindings": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "CreateTagBinding": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteTagBinding": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListEffectiveTags": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_proto_list.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_proto_list.json deleted file mode 100644 index 639794aadd4..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_bindings_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/cloud/resourcemanager/v3/folders.proto", - "../../protos/google/cloud/resourcemanager/v3/organizations.proto", - "../../protos/google/cloud/resourcemanager/v3/projects.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_holds.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" -] diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_client.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_client.ts deleted file mode 100644 index 02f1c57ffe3..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_client.ts +++ /dev/null @@ -1,1143 +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} 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/v3/tag_holds_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './tag_holds_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Allow users to create and manage TagHolds for TagValues. TagHolds represent - * the use of a Tag Value that is not captured by TagBindings but - * should still block TagValue deletion (such as a reference in a policy - * condition). This service provides isolated failure domains by cloud location - * so that TagHolds can be managed in the same location as their usage. - * @class - * @memberof v3 - */ -export class TagHoldsClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - tagHoldsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of TagHoldsClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 TagHoldsClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof TagHoldsClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - folderPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}' - ), - organizationPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - tagBindingPathTemplate: new this._gaxModule.PathTemplate( - 'tagBindings/{tag_binding}' - ), - tagHoldPathTemplate: new this._gaxModule.PathTemplate( - 'tagValues/{tag_value}/tagHolds/{tag_hold}' - ), - tagKeyPathTemplate: new this._gaxModule.PathTemplate( - 'tagKeys/{tag_key}' - ), - tagValuePathTemplate: new this._gaxModule.PathTemplate( - 'tagValues/{tag_value}' - ), - }; - - // 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 = { - listTagHolds: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tagHolds') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v3/{name=operations/**}',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createTagHoldResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.TagHold') as gax.protobuf.Type; - const createTagHoldMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.CreateTagHoldMetadata') as gax.protobuf.Type; - const deleteTagHoldResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteTagHoldMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.DeleteTagHoldMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createTagHold: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createTagHoldResponse.decode.bind(createTagHoldResponse), - createTagHoldMetadata.decode.bind(createTagHoldMetadata)), - deleteTagHold: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteTagHoldResponse.decode.bind(deleteTagHoldResponse), - deleteTagHoldMetadata.decode.bind(deleteTagHoldMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.resourcemanager.v3.TagHolds', 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.tagHoldsStub) { - return this.tagHoldsStub; - } - - // Put together the "service stub" for - // google.cloud.resourcemanager.v3.TagHolds. - this.tagHoldsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.TagHolds') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.resourcemanager.v3.TagHolds, - 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 tagHoldsStubMethods = - ['createTagHold', 'deleteTagHold', 'listTagHolds']; - for (const methodName of tagHoldsStubMethods) { - const callPromise = this.tagHoldsStub.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.tagHoldsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudresourcemanager.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 'cloudresourcemanager.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only' - ]; - } - - 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 TagHold. Returns ALREADY_EXISTS if a TagHold with the same - * resource and origin exists under the same TagValue. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the TagHold's parent TagValue. Must be of - * the form: `tagValues/{tag-value-id}`. - * @param {google.cloud.resourcemanager.v3.TagHold} request.tagHold - * Required. The TagHold to be created. - * @param {boolean} [request.validateOnly] - * Optional. Set to true to perform the validations necessary for creating the - * resource, but not actually perform the action. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_holds.create_tag_hold.js - * region_tag:cloudresourcemanager_v3_generated_TagHolds_CreateTagHold_async - */ - createTagHold( - request?: protos.google.cloud.resourcemanager.v3.ICreateTagHoldRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createTagHold( - request: protos.google.cloud.resourcemanager.v3.ICreateTagHoldRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createTagHold( - request: protos.google.cloud.resourcemanager.v3.ICreateTagHoldRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createTagHold( - request?: protos.google.cloud.resourcemanager.v3.ICreateTagHoldRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createTagHold(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createTagHold()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_holds.create_tag_hold.js - * region_tag:cloudresourcemanager_v3_generated_TagHolds_CreateTagHold_async - */ - async checkCreateTagHoldProgress(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.createTagHold, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a TagHold. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the TagHold to delete. Must be of the form: - * `tagValues/{tag-value-id}/tagHolds/{tag-hold-id}`. - * @param {boolean} [request.validateOnly] - * Optional. Set to true to perform the validations necessary for deleting the - * resource, but not actually perform the action. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_holds.delete_tag_hold.js - * region_tag:cloudresourcemanager_v3_generated_TagHolds_DeleteTagHold_async - */ - deleteTagHold( - request?: protos.google.cloud.resourcemanager.v3.IDeleteTagHoldRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteTagHold( - request: protos.google.cloud.resourcemanager.v3.IDeleteTagHoldRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteTagHold( - request: protos.google.cloud.resourcemanager.v3.IDeleteTagHoldRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteTagHold( - request?: protos.google.cloud.resourcemanager.v3.IDeleteTagHoldRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteTagHold(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteTagHold()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_holds.delete_tag_hold.js - * region_tag:cloudresourcemanager_v3_generated_TagHolds_DeleteTagHold_async - */ - async checkDeleteTagHoldProgress(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.deleteTagHold, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists TagHolds under a TagValue. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the parent TagValue. Must be of the form: - * `tagValues/{tag-value-id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of TagHolds to return in the response. The - * server allows a maximum of 300 TagHolds to return. If unspecified, the - * server will use 100 as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * `ListTagHolds` that indicates where this listing should continue from. - * @param {string} [request.filter] - * Optional. Criteria used to select a subset of TagHolds parented by the - * TagValue to return. This field follows the syntax defined by aip.dev/160; - * the `holder` and `origin` fields are supported for filtering. Currently - * only `AND` syntax is supported. Some example queries are: - * - * * `holder = - * //compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group` - * * `origin = 35678234` - * * `holder = - * //compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group - * AND origin = 35678234` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.resourcemanager.v3.TagHold|TagHold}. - * 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 `listTagHoldsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listTagHolds( - request?: protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagHold[], - protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest|null, - protos.google.cloud.resourcemanager.v3.IListTagHoldsResponse - ]>; - listTagHolds( - request: protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest, - protos.google.cloud.resourcemanager.v3.IListTagHoldsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagHold>): void; - listTagHolds( - request: protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest, - protos.google.cloud.resourcemanager.v3.IListTagHoldsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagHold>): void; - listTagHolds( - request?: protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest, - protos.google.cloud.resourcemanager.v3.IListTagHoldsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagHold>, - callback?: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest, - protos.google.cloud.resourcemanager.v3.IListTagHoldsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagHold>): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagHold[], - protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest|null, - protos.google.cloud.resourcemanager.v3.IListTagHoldsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listTagHolds(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the parent TagValue. Must be of the form: - * `tagValues/{tag-value-id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of TagHolds to return in the response. The - * server allows a maximum of 300 TagHolds to return. If unspecified, the - * server will use 100 as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * `ListTagHolds` that indicates where this listing should continue from. - * @param {string} [request.filter] - * Optional. Criteria used to select a subset of TagHolds parented by the - * TagValue to return. This field follows the syntax defined by aip.dev/160; - * the `holder` and `origin` fields are supported for filtering. Currently - * only `AND` syntax is supported. Some example queries are: - * - * * `holder = - * //compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group` - * * `origin = 35678234` - * * `holder = - * //compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group - * AND origin = 35678234` - * @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 protos.google.cloud.resourcemanager.v3.TagHold|TagHold} 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 `listTagHoldsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listTagHoldsStream( - request?: protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest, - 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['listTagHolds']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTagHolds.createStream( - this.innerApiCalls.listTagHolds as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listTagHolds`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the parent TagValue. Must be of the form: - * `tagValues/{tag-value-id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of TagHolds to return in the response. The - * server allows a maximum of 300 TagHolds to return. If unspecified, the - * server will use 100 as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * `ListTagHolds` that indicates where this listing should continue from. - * @param {string} [request.filter] - * Optional. Criteria used to select a subset of TagHolds parented by the - * TagValue to return. This field follows the syntax defined by aip.dev/160; - * the `holder` and `origin` fields are supported for filtering. Currently - * only `AND` syntax is supported. Some example queries are: - * - * * `holder = - * //compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group` - * * `origin = 35678234` - * * `holder = - * //compute.googleapis.com/compute/projects/myproject/regions/us-east-1/instanceGroupManagers/instance-group - * AND origin = 35678234` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.resourcemanager.v3.TagHold|TagHold}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_holds.list_tag_holds.js - * region_tag:cloudresourcemanager_v3_generated_TagHolds_ListTagHolds_async - */ - listTagHoldsAsync( - request?: protos.google.cloud.resourcemanager.v3.IListTagHoldsRequest, - 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['listTagHolds']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTagHolds.asyncIterate( - this.innerApiCalls['listTagHolds'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * 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 folder resource name string. - * - * @param {string} folder - * @returns {string} Resource name string. - */ - folderPath(folder:string) { - return this.pathTemplates.folderPathTemplate.render({ - folder: folder, - }); - } - - /** - * Parse the folder from Folder resource. - * - * @param {string} folderName - * A fully-qualified path representing Folder resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderName(folderName: string) { - return this.pathTemplates.folderPathTemplate.match(folderName).folder; - } - - /** - * Return a fully-qualified organization resource name string. - * - * @param {string} organization - * @returns {string} Resource name string. - */ - organizationPath(organization:string) { - return this.pathTemplates.organizationPathTemplate.render({ - organization: organization, - }); - } - - /** - * Parse the organization from Organization resource. - * - * @param {string} organizationName - * A fully-qualified path representing Organization resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationName(organizationName: string) { - return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified tagBinding resource name string. - * - * @param {string} tag_binding - * @returns {string} Resource name string. - */ - tagBindingPath(tagBinding:string) { - return this.pathTemplates.tagBindingPathTemplate.render({ - tag_binding: tagBinding, - }); - } - - /** - * Parse the tag_binding from TagBinding resource. - * - * @param {string} tagBindingName - * A fully-qualified path representing TagBinding resource. - * @returns {string} A string representing the tag_binding. - */ - matchTagBindingFromTagBindingName(tagBindingName: string) { - return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; - } - - /** - * Return a fully-qualified tagHold resource name string. - * - * @param {string} tag_value - * @param {string} tag_hold - * @returns {string} Resource name string. - */ - tagHoldPath(tagValue:string,tagHold:string) { - return this.pathTemplates.tagHoldPathTemplate.render({ - tag_value: tagValue, - tag_hold: tagHold, - }); - } - - /** - * Parse the tag_value from TagHold resource. - * - * @param {string} tagHoldName - * A fully-qualified path representing TagHold resource. - * @returns {string} A string representing the tag_value. - */ - matchTagValueFromTagHoldName(tagHoldName: string) { - return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_value; - } - - /** - * Parse the tag_hold from TagHold resource. - * - * @param {string} tagHoldName - * A fully-qualified path representing TagHold resource. - * @returns {string} A string representing the tag_hold. - */ - matchTagHoldFromTagHoldName(tagHoldName: string) { - return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_hold; - } - - /** - * Return a fully-qualified tagKey resource name string. - * - * @param {string} tag_key - * @returns {string} Resource name string. - */ - tagKeyPath(tagKey:string) { - return this.pathTemplates.tagKeyPathTemplate.render({ - tag_key: tagKey, - }); - } - - /** - * Parse the tag_key from TagKey resource. - * - * @param {string} tagKeyName - * A fully-qualified path representing TagKey resource. - * @returns {string} A string representing the tag_key. - */ - matchTagKeyFromTagKeyName(tagKeyName: string) { - return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; - } - - /** - * Return a fully-qualified tagValue resource name string. - * - * @param {string} tag_value - * @returns {string} Resource name string. - */ - tagValuePath(tagValue:string) { - return this.pathTemplates.tagValuePathTemplate.render({ - tag_value: tagValue, - }); - } - - /** - * Parse the tag_value from TagValue resource. - * - * @param {string} tagValueName - * A fully-qualified path representing TagValue resource. - * @returns {string} A string representing the tag_value. - */ - matchTagValueFromTagValueName(tagValueName: string) { - return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; - } - - /** - * 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.tagHoldsStub && !this._terminated) { - return this.tagHoldsStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_client_config.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_client_config.json deleted file mode 100644 index 5b42806f40b..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_client_config.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "interfaces": { - "google.cloud.resourcemanager.v3.TagHolds": { - "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": { - "CreateTagHold": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteTagHold": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListTagHolds": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_proto_list.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_proto_list.json deleted file mode 100644 index 639794aadd4..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_holds_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/cloud/resourcemanager/v3/folders.proto", - "../../protos/google/cloud/resourcemanager/v3/organizations.proto", - "../../protos/google/cloud/resourcemanager/v3/projects.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_holds.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" -] diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_client.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_client.ts deleted file mode 100644 index 608c4d49b76..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_client.ts +++ /dev/null @@ -1,1585 +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} 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/v3/tag_keys_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './tag_keys_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Allow users to create and manage tag keys. - * @class - * @memberof v3 - */ -export class TagKeysClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - tagKeysStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of TagKeysClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 TagKeysClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof TagKeysClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - folderPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}' - ), - organizationPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - tagBindingPathTemplate: new this._gaxModule.PathTemplate( - 'tagBindings/{tag_binding}' - ), - tagHoldPathTemplate: new this._gaxModule.PathTemplate( - 'tagValues/{tag_value}/tagHolds/{tag_hold}' - ), - tagKeyPathTemplate: new this._gaxModule.PathTemplate( - 'tagKeys/{tag_key}' - ), - tagValuePathTemplate: new this._gaxModule.PathTemplate( - 'tagValues/{tag_value}' - ), - }; - - // 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 = { - listTagKeys: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tagKeys') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v3/{name=operations/**}',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createTagKeyResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.TagKey') as gax.protobuf.Type; - const createTagKeyMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.CreateTagKeyMetadata') as gax.protobuf.Type; - const updateTagKeyResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.TagKey') as gax.protobuf.Type; - const updateTagKeyMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.UpdateTagKeyMetadata') as gax.protobuf.Type; - const deleteTagKeyResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.TagKey') as gax.protobuf.Type; - const deleteTagKeyMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.DeleteTagKeyMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createTagKey: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createTagKeyResponse.decode.bind(createTagKeyResponse), - createTagKeyMetadata.decode.bind(createTagKeyMetadata)), - updateTagKey: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateTagKeyResponse.decode.bind(updateTagKeyResponse), - updateTagKeyMetadata.decode.bind(updateTagKeyMetadata)), - deleteTagKey: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteTagKeyResponse.decode.bind(deleteTagKeyResponse), - deleteTagKeyMetadata.decode.bind(deleteTagKeyMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.resourcemanager.v3.TagKeys', 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.tagKeysStub) { - return this.tagKeysStub; - } - - // Put together the "service stub" for - // google.cloud.resourcemanager.v3.TagKeys. - this.tagKeysStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.TagKeys') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.resourcemanager.v3.TagKeys, - 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 tagKeysStubMethods = - ['listTagKeys', 'getTagKey', 'getNamespacedTagKey', 'createTagKey', 'updateTagKey', 'deleteTagKey', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; - for (const methodName of tagKeysStubMethods) { - const callPromise = this.tagKeysStub.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.tagKeysStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudresourcemanager.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 'cloudresourcemanager.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only' - ]; - } - - 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 -- - // ------------------- -/** - * Retrieves a TagKey. This method will return `PERMISSION_DENIED` if the - * key does not exist or the user does not have permission to view it. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A resource name in the format `tagKeys/{id}`, such as - * `tagKeys/123`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.resourcemanager.v3.TagKey|TagKey}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_keys.get_tag_key.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_GetTagKey_async - */ - getTagKey( - request?: protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagKey, - protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|undefined, {}|undefined - ]>; - getTagKey( - request: protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.resourcemanager.v3.ITagKey, - protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|null|undefined, - {}|null|undefined>): void; - getTagKey( - request: protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest, - callback: Callback< - protos.google.cloud.resourcemanager.v3.ITagKey, - protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|null|undefined, - {}|null|undefined>): void; - getTagKey( - request?: protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.resourcemanager.v3.ITagKey, - protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.resourcemanager.v3.ITagKey, - protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagKey, - protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getTagKey(request, options, callback); - } -/** - * Retrieves a TagKey by its namespaced name. - * This method will return `PERMISSION_DENIED` if the key does not exist - * or the user does not have permission to view it. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A namespaced tag key name in the format - * `{parentId}/{tagKeyShort}`, such as `42/foo` for a key with short name - * "foo" under the organization with ID 42 or `r2-d2/bar` for a key with short - * name "bar" under the project `r2-d2`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.resourcemanager.v3.TagKey|TagKey}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_keys.get_namespaced_tag_key.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_GetNamespacedTagKey_async - */ - getNamespacedTagKey( - request?: protos.google.cloud.resourcemanager.v3.IGetNamespacedTagKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagKey, - protos.google.cloud.resourcemanager.v3.IGetNamespacedTagKeyRequest|undefined, {}|undefined - ]>; - getNamespacedTagKey( - request: protos.google.cloud.resourcemanager.v3.IGetNamespacedTagKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.resourcemanager.v3.ITagKey, - protos.google.cloud.resourcemanager.v3.IGetNamespacedTagKeyRequest|null|undefined, - {}|null|undefined>): void; - getNamespacedTagKey( - request: protos.google.cloud.resourcemanager.v3.IGetNamespacedTagKeyRequest, - callback: Callback< - protos.google.cloud.resourcemanager.v3.ITagKey, - protos.google.cloud.resourcemanager.v3.IGetNamespacedTagKeyRequest|null|undefined, - {}|null|undefined>): void; - getNamespacedTagKey( - request?: protos.google.cloud.resourcemanager.v3.IGetNamespacedTagKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.resourcemanager.v3.ITagKey, - protos.google.cloud.resourcemanager.v3.IGetNamespacedTagKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.resourcemanager.v3.ITagKey, - protos.google.cloud.resourcemanager.v3.IGetNamespacedTagKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagKey, - protos.google.cloud.resourcemanager.v3.IGetNamespacedTagKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.getNamespacedTagKey(request, options, callback); - } -/** - * Gets the access control policy for a TagKey. The returned policy may be - * empty if no such policy or resource exists. The `resource` field should - * be the TagKey's resource name. For example, "tagKeys/1234". - * The caller must have - * `cloudresourcemanager.googleapis.com/tagKeys.getIamPolicy` permission on - * the specified TagKey. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_keys.get_iam_policy.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_GetIamPolicy_async - */ - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.getIamPolicy(request, options, callback); - } -/** - * Sets the access control policy on a TagKey, replacing any existing - * policy. The `resource` field should be the TagKey's resource name. - * For example, "tagKeys/1234". - * The caller must have `resourcemanager.tagKeys.setIamPolicy` permission - * on the identified tagValue. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_keys.set_iam_policy.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_SetIamPolicy_async - */ - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.setIamPolicy(request, options, callback); - } -/** - * Returns permissions that a caller has on the specified TagKey. - * The `resource` field should be the TagKey's resource name. - * For example, "tagKeys/1234". - * - * There are no permissions required for making this API call. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_keys.test_iam_permissions.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_TestIamPermissions_async - */ - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.testIamPermissions(request, options, callback); - } - -/** - * Creates a new TagKey. If another request with the same parameters is - * sent while the original request is in process, the second request - * will receive an error. A maximum of 1000 TagKeys can exist under a parent - * at any given time. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.resourcemanager.v3.TagKey} request.tagKey - * Required. The TagKey to be created. Only fields `short_name`, - * `description`, and `parent` are considered during the creation request. - * @param {boolean} [request.validateOnly] - * Optional. Set to true to perform validations necessary for creating the - * resource, but not actually perform the action. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_keys.create_tag_key.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_CreateTagKey_async - */ - createTagKey( - request?: protos.google.cloud.resourcemanager.v3.ICreateTagKeyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createTagKey( - request: protos.google.cloud.resourcemanager.v3.ICreateTagKeyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createTagKey( - request: protos.google.cloud.resourcemanager.v3.ICreateTagKeyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createTagKey( - request?: protos.google.cloud.resourcemanager.v3.ICreateTagKeyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.createTagKey(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createTagKey()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_keys.create_tag_key.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_CreateTagKey_async - */ - async checkCreateTagKeyProgress(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.createTagKey, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the attributes of the TagKey resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.resourcemanager.v3.TagKey} request.tagKey - * Required. The new definition of the TagKey. Only the `description` and - * `etag` fields can be updated by this request. If the `etag` field is not - * empty, it must match the `etag` field of the existing tag key. Otherwise, - * `ABORTED` will be returned. - * @param {google.protobuf.FieldMask} request.updateMask - * Fields to be updated. The mask may only contain `description` or - * `etag`. If omitted entirely, both `description` and `etag` are assumed to - * be significant. - * @param {boolean} request.validateOnly - * Set as true to perform validations necessary for updating the resource, but - * not actually perform the action. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_keys.update_tag_key.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_UpdateTagKey_async - */ - updateTagKey( - request?: protos.google.cloud.resourcemanager.v3.IUpdateTagKeyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateTagKey( - request: protos.google.cloud.resourcemanager.v3.IUpdateTagKeyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateTagKey( - request: protos.google.cloud.resourcemanager.v3.IUpdateTagKeyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateTagKey( - request?: protos.google.cloud.resourcemanager.v3.IUpdateTagKeyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'tag_key.name': request.tagKey!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateTagKey(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateTagKey()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_keys.update_tag_key.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_UpdateTagKey_async - */ - async checkUpdateTagKeyProgress(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.updateTagKey, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a TagKey. The TagKey cannot be deleted if it has any child - * TagValues. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of a TagKey to be deleted in the format - * `tagKeys/123`. The TagKey cannot be a parent of any existing TagValues or - * it will not be deleted successfully. - * @param {boolean} [request.validateOnly] - * Optional. Set as true to perform validations necessary for deletion, but - * not actually perform the action. - * @param {string} [request.etag] - * Optional. The etag known to the client for the expected state of the - * TagKey. This is to be used for optimistic concurrency. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_keys.delete_tag_key.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_DeleteTagKey_async - */ - deleteTagKey( - request?: protos.google.cloud.resourcemanager.v3.IDeleteTagKeyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteTagKey( - request: protos.google.cloud.resourcemanager.v3.IDeleteTagKeyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteTagKey( - request: protos.google.cloud.resourcemanager.v3.IDeleteTagKeyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteTagKey( - request?: protos.google.cloud.resourcemanager.v3.IDeleteTagKeyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteTagKey(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteTagKey()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_keys.delete_tag_key.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_DeleteTagKey_async - */ - async checkDeleteTagKeyProgress(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.deleteTagKey, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists all TagKeys for a parent resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the TagKey's parent. - * Must be of the form `organizations/{org_id}` or `projects/{project_id}` or - * `projects/{project_number}` - * @param {number} [request.pageSize] - * Optional. The maximum number of TagKeys to return in the response. The - * server allows a maximum of 300 TagKeys to return. If unspecified, the - * server will use 100 as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `ListTagKey` - * that indicates where this listing should continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.resourcemanager.v3.TagKey|TagKey}. - * 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 `listTagKeysAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listTagKeys( - request?: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagKey[], - protos.google.cloud.resourcemanager.v3.IListTagKeysRequest|null, - protos.google.cloud.resourcemanager.v3.IListTagKeysResponse - ]>; - listTagKeys( - request: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, - protos.google.cloud.resourcemanager.v3.IListTagKeysResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagKey>): void; - listTagKeys( - request: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, - protos.google.cloud.resourcemanager.v3.IListTagKeysResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagKey>): void; - listTagKeys( - request?: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, - protos.google.cloud.resourcemanager.v3.IListTagKeysResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagKey>, - callback?: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, - protos.google.cloud.resourcemanager.v3.IListTagKeysResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagKey>): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagKey[], - protos.google.cloud.resourcemanager.v3.IListTagKeysRequest|null, - protos.google.cloud.resourcemanager.v3.IListTagKeysResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.listTagKeys(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the TagKey's parent. - * Must be of the form `organizations/{org_id}` or `projects/{project_id}` or - * `projects/{project_number}` - * @param {number} [request.pageSize] - * Optional. The maximum number of TagKeys to return in the response. The - * server allows a maximum of 300 TagKeys to return. If unspecified, the - * server will use 100 as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `ListTagKey` - * that indicates where this listing should continue from. - * @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 protos.google.cloud.resourcemanager.v3.TagKey|TagKey} 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 `listTagKeysAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listTagKeysStream( - request?: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listTagKeys']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTagKeys.createStream( - this.innerApiCalls.listTagKeys as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listTagKeys`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the TagKey's parent. - * Must be of the form `organizations/{org_id}` or `projects/{project_id}` or - * `projects/{project_number}` - * @param {number} [request.pageSize] - * Optional. The maximum number of TagKeys to return in the response. The - * server allows a maximum of 300 TagKeys to return. If unspecified, the - * server will use 100 as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `ListTagKey` - * that indicates where this listing should continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.resourcemanager.v3.TagKey|TagKey}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_keys.list_tag_keys.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_ListTagKeys_async - */ - listTagKeysAsync( - request?: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listTagKeys']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTagKeys.asyncIterate( - this.innerApiCalls['listTagKeys'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * 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 folder resource name string. - * - * @param {string} folder - * @returns {string} Resource name string. - */ - folderPath(folder:string) { - return this.pathTemplates.folderPathTemplate.render({ - folder: folder, - }); - } - - /** - * Parse the folder from Folder resource. - * - * @param {string} folderName - * A fully-qualified path representing Folder resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderName(folderName: string) { - return this.pathTemplates.folderPathTemplate.match(folderName).folder; - } - - /** - * Return a fully-qualified organization resource name string. - * - * @param {string} organization - * @returns {string} Resource name string. - */ - organizationPath(organization:string) { - return this.pathTemplates.organizationPathTemplate.render({ - organization: organization, - }); - } - - /** - * Parse the organization from Organization resource. - * - * @param {string} organizationName - * A fully-qualified path representing Organization resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationName(organizationName: string) { - return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified tagBinding resource name string. - * - * @param {string} tag_binding - * @returns {string} Resource name string. - */ - tagBindingPath(tagBinding:string) { - return this.pathTemplates.tagBindingPathTemplate.render({ - tag_binding: tagBinding, - }); - } - - /** - * Parse the tag_binding from TagBinding resource. - * - * @param {string} tagBindingName - * A fully-qualified path representing TagBinding resource. - * @returns {string} A string representing the tag_binding. - */ - matchTagBindingFromTagBindingName(tagBindingName: string) { - return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; - } - - /** - * Return a fully-qualified tagHold resource name string. - * - * @param {string} tag_value - * @param {string} tag_hold - * @returns {string} Resource name string. - */ - tagHoldPath(tagValue:string,tagHold:string) { - return this.pathTemplates.tagHoldPathTemplate.render({ - tag_value: tagValue, - tag_hold: tagHold, - }); - } - - /** - * Parse the tag_value from TagHold resource. - * - * @param {string} tagHoldName - * A fully-qualified path representing TagHold resource. - * @returns {string} A string representing the tag_value. - */ - matchTagValueFromTagHoldName(tagHoldName: string) { - return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_value; - } - - /** - * Parse the tag_hold from TagHold resource. - * - * @param {string} tagHoldName - * A fully-qualified path representing TagHold resource. - * @returns {string} A string representing the tag_hold. - */ - matchTagHoldFromTagHoldName(tagHoldName: string) { - return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_hold; - } - - /** - * Return a fully-qualified tagKey resource name string. - * - * @param {string} tag_key - * @returns {string} Resource name string. - */ - tagKeyPath(tagKey:string) { - return this.pathTemplates.tagKeyPathTemplate.render({ - tag_key: tagKey, - }); - } - - /** - * Parse the tag_key from TagKey resource. - * - * @param {string} tagKeyName - * A fully-qualified path representing TagKey resource. - * @returns {string} A string representing the tag_key. - */ - matchTagKeyFromTagKeyName(tagKeyName: string) { - return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; - } - - /** - * Return a fully-qualified tagValue resource name string. - * - * @param {string} tag_value - * @returns {string} Resource name string. - */ - tagValuePath(tagValue:string) { - return this.pathTemplates.tagValuePathTemplate.render({ - tag_value: tagValue, - }); - } - - /** - * Parse the tag_value from TagValue resource. - * - * @param {string} tagValueName - * A fully-qualified path representing TagValue resource. - * @returns {string} A string representing the tag_value. - */ - matchTagValueFromTagValueName(tagValueName: string) { - return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; - } - - /** - * 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.tagKeysStub && !this._terminated) { - return this.tagKeysStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_client_config.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_client_config.json deleted file mode 100644 index f1e7c83955d..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_client_config.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "interfaces": { - "google.cloud.resourcemanager.v3.TagKeys": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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": { - "ListTagKeys": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "GetTagKey": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "GetNamespacedTagKey": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateTagKey": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateTagKey": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteTagKey": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "SetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "TestIamPermissions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_proto_list.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_proto_list.json deleted file mode 100644 index 639794aadd4..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_keys_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/cloud/resourcemanager/v3/folders.proto", - "../../protos/google/cloud/resourcemanager/v3/organizations.proto", - "../../protos/google/cloud/resourcemanager/v3/projects.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_holds.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" -] diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_client.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_client.ts deleted file mode 100644 index 9a9220b0702..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_client.ts +++ /dev/null @@ -1,1581 +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} 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/v3/tag_values_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './tag_values_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Allow users to create and manage tag values. - * @class - * @memberof v3 - */ -export class TagValuesClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - tagValuesStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of TagValuesClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 TagValuesClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof TagValuesClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - folderPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}' - ), - organizationPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - tagBindingPathTemplate: new this._gaxModule.PathTemplate( - 'tagBindings/{tag_binding}' - ), - tagHoldPathTemplate: new this._gaxModule.PathTemplate( - 'tagValues/{tag_value}/tagHolds/{tag_hold}' - ), - tagKeyPathTemplate: new this._gaxModule.PathTemplate( - 'tagKeys/{tag_key}' - ), - tagValuePathTemplate: new this._gaxModule.PathTemplate( - 'tagValues/{tag_value}' - ), - }; - - // 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 = { - listTagValues: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tagValues') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v3/{name=operations/**}',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createTagValueResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.TagValue') as gax.protobuf.Type; - const createTagValueMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.CreateTagValueMetadata') as gax.protobuf.Type; - const updateTagValueResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.TagValue') as gax.protobuf.Type; - const updateTagValueMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.UpdateTagValueMetadata') as gax.protobuf.Type; - const deleteTagValueResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.TagValue') as gax.protobuf.Type; - const deleteTagValueMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.DeleteTagValueMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createTagValue: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createTagValueResponse.decode.bind(createTagValueResponse), - createTagValueMetadata.decode.bind(createTagValueMetadata)), - updateTagValue: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateTagValueResponse.decode.bind(updateTagValueResponse), - updateTagValueMetadata.decode.bind(updateTagValueMetadata)), - deleteTagValue: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteTagValueResponse.decode.bind(deleteTagValueResponse), - deleteTagValueMetadata.decode.bind(deleteTagValueMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.resourcemanager.v3.TagValues', 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.tagValuesStub) { - return this.tagValuesStub; - } - - // Put together the "service stub" for - // google.cloud.resourcemanager.v3.TagValues. - this.tagValuesStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.TagValues') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.resourcemanager.v3.TagValues, - 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 tagValuesStubMethods = - ['listTagValues', 'getTagValue', 'getNamespacedTagValue', 'createTagValue', 'updateTagValue', 'deleteTagValue', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; - for (const methodName of tagValuesStubMethods) { - const callPromise = this.tagValuesStub.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.tagValuesStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudresourcemanager.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 'cloudresourcemanager.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only' - ]; - } - - 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 -- - // ------------------- -/** - * Retrieves a TagValue. This method will return `PERMISSION_DENIED` if the - * value does not exist or the user does not have permission to view it. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name for TagValue to be fetched in the format - * `tagValues/456`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.resourcemanager.v3.TagValue|TagValue}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_values.get_tag_value.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_GetTagValue_async - */ - getTagValue( - request?: protos.google.cloud.resourcemanager.v3.IGetTagValueRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagValue, - protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|undefined, {}|undefined - ]>; - getTagValue( - request: protos.google.cloud.resourcemanager.v3.IGetTagValueRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.resourcemanager.v3.ITagValue, - protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|null|undefined, - {}|null|undefined>): void; - getTagValue( - request: protos.google.cloud.resourcemanager.v3.IGetTagValueRequest, - callback: Callback< - protos.google.cloud.resourcemanager.v3.ITagValue, - protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|null|undefined, - {}|null|undefined>): void; - getTagValue( - request?: protos.google.cloud.resourcemanager.v3.IGetTagValueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.resourcemanager.v3.ITagValue, - protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.resourcemanager.v3.ITagValue, - protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagValue, - protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getTagValue(request, options, callback); - } -/** - * Retrieves a TagValue by its namespaced name. - * This method will return `PERMISSION_DENIED` if the value does not exist - * or the user does not have permission to view it. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A namespaced tag value name in the following format: - * - * `{parentId}/{tagKeyShort}/{tagValueShort}` - * - * Examples: - * - `42/foo/abc` for a value with short name "abc" under the key with short - * name "foo" under the organization with ID 42 - * - `r2-d2/bar/xyz` for a value with short name "xyz" under the key with - * short name "bar" under the project with ID "r2-d2" - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.resourcemanager.v3.TagValue|TagValue}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_values.get_namespaced_tag_value.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_GetNamespacedTagValue_async - */ - getNamespacedTagValue( - request?: protos.google.cloud.resourcemanager.v3.IGetNamespacedTagValueRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagValue, - protos.google.cloud.resourcemanager.v3.IGetNamespacedTagValueRequest|undefined, {}|undefined - ]>; - getNamespacedTagValue( - request: protos.google.cloud.resourcemanager.v3.IGetNamespacedTagValueRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.resourcemanager.v3.ITagValue, - protos.google.cloud.resourcemanager.v3.IGetNamespacedTagValueRequest|null|undefined, - {}|null|undefined>): void; - getNamespacedTagValue( - request: protos.google.cloud.resourcemanager.v3.IGetNamespacedTagValueRequest, - callback: Callback< - protos.google.cloud.resourcemanager.v3.ITagValue, - protos.google.cloud.resourcemanager.v3.IGetNamespacedTagValueRequest|null|undefined, - {}|null|undefined>): void; - getNamespacedTagValue( - request?: protos.google.cloud.resourcemanager.v3.IGetNamespacedTagValueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.resourcemanager.v3.ITagValue, - protos.google.cloud.resourcemanager.v3.IGetNamespacedTagValueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.resourcemanager.v3.ITagValue, - protos.google.cloud.resourcemanager.v3.IGetNamespacedTagValueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagValue, - protos.google.cloud.resourcemanager.v3.IGetNamespacedTagValueRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.getNamespacedTagValue(request, options, callback); - } -/** - * Gets the access control policy for a TagValue. The returned policy may be - * empty if no such policy or resource exists. The `resource` field should - * be the TagValue's resource name. For example: `tagValues/1234`. - * The caller must have the - * `cloudresourcemanager.googleapis.com/tagValues.getIamPolicy` permission on - * the identified TagValue to get the access control policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_values.get_iam_policy.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_GetIamPolicy_async - */ - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.getIamPolicy(request, options, callback); - } -/** - * Sets the access control policy on a TagValue, replacing any existing - * policy. The `resource` field should be the TagValue's resource name. - * For example: `tagValues/1234`. - * The caller must have `resourcemanager.tagValues.setIamPolicy` permission - * on the identified tagValue. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_values.set_iam_policy.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_SetIamPolicy_async - */ - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.setIamPolicy(request, options, callback); - } -/** - * Returns permissions that a caller has on the specified TagValue. - * The `resource` field should be the TagValue's resource name. For example: - * `tagValues/1234`. - * - * There are no permissions required for making this API call. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_values.test_iam_permissions.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_TestIamPermissions_async - */ - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.testIamPermissions(request, options, callback); - } - -/** - * Creates a TagValue as a child of the specified TagKey. If a another - * request with the same parameters is sent while the original request is in - * process the second request will receive an error. A maximum of 1000 - * TagValues can exist under a TagKey at any given time. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.resourcemanager.v3.TagValue} request.tagValue - * Required. The TagValue to be created. Only fields `short_name`, - * `description`, and `parent` are considered during the creation request. - * @param {boolean} [request.validateOnly] - * Optional. Set as true to perform the validations necessary for creating the - * resource, but not actually perform the action. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_values.create_tag_value.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_CreateTagValue_async - */ - createTagValue( - request?: protos.google.cloud.resourcemanager.v3.ICreateTagValueRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createTagValue( - request: protos.google.cloud.resourcemanager.v3.ICreateTagValueRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createTagValue( - request: protos.google.cloud.resourcemanager.v3.ICreateTagValueRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createTagValue( - request?: protos.google.cloud.resourcemanager.v3.ICreateTagValueRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.createTagValue(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createTagValue()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_values.create_tag_value.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_CreateTagValue_async - */ - async checkCreateTagValueProgress(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.createTagValue, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the attributes of the TagValue resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.resourcemanager.v3.TagValue} request.tagValue - * Required. The new definition of the TagValue. Only fields `description` and - * `etag` fields can be updated by this request. If the `etag` field is - * nonempty, it must match the `etag` field of the existing ControlGroup. - * Otherwise, `ABORTED` will be returned. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Fields to be updated. - * @param {boolean} [request.validateOnly] - * Optional. True to perform validations necessary for updating the resource, - * but not actually perform the action. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_values.update_tag_value.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_UpdateTagValue_async - */ - updateTagValue( - request?: protos.google.cloud.resourcemanager.v3.IUpdateTagValueRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateTagValue( - request: protos.google.cloud.resourcemanager.v3.IUpdateTagValueRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateTagValue( - request: protos.google.cloud.resourcemanager.v3.IUpdateTagValueRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateTagValue( - request?: protos.google.cloud.resourcemanager.v3.IUpdateTagValueRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'tag_value.name': request.tagValue!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateTagValue(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateTagValue()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_values.update_tag_value.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_UpdateTagValue_async - */ - async checkUpdateTagValueProgress(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.updateTagValue, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a TagValue. The TagValue cannot have any bindings when it is - * deleted. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name for TagValue to be deleted in the format - * tagValues/456. - * @param {boolean} [request.validateOnly] - * Optional. Set as true to perform the validations necessary for deletion, - * but not actually perform the action. - * @param {string} [request.etag] - * Optional. The etag known to the client for the expected state of the - * TagValue. This is to be used for optimistic concurrency. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_values.delete_tag_value.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_DeleteTagValue_async - */ - deleteTagValue( - request?: protos.google.cloud.resourcemanager.v3.IDeleteTagValueRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteTagValue( - request: protos.google.cloud.resourcemanager.v3.IDeleteTagValueRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteTagValue( - request: protos.google.cloud.resourcemanager.v3.IDeleteTagValueRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteTagValue( - request?: protos.google.cloud.resourcemanager.v3.IDeleteTagValueRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteTagValue(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteTagValue()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_values.delete_tag_value.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_DeleteTagValue_async - */ - async checkDeleteTagValueProgress(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.deleteTagValue, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists all TagValues for a specific TagKey. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. - * @param {number} [request.pageSize] - * Optional. The maximum number of TagValues to return in the response. The - * server allows a maximum of 300 TagValues to return. If unspecified, the - * server will use 100 as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * `ListTagValues` that indicates where this listing should continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.resourcemanager.v3.TagValue|TagValue}. - * 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 `listTagValuesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listTagValues( - request?: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagValue[], - protos.google.cloud.resourcemanager.v3.IListTagValuesRequest|null, - protos.google.cloud.resourcemanager.v3.IListTagValuesResponse - ]>; - listTagValues( - request: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, - protos.google.cloud.resourcemanager.v3.IListTagValuesResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagValue>): void; - listTagValues( - request: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, - protos.google.cloud.resourcemanager.v3.IListTagValuesResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagValue>): void; - listTagValues( - request?: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, - protos.google.cloud.resourcemanager.v3.IListTagValuesResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagValue>, - callback?: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, - protos.google.cloud.resourcemanager.v3.IListTagValuesResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagValue>): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagValue[], - protos.google.cloud.resourcemanager.v3.IListTagValuesRequest|null, - protos.google.cloud.resourcemanager.v3.IListTagValuesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.listTagValues(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. - * @param {number} [request.pageSize] - * Optional. The maximum number of TagValues to return in the response. The - * server allows a maximum of 300 TagValues to return. If unspecified, the - * server will use 100 as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * `ListTagValues` that indicates where this listing should continue from. - * @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 protos.google.cloud.resourcemanager.v3.TagValue|TagValue} 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 `listTagValuesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listTagValuesStream( - request?: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listTagValues']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTagValues.createStream( - this.innerApiCalls.listTagValues as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listTagValues`, 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. - * @param {number} [request.pageSize] - * Optional. The maximum number of TagValues to return in the response. The - * server allows a maximum of 300 TagValues to return. If unspecified, the - * server will use 100 as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to - * `ListTagValues` that indicates where this listing should continue from. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.resourcemanager.v3.TagValue|TagValue}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v3/tag_values.list_tag_values.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_ListTagValues_async - */ - listTagValuesAsync( - request?: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listTagValues']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTagValues.asyncIterate( - this.innerApiCalls['listTagValues'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * 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 folder resource name string. - * - * @param {string} folder - * @returns {string} Resource name string. - */ - folderPath(folder:string) { - return this.pathTemplates.folderPathTemplate.render({ - folder: folder, - }); - } - - /** - * Parse the folder from Folder resource. - * - * @param {string} folderName - * A fully-qualified path representing Folder resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderName(folderName: string) { - return this.pathTemplates.folderPathTemplate.match(folderName).folder; - } - - /** - * Return a fully-qualified organization resource name string. - * - * @param {string} organization - * @returns {string} Resource name string. - */ - organizationPath(organization:string) { - return this.pathTemplates.organizationPathTemplate.render({ - organization: organization, - }); - } - - /** - * Parse the organization from Organization resource. - * - * @param {string} organizationName - * A fully-qualified path representing Organization resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationName(organizationName: string) { - return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified tagBinding resource name string. - * - * @param {string} tag_binding - * @returns {string} Resource name string. - */ - tagBindingPath(tagBinding:string) { - return this.pathTemplates.tagBindingPathTemplate.render({ - tag_binding: tagBinding, - }); - } - - /** - * Parse the tag_binding from TagBinding resource. - * - * @param {string} tagBindingName - * A fully-qualified path representing TagBinding resource. - * @returns {string} A string representing the tag_binding. - */ - matchTagBindingFromTagBindingName(tagBindingName: string) { - return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; - } - - /** - * Return a fully-qualified tagHold resource name string. - * - * @param {string} tag_value - * @param {string} tag_hold - * @returns {string} Resource name string. - */ - tagHoldPath(tagValue:string,tagHold:string) { - return this.pathTemplates.tagHoldPathTemplate.render({ - tag_value: tagValue, - tag_hold: tagHold, - }); - } - - /** - * Parse the tag_value from TagHold resource. - * - * @param {string} tagHoldName - * A fully-qualified path representing TagHold resource. - * @returns {string} A string representing the tag_value. - */ - matchTagValueFromTagHoldName(tagHoldName: string) { - return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_value; - } - - /** - * Parse the tag_hold from TagHold resource. - * - * @param {string} tagHoldName - * A fully-qualified path representing TagHold resource. - * @returns {string} A string representing the tag_hold. - */ - matchTagHoldFromTagHoldName(tagHoldName: string) { - return this.pathTemplates.tagHoldPathTemplate.match(tagHoldName).tag_hold; - } - - /** - * Return a fully-qualified tagKey resource name string. - * - * @param {string} tag_key - * @returns {string} Resource name string. - */ - tagKeyPath(tagKey:string) { - return this.pathTemplates.tagKeyPathTemplate.render({ - tag_key: tagKey, - }); - } - - /** - * Parse the tag_key from TagKey resource. - * - * @param {string} tagKeyName - * A fully-qualified path representing TagKey resource. - * @returns {string} A string representing the tag_key. - */ - matchTagKeyFromTagKeyName(tagKeyName: string) { - return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; - } - - /** - * Return a fully-qualified tagValue resource name string. - * - * @param {string} tag_value - * @returns {string} Resource name string. - */ - tagValuePath(tagValue:string) { - return this.pathTemplates.tagValuePathTemplate.render({ - tag_value: tagValue, - }); - } - - /** - * Parse the tag_value from TagValue resource. - * - * @param {string} tagValueName - * A fully-qualified path representing TagValue resource. - * @returns {string} A string representing the tag_value. - */ - matchTagValueFromTagValueName(tagValueName: string) { - return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; - } - - /** - * 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.tagValuesStub && !this._terminated) { - return this.tagValuesStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_client_config.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_client_config.json deleted file mode 100644 index 6ddb1d9c83a..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_client_config.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "interfaces": { - "google.cloud.resourcemanager.v3.TagValues": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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": { - "ListTagValues": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "GetTagValue": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "GetNamespacedTagValue": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateTagValue": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateTagValue": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteTagValue": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "SetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "TestIamPermissions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_proto_list.json b/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_proto_list.json deleted file mode 100644 index 639794aadd4..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/src/v3/tag_values_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/cloud/resourcemanager/v3/folders.proto", - "../../protos/google/cloud/resourcemanager/v3/organizations.proto", - "../../protos/google/cloud/resourcemanager/v3/projects.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_holds.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" -] diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-resourcemanager/v3/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 8ef5ef34b96..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/system-test/fixtures/sample/src/index.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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const resourcemanager = require('@google-cloud/resource-manager'); - -function main() { - const foldersClient = new resourcemanager.FoldersClient(); - const organizationsClient = new resourcemanager.OrganizationsClient(); - const projectsClient = new resourcemanager.ProjectsClient(); - const tagBindingsClient = new resourcemanager.TagBindingsClient(); - const tagHoldsClient = new resourcemanager.TagHoldsClient(); - const tagKeysClient = new resourcemanager.TagKeysClient(); - const tagValuesClient = new resourcemanager.TagValuesClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 47d65a2016d..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/system-test/fixtures/sample/src/index.ts +++ /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. ** - -import {FoldersClient, OrganizationsClient, ProjectsClient, TagBindingsClient, TagHoldsClient, TagKeysClient, TagValuesClient} from '@google-cloud/resource-manager'; - -// check that the client class type name can be used -function doStuffWithFoldersClient(client: FoldersClient) { - client.close(); -} -function doStuffWithOrganizationsClient(client: OrganizationsClient) { - client.close(); -} -function doStuffWithProjectsClient(client: ProjectsClient) { - client.close(); -} -function doStuffWithTagBindingsClient(client: TagBindingsClient) { - client.close(); -} -function doStuffWithTagHoldsClient(client: TagHoldsClient) { - client.close(); -} -function doStuffWithTagKeysClient(client: TagKeysClient) { - client.close(); -} -function doStuffWithTagValuesClient(client: TagValuesClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const foldersClient = new FoldersClient(); - doStuffWithFoldersClient(foldersClient); - // check that the client instance can be created - const organizationsClient = new OrganizationsClient(); - doStuffWithOrganizationsClient(organizationsClient); - // check that the client instance can be created - const projectsClient = new ProjectsClient(); - doStuffWithProjectsClient(projectsClient); - // check that the client instance can be created - const tagBindingsClient = new TagBindingsClient(); - doStuffWithTagBindingsClient(tagBindingsClient); - // check that the client instance can be created - const tagHoldsClient = new TagHoldsClient(); - doStuffWithTagHoldsClient(tagHoldsClient); - // check that the client instance can be created - const tagKeysClient = new TagKeysClient(); - doStuffWithTagKeysClient(tagKeysClient); - // check that the client instance can be created - const tagValuesClient = new TagValuesClient(); - doStuffWithTagValuesClient(tagValuesClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/system-test/install.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/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-resourcemanager/v3/test/gapic_folders_v3.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_folders_v3.ts deleted file mode 100644 index 93aefe82f9a..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_folders_v3.ts +++ /dev/null @@ -1,2205 +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 foldersModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v3.FoldersClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = foldersModule.v3.FoldersClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = foldersModule.v3.FoldersClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = foldersModule.v3.FoldersClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new foldersModule.v3.FoldersClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new foldersModule.v3.FoldersClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.foldersStub, undefined); - await client.initialize(); - assert(client.foldersStub); - }); - - it('has close method for the initialized client', done => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.foldersStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.foldersStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new foldersModule.v3.FoldersClient({ - 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 foldersModule.v3.FoldersClient({ - 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('getFolder', () => { - it('invokes getFolder without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetFolderRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetFolderRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.Folder() - ); - client.innerApiCalls.getFolder = stubSimpleCall(expectedResponse); - const [response] = await client.getFolder(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getFolder as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFolder as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getFolder without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetFolderRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetFolderRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.Folder() - ); - client.innerApiCalls.getFolder = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getFolder( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IFolder|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getFolder as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFolder as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getFolder with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetFolderRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetFolderRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getFolder = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getFolder(request), expectedError); - const actualRequest = (client.innerApiCalls.getFolder as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFolder as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getFolder with closed client', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetFolderRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetFolderRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getFolder(request), expectedError); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy with closed client', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); - }); - - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy with closed client', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); - }); - - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions with closed client', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); - }); - - describe('createFolder', () => { - it('invokes createFolder without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateFolderRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createFolder = stubLongRunningCall(expectedResponse); - const [operation] = await client.createFolder(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes createFolder without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateFolderRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createFolder = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createFolder( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes createFolder with call error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateFolderRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.createFolder = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createFolder(request), expectedError); - }); - - it('invokes createFolder with LRO error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateFolderRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.createFolder = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createFolder(request); - await assert.rejects(operation.promise(), expectedError); - }); - - it('invokes checkCreateFolderProgress without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateFolderProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateFolderProgress with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateFolderProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateFolder', () => { - it('invokes updateFolder without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UpdateFolderRequest() - ); - request.folder ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateFolderRequest', ['folder', 'name']); - request.folder.name = defaultValue1; - const expectedHeaderRequestParams = `folder.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateFolder = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateFolder(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateFolder as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFolder as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateFolder without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UpdateFolderRequest() - ); - request.folder ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateFolderRequest', ['folder', 'name']); - request.folder.name = defaultValue1; - const expectedHeaderRequestParams = `folder.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateFolder = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateFolder( - request, - (err?: Error|null, - result?: 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.updateFolder as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFolder as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateFolder with call error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UpdateFolderRequest() - ); - request.folder ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateFolderRequest', ['folder', 'name']); - request.folder.name = defaultValue1; - const expectedHeaderRequestParams = `folder.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateFolder = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateFolder(request), expectedError); - const actualRequest = (client.innerApiCalls.updateFolder as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFolder as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateFolder with LRO error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UpdateFolderRequest() - ); - request.folder ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateFolderRequest', ['folder', 'name']); - request.folder.name = defaultValue1; - const expectedHeaderRequestParams = `folder.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateFolder = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateFolder(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateFolder as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFolder as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateFolderProgress without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateFolderProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateFolderProgress with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateFolderProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('moveFolder', () => { - it('invokes moveFolder without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.MoveFolderRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.MoveFolderRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.moveFolder = stubLongRunningCall(expectedResponse); - const [operation] = await client.moveFolder(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.moveFolder as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.moveFolder as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes moveFolder without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.MoveFolderRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.MoveFolderRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.moveFolder = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.moveFolder( - request, - (err?: Error|null, - result?: 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.moveFolder as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.moveFolder as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes moveFolder with call error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.MoveFolderRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.MoveFolderRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.moveFolder = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.moveFolder(request), expectedError); - const actualRequest = (client.innerApiCalls.moveFolder as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.moveFolder as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes moveFolder with LRO error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.MoveFolderRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.MoveFolderRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.moveFolder = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.moveFolder(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.moveFolder as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.moveFolder as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkMoveFolderProgress without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkMoveFolderProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkMoveFolderProgress with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkMoveFolderProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteFolder', () => { - it('invokes deleteFolder without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteFolderRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteFolderRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteFolder = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteFolder(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteFolder as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFolder as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteFolder without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteFolderRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteFolderRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteFolder = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteFolder( - request, - (err?: Error|null, - result?: 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.deleteFolder as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFolder as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteFolder with call error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteFolderRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteFolderRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteFolder = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteFolder(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteFolder as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFolder as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteFolder with LRO error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteFolderRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteFolderRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteFolder = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteFolder(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteFolder as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFolder as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteFolderProgress without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteFolderProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteFolderProgress with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteFolderProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('undeleteFolder', () => { - it('invokes undeleteFolder without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UndeleteFolderRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UndeleteFolderRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.undeleteFolder = stubLongRunningCall(expectedResponse); - const [operation] = await client.undeleteFolder(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.undeleteFolder as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeleteFolder as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes undeleteFolder without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UndeleteFolderRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UndeleteFolderRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.undeleteFolder = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.undeleteFolder( - request, - (err?: Error|null, - result?: 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.undeleteFolder as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeleteFolder as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes undeleteFolder with call error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UndeleteFolderRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UndeleteFolderRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.undeleteFolder = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.undeleteFolder(request), expectedError); - const actualRequest = (client.innerApiCalls.undeleteFolder as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeleteFolder as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes undeleteFolder with LRO error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UndeleteFolderRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UndeleteFolderRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.undeleteFolder = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.undeleteFolder(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.undeleteFolder as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeleteFolder as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUndeleteFolderProgress without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUndeleteFolderProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUndeleteFolderProgress with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUndeleteFolderProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listFolders', () => { - it('invokes listFolders without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListFoldersRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - ]; - client.innerApiCalls.listFolders = stubSimpleCall(expectedResponse); - const [response] = await client.listFolders(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes listFolders without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListFoldersRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - ]; - client.innerApiCalls.listFolders = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listFolders( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IFolder[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes listFolders with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListFoldersRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.listFolders = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listFolders(request), expectedError); - }); - - it('invokes listFoldersStream without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListFoldersRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - ]; - client.descriptors.page.listFolders.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listFoldersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.Folder[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Folder) => { - 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.listFolders.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listFolders, request)); - }); - - it('invokes listFoldersStream with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListFoldersRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.listFolders.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listFoldersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.Folder[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Folder) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listFolders.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listFolders, request)); - }); - - it('uses async iteration with listFolders without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListFoldersRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - ]; - client.descriptors.page.listFolders.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.resourcemanager.v3.IFolder[] = []; - const iterable = client.listFoldersAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listFolders.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - - it('uses async iteration with listFolders with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListFoldersRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.listFolders.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listFoldersAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.resourcemanager.v3.IFolder[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listFolders.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('searchFolders', () => { - it('invokes searchFolders without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - ]; - client.innerApiCalls.searchFolders = stubSimpleCall(expectedResponse); - const [response] = await client.searchFolders(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes searchFolders without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - ]; - client.innerApiCalls.searchFolders = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchFolders( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IFolder[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes searchFolders with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.searchFolders = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchFolders(request), expectedError); - }); - - it('invokes searchFoldersStream without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - ]; - client.descriptors.page.searchFolders.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchFoldersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.Folder[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Folder) => { - 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.searchFolders.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchFolders, request)); - }); - - it('invokes searchFoldersStream with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.searchFolders.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchFoldersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.Folder[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Folder) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.searchFolders.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchFolders, request)); - }); - - it('uses async iteration with searchFolders without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - ]; - client.descriptors.page.searchFolders.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.resourcemanager.v3.IFolder[] = []; - const iterable = client.searchFoldersAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchFolders.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - - it('uses async iteration with searchFolders with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.searchFolders.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchFoldersAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.resourcemanager.v3.IFolder[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchFolders.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - 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 foldersModule.v3.FoldersClient({ - 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 foldersModule.v3.FoldersClient({ - 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 foldersModule.v3.FoldersClient({ - 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 foldersModule.v3.FoldersClient({ - 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 foldersModule.v3.FoldersClient({ - 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 foldersModule.v3.FoldersClient({ - 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 foldersModule.v3.FoldersClient({ - 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 foldersModule.v3.FoldersClient({ - 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 foldersModule.v3.FoldersClient({ - 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 foldersModule.v3.FoldersClient({ - 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('folder', () => { - const fakePath = "/rendered/path/folder"; - const expectedParameters = { - folder: "folderValue", - }; - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderPath', () => { - const result = client.folderPath("folderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderName', () => { - const result = client.matchFolderFromFolderName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organization', () => { - const fakePath = "/rendered/path/organization"; - const expectedParameters = { - organization: "organizationValue", - }; - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationPath', () => { - const result = client.organizationPath("organizationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationName', () => { - const result = client.matchOrganizationFromOrganizationName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagBinding', () => { - const fakePath = "/rendered/path/tagBinding"; - const expectedParameters = { - tag_binding: "tagBindingValue", - }; - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagBindingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagBindingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagBindingPath', () => { - const result = client.tagBindingPath("tagBindingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagBindingFromTagBindingName', () => { - const result = client.matchTagBindingFromTagBindingName(fakePath); - assert.strictEqual(result, "tagBindingValue"); - assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagHold', () => { - const fakePath = "/rendered/path/tagHold"; - const expectedParameters = { - tag_value: "tagValueValue", - tag_hold: "tagHoldValue", - }; - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagHoldPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagHoldPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagHoldPath', () => { - const result = client.tagHoldPath("tagValueValue", "tagHoldValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagHoldPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagValueFromTagHoldName', () => { - const result = client.matchTagValueFromTagHoldName(fakePath); - assert.strictEqual(result, "tagValueValue"); - assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTagHoldFromTagHoldName', () => { - const result = client.matchTagHoldFromTagHoldName(fakePath); - assert.strictEqual(result, "tagHoldValue"); - assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagKey', () => { - const fakePath = "/rendered/path/tagKey"; - const expectedParameters = { - tag_key: "tagKeyValue", - }; - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagKeyPath', () => { - const result = client.tagKeyPath("tagKeyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagKeyFromTagKeyName', () => { - const result = client.matchTagKeyFromTagKeyName(fakePath); - assert.strictEqual(result, "tagKeyValue"); - assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagValue', () => { - const fakePath = "/rendered/path/tagValue"; - const expectedParameters = { - tag_value: "tagValueValue", - }; - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagValuePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagValuePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagValuePath', () => { - const result = client.tagValuePath("tagValueValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagValueFromTagValueName', () => { - const result = client.matchTagValueFromTagValueName(fakePath); - assert.strictEqual(result, "tagValueValue"); - assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_organizations_v3.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_organizations_v3.ts deleted file mode 100644 index 1065ddafdbb..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_organizations_v3.ts +++ /dev/null @@ -1,1025 +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 organizationsModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -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('v3.OrganizationsClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = organizationsModule.v3.OrganizationsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = organizationsModule.v3.OrganizationsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = organizationsModule.v3.OrganizationsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new organizationsModule.v3.OrganizationsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new organizationsModule.v3.OrganizationsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.organizationsStub, undefined); - await client.initialize(); - assert(client.organizationsStub); - }); - - it('has close method for the initialized client', done => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.organizationsStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.organizationsStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new organizationsModule.v3.OrganizationsClient({ - 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 organizationsModule.v3.OrganizationsClient({ - 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('getOrganization', () => { - it('invokes getOrganization without error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetOrganizationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetOrganizationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.Organization() - ); - client.innerApiCalls.getOrganization = stubSimpleCall(expectedResponse); - const [response] = await client.getOrganization(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getOrganization as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOrganization as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getOrganization without error using callback', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetOrganizationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetOrganizationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.Organization() - ); - client.innerApiCalls.getOrganization = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getOrganization( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IOrganization|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getOrganization as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOrganization as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getOrganization with error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetOrganizationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetOrganizationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getOrganization = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getOrganization(request), expectedError); - const actualRequest = (client.innerApiCalls.getOrganization as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOrganization as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getOrganization with closed client', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetOrganizationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetOrganizationRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getOrganization(request), expectedError); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy without error using callback', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy with error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy with closed client', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); - }); - - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy without error using callback', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy with error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy with closed client', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); - }); - - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions without error using callback', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions with error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions with closed client', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); - }); - - describe('searchOrganizations', () => { - it('invokes searchOrganizations without error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - ]; - client.innerApiCalls.searchOrganizations = stubSimpleCall(expectedResponse); - const [response] = await client.searchOrganizations(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes searchOrganizations without error using callback', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - ]; - client.innerApiCalls.searchOrganizations = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchOrganizations( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IOrganization[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes searchOrganizations with error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.searchOrganizations = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchOrganizations(request), expectedError); - }); - - it('invokes searchOrganizationsStream without error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - ]; - client.descriptors.page.searchOrganizations.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchOrganizationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.Organization[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Organization) => { - 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.searchOrganizations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchOrganizations, request)); - }); - - it('invokes searchOrganizationsStream with error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.searchOrganizations.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchOrganizationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.Organization[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Organization) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.searchOrganizations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchOrganizations, request)); - }); - - it('uses async iteration with searchOrganizations without error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - ]; - client.descriptors.page.searchOrganizations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.resourcemanager.v3.IOrganization[] = []; - const iterable = client.searchOrganizationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchOrganizations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - - it('uses async iteration with searchOrganizations with error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.searchOrganizations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchOrganizationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.resourcemanager.v3.IOrganization[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchOrganizations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('folder', () => { - const fakePath = "/rendered/path/folder"; - const expectedParameters = { - folder: "folderValue", - }; - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderPath', () => { - const result = client.folderPath("folderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderName', () => { - const result = client.matchFolderFromFolderName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organization', () => { - const fakePath = "/rendered/path/organization"; - const expectedParameters = { - organization: "organizationValue", - }; - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationPath', () => { - const result = client.organizationPath("organizationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationName', () => { - const result = client.matchOrganizationFromOrganizationName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagBinding', () => { - const fakePath = "/rendered/path/tagBinding"; - const expectedParameters = { - tag_binding: "tagBindingValue", - }; - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagBindingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagBindingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagBindingPath', () => { - const result = client.tagBindingPath("tagBindingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagBindingFromTagBindingName', () => { - const result = client.matchTagBindingFromTagBindingName(fakePath); - assert.strictEqual(result, "tagBindingValue"); - assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagHold', () => { - const fakePath = "/rendered/path/tagHold"; - const expectedParameters = { - tag_value: "tagValueValue", - tag_hold: "tagHoldValue", - }; - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagHoldPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagHoldPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagHoldPath', () => { - const result = client.tagHoldPath("tagValueValue", "tagHoldValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagHoldPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagValueFromTagHoldName', () => { - const result = client.matchTagValueFromTagHoldName(fakePath); - assert.strictEqual(result, "tagValueValue"); - assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTagHoldFromTagHoldName', () => { - const result = client.matchTagHoldFromTagHoldName(fakePath); - assert.strictEqual(result, "tagHoldValue"); - assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagKey', () => { - const fakePath = "/rendered/path/tagKey"; - const expectedParameters = { - tag_key: "tagKeyValue", - }; - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagKeyPath', () => { - const result = client.tagKeyPath("tagKeyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagKeyFromTagKeyName', () => { - const result = client.matchTagKeyFromTagKeyName(fakePath); - assert.strictEqual(result, "tagKeyValue"); - assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagValue', () => { - const fakePath = "/rendered/path/tagValue"; - const expectedParameters = { - tag_value: "tagValueValue", - }; - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagValuePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagValuePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagValuePath', () => { - const result = client.tagValuePath("tagValueValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagValueFromTagValueName', () => { - const result = client.matchTagValueFromTagValueName(fakePath); - assert.strictEqual(result, "tagValueValue"); - assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_projects_v3.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_projects_v3.ts deleted file mode 100644 index 80c78bed6a9..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_projects_v3.ts +++ /dev/null @@ -1,2205 +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 projectsModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v3.ProjectsClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = projectsModule.v3.ProjectsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = projectsModule.v3.ProjectsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = projectsModule.v3.ProjectsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new projectsModule.v3.ProjectsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new projectsModule.v3.ProjectsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.projectsStub, undefined); - await client.initialize(); - assert(client.projectsStub); - }); - - it('has close method for the initialized client', done => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.projectsStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.projectsStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new projectsModule.v3.ProjectsClient({ - 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 projectsModule.v3.ProjectsClient({ - 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('getProject', () => { - it('invokes getProject without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetProjectRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetProjectRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.Project() - ); - client.innerApiCalls.getProject = stubSimpleCall(expectedResponse); - const [response] = await client.getProject(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProject as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProject as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProject without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetProjectRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetProjectRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.Project() - ); - client.innerApiCalls.getProject = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProject( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IProject|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProject as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProject as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProject with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetProjectRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetProjectRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProject = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProject(request), expectedError); - const actualRequest = (client.innerApiCalls.getProject as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProject as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProject with closed client', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetProjectRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetProjectRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProject(request), expectedError); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy with closed client', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); - }); - - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy with closed client', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); - }); - - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions with closed client', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); - }); - - describe('createProject', () => { - it('invokes createProject without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateProjectRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createProject = stubLongRunningCall(expectedResponse); - const [operation] = await client.createProject(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes createProject without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateProjectRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createProject = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProject( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes createProject with call error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateProjectRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.createProject = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createProject(request), expectedError); - }); - - it('invokes createProject with LRO error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateProjectRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.createProject = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createProject(request); - await assert.rejects(operation.promise(), expectedError); - }); - - it('invokes checkCreateProjectProgress without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateProjectProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateProjectProgress with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateProjectProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateProject', () => { - it('invokes updateProject without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UpdateProjectRequest() - ); - request.project ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateProjectRequest', ['project', 'name']); - request.project.name = defaultValue1; - const expectedHeaderRequestParams = `project.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateProject = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateProject(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProject as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProject as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProject without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UpdateProjectRequest() - ); - request.project ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateProjectRequest', ['project', 'name']); - request.project.name = defaultValue1; - const expectedHeaderRequestParams = `project.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateProject = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProject( - request, - (err?: Error|null, - result?: 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.updateProject as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProject as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProject with call error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UpdateProjectRequest() - ); - request.project ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateProjectRequest', ['project', 'name']); - request.project.name = defaultValue1; - const expectedHeaderRequestParams = `project.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProject = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateProject(request), expectedError); - const actualRequest = (client.innerApiCalls.updateProject as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProject as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProject with LRO error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UpdateProjectRequest() - ); - request.project ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateProjectRequest', ['project', 'name']); - request.project.name = defaultValue1; - const expectedHeaderRequestParams = `project.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProject = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateProject(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateProject as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProject as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateProjectProgress without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateProjectProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateProjectProgress with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateProjectProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('moveProject', () => { - it('invokes moveProject without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.MoveProjectRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.MoveProjectRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.moveProject = stubLongRunningCall(expectedResponse); - const [operation] = await client.moveProject(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.moveProject as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.moveProject as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes moveProject without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.MoveProjectRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.MoveProjectRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.moveProject = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.moveProject( - request, - (err?: Error|null, - result?: 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.moveProject as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.moveProject as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes moveProject with call error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.MoveProjectRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.MoveProjectRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.moveProject = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.moveProject(request), expectedError); - const actualRequest = (client.innerApiCalls.moveProject as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.moveProject as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes moveProject with LRO error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.MoveProjectRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.MoveProjectRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.moveProject = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.moveProject(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.moveProject as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.moveProject as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkMoveProjectProgress without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkMoveProjectProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkMoveProjectProgress with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkMoveProjectProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteProject', () => { - it('invokes deleteProject without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteProjectRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteProjectRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteProject = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteProject(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProject as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProject as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProject without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteProjectRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteProjectRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteProject = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProject( - request, - (err?: Error|null, - result?: 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.deleteProject as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProject as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProject with call error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteProjectRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteProjectRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProject = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteProject(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProject as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProject as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProject with LRO error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteProjectRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteProjectRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProject = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteProject(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteProject as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProject as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteProjectProgress without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteProjectProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteProjectProgress with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteProjectProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('undeleteProject', () => { - it('invokes undeleteProject without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UndeleteProjectRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UndeleteProjectRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.undeleteProject = stubLongRunningCall(expectedResponse); - const [operation] = await client.undeleteProject(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.undeleteProject as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeleteProject as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes undeleteProject without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UndeleteProjectRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UndeleteProjectRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.undeleteProject = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.undeleteProject( - request, - (err?: Error|null, - result?: 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.undeleteProject as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeleteProject as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes undeleteProject with call error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UndeleteProjectRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UndeleteProjectRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.undeleteProject = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.undeleteProject(request), expectedError); - const actualRequest = (client.innerApiCalls.undeleteProject as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeleteProject as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes undeleteProject with LRO error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UndeleteProjectRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UndeleteProjectRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.undeleteProject = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.undeleteProject(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.undeleteProject as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeleteProject as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUndeleteProjectProgress without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUndeleteProjectProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUndeleteProjectProgress with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUndeleteProjectProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProjects', () => { - it('invokes listProjects without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListProjectsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - ]; - client.innerApiCalls.listProjects = stubSimpleCall(expectedResponse); - const [response] = await client.listProjects(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes listProjects without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListProjectsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - ]; - client.innerApiCalls.listProjects = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProjects( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IProject[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes listProjects with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListProjectsRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.listProjects = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProjects(request), expectedError); - }); - - it('invokes listProjectsStream without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListProjectsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - ]; - client.descriptors.page.listProjects.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProjectsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.Project[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Project) => { - 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.listProjects.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProjects, request)); - }); - - it('invokes listProjectsStream with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListProjectsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.listProjects.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProjectsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.Project[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Project) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProjects.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProjects, request)); - }); - - it('uses async iteration with listProjects without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListProjectsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - ]; - client.descriptors.page.listProjects.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.resourcemanager.v3.IProject[] = []; - const iterable = client.listProjectsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProjects.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - - it('uses async iteration with listProjects with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListProjectsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.listProjects.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProjectsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.resourcemanager.v3.IProject[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProjects.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('searchProjects', () => { - it('invokes searchProjects without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - ]; - client.innerApiCalls.searchProjects = stubSimpleCall(expectedResponse); - const [response] = await client.searchProjects(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes searchProjects without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - ]; - client.innerApiCalls.searchProjects = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchProjects( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IProject[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes searchProjects with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.searchProjects = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchProjects(request), expectedError); - }); - - it('invokes searchProjectsStream without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - ]; - client.descriptors.page.searchProjects.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchProjectsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.Project[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Project) => { - 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.searchProjects.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchProjects, request)); - }); - - it('invokes searchProjectsStream with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.searchProjects.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchProjectsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.Project[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Project) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.searchProjects.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchProjects, request)); - }); - - it('uses async iteration with searchProjects without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - ]; - client.descriptors.page.searchProjects.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.resourcemanager.v3.IProject[] = []; - const iterable = client.searchProjectsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchProjects.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - - it('uses async iteration with searchProjects with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.searchProjects.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchProjectsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.resourcemanager.v3.IProject[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchProjects.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - 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 projectsModule.v3.ProjectsClient({ - 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 projectsModule.v3.ProjectsClient({ - 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 projectsModule.v3.ProjectsClient({ - 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 projectsModule.v3.ProjectsClient({ - 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 projectsModule.v3.ProjectsClient({ - 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 projectsModule.v3.ProjectsClient({ - 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 projectsModule.v3.ProjectsClient({ - 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 projectsModule.v3.ProjectsClient({ - 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 projectsModule.v3.ProjectsClient({ - 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 projectsModule.v3.ProjectsClient({ - 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('folder', () => { - const fakePath = "/rendered/path/folder"; - const expectedParameters = { - folder: "folderValue", - }; - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderPath', () => { - const result = client.folderPath("folderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderName', () => { - const result = client.matchFolderFromFolderName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organization', () => { - const fakePath = "/rendered/path/organization"; - const expectedParameters = { - organization: "organizationValue", - }; - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationPath', () => { - const result = client.organizationPath("organizationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationName', () => { - const result = client.matchOrganizationFromOrganizationName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagBinding', () => { - const fakePath = "/rendered/path/tagBinding"; - const expectedParameters = { - tag_binding: "tagBindingValue", - }; - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagBindingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagBindingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagBindingPath', () => { - const result = client.tagBindingPath("tagBindingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagBindingFromTagBindingName', () => { - const result = client.matchTagBindingFromTagBindingName(fakePath); - assert.strictEqual(result, "tagBindingValue"); - assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagHold', () => { - const fakePath = "/rendered/path/tagHold"; - const expectedParameters = { - tag_value: "tagValueValue", - tag_hold: "tagHoldValue", - }; - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagHoldPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagHoldPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagHoldPath', () => { - const result = client.tagHoldPath("tagValueValue", "tagHoldValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagHoldPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagValueFromTagHoldName', () => { - const result = client.matchTagValueFromTagHoldName(fakePath); - assert.strictEqual(result, "tagValueValue"); - assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTagHoldFromTagHoldName', () => { - const result = client.matchTagHoldFromTagHoldName(fakePath); - assert.strictEqual(result, "tagHoldValue"); - assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagKey', () => { - const fakePath = "/rendered/path/tagKey"; - const expectedParameters = { - tag_key: "tagKeyValue", - }; - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagKeyPath', () => { - const result = client.tagKeyPath("tagKeyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagKeyFromTagKeyName', () => { - const result = client.matchTagKeyFromTagKeyName(fakePath); - assert.strictEqual(result, "tagKeyValue"); - assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagValue', () => { - const fakePath = "/rendered/path/tagValue"; - const expectedParameters = { - tag_value: "tagValueValue", - }; - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagValuePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagValuePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagValuePath', () => { - const result = client.tagValuePath("tagValueValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagValueFromTagValueName', () => { - const result = client.matchTagValueFromTagValueName(fakePath); - assert.strictEqual(result, "tagValueValue"); - assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_bindings_v3.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_bindings_v3.ts deleted file mode 100644 index 84289dbd944..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_bindings_v3.ts +++ /dev/null @@ -1,1307 +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 tagbindingsModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v3.TagBindingsClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = tagbindingsModule.v3.TagBindingsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = tagbindingsModule.v3.TagBindingsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = tagbindingsModule.v3.TagBindingsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new tagbindingsModule.v3.TagBindingsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tagBindingsStub, undefined); - await client.initialize(); - assert(client.tagBindingsStub); - }); - - it('has close method for the initialized client', done => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.tagBindingsStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tagBindingsStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new tagbindingsModule.v3.TagBindingsClient({ - 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 tagbindingsModule.v3.TagBindingsClient({ - 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('createTagBinding', () => { - it('invokes createTagBinding without error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateTagBindingRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createTagBinding = stubLongRunningCall(expectedResponse); - const [operation] = await client.createTagBinding(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes createTagBinding without error using callback', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateTagBindingRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createTagBinding = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createTagBinding( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes createTagBinding with call error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateTagBindingRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.createTagBinding = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createTagBinding(request), expectedError); - }); - - it('invokes createTagBinding with LRO error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateTagBindingRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.createTagBinding = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createTagBinding(request); - await assert.rejects(operation.promise(), expectedError); - }); - - it('invokes checkCreateTagBindingProgress without error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateTagBindingProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateTagBindingProgress with error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateTagBindingProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteTagBinding', () => { - it('invokes deleteTagBinding without error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteTagBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteTagBinding = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteTagBinding(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteTagBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTagBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteTagBinding without error using callback', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteTagBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteTagBinding = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteTagBinding( - request, - (err?: Error|null, - result?: 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.deleteTagBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTagBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteTagBinding with call error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteTagBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTagBinding = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteTagBinding(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteTagBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTagBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteTagBinding with LRO error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteTagBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTagBinding = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteTagBinding(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteTagBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTagBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteTagBindingProgress without error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteTagBindingProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteTagBindingProgress with error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteTagBindingProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listTagBindings', () => { - it('invokes listTagBindings without error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - ]; - client.innerApiCalls.listTagBindings = stubSimpleCall(expectedResponse); - const [response] = await client.listTagBindings(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes listTagBindings without error using callback', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - ]; - client.innerApiCalls.listTagBindings = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTagBindings( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagBinding[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes listTagBindings with error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.listTagBindings = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTagBindings(request), expectedError); - }); - - it('invokes listTagBindingsStream without error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - ]; - client.descriptors.page.listTagBindings.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTagBindingsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.TagBinding[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagBinding) => { - 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.listTagBindings.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTagBindings, request)); - }); - - it('invokes listTagBindingsStream with error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.listTagBindings.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTagBindingsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.TagBinding[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagBinding) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTagBindings.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTagBindings, request)); - }); - - it('uses async iteration with listTagBindings without error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - ]; - client.descriptors.page.listTagBindings.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.resourcemanager.v3.ITagBinding[] = []; - const iterable = client.listTagBindingsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTagBindings.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - - it('uses async iteration with listTagBindings with error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.listTagBindings.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTagBindingsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.resourcemanager.v3.ITagBinding[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTagBindings.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('listEffectiveTags', () => { - it('invokes listEffectiveTags without error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListEffectiveTagsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), - ]; - client.innerApiCalls.listEffectiveTags = stubSimpleCall(expectedResponse); - const [response] = await client.listEffectiveTags(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes listEffectiveTags without error using callback', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListEffectiveTagsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), - ]; - client.innerApiCalls.listEffectiveTags = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listEffectiveTags( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IEffectiveTag[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes listEffectiveTags with error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListEffectiveTagsRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.listEffectiveTags = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listEffectiveTags(request), expectedError); - }); - - it('invokes listEffectiveTagsStream without error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListEffectiveTagsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), - ]; - client.descriptors.page.listEffectiveTags.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listEffectiveTagsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.EffectiveTag[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.EffectiveTag) => { - 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.listEffectiveTags.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEffectiveTags, request)); - }); - - it('invokes listEffectiveTagsStream with error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListEffectiveTagsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.listEffectiveTags.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listEffectiveTagsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.EffectiveTag[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.EffectiveTag) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listEffectiveTags.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEffectiveTags, request)); - }); - - it('uses async iteration with listEffectiveTags without error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListEffectiveTagsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.EffectiveTag()), - ]; - client.descriptors.page.listEffectiveTags.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.resourcemanager.v3.IEffectiveTag[] = []; - const iterable = client.listEffectiveTagsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listEffectiveTags.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - - it('uses async iteration with listEffectiveTags with error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListEffectiveTagsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.listEffectiveTags.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listEffectiveTagsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.resourcemanager.v3.IEffectiveTag[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listEffectiveTags.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - 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 tagbindingsModule.v3.TagBindingsClient({ - 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 tagbindingsModule.v3.TagBindingsClient({ - 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 tagbindingsModule.v3.TagBindingsClient({ - 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 tagbindingsModule.v3.TagBindingsClient({ - 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 tagbindingsModule.v3.TagBindingsClient({ - 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 tagbindingsModule.v3.TagBindingsClient({ - 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 tagbindingsModule.v3.TagBindingsClient({ - 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 tagbindingsModule.v3.TagBindingsClient({ - 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 tagbindingsModule.v3.TagBindingsClient({ - 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 tagbindingsModule.v3.TagBindingsClient({ - 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('folder', () => { - const fakePath = "/rendered/path/folder"; - const expectedParameters = { - folder: "folderValue", - }; - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderPath', () => { - const result = client.folderPath("folderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderName', () => { - const result = client.matchFolderFromFolderName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organization', () => { - const fakePath = "/rendered/path/organization"; - const expectedParameters = { - organization: "organizationValue", - }; - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationPath', () => { - const result = client.organizationPath("organizationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationName', () => { - const result = client.matchOrganizationFromOrganizationName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagBinding', () => { - const fakePath = "/rendered/path/tagBinding"; - const expectedParameters = { - tag_binding: "tagBindingValue", - }; - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagBindingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagBindingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagBindingPath', () => { - const result = client.tagBindingPath("tagBindingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagBindingFromTagBindingName', () => { - const result = client.matchTagBindingFromTagBindingName(fakePath); - assert.strictEqual(result, "tagBindingValue"); - assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagHold', () => { - const fakePath = "/rendered/path/tagHold"; - const expectedParameters = { - tag_value: "tagValueValue", - tag_hold: "tagHoldValue", - }; - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagHoldPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagHoldPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagHoldPath', () => { - const result = client.tagHoldPath("tagValueValue", "tagHoldValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagHoldPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagValueFromTagHoldName', () => { - const result = client.matchTagValueFromTagHoldName(fakePath); - assert.strictEqual(result, "tagValueValue"); - assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTagHoldFromTagHoldName', () => { - const result = client.matchTagHoldFromTagHoldName(fakePath); - assert.strictEqual(result, "tagHoldValue"); - assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagKey', () => { - const fakePath = "/rendered/path/tagKey"; - const expectedParameters = { - tag_key: "tagKeyValue", - }; - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagKeyPath', () => { - const result = client.tagKeyPath("tagKeyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagKeyFromTagKeyName', () => { - const result = client.matchTagKeyFromTagKeyName(fakePath); - assert.strictEqual(result, "tagKeyValue"); - assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagValue', () => { - const fakePath = "/rendered/path/tagValue"; - const expectedParameters = { - tag_value: "tagValueValue", - }; - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagValuePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagValuePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagValuePath', () => { - const result = client.tagValuePath("tagValueValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagValueFromTagValueName', () => { - const result = client.matchTagValueFromTagValueName(fakePath); - assert.strictEqual(result, "tagValueValue"); - assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_holds_v3.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_holds_v3.ts deleted file mode 100644 index 17cf5fd6b5f..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_holds_v3.ts +++ /dev/null @@ -1,1242 +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 tagholdsModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v3.TagHoldsClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = tagholdsModule.v3.TagHoldsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = tagholdsModule.v3.TagHoldsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = tagholdsModule.v3.TagHoldsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new tagholdsModule.v3.TagHoldsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new tagholdsModule.v3.TagHoldsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tagHoldsStub, undefined); - await client.initialize(); - assert(client.tagHoldsStub); - }); - - it('has close method for the initialized client', done => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.tagHoldsStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tagHoldsStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new tagholdsModule.v3.TagHoldsClient({ - 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 tagholdsModule.v3.TagHoldsClient({ - 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('createTagHold', () => { - it('invokes createTagHold without error', async () => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateTagHoldRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.CreateTagHoldRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createTagHold = stubLongRunningCall(expectedResponse); - const [operation] = await client.createTagHold(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTagHold as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTagHold as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createTagHold without error using callback', async () => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateTagHoldRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.CreateTagHoldRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createTagHold = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createTagHold( - request, - (err?: Error|null, - result?: 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.createTagHold as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTagHold as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createTagHold with call error', async () => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateTagHoldRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.CreateTagHoldRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createTagHold = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createTagHold(request), expectedError); - const actualRequest = (client.innerApiCalls.createTagHold as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTagHold as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createTagHold with LRO error', async () => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateTagHoldRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.CreateTagHoldRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createTagHold = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createTagHold(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createTagHold as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTagHold as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateTagHoldProgress without error', async () => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateTagHoldProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateTagHoldProgress with error', async () => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateTagHoldProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteTagHold', () => { - it('invokes deleteTagHold without error', async () => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteTagHoldRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagHoldRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteTagHold = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteTagHold(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteTagHold as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTagHold as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteTagHold without error using callback', async () => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteTagHoldRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagHoldRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteTagHold = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteTagHold( - request, - (err?: Error|null, - result?: 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.deleteTagHold as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTagHold as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteTagHold with call error', async () => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteTagHoldRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagHoldRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTagHold = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteTagHold(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteTagHold as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTagHold as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteTagHold with LRO error', async () => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteTagHoldRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagHoldRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTagHold = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteTagHold(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteTagHold as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTagHold as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteTagHoldProgress without error', async () => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteTagHoldProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteTagHoldProgress with error', async () => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteTagHoldProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listTagHolds', () => { - it('invokes listTagHolds without error', async () => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagHoldsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.ListTagHoldsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), - ]; - client.innerApiCalls.listTagHolds = stubSimpleCall(expectedResponse); - const [response] = await client.listTagHolds(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTagHolds as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTagHolds as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTagHolds without error using callback', async () => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagHoldsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.ListTagHoldsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), - ]; - client.innerApiCalls.listTagHolds = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTagHolds( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagHold[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTagHolds as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTagHolds as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTagHolds with error', async () => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagHoldsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.ListTagHoldsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listTagHolds = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTagHolds(request), expectedError); - const actualRequest = (client.innerApiCalls.listTagHolds as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTagHolds as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTagHoldsStream without error', async () => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagHoldsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.ListTagHoldsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), - ]; - client.descriptors.page.listTagHolds.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTagHoldsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.TagHold[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagHold) => { - 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.listTagHolds.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTagHolds, request)); - assert( - (client.descriptors.page.listTagHolds.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listTagHoldsStream with error', async () => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagHoldsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.ListTagHoldsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listTagHolds.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTagHoldsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.TagHold[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagHold) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTagHolds.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTagHolds, request)); - assert( - (client.descriptors.page.listTagHolds.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listTagHolds without error', async () => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagHoldsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.ListTagHoldsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagHold()), - ]; - client.descriptors.page.listTagHolds.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.resourcemanager.v3.ITagHold[] = []; - const iterable = client.listTagHoldsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTagHolds.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTagHolds.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listTagHolds with error', async () => { - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagHoldsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.ListTagHoldsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listTagHolds.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTagHoldsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.resourcemanager.v3.ITagHold[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTagHolds.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTagHolds.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 tagholdsModule.v3.TagHoldsClient({ - 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 tagholdsModule.v3.TagHoldsClient({ - 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 tagholdsModule.v3.TagHoldsClient({ - 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 tagholdsModule.v3.TagHoldsClient({ - 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 tagholdsModule.v3.TagHoldsClient({ - 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 tagholdsModule.v3.TagHoldsClient({ - 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 tagholdsModule.v3.TagHoldsClient({ - 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 tagholdsModule.v3.TagHoldsClient({ - 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 tagholdsModule.v3.TagHoldsClient({ - 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 tagholdsModule.v3.TagHoldsClient({ - 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 tagholdsModule.v3.TagHoldsClient({ - 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('folder', () => { - const fakePath = "/rendered/path/folder"; - const expectedParameters = { - folder: "folderValue", - }; - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderPath', () => { - const result = client.folderPath("folderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderName', () => { - const result = client.matchFolderFromFolderName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organization', () => { - const fakePath = "/rendered/path/organization"; - const expectedParameters = { - organization: "organizationValue", - }; - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationPath', () => { - const result = client.organizationPath("organizationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationName', () => { - const result = client.matchOrganizationFromOrganizationName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagBinding', () => { - const fakePath = "/rendered/path/tagBinding"; - const expectedParameters = { - tag_binding: "tagBindingValue", - }; - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagBindingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagBindingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagBindingPath', () => { - const result = client.tagBindingPath("tagBindingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagBindingFromTagBindingName', () => { - const result = client.matchTagBindingFromTagBindingName(fakePath); - assert.strictEqual(result, "tagBindingValue"); - assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagHold', () => { - const fakePath = "/rendered/path/tagHold"; - const expectedParameters = { - tag_value: "tagValueValue", - tag_hold: "tagHoldValue", - }; - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagHoldPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagHoldPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagHoldPath', () => { - const result = client.tagHoldPath("tagValueValue", "tagHoldValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagHoldPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagValueFromTagHoldName', () => { - const result = client.matchTagValueFromTagHoldName(fakePath); - assert.strictEqual(result, "tagValueValue"); - assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTagHoldFromTagHoldName', () => { - const result = client.matchTagHoldFromTagHoldName(fakePath); - assert.strictEqual(result, "tagHoldValue"); - assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagKey', () => { - const fakePath = "/rendered/path/tagKey"; - const expectedParameters = { - tag_key: "tagKeyValue", - }; - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagKeyPath', () => { - const result = client.tagKeyPath("tagKeyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagKeyFromTagKeyName', () => { - const result = client.matchTagKeyFromTagKeyName(fakePath); - assert.strictEqual(result, "tagKeyValue"); - assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagValue', () => { - const fakePath = "/rendered/path/tagValue"; - const expectedParameters = { - tag_value: "tagValueValue", - }; - const client = new tagholdsModule.v3.TagHoldsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagValuePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagValuePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagValuePath', () => { - const result = client.tagValuePath("tagValueValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagValueFromTagValueName', () => { - const result = client.matchTagValueFromTagValueName(fakePath); - assert.strictEqual(result, "tagValueValue"); - assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_keys_v3.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_keys_v3.ts deleted file mode 100644 index 24965247705..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_keys_v3.ts +++ /dev/null @@ -1,1797 +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 tagkeysModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v3.TagKeysClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = tagkeysModule.v3.TagKeysClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = tagkeysModule.v3.TagKeysClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = tagkeysModule.v3.TagKeysClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new tagkeysModule.v3.TagKeysClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new tagkeysModule.v3.TagKeysClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tagKeysStub, undefined); - await client.initialize(); - assert(client.tagKeysStub); - }); - - it('has close method for the initialized client', done => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.tagKeysStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tagKeysStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new tagkeysModule.v3.TagKeysClient({ - 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 tagkeysModule.v3.TagKeysClient({ - 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('getTagKey', () => { - it('invokes getTagKey without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetTagKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetTagKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.TagKey() - ); - client.innerApiCalls.getTagKey = stubSimpleCall(expectedResponse); - const [response] = await client.getTagKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTagKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTagKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getTagKey without error using callback', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetTagKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetTagKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.TagKey() - ); - client.innerApiCalls.getTagKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getTagKey( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTagKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTagKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getTagKey with error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetTagKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetTagKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getTagKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getTagKey(request), expectedError); - const actualRequest = (client.innerApiCalls.getTagKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTagKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getTagKey with closed client', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetTagKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetTagKeyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getTagKey(request), expectedError); - }); - }); - - describe('getNamespacedTagKey', () => { - it('invokes getNamespacedTagKey without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetNamespacedTagKeyRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.TagKey() - ); - client.innerApiCalls.getNamespacedTagKey = stubSimpleCall(expectedResponse); - const [response] = await client.getNamespacedTagKey(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes getNamespacedTagKey without error using callback', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetNamespacedTagKeyRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.TagKey() - ); - client.innerApiCalls.getNamespacedTagKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getNamespacedTagKey( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes getNamespacedTagKey with error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetNamespacedTagKeyRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.getNamespacedTagKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getNamespacedTagKey(request), expectedError); - }); - - it('invokes getNamespacedTagKey with closed client', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetNamespacedTagKeyRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getNamespacedTagKey(request), expectedError); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy without error using callback', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy with error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy with closed client', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); - }); - - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy without error using callback', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy with error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy with closed client', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); - }); - - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions without error using callback', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions with error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions with closed client', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); - }); - - describe('createTagKey', () => { - it('invokes createTagKey without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateTagKeyRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createTagKey = stubLongRunningCall(expectedResponse); - const [operation] = await client.createTagKey(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes createTagKey without error using callback', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateTagKeyRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createTagKey = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createTagKey( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes createTagKey with call error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateTagKeyRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.createTagKey = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createTagKey(request), expectedError); - }); - - it('invokes createTagKey with LRO error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateTagKeyRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.createTagKey = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createTagKey(request); - await assert.rejects(operation.promise(), expectedError); - }); - - it('invokes checkCreateTagKeyProgress without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateTagKeyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateTagKeyProgress with error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateTagKeyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateTagKey', () => { - it('invokes updateTagKey without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UpdateTagKeyRequest() - ); - request.tagKey ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateTagKeyRequest', ['tagKey', 'name']); - request.tagKey.name = defaultValue1; - const expectedHeaderRequestParams = `tag_key.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateTagKey = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateTagKey(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateTagKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTagKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateTagKey without error using callback', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UpdateTagKeyRequest() - ); - request.tagKey ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateTagKeyRequest', ['tagKey', 'name']); - request.tagKey.name = defaultValue1; - const expectedHeaderRequestParams = `tag_key.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateTagKey = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateTagKey( - request, - (err?: Error|null, - result?: 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.updateTagKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTagKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateTagKey with call error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UpdateTagKeyRequest() - ); - request.tagKey ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateTagKeyRequest', ['tagKey', 'name']); - request.tagKey.name = defaultValue1; - const expectedHeaderRequestParams = `tag_key.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateTagKey = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateTagKey(request), expectedError); - const actualRequest = (client.innerApiCalls.updateTagKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTagKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateTagKey with LRO error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UpdateTagKeyRequest() - ); - request.tagKey ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateTagKeyRequest', ['tagKey', 'name']); - request.tagKey.name = defaultValue1; - const expectedHeaderRequestParams = `tag_key.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateTagKey = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateTagKey(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateTagKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTagKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateTagKeyProgress without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateTagKeyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateTagKeyProgress with error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateTagKeyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteTagKey', () => { - it('invokes deleteTagKey without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteTagKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteTagKey = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteTagKey(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteTagKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTagKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteTagKey without error using callback', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteTagKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteTagKey = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteTagKey( - request, - (err?: Error|null, - result?: 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.deleteTagKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTagKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteTagKey with call error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteTagKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTagKey = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteTagKey(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteTagKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTagKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteTagKey with LRO error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteTagKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTagKey = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteTagKey(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteTagKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTagKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteTagKeyProgress without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteTagKeyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteTagKeyProgress with error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteTagKeyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listTagKeys', () => { - it('invokes listTagKeys without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - ]; - client.innerApiCalls.listTagKeys = stubSimpleCall(expectedResponse); - const [response] = await client.listTagKeys(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes listTagKeys without error using callback', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - ]; - client.innerApiCalls.listTagKeys = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTagKeys( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagKey[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes listTagKeys with error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.listTagKeys = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTagKeys(request), expectedError); - }); - - it('invokes listTagKeysStream without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - ]; - client.descriptors.page.listTagKeys.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTagKeysStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.TagKey[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagKey) => { - 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.listTagKeys.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTagKeys, request)); - }); - - it('invokes listTagKeysStream with error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.listTagKeys.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTagKeysStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.TagKey[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagKey) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTagKeys.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTagKeys, request)); - }); - - it('uses async iteration with listTagKeys without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - ]; - client.descriptors.page.listTagKeys.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.resourcemanager.v3.ITagKey[] = []; - const iterable = client.listTagKeysAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTagKeys.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - - it('uses async iteration with listTagKeys with error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.listTagKeys.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTagKeysAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.resourcemanager.v3.ITagKey[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTagKeys.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - 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 tagkeysModule.v3.TagKeysClient({ - 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 tagkeysModule.v3.TagKeysClient({ - 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 tagkeysModule.v3.TagKeysClient({ - 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 tagkeysModule.v3.TagKeysClient({ - 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 tagkeysModule.v3.TagKeysClient({ - 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 tagkeysModule.v3.TagKeysClient({ - 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 tagkeysModule.v3.TagKeysClient({ - 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 tagkeysModule.v3.TagKeysClient({ - 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 tagkeysModule.v3.TagKeysClient({ - 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 tagkeysModule.v3.TagKeysClient({ - 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('folder', () => { - const fakePath = "/rendered/path/folder"; - const expectedParameters = { - folder: "folderValue", - }; - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderPath', () => { - const result = client.folderPath("folderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderName', () => { - const result = client.matchFolderFromFolderName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organization', () => { - const fakePath = "/rendered/path/organization"; - const expectedParameters = { - organization: "organizationValue", - }; - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationPath', () => { - const result = client.organizationPath("organizationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationName', () => { - const result = client.matchOrganizationFromOrganizationName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagBinding', () => { - const fakePath = "/rendered/path/tagBinding"; - const expectedParameters = { - tag_binding: "tagBindingValue", - }; - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagBindingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagBindingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagBindingPath', () => { - const result = client.tagBindingPath("tagBindingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagBindingFromTagBindingName', () => { - const result = client.matchTagBindingFromTagBindingName(fakePath); - assert.strictEqual(result, "tagBindingValue"); - assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagHold', () => { - const fakePath = "/rendered/path/tagHold"; - const expectedParameters = { - tag_value: "tagValueValue", - tag_hold: "tagHoldValue", - }; - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagHoldPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagHoldPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagHoldPath', () => { - const result = client.tagHoldPath("tagValueValue", "tagHoldValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagHoldPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagValueFromTagHoldName', () => { - const result = client.matchTagValueFromTagHoldName(fakePath); - assert.strictEqual(result, "tagValueValue"); - assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTagHoldFromTagHoldName', () => { - const result = client.matchTagHoldFromTagHoldName(fakePath); - assert.strictEqual(result, "tagHoldValue"); - assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagKey', () => { - const fakePath = "/rendered/path/tagKey"; - const expectedParameters = { - tag_key: "tagKeyValue", - }; - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagKeyPath', () => { - const result = client.tagKeyPath("tagKeyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagKeyFromTagKeyName', () => { - const result = client.matchTagKeyFromTagKeyName(fakePath); - assert.strictEqual(result, "tagKeyValue"); - assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagValue', () => { - const fakePath = "/rendered/path/tagValue"; - const expectedParameters = { - tag_value: "tagValueValue", - }; - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagValuePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagValuePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagValuePath', () => { - const result = client.tagValuePath("tagValueValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagValueFromTagValueName', () => { - const result = client.matchTagValueFromTagValueName(fakePath); - assert.strictEqual(result, "tagValueValue"); - assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_values_v3.ts b/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_values_v3.ts deleted file mode 100644 index 1a9b5fd1d77..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/test/gapic_tag_values_v3.ts +++ /dev/null @@ -1,1797 +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 tagvaluesModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v3.TagValuesClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = tagvaluesModule.v3.TagValuesClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = tagvaluesModule.v3.TagValuesClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = tagvaluesModule.v3.TagValuesClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new tagvaluesModule.v3.TagValuesClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tagValuesStub, undefined); - await client.initialize(); - assert(client.tagValuesStub); - }); - - it('has close method for the initialized client', done => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.tagValuesStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tagValuesStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new tagvaluesModule.v3.TagValuesClient({ - 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 tagvaluesModule.v3.TagValuesClient({ - 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('getTagValue', () => { - it('invokes getTagValue without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetTagValueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetTagValueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.TagValue() - ); - client.innerApiCalls.getTagValue = stubSimpleCall(expectedResponse); - const [response] = await client.getTagValue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTagValue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTagValue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getTagValue without error using callback', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetTagValueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetTagValueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.TagValue() - ); - client.innerApiCalls.getTagValue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getTagValue( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagValue|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTagValue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTagValue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getTagValue with error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetTagValueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetTagValueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getTagValue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getTagValue(request), expectedError); - const actualRequest = (client.innerApiCalls.getTagValue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTagValue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getTagValue with closed client', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetTagValueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.GetTagValueRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getTagValue(request), expectedError); - }); - }); - - describe('getNamespacedTagValue', () => { - it('invokes getNamespacedTagValue without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetNamespacedTagValueRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.TagValue() - ); - client.innerApiCalls.getNamespacedTagValue = stubSimpleCall(expectedResponse); - const [response] = await client.getNamespacedTagValue(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes getNamespacedTagValue without error using callback', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetNamespacedTagValueRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.TagValue() - ); - client.innerApiCalls.getNamespacedTagValue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getNamespacedTagValue( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagValue|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes getNamespacedTagValue with error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetNamespacedTagValueRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.getNamespacedTagValue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getNamespacedTagValue(request), expectedError); - }); - - it('invokes getNamespacedTagValue with closed client', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.GetNamespacedTagValueRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getNamespacedTagValue(request), expectedError); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy without error using callback', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy with error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy with closed client', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); - }); - - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy without error using callback', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy with error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy with closed client', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); - }); - - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions without error using callback', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions with error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions with closed client', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); - }); - - describe('createTagValue', () => { - it('invokes createTagValue without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateTagValueRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createTagValue = stubLongRunningCall(expectedResponse); - const [operation] = await client.createTagValue(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes createTagValue without error using callback', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateTagValueRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createTagValue = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createTagValue( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes createTagValue with call error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateTagValueRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.createTagValue = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createTagValue(request), expectedError); - }); - - it('invokes createTagValue with LRO error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.CreateTagValueRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.createTagValue = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createTagValue(request); - await assert.rejects(operation.promise(), expectedError); - }); - - it('invokes checkCreateTagValueProgress without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateTagValueProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateTagValueProgress with error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateTagValueProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateTagValue', () => { - it('invokes updateTagValue without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UpdateTagValueRequest() - ); - request.tagValue ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateTagValueRequest', ['tagValue', 'name']); - request.tagValue.name = defaultValue1; - const expectedHeaderRequestParams = `tag_value.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateTagValue = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateTagValue(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateTagValue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTagValue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateTagValue without error using callback', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UpdateTagValueRequest() - ); - request.tagValue ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateTagValueRequest', ['tagValue', 'name']); - request.tagValue.name = defaultValue1; - const expectedHeaderRequestParams = `tag_value.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateTagValue = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateTagValue( - request, - (err?: Error|null, - result?: 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.updateTagValue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTagValue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateTagValue with call error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UpdateTagValueRequest() - ); - request.tagValue ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateTagValueRequest', ['tagValue', 'name']); - request.tagValue.name = defaultValue1; - const expectedHeaderRequestParams = `tag_value.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateTagValue = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateTagValue(request), expectedError); - const actualRequest = (client.innerApiCalls.updateTagValue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTagValue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateTagValue with LRO error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.UpdateTagValueRequest() - ); - request.tagValue ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.UpdateTagValueRequest', ['tagValue', 'name']); - request.tagValue.name = defaultValue1; - const expectedHeaderRequestParams = `tag_value.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateTagValue = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateTagValue(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateTagValue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTagValue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateTagValueProgress without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateTagValueProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateTagValueProgress with error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateTagValueProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteTagValue', () => { - it('invokes deleteTagValue without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteTagValueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagValueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteTagValue = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteTagValue(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteTagValue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTagValue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteTagValue without error using callback', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteTagValueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagValueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteTagValue = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteTagValue( - request, - (err?: Error|null, - result?: 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.deleteTagValue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTagValue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteTagValue with call error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteTagValueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagValueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTagValue = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteTagValue(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteTagValue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTagValue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteTagValue with LRO error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.DeleteTagValueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcemanager.v3.DeleteTagValueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTagValue = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteTagValue(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteTagValue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTagValue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteTagValueProgress without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteTagValueProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteTagValueProgress with error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteTagValueProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listTagValues', () => { - it('invokes listTagValues without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - ]; - client.innerApiCalls.listTagValues = stubSimpleCall(expectedResponse); - const [response] = await client.listTagValues(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes listTagValues without error using callback', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - ]; - client.innerApiCalls.listTagValues = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTagValues( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagValue[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes listTagValues with error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.listTagValues = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTagValues(request), expectedError); - }); - - it('invokes listTagValuesStream without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - ]; - client.descriptors.page.listTagValues.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTagValuesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.TagValue[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagValue) => { - 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.listTagValues.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTagValues, request)); - }); - - it('invokes listTagValuesStream with error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.listTagValues.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTagValuesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.TagValue[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagValue) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTagValues.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTagValues, request)); - }); - - it('uses async iteration with listTagValues without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - ]; - client.descriptors.page.listTagValues.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.resourcemanager.v3.ITagValue[] = []; - const iterable = client.listTagValuesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTagValues.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - - it('uses async iteration with listTagValues with error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.listTagValues.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTagValuesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.resourcemanager.v3.ITagValue[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTagValues.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - 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 tagvaluesModule.v3.TagValuesClient({ - 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 tagvaluesModule.v3.TagValuesClient({ - 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 tagvaluesModule.v3.TagValuesClient({ - 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 tagvaluesModule.v3.TagValuesClient({ - 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 tagvaluesModule.v3.TagValuesClient({ - 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 tagvaluesModule.v3.TagValuesClient({ - 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 tagvaluesModule.v3.TagValuesClient({ - 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 tagvaluesModule.v3.TagValuesClient({ - 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 tagvaluesModule.v3.TagValuesClient({ - 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 tagvaluesModule.v3.TagValuesClient({ - 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('folder', () => { - const fakePath = "/rendered/path/folder"; - const expectedParameters = { - folder: "folderValue", - }; - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderPath', () => { - const result = client.folderPath("folderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderName', () => { - const result = client.matchFolderFromFolderName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organization', () => { - const fakePath = "/rendered/path/organization"; - const expectedParameters = { - organization: "organizationValue", - }; - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationPath', () => { - const result = client.organizationPath("organizationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationName', () => { - const result = client.matchOrganizationFromOrganizationName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagBinding', () => { - const fakePath = "/rendered/path/tagBinding"; - const expectedParameters = { - tag_binding: "tagBindingValue", - }; - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagBindingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagBindingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagBindingPath', () => { - const result = client.tagBindingPath("tagBindingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagBindingFromTagBindingName', () => { - const result = client.matchTagBindingFromTagBindingName(fakePath); - assert.strictEqual(result, "tagBindingValue"); - assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagHold', () => { - const fakePath = "/rendered/path/tagHold"; - const expectedParameters = { - tag_value: "tagValueValue", - tag_hold: "tagHoldValue", - }; - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagHoldPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagHoldPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagHoldPath', () => { - const result = client.tagHoldPath("tagValueValue", "tagHoldValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagHoldPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagValueFromTagHoldName', () => { - const result = client.matchTagValueFromTagHoldName(fakePath); - assert.strictEqual(result, "tagValueValue"); - assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTagHoldFromTagHoldName', () => { - const result = client.matchTagHoldFromTagHoldName(fakePath); - assert.strictEqual(result, "tagHoldValue"); - assert((client.pathTemplates.tagHoldPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagKey', () => { - const fakePath = "/rendered/path/tagKey"; - const expectedParameters = { - tag_key: "tagKeyValue", - }; - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagKeyPath', () => { - const result = client.tagKeyPath("tagKeyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagKeyFromTagKeyName', () => { - const result = client.matchTagKeyFromTagKeyName(fakePath); - assert.strictEqual(result, "tagKeyValue"); - assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagValue', () => { - const fakePath = "/rendered/path/tagValue"; - const expectedParameters = { - tag_value: "tagValueValue", - }; - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagValuePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagValuePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagValuePath', () => { - const result = client.tagValuePath("tagValueValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagValueFromTagValueName', () => { - const result = client.matchTagValueFromTagValueName(fakePath); - assert.strictEqual(result, "tagValueValue"); - assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-resourcemanager/v3/tsconfig.json b/owl-bot-staging/google-cloud-resourcemanager/v3/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/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-resourcemanager/v3/webpack.config.js b/owl-bot-staging/google-cloud-resourcemanager/v3/webpack.config.js deleted file mode 100644 index 92f3d14c0cc..00000000000 --- a/owl-bot-staging/google-cloud-resourcemanager/v3/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: 'Folders', - filename: './folders.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-resourcesettings/v1/.eslintignore b/owl-bot-staging/google-cloud-resourcesettings/v1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/.eslintrc.json b/owl-bot-staging/google-cloud-resourcesettings/v1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/.gitignore b/owl-bot-staging/google-cloud-resourcesettings/v1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/.jsdoc.js b/owl-bot-staging/google-cloud-resourcesettings/v1/.jsdoc.js deleted file mode 100644 index df02879c503..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/.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/resource-settings', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/.mocharc.js b/owl-bot-staging/google-cloud-resourcesettings/v1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/.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-resourcesettings/v1/.prettierrc.js b/owl-bot-staging/google-cloud-resourcesettings/v1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/.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-resourcesettings/v1/README.md b/owl-bot-staging/google-cloud-resourcesettings/v1/README.md deleted file mode 100644 index 83837ad6560..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Resourcesettings: Nodejs Client diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/package.json b/owl-bot-staging/google-cloud-resourcesettings/v1/package.json deleted file mode 100644 index 6a1a2c0d369..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/resource-settings", - "version": "0.1.0", - "description": "Resourcesettings client for Node.js", - "repository": "googleapis/nodejs-resourcesettings", - "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 resourcesettings", - "resourcesettings", - "resource settings service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/protos/google/cloud/resourcesettings/v1/resource_settings.proto b/owl-bot-staging/google-cloud-resourcesettings/v1/protos/google/cloud/resourcesettings/v1/resource_settings.proto deleted file mode 100644 index 38479dcbd01..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/protos/google/cloud/resourcesettings/v1/resource_settings.proto +++ /dev/null @@ -1,308 +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.resourcesettings.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; - -option cc_enable_arenas = true; -option go_package = "cloud.google.com/go/resourcesettings/apiv1/resourcesettingspb;resourcesettingspb"; -option java_multiple_files = true; -option java_outer_classname = "ResourceSettingsProto"; -option java_package = "com.google.cloud.resourcesettings.v1"; - -// Client library namespace -option csharp_namespace = "Google.Cloud.ResourceSettings.V1"; -option php_namespace = "Google\\Cloud\\ResourceSettings\\V1"; -option ruby_package = "Google::Cloud::ResourceSettings::V1"; - -// An interface to interact with resource settings and setting values throughout -// the resource hierarchy. -// -// Services may surface a number of settings for users to control how their -// resources behave. Values of settings applied on a given Cloud resource are -// evaluated hierarchically and inherited by all descendants of that resource. -// -// For all requests, returns a `google.rpc.Status` with -// `google.rpc.Code.PERMISSION_DENIED` if the IAM check fails or the `parent` -// resource is not in a Cloud Organization. -// For all requests, returns a `google.rpc.Status` with -// `google.rpc.Code.INVALID_ARGUMENT` if the request is malformed. -service ResourceSettingsService { - option (google.api.default_host) = "resourcesettings.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Lists all the settings that are available on the Cloud resource `parent`. - rpc ListSettings(ListSettingsRequest) returns (ListSettingsResponse) { - option (google.api.http) = { - get: "/v1/{parent=organizations/*}/settings" - additional_bindings { - get: "/v1/{parent=folders/*}/settings" - } - additional_bindings { - get: "/v1/{parent=projects/*}/settings" - } - }; - option (google.api.method_signature) = "parent"; - } - - // Gets a setting. - // - // Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the - // setting does not exist. - rpc GetSetting(GetSettingRequest) returns (Setting) { - option (google.api.http) = { - get: "/v1/{name=organizations/*/settings/*}" - additional_bindings { - get: "/v1/{name=folders/*/settings/*}" - } - additional_bindings { - get: "/v1/{name=projects/*/settings/*}" - } - }; - option (google.api.method_signature) = "name"; - } - - // Updates a setting. - // - // Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the - // setting does not exist. - // Returns a `google.rpc.Status` with `google.rpc.Code.FAILED_PRECONDITION` if - // the setting is flagged as read only. - // Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag - // supplied in the request does not match the persisted etag of the setting - // value. - // - // On success, the response will contain only `name`, `local_value` and - // `etag`. The `metadata` and `effective_value` cannot be updated through - // this API. - // - // Note: the supplied setting will perform a full overwrite of the - // `local_value` field. - rpc UpdateSetting(UpdateSettingRequest) returns (Setting) { - option (google.api.http) = { - patch: "/v1/{setting.name=organizations/*/settings/*}" - body: "setting" - additional_bindings { - patch: "/v1/{setting.name=folders/*/settings/*}" - body: "setting" - } - additional_bindings { - patch: "/v1/{setting.name=projects/*/settings/*}" - body: "setting" - } - }; - } -} - -// The schema for settings. -message Setting { - option (google.api.resource) = { - type: "resourcesettings.googleapis.com/Setting" - pattern: "projects/{project_number}/settings/{setting_name}" - pattern: "folders/{folder}/settings/{setting_name}" - pattern: "organizations/{organization}/settings/{setting_name}" - }; - - // The resource name of the setting. Must be in one of the following forms: - // - // * `projects/{project_number}/settings/{setting_name}` - // * `folders/{folder_id}/settings/{setting_name}` - // * `organizations/{organization_id}/settings/{setting_name}` - // - // For example, "/projects/123/settings/gcp-enableMyFeature" - string name = 1; - - // Output only. Metadata about a setting which is not editable by the end user. - SettingMetadata metadata = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The configured value of the setting at the given parent resource (ignoring - // the resource hierarchy). The data type of [Value][google.cloud.resourcesettings.v1.Value] must always be - // consistent with the data type defined in [Setting.metadata][google.cloud.resourcesettings.v1.Setting.metadata]. - Value local_value = 8; - - // Output only. The computed effective value of the setting at the given parent resource - // (based on the resource hierarchy). - // - // The effective value evaluates to one of the following options in the given - // order (the next option is used if the previous one does not exist): - // - // 1. the local setting value on the given resource: [Setting.local_value][google.cloud.resourcesettings.v1.Setting.local_value] - // 2. if one of the given resource's ancestors have a local setting value, - // the local value at the nearest such ancestor - // 3. the setting's default value: [SettingMetadata.default_value][google.cloud.resourcesettings.v1.SettingMetadata.default_value] - // 4. an empty value (defined as a `Value` with all fields unset) - // - // The data type of [Value][google.cloud.resourcesettings.v1.Value] must always be - // consistent with the data type defined in [Setting.metadata][google.cloud.resourcesettings.v1.Setting.metadata]. - Value effective_value = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // A fingerprint used for optimistic concurrency. See - // [UpdateSetting][google.cloud.resourcesettings.v1.ResourceSettingsService.UpdateSetting] for more - // details. - string etag = 10; -} - -// Metadata about a setting which is not editable by the end user. -message SettingMetadata { - // The data type for setting values of this setting. See [Value][google.cloud.resourcesettings.v1.Value] for more - // details on the available data types. - enum DataType { - // Unspecified data type. - DATA_TYPE_UNSPECIFIED = 0; - - // A boolean setting. - BOOLEAN = 1; - - // A string setting. - STRING = 2; - - // A string set setting. - STRING_SET = 3; - - // A Enum setting - ENUM_VALUE = 4; - } - - // The human readable name for this setting. - string display_name = 1; - - // A detailed description of what this setting does. - string description = 2; - - // A flag indicating that values of this setting cannot be modified (see - // documentation of the specific setting for updates and reasons). - bool read_only = 3; - - // The data type for this setting. - DataType data_type = 4; - - // The value provided by [Setting.effective_value][google.cloud.resourcesettings.v1.Setting.effective_value] if no setting value is - // explicitly set. - // - // Note: not all settings have a default value. - Value default_value = 5; -} - -// The data in a setting value. -message Value { - // A string set value that can hold a set of strings. The maximum length of - // each string is 200 characters and there can be a maximum of 50 strings in - // the string set. - message StringSet { - // The strings in the set - repeated string values = 1; - } - - // A enum value that can hold any enum type setting values. - // Each enum type is represented by a number, this representation - // is stored in the definitions. - message EnumValue { - // The value of this enum - string value = 1; - } - - // Selects the data type and associated value. - oneof value { - // Defines this value as being a boolean value. - bool boolean_value = 1; - - // Defines this value as being a string value. - string string_value = 2; - - // Defines this value as being a StringSet. - StringSet string_set_value = 3; - - // Defines this value as being a Enum. - EnumValue enum_value = 4; - } -} - -// The request for ListSettings. -message ListSettingsRequest { - // Required. The Cloud resource that parents the setting. Must be in one of the - // following forms: - // - // * `projects/{project_number}` - // * `projects/{project_id}` - // * `folders/{folder_id}` - // * `organizations/{organization_id}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "*" - } - ]; - - // Unused. The size of the page to be returned. - int32 page_size = 2; - - // Unused. A page token used to retrieve the next page. - string page_token = 3; - - // The SettingView for this request. - SettingView view = 4; -} - -// The response from ListSettings. -message ListSettingsResponse { - // A list of settings that are available at the specified Cloud resource. - repeated Setting settings = 1; - - // Unused. A page token used to retrieve the next page. - string next_page_token = 2; -} - -// The request for GetSetting. -message GetSettingRequest { - // Required. The name of the setting to get. See [Setting][google.cloud.resourcesettings.v1.Setting] for naming - // requirements. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "resourcesettings.googleapis.com/Setting" - } - ]; - - // The SettingView for this request. - SettingView view = 2; -} - -// The request for UpdateSetting. -message UpdateSettingRequest { - // Required. The setting to update. See [Setting][google.cloud.resourcesettings.v1.Setting] for field requirements. - Setting setting = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// View options for Settings. -enum SettingView { - // The default / unset value. - // The API will default to the SETTING_VIEW_BASIC view. - SETTING_VIEW_UNSPECIFIED = 0; - - // Include [Setting.metadata][google.cloud.resourcesettings.v1.Setting.metadata], but nothing else. - // This is the default value (for both ListSettings and GetSetting). - SETTING_VIEW_BASIC = 1; - - // Include [Setting.effective_value][google.cloud.resourcesettings.v1.Setting.effective_value], but nothing else. - SETTING_VIEW_EFFECTIVE_VALUE = 2; - - // Include [Setting.local_value][google.cloud.resourcesettings.v1.Setting.local_value], but nothing else. - SETTING_VIEW_LOCAL_VALUE = 3; -} diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.get_setting.js b/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.get_setting.js deleted file mode 100644 index cfb6e5b7d4b..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.get_setting.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(name) { - // [START resourcesettings_v1_generated_ResourceSettingsService_GetSetting_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 setting to get. See Setting google.cloud.resourcesettings.v1.Setting for naming - * requirements. - */ - // const name = 'abc123' - /** - * The SettingView for this request. - */ - // const view = {} - - // Imports the Resourcesettings library - const {ResourceSettingsServiceClient} = require('@google-cloud/resource-settings').v1; - - // Instantiates a client - const resourcesettingsClient = new ResourceSettingsServiceClient(); - - async function callGetSetting() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await resourcesettingsClient.getSetting(request); - console.log(response); - } - - callGetSetting(); - // [END resourcesettings_v1_generated_ResourceSettingsService_GetSetting_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.list_settings.js b/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.list_settings.js deleted file mode 100644 index ee3df4ce32d..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.list_settings.js +++ /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. ** - - - -'use strict'; - -function main(parent) { - // [START resourcesettings_v1_generated_ResourceSettingsService_ListSettings_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Cloud resource that parents the setting. Must be in one of the - * following forms: - * * `projects/{project_number}` - * * `projects/{project_id}` - * * `folders/{folder_id}` - * * `organizations/{organization_id}` - */ - // const parent = 'abc123' - /** - * Unused. The size of the page to be returned. - */ - // const pageSize = 1234 - /** - * Unused. A page token used to retrieve the next page. - */ - // const pageToken = 'abc123' - /** - * The SettingView for this request. - */ - // const view = {} - - // Imports the Resourcesettings library - const {ResourceSettingsServiceClient} = require('@google-cloud/resource-settings').v1; - - // Instantiates a client - const resourcesettingsClient = new ResourceSettingsServiceClient(); - - async function callListSettings() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await resourcesettingsClient.listSettingsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListSettings(); - // [END resourcesettings_v1_generated_ResourceSettingsService_ListSettings_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.update_setting.js b/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.update_setting.js deleted file mode 100644 index 811ee6d9477..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/resource_settings_service.update_setting.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(setting) { - // [START resourcesettings_v1_generated_ResourceSettingsService_UpdateSetting_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The setting to update. See Setting google.cloud.resourcesettings.v1.Setting for field requirements. - */ - // const setting = {} - - // Imports the Resourcesettings library - const {ResourceSettingsServiceClient} = require('@google-cloud/resource-settings').v1; - - // Instantiates a client - const resourcesettingsClient = new ResourceSettingsServiceClient(); - - async function callUpdateSetting() { - // Construct request - const request = { - setting, - }; - - // Run request - const response = await resourcesettingsClient.updateSetting(request); - console.log(response); - } - - callUpdateSetting(); - // [END resourcesettings_v1_generated_ResourceSettingsService_UpdateSetting_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/snippet_metadata_google.cloud.resourcesettings.v1.json b/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/snippet_metadata_google.cloud.resourcesettings.v1.json deleted file mode 100644 index 723ee3d0521..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/samples/generated/v1/snippet_metadata_google.cloud.resourcesettings.v1.json +++ /dev/null @@ -1,151 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-resourcesettings", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.resourcesettings.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "resourcesettings_v1_generated_ResourceSettingsService_ListSettings_async", - "title": "ResourceSettingsService listSettings Sample", - "origin": "API_DEFINITION", - "description": " Lists all the settings that are available on the Cloud resource `parent`.", - "canonical": true, - "file": "resource_settings_service.list_settings.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListSettings", - "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsService.ListSettings", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "view", - "type": ".google.cloud.resourcesettings.v1.SettingView" - } - ], - "resultType": ".google.cloud.resourcesettings.v1.ListSettingsResponse", - "client": { - "shortName": "ResourceSettingsServiceClient", - "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsServiceClient" - }, - "method": { - "shortName": "ListSettings", - "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsService.ListSettings", - "service": { - "shortName": "ResourceSettingsService", - "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsService" - } - } - } - }, - { - "regionTag": "resourcesettings_v1_generated_ResourceSettingsService_GetSetting_async", - "title": "ResourceSettingsService getSetting Sample", - "origin": "API_DEFINITION", - "description": " Gets a setting. Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the setting does not exist.", - "canonical": true, - "file": "resource_settings_service.get_setting.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetSetting", - "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsService.GetSetting", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "view", - "type": ".google.cloud.resourcesettings.v1.SettingView" - } - ], - "resultType": ".google.cloud.resourcesettings.v1.Setting", - "client": { - "shortName": "ResourceSettingsServiceClient", - "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsServiceClient" - }, - "method": { - "shortName": "GetSetting", - "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsService.GetSetting", - "service": { - "shortName": "ResourceSettingsService", - "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsService" - } - } - } - }, - { - "regionTag": "resourcesettings_v1_generated_ResourceSettingsService_UpdateSetting_async", - "title": "ResourceSettingsService updateSetting Sample", - "origin": "API_DEFINITION", - "description": " Updates a setting. Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the setting does not exist. Returns a `google.rpc.Status` with `google.rpc.Code.FAILED_PRECONDITION` if the setting is flagged as read only. Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag supplied in the request does not match the persisted etag of the setting value. On success, the response will contain only `name`, `local_value` and `etag`. The `metadata` and `effective_value` cannot be updated through this API. Note: the supplied setting will perform a full overwrite of the `local_value` field.", - "canonical": true, - "file": "resource_settings_service.update_setting.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateSetting", - "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsService.UpdateSetting", - "async": true, - "parameters": [ - { - "name": "setting", - "type": ".google.cloud.resourcesettings.v1.Setting" - } - ], - "resultType": ".google.cloud.resourcesettings.v1.Setting", - "client": { - "shortName": "ResourceSettingsServiceClient", - "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsServiceClient" - }, - "method": { - "shortName": "UpdateSetting", - "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsService.UpdateSetting", - "service": { - "shortName": "ResourceSettingsService", - "fullName": "google.cloud.resourcesettings.v1.ResourceSettingsService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/src/index.ts b/owl-bot-staging/google-cloud-resourcesettings/v1/src/index.ts deleted file mode 100644 index cc98aa85c64..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/src/index.ts +++ /dev/null @@ -1,25 +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 v1 from './v1'; -const ResourceSettingsServiceClient = v1.ResourceSettingsServiceClient; -type ResourceSettingsServiceClient = v1.ResourceSettingsServiceClient; -export {v1, ResourceSettingsServiceClient}; -export default {v1, ResourceSettingsServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 3b49a1ce240..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.resourcesettings.v1", - "libraryPackage": "@google-cloud/resource-settings", - "services": { - "ResourceSettingsService": { - "clients": { - "grpc": { - "libraryClient": "ResourceSettingsServiceClient", - "rpcs": { - "GetSetting": { - "methods": [ - "getSetting" - ] - }, - "UpdateSetting": { - "methods": [ - "updateSetting" - ] - }, - "ListSettings": { - "methods": [ - "listSettings", - "listSettingsStream", - "listSettingsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ResourceSettingsServiceClient", - "rpcs": { - "GetSetting": { - "methods": [ - "getSetting" - ] - }, - "UpdateSetting": { - "methods": [ - "updateSetting" - ] - }, - "ListSettings": { - "methods": [ - "listSettings", - "listSettingsStream", - "listSettingsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/index.ts deleted file mode 100644 index ea044328836..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +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 {ResourceSettingsServiceClient} from './resource_settings_service_client'; diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_client.ts b/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_client.ts deleted file mode 100644 index f36e0651c78..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_client.ts +++ /dev/null @@ -1,808 +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, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/resource_settings_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './resource_settings_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * An interface to interact with resource settings and setting values throughout - * the resource hierarchy. - * - * Services may surface a number of settings for users to control how their - * resources behave. Values of settings applied on a given Cloud resource are - * evaluated hierarchically and inherited by all descendants of that resource. - * - * For all requests, returns a `google.rpc.Status` with - * `google.rpc.Code.PERMISSION_DENIED` if the IAM check fails or the `parent` - * resource is not in a Cloud Organization. - * For all requests, returns a `google.rpc.Status` with - * `google.rpc.Code.INVALID_ARGUMENT` if the request is malformed. - * @class - * @memberof v1 - */ -export class ResourceSettingsServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - resourceSettingsServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ResourceSettingsServiceClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 ResourceSettingsServiceClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ResourceSettingsServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else { - 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 = { - folderSettingNamePathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}/settings/{setting_name}' - ), - organizationSettingNamePathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/settings/{setting_name}' - ), - projectNumberSettingNamePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project_number}/settings/{setting_name}' - ), - }; - - // 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 = { - listSettings: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'settings') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.resourcesettings.v1.ResourceSettingsService', 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.resourceSettingsServiceStub) { - return this.resourceSettingsServiceStub; - } - - // Put together the "service stub" for - // google.cloud.resourcesettings.v1.ResourceSettingsService. - this.resourceSettingsServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.resourcesettings.v1.ResourceSettingsService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.resourcesettings.v1.ResourceSettingsService, - 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 resourceSettingsServiceStubMethods = - ['listSettings', 'getSetting', 'updateSetting']; - for (const methodName of resourceSettingsServiceStubMethods) { - const callPromise = this.resourceSettingsServiceStub.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.resourceSettingsServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'resourcesettings.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 'resourcesettings.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 setting. - * - * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the - * setting does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the setting to get. See {@link protos.google.cloud.resourcesettings.v1.Setting|Setting} for naming - * requirements. - * @param {google.cloud.resourcesettings.v1.SettingView} request.view - * The SettingView for this request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.resourcesettings.v1.Setting|Setting}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/resource_settings_service.get_setting.js - * region_tag:resourcesettings_v1_generated_ResourceSettingsService_GetSetting_async - */ - getSetting( - request?: protos.google.cloud.resourcesettings.v1.IGetSettingRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcesettings.v1.ISetting, - protos.google.cloud.resourcesettings.v1.IGetSettingRequest|undefined, {}|undefined - ]>; - getSetting( - request: protos.google.cloud.resourcesettings.v1.IGetSettingRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.resourcesettings.v1.ISetting, - protos.google.cloud.resourcesettings.v1.IGetSettingRequest|null|undefined, - {}|null|undefined>): void; - getSetting( - request: protos.google.cloud.resourcesettings.v1.IGetSettingRequest, - callback: Callback< - protos.google.cloud.resourcesettings.v1.ISetting, - protos.google.cloud.resourcesettings.v1.IGetSettingRequest|null|undefined, - {}|null|undefined>): void; - getSetting( - request?: protos.google.cloud.resourcesettings.v1.IGetSettingRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.resourcesettings.v1.ISetting, - protos.google.cloud.resourcesettings.v1.IGetSettingRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.resourcesettings.v1.ISetting, - protos.google.cloud.resourcesettings.v1.IGetSettingRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.resourcesettings.v1.ISetting, - protos.google.cloud.resourcesettings.v1.IGetSettingRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getSetting(request, options, callback); - } -/** - * Updates a setting. - * - * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the - * setting does not exist. - * Returns a `google.rpc.Status` with `google.rpc.Code.FAILED_PRECONDITION` if - * the setting is flagged as read only. - * Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag - * supplied in the request does not match the persisted etag of the setting - * value. - * - * On success, the response will contain only `name`, `local_value` and - * `etag`. The `metadata` and `effective_value` cannot be updated through - * this API. - * - * Note: the supplied setting will perform a full overwrite of the - * `local_value` field. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.resourcesettings.v1.Setting} request.setting - * Required. The setting to update. See {@link protos.google.cloud.resourcesettings.v1.Setting|Setting} for field requirements. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.resourcesettings.v1.Setting|Setting}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/resource_settings_service.update_setting.js - * region_tag:resourcesettings_v1_generated_ResourceSettingsService_UpdateSetting_async - */ - updateSetting( - request?: protos.google.cloud.resourcesettings.v1.IUpdateSettingRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcesettings.v1.ISetting, - protos.google.cloud.resourcesettings.v1.IUpdateSettingRequest|undefined, {}|undefined - ]>; - updateSetting( - request: protos.google.cloud.resourcesettings.v1.IUpdateSettingRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.resourcesettings.v1.ISetting, - protos.google.cloud.resourcesettings.v1.IUpdateSettingRequest|null|undefined, - {}|null|undefined>): void; - updateSetting( - request: protos.google.cloud.resourcesettings.v1.IUpdateSettingRequest, - callback: Callback< - protos.google.cloud.resourcesettings.v1.ISetting, - protos.google.cloud.resourcesettings.v1.IUpdateSettingRequest|null|undefined, - {}|null|undefined>): void; - updateSetting( - request?: protos.google.cloud.resourcesettings.v1.IUpdateSettingRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.resourcesettings.v1.ISetting, - protos.google.cloud.resourcesettings.v1.IUpdateSettingRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.resourcesettings.v1.ISetting, - protos.google.cloud.resourcesettings.v1.IUpdateSettingRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.resourcesettings.v1.ISetting, - protos.google.cloud.resourcesettings.v1.IUpdateSettingRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'setting.name': request.setting!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateSetting(request, options, callback); - } - - /** - * Lists all the settings that are available on the Cloud resource `parent`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The Cloud resource that parents the setting. Must be in one of the - * following forms: - * - * * `projects/{project_number}` - * * `projects/{project_id}` - * * `folders/{folder_id}` - * * `organizations/{organization_id}` - * @param {number} request.pageSize - * Unused. The size of the page to be returned. - * @param {string} request.pageToken - * Unused. A page token used to retrieve the next page. - * @param {google.cloud.resourcesettings.v1.SettingView} request.view - * The SettingView for this request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.resourcesettings.v1.Setting|Setting}. - * 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 `listSettingsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listSettings( - request?: protos.google.cloud.resourcesettings.v1.IListSettingsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcesettings.v1.ISetting[], - protos.google.cloud.resourcesettings.v1.IListSettingsRequest|null, - protos.google.cloud.resourcesettings.v1.IListSettingsResponse - ]>; - listSettings( - request: protos.google.cloud.resourcesettings.v1.IListSettingsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.resourcesettings.v1.IListSettingsRequest, - protos.google.cloud.resourcesettings.v1.IListSettingsResponse|null|undefined, - protos.google.cloud.resourcesettings.v1.ISetting>): void; - listSettings( - request: protos.google.cloud.resourcesettings.v1.IListSettingsRequest, - callback: PaginationCallback< - protos.google.cloud.resourcesettings.v1.IListSettingsRequest, - protos.google.cloud.resourcesettings.v1.IListSettingsResponse|null|undefined, - protos.google.cloud.resourcesettings.v1.ISetting>): void; - listSettings( - request?: protos.google.cloud.resourcesettings.v1.IListSettingsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.resourcesettings.v1.IListSettingsRequest, - protos.google.cloud.resourcesettings.v1.IListSettingsResponse|null|undefined, - protos.google.cloud.resourcesettings.v1.ISetting>, - callback?: PaginationCallback< - protos.google.cloud.resourcesettings.v1.IListSettingsRequest, - protos.google.cloud.resourcesettings.v1.IListSettingsResponse|null|undefined, - protos.google.cloud.resourcesettings.v1.ISetting>): - Promise<[ - protos.google.cloud.resourcesettings.v1.ISetting[], - protos.google.cloud.resourcesettings.v1.IListSettingsRequest|null, - protos.google.cloud.resourcesettings.v1.IListSettingsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listSettings(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 Cloud resource that parents the setting. Must be in one of the - * following forms: - * - * * `projects/{project_number}` - * * `projects/{project_id}` - * * `folders/{folder_id}` - * * `organizations/{organization_id}` - * @param {number} request.pageSize - * Unused. The size of the page to be returned. - * @param {string} request.pageToken - * Unused. A page token used to retrieve the next page. - * @param {google.cloud.resourcesettings.v1.SettingView} request.view - * The SettingView for this request. - * @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 protos.google.cloud.resourcesettings.v1.Setting|Setting} 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 `listSettingsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listSettingsStream( - request?: protos.google.cloud.resourcesettings.v1.IListSettingsRequest, - 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['listSettings']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listSettings.createStream( - this.innerApiCalls.listSettings as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listSettings`, 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 Cloud resource that parents the setting. Must be in one of the - * following forms: - * - * * `projects/{project_number}` - * * `projects/{project_id}` - * * `folders/{folder_id}` - * * `organizations/{organization_id}` - * @param {number} request.pageSize - * Unused. The size of the page to be returned. - * @param {string} request.pageToken - * Unused. A page token used to retrieve the next page. - * @param {google.cloud.resourcesettings.v1.SettingView} request.view - * The SettingView for this request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.resourcesettings.v1.Setting|Setting}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/resource_settings_service.list_settings.js - * region_tag:resourcesettings_v1_generated_ResourceSettingsService_ListSettings_async - */ - listSettingsAsync( - request?: protos.google.cloud.resourcesettings.v1.IListSettingsRequest, - 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['listSettings']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listSettings.asyncIterate( - this.innerApiCalls['listSettings'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified folderSettingName resource name string. - * - * @param {string} folder - * @param {string} setting_name - * @returns {string} Resource name string. - */ - folderSettingNamePath(folder:string,settingName:string) { - return this.pathTemplates.folderSettingNamePathTemplate.render({ - folder: folder, - setting_name: settingName, - }); - } - - /** - * Parse the folder from FolderSettingName resource. - * - * @param {string} folderSettingNameName - * A fully-qualified path representing folder_setting_name resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderSettingNameName(folderSettingNameName: string) { - return this.pathTemplates.folderSettingNamePathTemplate.match(folderSettingNameName).folder; - } - - /** - * Parse the setting_name from FolderSettingName resource. - * - * @param {string} folderSettingNameName - * A fully-qualified path representing folder_setting_name resource. - * @returns {string} A string representing the setting_name. - */ - matchSettingNameFromFolderSettingNameName(folderSettingNameName: string) { - return this.pathTemplates.folderSettingNamePathTemplate.match(folderSettingNameName).setting_name; - } - - /** - * Return a fully-qualified organizationSettingName resource name string. - * - * @param {string} organization - * @param {string} setting_name - * @returns {string} Resource name string. - */ - organizationSettingNamePath(organization:string,settingName:string) { - return this.pathTemplates.organizationSettingNamePathTemplate.render({ - organization: organization, - setting_name: settingName, - }); - } - - /** - * Parse the organization from OrganizationSettingName resource. - * - * @param {string} organizationSettingNameName - * A fully-qualified path representing organization_setting_name resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationSettingNameName(organizationSettingNameName: string) { - return this.pathTemplates.organizationSettingNamePathTemplate.match(organizationSettingNameName).organization; - } - - /** - * Parse the setting_name from OrganizationSettingName resource. - * - * @param {string} organizationSettingNameName - * A fully-qualified path representing organization_setting_name resource. - * @returns {string} A string representing the setting_name. - */ - matchSettingNameFromOrganizationSettingNameName(organizationSettingNameName: string) { - return this.pathTemplates.organizationSettingNamePathTemplate.match(organizationSettingNameName).setting_name; - } - - /** - * Return a fully-qualified projectNumberSettingName resource name string. - * - * @param {string} project_number - * @param {string} setting_name - * @returns {string} Resource name string. - */ - projectNumberSettingNamePath(projectNumber:string,settingName:string) { - return this.pathTemplates.projectNumberSettingNamePathTemplate.render({ - project_number: projectNumber, - setting_name: settingName, - }); - } - - /** - * Parse the project_number from ProjectNumberSettingName resource. - * - * @param {string} projectNumberSettingNameName - * A fully-qualified path representing project_number_setting_name resource. - * @returns {string} A string representing the project_number. - */ - matchProjectNumberFromProjectNumberSettingNameName(projectNumberSettingNameName: string) { - return this.pathTemplates.projectNumberSettingNamePathTemplate.match(projectNumberSettingNameName).project_number; - } - - /** - * Parse the setting_name from ProjectNumberSettingName resource. - * - * @param {string} projectNumberSettingNameName - * A fully-qualified path representing project_number_setting_name resource. - * @returns {string} A string representing the setting_name. - */ - matchSettingNameFromProjectNumberSettingNameName(projectNumberSettingNameName: string) { - return this.pathTemplates.projectNumberSettingNamePathTemplate.match(projectNumberSettingNameName).setting_name; - } - - /** - * 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.resourceSettingsServiceStub && !this._terminated) { - return this.resourceSettingsServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_client_config.json b/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_client_config.json deleted file mode 100644 index a1802c062bc..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_client_config.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "interfaces": { - "google.cloud.resourcesettings.v1.ResourceSettingsService": { - "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 - }, - "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListSettings": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "GetSetting": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "UpdateSetting": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_proto_list.json b/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_proto_list.json deleted file mode 100644 index 675fedf1ac6..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/src/v1/resource_settings_service_proto_list.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "../../protos/google/cloud/resourcesettings/v1/resource_settings.proto" -] diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-resourcesettings/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 6766456c390..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const resourcesettings = require('@google-cloud/resource-settings'); - -function main() { - const resourceSettingsServiceClient = new resourcesettings.ResourceSettingsServiceClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-resourcesettings/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index acc97ba0fb5..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {ResourceSettingsServiceClient} from '@google-cloud/resource-settings'; - -// check that the client class type name can be used -function doStuffWithResourceSettingsServiceClient(client: ResourceSettingsServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const resourceSettingsServiceClient = new ResourceSettingsServiceClient(); - doStuffWithResourceSettingsServiceClient(resourceSettingsServiceClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/system-test/install.ts b/owl-bot-staging/google-cloud-resourcesettings/v1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/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-resourcesettings/v1/test/gapic_resource_settings_service_v1.ts b/owl-bot-staging/google-cloud-resourcesettings/v1/test/gapic_resource_settings_service_v1.ts deleted file mode 100644 index 7c8ef02cc74..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/test/gapic_resource_settings_service_v1.ts +++ /dev/null @@ -1,779 +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 resourcesettingsserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.ResourceSettingsServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = resourcesettingsserviceModule.v1.ResourceSettingsServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = resourcesettingsserviceModule.v1.ResourceSettingsServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = resourcesettingsserviceModule.v1.ResourceSettingsServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.resourceSettingsServiceStub, undefined); - await client.initialize(); - assert(client.resourceSettingsServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.resourceSettingsServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.resourceSettingsServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - 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 resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - 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('getSetting', () => { - it('invokes getSetting without error', async () => { - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcesettings.v1.GetSettingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcesettings.v1.GetSettingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.resourcesettings.v1.Setting() - ); - client.innerApiCalls.getSetting = stubSimpleCall(expectedResponse); - const [response] = await client.getSetting(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSetting as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSetting as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSetting without error using callback', async () => { - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcesettings.v1.GetSettingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcesettings.v1.GetSettingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.resourcesettings.v1.Setting() - ); - client.innerApiCalls.getSetting = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getSetting( - request, - (err?: Error|null, result?: protos.google.cloud.resourcesettings.v1.ISetting|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSetting as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSetting as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSetting with error', async () => { - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcesettings.v1.GetSettingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcesettings.v1.GetSettingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getSetting = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getSetting(request), expectedError); - const actualRequest = (client.innerApiCalls.getSetting as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSetting as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSetting with closed client', async () => { - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcesettings.v1.GetSettingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcesettings.v1.GetSettingRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getSetting(request), expectedError); - }); - }); - - describe('updateSetting', () => { - it('invokes updateSetting without error', async () => { - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcesettings.v1.UpdateSettingRequest() - ); - request.setting ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcesettings.v1.UpdateSettingRequest', ['setting', 'name']); - request.setting.name = defaultValue1; - const expectedHeaderRequestParams = `setting.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.resourcesettings.v1.Setting() - ); - client.innerApiCalls.updateSetting = stubSimpleCall(expectedResponse); - const [response] = await client.updateSetting(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSetting as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSetting as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateSetting without error using callback', async () => { - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcesettings.v1.UpdateSettingRequest() - ); - request.setting ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcesettings.v1.UpdateSettingRequest', ['setting', 'name']); - request.setting.name = defaultValue1; - const expectedHeaderRequestParams = `setting.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.resourcesettings.v1.Setting() - ); - client.innerApiCalls.updateSetting = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateSetting( - request, - (err?: Error|null, result?: protos.google.cloud.resourcesettings.v1.ISetting|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSetting as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSetting as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateSetting with error', async () => { - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcesettings.v1.UpdateSettingRequest() - ); - request.setting ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcesettings.v1.UpdateSettingRequest', ['setting', 'name']); - request.setting.name = defaultValue1; - const expectedHeaderRequestParams = `setting.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSetting = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateSetting(request), expectedError); - const actualRequest = (client.innerApiCalls.updateSetting as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSetting as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateSetting with closed client', async () => { - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcesettings.v1.UpdateSettingRequest() - ); - request.setting ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcesettings.v1.UpdateSettingRequest', ['setting', 'name']); - request.setting.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateSetting(request), expectedError); - }); - }); - - describe('listSettings', () => { - it('invokes listSettings without error', async () => { - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcesettings.v1.ListSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcesettings.v1.ListSettingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), - generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), - generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), - ]; - client.innerApiCalls.listSettings = stubSimpleCall(expectedResponse); - const [response] = await client.listSettings(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSettings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSettings without error using callback', async () => { - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcesettings.v1.ListSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcesettings.v1.ListSettingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), - generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), - generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), - ]; - client.innerApiCalls.listSettings = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listSettings( - request, - (err?: Error|null, result?: protos.google.cloud.resourcesettings.v1.ISetting[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSettings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSettings with error', async () => { - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcesettings.v1.ListSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcesettings.v1.ListSettingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listSettings = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listSettings(request), expectedError); - const actualRequest = (client.innerApiCalls.listSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSettings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSettingsStream without error', async () => { - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcesettings.v1.ListSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcesettings.v1.ListSettingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), - generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), - generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), - ]; - client.descriptors.page.listSettings.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listSettingsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcesettings.v1.Setting[] = []; - stream.on('data', (response: protos.google.cloud.resourcesettings.v1.Setting) => { - 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.listSettings.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSettings, request)); - assert( - (client.descriptors.page.listSettings.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listSettingsStream with error', async () => { - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcesettings.v1.ListSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcesettings.v1.ListSettingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listSettings.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listSettingsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcesettings.v1.Setting[] = []; - stream.on('data', (response: protos.google.cloud.resourcesettings.v1.Setting) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listSettings.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSettings, request)); - assert( - (client.descriptors.page.listSettings.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSettings without error', async () => { - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcesettings.v1.ListSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcesettings.v1.ListSettingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), - generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), - generateSampleMessage(new protos.google.cloud.resourcesettings.v1.Setting()), - ]; - client.descriptors.page.listSettings.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.resourcesettings.v1.ISetting[] = []; - const iterable = client.listSettingsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listSettings.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSettings.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSettings with error', async () => { - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.resourcesettings.v1.ListSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.resourcesettings.v1.ListSettingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listSettings.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listSettingsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.resourcesettings.v1.ISetting[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listSettings.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSettings.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('folderSettingName', () => { - const fakePath = "/rendered/path/folderSettingName"; - const expectedParameters = { - folder: "folderValue", - setting_name: "settingNameValue", - }; - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderSettingNamePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderSettingNamePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderSettingNamePath', () => { - const result = client.folderSettingNamePath("folderValue", "settingNameValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderSettingNamePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderSettingNameName', () => { - const result = client.matchFolderFromFolderSettingNameName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderSettingNamePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSettingNameFromFolderSettingNameName', () => { - const result = client.matchSettingNameFromFolderSettingNameName(fakePath); - assert.strictEqual(result, "settingNameValue"); - assert((client.pathTemplates.folderSettingNamePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organizationSettingName', () => { - const fakePath = "/rendered/path/organizationSettingName"; - const expectedParameters = { - organization: "organizationValue", - setting_name: "settingNameValue", - }; - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationSettingNamePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationSettingNamePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationSettingNamePath', () => { - const result = client.organizationSettingNamePath("organizationValue", "settingNameValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationSettingNamePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationSettingNameName', () => { - const result = client.matchOrganizationFromOrganizationSettingNameName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationSettingNamePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSettingNameFromOrganizationSettingNameName', () => { - const result = client.matchSettingNameFromOrganizationSettingNameName(fakePath); - assert.strictEqual(result, "settingNameValue"); - assert((client.pathTemplates.organizationSettingNamePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectNumberSettingName', () => { - const fakePath = "/rendered/path/projectNumberSettingName"; - const expectedParameters = { - project_number: "projectNumberValue", - setting_name: "settingNameValue", - }; - const client = new resourcesettingsserviceModule.v1.ResourceSettingsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectNumberSettingNamePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectNumberSettingNamePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectNumberSettingNamePath', () => { - const result = client.projectNumberSettingNamePath("projectNumberValue", "settingNameValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectNumberSettingNamePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectNumberFromProjectNumberSettingNameName', () => { - const result = client.matchProjectNumberFromProjectNumberSettingNameName(fakePath); - assert.strictEqual(result, "projectNumberValue"); - assert((client.pathTemplates.projectNumberSettingNamePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSettingNameFromProjectNumberSettingNameName', () => { - const result = client.matchSettingNameFromProjectNumberSettingNameName(fakePath); - assert.strictEqual(result, "settingNameValue"); - assert((client.pathTemplates.projectNumberSettingNamePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/tsconfig.json b/owl-bot-staging/google-cloud-resourcesettings/v1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-resourcesettings/v1/webpack.config.js b/owl-bot-staging/google-cloud-resourcesettings/v1/webpack.config.js deleted file mode 100644 index af213ce887e..00000000000 --- a/owl-bot-staging/google-cloud-resourcesettings/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'ResourceSettingsService', - filename: './resource-settings-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/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/package.json b/owl-bot-staging/google-cloud-retail/v2/package.json deleted file mode 100644 index 335f43fc78d..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/package.json +++ /dev/null @@ -1,66 +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", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} 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 f8df0337665..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 = ['abc','def'] - /** - * 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 67f7afe6761..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 = [1,2,3,4] - /** - * 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 = [1,2,3,4] - - // 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 37d00508561..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 = ['abc','def'] - /** - * 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 1e766bf21ae..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 = [1,2,3,4] - /** - * 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 b949bfd3d29..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 = ['abc','def'] - /** - * 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 eaf4e9abc2d..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 = ['abc','def'] - /** - * 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 c7524d4299c..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 = [1,2,3,4] - /** - * 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 = ['abc','def'] - /** - * 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 = ['abc','def'] - /** - * 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 = [1,2,3,4] - /** - * 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 dd09fa6d712..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_client.ts +++ /dev/null @@ -1,2207 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.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 protos.google.cloud.retail.v2.Catalog|Catalog} to update. - * - * If the caller does not have permission to update the - * {@link protos.google.cloud.retail.v2.Catalog|Catalog}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * - * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2.Catalog|Catalog}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2.SearchService.Search|SearchService.Search}, - * {@link protos.google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct}, - * {@link protos.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 protos.google.cloud.retail.v2.SearchRequest.branch|SearchRequest.branch} to - * `projects/* /locations/* /catalogs/* /branches/default_branch` is equivalent - * to setting - * {@link protos.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 protos.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 protos.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 protos.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 protos.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 protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2.GetDefaultBranchResponse|GetDefaultBranchResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2.CompletionConfig|CompletionConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2.CompletionConfig|CompletionConfig} - * to update. - * - * If the caller does not have permission to update the - * {@link protos.google.cloud.retail.v2.CompletionConfig|CompletionConfig}, then a - * PERMISSION_DENIED error is returned. - * - * If the {@link protos.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 protos.google.cloud.retail.v2.CompletionConfig|CompletionConfig} to update. The - * following are the only supported fields: - * - * * {@link protos.google.cloud.retail.v2.CompletionConfig.matching_order|CompletionConfig.matching_order} - * * {@link protos.google.cloud.retail.v2.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions} - * * {@link protos.google.cloud.retail.v2.CompletionConfig.min_prefix_length|CompletionConfig.min_prefix_length} - * * {@link protos.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 protos.google.cloud.retail.v2.CompletionConfig|CompletionConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2.AttributesConfig|AttributesConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2.AttributesConfig|AttributesConfig} - * to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link protos.google.cloud.retail.v2.AttributesConfig|AttributesConfig} to update. The - * following is the only supported field: - * - * * {@link protos.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 protos.google.cloud.retail.v2.AttributesConfig|AttributesConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} to the - * {@link protos.google.cloud.retail.v2.AttributesConfig|AttributesConfig}. - * - * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2.AttributesConfig|AttributesConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} from the - * {@link protos.google.cloud.retail.v2.AttributesConfig|AttributesConfig}. - * - * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2.AttributesConfig|AttributesConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} in the - * {@link protos.google.cloud.retail.v2.AttributesConfig|AttributesConfig} by updating the - * catalog attribute with the same - * {@link protos.google.cloud.retail.v2.CatalogAttribute.key|CatalogAttribute.key}. - * - * If the {@link protos.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 protos.google.cloud.retail.v2.CatalogAttribute|CatalogAttribute}. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link protos.google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} to update. The - * following are NOT supported: - * - * * {@link protos.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 protos.google.cloud.retail.v2.AttributesConfig|AttributesConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 780b15b73b5..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/completion_service_client.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. ** - -/* 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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.CompleteQueryResponse|CompleteQueryResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 307b1c502b0..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_client.ts +++ /dev/null @@ -1,1546 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.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 protos.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 protos.google.cloud.retail.v2.Control|Control}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2.Control|Control} cannot be set to a different - * oneof field, if so an INVALID_ARGUMENT is returned. If the - * {@link protos.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 protos.google.cloud.retail.v2.Control|Control} to update. The following are NOT - * supported: - * - * * {@link protos.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 protos.google.cloud.retail.v2.Control|Control}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2.Control|Control}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 5fe8ba017bc..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_client.ts +++ /dev/null @@ -1,1796 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.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 protos.google.cloud.retail.v2.Model|Model}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2.Model|Model}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2.Model|Model}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2.Model|Model}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 7e9fa1fd3f3..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/prediction_service_client.ts +++ /dev/null @@ -1,1222 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id} or - * {@link protos.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 protos.google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id} to a - * random unique ID and leave - * {@link protos.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 protos.google.cloud.retail.v2.PredictResponse|PredictResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 fe3971c01f3..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/product_service_client.ts +++ /dev/null @@ -1,2835 +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 protos.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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.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 protos.google.cloud.retail.v2.Product|Product} to create. - * @param {string} request.productId - * Required. The ID to use for the {@link protos.google.cloud.retail.v2.Product|Product}, - * which will become the final component of the - * {@link protos.google.cloud.retail.v2.Product.name|Product.name}. - * - * If the caller does not have permission to create the - * {@link protos.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 protos.google.cloud.retail.v2.Product|Product}s with the same - * {@link protos.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 protos.google.cloud.retail.v2.Product|Product}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2.Product|Product}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * - * If the requested {@link protos.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 protos.google.cloud.retail.v2.Product|Product}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2.Product|Product}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * - * If the {@link protos.google.cloud.retail.v2.Product|Product} to update does not exist - * and - * {@link protos.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 protos.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 protos.google.cloud.retail.v2.Product|Product} is not - * found, a new {@link protos.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 protos.google.cloud.retail.v2.Product|Product}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2.Product|Product}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * - * If the {@link protos.google.cloud.retail.v2.Product|Product} to delete does not exist, - * a NOT_FOUND error is returned. - * - * The {@link protos.google.cloud.retail.v2.Product|Product} to delete can neither be a - * {@link protos.google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link protos.google.cloud.retail.v2.Product|Product} member nor a - * {@link protos.google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link protos.google.cloud.retail.v2.Product|Product} with more than one - * {@link protos.google.cloud.retail.v2.Product.Type.VARIANT|variants}. Otherwise, an - * INVALID_ARGUMENT error is returned. - * - * All inventory information for the named - * {@link protos.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 protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.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 protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2.Product|Product} queried by - * {@link protos.google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct} - * or - * {@link protos.google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. - * - * When inventory is updated with - * {@link protos.google.cloud.retail.v2.ProductService.CreateProduct|ProductService.CreateProduct} - * and - * {@link protos.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 protos.google.cloud.retail.v2.ProductService.CreateProduct|ProductService.CreateProduct} - * or - * {@link protos.google.cloud.retail.v2.ProductService.UpdateProduct|ProductService.UpdateProduct} - * request. - * - * If no inventory fields are set in - * {@link protos.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 protos.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 protos.google.cloud.retail.v2.ProductService.SetInventory|ProductService.SetInventory}, - * {@link protos.google.cloud.retail.v2.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}, - * and - * {@link protos.google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. - * - * The returned {@link protos.google.longrunning.Operation|Operation}s is obsolete after - * one day, and the {@link protos.google.longrunning.Operations.GetOperation|GetOperation} - * API returns `NOT_FOUND` afterwards. - * - * If conflicting updates are issued, the - * {@link protos.google.longrunning.Operation|Operation}s associated with the stale - * updates are not marked as {@link protos.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 protos.google.cloud.retail.v2.Product.price_info|Product.price_info} - * * {@link protos.google.cloud.retail.v2.Product.availability|Product.availability} - * * {@link protos.google.cloud.retail.v2.Product.available_quantity|Product.available_quantity} - * * {@link protos.google.cloud.retail.v2.Product.fulfillment_info|Product.fulfillment_info} - * The updated inventory fields must be specified in - * {@link protos.google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}. - * - * If - * {@link protos.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 protos.google.cloud.retail.v2.Product|Product} named in - * {@link protos.google.cloud.retail.v2.Product.name|Product.name}, regardless of whether - * or not it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link protos.google.cloud.retail.v2.Product|Product} to update does not have - * existing inventory information, the provided inventory information will be - * inserted. - * - * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} - * * Specifies only the desired fulfillment types and corresponding place IDs - * to update in - * {@link protos.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 protos.google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} - * * Specifies only the desired fulfillment types to clear in - * {@link protos.google.cloud.retail.v2.Product.fulfillment_info|SetInventoryRequest.inventory.fulfillment_info} - * * Checks that only the desired fulfillment info types have empty - * {@link protos.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 protos.google.cloud.retail.v2.Product.price_info|Product.price_info} - * * {@link protos.google.cloud.retail.v2.Product.availability|Product.availability} - * * {@link protos.google.cloud.retail.v2.Product.available_quantity|Product.available_quantity} - * * {@link protos.google.cloud.retail.v2.Product.fulfillment_info|Product.fulfillment_info} - * - * If a full overwrite of inventory information while ignoring timestamps is - * needed, - * {@link protos.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 protos.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 protos.google.cloud.retail.v2.Product|Product} with name - * {@link protos.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 protos.google.cloud.retail.v2.Product|Product} is created. If set to - * false, a NOT_FOUND error is returned if the - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.google.cloud.retail.v2.ProductService.AddLocalInventories|ProductService.AddLocalInventories} - * method instead of - * {@link protos.google.cloud.retail.v2.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}. - * {@link protos.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 protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. - * - * This process is asynchronous and does not require the - * {@link protos.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 protos.google.cloud.retail.v2.Product|Product} queried by - * {@link protos.google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct} - * or - * {@link protos.google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. - * - * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link protos.google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.FulfillmentInfo.type|Product.fulfillment_info.type}. - * @param {string[]} request.placeIds - * Required. The IDs for this - * {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.Product|Product} is created. If set to false, a - * NOT_FOUND error is returned if the - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.google.cloud.retail.v2.ProductService.RemoveLocalInventories|ProductService.RemoveLocalInventories} - * method instead of - * {@link protos.google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. - * {@link protos.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 protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. - * - * This process is asynchronous and does not require the - * {@link protos.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 protos.google.cloud.retail.v2.Product|Product} queried by - * {@link protos.google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct} - * or - * {@link protos.google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. - * - * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link protos.google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.FulfillmentInfo.type|Product.fulfillment_info.type}. - * @param {string[]} request.placeIds - * Required. The IDs for this - * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.Product|Product} is created. If set to false, a - * NOT_FOUND error is returned if the - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2.Product|Product} queried by - * {@link protos.google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct} - * or - * {@link protos.google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. - * - * Local inventory information can only be modified using this method. - * {@link protos.google.cloud.retail.v2.ProductService.CreateProduct|ProductService.CreateProduct} - * and - * {@link protos.google.cloud.retail.v2.ProductService.UpdateProduct|ProductService.UpdateProduct} - * has no effect on local inventories. - * - * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link protos.google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.Product|Product} is - * created. If set to false, a NOT_FOUND error is returned if the - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.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 protos.google.cloud.retail.v2.Product|Product} queried by - * {@link protos.google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct} - * or - * {@link protos.google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. - * - * Local inventory information can only be removed using this method. - * {@link protos.google.cloud.retail.v2.ProductService.CreateProduct|ProductService.CreateProduct} - * and - * {@link protos.google.cloud.retail.v2.ProductService.UpdateProduct|ProductService.UpdateProduct} - * has no effect on local inventories. - * - * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link protos.google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.Product|Product} is created. If set to false, a - * NOT_FOUND error is returned if the - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.google.cloud.retail.v2.ListProductsRequest.filter|filter} is unset. - * * List {@link protos.google.cloud.retail.v2.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link protos.google.cloud.retail.v2.Product|Product}s sharing the same - * {@link protos.google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link protos.google.cloud.retail.v2.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link protos.google.cloud.retail.v2.Product|Product}s bundled in a - * {@link protos.google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link protos.google.cloud.retail.v2.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link protos.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 protos.google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link protos.google.cloud.retail.v2.Product|Product} or - * {@link protos.google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link protos.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 protos.google.cloud.retail.v2.Product|Product} to return in the - * responses. If not set or empty, the following fields are returned: - * - * * {@link protos.google.cloud.retail.v2.Product.name|Product.name} - * * {@link protos.google.cloud.retail.v2.Product.id|Product.id} - * * {@link protos.google.cloud.retail.v2.Product.title|Product.title} - * * {@link protos.google.cloud.retail.v2.Product.uri|Product.uri} - * * {@link protos.google.cloud.retail.v2.Product.images|Product.images} - * * {@link protos.google.cloud.retail.v2.Product.price_info|Product.price_info} - * * {@link protos.google.cloud.retail.v2.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.google.cloud.retail.v2.ListProductsRequest.filter|filter} is unset. - * * List {@link protos.google.cloud.retail.v2.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link protos.google.cloud.retail.v2.Product|Product}s sharing the same - * {@link protos.google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link protos.google.cloud.retail.v2.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link protos.google.cloud.retail.v2.Product|Product}s bundled in a - * {@link protos.google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link protos.google.cloud.retail.v2.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link protos.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 protos.google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link protos.google.cloud.retail.v2.Product|Product} or - * {@link protos.google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link protos.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 protos.google.cloud.retail.v2.Product|Product} to return in the - * responses. If not set or empty, the following fields are returned: - * - * * {@link protos.google.cloud.retail.v2.Product.name|Product.name} - * * {@link protos.google.cloud.retail.v2.Product.id|Product.id} - * * {@link protos.google.cloud.retail.v2.Product.title|Product.title} - * * {@link protos.google.cloud.retail.v2.Product.uri|Product.uri} - * * {@link protos.google.cloud.retail.v2.Product.images|Product.images} - * * {@link protos.google.cloud.retail.v2.Product.price_info|Product.price_info} - * * {@link protos.google.cloud.retail.v2.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.google.cloud.retail.v2.ListProductsRequest.filter|filter} is unset. - * * List {@link protos.google.cloud.retail.v2.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link protos.google.cloud.retail.v2.Product|Product}s sharing the same - * {@link protos.google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link protos.google.cloud.retail.v2.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link protos.google.cloud.retail.v2.Product|Product}s bundled in a - * {@link protos.google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link protos.google.cloud.retail.v2.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link protos.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 protos.google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link protos.google.cloud.retail.v2.Product|Product} or - * {@link protos.google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link protos.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 protos.google.cloud.retail.v2.Product|Product} to return in the - * responses. If not set or empty, the following fields are returned: - * - * * {@link protos.google.cloud.retail.v2.Product.name|Product.name} - * * {@link protos.google.cloud.retail.v2.Product.id|Product.id} - * * {@link protos.google.cloud.retail.v2.Product.title|Product.title} - * * {@link protos.google.cloud.retail.v2.Product.uri|Product.uri} - * * {@link protos.google.cloud.retail.v2.Product.images|Product.images} - * * {@link protos.google.cloud.retail.v2.Product.price_info|Product.price_info} - * * {@link protos.google.cloud.retail.v2.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 8555ebfd641..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/search_service_client.ts +++ /dev/null @@ -1,2037 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.google.cloud.retail.v2.SearchRequest.filter|filter} and - * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2.SearchService.Search|SearchService.Search} call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.google.cloud.retail.v2.Product|Product}s - * deemed by the API as relevant) in search results. This field is only - * considered if {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} - * and - * {@link protos.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 protos.google.cloud.retail.v2.Product.Type.VARIANT|variant} - * {@link protos.google.cloud.retail.v2.Product|Product}s attributes, - * {@link protos.google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo} or - * {@link protos.google.cloud.retail.v2.LocalInventory|LocalInventory}s attributes. The - * attributes from all the matching - * {@link protos.google.cloud.retail.v2.Product.Type.VARIANT|variant} - * {@link protos.google.cloud.retail.v2.Product|Product}s or - * {@link protos.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 protos.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 protos.google.cloud.retail.v2.LocalInventory.attributes|Product.local_inventories.attributes} - * map. - * * attributes.key, where key is any key in the - * {@link protos.google.cloud.retail.v2.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.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 protos.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 protos.google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec} - * and - * {@link protos.google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * are set. - * {@link protos.google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * will override - * {@link protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.google.cloud.retail.v2.SearchRequest.filter|filter} and - * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2.SearchService.Search|SearchService.Search} call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.google.cloud.retail.v2.Product|Product}s - * deemed by the API as relevant) in search results. This field is only - * considered if {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} - * and - * {@link protos.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 protos.google.cloud.retail.v2.Product.Type.VARIANT|variant} - * {@link protos.google.cloud.retail.v2.Product|Product}s attributes, - * {@link protos.google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo} or - * {@link protos.google.cloud.retail.v2.LocalInventory|LocalInventory}s attributes. The - * attributes from all the matching - * {@link protos.google.cloud.retail.v2.Product.Type.VARIANT|variant} - * {@link protos.google.cloud.retail.v2.Product|Product}s or - * {@link protos.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 protos.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 protos.google.cloud.retail.v2.LocalInventory.attributes|Product.local_inventories.attributes} - * map. - * * attributes.key, where key is any key in the - * {@link protos.google.cloud.retail.v2.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.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 protos.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 protos.google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec} - * and - * {@link protos.google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * are set. - * {@link protos.google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * will override - * {@link protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.google.cloud.retail.v2.SearchRequest.filter|filter} and - * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2.SearchService.Search|SearchService.Search} call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.google.cloud.retail.v2.Product|Product}s - * deemed by the API as relevant) in search results. This field is only - * considered if {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} - * and - * {@link protos.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 protos.google.cloud.retail.v2.Product.Type.VARIANT|variant} - * {@link protos.google.cloud.retail.v2.Product|Product}s attributes, - * {@link protos.google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo} or - * {@link protos.google.cloud.retail.v2.LocalInventory|LocalInventory}s attributes. The - * attributes from all the matching - * {@link protos.google.cloud.retail.v2.Product.Type.VARIANT|variant} - * {@link protos.google.cloud.retail.v2.Product|Product}s or - * {@link protos.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 protos.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 protos.google.cloud.retail.v2.LocalInventory.attributes|Product.local_inventories.attributes} - * map. - * * attributes.key, where key is any key in the - * {@link protos.google.cloud.retail.v2.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link protos.google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.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 protos.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 protos.google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec} - * and - * {@link protos.google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * are set. - * {@link protos.google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * will override - * {@link protos.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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 1a8cf6cd5b9..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_client.ts +++ /dev/null @@ -1,1681 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.google.cloud.retail.v2.ServingConfig|ServingConfig}s are - * allowed in a {@link protos.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 protos.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 protos.google.cloud.retail.v2.ServingConfig|ServingConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2.ServingConfig|ServingConfig} to update. The - * following are NOT supported: - * - * * {@link protos.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 protos.google.cloud.retail.v2.ServingConfig|ServingConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2.ServingConfig|ServingConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2.ServingConfig|ServingConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2.ServingConfig|ServingConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 d59e333bbfd..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/user_event_service_client.ts +++ /dev/null @@ -1,1548 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.google.cloud.retail.v2.UserEvent|UserEvent}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.api.HttpBody|HttpBody}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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/package.json b/owl-bot-staging/google-cloud-retail/v2alpha/package.json deleted file mode 100644 index 60fb03c0056..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/package.json +++ /dev/null @@ -1,67 +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", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} 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 6d0ce2f5084..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 = ['abc','def'] - - // 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 80b9515dc7c..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 = ['abc','def'] - /** - * 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 7ba158c314b..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 = [1,2,3,4] - /** - * 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 = [1,2,3,4] - - // 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 8bb159be5a5..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 = ['abc','def'] - /** - * 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 e7bc30ee253..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 = [1,2,3,4] - /** - * 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 7bfafee6dd3..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 = ['abc','def'] - /** - * 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 88e315f9fad..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 = ['abc','def'] - /** - * 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 d3b029b917d..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 = [1,2,3,4] - /** - * 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 = ['abc','def'] - /** - * 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 = ['abc','def'] - /** - * 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 = [1,2,3,4] - /** - * 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 9e42d95478e..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_client.ts +++ /dev/null @@ -1,2352 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.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 protos.google.cloud.retail.v2alpha.Catalog|Catalog} to update. - * - * If the caller does not have permission to update the - * {@link protos.google.cloud.retail.v2alpha.Catalog|Catalog}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.Catalog|Catalog}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search}, - * {@link protos.google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct}, - * {@link protos.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 protos.google.cloud.retail.v2alpha.SearchRequest.branch|SearchRequest.branch} to - * `projects/* /locations/* /catalogs/* /branches/default_branch` is equivalent - * to setting - * {@link protos.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 protos.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 protos.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 protos.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 protos.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 protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2alpha.GetDefaultBranchResponse|GetDefaultBranchResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig} to update. - * - * If the caller does not have permission to update the - * {@link protos.google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig}, then a - * PERMISSION_DENIED error is returned. - * - * If the {@link protos.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 protos.google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig} to update. - * The following are the only supported fields: - * - * * {@link protos.google.cloud.retail.v2alpha.CompletionConfig.matching_order|CompletionConfig.matching_order} - * * {@link protos.google.cloud.retail.v2alpha.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions} - * * {@link protos.google.cloud.retail.v2alpha.CompletionConfig.min_prefix_length|CompletionConfig.min_prefix_length} - * * {@link protos.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 protos.google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig} to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link protos.google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig} to update. - * The following is the only supported field: - * - * * {@link protos.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 protos.google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to the - * {@link protos.google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. - * - * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} from the - * {@link protos.google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. - * - * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute}s from the - * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.BatchRemoveCatalogAttributesResponse|BatchRemoveCatalogAttributesResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} in the - * {@link protos.google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig} by - * updating the catalog attribute with the same - * {@link protos.google.cloud.retail.v2alpha.CatalogAttribute.key|CatalogAttribute.key}. - * - * If the {@link protos.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 protos.google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute}. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link protos.google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to update. - * The following are NOT supported: - * - * * {@link protos.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 protos.google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 d6262741b81..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/completion_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/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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.CompleteQueryResponse|CompleteQueryResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 e242ee0aaab..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/control_service_client.ts +++ /dev/null @@ -1,1611 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.Control|Control}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2alpha.Control|Control} cannot be set to a different - * oneof field, if so an INVALID_ARGUMENT is returned. If the - * {@link protos.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 protos.google.cloud.retail.v2alpha.Control|Control} to update. The following are - * NOT supported: - * - * * {@link protos.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 protos.google.cloud.retail.v2alpha.Control|Control}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2alpha.Control|Control}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 02b2f50fec3..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_client.ts +++ /dev/null @@ -1,1350 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink}s - * under the specified parent {@link protos.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 protos.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksResponse|ListMerchantCenterAccountLinksResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink}. - * If the - * {@link protos.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 protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink} - * to create. - * - * If the caller does not have permission to create the - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 db6d53a4210..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_client.ts +++ /dev/null @@ -1,1862 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.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 protos.google.cloud.retail.v2alpha.Model|Model}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2alpha.Model|Model}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2alpha.Model|Model}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2alpha.Model|Model}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 875ef80e1ee..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_client.ts +++ /dev/null @@ -1,1287 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id} or - * {@link protos.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 protos.google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id} to - * a random unique ID and leave - * {@link protos.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 protos.google.cloud.retail.v2alpha.PredictResponse|PredictResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 e4560c639df..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/product_service_client.ts +++ /dev/null @@ -1,3109 +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 protos.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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product} to create. - * @param {string} request.productId - * Required. The ID to use for the - * {@link protos.google.cloud.retail.v2alpha.Product|Product}, which will become the final - * component of the {@link protos.google.cloud.retail.v2alpha.Product.name|Product.name}. - * - * If the caller does not have permission to create the - * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product}s with the same - * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * - * If the requested {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link protos.google.cloud.retail.v2alpha.Product|Product} to update does not - * exist and - * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product} is - * not found, a new {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link protos.google.cloud.retail.v2alpha.Product|Product} to delete does not - * exist, a NOT_FOUND error is returned. - * - * The {@link protos.google.cloud.retail.v2alpha.Product|Product} to delete can neither be - * a - * {@link protos.google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link protos.google.cloud.retail.v2alpha.Product|Product} member nor a - * {@link protos.google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link protos.google.cloud.retail.v2alpha.Product|Product} with more than one - * {@link protos.google.cloud.retail.v2alpha.Product.Type.VARIANT|variants}. Otherwise, an - * INVALID_ARGUMENT error is returned. - * - * All inventory information for the named - * {@link protos.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 protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product}s, this operation could take - * hours to complete. Before the operation completes, some - * {@link protos.google.cloud.retail.v2alpha.Product|Product}s may still be returned by - * {@link protos.google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct} - * or - * {@link protos.google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. - * - * Depending on the number of {@link protos.google.cloud.retail.v2alpha.Product|Product}s, - * this operation could take hours to complete. To get a sample of - * {@link protos.google.cloud.retail.v2alpha.Product|Product}s that would be deleted, set - * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.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 protos.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 protos.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 protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product} queried by - * {@link protos.google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct} - * or - * {@link protos.google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. - * - * When inventory is updated with - * {@link protos.google.cloud.retail.v2alpha.ProductService.CreateProduct|ProductService.CreateProduct} - * and - * {@link protos.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 protos.google.cloud.retail.v2alpha.ProductService.CreateProduct|ProductService.CreateProduct} - * or - * {@link protos.google.cloud.retail.v2alpha.ProductService.UpdateProduct|ProductService.UpdateProduct} - * request. - * - * If no inventory fields are set in - * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.ProductService.SetInventory|ProductService.SetInventory}, - * {@link protos.google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}, - * and - * {@link protos.google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. - * - * The returned {@link protos.google.longrunning.Operation|Operation}s is obsolete after - * one day, and the {@link protos.google.longrunning.Operations.GetOperation|GetOperation} - * API returns `NOT_FOUND` afterwards. - * - * If conflicting updates are issued, the - * {@link protos.google.longrunning.Operation|Operation}s associated with the stale - * updates are not marked as {@link protos.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 protos.google.cloud.retail.v2alpha.Product.price_info|Product.price_info} - * * {@link protos.google.cloud.retail.v2alpha.Product.availability|Product.availability} - * * {@link protos.google.cloud.retail.v2alpha.Product.available_quantity|Product.available_quantity} - * * {@link protos.google.cloud.retail.v2alpha.Product.fulfillment_info|Product.fulfillment_info} - * The updated inventory fields must be specified in - * {@link protos.google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}. - * - * If - * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product} named in - * {@link protos.google.cloud.retail.v2alpha.Product.name|Product.name}, regardless of - * whether or not it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link protos.google.cloud.retail.v2alpha.Product|Product} to update does not - * have existing inventory information, the provided inventory information - * will be inserted. - * - * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} - * * Specifies only the desired fulfillment types and corresponding place IDs - * to update in - * {@link protos.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 protos.google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} - * * Specifies only the desired fulfillment types to clear in - * {@link protos.google.cloud.retail.v2alpha.Product.fulfillment_info|SetInventoryRequest.inventory.fulfillment_info} - * * Checks that only the desired fulfillment info types have empty - * {@link protos.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 protos.google.cloud.retail.v2alpha.Product.price_info|Product.price_info} - * * {@link protos.google.cloud.retail.v2alpha.Product.availability|Product.availability} - * * {@link protos.google.cloud.retail.v2alpha.Product.available_quantity|Product.available_quantity} - * * {@link protos.google.cloud.retail.v2alpha.Product.fulfillment_info|Product.fulfillment_info} - * - * If a full overwrite of inventory information while ignoring timestamps is - * needed, - * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product} with - * name {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product} is created. If set - * to false, a NOT_FOUND error is returned if the - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.google.cloud.retail.v2alpha.ProductService.AddLocalInventories|ProductService.AddLocalInventories} - * method instead of - * {@link protos.google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}. - * {@link protos.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 protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. - * - * This process is asynchronous and does not require the - * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product} queried by - * {@link protos.google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct} - * or - * {@link protos.google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. - * - * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link protos.google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|Product.fulfillment_info.type}. - * @param {string[]} request.placeIds - * Required. The IDs for this - * {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories|ProductService.RemoveLocalInventories} - * method instead of - * {@link protos.google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. - * {@link protos.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 protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. - * - * This process is asynchronous and does not require the - * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product} queried by - * {@link protos.google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct} - * or - * {@link protos.google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. - * - * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link protos.google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|Product.fulfillment_info.type}. - * @param {string[]} request.placeIds - * Required. The IDs for this - * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product} queried by - * {@link protos.google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct} - * or - * {@link protos.google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. - * - * Local inventory information can only be modified using this method. - * {@link protos.google.cloud.retail.v2alpha.ProductService.CreateProduct|ProductService.CreateProduct} - * and - * {@link protos.google.cloud.retail.v2alpha.ProductService.UpdateProduct|ProductService.UpdateProduct} - * has no effect on local inventories. - * - * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link protos.google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product} queried by - * {@link protos.google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct} - * or - * {@link protos.google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. - * - * Local inventory information can only be removed using this method. - * {@link protos.google.cloud.retail.v2alpha.ProductService.CreateProduct|ProductService.CreateProduct} - * and - * {@link protos.google.cloud.retail.v2alpha.ProductService.UpdateProduct|ProductService.UpdateProduct} - * has no effect on local inventories. - * - * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link protos.google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.google.cloud.retail.v2alpha.ListProductsRequest.filter|filter} is unset. - * * List - * {@link protos.google.cloud.retail.v2alpha.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link protos.google.cloud.retail.v2alpha.Product|Product}s sharing the same - * {@link protos.google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link protos.google.cloud.retail.v2alpha.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link protos.google.cloud.retail.v2alpha.Product|Product}s bundled in a - * {@link protos.google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link protos.google.cloud.retail.v2alpha.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link protos.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 protos.google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link protos.google.cloud.retail.v2alpha.Product|Product} or - * {@link protos.google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product} to return in - * the responses. If not set or empty, the following fields are returned: - * - * * {@link protos.google.cloud.retail.v2alpha.Product.name|Product.name} - * * {@link protos.google.cloud.retail.v2alpha.Product.id|Product.id} - * * {@link protos.google.cloud.retail.v2alpha.Product.title|Product.title} - * * {@link protos.google.cloud.retail.v2alpha.Product.uri|Product.uri} - * * {@link protos.google.cloud.retail.v2alpha.Product.images|Product.images} - * * {@link protos.google.cloud.retail.v2alpha.Product.price_info|Product.price_info} - * * {@link protos.google.cloud.retail.v2alpha.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link protos.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 protos.google.cloud.retail.v2alpha.ListProductsRequest.page_token|page_token} is - * empty, - * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.google.cloud.retail.v2alpha.ListProductsRequest.filter|filter} is unset. - * * List - * {@link protos.google.cloud.retail.v2alpha.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link protos.google.cloud.retail.v2alpha.Product|Product}s sharing the same - * {@link protos.google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link protos.google.cloud.retail.v2alpha.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link protos.google.cloud.retail.v2alpha.Product|Product}s bundled in a - * {@link protos.google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link protos.google.cloud.retail.v2alpha.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link protos.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 protos.google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link protos.google.cloud.retail.v2alpha.Product|Product} or - * {@link protos.google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product} to return in - * the responses. If not set or empty, the following fields are returned: - * - * * {@link protos.google.cloud.retail.v2alpha.Product.name|Product.name} - * * {@link protos.google.cloud.retail.v2alpha.Product.id|Product.id} - * * {@link protos.google.cloud.retail.v2alpha.Product.title|Product.title} - * * {@link protos.google.cloud.retail.v2alpha.Product.uri|Product.uri} - * * {@link protos.google.cloud.retail.v2alpha.Product.images|Product.images} - * * {@link protos.google.cloud.retail.v2alpha.Product.price_info|Product.price_info} - * * {@link protos.google.cloud.retail.v2alpha.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link protos.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 protos.google.cloud.retail.v2alpha.ListProductsRequest.page_token|page_token} is - * empty, - * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.google.cloud.retail.v2alpha.ListProductsRequest.filter|filter} is unset. - * * List - * {@link protos.google.cloud.retail.v2alpha.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link protos.google.cloud.retail.v2alpha.Product|Product}s sharing the same - * {@link protos.google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link protos.google.cloud.retail.v2alpha.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link protos.google.cloud.retail.v2alpha.Product|Product}s bundled in a - * {@link protos.google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link protos.google.cloud.retail.v2alpha.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link protos.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 protos.google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link protos.google.cloud.retail.v2alpha.Product|Product} or - * {@link protos.google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product} to return in - * the responses. If not set or empty, the following fields are returned: - * - * * {@link protos.google.cloud.retail.v2alpha.Product.name|Product.name} - * * {@link protos.google.cloud.retail.v2alpha.Product.id|Product.id} - * * {@link protos.google.cloud.retail.v2alpha.Product.title|Product.title} - * * {@link protos.google.cloud.retail.v2alpha.Product.uri|Product.uri} - * * {@link protos.google.cloud.retail.v2alpha.Product.images|Product.images} - * * {@link protos.google.cloud.retail.v2alpha.Product.price_info|Product.price_info} - * * {@link protos.google.cloud.retail.v2alpha.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link protos.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 protos.google.cloud.retail.v2alpha.ListProductsRequest.page_token|page_token} is - * empty, - * {@link protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 6f0eec9ff46..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/search_service_client.ts +++ /dev/null @@ -1,2159 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.google.cloud.retail.v2alpha.SearchRequest.filter|filter} and - * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product}s deemed by the API as - * relevant) in search results. This field is only considered if - * {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} - * and - * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} - * {@link protos.google.cloud.retail.v2alpha.Product|Product}s attributes, - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo} or - * {@link protos.google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s attributes. - * The attributes from all the matching - * {@link protos.google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} - * {@link protos.google.cloud.retail.v2alpha.Product|Product}s or - * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.LocalInventory.attributes|Product.local_inventories.attributes} - * map. - * * attributes.key, where key is any key in the - * {@link protos.google.cloud.retail.v2alpha.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.ServingConfig.personalization_spec|ServingConfig.personalization_spec} - * and - * {@link protos.google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * are set. - * {@link protos.google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * will override - * {@link protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.google.cloud.retail.v2alpha.SearchRequest.filter|filter} and - * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product}s deemed by the API as - * relevant) in search results. This field is only considered if - * {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} - * and - * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} - * {@link protos.google.cloud.retail.v2alpha.Product|Product}s attributes, - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo} or - * {@link protos.google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s attributes. - * The attributes from all the matching - * {@link protos.google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} - * {@link protos.google.cloud.retail.v2alpha.Product|Product}s or - * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.LocalInventory.attributes|Product.local_inventories.attributes} - * map. - * * attributes.key, where key is any key in the - * {@link protos.google.cloud.retail.v2alpha.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.ServingConfig.personalization_spec|ServingConfig.personalization_spec} - * and - * {@link protos.google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * are set. - * {@link protos.google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * will override - * {@link protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.google.cloud.retail.v2alpha.SearchRequest.filter|filter} and - * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.google.cloud.retail.v2alpha.Product|Product}s deemed by the API as - * relevant) in search results. This field is only considered if - * {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2alpha.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} - * and - * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} - * {@link protos.google.cloud.retail.v2alpha.Product|Product}s attributes, - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo} or - * {@link protos.google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s attributes. - * The attributes from all the matching - * {@link protos.google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} - * {@link protos.google.cloud.retail.v2alpha.Product|Product}s or - * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.LocalInventory.attributes|Product.local_inventories.attributes} - * map. - * * attributes.key, where key is any key in the - * {@link protos.google.cloud.retail.v2alpha.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link protos.google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.ServingConfig.personalization_spec|ServingConfig.personalization_spec} - * and - * {@link protos.google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * are set. - * {@link protos.google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * will override - * {@link protos.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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 a0ce43a9353..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_client.ts +++ /dev/null @@ -1,1747 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.google.cloud.retail.v2alpha.ServingConfig|ServingConfig}s are allowed in - * a {@link protos.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 protos.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 protos.google.cloud.retail.v2alpha.ServingConfig|ServingConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2alpha.ServingConfig|ServingConfig} to update. The - * following are NOT supported: - * - * * {@link protos.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 protos.google.cloud.retail.v2alpha.ServingConfig|ServingConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2alpha.ServingConfig|ServingConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2alpha.ServingConfig|ServingConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2alpha.ServingConfig|ServingConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 1eae60d1e83..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_client.ts +++ /dev/null @@ -1,1614 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.google.cloud.retail.v2alpha.UserEvent|UserEvent}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.api.HttpBody|HttpBody}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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/package.json b/owl-bot-staging/google-cloud-retail/v2beta/package.json deleted file mode 100644 index 335f43fc78d..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/package.json +++ /dev/null @@ -1,66 +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", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} 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 58aa90a124d..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 = ['abc','def'] - - // 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 9ba73ea0ac7..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 = ['abc','def'] - /** - * 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 391aae2f11d..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 = [1,2,3,4] - /** - * 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 = [1,2,3,4] - - // 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 db6d3860c4f..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 = ['abc','def'] - /** - * 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 55407ab7f73..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 = [1,2,3,4] - /** - * 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 e830998feff..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 = ['abc','def'] - /** - * 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 ecb44e4a246..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 = ['abc','def'] - /** - * 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 bab66266868..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 = [1,2,3,4] - /** - * 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 = ['abc','def'] - /** - * 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 = ['abc','def'] - /** - * 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 = [1,2,3,4] - /** - * 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 331b285dced..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_client.ts +++ /dev/null @@ -1,2287 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.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 protos.google.cloud.retail.v2beta.Catalog|Catalog} to update. - * - * If the caller does not have permission to update the - * {@link protos.google.cloud.retail.v2beta.Catalog|Catalog}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.Catalog|Catalog}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2beta.SearchService.Search|SearchService.Search}, - * {@link protos.google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct}, - * {@link protos.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 protos.google.cloud.retail.v2beta.SearchRequest.branch|SearchRequest.branch} to - * `projects/* /locations/* /catalogs/* /branches/default_branch` is equivalent - * to setting - * {@link protos.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 protos.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 protos.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 protos.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 protos.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 protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2beta.GetDefaultBranchResponse|GetDefaultBranchResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2beta.CompletionConfig|CompletionConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2beta.CompletionConfig|CompletionConfig} to update. - * - * If the caller does not have permission to update the - * {@link protos.google.cloud.retail.v2beta.CompletionConfig|CompletionConfig}, then a - * PERMISSION_DENIED error is returned. - * - * If the {@link protos.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 protos.google.cloud.retail.v2beta.CompletionConfig|CompletionConfig} to update. - * The following are the only supported fields: - * - * * {@link protos.google.cloud.retail.v2beta.CompletionConfig.matching_order|CompletionConfig.matching_order} - * * {@link protos.google.cloud.retail.v2beta.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions} - * * {@link protos.google.cloud.retail.v2beta.CompletionConfig.min_prefix_length|CompletionConfig.min_prefix_length} - * * {@link protos.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 protos.google.cloud.retail.v2beta.CompletionConfig|CompletionConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2beta.AttributesConfig|AttributesConfig} to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link protos.google.cloud.retail.v2beta.AttributesConfig|AttributesConfig} to update. - * The following is the only supported field: - * - * * {@link protos.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 protos.google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to the - * {@link protos.google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. - * - * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} from the - * {@link protos.google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. - * - * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute}s from the - * {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse|BatchRemoveCatalogAttributesResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} in the - * {@link protos.google.cloud.retail.v2beta.AttributesConfig|AttributesConfig} by updating - * the catalog attribute with the same - * {@link protos.google.cloud.retail.v2beta.CatalogAttribute.key|CatalogAttribute.key}. - * - * If the {@link protos.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 protos.google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute}. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link protos.google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to update. - * The following are NOT supported: - * - * * {@link protos.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 protos.google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 063dc71473d..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/completion_service_client.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. ** - -/* 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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.CompleteQueryResponse|CompleteQueryResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 2a269bb1548..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/control_service_client.ts +++ /dev/null @@ -1,1546 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.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 protos.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 protos.google.cloud.retail.v2beta.Control|Control}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2beta.Control|Control} cannot be set to a different - * oneof field, if so an INVALID_ARGUMENT is returned. If the - * {@link protos.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 protos.google.cloud.retail.v2beta.Control|Control} to update. The following are - * NOT supported: - * - * * {@link protos.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 protos.google.cloud.retail.v2beta.Control|Control}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2beta.Control|Control}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 ce6c0b4b219..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_client.ts +++ /dev/null @@ -1,1797 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.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 protos.google.cloud.retail.v2beta.Model|Model}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2beta.Model|Model}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2beta.Model|Model}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2beta.Model|Model}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 6ca97c6d694..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/prediction_service_client.ts +++ /dev/null @@ -1,1222 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id} or - * {@link protos.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 protos.google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id} to - * a random unique ID and leave - * {@link protos.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 protos.google.cloud.retail.v2beta.PredictResponse|PredictResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 fa54c373837..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/product_service_client.ts +++ /dev/null @@ -1,2843 +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 protos.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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.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 protos.google.cloud.retail.v2beta.Product|Product} to create. - * @param {string} request.productId - * Required. The ID to use for the - * {@link protos.google.cloud.retail.v2beta.Product|Product}, which will become the final - * component of the {@link protos.google.cloud.retail.v2beta.Product.name|Product.name}. - * - * If the caller does not have permission to create the - * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product}s with the same - * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2beta.Product|Product}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * - * If the requested {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.google.cloud.retail.v2beta.Product|Product}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link protos.google.cloud.retail.v2beta.Product|Product} to update does not - * exist and - * {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.Product|Product} is - * not found, a new {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2beta.Product|Product}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link protos.google.cloud.retail.v2beta.Product|Product} to delete does not - * exist, a NOT_FOUND error is returned. - * - * The {@link protos.google.cloud.retail.v2beta.Product|Product} to delete can neither be - * a - * {@link protos.google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link protos.google.cloud.retail.v2beta.Product|Product} member nor a - * {@link protos.google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link protos.google.cloud.retail.v2beta.Product|Product} with more than one - * {@link protos.google.cloud.retail.v2beta.Product.Type.VARIANT|variants}. Otherwise, an - * INVALID_ARGUMENT error is returned. - * - * All inventory information for the named - * {@link protos.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 protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 protos.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 protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2beta.Product|Product} queried by - * {@link protos.google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct} - * or - * {@link protos.google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. - * - * When inventory is updated with - * {@link protos.google.cloud.retail.v2beta.ProductService.CreateProduct|ProductService.CreateProduct} - * and - * {@link protos.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 protos.google.cloud.retail.v2beta.ProductService.CreateProduct|ProductService.CreateProduct} - * or - * {@link protos.google.cloud.retail.v2beta.ProductService.UpdateProduct|ProductService.UpdateProduct} - * request. - * - * If no inventory fields are set in - * {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.ProductService.SetInventory|ProductService.SetInventory}, - * {@link protos.google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}, - * and - * {@link protos.google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. - * - * The returned {@link protos.google.longrunning.Operation|Operation}s is obsolete after - * one day, and the {@link protos.google.longrunning.Operations.GetOperation|GetOperation} - * API returns `NOT_FOUND` afterwards. - * - * If conflicting updates are issued, the - * {@link protos.google.longrunning.Operation|Operation}s associated with the stale - * updates are not marked as {@link protos.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 protos.google.cloud.retail.v2beta.Product.price_info|Product.price_info} - * * {@link protos.google.cloud.retail.v2beta.Product.availability|Product.availability} - * * {@link protos.google.cloud.retail.v2beta.Product.available_quantity|Product.available_quantity} - * * {@link protos.google.cloud.retail.v2beta.Product.fulfillment_info|Product.fulfillment_info} - * The updated inventory fields must be specified in - * {@link protos.google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}. - * - * If - * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product} named in - * {@link protos.google.cloud.retail.v2beta.Product.name|Product.name}, regardless of - * whether or not it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link protos.google.cloud.retail.v2beta.Product|Product} to update does not - * have existing inventory information, the provided inventory information - * will be inserted. - * - * If the {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} - * * Specifies only the desired fulfillment types and corresponding place IDs - * to update in - * {@link protos.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 protos.google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} - * * Specifies only the desired fulfillment types to clear in - * {@link protos.google.cloud.retail.v2beta.Product.fulfillment_info|SetInventoryRequest.inventory.fulfillment_info} - * * Checks that only the desired fulfillment info types have empty - * {@link protos.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 protos.google.cloud.retail.v2beta.Product.price_info|Product.price_info} - * * {@link protos.google.cloud.retail.v2beta.Product.availability|Product.availability} - * * {@link protos.google.cloud.retail.v2beta.Product.available_quantity|Product.available_quantity} - * * {@link protos.google.cloud.retail.v2beta.Product.fulfillment_info|Product.fulfillment_info} - * - * If a full overwrite of inventory information while ignoring timestamps is - * needed, - * {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.Product|Product} with - * name {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product} is created. If set - * to false, a NOT_FOUND error is returned if the - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.google.cloud.retail.v2beta.ProductService.AddLocalInventories|ProductService.AddLocalInventories} - * method instead of - * {@link protos.google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}. - * {@link protos.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 protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. - * - * This process is asynchronous and does not require the - * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product} queried by - * {@link protos.google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct} - * or - * {@link protos.google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. - * - * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link protos.google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.FulfillmentInfo.type|Product.fulfillment_info.type}. - * @param {string[]} request.placeIds - * Required. The IDs for this - * {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.google.cloud.retail.v2beta.ProductService.RemoveLocalInventories|ProductService.RemoveLocalInventories} - * method instead of - * {@link protos.google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. - * {@link protos.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 protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. - * - * This process is asynchronous and does not require the - * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product} queried by - * {@link protos.google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct} - * or - * {@link protos.google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. - * - * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link protos.google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.FulfillmentInfo.type|Product.fulfillment_info.type}. - * @param {string[]} request.placeIds - * Required. The IDs for this - * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2beta.Product|Product} queried by - * {@link protos.google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct} - * or - * {@link protos.google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. - * - * Local inventory information can only be modified using this method. - * {@link protos.google.cloud.retail.v2beta.ProductService.CreateProduct|ProductService.CreateProduct} - * and - * {@link protos.google.cloud.retail.v2beta.ProductService.UpdateProduct|ProductService.UpdateProduct} - * has no effect on local inventories. - * - * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link protos.google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.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 protos.google.cloud.retail.v2beta.Product|Product} queried by - * {@link protos.google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct} - * or - * {@link protos.google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. - * - * Local inventory information can only be removed using this method. - * {@link protos.google.cloud.retail.v2beta.ProductService.CreateProduct|ProductService.CreateProduct} - * and - * {@link protos.google.cloud.retail.v2beta.ProductService.UpdateProduct|ProductService.UpdateProduct} - * has no effect on local inventories. - * - * The returned {@link protos.google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link protos.google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link protos.google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.google.cloud.retail.v2beta.ListProductsRequest.filter|filter} is unset. - * * List - * {@link protos.google.cloud.retail.v2beta.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link protos.google.cloud.retail.v2beta.Product|Product}s sharing the same - * {@link protos.google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link protos.google.cloud.retail.v2beta.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link protos.google.cloud.retail.v2beta.Product|Product}s bundled in a - * {@link protos.google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link protos.google.cloud.retail.v2beta.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link protos.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 protos.google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link protos.google.cloud.retail.v2beta.Product|Product} or - * {@link protos.google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product} to return in - * the responses. If not set or empty, the following fields are returned: - * - * * {@link protos.google.cloud.retail.v2beta.Product.name|Product.name} - * * {@link protos.google.cloud.retail.v2beta.Product.id|Product.id} - * * {@link protos.google.cloud.retail.v2beta.Product.title|Product.title} - * * {@link protos.google.cloud.retail.v2beta.Product.uri|Product.uri} - * * {@link protos.google.cloud.retail.v2beta.Product.images|Product.images} - * * {@link protos.google.cloud.retail.v2beta.Product.price_info|Product.price_info} - * * {@link protos.google.cloud.retail.v2beta.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2beta.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.google.cloud.retail.v2beta.ListProductsRequest.filter|filter} is unset. - * * List - * {@link protos.google.cloud.retail.v2beta.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link protos.google.cloud.retail.v2beta.Product|Product}s sharing the same - * {@link protos.google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link protos.google.cloud.retail.v2beta.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link protos.google.cloud.retail.v2beta.Product|Product}s bundled in a - * {@link protos.google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link protos.google.cloud.retail.v2beta.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link protos.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 protos.google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link protos.google.cloud.retail.v2beta.Product|Product} or - * {@link protos.google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product} to return in - * the responses. If not set or empty, the following fields are returned: - * - * * {@link protos.google.cloud.retail.v2beta.Product.name|Product.name} - * * {@link protos.google.cloud.retail.v2beta.Product.id|Product.id} - * * {@link protos.google.cloud.retail.v2beta.Product.title|Product.title} - * * {@link protos.google.cloud.retail.v2beta.Product.uri|Product.uri} - * * {@link protos.google.cloud.retail.v2beta.Product.images|Product.images} - * * {@link protos.google.cloud.retail.v2beta.Product.price_info|Product.price_info} - * * {@link protos.google.cloud.retail.v2beta.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 protos.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 protos.google.cloud.retail.v2beta.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.google.cloud.retail.v2beta.ListProductsRequest.filter|filter} is unset. - * * List - * {@link protos.google.cloud.retail.v2beta.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link protos.google.cloud.retail.v2beta.Product|Product}s sharing the same - * {@link protos.google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link protos.google.cloud.retail.v2beta.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link protos.google.cloud.retail.v2beta.Product|Product}s bundled in a - * {@link protos.google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link protos.google.cloud.retail.v2beta.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link protos.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 protos.google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link protos.google.cloud.retail.v2beta.Product|Product} or - * {@link protos.google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product} to return in - * the responses. If not set or empty, the following fields are returned: - * - * * {@link protos.google.cloud.retail.v2beta.Product.name|Product.name} - * * {@link protos.google.cloud.retail.v2beta.Product.id|Product.id} - * * {@link protos.google.cloud.retail.v2beta.Product.title|Product.title} - * * {@link protos.google.cloud.retail.v2beta.Product.uri|Product.uri} - * * {@link protos.google.cloud.retail.v2beta.Product.images|Product.images} - * * {@link protos.google.cloud.retail.v2beta.Product.price_info|Product.price_info} - * * {@link protos.google.cloud.retail.v2beta.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 9abe414e819..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/search_service_client.ts +++ /dev/null @@ -1,2037 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.google.cloud.retail.v2beta.SearchRequest.filter|filter} and - * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product}s - * deemed by the API as relevant) in search results. This field is only - * considered if - * {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} - * and - * {@link protos.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 protos.google.cloud.retail.v2beta.Product.Type.VARIANT|variant} - * {@link protos.google.cloud.retail.v2beta.Product|Product}s attributes, - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo} or - * {@link protos.google.cloud.retail.v2beta.LocalInventory|LocalInventory}s attributes. - * The attributes from all the matching - * {@link protos.google.cloud.retail.v2beta.Product.Type.VARIANT|variant} - * {@link protos.google.cloud.retail.v2beta.Product|Product}s or - * {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.LocalInventory.attributes|Product.local_inventories.attributes} - * map. - * * attributes.key, where key is any key in the - * {@link protos.google.cloud.retail.v2beta.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec} - * and - * {@link protos.google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * are set. - * {@link protos.google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * will override - * {@link protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.google.cloud.retail.v2beta.SearchRequest.filter|filter} and - * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product}s - * deemed by the API as relevant) in search results. This field is only - * considered if - * {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} - * and - * {@link protos.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 protos.google.cloud.retail.v2beta.Product.Type.VARIANT|variant} - * {@link protos.google.cloud.retail.v2beta.Product|Product}s attributes, - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo} or - * {@link protos.google.cloud.retail.v2beta.LocalInventory|LocalInventory}s attributes. - * The attributes from all the matching - * {@link protos.google.cloud.retail.v2beta.Product.Type.VARIANT|variant} - * {@link protos.google.cloud.retail.v2beta.Product|Product}s or - * {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.LocalInventory.attributes|Product.local_inventories.attributes} - * map. - * * attributes.key, where key is any key in the - * {@link protos.google.cloud.retail.v2beta.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec} - * and - * {@link protos.google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * are set. - * {@link protos.google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * will override - * {@link protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.google.cloud.retail.v2beta.SearchRequest.filter|filter} and - * {@link protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link protos.google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.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 protos.google.cloud.retail.v2beta.Product|Product}s - * deemed by the API as relevant) in search results. This field is only - * considered if - * {@link protos.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 protos.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 protos.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 protos.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 protos.google.cloud.retail.v2beta.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} - * and - * {@link protos.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 protos.google.cloud.retail.v2beta.Product.Type.VARIANT|variant} - * {@link protos.google.cloud.retail.v2beta.Product|Product}s attributes, - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo} or - * {@link protos.google.cloud.retail.v2beta.LocalInventory|LocalInventory}s attributes. - * The attributes from all the matching - * {@link protos.google.cloud.retail.v2beta.Product.Type.VARIANT|variant} - * {@link protos.google.cloud.retail.v2beta.Product|Product}s or - * {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.LocalInventory.attributes|Product.local_inventories.attributes} - * map. - * * attributes.key, where key is any key in the - * {@link protos.google.cloud.retail.v2beta.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link protos.google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec} - * and - * {@link protos.google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * are set. - * {@link protos.google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * will override - * {@link protos.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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 cec43f73cdd..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/serving_config_service_client.ts +++ /dev/null @@ -1,1681 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.google.cloud.retail.v2beta.ServingConfig|ServingConfig}s - * are allowed in a {@link protos.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 protos.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 protos.google.cloud.retail.v2beta.ServingConfig|ServingConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2beta.ServingConfig|ServingConfig} to update. The - * following are NOT supported: - * - * * {@link protos.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 protos.google.cloud.retail.v2beta.ServingConfig|ServingConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2beta.ServingConfig|ServingConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2beta.ServingConfig|ServingConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.cloud.retail.v2beta.ServingConfig|ServingConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 03f11d11e7d..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/user_event_service_client.ts +++ /dev/null @@ -1,1549 +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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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: true}, 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 { - 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) { - 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 protos.google.cloud.retail.v2beta.UserEvent|UserEvent}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.google.api.HttpBody|HttpBody}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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/owl-bot-staging/google-cloud-run/v2/.eslintignore b/owl-bot-staging/google-cloud-run/v2/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-run/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-run/v2/.eslintrc.json b/owl-bot-staging/google-cloud-run/v2/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-run/v2/.gitignore b/owl-bot-staging/google-cloud-run/v2/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-run/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-run/v2/.jsdoc.js b/owl-bot-staging/google-cloud-run/v2/.jsdoc.js deleted file mode 100644 index fd5db45a599..00000000000 --- a/owl-bot-staging/google-cloud-run/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/run', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-run/v2/.mocharc.js b/owl-bot-staging/google-cloud-run/v2/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-run/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-run/v2/.prettierrc.js b/owl-bot-staging/google-cloud-run/v2/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-run/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-run/v2/README.md b/owl-bot-staging/google-cloud-run/v2/README.md deleted file mode 100644 index bc79325d121..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/README.md +++ /dev/null @@ -1 +0,0 @@ -Run: Nodejs Client diff --git a/owl-bot-staging/google-cloud-run/v2/package.json b/owl-bot-staging/google-cloud-run/v2/package.json deleted file mode 100644 index 88d18b9fdcc..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/package.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "name": "@google-cloud/run", - "version": "0.1.0", - "description": "Run client for Node.js", - "repository": "googleapis/nodejs-run", - "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 run", - "run", - "executions", - "jobs", - "revisions", - "services", - "tasks" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/condition.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/condition.proto deleted file mode 100644 index cb6680a61b5..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/condition.proto +++ /dev/null @@ -1,209 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.run.v2; - -import "google/protobuf/timestamp.proto"; - -option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; -option java_multiple_files = true; -option java_outer_classname = "ConditionProto"; -option java_package = "com.google.cloud.run.v2"; - -// Defines a status condition for a resource. -message Condition { - // Represents the possible Condition states. - enum State { - // The default value. This value is used if the state is omitted. - STATE_UNSPECIFIED = 0; - - // Transient state: Reconciliation has not started yet. - CONDITION_PENDING = 1; - - // Transient state: reconciliation is still in progress. - CONDITION_RECONCILING = 2; - - // Terminal state: Reconciliation did not succeed. - CONDITION_FAILED = 3; - - // Terminal state: Reconciliation completed successfully. - CONDITION_SUCCEEDED = 4; - } - - // Represents the severity of the condition failures. - enum Severity { - // Unspecified severity - SEVERITY_UNSPECIFIED = 0; - - // Error severity. - ERROR = 1; - - // Warning severity. - WARNING = 2; - - // Info severity. - INFO = 3; - } - - // Reasons common to all types of conditions. - enum CommonReason { - // Default value. - COMMON_REASON_UNDEFINED = 0; - - // Reason unknown. Further details will be in message. - UNKNOWN = 1; - - // Revision creation process failed. - REVISION_FAILED = 3; - - // Timed out waiting for completion. - PROGRESS_DEADLINE_EXCEEDED = 4; - - // The container image path is incorrect. - CONTAINER_MISSING = 6; - - // Insufficient permissions on the container image. - CONTAINER_PERMISSION_DENIED = 7; - - // Container image is not authorized by policy. - CONTAINER_IMAGE_UNAUTHORIZED = 8; - - // Container image policy authorization check failed. - CONTAINER_IMAGE_AUTHORIZATION_CHECK_FAILED = 9; - - // Insufficient permissions on encryption key. - ENCRYPTION_KEY_PERMISSION_DENIED = 10; - - // Permission check on encryption key failed. - ENCRYPTION_KEY_CHECK_FAILED = 11; - - // At least one Access check on secrets failed. - SECRETS_ACCESS_CHECK_FAILED = 12; - - // Waiting for operation to complete. - WAITING_FOR_OPERATION = 13; - - // System will retry immediately. - IMMEDIATE_RETRY = 14; - - // System will retry later; current attempt failed. - POSTPONED_RETRY = 15; - - // An internal error occurred. Further information may be in the message. - INTERNAL = 16; - } - - // Reasons specific to Revision resource. - enum RevisionReason { - // Default value. - REVISION_REASON_UNDEFINED = 0; - - // Revision in Pending state. - PENDING = 1; - - // Revision is in Reserve state. - RESERVE = 2; - - // Revision is Retired. - RETIRED = 3; - - // Revision is being retired. - RETIRING = 4; - - // Revision is being recreated. - RECREATING = 5; - - // There was a health check error. - HEALTH_CHECK_CONTAINER_ERROR = 6; - - // Health check failed due to user error from customized path of the - // container. System will retry. - CUSTOMIZED_PATH_RESPONSE_PENDING = 7; - - // A revision with min_instance_count > 0 was created and is reserved, but - // it was not configured to serve traffic, so it's not live. This can also - // happen momentarily during traffic migration. - MIN_INSTANCES_NOT_PROVISIONED = 8; - - // The maximum allowed number of active revisions has been reached. - ACTIVE_REVISION_LIMIT_REACHED = 9; - - // There was no deployment defined. - // This value is no longer used, but Services created in older versions of - // the API might contain this value. - NO_DEPLOYMENT = 10; - - // A revision's container has no port specified since the revision is of a - // manually scaled service with 0 instance count - HEALTH_CHECK_SKIPPED = 11; - - // A revision with min_instance_count > 0 was created and is waiting for - // enough instances to begin a traffic migration. - MIN_INSTANCES_WARMING = 12; - } - - // Reasons specific to Execution resource. - enum ExecutionReason { - // Default value. - EXECUTION_REASON_UNDEFINED = 0; - - // Internal system error getting execution status. System will retry. - JOB_STATUS_SERVICE_POLLING_ERROR = 1; - - // A task reached its retry limit and the last attempt failed due to the - // user container exiting with a non-zero exit code. - NON_ZERO_EXIT_CODE = 2; - - // The execution was cancelled by users. - CANCELLED = 3; - - // The execution is in the process of being cancelled. - CANCELLING = 4; - } - - // type is used to communicate the status of the reconciliation process. - // See also: - // https://github.com/knative/serving/blob/main/docs/spec/errors.md#error-conditions-and-reporting - // Types common to all resources include: - // * "Ready": True when the Resource is ready. - string type = 1; - - // State of the condition. - State state = 2; - - // Human readable message indicating details about the current status. - string message = 3; - - // Last time the condition transitioned from one status to another. - google.protobuf.Timestamp last_transition_time = 4; - - // How to interpret failures of this condition, one of Error, Warning, Info - Severity severity = 5; - - // The reason for this condition. Depending on the condition type, - // it will populate one of these fields. - // Successful conditions cannot have a reason. - oneof reasons { - // A common (service-level) reason for this condition. - CommonReason reason = 6; - - // A reason for the revision condition. - RevisionReason revision_reason = 9; - - // A reason for the execution condition. - ExecutionReason execution_reason = 11; - } -} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/execution.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/execution.proto deleted file mode 100644 index 29b73a232fa..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/execution.proto +++ /dev/null @@ -1,277 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.run.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/launch_stage.proto"; -import "google/api/resource.proto"; -import "google/cloud/run/v2/condition.proto"; -import "google/cloud/run/v2/task_template.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; -option java_multiple_files = true; -option java_outer_classname = "ExecutionProto"; -option java_package = "com.google.cloud.run.v2"; - -// Cloud Run Execution Control Plane API. -service Executions { - option (google.api.default_host) = "run.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Gets information about an Execution. - rpc GetExecution(GetExecutionRequest) returns (Execution) { - option (google.api.http) = { - get: "/v2/{name=projects/*/locations/*/jobs/*/executions/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists Executions from a Job. - rpc ListExecutions(ListExecutionsRequest) returns (ListExecutionsResponse) { - option (google.api.http) = { - get: "/v2/{parent=projects/*/locations/*/jobs/*}/executions" - }; - option (google.api.method_signature) = "parent"; - } - - // Deletes an Execution. - rpc DeleteExecution(DeleteExecutionRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v2/{name=projects/*/locations/*/jobs/*/executions/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Execution" - metadata_type: "Execution" - }; - } -} - -// Request message for obtaining a Execution by its full name. -message GetExecutionRequest { - // Required. The full name of the Execution. - // Format: - // projects/{project}/locations/{location}/jobs/{job}/executions/{execution}, - // where {project} can be project id or number. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "run.googleapis.com/Execution" } - ]; -} - -// Request message for retrieving a list of Executions. -message ListExecutionsRequest { - // Required. The Execution from which the Executions should be listed. - // To list all Executions across Jobs, use "-" instead of Job name. - // Format: projects/{project}/locations/{location}/jobs/{job}, where {project} - // can be project id or number. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "run.googleapis.com/Execution" - } - ]; - - // Maximum number of Executions to return in this call. - int32 page_size = 2; - - // A page token received from a previous call to ListExecutions. - // All other parameters must match. - string page_token = 3; - - // If true, returns deleted (but unexpired) resources along with active ones. - bool show_deleted = 4; -} - -// Response message containing a list of Executions. -message ListExecutionsResponse { - // The resulting list of Executions. - repeated Execution executions = 1; - - // A token indicating there are more items than page_size. Use it in the next - // ListExecutions request to continue. - string next_page_token = 2; -} - -// Request message for deleting an Execution. -message DeleteExecutionRequest { - // Required. The name of the Execution to delete. - // Format: - // projects/{project}/locations/{location}/jobs/{job}/executions/{execution}, - // where {project} can be project id or number. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "run.googleapis.com/Execution" } - ]; - - // Indicates that the request should be validated without actually - // deleting any resources. - bool validate_only = 2; - - // A system-generated fingerprint for this version of the resource. - // This may be used to detect modification conflict during updates. - string etag = 3; -} - -// Execution represents the configuration of a single execution. A execution an -// immutable resource that references a container image which is run to -// completion. -message Execution { - option (google.api.resource) = { - type: "run.googleapis.com/Execution" - pattern: "projects/{project}/locations/{location}/jobs/{job}/executions/{execution}" - style: DECLARATIVE_FRIENDLY - }; - - // Output only. The unique name of this Execution. - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Server assigned unique identifier for the Execution. The value - // is a UUID4 string and guaranteed to remain unchanged until the resource is - // deleted. - string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A number that monotonically increases every time the user - // modifies the desired state. - int64 generation = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Unstructured key value map that can be used to organize and - // categorize objects. User-provided labels are shared with Google's billing - // system, so they can be used to filter, or break down billing charges by - // team, component, environment, state, etc. For more information, visit - // https://cloud.google.com/resource-manager/docs/creating-managing-labels or - // https://cloud.google.com/run/docs/configuring/labels - map labels = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Unstructured key value map that may - // be set by external tools to store and arbitrary metadata. - // They are not queryable and should be preserved - // when modifying objects. - map annotations = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Represents time when the execution was acknowledged by the - // execution controller. It is not guaranteed to be set in happens-before - // order across separate operations. - google.protobuf.Timestamp create_time = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Represents time when the execution started to run. - // It is not guaranteed to be set in happens-before order across separate - // operations. - google.protobuf.Timestamp start_time = 22 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Represents time when the execution was completed. It is not - // guaranteed to be set in happens-before order across separate operations. - google.protobuf.Timestamp completion_time = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The last-modified time. - google.protobuf.Timestamp update_time = 8 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. For a deleted resource, the deletion time. It is only - // populated as a response to a Delete request. - google.protobuf.Timestamp delete_time = 9 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. For a deleted resource, the time after which it will be - // permamently deleted. It is only populated as a response to a Delete - // request. - google.protobuf.Timestamp expire_time = 10 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The least stable launch stage needed to create this resource, as defined by - // [Google Cloud Platform Launch - // Stages](https://cloud.google.com/terms/launch-stages). Cloud Run supports - // `ALPHA`, `BETA`, and `GA`. - //

Note that this value might not be what was used - // as input. For example, if ALPHA was provided as input in the parent - // resource, but only BETA and GA-level features are were, this field will be - // BETA. - google.api.LaunchStage launch_stage = 11; - - // Output only. The name of the parent Job. - string job = 12 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.resource_reference) = { type: "run.googleapis.com/Job" } - ]; - - // Output only. Specifies the maximum desired number of tasks the execution - // should run at any given time. Must be <= task_count. The actual number of - // tasks running in steady state will be less than this number when - // ((.spec.task_count - .status.successful) < .spec.parallelism), i.e. when - // the work left to do is less than max parallelism. - int32 parallelism = 13 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Specifies the desired number of tasks the execution should - // run. Setting to 1 means that parallelism is limited to 1 and the success of - // that task signals the success of the execution. - int32 task_count = 14 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The template used to create tasks for this execution. - TaskTemplate template = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Indicates whether the resource's reconciliation is still in - // progress. See comments in `Job.reconciling` for additional information on - // reconciliation process in Cloud Run. - bool reconciling = 16 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The Condition of this Execution, containing its readiness - // status, and detailed error information in case it did not reach the desired - // state. - repeated Condition conditions = 17 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The generation of this Execution. See comments in - // `reconciling` for additional information on reconciliation process in Cloud - // Run. - int64 observed_generation = 18 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The number of actively running tasks. - int32 running_count = 19 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The number of tasks which reached phase Succeeded. - int32 succeeded_count = 20 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The number of tasks which reached phase Failed. - int32 failed_count = 21 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The number of tasks which reached phase Cancelled. - int32 cancelled_count = 24 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The number of tasks which have retried at least once. - int32 retried_count = 25 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. URI where logs for this execution can be found in Cloud - // Console. - string log_uri = 26 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Reserved for future use. - bool satisfies_pzs = 27 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A system-generated fingerprint for this version of the - // resource. May be used to detect modification conflict during updates. - string etag = 99 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/execution_template.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/execution_template.proto deleted file mode 100644 index 55f465a5f43..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/execution_template.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.run.v2; - -import "google/api/field_behavior.proto"; -import "google/cloud/run/v2/task_template.proto"; - -option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; -option java_multiple_files = true; -option java_outer_classname = "ExecutionTemplateProto"; -option java_package = "com.google.cloud.run.v2"; - -// ExecutionTemplate describes the data an execution should have when created -// from a template. -message ExecutionTemplate { - // Unstructured key value map that can be used to organize and categorize - // objects. - // User-provided labels are shared with Google's billing system, so they can - // be used to filter, or break down billing charges by team, component, - // environment, state, etc. For more information, visit - // https://cloud.google.com/resource-manager/docs/creating-managing-labels or - // https://cloud.google.com/run/docs/configuring/labels. - // - //

Cloud Run API v2 does not support labels with `run.googleapis.com`, - // `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` - // namespaces, and they will be rejected. All system labels in v1 now have a - // corresponding field in v2 ExecutionTemplate. - map labels = 1; - - // Unstructured key value map that may be set by external tools to store and - // arbitrary metadata. They are not queryable and should be preserved - // when modifying objects. - // - //

Cloud Run API v2 does not support annotations with `run.googleapis.com`, - // `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` - // namespaces, and they will be rejected. All system annotations in v1 now - // have a corresponding field in v2 ExecutionTemplate. - // - //

This field follows Kubernetes annotations' namespacing, limits, and - // rules. - map annotations = 2; - - // Specifies the maximum desired number of tasks the execution should run at - // given time. Must be <= task_count. - // When the job is run, if this field is 0 or unset, the maximum possible - // value will be used for that execution. - // The actual number of tasks running in steady state will be less than this - // number when there are fewer tasks waiting to be completed remaining, - // i.e. when the work left to do is less than max parallelism. - int32 parallelism = 3; - - // Specifies the desired number of tasks the execution should run. - // Setting to 1 means that parallelism is limited to 1 and the success of - // that task signals the success of the execution. Defaults to 1. - int32 task_count = 4; - - // Required. Describes the task(s) that will be created when executing an - // execution. - TaskTemplate template = 5 [(google.api.field_behavior) = REQUIRED]; -} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/job.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/job.proto deleted file mode 100644 index b180eb50610..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/job.proto +++ /dev/null @@ -1,424 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.run.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/launch_stage.proto"; -import "google/api/resource.proto"; -import "google/cloud/run/v2/condition.proto"; -import "google/cloud/run/v2/execution.proto"; -import "google/cloud/run/v2/execution_template.proto"; -import "google/cloud/run/v2/vendor_settings.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; -option java_multiple_files = true; -option java_outer_classname = "JobProto"; -option java_package = "com.google.cloud.run.v2"; - -// Cloud Run Job Control Plane API. -service Jobs { - option (google.api.default_host) = "run.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a Job. - rpc CreateJob(CreateJobRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{parent=projects/*/locations/*}/jobs" - body: "job" - }; - option (google.api.method_signature) = "parent,job,job_id"; - option (google.longrunning.operation_info) = { - response_type: "Job" - metadata_type: "Job" - }; - } - - // Gets information about a Job. - rpc GetJob(GetJobRequest) returns (Job) { - option (google.api.http) = { - get: "/v2/{name=projects/*/locations/*/jobs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists Jobs. - rpc ListJobs(ListJobsRequest) returns (ListJobsResponse) { - option (google.api.http) = { - get: "/v2/{parent=projects/*/locations/*}/jobs" - }; - option (google.api.method_signature) = "parent"; - } - - // Updates a Job. - rpc UpdateJob(UpdateJobRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v2/{job.name=projects/*/locations/*/jobs/*}" - body: "job" - }; - option (google.api.method_signature) = "job"; - option (google.longrunning.operation_info) = { - response_type: "Job" - metadata_type: "Job" - }; - } - - // Deletes a Job. - rpc DeleteJob(DeleteJobRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v2/{name=projects/*/locations/*/jobs/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Job" - metadata_type: "Job" - }; - } - - // Triggers creation of a new Execution of this Job. - rpc RunJob(RunJobRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{name=projects/*/locations/*/jobs/*}:run" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Execution" - metadata_type: "Execution" - }; - } - - // Gets the IAM Access Control policy currently in effect for the given Job. - // This result does not include any inherited policies. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) - returns (google.iam.v1.Policy) { - option (google.api.http) = { - get: "/v2/{resource=projects/*/locations/*/jobs/*}:getIamPolicy" - }; - } - - // Sets the IAM Access control policy for the specified Job. Overwrites - // any existing policy. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) - returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v2/{resource=projects/*/locations/*/jobs/*}:setIamPolicy" - body: "*" - }; - } - - // Returns permissions that a caller has on the specified Project. - // - // There are no permissions required for making this API call. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) - returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v2/{resource=projects/*/locations/*/jobs/*}:testIamPermissions" - body: "*" - }; - } -} - -// Request message for creating a Job. -message CreateJobRequest { - // Required. The location and project in which this Job should be created. - // Format: projects/{project}/locations/{location}, where {project} can be - // project id or number. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { child_type: "run.googleapis.com/Job" } - ]; - - // Required. The Job instance to create. - Job job = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The unique identifier for the Job. The name of the job becomes - // {parent}/jobs/{job_id}. - string job_id = 3 [(google.api.field_behavior) = REQUIRED]; - - // Indicates that the request should be validated and default values - // populated, without persisting the request or creating any resources. - bool validate_only = 4; -} - -// Request message for obtaining a Job by its full name. -message GetJobRequest { - // Required. The full name of the Job. - // Format: projects/{project}/locations/{location}/jobs/{job}, where {project} - // can be project id or number. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "run.googleapis.com/Job" } - ]; -} - -// Request message for updating a Job. -message UpdateJobRequest { - // Required. The Job to be updated. - Job job = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates that the request should be validated and default values - // populated, without persisting the request or updating any resources. - bool validate_only = 3; - - // If set to true, and if the Job does not exist, it will create a new - // one. Caller must have both create and update permissions for this call if - // this is set to true. - bool allow_missing = 4; -} - -// Request message for retrieving a list of Jobs. -message ListJobsRequest { - // Required. The location and project to list resources on. - // Format: projects/{project}/locations/{location}, where {project} can be - // project id or number. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { child_type: "run.googleapis.com/Job" } - ]; - - // Maximum number of Jobs to return in this call. - int32 page_size = 2; - - // A page token received from a previous call to ListJobs. - // All other parameters must match. - string page_token = 3; - - // If true, returns deleted (but unexpired) resources along with active ones. - bool show_deleted = 4; -} - -// Response message containing a list of Jobs. -message ListJobsResponse { - // The resulting list of Jobs. - repeated Job jobs = 1; - - // A token indicating there are more items than page_size. Use it in the next - // ListJobs request to continue. - string next_page_token = 2; -} - -// Request message to delete a Job by its full name. -message DeleteJobRequest { - // Required. The full name of the Job. - // Format: projects/{project}/locations/{location}/jobs/{job}, where {project} - // can be project id or number. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "run.googleapis.com/Job" } - ]; - - // Indicates that the request should be validated without actually - // deleting any resources. - bool validate_only = 3; - - // A system-generated fingerprint for this version of the - // resource. May be used to detect modification conflict during updates. - string etag = 4; -} - -// Request message to create a new Execution of a Job. -message RunJobRequest { - // Required. The full name of the Job. - // Format: projects/{project}/locations/{location}/jobs/{job}, where {project} - // can be project id or number. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "run.googleapis.com/Job" } - ]; - - // Indicates that the request should be validated without actually - // deleting any resources. - bool validate_only = 2; - - // A system-generated fingerprint for this version of the - // resource. May be used to detect modification conflict during updates. - string etag = 3; -} - -// Job represents the configuration of a single job, which references a -// container image that is run to completion. -message Job { - option (google.api.resource) = { - type: "run.googleapis.com/Job" - pattern: "projects/{project}/locations/{location}/jobs/{job}" - style: DECLARATIVE_FRIENDLY - }; - - // The fully qualified name of this Job. - // - // Format: - // projects/{project}/locations/{location}/jobs/{job} - string name = 1; - - // Output only. Server assigned unique identifier for the Execution. The value - // is a UUID4 string and guaranteed to remain unchanged until the resource is - // deleted. - string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A number that monotonically increases every time the user - // modifies the desired state. - int64 generation = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Unstructured key value map that can be used to organize and categorize - // objects. - // User-provided labels are shared with Google's billing system, so they can - // be used to filter, or break down billing charges by team, component, - // environment, state, etc. For more information, visit - // https://cloud.google.com/resource-manager/docs/creating-managing-labels or - // https://cloud.google.com/run/docs/configuring/labels. - // - //

Cloud Run API v2 does not support labels with `run.googleapis.com`, - // `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` - // namespaces, and they will be rejected. All system labels in v1 now have a - // corresponding field in v2 Job. - map labels = 4; - - // Unstructured key value map that may - // be set by external tools to store and arbitrary metadata. - // They are not queryable and should be preserved - // when modifying objects. - // - //

Cloud Run API v2 does not support annotations with `run.googleapis.com`, - // `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` - // namespaces, and they will be rejected on new resources. All system - // annotations in v1 now have a corresponding field in v2 Job. - // - //

This field follows Kubernetes annotations' namespacing, limits, and - // rules. - map annotations = 5; - - // Output only. The creation time. - google.protobuf.Timestamp create_time = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The last-modified time. - google.protobuf.Timestamp update_time = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The deletion time. - google.protobuf.Timestamp delete_time = 8 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. For a deleted resource, the time after which it will be - // permamently deleted. - google.protobuf.Timestamp expire_time = 9 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Email address of the authenticated creator. - string creator = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Email address of the last authenticated modifier. - string last_modifier = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Arbitrary identifier for the API client. - string client = 12; - - // Arbitrary version identifier for the API client. - string client_version = 13; - - // The launch stage as defined by [Google Cloud Platform - // Launch Stages](https://cloud.google.com/terms/launch-stages). - // Cloud Run supports `ALPHA`, `BETA`, and `GA`. If no value is specified, GA - // is assumed. - // Set the launch stage to a preview stage on input to allow use of preview - // features in that stage. On read (or output), describes whether the resource - // uses preview features. - //

- // For example, if ALPHA is provided as input, but only BETA and GA-level - // features are used, this field will be BETA on output. - google.api.LaunchStage launch_stage = 14; - - // Settings for the Binary Authorization feature. - BinaryAuthorization binary_authorization = 15; - - // Required. The template used to create executions for this Job. - ExecutionTemplate template = 16 [(google.api.field_behavior) = REQUIRED]; - - // Output only. The generation of this Job. See comments in `reconciling` for - // additional information on reconciliation process in Cloud Run. - int64 observed_generation = 17 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The Condition of this Job, containing its readiness status, - // and detailed error information in case it did not reach the desired state. - Condition terminal_condition = 18 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The Conditions of all other associated sub-resources. They - // contain additional diagnostics information in case the Job does not reach - // its desired state. See comments in `reconciling` for additional information - // on reconciliation process in Cloud Run. - repeated Condition conditions = 19 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Number of executions created for this job. - int32 execution_count = 20 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Name of the last created execution. - ExecutionReference latest_created_execution = 22 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Returns true if the Job is currently being acted upon by the - // system to bring it into the desired state. - // - // When a new Job is created, or an existing one is updated, Cloud Run - // will asynchronously perform all necessary steps to bring the Job to the - // desired state. This process is called reconciliation. - // While reconciliation is in process, `observed_generation` and - // `latest_succeeded_execution`, will have transient values that might - // mismatch the intended state: Once reconciliation is over (and this field is - // false), there are two possible outcomes: reconciliation succeeded and the - // state matches the Job, or there was an error, and reconciliation failed. - // This state can be found in `terminal_condition.state`. - // - // If reconciliation succeeded, the following fields will match: - // `observed_generation` and `generation`, `latest_succeeded_execution` and - // `latest_created_execution`. - // - // If reconciliation failed, `observed_generation` and - // `latest_succeeded_execution` will have the state of the last succeeded - // execution or empty for newly created Job. Additional information on the - // failure can be found in `terminal_condition` and `conditions`. - bool reconciling = 23 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Reserved for future use. - bool satisfies_pzs = 25 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A system-generated fingerprint for this version of the - // resource. May be used to detect modification conflict during updates. - string etag = 99 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Reference to an Execution. Use /Executions.GetExecution with the given name -// to get full execution including the latest status. -message ExecutionReference { - // Name of the execution. - string name = 1 [ - (google.api.resource_reference) = { type: "run.googleapis.com/Execution" } - ]; - - // Creation timestamp of the execution. - google.protobuf.Timestamp create_time = 2; - - // Creation timestamp of the execution. - google.protobuf.Timestamp completion_time = 3; -} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/k8s.min.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/k8s.min.proto deleted file mode 100644 index 1d66551ac39..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/k8s.min.proto +++ /dev/null @@ -1,369 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.run.v2; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; - -option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; -option java_multiple_files = true; -option java_outer_classname = "K8sMinProto"; -option java_package = "com.google.cloud.run.v2"; -option (google.api.resource_definition) = { - type: "cloudkms.googleapis.com/CryptoKey" - pattern: "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}" -}; -option (google.api.resource_definition) = { - type: "secretmanager.googleapis.com/Secret" - pattern: "projects/{project}/secrets/{secret}" -}; -option (google.api.resource_definition) = { - type: "secretmanager.googleapis.com/SecretVersion" - pattern: "projects/{project}/secrets/{secret}/versions/{version}" -}; -option (google.api.resource_definition) = { - type: "vpcaccess.googleapis.com/Connector" - pattern: "projects/{project}/locations/{location}/connectors/{connector}" -}; - -// A single application container. -// This specifies both the container to run, the command to run in the container -// and the arguments to supply to it. -// Note that additional arguments may be supplied by the system to the container -// at runtime. -message Container { - // Name of the container specified as a DNS_LABEL (RFC 1123). - string name = 1; - - // Required. Name of the container image in Dockerhub, Google Artifact - // Registry, or Google Container Registry. If the host is not provided, - // Dockerhub is assumed. - string image = 2 [(google.api.field_behavior) = REQUIRED]; - - // Entrypoint array. Not executed within a shell. - // The docker image's ENTRYPOINT is used if this is not provided. - repeated string command = 3; - - // Arguments to the entrypoint. - // The docker image's CMD is used if this is not provided. - repeated string args = 4; - - // List of environment variables to set in the container. - repeated EnvVar env = 5; - - // Compute Resource requirements by this container. - ResourceRequirements resources = 6; - - // List of ports to expose from the container. Only a single port can be - // specified. The specified ports must be listening on all interfaces - // (0.0.0.0) within the container to be accessible. - // - // If omitted, a port number will be chosen and passed to the container - // through the PORT environment variable for the container to listen on. - repeated ContainerPort ports = 7; - - // Volume to mount into the container's filesystem. - repeated VolumeMount volume_mounts = 8; - - // Container's working directory. - // If not specified, the container runtime's default will be used, which - // might be configured in the container image. - string working_dir = 9; - - // Periodic probe of container liveness. - // Container will be restarted if the probe fails. - Probe liveness_probe = 10; - - // Startup probe of application within the container. - // All other probes are disabled if a startup probe is provided, until it - // succeeds. Container will not be added to service endpoints if the probe - // fails. - Probe startup_probe = 11; -} - -// ResourceRequirements describes the compute resource requirements. -message ResourceRequirements { - // Only ´memory´ and 'cpu' are supported. - // - //

Notes: - // * The only supported values for CPU are '1', '2', '4', and '8'. Setting 4 - // CPU requires at least 2Gi of memory. For more information, go to - // https://cloud.google.com/run/docs/configuring/cpu. - // * For supported 'memory' values and syntax, go to - // https://cloud.google.com/run/docs/configuring/memory-limits - map limits = 1; - - // Determines whether CPU should be throttled or not outside of requests. - bool cpu_idle = 2; - - // Determines whether CPU should be boosted on startup of a new container - // instance above the requested CPU threshold, this can help reduce cold-start - // latency. - bool startup_cpu_boost = 3; -} - -// EnvVar represents an environment variable present in a Container. -message EnvVar { - // Required. Name of the environment variable. Must be a C_IDENTIFIER, and - // mnay not exceed 32768 characters. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - oneof values { - // Variable references $(VAR_NAME) are expanded - // using the previous defined environment variables in the container and - // any route environment variables. If a variable cannot be resolved, - // the reference in the input string will be unchanged. The $(VAR_NAME) - // syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped - // references will never be expanded, regardless of whether the variable - // exists or not. - // Defaults to "", and the maximum length is 32768 bytes. - string value = 2; - - // Source for the environment variable's value. - EnvVarSource value_source = 3; - } -} - -// EnvVarSource represents a source for the value of an EnvVar. -message EnvVarSource { - // Selects a secret and a specific version from Cloud Secret Manager. - SecretKeySelector secret_key_ref = 1; -} - -// SecretEnvVarSource represents a source for the value of an EnvVar. -message SecretKeySelector { - // Required. The name of the secret in Cloud Secret Manager. - // Format: {secret_name} if the secret is in the same project. - // projects/{project}/secrets/{secret_name} if the secret is - // in a different project. - string secret = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "secretmanager.googleapis.com/Secret" - } - ]; - - // The Cloud Secret Manager secret version. - // Can be 'latest' for the latest version, an integer for a specific version, - // or a version alias. - string version = 2 [(google.api.resource_reference) = { - type: "secretmanager.googleapis.com/SecretVersion" - }]; -} - -// ContainerPort represents a network port in a single container. -message ContainerPort { - // If specified, used to specify which protocol to use. - // Allowed values are "http1" and "h2c". - string name = 1; - - // Port number the container listens on. - // This must be a valid TCP port number, 0 < container_port < 65536. - int32 container_port = 3; -} - -// VolumeMount describes a mounting of a Volume within a container. -message VolumeMount { - // Required. This must match the Name of a Volume. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Path within the container at which the volume should be mounted. - // Must not contain ':'. For Cloud SQL volumes, it can be left empty, or must - // otherwise be `/cloudsql`. All instances defined in the Volume will be - // available as `/cloudsql/[instance]`. For more information on Cloud SQL - // volumes, visit https://cloud.google.com/sql/docs/mysql/connect-run - string mount_path = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Volume represents a named volume in a container. -message Volume { - // Required. Volume's name. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - oneof volume_type { - // Secret represents a secret that should populate this volume. - SecretVolumeSource secret = 2; - - // For Cloud SQL volumes, contains the specific instances that should be - // mounted. Visit https://cloud.google.com/sql/docs/mysql/connect-run for - // more information on how to connect Cloud SQL and Cloud Run. - CloudSqlInstance cloud_sql_instance = 3; - } -} - -// The secret's value will be presented as the content of a file whose -// name is defined in the item path. If no items are defined, the name of -// the file is the secret. -message SecretVolumeSource { - // Required. The name of the secret in Cloud Secret Manager. - // Format: {secret} if the secret is in the same project. - // projects/{project}/secrets/{secret} if the secret is - // in a different project. - string secret = 1 [(google.api.field_behavior) = REQUIRED]; - - // If unspecified, the volume will expose a file whose name is the - // secret, relative to VolumeMount.mount_path. - // If specified, the key will be used as the version to fetch from Cloud - // Secret Manager and the path will be the name of the file exposed in the - // volume. When items are defined, they must specify a path and a version. - repeated VersionToPath items = 2; - - // Integer representation of mode bits to use on created files by default. - // Must be a value between 0000 and 0777 (octal), defaulting to 0444. - // Directories within the path are not affected by this setting. - // - // Notes - // - // * Internally, a umask of 0222 will be applied to any non-zero value. - // * This is an integer representation of the mode bits. So, the octal - // integer value should look exactly as the chmod numeric notation with a - // leading zero. Some examples: for chmod 777 (a=rwx), set to 0777 (octal) or - // 511 (base-10). For chmod 640 (u=rw,g=r), set to 0640 (octal) or - // 416 (base-10). For chmod 755 (u=rwx,g=rx,o=rx), set to 0755 (octal) or 493 - // (base-10). - // * This might be in conflict with other options that affect the - // file mode, like fsGroup, and the result can be other mode bits set. - // - // This might be in conflict with other options that affect the - // file mode, like fsGroup, and as a result, other mode bits could be set. - int32 default_mode = 3; -} - -// VersionToPath maps a specific version of a secret to a relative file to mount -// to, relative to VolumeMount's mount_path. -message VersionToPath { - // Required. The relative path of the secret in the container. - string path = 1 [(google.api.field_behavior) = REQUIRED]; - - // The Cloud Secret Manager secret version. - // Can be 'latest' for the latest value, or an integer or a secret alias for a - // specific version. - string version = 2; - - // Integer octal mode bits to use on this file, must be a value between - // 01 and 0777 (octal). If 0 or not set, the Volume's default mode will be - // used. - // - // Notes - // - // * Internally, a umask of 0222 will be applied to any non-zero value. - // * This is an integer representation of the mode bits. So, the octal - // integer value should look exactly as the chmod numeric notation with a - // leading zero. Some examples: for chmod 777 (a=rwx), set to 0777 (octal) or - // 511 (base-10). For chmod 640 (u=rw,g=r), set to 0640 (octal) or - // 416 (base-10). For chmod 755 (u=rwx,g=rx,o=rx), set to 0755 (octal) or 493 - // (base-10). - // * This might be in conflict with other options that affect the - // file mode, like fsGroup, and the result can be other mode bits set. - int32 mode = 3; -} - -// Represents a set of Cloud SQL instances. Each one will be available under -// /cloudsql/[instance]. Visit -// https://cloud.google.com/sql/docs/mysql/connect-run for more information on -// how to connect Cloud SQL and Cloud Run. -message CloudSqlInstance { - // The Cloud SQL instance connection names, as can be found in - // https://console.cloud.google.com/sql/instances. Visit - // https://cloud.google.com/sql/docs/mysql/connect-run for more information on - // how to connect Cloud SQL and Cloud Run. Format: - // {project}:{location}:{instance} - repeated string instances = 1; -} - -// Probe describes a health check to be performed against a container to -// determine whether it is alive or ready to receive traffic. -message Probe { - // Number of seconds after the container has started before the probe is - // initiated. - // Defaults to 0 seconds. Minimum value is 0. Maximum value for liveness probe - // is 3600. Maximum value for startup probe is 240. - int32 initial_delay_seconds = 1; - - // Number of seconds after which the probe times out. - // Defaults to 1 second. Minimum value is 1. Maximum value is 3600. - // Must be smaller than period_seconds. - int32 timeout_seconds = 2; - - // How often (in seconds) to perform the probe. - // Default to 10 seconds. Minimum value is 1. Maximum value for liveness probe - // is 3600. Maximum value for startup probe is 240. - // Must be greater or equal than timeout_seconds. - int32 period_seconds = 3; - - // Minimum consecutive failures for the probe to be considered failed after - // having succeeded. Defaults to 3. Minimum value is 1. - int32 failure_threshold = 4; - - oneof probe_type { - // HTTPGet specifies the http request to perform. - // Exactly one of httpGet, tcpSocket, or grpc must be specified. - HTTPGetAction http_get = 5; - - // TCPSocket specifies an action involving a TCP port. - // Exactly one of httpGet, tcpSocket, or grpc must be specified. - TCPSocketAction tcp_socket = 6; - - // GRPC specifies an action involving a gRPC port. - // Exactly one of httpGet, tcpSocket, or grpc must be specified. - GRPCAction grpc = 7; - } -} - -// HTTPGetAction describes an action based on HTTP Get requests. -message HTTPGetAction { - // Path to access on the HTTP server. Defaults to '/'. - string path = 1; - - // Custom headers to set in the request. HTTP allows repeated headers. - repeated HTTPHeader http_headers = 4; - - // Port number to access on the container. Must be in the range 1 to 65535. - // If not specified, defaults to the exposed port of the container, which is - // the value of container.ports[0].containerPort. - int32 port = 5; -} - -// HTTPHeader describes a custom header to be used in HTTP probes -message HTTPHeader { - // Required. The header field name - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // The header field value - string value = 2; -} - -// TCPSocketAction describes an action based on opening a socket -message TCPSocketAction { - // Port number to access on the container. Must be in the range 1 to 65535. - // If not specified, defaults to the exposed port of the container, which is - // the value of container.ports[0].containerPort. - int32 port = 1; -} - -// GRPCAction describes an action involving a GRPC port. -message GRPCAction { - // Port number of the gRPC service. Number must be in the range 1 to 65535. - // If not specified, defaults to the exposed port of the container, which is - // the value of container.ports[0].containerPort. - int32 port = 1; - - // Service is the name of the service to place in the gRPC HealthCheckRequest - // (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). If - // this is not specified, the default behavior is defined by gRPC. - string service = 2; -} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/revision.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/revision.proto deleted file mode 100644 index bdaf9e73992..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/revision.proto +++ /dev/null @@ -1,299 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.run.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/launch_stage.proto"; -import "google/api/resource.proto"; -import "google/api/routing.proto"; -import "google/cloud/run/v2/condition.proto"; -import "google/cloud/run/v2/k8s.min.proto"; -import "google/cloud/run/v2/vendor_settings.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; -option java_multiple_files = true; -option java_outer_classname = "RevisionProto"; -option java_package = "com.google.cloud.run.v2"; - -// Cloud Run Revision Control Plane API. -service Revisions { - option (google.api.default_host) = "run.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Gets information about a Revision. - rpc GetRevision(GetRevisionRequest) returns (Revision) { - option (google.api.http) = { - get: "/v2/{name=projects/*/locations/*/services/*/revisions/*}" - }; - option (google.api.routing) = { - routing_parameters { - field: "name" - path_template: "projects/*/locations/{location=*}/**" - } - }; - option (google.api.method_signature) = "name"; - } - - // Lists Revisions from a given Service, or from a given location. - rpc ListRevisions(ListRevisionsRequest) returns (ListRevisionsResponse) { - option (google.api.http) = { - get: "/v2/{parent=projects/*/locations/*/services/*}/revisions" - }; - option (google.api.routing) = { - routing_parameters { - field: "parent" - path_template: "projects/*/locations/{location=*}/**" - } - }; - option (google.api.method_signature) = "parent"; - } - - // Deletes a Revision. - rpc DeleteRevision(DeleteRevisionRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v2/{name=projects/*/locations/*/services/*/revisions/*}" - }; - option (google.api.routing) = { - routing_parameters { - field: "name" - path_template: "projects/*/locations/{location=*}/**" - } - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Revision" - metadata_type: "Revision" - }; - } -} - -// Request message for obtaining a Revision by its full name. -message GetRevisionRequest { - // Required. The full name of the Revision. - // Format: - // projects/{project}/locations/{location}/services/{service}/revisions/{revision} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "run.googleapis.com/Revision" } - ]; -} - -// Request message for retrieving a list of Revisions. -message ListRevisionsRequest { - // Required. The Service from which the Revisions should be listed. - // To list all Revisions across Services, use "-" instead of Service name. - // Format: - // projects/{project}/locations/{location}/services/{service} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "run.googleapis.com/Revision" - } - ]; - - // Maximum number of revisions to return in this call. - int32 page_size = 2; - - // A page token received from a previous call to ListRevisions. - // All other parameters must match. - string page_token = 3; - - // If true, returns deleted (but unexpired) resources along with active ones. - bool show_deleted = 4; -} - -// Response message containing a list of Revisions. -message ListRevisionsResponse { - // The resulting list of Revisions. - repeated Revision revisions = 1; - - // A token indicating there are more items than page_size. Use it in the next - // ListRevisions request to continue. - string next_page_token = 2; -} - -// Request message for deleting a retired Revision. -// Revision lifecycle is usually managed by making changes to the parent -// Service. Only retired revisions can be deleted with this API. -message DeleteRevisionRequest { - // Required. The name of the Revision to delete. - // Format: - // projects/{project}/locations/{location}/services/{service}/revisions/{revision} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "run.googleapis.com/Revision" } - ]; - - // Indicates that the request should be validated without actually - // deleting any resources. - bool validate_only = 2; - - // A system-generated fingerprint for this version of the - // resource. This may be used to detect modification conflict during updates. - string etag = 3; -} - -// A Revision is an immutable snapshot of code and configuration. A Revision -// references a container image. Revisions are only created by updates to its -// parent Service. -message Revision { - option (google.api.resource) = { - type: "run.googleapis.com/Revision" - pattern: "projects/{project}/locations/{location}/services/{service}/revisions/{revision}" - style: DECLARATIVE_FRIENDLY - }; - - // Output only. The unique name of this Revision. - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Server assigned unique identifier for the Revision. The value - // is a UUID4 string and guaranteed to remain unchanged until the resource is - // deleted. - string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A number that monotonically increases every time the user - // modifies the desired state. - int64 generation = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Unstructured key value map that can be used to organize and - // categorize objects. User-provided labels are shared with Google's billing - // system, so they can be used to filter, or break down billing charges by - // team, component, environment, state, etc. For more information, visit - // https://cloud.google.com/resource-manager/docs/creating-managing-labels or - // https://cloud.google.com/run/docs/configuring/labels. - map labels = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Unstructured key value map that may - // be set by external tools to store and arbitrary metadata. - // They are not queryable and should be preserved - // when modifying objects. - map annotations = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The creation time. - google.protobuf.Timestamp create_time = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The last-modified time. - google.protobuf.Timestamp update_time = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. For a deleted resource, the deletion time. It is only - // populated as a response to a Delete request. - google.protobuf.Timestamp delete_time = 8 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. For a deleted resource, the time after which it will be - // permamently deleted. It is only populated as a response to a Delete - // request. - google.protobuf.Timestamp expire_time = 9 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The least stable launch stage needed to create this resource, as defined by - // [Google Cloud Platform Launch - // Stages](https://cloud.google.com/terms/launch-stages). Cloud Run supports - // `ALPHA`, `BETA`, and `GA`. - //

Note that this value might not be what was used - // as input. For example, if ALPHA was provided as input in the parent - // resource, but only BETA and GA-level features are were, this field will be - // BETA. - google.api.LaunchStage launch_stage = 10; - - // Output only. The name of the parent service. - string service = 11 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.resource_reference) = { type: "run.googleapis.com/Service" } - ]; - - // Scaling settings for this revision. - RevisionScaling scaling = 12; - - // VPC Access configuration for this Revision. For more information, visit - // https://cloud.google.com/run/docs/configuring/connecting-vpc. - VpcAccess vpc_access = 13; - - // Sets the maximum number of requests that each serving instance can receive. - int32 max_instance_request_concurrency = 34; - - // Max allowed time for an instance to respond to a request. - google.protobuf.Duration timeout = 15; - - // Email address of the IAM service account associated with the revision of - // the service. The service account represents the identity of the running - // revision, and determines what permissions the revision has. - string service_account = 16; - - // Holds the single container that defines the unit of execution for this - // Revision. - repeated Container containers = 17; - - // A list of Volumes to make available to containers. - repeated Volume volumes = 18; - - // The execution environment being used to host this Revision. - ExecutionEnvironment execution_environment = 20; - - // A reference to a customer managed encryption key (CMEK) to use to encrypt - // this container image. For more information, go to - // https://cloud.google.com/run/docs/securing/using-cmek - string encryption_key = 21 [(google.api.resource_reference) = { - type: "cloudkms.googleapis.com/CryptoKey" - }]; - - // The action to take if the encryption key is revoked. - EncryptionKeyRevocationAction encryption_key_revocation_action = 23; - - // If encryption_key_revocation_action is SHUTDOWN, the duration before - // shutting down all instances. The minimum increment is 1 hour. - google.protobuf.Duration encryption_key_shutdown_duration = 24; - - // Output only. Indicates whether the resource's reconciliation is still in - // progress. See comments in `Service.reconciling` for additional information - // on reconciliation process in Cloud Run. - bool reconciling = 30 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The Condition of this Revision, containing its readiness - // status, and detailed error information in case it did not reach a serving - // state. - repeated Condition conditions = 31 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The generation of this Revision currently serving traffic. See - // comments in `reconciling` for additional information on reconciliation - // process in Cloud Run. - int64 observed_generation = 32 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The Google Console URI to obtain logs for the Revision. - string log_uri = 33 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Reserved for future use. - bool satisfies_pzs = 37 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Enable session affinity. - bool session_affinity = 38; - - // Output only. A system-generated fingerprint for this version of the - // resource. May be used to detect modification conflict during updates. - string etag = 99 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/revision_template.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/revision_template.proto deleted file mode 100644 index cc13e2d8509..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/revision_template.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.run.v2; - -import "google/api/resource.proto"; -import "google/cloud/run/v2/k8s.min.proto"; -import "google/cloud/run/v2/vendor_settings.proto"; -import "google/protobuf/duration.proto"; - -option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; -option java_multiple_files = true; -option java_outer_classname = "RevisionTemplateProto"; -option java_package = "com.google.cloud.run.v2"; - -// RevisionTemplate describes the data a revision should have when created from -// a template. -message RevisionTemplate { - // The unique name for the revision. If this field is omitted, it will be - // automatically generated based on the Service name. - string revision = 1 [ - (google.api.resource_reference) = { type: "run.googleapis.com/Revision" } - ]; - - // Unstructured key value map that can be used to organize and categorize - // objects. - // User-provided labels are shared with Google's billing system, so they can - // be used to filter, or break down billing charges by team, component, - // environment, state, etc. For more information, visit - // https://cloud.google.com/resource-manager/docs/creating-managing-labels or - // https://cloud.google.com/run/docs/configuring/labels. - // - //

Cloud Run API v2 does not support labels with `run.googleapis.com`, - // `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` - // namespaces, and they will be rejected. All system labels in v1 now have a - // corresponding field in v2 RevisionTemplate. - map labels = 2; - - // Unstructured key value map that may be set by external tools to store and - // arbitrary metadata. They are not queryable and should be preserved - // when modifying objects. - // - //

Cloud Run API v2 does not support annotations with `run.googleapis.com`, - // `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` - // namespaces, and they will be rejected. All system annotations in v1 now - // have a corresponding field in v2 RevisionTemplate. - // - //

This field follows Kubernetes annotations' namespacing, limits, and - // rules. - map annotations = 3; - - // Scaling settings for this Revision. - RevisionScaling scaling = 4; - - // VPC Access configuration to use for this Revision. For more information, - // visit https://cloud.google.com/run/docs/configuring/connecting-vpc. - VpcAccess vpc_access = 6; - - // Max allowed time for an instance to respond to a request. - google.protobuf.Duration timeout = 8; - - // Email address of the IAM service account associated with the revision of - // the service. The service account represents the identity of the running - // revision, and determines what permissions the revision has. If not - // provided, the revision will use the project's default service account. - string service_account = 9; - - // Holds the single container that defines the unit of execution for this - // Revision. - repeated Container containers = 10; - - // A list of Volumes to make available to containers. - repeated Volume volumes = 11; - - // The sandbox environment to host this Revision. - ExecutionEnvironment execution_environment = 13; - - // A reference to a customer managed encryption key (CMEK) to use to encrypt - // this container image. For more information, go to - // https://cloud.google.com/run/docs/securing/using-cmek - string encryption_key = 14 [(google.api.resource_reference) = { - type: "cloudkms.googleapis.com/CryptoKey" - }]; - - // Sets the maximum number of requests that each serving instance can receive. - int32 max_instance_request_concurrency = 15; - - // Enable session affinity. - bool session_affinity = 19; -} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/service.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/service.proto deleted file mode 100644 index 8ce51cb2beb..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/service.proto +++ /dev/null @@ -1,470 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.run.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/launch_stage.proto"; -import "google/api/resource.proto"; -import "google/api/routing.proto"; -import "google/cloud/run/v2/condition.proto"; -import "google/cloud/run/v2/revision_template.proto"; -import "google/cloud/run/v2/traffic_target.proto"; -import "google/cloud/run/v2/vendor_settings.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; -option java_multiple_files = true; -option java_outer_classname = "ServiceProto"; -option java_package = "com.google.cloud.run.v2"; - -// Cloud Run Service Control Plane API -service Services { - option (google.api.default_host) = "run.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a new Service in a given project and location. - rpc CreateService(CreateServiceRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{parent=projects/*/locations/*}/services" - body: "service" - }; - option (google.api.routing) = { - routing_parameters { - field: "parent" - path_template: "projects/*/locations/{location=*}" - } - }; - option (google.api.method_signature) = "parent,service,service_id"; - option (google.longrunning.operation_info) = { - response_type: "Service" - metadata_type: "Service" - }; - } - - // Gets information about a Service. - rpc GetService(GetServiceRequest) returns (Service) { - option (google.api.http) = { - get: "/v2/{name=projects/*/locations/*/services/*}" - }; - option (google.api.routing) = { - routing_parameters { - field: "name" - path_template: "projects/*/locations/{location=*}/**" - } - }; - option (google.api.method_signature) = "name"; - } - - // Lists Services. - rpc ListServices(ListServicesRequest) returns (ListServicesResponse) { - option (google.api.http) = { - get: "/v2/{parent=projects/*/locations/*}/services" - }; - option (google.api.routing) = { - routing_parameters { - field: "parent" - path_template: "projects/*/locations/{location=*}" - } - }; - option (google.api.method_signature) = "parent"; - } - - // Updates a Service. - rpc UpdateService(UpdateServiceRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v2/{service.name=projects/*/locations/*/services/*}" - body: "service" - }; - option (google.api.routing) = { - routing_parameters { - field: "service.name" - path_template: "projects/*/locations/{location=*}/**" - } - }; - option (google.api.method_signature) = "service"; - option (google.longrunning.operation_info) = { - response_type: "Service" - metadata_type: "Service" - }; - } - - // Deletes a Service. - // This will cause the Service to stop serving traffic and will delete all - // revisions. - rpc DeleteService(DeleteServiceRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v2/{name=projects/*/locations/*/services/*}" - }; - option (google.api.routing) = { - routing_parameters { - field: "name" - path_template: "projects/*/locations/{location=*}/**" - } - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Service" - metadata_type: "Service" - }; - } - - // Gets the IAM Access Control policy currently in effect for the given - // Cloud Run Service. This result does not include any inherited policies. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) - returns (google.iam.v1.Policy) { - option (google.api.http) = { - get: "/v2/{resource=projects/*/locations/*/services/*}:getIamPolicy" - }; - } - - // Sets the IAM Access control policy for the specified Service. Overwrites - // any existing policy. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) - returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v2/{resource=projects/*/locations/*/services/*}:setIamPolicy" - body: "*" - }; - } - - // Returns permissions that a caller has on the specified Project. - // - // There are no permissions required for making this API call. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) - returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v2/{resource=projects/*/locations/*/services/*}:testIamPermissions" - body: "*" - }; - } -} - -// Request message for creating a Service. -message CreateServiceRequest { - // Required. The location and project in which this service should be created. - // Format: projects/{project}/locations/{location}, where {project} can be - // project id or number. Only lowercase characters, digits, and hyphens. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "run.googleapis.com/Service" - } - ]; - - // Required. The Service instance to create. - Service service = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The unique identifier for the Service. It must begin with letter, - // and cannot end with hyphen; must contain fewer than 50 characters. - // The name of the service becomes {parent}/services/{service_id}. - string service_id = 3 [(google.api.field_behavior) = REQUIRED]; - - // Indicates that the request should be validated and default values - // populated, without persisting the request or creating any resources. - bool validate_only = 4; -} - -// Request message for updating a service. -message UpdateServiceRequest { - // Required. The Service to be updated. - Service service = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates that the request should be validated and default values - // populated, without persisting the request or updating any resources. - bool validate_only = 3; - - // If set to true, and if the Service does not exist, it will create a new - // one. The caller must have 'run.services.create' permissions if this is set - // to true and the Service does not exist. - bool allow_missing = 4; -} - -// Request message for retrieving a list of Services. -message ListServicesRequest { - // Required. The location and project to list resources on. - // Location must be a valid Google Cloud region, and cannot be the "-" - // wildcard. Format: projects/{project}/locations/{location}, where {project} - // can be project id or number. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "run.googleapis.com/Service" - } - ]; - - // Maximum number of Services to return in this call. - int32 page_size = 2; - - // A page token received from a previous call to ListServices. - // All other parameters must match. - string page_token = 3; - - // If true, returns deleted (but unexpired) resources along with active ones. - bool show_deleted = 4; -} - -// Response message containing a list of Services. -message ListServicesResponse { - // The resulting list of Services. - repeated Service services = 1; - - // A token indicating there are more items than page_size. Use it in the next - // ListServices request to continue. - string next_page_token = 2; -} - -// Request message for obtaining a Service by its full name. -message GetServiceRequest { - // Required. The full name of the Service. - // Format: projects/{project}/locations/{location}/services/{service}, where - // {project} can be project id or number. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "run.googleapis.com/Service" } - ]; -} - -// Request message to delete a Service by its full name. -message DeleteServiceRequest { - // Required. The full name of the Service. - // Format: projects/{project}/locations/{location}/services/{service}, where - // {project} can be project id or number. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "run.googleapis.com/Service" } - ]; - - // Indicates that the request should be validated without actually - // deleting any resources. - bool validate_only = 2; - - // A system-generated fingerprint for this version of the - // resource. May be used to detect modification conflict during updates. - string etag = 3; -} - -// Service acts as a top-level container that manages a set of -// configurations and revision templates which implement a network service. -// Service exists to provide a singular abstraction which can be access -// controlled, reasoned about, and which encapsulates software lifecycle -// decisions such as rollout policy and team resource ownership. -message Service { - option (google.api.resource) = { - type: "run.googleapis.com/Service" - pattern: "projects/{project}/locations/{location}/services/{service}" - style: DECLARATIVE_FRIENDLY - }; - - // The fully qualified name of this Service. In CreateServiceRequest, this - // field is ignored, and instead composed from CreateServiceRequest.parent and - // CreateServiceRequest.service_id. - // - // Format: - // projects/{project}/locations/{location}/services/{service_id} - string name = 1; - - // User-provided description of the Service. This field currently has a - // 512-character limit. - string description = 2; - - // Output only. Server assigned unique identifier for the trigger. The value - // is a UUID4 string and guaranteed to remain unchanged until the resource is - // deleted. - string uid = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A number that monotonically increases every time the user - // modifies the desired state. - // Please note that unlike v1, this is an int64 value. As with most Google - // APIs, its JSON representation will be a `string` instead of an `integer`. - int64 generation = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Unstructured key value map that can be used to organize and categorize - // objects. - // User-provided labels are shared with Google's billing system, so they can - // be used to filter, or break down billing charges by team, component, - // environment, state, etc. For more information, visit - // https://cloud.google.com/resource-manager/docs/creating-managing-labels or - // https://cloud.google.com/run/docs/configuring/labels. - // - //

Cloud Run API v2 does not support labels with `run.googleapis.com`, - // `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` - // namespaces, and they will be rejected. All system labels in v1 now have a - // corresponding field in v2 Service. - map labels = 5; - - // Unstructured key value map that may be set by external tools to store and - // arbitrary metadata. They are not queryable and should be preserved - // when modifying objects. - // - //

Cloud Run API v2 does not support annotations with `run.googleapis.com`, - // `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` - // namespaces, and they will be rejected in new resources. All system - // annotations in v1 now have a corresponding field in v2 Service. - // - //

This field follows Kubernetes - // annotations' namespacing, limits, and rules. - map annotations = 6; - - // Output only. The creation time. - google.protobuf.Timestamp create_time = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The last-modified time. - google.protobuf.Timestamp update_time = 8 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The deletion time. - google.protobuf.Timestamp delete_time = 9 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. For a deleted resource, the time after which it will be - // permamently deleted. - google.protobuf.Timestamp expire_time = 10 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Email address of the authenticated creator. - string creator = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Email address of the last authenticated modifier. - string last_modifier = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Arbitrary identifier for the API client. - string client = 13; - - // Arbitrary version identifier for the API client. - string client_version = 14; - - // Provides the ingress settings for this Service. On output, returns the - // currently observed ingress settings, or INGRESS_TRAFFIC_UNSPECIFIED if no - // revision is active. - IngressTraffic ingress = 15; - - // The launch stage as defined by [Google Cloud Platform - // Launch Stages](https://cloud.google.com/terms/launch-stages). - // Cloud Run supports `ALPHA`, `BETA`, and `GA`. If no value is specified, GA - // is assumed. - // Set the launch stage to a preview stage on input to allow use of preview - // features in that stage. On read (or output), describes whether the resource - // uses preview features. - //

- // For example, if ALPHA is provided as input, but only BETA and GA-level - // features are used, this field will be BETA on output. - google.api.LaunchStage launch_stage = 16; - - // Settings for the Binary Authorization feature. - BinaryAuthorization binary_authorization = 17; - - // Required. The template used to create revisions for this Service. - RevisionTemplate template = 18 [(google.api.field_behavior) = REQUIRED]; - - // Specifies how to distribute traffic over a collection of Revisions - // belonging to the Service. If traffic is empty or not provided, defaults to - // 100% traffic to the latest `Ready` Revision. - repeated TrafficTarget traffic = 19; - - // Output only. The generation of this Service currently serving traffic. See - // comments in `reconciling` for additional information on reconciliation - // process in Cloud Run. Please note that unlike v1, this is an int64 value. - // As with most Google APIs, its JSON representation will be a `string` - // instead of an `integer`. - int64 observed_generation = 30 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The Condition of this Service, containing its readiness - // status, and detailed error information in case it did not reach a serving - // state. See comments in `reconciling` for additional information on - // reconciliation process in Cloud Run. - Condition terminal_condition = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The Conditions of all other associated sub-resources. They - // contain additional diagnostics information in case the Service does not - // reach its Serving state. See comments in `reconciling` for additional - // information on reconciliation process in Cloud Run. - repeated Condition conditions = 32 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Name of the latest revision that is serving traffic. See - // comments in `reconciling` for additional information on reconciliation - // process in Cloud Run. - string latest_ready_revision = 33 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.resource_reference) = { type: "run.googleapis.com/Revision" } - ]; - - // Output only. Name of the last created revision. See comments in - // `reconciling` for additional information on reconciliation process in Cloud - // Run. - string latest_created_revision = 34 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.resource_reference) = { type: "run.googleapis.com/Revision" } - ]; - - // Output only. Detailed status information for corresponding traffic targets. - // See comments in `reconciling` for additional information on reconciliation - // process in Cloud Run. - repeated TrafficTargetStatus traffic_statuses = 35 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The main URI in which this Service is serving traffic. - string uri = 36 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // One or more custom audiences that you want this service to support. Specify - // each custom audience as the full URL in a string. The custom audiences are - // encoded in the token and used to authenticate requests. For more - // information, see - // https://cloud.google.com/run/docs/configuring/custom-audiences. - repeated string custom_audiences = 37; - - // Output only. Reserved for future use. - bool satisfies_pzs = 38 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Returns true if the Service is currently being acted upon by - // the system to bring it into the desired state. - // - // When a new Service is created, or an existing one is updated, Cloud Run - // will asynchronously perform all necessary steps to bring the Service to the - // desired serving state. This process is called reconciliation. - // While reconciliation is in process, `observed_generation`, - // `latest_ready_revison`, `traffic_statuses`, and `uri` will have transient - // values that might mismatch the intended state: Once reconciliation is over - // (and this field is false), there are two possible outcomes: reconciliation - // succeeded and the serving state matches the Service, or there was an error, - // and reconciliation failed. This state can be found in - // `terminal_condition.state`. - // - // If reconciliation succeeded, the following fields will match: `traffic` and - // `traffic_statuses`, `observed_generation` and `generation`, - // `latest_ready_revision` and `latest_created_revision`. - // - // If reconciliation failed, `traffic_statuses`, `observed_generation`, and - // `latest_ready_revision` will have the state of the last serving revision, - // or empty for newly created Services. Additional information on the failure - // can be found in `terminal_condition` and `conditions`. - bool reconciling = 98 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A system-generated fingerprint for this version of the - // resource. May be used to detect modification conflict during updates. - string etag = 99 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/task.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/task.proto deleted file mode 100644 index 7741c301617..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/task.proto +++ /dev/null @@ -1,267 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.run.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/run/v2/condition.proto"; -import "google/cloud/run/v2/k8s.min.proto"; -import "google/cloud/run/v2/vendor_settings.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; -option java_multiple_files = true; -option java_outer_classname = "TaskProto"; -option java_package = "com.google.cloud.run.v2"; - -// Cloud Run Task Control Plane API. -service Tasks { - option (google.api.default_host) = "run.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Gets information about a Task. - rpc GetTask(GetTaskRequest) returns (Task) { - option (google.api.http) = { - get: "/v2/{name=projects/*/locations/*/jobs/*/executions/*/tasks/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists Tasks from an Execution of a Job. - rpc ListTasks(ListTasksRequest) returns (ListTasksResponse) { - option (google.api.http) = { - get: "/v2/{parent=projects/*/locations/*/jobs/*/executions/*}/tasks" - }; - option (google.api.method_signature) = "parent"; - } -} - -// Request message for obtaining a Task by its full name. -message GetTaskRequest { - // Required. The full name of the Task. - // Format: - // projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "run.googleapis.com/Task" } - ]; -} - -// Request message for retrieving a list of Tasks. -message ListTasksRequest { - // Required. The Execution from which the Tasks should be listed. - // To list all Tasks across Executions of a Job, use "-" instead of Execution - // name. To list all Tasks across Jobs, use "-" instead of Job name. Format: - // projects/{project}/locations/{location}/jobs/{job}/executions/{execution} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { child_type: "run.googleapis.com/Task" } - ]; - - // Maximum number of Tasks to return in this call. - int32 page_size = 2; - - // A page token received from a previous call to ListTasks. - // All other parameters must match. - string page_token = 3; - - // If true, returns deleted (but unexpired) resources along with active ones. - bool show_deleted = 4; -} - -// Response message containing a list of Tasks. -message ListTasksResponse { - // The resulting list of Tasks. - repeated Task tasks = 1; - - // A token indicating there are more items than page_size. Use it in the next - // ListTasks request to continue. - string next_page_token = 2; -} - -// Task represents a single run of a container to completion. -message Task { - option (google.api.resource) = { - type: "run.googleapis.com/Task" - pattern: "projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task}" - style: DECLARATIVE_FRIENDLY - }; - - // Output only. The unique name of this Task. - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Server assigned unique identifier for the Task. The value is a - // UUID4 string and guaranteed to remain unchanged until the resource is - // deleted. - string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A number that monotonically increases every time the user - // modifies the desired state. - int64 generation = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Unstructured key value map that can be used to organize and - // categorize objects. User-provided labels are shared with Google's billing - // system, so they can be used to filter, or break down billing charges by - // team, component, environment, state, etc. For more information, visit - // https://cloud.google.com/resource-manager/docs/creating-managing-labels or - // https://cloud.google.com/run/docs/configuring/labels - map labels = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Unstructured key value map that may - // be set by external tools to store and arbitrary metadata. - // They are not queryable and should be preserved - // when modifying objects. - map annotations = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Represents time when the task was created by the job - // controller. It is not guaranteed to be set in happens-before order across - // separate operations. - google.protobuf.Timestamp create_time = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Represents time when the task started to run. - // It is not guaranteed to be set in happens-before order across separate - // operations. - google.protobuf.Timestamp start_time = 27 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Represents time when the Task was completed. It is not - // guaranteed to be set in happens-before order across separate operations. - google.protobuf.Timestamp completion_time = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The last-modified time. - google.protobuf.Timestamp update_time = 8 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. For a deleted resource, the deletion time. It is only - // populated as a response to a Delete request. - google.protobuf.Timestamp delete_time = 9 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. For a deleted resource, the time after which it will be - // permamently deleted. It is only populated as a response to a Delete - // request. - google.protobuf.Timestamp expire_time = 10 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The name of the parent Job. - string job = 12 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.resource_reference) = { type: "run.googleapis.com/Job" } - ]; - - // Output only. The name of the parent Execution. - string execution = 13 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.resource_reference) = { type: "run.googleapis.com/Execution" } - ]; - - // Holds the single container that defines the unit of execution for this - // task. - repeated Container containers = 14; - - // A list of Volumes to make available to containers. - repeated Volume volumes = 15; - - // Number of retries allowed per Task, before marking this Task failed. - int32 max_retries = 16; - - // Max allowed time duration the Task may be active before the system will - // actively try to mark it failed and kill associated containers. This applies - // per attempt of a task, meaning each retry can run for the full timeout. - google.protobuf.Duration timeout = 17; - - // Email address of the IAM service account associated with the Task of a - // Job. The service account represents the identity of the - // running task, and determines what permissions the task has. If - // not provided, the task will use the project's default service account. - string service_account = 18; - - // The execution environment being used to host this Task. - ExecutionEnvironment execution_environment = 20; - - // Output only. Indicates whether the resource's reconciliation is still in - // progress. See comments in `Job.reconciling` for additional information on - // reconciliation process in Cloud Run. - bool reconciling = 21 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The Condition of this Task, containing its readiness status, - // and detailed error information in case it did not reach the desired state. - repeated Condition conditions = 22 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The generation of this Task. See comments in `Job.reconciling` - // for additional information on reconciliation process in Cloud Run. - int64 observed_generation = 23 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Index of the Task, unique per execution, and beginning at 0. - int32 index = 24 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The number of times this Task was retried. - // Tasks are retried when they fail up to the maxRetries limit. - int32 retried = 25 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Result of the last attempt of this Task. - TaskAttemptResult last_attempt_result = 26 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A reference to a customer managed encryption key (CMEK) to use - // to encrypt this container image. For more information, go to - // https://cloud.google.com/run/docs/securing/using-cmek - string encryption_key = 28 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.resource_reference) = { - type: "cloudkms.googleapis.com/CryptoKey" - } - ]; - - // Output only. VPC Access configuration to use for this Task. For more - // information, visit - // https://cloud.google.com/run/docs/configuring/connecting-vpc. - VpcAccess vpc_access = 29 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. URI where logs for this execution can be found in Cloud - // Console. - string log_uri = 32 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Reserved for future use. - bool satisfies_pzs = 33 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A system-generated fingerprint for this version of the - // resource. May be used to detect modification conflict during updates. - string etag = 99 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Result of a task attempt. -message TaskAttemptResult { - // Output only. The status of this attempt. - // If the status code is OK, then the attempt succeeded. - google.rpc.Status status = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The exit code of this attempt. - // This may be unset if the container was unable to exit cleanly with a code - // due to some other failure. - // See status field for possible failure details. - int32 exit_code = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/task_template.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/task_template.proto deleted file mode 100644 index 586c4495627..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/task_template.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.run.v2; - -import "google/api/resource.proto"; -import "google/cloud/run/v2/k8s.min.proto"; -import "google/cloud/run/v2/vendor_settings.proto"; -import "google/protobuf/duration.proto"; - -option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; -option java_multiple_files = true; -option java_outer_classname = "TaskTemplateProto"; -option java_package = "com.google.cloud.run.v2"; - -// TaskTemplate describes the data a task should have when created -// from a template. -message TaskTemplate { - // Holds the single container that defines the unit of execution for this - // task. - repeated Container containers = 1; - - // A list of Volumes to make available to containers. - repeated Volume volumes = 2; - - oneof retries { - // Number of retries allowed per Task, before marking this Task failed. - // Defaults to 3. - int32 max_retries = 3; - } - - // Max allowed time duration the Task may be active before the system will - // actively try to mark it failed and kill associated containers. This applies - // per attempt of a task, meaning each retry can run for the full timeout. - // Defaults to 600 seconds. - google.protobuf.Duration timeout = 4; - - // Email address of the IAM service account associated with the Task of a - // Job. The service account represents the identity of the - // running task, and determines what permissions the task has. If - // not provided, the task will use the project's default service account. - string service_account = 5; - - // The execution environment being used to host this Task. - ExecutionEnvironment execution_environment = 6; - - // A reference to a customer managed encryption key (CMEK) to use to encrypt - // this container image. For more information, go to - // https://cloud.google.com/run/docs/securing/using-cmek - string encryption_key = 7 [(google.api.resource_reference) = { - type: "cloudkms.googleapis.com/CryptoKey" - }]; - - // VPC Access configuration to use for this Task. For more information, - // visit https://cloud.google.com/run/docs/configuring/connecting-vpc. - VpcAccess vpc_access = 8; -} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/traffic_target.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/traffic_target.proto deleted file mode 100644 index adc7f05e2e8..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/traffic_target.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.run.v2; - -import "google/api/resource.proto"; - -option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; -option java_multiple_files = true; -option java_outer_classname = "TrafficTargetProto"; -option java_package = "com.google.cloud.run.v2"; - -// Holds a single traffic routing entry for the Service. Allocations can be done -// to a specific Revision name, or pointing to the latest Ready Revision. -message TrafficTarget { - // The allocation type for this traffic target. - TrafficTargetAllocationType type = 1; - - // Revision to which to send this portion of traffic, if traffic allocation is - // by revision. - string revision = 2 [ - (google.api.resource_reference) = { type: "run.googleapis.com/Revision" } - ]; - - // Specifies percent of the traffic to this Revision. - // This defaults to zero if unspecified. - int32 percent = 3; - - // Indicates a string to be part of the URI to exclusively reference this - // target. - string tag = 4; -} - -// Represents the observed state of a single `TrafficTarget` entry. -message TrafficTargetStatus { - // The allocation type for this traffic target. - TrafficTargetAllocationType type = 1; - - // Revision to which this traffic is sent. - string revision = 2 [ - (google.api.resource_reference) = { type: "run.googleapis.com/Revision" } - ]; - - // Specifies percent of the traffic to this Revision. - int32 percent = 3; - - // Indicates the string used in the URI to exclusively reference this target. - string tag = 4; - - // Displays the target URI. - string uri = 5; -} - -// The type of instance allocation. -enum TrafficTargetAllocationType { - // Unspecified instance allocation type. - TRAFFIC_TARGET_ALLOCATION_TYPE_UNSPECIFIED = 0; - - // Allocates instances to the Service's latest ready Revision. - TRAFFIC_TARGET_ALLOCATION_TYPE_LATEST = 1; - - // Allocates instances to a Revision by name. - TRAFFIC_TARGET_ALLOCATION_TYPE_REVISION = 2; -} diff --git a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/vendor_settings.proto b/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/vendor_settings.proto deleted file mode 100644 index 389b6153229..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/protos/google/cloud/run/v2/vendor_settings.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.run.v2; - -import "google/api/resource.proto"; - -option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb"; -option java_multiple_files = true; -option java_outer_classname = "VendorSettingsProto"; -option java_package = "com.google.cloud.run.v2"; - -// VPC Access settings. For more information on creating a VPC Connector, visit -// https://cloud.google.com/vpc/docs/configure-serverless-vpc-access For -// information on how to configure Cloud Run with an existing VPC Connector, -// visit https://cloud.google.com/run/docs/configuring/connecting-vpc -message VpcAccess { - // Egress options for VPC access. - enum VpcEgress { - // Unspecified - VPC_EGRESS_UNSPECIFIED = 0; - - // All outbound traffic is routed through the VPC connector. - ALL_TRAFFIC = 1; - - // Only private IP ranges are routed through the VPC connector. - PRIVATE_RANGES_ONLY = 2; - } - - // VPC Access connector name. - // Format: projects/{project}/locations/{location}/connectors/{connector}, - // where {project} can be project id or number. - string connector = 1 [(google.api.resource_reference) = { - type: "vpcaccess.googleapis.com/Connector" - }]; - - // Traffic VPC egress settings. - VpcEgress egress = 2; -} - -// Settings for Binary Authorization feature. -message BinaryAuthorization { - oneof binauthz_method { - // If True, indicates to use the default project's binary authorization - // policy. If False, binary authorization will be disabled. - bool use_default = 1; - } - - // If present, indicates to use Breakglass using this justification. - // If use_default is False, then it must be empty. - // For more information on breakglass, see - // https://cloud.google.com/binary-authorization/docs/using-breakglass - string breakglass_justification = 2; -} - -// Settings for revision-level scaling settings. -message RevisionScaling { - // Minimum number of serving instances that this resource should have. - int32 min_instance_count = 1; - - // Maximum number of serving instances that this resource should have. - int32 max_instance_count = 2; -} - -// Allowed ingress traffic for the Container. -enum IngressTraffic { - // Unspecified - INGRESS_TRAFFIC_UNSPECIFIED = 0; - - // All inbound traffic is allowed. - INGRESS_TRAFFIC_ALL = 1; - - // Only internal traffic is allowed. - INGRESS_TRAFFIC_INTERNAL_ONLY = 2; - - // Both internal and Google Cloud Load Balancer traffic is allowed. - INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER = 3; -} - -// Alternatives for execution environments. -enum ExecutionEnvironment { - // Unspecified - EXECUTION_ENVIRONMENT_UNSPECIFIED = 0; - - // Uses the First Generation environment. - EXECUTION_ENVIRONMENT_GEN1 = 1; - - // Uses Second Generation environment. - EXECUTION_ENVIRONMENT_GEN2 = 2; -} - -// Specifies behavior if an encryption key used by a resource is revoked. -enum EncryptionKeyRevocationAction { - // Unspecified - ENCRYPTION_KEY_REVOCATION_ACTION_UNSPECIFIED = 0; - - // Prevents the creation of new instances. - PREVENT_NEW = 1; - - // Shuts down existing instances, and prevents creation of new ones. - SHUTDOWN = 2; -} diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.delete_execution.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.delete_execution.js deleted file mode 100644 index bec84488fcb..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.delete_execution.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(name) { - // [START run_v2_generated_Executions_DeleteExecution_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 Execution to delete. - * Format: - * projects/{project}/locations/{location}/jobs/{job}/executions/{execution}, - * where {project} can be project id or number. - */ - // const name = 'abc123' - /** - * Indicates that the request should be validated without actually - * deleting any resources. - */ - // const validateOnly = true - /** - * A system-generated fingerprint for this version of the resource. - * This may be used to detect modification conflict during updates. - */ - // const etag = 'abc123' - - // Imports the Run library - const {ExecutionsClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ExecutionsClient(); - - async function callDeleteExecution() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await runClient.deleteExecution(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteExecution(); - // [END run_v2_generated_Executions_DeleteExecution_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.get_execution.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.get_execution.js deleted file mode 100644 index 8233f4e8a19..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.get_execution.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 run_v2_generated_Executions_GetExecution_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The full name of the Execution. - * Format: - * projects/{project}/locations/{location}/jobs/{job}/executions/{execution}, - * where {project} can be project id or number. - */ - // const name = 'abc123' - - // Imports the Run library - const {ExecutionsClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ExecutionsClient(); - - async function callGetExecution() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await runClient.getExecution(request); - console.log(response); - } - - callGetExecution(); - // [END run_v2_generated_Executions_GetExecution_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.list_executions.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.list_executions.js deleted file mode 100644 index ebcc951cd10..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/executions.list_executions.js +++ /dev/null @@ -1,79 +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 run_v2_generated_Executions_ListExecutions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Execution from which the Executions should be listed. - * To list all Executions across Jobs, use "-" instead of Job name. - * Format: projects/{project}/locations/{location}/jobs/{job}, where {project} - * can be project id or number. - */ - // const parent = 'abc123' - /** - * Maximum number of Executions to return in this call. - */ - // const pageSize = 1234 - /** - * A page token received from a previous call to ListExecutions. - * All other parameters must match. - */ - // const pageToken = 'abc123' - /** - * If true, returns deleted (but unexpired) resources along with active ones. - */ - // const showDeleted = true - - // Imports the Run library - const {ExecutionsClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ExecutionsClient(); - - async function callListExecutions() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await runClient.listExecutionsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListExecutions(); - // [END run_v2_generated_Executions_ListExecutions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.create_job.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.create_job.js deleted file mode 100644 index 4f2f2152f1d..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.create_job.js +++ /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. ** - - - -'use strict'; - -function main(parent, job, jobId) { - // [START run_v2_generated_Jobs_CreateJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The location and project in which this Job should be created. - * Format: projects/{project}/locations/{location}, where {project} can be - * project id or number. - */ - // const parent = 'abc123' - /** - * Required. The Job instance to create. - */ - // const job = {} - /** - * Required. The unique identifier for the Job. The name of the job becomes - * {parent}/jobs/{job_id}. - */ - // const jobId = 'abc123' - /** - * Indicates that the request should be validated and default values - * populated, without persisting the request or creating any resources. - */ - // const validateOnly = true - - // Imports the Run library - const {JobsClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new JobsClient(); - - async function callCreateJob() { - // Construct request - const request = { - parent, - job, - jobId, - }; - - // Run request - const [operation] = await runClient.createJob(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateJob(); - // [END run_v2_generated_Jobs_CreateJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.delete_job.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.delete_job.js deleted file mode 100644 index 2ae230b7d92..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.delete_job.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(name) { - // [START run_v2_generated_Jobs_DeleteJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The full name of the Job. - * Format: projects/{project}/locations/{location}/jobs/{job}, where {project} - * can be project id or number. - */ - // const name = 'abc123' - /** - * Indicates that the request should be validated without actually - * deleting any resources. - */ - // const validateOnly = true - /** - * A system-generated fingerprint for this version of the - * resource. May be used to detect modification conflict during updates. - */ - // const etag = 'abc123' - - // Imports the Run library - const {JobsClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new JobsClient(); - - async function callDeleteJob() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await runClient.deleteJob(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteJob(); - // [END run_v2_generated_Jobs_DeleteJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.get_iam_policy.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.get_iam_policy.js deleted file mode 100644 index c7d7717d748..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.get_iam_policy.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(resource) { - // [START run_v2_generated_Jobs_GetIamPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - */ - // const options = {} - - // Imports the Run library - const {JobsClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new JobsClient(); - - async function callGetIamPolicy() { - // Construct request - const request = { - resource, - }; - - // Run request - const response = await runClient.getIamPolicy(request); - console.log(response); - } - - callGetIamPolicy(); - // [END run_v2_generated_Jobs_GetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.get_job.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.get_job.js deleted file mode 100644 index 5380023ba28..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.get_job.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 run_v2_generated_Jobs_GetJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The full name of the Job. - * Format: projects/{project}/locations/{location}/jobs/{job}, where {project} - * can be project id or number. - */ - // const name = 'abc123' - - // Imports the Run library - const {JobsClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new JobsClient(); - - async function callGetJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await runClient.getJob(request); - console.log(response); - } - - callGetJob(); - // [END run_v2_generated_Jobs_GetJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.list_jobs.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.list_jobs.js deleted file mode 100644 index 35e4852d866..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.list_jobs.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(parent) { - // [START run_v2_generated_Jobs_ListJobs_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The location and project to list resources on. - * Format: projects/{project}/locations/{location}, where {project} can be - * project id or number. - */ - // const parent = 'abc123' - /** - * Maximum number of Jobs to return in this call. - */ - // const pageSize = 1234 - /** - * A page token received from a previous call to ListJobs. - * All other parameters must match. - */ - // const pageToken = 'abc123' - /** - * If true, returns deleted (but unexpired) resources along with active ones. - */ - // const showDeleted = true - - // Imports the Run library - const {JobsClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new JobsClient(); - - async function callListJobs() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await runClient.listJobsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListJobs(); - // [END run_v2_generated_Jobs_ListJobs_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.run_job.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.run_job.js deleted file mode 100644 index 6bf942f7fe2..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.run_job.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(name) { - // [START run_v2_generated_Jobs_RunJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The full name of the Job. - * Format: projects/{project}/locations/{location}/jobs/{job}, where {project} - * can be project id or number. - */ - // const name = 'abc123' - /** - * Indicates that the request should be validated without actually - * deleting any resources. - */ - // const validateOnly = true - /** - * A system-generated fingerprint for this version of the - * resource. May be used to detect modification conflict during updates. - */ - // const etag = 'abc123' - - // Imports the Run library - const {JobsClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new JobsClient(); - - async function callRunJob() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await runClient.runJob(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRunJob(); - // [END run_v2_generated_Jobs_RunJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.set_iam_policy.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.set_iam_policy.js deleted file mode 100644 index d206bfa241e..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.set_iam_policy.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(resource, policy) { - // [START run_v2_generated_Jobs_SetIamPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - */ - // const policy = {} - /** - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * `paths: "bindings, etag"` - */ - // const updateMask = {} - - // Imports the Run library - const {JobsClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new JobsClient(); - - async function callSetIamPolicy() { - // Construct request - const request = { - resource, - policy, - }; - - // Run request - const response = await runClient.setIamPolicy(request); - console.log(response); - } - - callSetIamPolicy(); - // [END run_v2_generated_Jobs_SetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.test_iam_permissions.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.test_iam_permissions.js deleted file mode 100644 index 2f53892e97f..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.test_iam_permissions.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(resource, permissions) { - // [START run_v2_generated_Jobs_TestIamPermissions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). - */ - // const permissions = ['abc','def'] - - // Imports the Run library - const {JobsClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new JobsClient(); - - async function callTestIamPermissions() { - // Construct request - const request = { - resource, - permissions, - }; - - // Run request - const response = await runClient.testIamPermissions(request); - console.log(response); - } - - callTestIamPermissions(); - // [END run_v2_generated_Jobs_TestIamPermissions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.update_job.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.update_job.js deleted file mode 100644 index 15e4e80046a..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/jobs.update_job.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(job) { - // [START run_v2_generated_Jobs_UpdateJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Job to be updated. - */ - // const job = {} - /** - * Indicates that the request should be validated and default values - * populated, without persisting the request or updating any resources. - */ - // const validateOnly = true - /** - * If set to true, and if the Job does not exist, it will create a new - * one. Caller must have both create and update permissions for this call if - * this is set to true. - */ - // const allowMissing = true - - // Imports the Run library - const {JobsClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new JobsClient(); - - async function callUpdateJob() { - // Construct request - const request = { - job, - }; - - // Run request - const [operation] = await runClient.updateJob(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateJob(); - // [END run_v2_generated_Jobs_UpdateJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.delete_revision.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.delete_revision.js deleted file mode 100644 index 412c47f9d83..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.delete_revision.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(name) { - // [START run_v2_generated_Revisions_DeleteRevision_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 Revision to delete. - * Format: - * projects/{project}/locations/{location}/services/{service}/revisions/{revision} - */ - // const name = 'abc123' - /** - * Indicates that the request should be validated without actually - * deleting any resources. - */ - // const validateOnly = true - /** - * A system-generated fingerprint for this version of the - * resource. This may be used to detect modification conflict during updates. - */ - // const etag = 'abc123' - - // Imports the Run library - const {RevisionsClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new RevisionsClient(); - - async function callDeleteRevision() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await runClient.deleteRevision(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteRevision(); - // [END run_v2_generated_Revisions_DeleteRevision_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.get_revision.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.get_revision.js deleted file mode 100644 index e2dbac26d79..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.get_revision.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 run_v2_generated_Revisions_GetRevision_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The full name of the Revision. - * Format: - * projects/{project}/locations/{location}/services/{service}/revisions/{revision} - */ - // const name = 'abc123' - - // Imports the Run library - const {RevisionsClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new RevisionsClient(); - - async function callGetRevision() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await runClient.getRevision(request); - console.log(response); - } - - callGetRevision(); - // [END run_v2_generated_Revisions_GetRevision_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.list_revisions.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.list_revisions.js deleted file mode 100644 index feeb3de4e24..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/revisions.list_revisions.js +++ /dev/null @@ -1,79 +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 run_v2_generated_Revisions_ListRevisions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Service from which the Revisions should be listed. - * To list all Revisions across Services, use "-" instead of Service name. - * Format: - * projects/{project}/locations/{location}/services/{service} - */ - // const parent = 'abc123' - /** - * Maximum number of revisions to return in this call. - */ - // const pageSize = 1234 - /** - * A page token received from a previous call to ListRevisions. - * All other parameters must match. - */ - // const pageToken = 'abc123' - /** - * If true, returns deleted (but unexpired) resources along with active ones. - */ - // const showDeleted = true - - // Imports the Run library - const {RevisionsClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new RevisionsClient(); - - async function callListRevisions() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await runClient.listRevisionsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListRevisions(); - // [END run_v2_generated_Revisions_ListRevisions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.create_service.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.create_service.js deleted file mode 100644 index ac7f7db0fbd..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.create_service.js +++ /dev/null @@ -1,81 +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, service, serviceId) { - // [START run_v2_generated_Services_CreateService_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The location and project in which this service should be created. - * Format: projects/{project}/locations/{location}, where {project} can be - * project id or number. Only lowercase characters, digits, and hyphens. - */ - // const parent = 'abc123' - /** - * Required. The Service instance to create. - */ - // const service = {} - /** - * Required. The unique identifier for the Service. It must begin with letter, - * and cannot end with hyphen; must contain fewer than 50 characters. - * The name of the service becomes {parent}/services/{service_id}. - */ - // const serviceId = 'abc123' - /** - * Indicates that the request should be validated and default values - * populated, without persisting the request or creating any resources. - */ - // const validateOnly = true - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callCreateService() { - // Construct request - const request = { - parent, - service, - serviceId, - }; - - // Run request - const [operation] = await runClient.createService(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateService(); - // [END run_v2_generated_Services_CreateService_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.delete_service.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.delete_service.js deleted file mode 100644 index f3d8e315d2f..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.delete_service.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(name) { - // [START run_v2_generated_Services_DeleteService_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The full name of the Service. - * Format: projects/{project}/locations/{location}/services/{service}, where - * {project} can be project id or number. - */ - // const name = 'abc123' - /** - * Indicates that the request should be validated without actually - * deleting any resources. - */ - // const validateOnly = true - /** - * A system-generated fingerprint for this version of the - * resource. May be used to detect modification conflict during updates. - */ - // const etag = 'abc123' - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callDeleteService() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await runClient.deleteService(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteService(); - // [END run_v2_generated_Services_DeleteService_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.get_iam_policy.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.get_iam_policy.js deleted file mode 100644 index c1fda69132e..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.get_iam_policy.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(resource) { - // [START run_v2_generated_Services_GetIamPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - */ - // const options = {} - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callGetIamPolicy() { - // Construct request - const request = { - resource, - }; - - // Run request - const response = await runClient.getIamPolicy(request); - console.log(response); - } - - callGetIamPolicy(); - // [END run_v2_generated_Services_GetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.get_service.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.get_service.js deleted file mode 100644 index 4bca6947a81..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.get_service.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 run_v2_generated_Services_GetService_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The full name of the Service. - * Format: projects/{project}/locations/{location}/services/{service}, where - * {project} can be project id or number. - */ - // const name = 'abc123' - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callGetService() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await runClient.getService(request); - console.log(response); - } - - callGetService(); - // [END run_v2_generated_Services_GetService_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.list_services.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.list_services.js deleted file mode 100644 index 5212a84dfe7..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.list_services.js +++ /dev/null @@ -1,79 +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 run_v2_generated_Services_ListServices_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The location and project to list resources on. - * Location must be a valid Google Cloud region, and cannot be the "-" - * wildcard. Format: projects/{project}/locations/{location}, where {project} - * can be project id or number. - */ - // const parent = 'abc123' - /** - * Maximum number of Services to return in this call. - */ - // const pageSize = 1234 - /** - * A page token received from a previous call to ListServices. - * All other parameters must match. - */ - // const pageToken = 'abc123' - /** - * If true, returns deleted (but unexpired) resources along with active ones. - */ - // const showDeleted = true - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callListServices() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await runClient.listServicesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListServices(); - // [END run_v2_generated_Services_ListServices_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.set_iam_policy.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.set_iam_policy.js deleted file mode 100644 index c1c3105bd71..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.set_iam_policy.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(resource, policy) { - // [START run_v2_generated_Services_SetIamPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - */ - // const policy = {} - /** - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * `paths: "bindings, etag"` - */ - // const updateMask = {} - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callSetIamPolicy() { - // Construct request - const request = { - resource, - policy, - }; - - // Run request - const response = await runClient.setIamPolicy(request); - console.log(response); - } - - callSetIamPolicy(); - // [END run_v2_generated_Services_SetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.test_iam_permissions.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.test_iam_permissions.js deleted file mode 100644 index dd9186f09a1..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.test_iam_permissions.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(resource, permissions) { - // [START run_v2_generated_Services_TestIamPermissions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require 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 for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). - */ - // const permissions = ['abc','def'] - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callTestIamPermissions() { - // Construct request - const request = { - resource, - permissions, - }; - - // Run request - const response = await runClient.testIamPermissions(request); - console.log(response); - } - - callTestIamPermissions(); - // [END run_v2_generated_Services_TestIamPermissions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.update_service.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.update_service.js deleted file mode 100644 index e37f7604793..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/services.update_service.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(service) { - // [START run_v2_generated_Services_UpdateService_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Service to be updated. - */ - // const service = {} - /** - * Indicates that the request should be validated and default values - * populated, without persisting the request or updating any resources. - */ - // const validateOnly = true - /** - * If set to true, and if the Service does not exist, it will create a new - * one. The caller must have 'run.services.create' permissions if this is set - * to true and the Service does not exist. - */ - // const allowMissing = true - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callUpdateService() { - // Construct request - const request = { - service, - }; - - // Run request - const [operation] = await runClient.updateService(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateService(); - // [END run_v2_generated_Services_UpdateService_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/snippet_metadata_google.cloud.run.v2.json b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/snippet_metadata_google.cloud.run.v2.json deleted file mode 100644 index 7050ec71d11..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/snippet_metadata_google.cloud.run.v2.json +++ /dev/null @@ -1,1187 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-run", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.run.v2", - "version": "v2" - } - ] - }, - "snippets": [ - { - "regionTag": "run_v2_generated_Executions_GetExecution_async", - "title": "Executions getExecution Sample", - "origin": "API_DEFINITION", - "description": " Gets information about an Execution.", - "canonical": true, - "file": "executions.get_execution.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetExecution", - "fullName": "google.cloud.run.v2.Executions.GetExecution", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.run.v2.Execution", - "client": { - "shortName": "ExecutionsClient", - "fullName": "google.cloud.run.v2.ExecutionsClient" - }, - "method": { - "shortName": "GetExecution", - "fullName": "google.cloud.run.v2.Executions.GetExecution", - "service": { - "shortName": "Executions", - "fullName": "google.cloud.run.v2.Executions" - } - } - } - }, - { - "regionTag": "run_v2_generated_Executions_ListExecutions_async", - "title": "Executions listExecutions Sample", - "origin": "API_DEFINITION", - "description": " Lists Executions from a Job.", - "canonical": true, - "file": "executions.list_executions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListExecutions", - "fullName": "google.cloud.run.v2.Executions.ListExecutions", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "show_deleted", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.run.v2.ListExecutionsResponse", - "client": { - "shortName": "ExecutionsClient", - "fullName": "google.cloud.run.v2.ExecutionsClient" - }, - "method": { - "shortName": "ListExecutions", - "fullName": "google.cloud.run.v2.Executions.ListExecutions", - "service": { - "shortName": "Executions", - "fullName": "google.cloud.run.v2.Executions" - } - } - } - }, - { - "regionTag": "run_v2_generated_Executions_DeleteExecution_async", - "title": "Executions deleteExecution Sample", - "origin": "API_DEFINITION", - "description": " Deletes an Execution.", - "canonical": true, - "file": "executions.delete_execution.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteExecution", - "fullName": "google.cloud.run.v2.Executions.DeleteExecution", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "etag", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ExecutionsClient", - "fullName": "google.cloud.run.v2.ExecutionsClient" - }, - "method": { - "shortName": "DeleteExecution", - "fullName": "google.cloud.run.v2.Executions.DeleteExecution", - "service": { - "shortName": "Executions", - "fullName": "google.cloud.run.v2.Executions" - } - } - } - }, - { - "regionTag": "run_v2_generated_Jobs_CreateJob_async", - "title": "Executions createJob Sample", - "origin": "API_DEFINITION", - "description": " Creates a Job.", - "canonical": true, - "file": "jobs.create_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateJob", - "fullName": "google.cloud.run.v2.Jobs.CreateJob", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "job", - "type": ".google.cloud.run.v2.Job" - }, - { - "name": "job_id", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "JobsClient", - "fullName": "google.cloud.run.v2.JobsClient" - }, - "method": { - "shortName": "CreateJob", - "fullName": "google.cloud.run.v2.Jobs.CreateJob", - "service": { - "shortName": "Jobs", - "fullName": "google.cloud.run.v2.Jobs" - } - } - } - }, - { - "regionTag": "run_v2_generated_Jobs_GetJob_async", - "title": "Executions getJob Sample", - "origin": "API_DEFINITION", - "description": " Gets information about a Job.", - "canonical": true, - "file": "jobs.get_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetJob", - "fullName": "google.cloud.run.v2.Jobs.GetJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.run.v2.Job", - "client": { - "shortName": "JobsClient", - "fullName": "google.cloud.run.v2.JobsClient" - }, - "method": { - "shortName": "GetJob", - "fullName": "google.cloud.run.v2.Jobs.GetJob", - "service": { - "shortName": "Jobs", - "fullName": "google.cloud.run.v2.Jobs" - } - } - } - }, - { - "regionTag": "run_v2_generated_Jobs_ListJobs_async", - "title": "Executions listJobs Sample", - "origin": "API_DEFINITION", - "description": " Lists Jobs.", - "canonical": true, - "file": "jobs.list_jobs.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListJobs", - "fullName": "google.cloud.run.v2.Jobs.ListJobs", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "show_deleted", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.run.v2.ListJobsResponse", - "client": { - "shortName": "JobsClient", - "fullName": "google.cloud.run.v2.JobsClient" - }, - "method": { - "shortName": "ListJobs", - "fullName": "google.cloud.run.v2.Jobs.ListJobs", - "service": { - "shortName": "Jobs", - "fullName": "google.cloud.run.v2.Jobs" - } - } - } - }, - { - "regionTag": "run_v2_generated_Jobs_UpdateJob_async", - "title": "Executions updateJob Sample", - "origin": "API_DEFINITION", - "description": " Updates a Job.", - "canonical": true, - "file": "jobs.update_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateJob", - "fullName": "google.cloud.run.v2.Jobs.UpdateJob", - "async": true, - "parameters": [ - { - "name": "job", - "type": ".google.cloud.run.v2.Job" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "JobsClient", - "fullName": "google.cloud.run.v2.JobsClient" - }, - "method": { - "shortName": "UpdateJob", - "fullName": "google.cloud.run.v2.Jobs.UpdateJob", - "service": { - "shortName": "Jobs", - "fullName": "google.cloud.run.v2.Jobs" - } - } - } - }, - { - "regionTag": "run_v2_generated_Jobs_DeleteJob_async", - "title": "Executions deleteJob Sample", - "origin": "API_DEFINITION", - "description": " Deletes a Job.", - "canonical": true, - "file": "jobs.delete_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteJob", - "fullName": "google.cloud.run.v2.Jobs.DeleteJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "etag", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "JobsClient", - "fullName": "google.cloud.run.v2.JobsClient" - }, - "method": { - "shortName": "DeleteJob", - "fullName": "google.cloud.run.v2.Jobs.DeleteJob", - "service": { - "shortName": "Jobs", - "fullName": "google.cloud.run.v2.Jobs" - } - } - } - }, - { - "regionTag": "run_v2_generated_Jobs_RunJob_async", - "title": "Executions runJob Sample", - "origin": "API_DEFINITION", - "description": " Triggers creation of a new Execution of this Job.", - "canonical": true, - "file": "jobs.run_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RunJob", - "fullName": "google.cloud.run.v2.Jobs.RunJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "etag", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "JobsClient", - "fullName": "google.cloud.run.v2.JobsClient" - }, - "method": { - "shortName": "RunJob", - "fullName": "google.cloud.run.v2.Jobs.RunJob", - "service": { - "shortName": "Jobs", - "fullName": "google.cloud.run.v2.Jobs" - } - } - } - }, - { - "regionTag": "run_v2_generated_Jobs_GetIamPolicy_async", - "title": "Executions getIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Gets the IAM Access Control policy currently in effect for the given Job. This result does not include any inherited policies.", - "canonical": true, - "file": "jobs.get_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.run.v2.Jobs.GetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "options", - "type": ".google.iam.v1.GetPolicyOptions" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "JobsClient", - "fullName": "google.cloud.run.v2.JobsClient" - }, - "method": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.run.v2.Jobs.GetIamPolicy", - "service": { - "shortName": "Jobs", - "fullName": "google.cloud.run.v2.Jobs" - } - } - } - }, - { - "regionTag": "run_v2_generated_Jobs_SetIamPolicy_async", - "title": "Executions setIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Sets the IAM Access control policy for the specified Job. Overwrites any existing policy.", - "canonical": true, - "file": "jobs.set_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.run.v2.Jobs.SetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "policy", - "type": ".google.iam.v1.Policy" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "JobsClient", - "fullName": "google.cloud.run.v2.JobsClient" - }, - "method": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.run.v2.Jobs.SetIamPolicy", - "service": { - "shortName": "Jobs", - "fullName": "google.cloud.run.v2.Jobs" - } - } - } - }, - { - "regionTag": "run_v2_generated_Jobs_TestIamPermissions_async", - "title": "Executions testIamPermissions Sample", - "origin": "API_DEFINITION", - "description": " Returns permissions that a caller has on the specified Project. There are no permissions required for making this API call.", - "canonical": true, - "file": "jobs.test_iam_permissions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.run.v2.Jobs.TestIamPermissions", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "permissions", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.iam.v1.TestIamPermissionsResponse", - "client": { - "shortName": "JobsClient", - "fullName": "google.cloud.run.v2.JobsClient" - }, - "method": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.run.v2.Jobs.TestIamPermissions", - "service": { - "shortName": "Jobs", - "fullName": "google.cloud.run.v2.Jobs" - } - } - } - }, - { - "regionTag": "run_v2_generated_Revisions_GetRevision_async", - "title": "Executions getRevision Sample", - "origin": "API_DEFINITION", - "description": " Gets information about a Revision.", - "canonical": true, - "file": "revisions.get_revision.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetRevision", - "fullName": "google.cloud.run.v2.Revisions.GetRevision", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.run.v2.Revision", - "client": { - "shortName": "RevisionsClient", - "fullName": "google.cloud.run.v2.RevisionsClient" - }, - "method": { - "shortName": "GetRevision", - "fullName": "google.cloud.run.v2.Revisions.GetRevision", - "service": { - "shortName": "Revisions", - "fullName": "google.cloud.run.v2.Revisions" - } - } - } - }, - { - "regionTag": "run_v2_generated_Revisions_ListRevisions_async", - "title": "Executions listRevisions Sample", - "origin": "API_DEFINITION", - "description": " Lists Revisions from a given Service, or from a given location.", - "canonical": true, - "file": "revisions.list_revisions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListRevisions", - "fullName": "google.cloud.run.v2.Revisions.ListRevisions", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "show_deleted", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.run.v2.ListRevisionsResponse", - "client": { - "shortName": "RevisionsClient", - "fullName": "google.cloud.run.v2.RevisionsClient" - }, - "method": { - "shortName": "ListRevisions", - "fullName": "google.cloud.run.v2.Revisions.ListRevisions", - "service": { - "shortName": "Revisions", - "fullName": "google.cloud.run.v2.Revisions" - } - } - } - }, - { - "regionTag": "run_v2_generated_Revisions_DeleteRevision_async", - "title": "Executions deleteRevision Sample", - "origin": "API_DEFINITION", - "description": " Deletes a Revision.", - "canonical": true, - "file": "revisions.delete_revision.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteRevision", - "fullName": "google.cloud.run.v2.Revisions.DeleteRevision", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "etag", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "RevisionsClient", - "fullName": "google.cloud.run.v2.RevisionsClient" - }, - "method": { - "shortName": "DeleteRevision", - "fullName": "google.cloud.run.v2.Revisions.DeleteRevision", - "service": { - "shortName": "Revisions", - "fullName": "google.cloud.run.v2.Revisions" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_CreateService_async", - "title": "Executions createService Sample", - "origin": "API_DEFINITION", - "description": " Creates a new Service in a given project and location.", - "canonical": true, - "file": "services.create_service.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 73, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateService", - "fullName": "google.cloud.run.v2.Services.CreateService", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "service", - "type": ".google.cloud.run.v2.Service" - }, - { - "name": "service_id", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "CreateService", - "fullName": "google.cloud.run.v2.Services.CreateService", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_GetService_async", - "title": "Executions getService Sample", - "origin": "API_DEFINITION", - "description": " Gets information about a Service.", - "canonical": true, - "file": "services.get_service.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetService", - "fullName": "google.cloud.run.v2.Services.GetService", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.run.v2.Service", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "GetService", - "fullName": "google.cloud.run.v2.Services.GetService", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_ListServices_async", - "title": "Executions listServices Sample", - "origin": "API_DEFINITION", - "description": " Lists Services.", - "canonical": true, - "file": "services.list_services.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListServices", - "fullName": "google.cloud.run.v2.Services.ListServices", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "show_deleted", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.run.v2.ListServicesResponse", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "ListServices", - "fullName": "google.cloud.run.v2.Services.ListServices", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_UpdateService_async", - "title": "Executions updateService Sample", - "origin": "API_DEFINITION", - "description": " Updates a Service.", - "canonical": true, - "file": "services.update_service.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateService", - "fullName": "google.cloud.run.v2.Services.UpdateService", - "async": true, - "parameters": [ - { - "name": "service", - "type": ".google.cloud.run.v2.Service" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "UpdateService", - "fullName": "google.cloud.run.v2.Services.UpdateService", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_DeleteService_async", - "title": "Executions deleteService Sample", - "origin": "API_DEFINITION", - "description": " Deletes a Service. This will cause the Service to stop serving traffic and will delete all revisions.", - "canonical": true, - "file": "services.delete_service.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteService", - "fullName": "google.cloud.run.v2.Services.DeleteService", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "etag", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "DeleteService", - "fullName": "google.cloud.run.v2.Services.DeleteService", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_GetIamPolicy_async", - "title": "Executions getIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Gets the IAM Access Control policy currently in effect for the given Cloud Run Service. This result does not include any inherited policies.", - "canonical": true, - "file": "services.get_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.run.v2.Services.GetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "options", - "type": ".google.iam.v1.GetPolicyOptions" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.run.v2.Services.GetIamPolicy", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_SetIamPolicy_async", - "title": "Executions setIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Sets the IAM Access control policy for the specified Service. Overwrites any existing policy.", - "canonical": true, - "file": "services.set_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.run.v2.Services.SetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "policy", - "type": ".google.iam.v1.Policy" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.run.v2.Services.SetIamPolicy", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_TestIamPermissions_async", - "title": "Executions testIamPermissions Sample", - "origin": "API_DEFINITION", - "description": " Returns permissions that a caller has on the specified Project. There are no permissions required for making this API call.", - "canonical": true, - "file": "services.test_iam_permissions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.run.v2.Services.TestIamPermissions", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "permissions", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.iam.v1.TestIamPermissionsResponse", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.run.v2.Services.TestIamPermissions", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Tasks_GetTask_async", - "title": "Executions getTask Sample", - "origin": "API_DEFINITION", - "description": " Gets information about a Task.", - "canonical": true, - "file": "tasks.get_task.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetTask", - "fullName": "google.cloud.run.v2.Tasks.GetTask", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.run.v2.Task", - "client": { - "shortName": "TasksClient", - "fullName": "google.cloud.run.v2.TasksClient" - }, - "method": { - "shortName": "GetTask", - "fullName": "google.cloud.run.v2.Tasks.GetTask", - "service": { - "shortName": "Tasks", - "fullName": "google.cloud.run.v2.Tasks" - } - } - } - }, - { - "regionTag": "run_v2_generated_Tasks_ListTasks_async", - "title": "Executions listTasks Sample", - "origin": "API_DEFINITION", - "description": " Lists Tasks from an Execution of a Job.", - "canonical": true, - "file": "tasks.list_tasks.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListTasks", - "fullName": "google.cloud.run.v2.Tasks.ListTasks", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "show_deleted", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.run.v2.ListTasksResponse", - "client": { - "shortName": "TasksClient", - "fullName": "google.cloud.run.v2.TasksClient" - }, - "method": { - "shortName": "ListTasks", - "fullName": "google.cloud.run.v2.Tasks.ListTasks", - "service": { - "shortName": "Tasks", - "fullName": "google.cloud.run.v2.Tasks" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/tasks.get_task.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/tasks.get_task.js deleted file mode 100644 index 211137155b1..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/tasks.get_task.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 run_v2_generated_Tasks_GetTask_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The full name of the Task. - * Format: - * projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task} - */ - // const name = 'abc123' - - // Imports the Run library - const {TasksClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new TasksClient(); - - async function callGetTask() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await runClient.getTask(request); - console.log(response); - } - - callGetTask(); - // [END run_v2_generated_Tasks_GetTask_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/tasks.list_tasks.js b/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/tasks.list_tasks.js deleted file mode 100644 index 6bb2c337ecb..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/samples/generated/v2/tasks.list_tasks.js +++ /dev/null @@ -1,79 +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 run_v2_generated_Tasks_ListTasks_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Execution from which the Tasks should be listed. - * To list all Tasks across Executions of a Job, use "-" instead of Execution - * name. To list all Tasks across Jobs, use "-" instead of Job name. Format: - * projects/{project}/locations/{location}/jobs/{job}/executions/{execution} - */ - // const parent = 'abc123' - /** - * Maximum number of Tasks to return in this call. - */ - // const pageSize = 1234 - /** - * A page token received from a previous call to ListTasks. - * All other parameters must match. - */ - // const pageToken = 'abc123' - /** - * If true, returns deleted (but unexpired) resources along with active ones. - */ - // const showDeleted = true - - // Imports the Run library - const {TasksClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new TasksClient(); - - async function callListTasks() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await runClient.listTasksAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListTasks(); - // [END run_v2_generated_Tasks_ListTasks_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-run/v2/src/index.ts b/owl-bot-staging/google-cloud-run/v2/src/index.ts deleted file mode 100644 index 5c10c55052f..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/src/index.ts +++ /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. ** - -import * as v2 from './v2'; -const ExecutionsClient = v2.ExecutionsClient; -type ExecutionsClient = v2.ExecutionsClient; -const JobsClient = v2.JobsClient; -type JobsClient = v2.JobsClient; -const RevisionsClient = v2.RevisionsClient; -type RevisionsClient = v2.RevisionsClient; -const ServicesClient = v2.ServicesClient; -type ServicesClient = v2.ServicesClient; -const TasksClient = v2.TasksClient; -type TasksClient = v2.TasksClient; -export {v2, ExecutionsClient, JobsClient, RevisionsClient, ServicesClient, TasksClient}; -export default {v2, ExecutionsClient, JobsClient, RevisionsClient, ServicesClient, TasksClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/executions_client.ts b/owl-bot-staging/google-cloud-run/v2/src/v2/executions_client.ts deleted file mode 100644 index 191c4754a2f..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/src/v2/executions_client.ts +++ /dev/null @@ -1,1349 +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/executions_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './executions_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Cloud Run Execution Control Plane API. - * @class - * @memberof v2 - */ -export class ExecutionsClient { - 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; - executionsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ExecutionsClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 ExecutionsClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ExecutionsClient; - 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 { - 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 = { - executionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}' - ), - jobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - revisionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}/revisions/{revision}' - ), - servicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}' - ), - taskPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task}' - ), - }; - - // 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 = { - listExecutions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'executions') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',},{selector: 'google.longrunning.Operations.WaitOperation',post: '/v2/{name=projects/*/locations/*/operations/*}:wait',body: '*',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const deleteExecutionResponse = protoFilesRoot.lookup( - '.google.cloud.run.v2.Execution') as gax.protobuf.Type; - const deleteExecutionMetadata = protoFilesRoot.lookup( - '.google.cloud.run.v2.Execution') as gax.protobuf.Type; - - this.descriptors.longrunning = { - deleteExecution: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteExecutionResponse.decode.bind(deleteExecutionResponse), - deleteExecutionMetadata.decode.bind(deleteExecutionMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.run.v2.Executions', 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.executionsStub) { - return this.executionsStub; - } - - // Put together the "service stub" for - // google.cloud.run.v2.Executions. - this.executionsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.run.v2.Executions') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.run.v2.Executions, - 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 executionsStubMethods = - ['getExecution', 'listExecutions', 'deleteExecution']; - for (const methodName of executionsStubMethods) { - const callPromise = this.executionsStub.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.executionsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'run.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 'run.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 information about an Execution. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full name of the Execution. - * Format: - * projects/{project}/locations/{location}/jobs/{job}/executions/{execution}, - * where {project} can be project id or number. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.run.v2.Execution|Execution}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/executions.get_execution.js - * region_tag:run_v2_generated_Executions_GetExecution_async - */ - getExecution( - request?: protos.google.cloud.run.v2.IGetExecutionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.run.v2.IExecution, - protos.google.cloud.run.v2.IGetExecutionRequest|undefined, {}|undefined - ]>; - getExecution( - request: protos.google.cloud.run.v2.IGetExecutionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.run.v2.IExecution, - protos.google.cloud.run.v2.IGetExecutionRequest|null|undefined, - {}|null|undefined>): void; - getExecution( - request: protos.google.cloud.run.v2.IGetExecutionRequest, - callback: Callback< - protos.google.cloud.run.v2.IExecution, - protos.google.cloud.run.v2.IGetExecutionRequest|null|undefined, - {}|null|undefined>): void; - getExecution( - request?: protos.google.cloud.run.v2.IGetExecutionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.run.v2.IExecution, - protos.google.cloud.run.v2.IGetExecutionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.run.v2.IExecution, - protos.google.cloud.run.v2.IGetExecutionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.run.v2.IExecution, - protos.google.cloud.run.v2.IGetExecutionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getExecution(request, options, callback); - } - -/** - * Deletes an Execution. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Execution to delete. - * Format: - * projects/{project}/locations/{location}/jobs/{job}/executions/{execution}, - * where {project} can be project id or number. - * @param {boolean} request.validateOnly - * Indicates that the request should be validated without actually - * deleting any resources. - * @param {string} request.etag - * A system-generated fingerprint for this version of the resource. - * This may be used to detect modification conflict during updates. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/executions.delete_execution.js - * region_tag:run_v2_generated_Executions_DeleteExecution_async - */ - deleteExecution( - request?: protos.google.cloud.run.v2.IDeleteExecutionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteExecution( - request: protos.google.cloud.run.v2.IDeleteExecutionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteExecution( - request: protos.google.cloud.run.v2.IDeleteExecutionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteExecution( - request?: protos.google.cloud.run.v2.IDeleteExecutionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteExecution(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteExecution()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/executions.delete_execution.js - * region_tag:run_v2_generated_Executions_DeleteExecution_async - */ - async checkDeleteExecutionProgress(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.deleteExecution, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists Executions from a Job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The Execution from which the Executions should be listed. - * To list all Executions across Jobs, use "-" instead of Job name. - * Format: projects/{project}/locations/{location}/jobs/{job}, where {project} - * can be project id or number. - * @param {number} request.pageSize - * Maximum number of Executions to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListExecutions. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.run.v2.Execution|Execution}. - * 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 `listExecutionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listExecutions( - request?: protos.google.cloud.run.v2.IListExecutionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.run.v2.IExecution[], - protos.google.cloud.run.v2.IListExecutionsRequest|null, - protos.google.cloud.run.v2.IListExecutionsResponse - ]>; - listExecutions( - request: protos.google.cloud.run.v2.IListExecutionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.run.v2.IListExecutionsRequest, - protos.google.cloud.run.v2.IListExecutionsResponse|null|undefined, - protos.google.cloud.run.v2.IExecution>): void; - listExecutions( - request: protos.google.cloud.run.v2.IListExecutionsRequest, - callback: PaginationCallback< - protos.google.cloud.run.v2.IListExecutionsRequest, - protos.google.cloud.run.v2.IListExecutionsResponse|null|undefined, - protos.google.cloud.run.v2.IExecution>): void; - listExecutions( - request?: protos.google.cloud.run.v2.IListExecutionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.run.v2.IListExecutionsRequest, - protos.google.cloud.run.v2.IListExecutionsResponse|null|undefined, - protos.google.cloud.run.v2.IExecution>, - callback?: PaginationCallback< - protos.google.cloud.run.v2.IListExecutionsRequest, - protos.google.cloud.run.v2.IListExecutionsResponse|null|undefined, - protos.google.cloud.run.v2.IExecution>): - Promise<[ - protos.google.cloud.run.v2.IExecution[], - protos.google.cloud.run.v2.IListExecutionsRequest|null, - protos.google.cloud.run.v2.IListExecutionsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listExecutions(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 Execution from which the Executions should be listed. - * To list all Executions across Jobs, use "-" instead of Job name. - * Format: projects/{project}/locations/{location}/jobs/{job}, where {project} - * can be project id or number. - * @param {number} request.pageSize - * Maximum number of Executions to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListExecutions. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @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 protos.google.cloud.run.v2.Execution|Execution} 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 `listExecutionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listExecutionsStream( - request?: protos.google.cloud.run.v2.IListExecutionsRequest, - 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['listExecutions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listExecutions.createStream( - this.innerApiCalls.listExecutions as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listExecutions`, 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 Execution from which the Executions should be listed. - * To list all Executions across Jobs, use "-" instead of Job name. - * Format: projects/{project}/locations/{location}/jobs/{job}, where {project} - * can be project id or number. - * @param {number} request.pageSize - * Maximum number of Executions to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListExecutions. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.run.v2.Execution|Execution}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v2/executions.list_executions.js - * region_tag:run_v2_generated_Executions_ListExecutions_async - */ - listExecutionsAsync( - request?: protos.google.cloud.run.v2.IListExecutionsRequest, - 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['listExecutions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listExecutions.asyncIterate( - this.innerApiCalls['listExecutions'] 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 execution resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @param {string} execution - * @returns {string} Resource name string. - */ - executionPath(project:string,location:string,job:string,execution:string) { - return this.pathTemplates.executionPathTemplate.render({ - project: project, - location: location, - job: job, - execution: execution, - }); - } - - /** - * Parse the project from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the project. - */ - matchProjectFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).project; - } - - /** - * Parse the location from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the location. - */ - matchLocationFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).location; - } - - /** - * Parse the job from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the job. - */ - matchJobFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).job; - } - - /** - * Parse the execution from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the execution. - */ - matchExecutionFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).execution; - } - - /** - * Return a fully-qualified job resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @returns {string} Resource name string. - */ - jobPath(project:string,location:string,job:string) { - return this.pathTemplates.jobPathTemplate.render({ - project: project, - location: location, - job: job, - }); - } - - /** - * Parse the project from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the project. - */ - matchProjectFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).project; - } - - /** - * Parse the location from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the location. - */ - matchLocationFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).location; - } - - /** - * Parse the job from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the job. - */ - matchJobFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).job; - } - - /** - * 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 project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified revision resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} service - * @param {string} revision - * @returns {string} Resource name string. - */ - revisionPath(project:string,location:string,service:string,revision:string) { - return this.pathTemplates.revisionPathTemplate.render({ - project: project, - location: location, - service: service, - revision: revision, - }); - } - - /** - * Parse the project from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).project; - } - - /** - * Parse the location from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the location. - */ - matchLocationFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).location; - } - - /** - * Parse the service from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the service. - */ - matchServiceFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).service; - } - - /** - * Parse the revision from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the revision. - */ - matchRevisionFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).revision; - } - - /** - * Return a fully-qualified service resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} service - * @returns {string} Resource name string. - */ - servicePath(project:string,location:string,service:string) { - return this.pathTemplates.servicePathTemplate.render({ - project: project, - location: location, - service: service, - }); - } - - /** - * Parse the project from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).project; - } - - /** - * Parse the location from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).location; - } - - /** - * Parse the service from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).service; - } - - /** - * Return a fully-qualified task resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @param {string} execution - * @param {string} task - * @returns {string} Resource name string. - */ - taskPath(project:string,location:string,job:string,execution:string,task:string) { - return this.pathTemplates.taskPathTemplate.render({ - project: project, - location: location, - job: job, - execution: execution, - task: task, - }); - } - - /** - * Parse the project from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the project. - */ - matchProjectFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).project; - } - - /** - * Parse the location from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the location. - */ - matchLocationFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).location; - } - - /** - * Parse the job from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the job. - */ - matchJobFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).job; - } - - /** - * Parse the execution from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the execution. - */ - matchExecutionFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).execution; - } - - /** - * Parse the task from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the task. - */ - matchTaskFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).task; - } - - /** - * 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.executionsStub && !this._terminated) { - return this.executionsStub.then(stub => { - this._terminated = true; - stub.close(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/executions_client_config.json b/owl-bot-staging/google-cloud-run/v2/src/v2/executions_client_config.json deleted file mode 100644 index fadded8ee9a..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/src/v2/executions_client_config.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "interfaces": { - "google.cloud.run.v2.Executions": { - "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": { - "GetExecution": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListExecutions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteExecution": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/executions_proto_list.json b/owl-bot-staging/google-cloud-run/v2/src/v2/executions_proto_list.json deleted file mode 100644 index f6d18fdac6b..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/src/v2/executions_proto_list.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - "../../protos/google/cloud/run/v2/condition.proto", - "../../protos/google/cloud/run/v2/execution.proto", - "../../protos/google/cloud/run/v2/execution_template.proto", - "../../protos/google/cloud/run/v2/job.proto", - "../../protos/google/cloud/run/v2/k8s.min.proto", - "../../protos/google/cloud/run/v2/revision.proto", - "../../protos/google/cloud/run/v2/revision_template.proto", - "../../protos/google/cloud/run/v2/service.proto", - "../../protos/google/cloud/run/v2/task.proto", - "../../protos/google/cloud/run/v2/task_template.proto", - "../../protos/google/cloud/run/v2/traffic_target.proto", - "../../protos/google/cloud/run/v2/vendor_settings.proto" -] diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/gapic_metadata.json b/owl-bot-staging/google-cloud-run/v2/src/v2/gapic_metadata.json deleted file mode 100644 index cfa5d3b6414..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/src/v2/gapic_metadata.json +++ /dev/null @@ -1,349 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.run.v2", - "libraryPackage": "@google-cloud/run", - "services": { - "Executions": { - "clients": { - "grpc": { - "libraryClient": "ExecutionsClient", - "rpcs": { - "GetExecution": { - "methods": [ - "getExecution" - ] - }, - "DeleteExecution": { - "methods": [ - "deleteExecution" - ] - }, - "ListExecutions": { - "methods": [ - "listExecutions", - "listExecutionsStream", - "listExecutionsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ExecutionsClient", - "rpcs": { - "GetExecution": { - "methods": [ - "getExecution" - ] - }, - "DeleteExecution": { - "methods": [ - "deleteExecution" - ] - }, - "ListExecutions": { - "methods": [ - "listExecutions", - "listExecutionsStream", - "listExecutionsAsync" - ] - } - } - } - } - }, - "Jobs": { - "clients": { - "grpc": { - "libraryClient": "JobsClient", - "rpcs": { - "GetJob": { - "methods": [ - "getJob" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateJob": { - "methods": [ - "createJob" - ] - }, - "UpdateJob": { - "methods": [ - "updateJob" - ] - }, - "DeleteJob": { - "methods": [ - "deleteJob" - ] - }, - "RunJob": { - "methods": [ - "runJob" - ] - }, - "ListJobs": { - "methods": [ - "listJobs", - "listJobsStream", - "listJobsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "JobsClient", - "rpcs": { - "GetJob": { - "methods": [ - "getJob" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateJob": { - "methods": [ - "createJob" - ] - }, - "UpdateJob": { - "methods": [ - "updateJob" - ] - }, - "DeleteJob": { - "methods": [ - "deleteJob" - ] - }, - "RunJob": { - "methods": [ - "runJob" - ] - }, - "ListJobs": { - "methods": [ - "listJobs", - "listJobsStream", - "listJobsAsync" - ] - } - } - } - } - }, - "Revisions": { - "clients": { - "grpc": { - "libraryClient": "RevisionsClient", - "rpcs": { - "GetRevision": { - "methods": [ - "getRevision" - ] - }, - "DeleteRevision": { - "methods": [ - "deleteRevision" - ] - }, - "ListRevisions": { - "methods": [ - "listRevisions", - "listRevisionsStream", - "listRevisionsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "RevisionsClient", - "rpcs": { - "GetRevision": { - "methods": [ - "getRevision" - ] - }, - "DeleteRevision": { - "methods": [ - "deleteRevision" - ] - }, - "ListRevisions": { - "methods": [ - "listRevisions", - "listRevisionsStream", - "listRevisionsAsync" - ] - } - } - } - } - }, - "Services": { - "clients": { - "grpc": { - "libraryClient": "ServicesClient", - "rpcs": { - "GetService": { - "methods": [ - "getService" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateService": { - "methods": [ - "createService" - ] - }, - "UpdateService": { - "methods": [ - "updateService" - ] - }, - "DeleteService": { - "methods": [ - "deleteService" - ] - }, - "ListServices": { - "methods": [ - "listServices", - "listServicesStream", - "listServicesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ServicesClient", - "rpcs": { - "GetService": { - "methods": [ - "getService" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateService": { - "methods": [ - "createService" - ] - }, - "UpdateService": { - "methods": [ - "updateService" - ] - }, - "DeleteService": { - "methods": [ - "deleteService" - ] - }, - "ListServices": { - "methods": [ - "listServices", - "listServicesStream", - "listServicesAsync" - ] - } - } - } - } - }, - "Tasks": { - "clients": { - "grpc": { - "libraryClient": "TasksClient", - "rpcs": { - "GetTask": { - "methods": [ - "getTask" - ] - }, - "ListTasks": { - "methods": [ - "listTasks", - "listTasksStream", - "listTasksAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "TasksClient", - "rpcs": { - "GetTask": { - "methods": [ - "getTask" - ] - }, - "ListTasks": { - "methods": [ - "listTasks", - "listTasksStream", - "listTasksAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/index.ts b/owl-bot-staging/google-cloud-run/v2/src/v2/index.ts deleted file mode 100644 index 126c1e5f73f..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/src/v2/index.ts +++ /dev/null @@ -1,23 +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 {ExecutionsClient} from './executions_client'; -export {JobsClient} from './jobs_client'; -export {RevisionsClient} from './revisions_client'; -export {ServicesClient} from './services_client'; -export {TasksClient} from './tasks_client'; diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/jobs_client.ts b/owl-bot-staging/google-cloud-run/v2/src/v2/jobs_client.ts deleted file mode 100644 index 6d9ef6a7a79..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/src/v2/jobs_client.ts +++ /dev/null @@ -1,1896 +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/jobs_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './jobs_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Cloud Run Job Control Plane API. - * @class - * @memberof v2 - */ -export class JobsClient { - 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; - jobsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of JobsClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 JobsClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof JobsClient; - 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 { - 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 = { - executionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}' - ), - jobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - revisionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}/revisions/{revision}' - ), - servicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}' - ), - taskPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task}' - ), - }; - - // 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 = { - listJobs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'jobs') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',},{selector: 'google.longrunning.Operations.WaitOperation',post: '/v2/{name=projects/*/locations/*/operations/*}:wait',body: '*',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createJobResponse = protoFilesRoot.lookup( - '.google.cloud.run.v2.Job') as gax.protobuf.Type; - const createJobMetadata = protoFilesRoot.lookup( - '.google.cloud.run.v2.Job') as gax.protobuf.Type; - const updateJobResponse = protoFilesRoot.lookup( - '.google.cloud.run.v2.Job') as gax.protobuf.Type; - const updateJobMetadata = protoFilesRoot.lookup( - '.google.cloud.run.v2.Job') as gax.protobuf.Type; - const deleteJobResponse = protoFilesRoot.lookup( - '.google.cloud.run.v2.Job') as gax.protobuf.Type; - const deleteJobMetadata = protoFilesRoot.lookup( - '.google.cloud.run.v2.Job') as gax.protobuf.Type; - const runJobResponse = protoFilesRoot.lookup( - '.google.cloud.run.v2.Execution') as gax.protobuf.Type; - const runJobMetadata = protoFilesRoot.lookup( - '.google.cloud.run.v2.Execution') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createJob: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createJobResponse.decode.bind(createJobResponse), - createJobMetadata.decode.bind(createJobMetadata)), - updateJob: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateJobResponse.decode.bind(updateJobResponse), - updateJobMetadata.decode.bind(updateJobMetadata)), - deleteJob: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteJobResponse.decode.bind(deleteJobResponse), - deleteJobMetadata.decode.bind(deleteJobMetadata)), - runJob: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - runJobResponse.decode.bind(runJobResponse), - runJobMetadata.decode.bind(runJobMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.run.v2.Jobs', 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.jobsStub) { - return this.jobsStub; - } - - // Put together the "service stub" for - // google.cloud.run.v2.Jobs. - this.jobsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.run.v2.Jobs') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.run.v2.Jobs, - 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 jobsStubMethods = - ['createJob', 'getJob', 'listJobs', 'updateJob', 'deleteJob', 'runJob', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; - for (const methodName of jobsStubMethods) { - const callPromise = this.jobsStub.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.jobsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'run.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 'run.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 information about a Job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full name of the Job. - * Format: projects/{project}/locations/{location}/jobs/{job}, where {project} - * can be project id or number. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.run.v2.Job|Job}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/jobs.get_job.js - * region_tag:run_v2_generated_Jobs_GetJob_async - */ - getJob( - request?: protos.google.cloud.run.v2.IGetJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.run.v2.IJob, - protos.google.cloud.run.v2.IGetJobRequest|undefined, {}|undefined - ]>; - getJob( - request: protos.google.cloud.run.v2.IGetJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.run.v2.IJob, - protos.google.cloud.run.v2.IGetJobRequest|null|undefined, - {}|null|undefined>): void; - getJob( - request: protos.google.cloud.run.v2.IGetJobRequest, - callback: Callback< - protos.google.cloud.run.v2.IJob, - protos.google.cloud.run.v2.IGetJobRequest|null|undefined, - {}|null|undefined>): void; - getJob( - request?: protos.google.cloud.run.v2.IGetJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.run.v2.IJob, - protos.google.cloud.run.v2.IGetJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.run.v2.IJob, - protos.google.cloud.run.v2.IGetJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.run.v2.IJob, - protos.google.cloud.run.v2.IGetJobRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getJob(request, options, callback); - } -/** - * Gets the IAM Access Control policy currently in effect for the given Job. - * This result does not include any inherited policies. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/jobs.get_iam_policy.js - * region_tag:run_v2_generated_Jobs_GetIamPolicy_async - */ - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.getIamPolicy(request, options, callback); - } -/** - * Sets the IAM Access control policy for the specified Job. Overwrites - * any existing policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/jobs.set_iam_policy.js - * region_tag:run_v2_generated_Jobs_SetIamPolicy_async - */ - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.setIamPolicy(request, options, callback); - } -/** - * Returns permissions that a caller has on the specified Project. - * - * There are no permissions required for making this API call. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/jobs.test_iam_permissions.js - * region_tag:run_v2_generated_Jobs_TestIamPermissions_async - */ - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.testIamPermissions(request, options, callback); - } - -/** - * Creates a Job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location and project in which this Job should be created. - * Format: projects/{project}/locations/{location}, where {project} can be - * project id or number. - * @param {google.cloud.run.v2.Job} request.job - * Required. The Job instance to create. - * @param {string} request.jobId - * Required. The unique identifier for the Job. The name of the job becomes - * {parent}/jobs/{job_id}. - * @param {boolean} request.validateOnly - * Indicates that the request should be validated and default values - * populated, without persisting the request or creating any resources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/jobs.create_job.js - * region_tag:run_v2_generated_Jobs_CreateJob_async - */ - createJob( - request?: protos.google.cloud.run.v2.ICreateJobRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createJob( - request: protos.google.cloud.run.v2.ICreateJobRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createJob( - request: protos.google.cloud.run.v2.ICreateJobRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createJob( - request?: protos.google.cloud.run.v2.ICreateJobRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createJob(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createJob()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/jobs.create_job.js - * region_tag:run_v2_generated_Jobs_CreateJob_async - */ - async checkCreateJobProgress(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.createJob, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates a Job. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.run.v2.Job} request.job - * Required. The Job to be updated. - * @param {boolean} request.validateOnly - * Indicates that the request should be validated and default values - * populated, without persisting the request or updating any resources. - * @param {boolean} request.allowMissing - * If set to true, and if the Job does not exist, it will create a new - * one. Caller must have both create and update permissions for this call if - * this is set to true. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/jobs.update_job.js - * region_tag:run_v2_generated_Jobs_UpdateJob_async - */ - updateJob( - request?: protos.google.cloud.run.v2.IUpdateJobRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateJob( - request: protos.google.cloud.run.v2.IUpdateJobRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateJob( - request: protos.google.cloud.run.v2.IUpdateJobRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateJob( - request?: protos.google.cloud.run.v2.IUpdateJobRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'job.name': request.job!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateJob(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateJob()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/jobs.update_job.js - * region_tag:run_v2_generated_Jobs_UpdateJob_async - */ - async checkUpdateJobProgress(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.updateJob, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a Job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full name of the Job. - * Format: projects/{project}/locations/{location}/jobs/{job}, where {project} - * can be project id or number. - * @param {boolean} request.validateOnly - * Indicates that the request should be validated without actually - * deleting any resources. - * @param {string} request.etag - * A system-generated fingerprint for this version of the - * resource. May be used to detect modification conflict during updates. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/jobs.delete_job.js - * region_tag:run_v2_generated_Jobs_DeleteJob_async - */ - deleteJob( - request?: protos.google.cloud.run.v2.IDeleteJobRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteJob( - request: protos.google.cloud.run.v2.IDeleteJobRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteJob( - request: protos.google.cloud.run.v2.IDeleteJobRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteJob( - request?: protos.google.cloud.run.v2.IDeleteJobRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteJob(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteJob()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/jobs.delete_job.js - * region_tag:run_v2_generated_Jobs_DeleteJob_async - */ - async checkDeleteJobProgress(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.deleteJob, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Triggers creation of a new Execution of this Job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full name of the Job. - * Format: projects/{project}/locations/{location}/jobs/{job}, where {project} - * can be project id or number. - * @param {boolean} request.validateOnly - * Indicates that the request should be validated without actually - * deleting any resources. - * @param {string} request.etag - * A system-generated fingerprint for this version of the - * resource. May be used to detect modification conflict during updates. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/jobs.run_job.js - * region_tag:run_v2_generated_Jobs_RunJob_async - */ - runJob( - request?: protos.google.cloud.run.v2.IRunJobRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - runJob( - request: protos.google.cloud.run.v2.IRunJobRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - runJob( - request: protos.google.cloud.run.v2.IRunJobRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - runJob( - request?: protos.google.cloud.run.v2.IRunJobRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.runJob(request, options, callback); - } -/** - * Check the status of the long running operation returned by `runJob()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/jobs.run_job.js - * region_tag:run_v2_generated_Jobs_RunJob_async - */ - async checkRunJobProgress(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.runJob, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists Jobs. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location and project to list resources on. - * Format: projects/{project}/locations/{location}, where {project} can be - * project id or number. - * @param {number} request.pageSize - * Maximum number of Jobs to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListJobs. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.run.v2.Job|Job}. - * 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 `listJobsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listJobs( - request?: protos.google.cloud.run.v2.IListJobsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.run.v2.IJob[], - protos.google.cloud.run.v2.IListJobsRequest|null, - protos.google.cloud.run.v2.IListJobsResponse - ]>; - listJobs( - request: protos.google.cloud.run.v2.IListJobsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.run.v2.IListJobsRequest, - protos.google.cloud.run.v2.IListJobsResponse|null|undefined, - protos.google.cloud.run.v2.IJob>): void; - listJobs( - request: protos.google.cloud.run.v2.IListJobsRequest, - callback: PaginationCallback< - protos.google.cloud.run.v2.IListJobsRequest, - protos.google.cloud.run.v2.IListJobsResponse|null|undefined, - protos.google.cloud.run.v2.IJob>): void; - listJobs( - request?: protos.google.cloud.run.v2.IListJobsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.run.v2.IListJobsRequest, - protos.google.cloud.run.v2.IListJobsResponse|null|undefined, - protos.google.cloud.run.v2.IJob>, - callback?: PaginationCallback< - protos.google.cloud.run.v2.IListJobsRequest, - protos.google.cloud.run.v2.IListJobsResponse|null|undefined, - protos.google.cloud.run.v2.IJob>): - Promise<[ - protos.google.cloud.run.v2.IJob[], - protos.google.cloud.run.v2.IListJobsRequest|null, - protos.google.cloud.run.v2.IListJobsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listJobs(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location and project to list resources on. - * Format: projects/{project}/locations/{location}, where {project} can be - * project id or number. - * @param {number} request.pageSize - * Maximum number of Jobs to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListJobs. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @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 protos.google.cloud.run.v2.Job|Job} 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 `listJobsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listJobsStream( - request?: protos.google.cloud.run.v2.IListJobsRequest, - 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['listJobs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listJobs.createStream( - this.innerApiCalls.listJobs as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listJobs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location and project to list resources on. - * Format: projects/{project}/locations/{location}, where {project} can be - * project id or number. - * @param {number} request.pageSize - * Maximum number of Jobs to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListJobs. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.run.v2.Job|Job}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v2/jobs.list_jobs.js - * region_tag:run_v2_generated_Jobs_ListJobs_async - */ - listJobsAsync( - request?: protos.google.cloud.run.v2.IListJobsRequest, - 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['listJobs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listJobs.asyncIterate( - this.innerApiCalls['listJobs'] 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 execution resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @param {string} execution - * @returns {string} Resource name string. - */ - executionPath(project:string,location:string,job:string,execution:string) { - return this.pathTemplates.executionPathTemplate.render({ - project: project, - location: location, - job: job, - execution: execution, - }); - } - - /** - * Parse the project from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the project. - */ - matchProjectFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).project; - } - - /** - * Parse the location from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the location. - */ - matchLocationFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).location; - } - - /** - * Parse the job from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the job. - */ - matchJobFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).job; - } - - /** - * Parse the execution from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the execution. - */ - matchExecutionFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).execution; - } - - /** - * Return a fully-qualified job resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @returns {string} Resource name string. - */ - jobPath(project:string,location:string,job:string) { - return this.pathTemplates.jobPathTemplate.render({ - project: project, - location: location, - job: job, - }); - } - - /** - * Parse the project from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the project. - */ - matchProjectFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).project; - } - - /** - * Parse the location from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the location. - */ - matchLocationFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).location; - } - - /** - * Parse the job from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the job. - */ - matchJobFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).job; - } - - /** - * 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 project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified revision resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} service - * @param {string} revision - * @returns {string} Resource name string. - */ - revisionPath(project:string,location:string,service:string,revision:string) { - return this.pathTemplates.revisionPathTemplate.render({ - project: project, - location: location, - service: service, - revision: revision, - }); - } - - /** - * Parse the project from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).project; - } - - /** - * Parse the location from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the location. - */ - matchLocationFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).location; - } - - /** - * Parse the service from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the service. - */ - matchServiceFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).service; - } - - /** - * Parse the revision from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the revision. - */ - matchRevisionFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).revision; - } - - /** - * Return a fully-qualified service resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} service - * @returns {string} Resource name string. - */ - servicePath(project:string,location:string,service:string) { - return this.pathTemplates.servicePathTemplate.render({ - project: project, - location: location, - service: service, - }); - } - - /** - * Parse the project from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).project; - } - - /** - * Parse the location from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).location; - } - - /** - * Parse the service from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).service; - } - - /** - * Return a fully-qualified task resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @param {string} execution - * @param {string} task - * @returns {string} Resource name string. - */ - taskPath(project:string,location:string,job:string,execution:string,task:string) { - return this.pathTemplates.taskPathTemplate.render({ - project: project, - location: location, - job: job, - execution: execution, - task: task, - }); - } - - /** - * Parse the project from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the project. - */ - matchProjectFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).project; - } - - /** - * Parse the location from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the location. - */ - matchLocationFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).location; - } - - /** - * Parse the job from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the job. - */ - matchJobFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).job; - } - - /** - * Parse the execution from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the execution. - */ - matchExecutionFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).execution; - } - - /** - * Parse the task from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the task. - */ - matchTaskFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).task; - } - - /** - * 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.jobsStub && !this._terminated) { - return this.jobsStub.then(stub => { - this._terminated = true; - stub.close(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/jobs_client_config.json b/owl-bot-staging/google-cloud-run/v2/src/v2/jobs_client_config.json deleted file mode 100644 index 0751746db74..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/src/v2/jobs_client_config.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "interfaces": { - "google.cloud.run.v2.Jobs": { - "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": { - "CreateJob": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetJob": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListJobs": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateJob": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteJob": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RunJob": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetIamPolicy": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "SetIamPolicy": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "TestIamPermissions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/jobs_proto_list.json b/owl-bot-staging/google-cloud-run/v2/src/v2/jobs_proto_list.json deleted file mode 100644 index f6d18fdac6b..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/src/v2/jobs_proto_list.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - "../../protos/google/cloud/run/v2/condition.proto", - "../../protos/google/cloud/run/v2/execution.proto", - "../../protos/google/cloud/run/v2/execution_template.proto", - "../../protos/google/cloud/run/v2/job.proto", - "../../protos/google/cloud/run/v2/k8s.min.proto", - "../../protos/google/cloud/run/v2/revision.proto", - "../../protos/google/cloud/run/v2/revision_template.proto", - "../../protos/google/cloud/run/v2/service.proto", - "../../protos/google/cloud/run/v2/task.proto", - "../../protos/google/cloud/run/v2/task_template.proto", - "../../protos/google/cloud/run/v2/traffic_target.proto", - "../../protos/google/cloud/run/v2/vendor_settings.proto" -] diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/revisions_client.ts b/owl-bot-staging/google-cloud-run/v2/src/v2/revisions_client.ts deleted file mode 100644 index 2a059a40327..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/src/v2/revisions_client.ts +++ /dev/null @@ -1,1467 +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/revisions_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './revisions_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Cloud Run Revision Control Plane API. - * @class - * @memberof v2 - */ -export class RevisionsClient { - 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; - revisionsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of RevisionsClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 RevisionsClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof RevisionsClient; - 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 { - 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 = { - cryptoKeyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}' - ), - executionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}' - ), - jobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - revisionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}/revisions/{revision}' - ), - servicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}' - ), - taskPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task}' - ), - }; - - // 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 = { - listRevisions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'revisions') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',},{selector: 'google.longrunning.Operations.WaitOperation',post: '/v2/{name=projects/*/locations/*/operations/*}:wait',body: '*',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const deleteRevisionResponse = protoFilesRoot.lookup( - '.google.cloud.run.v2.Revision') as gax.protobuf.Type; - const deleteRevisionMetadata = protoFilesRoot.lookup( - '.google.cloud.run.v2.Revision') as gax.protobuf.Type; - - this.descriptors.longrunning = { - deleteRevision: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteRevisionResponse.decode.bind(deleteRevisionResponse), - deleteRevisionMetadata.decode.bind(deleteRevisionMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.run.v2.Revisions', 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.revisionsStub) { - return this.revisionsStub; - } - - // Put together the "service stub" for - // google.cloud.run.v2.Revisions. - this.revisionsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.run.v2.Revisions') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.run.v2.Revisions, - 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 revisionsStubMethods = - ['getRevision', 'listRevisions', 'deleteRevision']; - for (const methodName of revisionsStubMethods) { - const callPromise = this.revisionsStub.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.revisionsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'run.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 'run.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 information about a Revision. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full name of the Revision. - * Format: - * projects/{project}/locations/{location}/services/{service}/revisions/{revision} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.run.v2.Revision|Revision}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/revisions.get_revision.js - * region_tag:run_v2_generated_Revisions_GetRevision_async - */ - getRevision( - request?: protos.google.cloud.run.v2.IGetRevisionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.run.v2.IRevision, - protos.google.cloud.run.v2.IGetRevisionRequest|undefined, {}|undefined - ]>; - getRevision( - request: protos.google.cloud.run.v2.IGetRevisionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.run.v2.IRevision, - protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, - {}|null|undefined>): void; - getRevision( - request: protos.google.cloud.run.v2.IGetRevisionRequest, - callback: Callback< - protos.google.cloud.run.v2.IRevision, - protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, - {}|null|undefined>): void; - getRevision( - request?: protos.google.cloud.run.v2.IGetRevisionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.run.v2.IRevision, - protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.run.v2.IRevision, - protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.run.v2.IRevision, - protos.google.cloud.run.v2.IGetRevisionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - let routingParameter = {}; - { - const fieldValue = request.name; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.getRevision(request, options, callback); - } - -/** - * Deletes a Revision. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Revision to delete. - * Format: - * projects/{project}/locations/{location}/services/{service}/revisions/{revision} - * @param {boolean} request.validateOnly - * Indicates that the request should be validated without actually - * deleting any resources. - * @param {string} request.etag - * A system-generated fingerprint for this version of the - * resource. This may be used to detect modification conflict during updates. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/revisions.delete_revision.js - * region_tag:run_v2_generated_Revisions_DeleteRevision_async - */ - deleteRevision( - request?: protos.google.cloud.run.v2.IDeleteRevisionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteRevision( - request: protos.google.cloud.run.v2.IDeleteRevisionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteRevision( - request: protos.google.cloud.run.v2.IDeleteRevisionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteRevision( - request?: protos.google.cloud.run.v2.IDeleteRevisionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - let routingParameter = {}; - { - const fieldValue = request.name; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.deleteRevision(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteRevision()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/revisions.delete_revision.js - * region_tag:run_v2_generated_Revisions_DeleteRevision_async - */ - async checkDeleteRevisionProgress(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.deleteRevision, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists Revisions from a given Service, or from a given location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The Service from which the Revisions should be listed. - * To list all Revisions across Services, use "-" instead of Service name. - * Format: - * projects/{project}/locations/{location}/services/{service} - * @param {number} request.pageSize - * Maximum number of revisions to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListRevisions. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.run.v2.Revision|Revision}. - * 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 `listRevisionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listRevisions( - request?: protos.google.cloud.run.v2.IListRevisionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.run.v2.IRevision[], - protos.google.cloud.run.v2.IListRevisionsRequest|null, - protos.google.cloud.run.v2.IListRevisionsResponse - ]>; - listRevisions( - request: protos.google.cloud.run.v2.IListRevisionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.run.v2.IListRevisionsRequest, - protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, - protos.google.cloud.run.v2.IRevision>): void; - listRevisions( - request: protos.google.cloud.run.v2.IListRevisionsRequest, - callback: PaginationCallback< - protos.google.cloud.run.v2.IListRevisionsRequest, - protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, - protos.google.cloud.run.v2.IRevision>): void; - listRevisions( - request?: protos.google.cloud.run.v2.IListRevisionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.run.v2.IListRevisionsRequest, - protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, - protos.google.cloud.run.v2.IRevision>, - callback?: PaginationCallback< - protos.google.cloud.run.v2.IListRevisionsRequest, - protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, - protos.google.cloud.run.v2.IRevision>): - Promise<[ - protos.google.cloud.run.v2.IRevision[], - protos.google.cloud.run.v2.IListRevisionsRequest|null, - protos.google.cloud.run.v2.IListRevisionsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - let routingParameter = {}; - { - const fieldValue = request.parent; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.listRevisions(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 Service from which the Revisions should be listed. - * To list all Revisions across Services, use "-" instead of Service name. - * Format: - * projects/{project}/locations/{location}/services/{service} - * @param {number} request.pageSize - * Maximum number of revisions to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListRevisions. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @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 protos.google.cloud.run.v2.Revision|Revision} 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 `listRevisionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listRevisionsStream( - request?: protos.google.cloud.run.v2.IListRevisionsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - let routingParameter = {}; - { - const fieldValue = request.parent; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - const defaultCallSettings = this._defaults['listRevisions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRevisions.createStream( - this.innerApiCalls.listRevisions as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listRevisions`, 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 Service from which the Revisions should be listed. - * To list all Revisions across Services, use "-" instead of Service name. - * Format: - * projects/{project}/locations/{location}/services/{service} - * @param {number} request.pageSize - * Maximum number of revisions to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListRevisions. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.run.v2.Revision|Revision}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v2/revisions.list_revisions.js - * region_tag:run_v2_generated_Revisions_ListRevisions_async - */ - listRevisionsAsync( - request?: protos.google.cloud.run.v2.IListRevisionsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - let routingParameter = {}; - { - const fieldValue = request.parent; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - const defaultCallSettings = this._defaults['listRevisions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRevisions.asyncIterate( - this.innerApiCalls['listRevisions'] 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 cryptoKey resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} key_ring - * @param {string} crypto_key - * @returns {string} Resource name string. - */ - cryptoKeyPath(project:string,location:string,keyRing:string,cryptoKey:string) { - return this.pathTemplates.cryptoKeyPathTemplate.render({ - project: project, - location: location, - key_ring: keyRing, - crypto_key: cryptoKey, - }); - } - - /** - * Parse the project from CryptoKey resource. - * - * @param {string} cryptoKeyName - * A fully-qualified path representing CryptoKey resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).project; - } - - /** - * Parse the location from CryptoKey resource. - * - * @param {string} cryptoKeyName - * A fully-qualified path representing CryptoKey resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).location; - } - - /** - * Parse the key_ring from CryptoKey resource. - * - * @param {string} cryptoKeyName - * A fully-qualified path representing CryptoKey resource. - * @returns {string} A string representing the key_ring. - */ - matchKeyRingFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).key_ring; - } - - /** - * Parse the crypto_key from CryptoKey resource. - * - * @param {string} cryptoKeyName - * A fully-qualified path representing CryptoKey resource. - * @returns {string} A string representing the crypto_key. - */ - matchCryptoKeyFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).crypto_key; - } - - /** - * Return a fully-qualified execution resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @param {string} execution - * @returns {string} Resource name string. - */ - executionPath(project:string,location:string,job:string,execution:string) { - return this.pathTemplates.executionPathTemplate.render({ - project: project, - location: location, - job: job, - execution: execution, - }); - } - - /** - * Parse the project from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the project. - */ - matchProjectFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).project; - } - - /** - * Parse the location from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the location. - */ - matchLocationFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).location; - } - - /** - * Parse the job from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the job. - */ - matchJobFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).job; - } - - /** - * Parse the execution from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the execution. - */ - matchExecutionFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).execution; - } - - /** - * Return a fully-qualified job resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @returns {string} Resource name string. - */ - jobPath(project:string,location:string,job:string) { - return this.pathTemplates.jobPathTemplate.render({ - project: project, - location: location, - job: job, - }); - } - - /** - * Parse the project from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the project. - */ - matchProjectFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).project; - } - - /** - * Parse the location from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the location. - */ - matchLocationFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).location; - } - - /** - * Parse the job from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the job. - */ - matchJobFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).job; - } - - /** - * 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 project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified revision resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} service - * @param {string} revision - * @returns {string} Resource name string. - */ - revisionPath(project:string,location:string,service:string,revision:string) { - return this.pathTemplates.revisionPathTemplate.render({ - project: project, - location: location, - service: service, - revision: revision, - }); - } - - /** - * Parse the project from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).project; - } - - /** - * Parse the location from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the location. - */ - matchLocationFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).location; - } - - /** - * Parse the service from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the service. - */ - matchServiceFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).service; - } - - /** - * Parse the revision from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the revision. - */ - matchRevisionFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).revision; - } - - /** - * Return a fully-qualified service resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} service - * @returns {string} Resource name string. - */ - servicePath(project:string,location:string,service:string) { - return this.pathTemplates.servicePathTemplate.render({ - project: project, - location: location, - service: service, - }); - } - - /** - * Parse the project from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).project; - } - - /** - * Parse the location from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).location; - } - - /** - * Parse the service from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).service; - } - - /** - * Return a fully-qualified task resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @param {string} execution - * @param {string} task - * @returns {string} Resource name string. - */ - taskPath(project:string,location:string,job:string,execution:string,task:string) { - return this.pathTemplates.taskPathTemplate.render({ - project: project, - location: location, - job: job, - execution: execution, - task: task, - }); - } - - /** - * Parse the project from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the project. - */ - matchProjectFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).project; - } - - /** - * Parse the location from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the location. - */ - matchLocationFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).location; - } - - /** - * Parse the job from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the job. - */ - matchJobFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).job; - } - - /** - * Parse the execution from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the execution. - */ - matchExecutionFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).execution; - } - - /** - * Parse the task from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the task. - */ - matchTaskFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).task; - } - - /** - * 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.revisionsStub && !this._terminated) { - return this.revisionsStub.then(stub => { - this._terminated = true; - stub.close(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/revisions_client_config.json b/owl-bot-staging/google-cloud-run/v2/src/v2/revisions_client_config.json deleted file mode 100644 index f5a18a2ed2b..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/src/v2/revisions_client_config.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "interfaces": { - "google.cloud.run.v2.Revisions": { - "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": { - "GetRevision": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListRevisions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteRevision": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/revisions_proto_list.json b/owl-bot-staging/google-cloud-run/v2/src/v2/revisions_proto_list.json deleted file mode 100644 index f6d18fdac6b..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/src/v2/revisions_proto_list.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - "../../protos/google/cloud/run/v2/condition.proto", - "../../protos/google/cloud/run/v2/execution.proto", - "../../protos/google/cloud/run/v2/execution_template.proto", - "../../protos/google/cloud/run/v2/job.proto", - "../../protos/google/cloud/run/v2/k8s.min.proto", - "../../protos/google/cloud/run/v2/revision.proto", - "../../protos/google/cloud/run/v2/revision_template.proto", - "../../protos/google/cloud/run/v2/service.proto", - "../../protos/google/cloud/run/v2/task.proto", - "../../protos/google/cloud/run/v2/task_template.proto", - "../../protos/google/cloud/run/v2/traffic_target.proto", - "../../protos/google/cloud/run/v2/vendor_settings.proto" -] diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/services_client.ts b/owl-bot-staging/google-cloud-run/v2/src/v2/services_client.ts deleted file mode 100644 index 7f30cc23110..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/src/v2/services_client.ts +++ /dev/null @@ -1,1874 +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/services_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './services_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Cloud Run Service Control Plane API - * @class - * @memberof v2 - */ -export class ServicesClient { - 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; - servicesStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ServicesClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 ServicesClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ServicesClient; - 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 { - 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 = { - executionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}' - ), - jobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - revisionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}/revisions/{revision}' - ), - servicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}' - ), - taskPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task}' - ), - }; - - // 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 = { - listServices: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'services') - }; - - 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) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',},{selector: 'google.longrunning.Operations.WaitOperation',post: '/v2/{name=projects/*/locations/*/operations/*}:wait',body: '*',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createServiceResponse = protoFilesRoot.lookup( - '.google.cloud.run.v2.Service') as gax.protobuf.Type; - const createServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.run.v2.Service') as gax.protobuf.Type; - const updateServiceResponse = protoFilesRoot.lookup( - '.google.cloud.run.v2.Service') as gax.protobuf.Type; - const updateServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.run.v2.Service') as gax.protobuf.Type; - const deleteServiceResponse = protoFilesRoot.lookup( - '.google.cloud.run.v2.Service') as gax.protobuf.Type; - const deleteServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.run.v2.Service') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createService: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createServiceResponse.decode.bind(createServiceResponse), - createServiceMetadata.decode.bind(createServiceMetadata)), - updateService: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateServiceResponse.decode.bind(updateServiceResponse), - updateServiceMetadata.decode.bind(updateServiceMetadata)), - deleteService: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteServiceResponse.decode.bind(deleteServiceResponse), - deleteServiceMetadata.decode.bind(deleteServiceMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.run.v2.Services', 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.servicesStub) { - return this.servicesStub; - } - - // Put together the "service stub" for - // google.cloud.run.v2.Services. - this.servicesStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.run.v2.Services') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.run.v2.Services, - 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 servicesStubMethods = - ['createService', 'getService', 'listServices', 'updateService', 'deleteService', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; - for (const methodName of servicesStubMethods) { - const callPromise = this.servicesStub.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.servicesStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'run.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 'run.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 information about a Service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full name of the Service. - * Format: projects/{project}/locations/{location}/services/{service}, where - * {project} can be project id or number. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.run.v2.Service|Service}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/services.get_service.js - * region_tag:run_v2_generated_Services_GetService_async - */ - getService( - request?: protos.google.cloud.run.v2.IGetServiceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.run.v2.IService, - protos.google.cloud.run.v2.IGetServiceRequest|undefined, {}|undefined - ]>; - getService( - request: protos.google.cloud.run.v2.IGetServiceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.run.v2.IService, - protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, - {}|null|undefined>): void; - getService( - request: protos.google.cloud.run.v2.IGetServiceRequest, - callback: Callback< - protos.google.cloud.run.v2.IService, - protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, - {}|null|undefined>): void; - getService( - request?: protos.google.cloud.run.v2.IGetServiceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.run.v2.IService, - protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.run.v2.IService, - protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.run.v2.IService, - protos.google.cloud.run.v2.IGetServiceRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - let routingParameter = {}; - { - const fieldValue = request.name; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.getService(request, options, callback); - } -/** - * Gets the IAM Access Control policy currently in effect for the given - * Cloud Run Service. This result does not include any inherited policies. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/services.get_iam_policy.js - * region_tag:run_v2_generated_Services_GetIamPolicy_async - */ - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.getIamPolicy(request, options, callback); - } -/** - * Sets the IAM Access control policy for the specified Service. Overwrites - * any existing policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/services.set_iam_policy.js - * region_tag:run_v2_generated_Services_SetIamPolicy_async - */ - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.setIamPolicy(request, options, callback); - } -/** - * Returns permissions that a caller has on the specified Project. - * - * There are no permissions required for making this API call. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/services.test_iam_permissions.js - * region_tag:run_v2_generated_Services_TestIamPermissions_async - */ - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.testIamPermissions(request, options, callback); - } - -/** - * Creates a new Service in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location and project in which this service should be created. - * Format: projects/{project}/locations/{location}, where {project} can be - * project id or number. Only lowercase characters, digits, and hyphens. - * @param {google.cloud.run.v2.Service} request.service - * Required. The Service instance to create. - * @param {string} request.serviceId - * Required. The unique identifier for the Service. It must begin with letter, - * and cannot end with hyphen; must contain fewer than 50 characters. - * The name of the service becomes {parent}/services/{service_id}. - * @param {boolean} request.validateOnly - * Indicates that the request should be validated and default values - * populated, without persisting the request or creating any resources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/services.create_service.js - * region_tag:run_v2_generated_Services_CreateService_async - */ - createService( - request?: protos.google.cloud.run.v2.ICreateServiceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createService( - request: protos.google.cloud.run.v2.ICreateServiceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createService( - request: protos.google.cloud.run.v2.ICreateServiceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createService( - request?: protos.google.cloud.run.v2.ICreateServiceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - let routingParameter = {}; - { - const fieldValue = request.parent; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.createService(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createService()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/services.create_service.js - * region_tag:run_v2_generated_Services_CreateService_async - */ - async checkCreateServiceProgress(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.createService, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates a Service. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.run.v2.Service} request.service - * Required. The Service to be updated. - * @param {boolean} request.validateOnly - * Indicates that the request should be validated and default values - * populated, without persisting the request or updating any resources. - * @param {boolean} request.allowMissing - * If set to true, and if the Service does not exist, it will create a new - * one. The caller must have 'run.services.create' permissions if this is set - * to true and the Service does not exist. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/services.update_service.js - * region_tag:run_v2_generated_Services_UpdateService_async - */ - updateService( - request?: protos.google.cloud.run.v2.IUpdateServiceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateService( - request: protos.google.cloud.run.v2.IUpdateServiceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateService( - request: protos.google.cloud.run.v2.IUpdateServiceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateService( - request?: protos.google.cloud.run.v2.IUpdateServiceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - let routingParameter = {}; - { - const fieldValue = request.service?.name; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.updateService(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateService()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/services.update_service.js - * region_tag:run_v2_generated_Services_UpdateService_async - */ - async checkUpdateServiceProgress(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.updateService, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a Service. - * This will cause the Service to stop serving traffic and will delete all - * revisions. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full name of the Service. - * Format: projects/{project}/locations/{location}/services/{service}, where - * {project} can be project id or number. - * @param {boolean} request.validateOnly - * Indicates that the request should be validated without actually - * deleting any resources. - * @param {string} request.etag - * A system-generated fingerprint for this version of the - * resource. May be used to detect modification conflict during updates. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/services.delete_service.js - * region_tag:run_v2_generated_Services_DeleteService_async - */ - deleteService( - request?: protos.google.cloud.run.v2.IDeleteServiceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteService( - request: protos.google.cloud.run.v2.IDeleteServiceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteService( - request: protos.google.cloud.run.v2.IDeleteServiceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteService( - request?: protos.google.cloud.run.v2.IDeleteServiceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - let routingParameter = {}; - { - const fieldValue = request.name; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.deleteService(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteService()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2/services.delete_service.js - * region_tag:run_v2_generated_Services_DeleteService_async - */ - async checkDeleteServiceProgress(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.deleteService, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists Services. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location and project to list resources on. - * Location must be a valid Google Cloud region, and cannot be the "-" - * wildcard. Format: projects/{project}/locations/{location}, where {project} - * can be project id or number. - * @param {number} request.pageSize - * Maximum number of Services to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListServices. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.run.v2.Service|Service}. - * 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 `listServicesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listServices( - request?: protos.google.cloud.run.v2.IListServicesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.run.v2.IService[], - protos.google.cloud.run.v2.IListServicesRequest|null, - protos.google.cloud.run.v2.IListServicesResponse - ]>; - listServices( - request: protos.google.cloud.run.v2.IListServicesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.run.v2.IListServicesRequest, - protos.google.cloud.run.v2.IListServicesResponse|null|undefined, - protos.google.cloud.run.v2.IService>): void; - listServices( - request: protos.google.cloud.run.v2.IListServicesRequest, - callback: PaginationCallback< - protos.google.cloud.run.v2.IListServicesRequest, - protos.google.cloud.run.v2.IListServicesResponse|null|undefined, - protos.google.cloud.run.v2.IService>): void; - listServices( - request?: protos.google.cloud.run.v2.IListServicesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.run.v2.IListServicesRequest, - protos.google.cloud.run.v2.IListServicesResponse|null|undefined, - protos.google.cloud.run.v2.IService>, - callback?: PaginationCallback< - protos.google.cloud.run.v2.IListServicesRequest, - protos.google.cloud.run.v2.IListServicesResponse|null|undefined, - protos.google.cloud.run.v2.IService>): - Promise<[ - protos.google.cloud.run.v2.IService[], - protos.google.cloud.run.v2.IListServicesRequest|null, - protos.google.cloud.run.v2.IListServicesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - let routingParameter = {}; - { - const fieldValue = request.parent; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.listServices(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location and project to list resources on. - * Location must be a valid Google Cloud region, and cannot be the "-" - * wildcard. Format: projects/{project}/locations/{location}, where {project} - * can be project id or number. - * @param {number} request.pageSize - * Maximum number of Services to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListServices. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @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 protos.google.cloud.run.v2.Service|Service} 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 `listServicesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listServicesStream( - request?: protos.google.cloud.run.v2.IListServicesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - let routingParameter = {}; - { - const fieldValue = request.parent; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - const defaultCallSettings = this._defaults['listServices']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServices.createStream( - this.innerApiCalls.listServices as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listServices`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location and project to list resources on. - * Location must be a valid Google Cloud region, and cannot be the "-" - * wildcard. Format: projects/{project}/locations/{location}, where {project} - * can be project id or number. - * @param {number} request.pageSize - * Maximum number of Services to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListServices. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.run.v2.Service|Service}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v2/services.list_services.js - * region_tag:run_v2_generated_Services_ListServices_async - */ - listServicesAsync( - request?: protos.google.cloud.run.v2.IListServicesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - let routingParameter = {}; - { - const fieldValue = request.parent; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - const defaultCallSettings = this._defaults['listServices']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServices.asyncIterate( - this.innerApiCalls['listServices'] 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 execution resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @param {string} execution - * @returns {string} Resource name string. - */ - executionPath(project:string,location:string,job:string,execution:string) { - return this.pathTemplates.executionPathTemplate.render({ - project: project, - location: location, - job: job, - execution: execution, - }); - } - - /** - * Parse the project from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the project. - */ - matchProjectFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).project; - } - - /** - * Parse the location from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the location. - */ - matchLocationFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).location; - } - - /** - * Parse the job from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the job. - */ - matchJobFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).job; - } - - /** - * Parse the execution from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the execution. - */ - matchExecutionFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).execution; - } - - /** - * Return a fully-qualified job resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @returns {string} Resource name string. - */ - jobPath(project:string,location:string,job:string) { - return this.pathTemplates.jobPathTemplate.render({ - project: project, - location: location, - job: job, - }); - } - - /** - * Parse the project from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the project. - */ - matchProjectFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).project; - } - - /** - * Parse the location from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the location. - */ - matchLocationFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).location; - } - - /** - * Parse the job from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the job. - */ - matchJobFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).job; - } - - /** - * 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 project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified revision resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} service - * @param {string} revision - * @returns {string} Resource name string. - */ - revisionPath(project:string,location:string,service:string,revision:string) { - return this.pathTemplates.revisionPathTemplate.render({ - project: project, - location: location, - service: service, - revision: revision, - }); - } - - /** - * Parse the project from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).project; - } - - /** - * Parse the location from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the location. - */ - matchLocationFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).location; - } - - /** - * Parse the service from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the service. - */ - matchServiceFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).service; - } - - /** - * Parse the revision from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the revision. - */ - matchRevisionFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).revision; - } - - /** - * Return a fully-qualified service resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} service - * @returns {string} Resource name string. - */ - servicePath(project:string,location:string,service:string) { - return this.pathTemplates.servicePathTemplate.render({ - project: project, - location: location, - service: service, - }); - } - - /** - * Parse the project from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).project; - } - - /** - * Parse the location from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).location; - } - - /** - * Parse the service from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).service; - } - - /** - * Return a fully-qualified task resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @param {string} execution - * @param {string} task - * @returns {string} Resource name string. - */ - taskPath(project:string,location:string,job:string,execution:string,task:string) { - return this.pathTemplates.taskPathTemplate.render({ - project: project, - location: location, - job: job, - execution: execution, - task: task, - }); - } - - /** - * Parse the project from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the project. - */ - matchProjectFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).project; - } - - /** - * Parse the location from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the location. - */ - matchLocationFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).location; - } - - /** - * Parse the job from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the job. - */ - matchJobFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).job; - } - - /** - * Parse the execution from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the execution. - */ - matchExecutionFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).execution; - } - - /** - * Parse the task from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the task. - */ - matchTaskFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).task; - } - - /** - * 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.servicesStub && !this._terminated) { - return this.servicesStub.then(stub => { - this._terminated = true; - stub.close(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/services_client_config.json b/owl-bot-staging/google-cloud-run/v2/src/v2/services_client_config.json deleted file mode 100644 index d9a33646b69..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/src/v2/services_client_config.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "interfaces": { - "google.cloud.run.v2.Services": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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 - }, - "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateService": { - "timeout_millis": 15000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetService": { - "timeout_millis": 10000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "ListServices": { - "timeout_millis": 10000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "UpdateService": { - "timeout_millis": 15000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteService": { - "timeout_millis": 10000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetIamPolicy": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "SetIamPolicy": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "TestIamPermissions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/services_proto_list.json b/owl-bot-staging/google-cloud-run/v2/src/v2/services_proto_list.json deleted file mode 100644 index f6d18fdac6b..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/src/v2/services_proto_list.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - "../../protos/google/cloud/run/v2/condition.proto", - "../../protos/google/cloud/run/v2/execution.proto", - "../../protos/google/cloud/run/v2/execution_template.proto", - "../../protos/google/cloud/run/v2/job.proto", - "../../protos/google/cloud/run/v2/k8s.min.proto", - "../../protos/google/cloud/run/v2/revision.proto", - "../../protos/google/cloud/run/v2/revision_template.proto", - "../../protos/google/cloud/run/v2/service.proto", - "../../protos/google/cloud/run/v2/task.proto", - "../../protos/google/cloud/run/v2/task_template.proto", - "../../protos/google/cloud/run/v2/traffic_target.proto", - "../../protos/google/cloud/run/v2/vendor_settings.proto" -] diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/tasks_client.ts b/owl-bot-staging/google-cloud-run/v2/src/v2/tasks_client.ts deleted file mode 100644 index acee35d2327..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/src/v2/tasks_client.ts +++ /dev/null @@ -1,1112 +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, 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/tasks_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './tasks_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Cloud Run Task Control Plane API. - * @class - * @memberof v2 - */ -export class TasksClient { - 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}; - tasksStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of TasksClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 TasksClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof TasksClient; - 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 { - 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 = { - cryptoKeyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}' - ), - executionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}' - ), - jobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - revisionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}/revisions/{revision}' - ), - servicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}' - ), - taskPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task}' - ), - }; - - // 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 = { - listTasks: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tasks') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.run.v2.Tasks', 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.tasksStub) { - return this.tasksStub; - } - - // Put together the "service stub" for - // google.cloud.run.v2.Tasks. - this.tasksStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.run.v2.Tasks') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.run.v2.Tasks, - 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 tasksStubMethods = - ['getTask', 'listTasks']; - for (const methodName of tasksStubMethods) { - const callPromise = this.tasksStub.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.tasksStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'run.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 'run.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 information about a Task. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full name of the Task. - * Format: - * projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.run.v2.Task|Task}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/tasks.get_task.js - * region_tag:run_v2_generated_Tasks_GetTask_async - */ - getTask( - request?: protos.google.cloud.run.v2.IGetTaskRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.run.v2.ITask, - protos.google.cloud.run.v2.IGetTaskRequest|undefined, {}|undefined - ]>; - getTask( - request: protos.google.cloud.run.v2.IGetTaskRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.run.v2.ITask, - protos.google.cloud.run.v2.IGetTaskRequest|null|undefined, - {}|null|undefined>): void; - getTask( - request: protos.google.cloud.run.v2.IGetTaskRequest, - callback: Callback< - protos.google.cloud.run.v2.ITask, - protos.google.cloud.run.v2.IGetTaskRequest|null|undefined, - {}|null|undefined>): void; - getTask( - request?: protos.google.cloud.run.v2.IGetTaskRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.run.v2.ITask, - protos.google.cloud.run.v2.IGetTaskRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.run.v2.ITask, - protos.google.cloud.run.v2.IGetTaskRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.run.v2.ITask, - protos.google.cloud.run.v2.IGetTaskRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getTask(request, options, callback); - } - - /** - * Lists Tasks from an Execution of a Job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The Execution from which the Tasks should be listed. - * To list all Tasks across Executions of a Job, use "-" instead of Execution - * name. To list all Tasks across Jobs, use "-" instead of Job name. Format: - * projects/{project}/locations/{location}/jobs/{job}/executions/{execution} - * @param {number} request.pageSize - * Maximum number of Tasks to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListTasks. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.run.v2.Task|Task}. - * 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 `listTasksAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listTasks( - request?: protos.google.cloud.run.v2.IListTasksRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.run.v2.ITask[], - protos.google.cloud.run.v2.IListTasksRequest|null, - protos.google.cloud.run.v2.IListTasksResponse - ]>; - listTasks( - request: protos.google.cloud.run.v2.IListTasksRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.run.v2.IListTasksRequest, - protos.google.cloud.run.v2.IListTasksResponse|null|undefined, - protos.google.cloud.run.v2.ITask>): void; - listTasks( - request: protos.google.cloud.run.v2.IListTasksRequest, - callback: PaginationCallback< - protos.google.cloud.run.v2.IListTasksRequest, - protos.google.cloud.run.v2.IListTasksResponse|null|undefined, - protos.google.cloud.run.v2.ITask>): void; - listTasks( - request?: protos.google.cloud.run.v2.IListTasksRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.run.v2.IListTasksRequest, - protos.google.cloud.run.v2.IListTasksResponse|null|undefined, - protos.google.cloud.run.v2.ITask>, - callback?: PaginationCallback< - protos.google.cloud.run.v2.IListTasksRequest, - protos.google.cloud.run.v2.IListTasksResponse|null|undefined, - protos.google.cloud.run.v2.ITask>): - Promise<[ - protos.google.cloud.run.v2.ITask[], - protos.google.cloud.run.v2.IListTasksRequest|null, - protos.google.cloud.run.v2.IListTasksResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listTasks(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 Execution from which the Tasks should be listed. - * To list all Tasks across Executions of a Job, use "-" instead of Execution - * name. To list all Tasks across Jobs, use "-" instead of Job name. Format: - * projects/{project}/locations/{location}/jobs/{job}/executions/{execution} - * @param {number} request.pageSize - * Maximum number of Tasks to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListTasks. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @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 protos.google.cloud.run.v2.Task|Task} 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 `listTasksAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listTasksStream( - request?: protos.google.cloud.run.v2.IListTasksRequest, - 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['listTasks']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTasks.createStream( - this.innerApiCalls.listTasks as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listTasks`, 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 Execution from which the Tasks should be listed. - * To list all Tasks across Executions of a Job, use "-" instead of Execution - * name. To list all Tasks across Jobs, use "-" instead of Job name. Format: - * projects/{project}/locations/{location}/jobs/{job}/executions/{execution} - * @param {number} request.pageSize - * Maximum number of Tasks to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListTasks. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.run.v2.Task|Task}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v2/tasks.list_tasks.js - * region_tag:run_v2_generated_Tasks_ListTasks_async - */ - listTasksAsync( - request?: protos.google.cloud.run.v2.IListTasksRequest, - 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['listTasks']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTasks.asyncIterate( - this.innerApiCalls['listTasks'] 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified cryptoKey resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} key_ring - * @param {string} crypto_key - * @returns {string} Resource name string. - */ - cryptoKeyPath(project:string,location:string,keyRing:string,cryptoKey:string) { - return this.pathTemplates.cryptoKeyPathTemplate.render({ - project: project, - location: location, - key_ring: keyRing, - crypto_key: cryptoKey, - }); - } - - /** - * Parse the project from CryptoKey resource. - * - * @param {string} cryptoKeyName - * A fully-qualified path representing CryptoKey resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).project; - } - - /** - * Parse the location from CryptoKey resource. - * - * @param {string} cryptoKeyName - * A fully-qualified path representing CryptoKey resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).location; - } - - /** - * Parse the key_ring from CryptoKey resource. - * - * @param {string} cryptoKeyName - * A fully-qualified path representing CryptoKey resource. - * @returns {string} A string representing the key_ring. - */ - matchKeyRingFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).key_ring; - } - - /** - * Parse the crypto_key from CryptoKey resource. - * - * @param {string} cryptoKeyName - * A fully-qualified path representing CryptoKey resource. - * @returns {string} A string representing the crypto_key. - */ - matchCryptoKeyFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).crypto_key; - } - - /** - * Return a fully-qualified execution resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @param {string} execution - * @returns {string} Resource name string. - */ - executionPath(project:string,location:string,job:string,execution:string) { - return this.pathTemplates.executionPathTemplate.render({ - project: project, - location: location, - job: job, - execution: execution, - }); - } - - /** - * Parse the project from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the project. - */ - matchProjectFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).project; - } - - /** - * Parse the location from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the location. - */ - matchLocationFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).location; - } - - /** - * Parse the job from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the job. - */ - matchJobFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).job; - } - - /** - * Parse the execution from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the execution. - */ - matchExecutionFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).execution; - } - - /** - * Return a fully-qualified job resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @returns {string} Resource name string. - */ - jobPath(project:string,location:string,job:string) { - return this.pathTemplates.jobPathTemplate.render({ - project: project, - location: location, - job: job, - }); - } - - /** - * Parse the project from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the project. - */ - matchProjectFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).project; - } - - /** - * Parse the location from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the location. - */ - matchLocationFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).location; - } - - /** - * Parse the job from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the job. - */ - matchJobFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).job; - } - - /** - * 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 project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified revision resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} service - * @param {string} revision - * @returns {string} Resource name string. - */ - revisionPath(project:string,location:string,service:string,revision:string) { - return this.pathTemplates.revisionPathTemplate.render({ - project: project, - location: location, - service: service, - revision: revision, - }); - } - - /** - * Parse the project from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).project; - } - - /** - * Parse the location from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the location. - */ - matchLocationFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).location; - } - - /** - * Parse the service from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the service. - */ - matchServiceFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).service; - } - - /** - * Parse the revision from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the revision. - */ - matchRevisionFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).revision; - } - - /** - * Return a fully-qualified service resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} service - * @returns {string} Resource name string. - */ - servicePath(project:string,location:string,service:string) { - return this.pathTemplates.servicePathTemplate.render({ - project: project, - location: location, - service: service, - }); - } - - /** - * Parse the project from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).project; - } - - /** - * Parse the location from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).location; - } - - /** - * Parse the service from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).service; - } - - /** - * Return a fully-qualified task resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @param {string} execution - * @param {string} task - * @returns {string} Resource name string. - */ - taskPath(project:string,location:string,job:string,execution:string,task:string) { - return this.pathTemplates.taskPathTemplate.render({ - project: project, - location: location, - job: job, - execution: execution, - task: task, - }); - } - - /** - * Parse the project from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the project. - */ - matchProjectFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).project; - } - - /** - * Parse the location from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the location. - */ - matchLocationFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).location; - } - - /** - * Parse the job from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the job. - */ - matchJobFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).job; - } - - /** - * Parse the execution from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the execution. - */ - matchExecutionFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).execution; - } - - /** - * Parse the task from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the task. - */ - matchTaskFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).task; - } - - /** - * 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.tasksStub && !this._terminated) { - return this.tasksStub.then(stub => { - this._terminated = true; - stub.close(); - this.locationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/tasks_client_config.json b/owl-bot-staging/google-cloud-run/v2/src/v2/tasks_client_config.json deleted file mode 100644 index c9fe28e061c..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/src/v2/tasks_client_config.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "interfaces": { - "google.cloud.run.v2.Tasks": { - "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": { - "GetTask": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListTasks": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-run/v2/src/v2/tasks_proto_list.json b/owl-bot-staging/google-cloud-run/v2/src/v2/tasks_proto_list.json deleted file mode 100644 index f6d18fdac6b..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/src/v2/tasks_proto_list.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - "../../protos/google/cloud/run/v2/condition.proto", - "../../protos/google/cloud/run/v2/execution.proto", - "../../protos/google/cloud/run/v2/execution_template.proto", - "../../protos/google/cloud/run/v2/job.proto", - "../../protos/google/cloud/run/v2/k8s.min.proto", - "../../protos/google/cloud/run/v2/revision.proto", - "../../protos/google/cloud/run/v2/revision_template.proto", - "../../protos/google/cloud/run/v2/service.proto", - "../../protos/google/cloud/run/v2/task.proto", - "../../protos/google/cloud/run/v2/task_template.proto", - "../../protos/google/cloud/run/v2/traffic_target.proto", - "../../protos/google/cloud/run/v2/vendor_settings.proto" -] diff --git a/owl-bot-staging/google-cloud-run/v2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-run/v2/system-test/fixtures/sample/src/index.js deleted file mode 100644 index f91d0fdb85e..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,31 +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 run = require('@google-cloud/run'); - -function main() { - const executionsClient = new run.ExecutionsClient(); - const jobsClient = new run.JobsClient(); - const revisionsClient = new run.RevisionsClient(); - const servicesClient = new run.ServicesClient(); - const tasksClient = new run.TasksClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-run/v2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-run/v2/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index d1dc2ca2135..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,56 +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 {ExecutionsClient, JobsClient, RevisionsClient, ServicesClient, TasksClient} from '@google-cloud/run'; - -// check that the client class type name can be used -function doStuffWithExecutionsClient(client: ExecutionsClient) { - client.close(); -} -function doStuffWithJobsClient(client: JobsClient) { - client.close(); -} -function doStuffWithRevisionsClient(client: RevisionsClient) { - client.close(); -} -function doStuffWithServicesClient(client: ServicesClient) { - client.close(); -} -function doStuffWithTasksClient(client: TasksClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const executionsClient = new ExecutionsClient(); - doStuffWithExecutionsClient(executionsClient); - // check that the client instance can be created - const jobsClient = new JobsClient(); - doStuffWithJobsClient(jobsClient); - // check that the client instance can be created - const revisionsClient = new RevisionsClient(); - doStuffWithRevisionsClient(revisionsClient); - // check that the client instance can be created - const servicesClient = new ServicesClient(); - doStuffWithServicesClient(servicesClient); - // check that the client instance can be created - const tasksClient = new TasksClient(); - doStuffWithTasksClient(tasksClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-run/v2/system-test/install.ts b/owl-bot-staging/google-cloud-run/v2/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-run/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-run/v2/test/gapic_executions_v2.ts b/owl-bot-staging/google-cloud-run/v2/test/gapic_executions_v2.ts deleted file mode 100644 index 657aaf35b3f..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/test/gapic_executions_v2.ts +++ /dev/null @@ -1,1474 +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 executionsModule 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.ExecutionsClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = executionsModule.v2.ExecutionsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = executionsModule.v2.ExecutionsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = executionsModule.v2.ExecutionsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new executionsModule.v2.ExecutionsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new executionsModule.v2.ExecutionsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.executionsStub, undefined); - await client.initialize(); - assert(client.executionsStub); - }); - - it('has close method for the initialized client', done => { - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.executionsStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.executionsStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new executionsModule.v2.ExecutionsClient({ - 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 executionsModule.v2.ExecutionsClient({ - 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('getExecution', () => { - it('invokes getExecution without error', async () => { - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.GetExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.GetExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.run.v2.Execution() - ); - client.innerApiCalls.getExecution = stubSimpleCall(expectedResponse); - const [response] = await client.getExecution(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getExecution without error using callback', async () => { - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.GetExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.GetExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.run.v2.Execution() - ); - client.innerApiCalls.getExecution = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getExecution( - request, - (err?: Error|null, result?: protos.google.cloud.run.v2.IExecution|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getExecution with error', async () => { - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.GetExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.GetExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getExecution = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getExecution(request), expectedError); - const actualRequest = (client.innerApiCalls.getExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getExecution with closed client', async () => { - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.GetExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.GetExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getExecution(request), expectedError); - }); - }); - - describe('deleteExecution', () => { - it('invokes deleteExecution without error', async () => { - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.DeleteExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.DeleteExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteExecution = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteExecution(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteExecution without error using callback', async () => { - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.DeleteExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.DeleteExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteExecution = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteExecution( - request, - (err?: Error|null, - result?: 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.deleteExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteExecution with call error', async () => { - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.DeleteExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.DeleteExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteExecution = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteExecution(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteExecution with LRO error', async () => { - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.DeleteExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.DeleteExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteExecution = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteExecution(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteExecutionProgress without error', async () => { - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteExecutionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteExecutionProgress with error', async () => { - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteExecutionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listExecutions', () => { - it('invokes listExecutions without error', async () => { - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListExecutionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.ListExecutionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Execution()), - generateSampleMessage(new protos.google.cloud.run.v2.Execution()), - generateSampleMessage(new protos.google.cloud.run.v2.Execution()), - ]; - client.innerApiCalls.listExecutions = stubSimpleCall(expectedResponse); - const [response] = await client.listExecutions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listExecutions without error using callback', async () => { - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListExecutionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.ListExecutionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Execution()), - generateSampleMessage(new protos.google.cloud.run.v2.Execution()), - generateSampleMessage(new protos.google.cloud.run.v2.Execution()), - ]; - client.innerApiCalls.listExecutions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listExecutions( - request, - (err?: Error|null, result?: protos.google.cloud.run.v2.IExecution[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listExecutions with error', async () => { - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListExecutionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.ListExecutionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listExecutions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listExecutions(request), expectedError); - const actualRequest = (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listExecutionsStream without error', async () => { - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListExecutionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.ListExecutionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Execution()), - generateSampleMessage(new protos.google.cloud.run.v2.Execution()), - generateSampleMessage(new protos.google.cloud.run.v2.Execution()), - ]; - client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listExecutionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.run.v2.Execution[] = []; - stream.on('data', (response: protos.google.cloud.run.v2.Execution) => { - 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.listExecutions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); - assert( - (client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listExecutionsStream with error', async () => { - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListExecutionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.ListExecutionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listExecutionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.run.v2.Execution[] = []; - stream.on('data', (response: protos.google.cloud.run.v2.Execution) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); - assert( - (client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listExecutions without error', async () => { - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListExecutionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.ListExecutionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Execution()), - generateSampleMessage(new protos.google.cloud.run.v2.Execution()), - generateSampleMessage(new protos.google.cloud.run.v2.Execution()), - ]; - client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.run.v2.IExecution[] = []; - const iterable = client.listExecutionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listExecutions with error', async () => { - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListExecutionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.ListExecutionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listExecutionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.run.v2.IExecution[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listExecutions.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 executionsModule.v2.ExecutionsClient({ - 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 executionsModule.v2.ExecutionsClient({ - 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 executionsModule.v2.ExecutionsClient({ - 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 executionsModule.v2.ExecutionsClient({ - 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 executionsModule.v2.ExecutionsClient({ - 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 executionsModule.v2.ExecutionsClient({ - 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 executionsModule.v2.ExecutionsClient({ - 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 executionsModule.v2.ExecutionsClient({ - 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 executionsModule.v2.ExecutionsClient({ - 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 executionsModule.v2.ExecutionsClient({ - 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 executionsModule.v2.ExecutionsClient({ - 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 executionsModule.v2.ExecutionsClient({ - 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 executionsModule.v2.ExecutionsClient({ - 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 executionsModule.v2.ExecutionsClient({ - 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 executionsModule.v2.ExecutionsClient({ - 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 executionsModule.v2.ExecutionsClient({ - 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('execution', () => { - const fakePath = "/rendered/path/execution"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - execution: "executionValue", - }; - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.executionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.executionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('executionPath', () => { - const result = client.executionPath("projectValue", "locationValue", "jobValue", "executionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.executionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromExecutionName', () => { - const result = client.matchProjectFromExecutionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromExecutionName', () => { - const result = client.matchLocationFromExecutionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromExecutionName', () => { - const result = client.matchJobFromExecutionName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExecutionFromExecutionName', () => { - const result = client.matchExecutionFromExecutionName(fakePath); - assert.strictEqual(result, "executionValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('job', () => { - const fakePath = "/rendered/path/job"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - }; - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.jobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.jobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('jobPath', () => { - const result = client.jobPath("projectValue", "locationValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.jobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromJobName', () => { - const result = client.matchProjectFromJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromJobName', () => { - const result = client.matchLocationFromJobName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromJobName', () => { - const result = client.matchJobFromJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new executionsModule.v2.ExecutionsClient({ - 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('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('revision', () => { - const fakePath = "/rendered/path/revision"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - revision: "revisionValue", - }; - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.revisionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.revisionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('revisionPath', () => { - const result = client.revisionPath("projectValue", "locationValue", "serviceValue", "revisionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.revisionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRevisionName', () => { - const result = client.matchProjectFromRevisionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRevisionName', () => { - const result = client.matchLocationFromRevisionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromRevisionName', () => { - const result = client.matchServiceFromRevisionName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRevisionFromRevisionName', () => { - const result = client.matchRevisionFromRevisionName(fakePath); - assert.strictEqual(result, "revisionValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('service', () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - }; - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servicePath', () => { - const result = client.servicePath("projectValue", "locationValue", "serviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceName', () => { - const result = client.matchProjectFromServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceName', () => { - const result = client.matchLocationFromServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromServiceName', () => { - const result = client.matchServiceFromServiceName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('task', () => { - const fakePath = "/rendered/path/task"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - execution: "executionValue", - task: "taskValue", - }; - const client = new executionsModule.v2.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.taskPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.taskPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('taskPath', () => { - const result = client.taskPath("projectValue", "locationValue", "jobValue", "executionValue", "taskValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.taskPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTaskName', () => { - const result = client.matchProjectFromTaskName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTaskName', () => { - const result = client.matchLocationFromTaskName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromTaskName', () => { - const result = client.matchJobFromTaskName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExecutionFromTaskName', () => { - const result = client.matchExecutionFromTaskName(fakePath); - assert.strictEqual(result, "executionValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTaskFromTaskName', () => { - const result = client.matchTaskFromTaskName(fakePath); - assert.strictEqual(result, "taskValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-run/v2/test/gapic_jobs_v2.ts b/owl-bot-staging/google-cloud-run/v2/test/gapic_jobs_v2.ts deleted file mode 100644 index 69d0b0ae38f..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/test/gapic_jobs_v2.ts +++ /dev/null @@ -1,2264 +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 jobsModule 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.JobsClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = jobsModule.v2.JobsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = jobsModule.v2.JobsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = jobsModule.v2.JobsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new jobsModule.v2.JobsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new jobsModule.v2.JobsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.jobsStub, undefined); - await client.initialize(); - assert(client.jobsStub); - }); - - it('has close method for the initialized client', done => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.jobsStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.jobsStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new jobsModule.v2.JobsClient({ - 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 jobsModule.v2.JobsClient({ - 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('getJob', () => { - it('invokes getJob without error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.run.v2.Job() - ); - client.innerApiCalls.getJob = stubSimpleCall(expectedResponse); - const [response] = await client.getJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getJob without error using callback', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.run.v2.Job() - ); - client.innerApiCalls.getJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getJob( - request, - (err?: Error|null, result?: protos.google.cloud.run.v2.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getJob with error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getJob(request), expectedError); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getJob with closed client', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getJob(request), expectedError); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy without error using callback', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy with error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy with closed client', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); - }); - - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy without error using callback', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy with error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy with closed client', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); - }); - - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions without error using callback', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions with error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions with closed client', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); - }); - - describe('createJob', () => { - it('invokes createJob without error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createJob = stubLongRunningCall(expectedResponse); - const [operation] = await client.createJob(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createJob without error using callback', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createJob = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createJob( - request, - (err?: Error|null, - result?: 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.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createJob with call error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createJob = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createJob(request), expectedError); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createJob with LRO error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createJob = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createJob(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateJobProgress without error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateJobProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateJobProgress with error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateJobProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateJob', () => { - it('invokes updateJob without error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateJob = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateJob(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateJob without error using callback', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateJob = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateJob( - request, - (err?: Error|null, - result?: 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.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateJob with call error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateJob = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateJob(request), expectedError); - const actualRequest = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateJob with LRO error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateJob = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateJob(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateJobProgress without error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateJobProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateJobProgress with error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateJobProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteJob', () => { - it('invokes deleteJob without error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteJob = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteJob(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteJob without error using callback', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteJob = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteJob( - request, - (err?: Error|null, - result?: 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.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteJob with call error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteJob = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteJob(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteJob with LRO error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteJob = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteJob(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteJobProgress without error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteJobProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteJobProgress with error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteJobProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('runJob', () => { - it('invokes runJob without error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.RunJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.RunJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.runJob = stubLongRunningCall(expectedResponse); - const [operation] = await client.runJob(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runJob without error using callback', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.RunJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.RunJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.runJob = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.runJob( - request, - (err?: Error|null, - result?: 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.runJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runJob with call error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.RunJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.RunJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.runJob = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.runJob(request), expectedError); - const actualRequest = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runJob with LRO error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.RunJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.RunJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.runJob = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.runJob(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkRunJobProgress without error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRunJobProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRunJobProgress with error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRunJobProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listJobs', () => { - it('invokes listJobs without error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Job()), - generateSampleMessage(new protos.google.cloud.run.v2.Job()), - generateSampleMessage(new protos.google.cloud.run.v2.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCall(expectedResponse); - const [response] = await client.listJobs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listJobs without error using callback', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Job()), - generateSampleMessage(new protos.google.cloud.run.v2.Job()), - generateSampleMessage(new protos.google.cloud.run.v2.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listJobs( - request, - (err?: Error|null, result?: protos.google.cloud.run.v2.IJob[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listJobs with error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listJobs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listJobs(request), expectedError); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listJobsStream without error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Job()), - generateSampleMessage(new protos.google.cloud.run.v2.Job()), - generateSampleMessage(new protos.google.cloud.run.v2.Job()), - ]; - client.descriptors.page.listJobs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.run.v2.Job[] = []; - stream.on('data', (response: protos.google.cloud.run.v2.Job) => { - 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.listJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); - assert( - (client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listJobsStream with error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listJobs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.run.v2.Job[] = []; - stream.on('data', (response: protos.google.cloud.run.v2.Job) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); - assert( - (client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listJobs without error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Job()), - generateSampleMessage(new protos.google.cloud.run.v2.Job()), - generateSampleMessage(new protos.google.cloud.run.v2.Job()), - ]; - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.run.v2.IJob[] = []; - const iterable = client.listJobsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listJobs with error', async () => { - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listJobsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.run.v2.IJob[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listJobs.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 jobsModule.v2.JobsClient({ - 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 jobsModule.v2.JobsClient({ - 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 jobsModule.v2.JobsClient({ - 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 jobsModule.v2.JobsClient({ - 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 jobsModule.v2.JobsClient({ - 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 jobsModule.v2.JobsClient({ - 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 jobsModule.v2.JobsClient({ - 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 jobsModule.v2.JobsClient({ - 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 jobsModule.v2.JobsClient({ - 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 jobsModule.v2.JobsClient({ - 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 jobsModule.v2.JobsClient({ - 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 jobsModule.v2.JobsClient({ - 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 jobsModule.v2.JobsClient({ - 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 jobsModule.v2.JobsClient({ - 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 jobsModule.v2.JobsClient({ - 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 jobsModule.v2.JobsClient({ - 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('execution', () => { - const fakePath = "/rendered/path/execution"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - execution: "executionValue", - }; - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.executionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.executionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('executionPath', () => { - const result = client.executionPath("projectValue", "locationValue", "jobValue", "executionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.executionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromExecutionName', () => { - const result = client.matchProjectFromExecutionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromExecutionName', () => { - const result = client.matchLocationFromExecutionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromExecutionName', () => { - const result = client.matchJobFromExecutionName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExecutionFromExecutionName', () => { - const result = client.matchExecutionFromExecutionName(fakePath); - assert.strictEqual(result, "executionValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('job', () => { - const fakePath = "/rendered/path/job"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - }; - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.jobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.jobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('jobPath', () => { - const result = client.jobPath("projectValue", "locationValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.jobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromJobName', () => { - const result = client.matchProjectFromJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromJobName', () => { - const result = client.matchLocationFromJobName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromJobName', () => { - const result = client.matchJobFromJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new jobsModule.v2.JobsClient({ - 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('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('revision', () => { - const fakePath = "/rendered/path/revision"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - revision: "revisionValue", - }; - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.revisionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.revisionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('revisionPath', () => { - const result = client.revisionPath("projectValue", "locationValue", "serviceValue", "revisionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.revisionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRevisionName', () => { - const result = client.matchProjectFromRevisionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRevisionName', () => { - const result = client.matchLocationFromRevisionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromRevisionName', () => { - const result = client.matchServiceFromRevisionName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRevisionFromRevisionName', () => { - const result = client.matchRevisionFromRevisionName(fakePath); - assert.strictEqual(result, "revisionValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('service', () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - }; - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servicePath', () => { - const result = client.servicePath("projectValue", "locationValue", "serviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceName', () => { - const result = client.matchProjectFromServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceName', () => { - const result = client.matchLocationFromServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromServiceName', () => { - const result = client.matchServiceFromServiceName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('task', () => { - const fakePath = "/rendered/path/task"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - execution: "executionValue", - task: "taskValue", - }; - const client = new jobsModule.v2.JobsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.taskPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.taskPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('taskPath', () => { - const result = client.taskPath("projectValue", "locationValue", "jobValue", "executionValue", "taskValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.taskPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTaskName', () => { - const result = client.matchProjectFromTaskName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTaskName', () => { - const result = client.matchLocationFromTaskName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromTaskName', () => { - const result = client.matchJobFromTaskName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExecutionFromTaskName', () => { - const result = client.matchExecutionFromTaskName(fakePath); - assert.strictEqual(result, "executionValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTaskFromTaskName', () => { - const result = client.matchTaskFromTaskName(fakePath); - assert.strictEqual(result, "taskValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-run/v2/test/gapic_revisions_v2.ts b/owl-bot-staging/google-cloud-run/v2/test/gapic_revisions_v2.ts deleted file mode 100644 index 2805a3f3661..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/test/gapic_revisions_v2.ts +++ /dev/null @@ -1,1513 +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 revisionsModule 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.RevisionsClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = revisionsModule.v2.RevisionsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = revisionsModule.v2.RevisionsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = revisionsModule.v2.RevisionsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new revisionsModule.v2.RevisionsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new revisionsModule.v2.RevisionsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.revisionsStub, undefined); - await client.initialize(); - assert(client.revisionsStub); - }); - - it('has close method for the initialized client', done => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.revisionsStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.revisionsStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new revisionsModule.v2.RevisionsClient({ - 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 revisionsModule.v2.RevisionsClient({ - 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('getRevision', () => { - it('invokes getRevision without error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.GetRevisionRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.run.v2.Revision() - ); - client.innerApiCalls.getRevision = stubSimpleCall(expectedResponse); - const [response] = await client.getRevision(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRevision as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRevision as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRevision without error using callback', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.GetRevisionRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.run.v2.Revision() - ); - client.innerApiCalls.getRevision = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getRevision( - request, - (err?: Error|null, result?: protos.google.cloud.run.v2.IRevision|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRevision as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRevision as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRevision with error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.GetRevisionRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedError = new Error('expected'); - client.innerApiCalls.getRevision = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getRevision(request), expectedError); - const actualRequest = (client.innerApiCalls.getRevision as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRevision as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRevision with closed client', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.GetRevisionRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getRevision(request), expectedError); - }); - }); - - describe('deleteRevision', () => { - it('invokes deleteRevision without error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.DeleteRevisionRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteRevision = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteRevision(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteRevision as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteRevision as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteRevision without error using callback', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.DeleteRevisionRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteRevision = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteRevision( - request, - (err?: Error|null, - result?: 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.deleteRevision as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteRevision as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteRevision with call error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.DeleteRevisionRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteRevision = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteRevision(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteRevision as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteRevision as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteRevision with LRO error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.DeleteRevisionRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteRevision = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteRevision(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteRevision as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteRevision as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteRevisionProgress without error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteRevisionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteRevisionProgress with error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteRevisionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listRevisions', () => { - it('invokes listRevisions without error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListRevisionsRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.parent = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value';const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - ]; - client.innerApiCalls.listRevisions = stubSimpleCall(expectedResponse); - const [response] = await client.listRevisions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRevisions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRevisions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRevisions without error using callback', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListRevisionsRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.parent = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value';const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - ]; - client.innerApiCalls.listRevisions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listRevisions( - request, - (err?: Error|null, result?: protos.google.cloud.run.v2.IRevision[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRevisions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRevisions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRevisions with error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListRevisionsRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.parent = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedError = new Error('expected'); - client.innerApiCalls.listRevisions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listRevisions(request), expectedError); - const actualRequest = (client.innerApiCalls.listRevisions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRevisions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRevisionsStream without error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListRevisionsRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.parent = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - ]; - client.descriptors.page.listRevisions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listRevisionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.run.v2.Revision[] = []; - stream.on('data', (response: protos.google.cloud.run.v2.Revision) => { - 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.listRevisions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRevisions, request)); - assert( - (client.descriptors.page.listRevisions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listRevisionsStream with error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListRevisionsRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.parent = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedError = new Error('expected'); - client.descriptors.page.listRevisions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listRevisionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.run.v2.Revision[] = []; - stream.on('data', (response: protos.google.cloud.run.v2.Revision) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listRevisions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRevisions, request)); - assert( - (client.descriptors.page.listRevisions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRevisions without error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListRevisionsRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.parent = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - ]; - client.descriptors.page.listRevisions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.run.v2.IRevision[] = []; - const iterable = client.listRevisionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listRevisions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRevisions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRevisions with error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListRevisionsRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.parent = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedError = new Error('expected'); - client.descriptors.page.listRevisions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listRevisionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.run.v2.IRevision[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listRevisions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRevisions.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 revisionsModule.v2.RevisionsClient({ - 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 revisionsModule.v2.RevisionsClient({ - 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 revisionsModule.v2.RevisionsClient({ - 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 revisionsModule.v2.RevisionsClient({ - 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 revisionsModule.v2.RevisionsClient({ - 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 revisionsModule.v2.RevisionsClient({ - 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 revisionsModule.v2.RevisionsClient({ - 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 revisionsModule.v2.RevisionsClient({ - 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 revisionsModule.v2.RevisionsClient({ - 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 revisionsModule.v2.RevisionsClient({ - 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 revisionsModule.v2.RevisionsClient({ - 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 revisionsModule.v2.RevisionsClient({ - 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 revisionsModule.v2.RevisionsClient({ - 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 revisionsModule.v2.RevisionsClient({ - 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 revisionsModule.v2.RevisionsClient({ - 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 revisionsModule.v2.RevisionsClient({ - 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('cryptoKey', () => { - const fakePath = "/rendered/path/cryptoKey"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - }; - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.cryptoKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.cryptoKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('cryptoKeyPath', () => { - const result = client.cryptoKeyPath("projectValue", "locationValue", "keyRingValue", "cryptoKeyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.cryptoKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCryptoKeyName', () => { - const result = client.matchProjectFromCryptoKeyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCryptoKeyName', () => { - const result = client.matchLocationFromCryptoKeyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromCryptoKeyName', () => { - const result = client.matchKeyRingFromCryptoKeyName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCryptoKeyFromCryptoKeyName', () => { - const result = client.matchCryptoKeyFromCryptoKeyName(fakePath); - assert.strictEqual(result, "cryptoKeyValue"); - assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('execution', () => { - const fakePath = "/rendered/path/execution"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - execution: "executionValue", - }; - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.executionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.executionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('executionPath', () => { - const result = client.executionPath("projectValue", "locationValue", "jobValue", "executionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.executionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromExecutionName', () => { - const result = client.matchProjectFromExecutionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromExecutionName', () => { - const result = client.matchLocationFromExecutionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromExecutionName', () => { - const result = client.matchJobFromExecutionName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExecutionFromExecutionName', () => { - const result = client.matchExecutionFromExecutionName(fakePath); - assert.strictEqual(result, "executionValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('job', () => { - const fakePath = "/rendered/path/job"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - }; - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.jobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.jobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('jobPath', () => { - const result = client.jobPath("projectValue", "locationValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.jobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromJobName', () => { - const result = client.matchProjectFromJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromJobName', () => { - const result = client.matchLocationFromJobName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromJobName', () => { - const result = client.matchJobFromJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new revisionsModule.v2.RevisionsClient({ - 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('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('revision', () => { - const fakePath = "/rendered/path/revision"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - revision: "revisionValue", - }; - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.revisionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.revisionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('revisionPath', () => { - const result = client.revisionPath("projectValue", "locationValue", "serviceValue", "revisionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.revisionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRevisionName', () => { - const result = client.matchProjectFromRevisionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRevisionName', () => { - const result = client.matchLocationFromRevisionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromRevisionName', () => { - const result = client.matchServiceFromRevisionName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRevisionFromRevisionName', () => { - const result = client.matchRevisionFromRevisionName(fakePath); - assert.strictEqual(result, "revisionValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('service', () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - }; - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servicePath', () => { - const result = client.servicePath("projectValue", "locationValue", "serviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceName', () => { - const result = client.matchProjectFromServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceName', () => { - const result = client.matchLocationFromServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromServiceName', () => { - const result = client.matchServiceFromServiceName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('task', () => { - const fakePath = "/rendered/path/task"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - execution: "executionValue", - task: "taskValue", - }; - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.taskPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.taskPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('taskPath', () => { - const result = client.taskPath("projectValue", "locationValue", "jobValue", "executionValue", "taskValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.taskPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTaskName', () => { - const result = client.matchProjectFromTaskName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTaskName', () => { - const result = client.matchLocationFromTaskName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromTaskName', () => { - const result = client.matchJobFromTaskName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExecutionFromTaskName', () => { - const result = client.matchExecutionFromTaskName(fakePath); - assert.strictEqual(result, "executionValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTaskFromTaskName', () => { - const result = client.matchTaskFromTaskName(fakePath); - assert.strictEqual(result, "taskValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-run/v2/test/gapic_services_v2.ts b/owl-bot-staging/google-cloud-run/v2/test/gapic_services_v2.ts deleted file mode 100644 index 6d61b3188a1..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/test/gapic_services_v2.ts +++ /dev/null @@ -1,2087 +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 servicesModule 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.ServicesClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = servicesModule.v2.ServicesClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = servicesModule.v2.ServicesClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = servicesModule.v2.ServicesClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new servicesModule.v2.ServicesClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new servicesModule.v2.ServicesClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.servicesStub, undefined); - await client.initialize(); - assert(client.servicesStub); - }); - - it('has close method for the initialized client', done => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.servicesStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.servicesStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new servicesModule.v2.ServicesClient({ - 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 servicesModule.v2.ServicesClient({ - 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('getService', () => { - it('invokes getService without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.GetServiceRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.run.v2.Service() - ); - client.innerApiCalls.getService = stubSimpleCall(expectedResponse); - const [response] = await client.getService(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getService without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.GetServiceRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.run.v2.Service() - ); - client.innerApiCalls.getService = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getService( - request, - (err?: Error|null, result?: protos.google.cloud.run.v2.IService|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getService with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.GetServiceRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedError = new Error('expected'); - client.innerApiCalls.getService = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getService(request), expectedError); - const actualRequest = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getService with closed client', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.GetServiceRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getService(request), expectedError); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy with closed client', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); - }); - - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy with closed client', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); - }); - - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions with closed client', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); - }); - - describe('createService', () => { - it('invokes createService without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.CreateServiceRequest() - ); - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createService = stubLongRunningCall(expectedResponse); - const [operation] = await client.createService(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createService without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.CreateServiceRequest() - ); - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createService = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createService( - request, - (err?: Error|null, - result?: 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.createService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createService with call error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.CreateServiceRequest() - ); - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedError = new Error('expected'); - client.innerApiCalls.createService = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createService(request), expectedError); - const actualRequest = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createService with LRO error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.CreateServiceRequest() - ); - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedError = new Error('expected'); - client.innerApiCalls.createService = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createService(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateServiceProgress without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateServiceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateServiceProgress with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateServiceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateService', () => { - it('invokes updateService without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.UpdateServiceRequest() - ); - request.service = {}; - // path template: projects/*/locations/{location=*}/** - request.service.name = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateService = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateService(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateService without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.UpdateServiceRequest() - ); - request.service = {}; - // path template: projects/*/locations/{location=*}/** - request.service.name = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateService = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateService( - request, - (err?: Error|null, - result?: 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.updateService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateService with call error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.UpdateServiceRequest() - ); - request.service = {}; - // path template: projects/*/locations/{location=*}/** - request.service.name = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedError = new Error('expected'); - client.innerApiCalls.updateService = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateService(request), expectedError); - const actualRequest = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateService with LRO error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.UpdateServiceRequest() - ); - request.service = {}; - // path template: projects/*/locations/{location=*}/** - request.service.name = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedError = new Error('expected'); - client.innerApiCalls.updateService = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateService(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateServiceProgress without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateServiceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateServiceProgress with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateServiceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteService', () => { - it('invokes deleteService without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.DeleteServiceRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteService = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteService(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteService without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.DeleteServiceRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteService = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteService( - request, - (err?: Error|null, - result?: 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.deleteService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteService with call error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.DeleteServiceRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteService = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteService(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteService with LRO error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.DeleteServiceRequest() - ); - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteService = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteService(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteServiceProgress without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteServiceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteServiceProgress with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteServiceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listServices', () => { - it('invokes listServices without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListServicesRequest() - ); - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - const expectedHeaderRequestParams = 'location=value';const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - ]; - client.innerApiCalls.listServices = stubSimpleCall(expectedResponse); - const [response] = await client.listServices(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServices without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListServicesRequest() - ); - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - const expectedHeaderRequestParams = 'location=value';const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - ]; - client.innerApiCalls.listServices = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServices( - request, - (err?: Error|null, result?: protos.google.cloud.run.v2.IService[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServices with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListServicesRequest() - ); - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedError = new Error('expected'); - client.innerApiCalls.listServices = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServices(request), expectedError); - const actualRequest = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServicesStream without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListServicesRequest() - ); - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - ]; - client.descriptors.page.listServices.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listServicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.run.v2.Service[] = []; - stream.on('data', (response: protos.google.cloud.run.v2.Service) => { - 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.listServices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServices, request)); - assert( - (client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listServicesStream with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListServicesRequest() - ); - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedError = new Error('expected'); - client.descriptors.page.listServices.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listServicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.run.v2.Service[] = []; - stream.on('data', (response: protos.google.cloud.run.v2.Service) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServices, request)); - assert( - (client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listServices without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListServicesRequest() - ); - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - ]; - client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.run.v2.IService[] = []; - const iterable = client.listServicesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listServices with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListServicesRequest() - ); - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - const expectedHeaderRequestParams = 'location=value'; - const expectedError = new Error('expected'); - client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listServicesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.run.v2.IService[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServices.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 servicesModule.v2.ServicesClient({ - 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 servicesModule.v2.ServicesClient({ - 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 servicesModule.v2.ServicesClient({ - 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 servicesModule.v2.ServicesClient({ - 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 servicesModule.v2.ServicesClient({ - 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 servicesModule.v2.ServicesClient({ - 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 servicesModule.v2.ServicesClient({ - 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 servicesModule.v2.ServicesClient({ - 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 servicesModule.v2.ServicesClient({ - 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 servicesModule.v2.ServicesClient({ - 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 servicesModule.v2.ServicesClient({ - 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 servicesModule.v2.ServicesClient({ - 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 servicesModule.v2.ServicesClient({ - 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 servicesModule.v2.ServicesClient({ - 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 servicesModule.v2.ServicesClient({ - 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 servicesModule.v2.ServicesClient({ - 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('execution', () => { - const fakePath = "/rendered/path/execution"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - execution: "executionValue", - }; - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.executionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.executionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('executionPath', () => { - const result = client.executionPath("projectValue", "locationValue", "jobValue", "executionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.executionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromExecutionName', () => { - const result = client.matchProjectFromExecutionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromExecutionName', () => { - const result = client.matchLocationFromExecutionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromExecutionName', () => { - const result = client.matchJobFromExecutionName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExecutionFromExecutionName', () => { - const result = client.matchExecutionFromExecutionName(fakePath); - assert.strictEqual(result, "executionValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('job', () => { - const fakePath = "/rendered/path/job"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - }; - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.jobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.jobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('jobPath', () => { - const result = client.jobPath("projectValue", "locationValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.jobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromJobName', () => { - const result = client.matchProjectFromJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromJobName', () => { - const result = client.matchLocationFromJobName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromJobName', () => { - const result = client.matchJobFromJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new servicesModule.v2.ServicesClient({ - 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('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('revision', () => { - const fakePath = "/rendered/path/revision"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - revision: "revisionValue", - }; - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.revisionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.revisionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('revisionPath', () => { - const result = client.revisionPath("projectValue", "locationValue", "serviceValue", "revisionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.revisionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRevisionName', () => { - const result = client.matchProjectFromRevisionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRevisionName', () => { - const result = client.matchLocationFromRevisionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromRevisionName', () => { - const result = client.matchServiceFromRevisionName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRevisionFromRevisionName', () => { - const result = client.matchRevisionFromRevisionName(fakePath); - assert.strictEqual(result, "revisionValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('service', () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - }; - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servicePath', () => { - const result = client.servicePath("projectValue", "locationValue", "serviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceName', () => { - const result = client.matchProjectFromServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceName', () => { - const result = client.matchLocationFromServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromServiceName', () => { - const result = client.matchServiceFromServiceName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('task', () => { - const fakePath = "/rendered/path/task"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - execution: "executionValue", - task: "taskValue", - }; - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.taskPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.taskPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('taskPath', () => { - const result = client.taskPath("projectValue", "locationValue", "jobValue", "executionValue", "taskValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.taskPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTaskName', () => { - const result = client.matchProjectFromTaskName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTaskName', () => { - const result = client.matchLocationFromTaskName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromTaskName', () => { - const result = client.matchJobFromTaskName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExecutionFromTaskName', () => { - const result = client.matchExecutionFromTaskName(fakePath); - assert.strictEqual(result, "executionValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTaskFromTaskName', () => { - const result = client.matchTaskFromTaskName(fakePath); - assert.strictEqual(result, "taskValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-run/v2/test/gapic_tasks_v2.ts b/owl-bot-staging/google-cloud-run/v2/test/gapic_tasks_v2.ts deleted file mode 100644 index 4488b5b1bf8..00000000000 --- a/owl-bot-staging/google-cloud-run/v2/test/gapic_tasks_v2.ts +++ /dev/null @@ -1,1103 +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 tasksModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, 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.TasksClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = tasksModule.v2.TasksClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = tasksModule.v2.TasksClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = tasksModule.v2.TasksClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new tasksModule.v2.TasksClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new tasksModule.v2.TasksClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new tasksModule.v2.TasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tasksStub, undefined); - await client.initialize(); - assert(client.tasksStub); - }); - - it('has close method for the initialized client', done => { - const client = new tasksModule.v2.TasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.tasksStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new tasksModule.v2.TasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tasksStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new tasksModule.v2.TasksClient({ - 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 tasksModule.v2.TasksClient({ - 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('getTask', () => { - it('invokes getTask without error', async () => { - const client = new tasksModule.v2.TasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.run.v2.Task() - ); - client.innerApiCalls.getTask = stubSimpleCall(expectedResponse); - const [response] = await client.getTask(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getTask without error using callback', async () => { - const client = new tasksModule.v2.TasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.run.v2.Task() - ); - client.innerApiCalls.getTask = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getTask( - request, - (err?: Error|null, result?: protos.google.cloud.run.v2.ITask|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getTask with error', async () => { - const client = new tasksModule.v2.TasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getTask = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getTask(request), expectedError); - const actualRequest = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getTask with closed client', async () => { - const client = new tasksModule.v2.TasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getTask(request), expectedError); - }); - }); - - describe('listTasks', () => { - it('invokes listTasks without error', async () => { - const client = new tasksModule.v2.TasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Task()), - generateSampleMessage(new protos.google.cloud.run.v2.Task()), - generateSampleMessage(new protos.google.cloud.run.v2.Task()), - ]; - client.innerApiCalls.listTasks = stubSimpleCall(expectedResponse); - const [response] = await client.listTasks(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTasks without error using callback', async () => { - const client = new tasksModule.v2.TasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Task()), - generateSampleMessage(new protos.google.cloud.run.v2.Task()), - generateSampleMessage(new protos.google.cloud.run.v2.Task()), - ]; - client.innerApiCalls.listTasks = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTasks( - request, - (err?: Error|null, result?: protos.google.cloud.run.v2.ITask[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTasks with error', async () => { - const client = new tasksModule.v2.TasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listTasks = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTasks(request), expectedError); - const actualRequest = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTasksStream without error', async () => { - const client = new tasksModule.v2.TasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Task()), - generateSampleMessage(new protos.google.cloud.run.v2.Task()), - generateSampleMessage(new protos.google.cloud.run.v2.Task()), - ]; - client.descriptors.page.listTasks.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTasksStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.run.v2.Task[] = []; - stream.on('data', (response: protos.google.cloud.run.v2.Task) => { - 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.listTasks.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTasks, request)); - assert( - (client.descriptors.page.listTasks.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listTasksStream with error', async () => { - const client = new tasksModule.v2.TasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listTasks.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTasksStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.run.v2.Task[] = []; - stream.on('data', (response: protos.google.cloud.run.v2.Task) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTasks.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTasks, request)); - assert( - (client.descriptors.page.listTasks.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listTasks without error', async () => { - const client = new tasksModule.v2.TasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Task()), - generateSampleMessage(new protos.google.cloud.run.v2.Task()), - generateSampleMessage(new protos.google.cloud.run.v2.Task()), - ]; - client.descriptors.page.listTasks.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.run.v2.ITask[] = []; - const iterable = client.listTasksAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listTasks with error', async () => { - const client = new tasksModule.v2.TasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.run.v2.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.run.v2.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listTasks.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTasksAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.run.v2.ITask[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTasks.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 tasksModule.v2.TasksClient({ - 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 tasksModule.v2.TasksClient({ - 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 tasksModule.v2.TasksClient({ - 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 tasksModule.v2.TasksClient({ - 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 tasksModule.v2.TasksClient({ - 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('Path templates', () => { - - describe('cryptoKey', () => { - const fakePath = "/rendered/path/cryptoKey"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - }; - const client = new tasksModule.v2.TasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.cryptoKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.cryptoKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('cryptoKeyPath', () => { - const result = client.cryptoKeyPath("projectValue", "locationValue", "keyRingValue", "cryptoKeyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.cryptoKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCryptoKeyName', () => { - const result = client.matchProjectFromCryptoKeyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCryptoKeyName', () => { - const result = client.matchLocationFromCryptoKeyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromCryptoKeyName', () => { - const result = client.matchKeyRingFromCryptoKeyName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCryptoKeyFromCryptoKeyName', () => { - const result = client.matchCryptoKeyFromCryptoKeyName(fakePath); - assert.strictEqual(result, "cryptoKeyValue"); - assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('execution', () => { - const fakePath = "/rendered/path/execution"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - execution: "executionValue", - }; - const client = new tasksModule.v2.TasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.executionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.executionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('executionPath', () => { - const result = client.executionPath("projectValue", "locationValue", "jobValue", "executionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.executionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromExecutionName', () => { - const result = client.matchProjectFromExecutionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromExecutionName', () => { - const result = client.matchLocationFromExecutionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromExecutionName', () => { - const result = client.matchJobFromExecutionName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExecutionFromExecutionName', () => { - const result = client.matchExecutionFromExecutionName(fakePath); - assert.strictEqual(result, "executionValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('job', () => { - const fakePath = "/rendered/path/job"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - }; - const client = new tasksModule.v2.TasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.jobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.jobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('jobPath', () => { - const result = client.jobPath("projectValue", "locationValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.jobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromJobName', () => { - const result = client.matchProjectFromJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromJobName', () => { - const result = client.matchLocationFromJobName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromJobName', () => { - const result = client.matchJobFromJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new tasksModule.v2.TasksClient({ - 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('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new tasksModule.v2.TasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('revision', () => { - const fakePath = "/rendered/path/revision"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - revision: "revisionValue", - }; - const client = new tasksModule.v2.TasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.revisionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.revisionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('revisionPath', () => { - const result = client.revisionPath("projectValue", "locationValue", "serviceValue", "revisionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.revisionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRevisionName', () => { - const result = client.matchProjectFromRevisionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRevisionName', () => { - const result = client.matchLocationFromRevisionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromRevisionName', () => { - const result = client.matchServiceFromRevisionName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRevisionFromRevisionName', () => { - const result = client.matchRevisionFromRevisionName(fakePath); - assert.strictEqual(result, "revisionValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('service', () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - }; - const client = new tasksModule.v2.TasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servicePath', () => { - const result = client.servicePath("projectValue", "locationValue", "serviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceName', () => { - const result = client.matchProjectFromServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceName', () => { - const result = client.matchLocationFromServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromServiceName', () => { - const result = client.matchServiceFromServiceName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('task', () => { - const fakePath = "/rendered/path/task"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - execution: "executionValue", - task: "taskValue", - }; - const client = new tasksModule.v2.TasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.taskPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.taskPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('taskPath', () => { - const result = client.taskPath("projectValue", "locationValue", "jobValue", "executionValue", "taskValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.taskPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTaskName', () => { - const result = client.matchProjectFromTaskName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTaskName', () => { - const result = client.matchLocationFromTaskName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromTaskName', () => { - const result = client.matchJobFromTaskName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExecutionFromTaskName', () => { - const result = client.matchExecutionFromTaskName(fakePath); - assert.strictEqual(result, "executionValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTaskFromTaskName', () => { - const result = client.matchTaskFromTaskName(fakePath); - assert.strictEqual(result, "taskValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-run/v2/tsconfig.json b/owl-bot-staging/google-cloud-run/v2/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-run/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-run/v2/webpack.config.js b/owl-bot-staging/google-cloud-run/v2/webpack.config.js deleted file mode 100644 index 7de187a074a..00000000000 --- a/owl-bot-staging/google-cloud-run/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: 'Executions', - filename: './executions.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-scheduler/v1/.eslintignore b/owl-bot-staging/google-cloud-scheduler/v1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-scheduler/v1/.eslintrc.json b/owl-bot-staging/google-cloud-scheduler/v1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/.gitignore b/owl-bot-staging/google-cloud-scheduler/v1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-scheduler/v1/.jsdoc.js b/owl-bot-staging/google-cloud-scheduler/v1/.jsdoc.js deleted file mode 100644 index da319aef859..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/.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/scheduler', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-scheduler/v1/.mocharc.js b/owl-bot-staging/google-cloud-scheduler/v1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/.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-scheduler/v1/.prettierrc.js b/owl-bot-staging/google-cloud-scheduler/v1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/.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-scheduler/v1/README.md b/owl-bot-staging/google-cloud-scheduler/v1/README.md deleted file mode 100644 index 90fa2a2d162..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Scheduler: Nodejs Client diff --git a/owl-bot-staging/google-cloud-scheduler/v1/package.json b/owl-bot-staging/google-cloud-scheduler/v1/package.json deleted file mode 100644 index c3738ba2d1a..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/scheduler", - "version": "0.1.0", - "description": "Scheduler client for Node.js", - "repository": "googleapis/nodejs-scheduler", - "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 scheduler", - "scheduler", - "cloud scheduler" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/cloudscheduler.proto b/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/cloudscheduler.proto deleted file mode 100644 index b6b594b2b62..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/cloudscheduler.proto +++ /dev/null @@ -1,287 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.scheduler.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/scheduler/v1/job.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option go_package = "cloud.google.com/go/scheduler/apiv1/schedulerpb;schedulerpb"; -option java_multiple_files = true; -option java_outer_classname = "SchedulerProto"; -option java_package = "com.google.cloud.scheduler.v1"; -option objc_class_prefix = "SCHEDULER"; - -// The Cloud Scheduler API allows external entities to reliably -// schedule asynchronous jobs. -service CloudScheduler { - option (google.api.default_host) = "cloudscheduler.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Lists jobs. - rpc ListJobs(ListJobsRequest) returns (ListJobsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/jobs" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets a job. - rpc GetJob(GetJobRequest) returns (Job) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/jobs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a job. - rpc CreateJob(CreateJobRequest) returns (Job) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/jobs" - body: "job" - }; - option (google.api.method_signature) = "parent,job"; - } - - // Updates a job. - // - // If successful, the updated [Job][google.cloud.scheduler.v1.Job] is - // returned. If the job does not exist, `NOT_FOUND` is returned. - // - // If UpdateJob does not successfully return, it is possible for the - // job to be in an - // [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1.Job.State.UPDATE_FAILED] - // state. A job in this state may not be executed. If this happens, retry the - // UpdateJob request until a successful response is received. - rpc UpdateJob(UpdateJobRequest) returns (Job) { - option (google.api.http) = { - patch: "/v1/{job.name=projects/*/locations/*/jobs/*}" - body: "job" - }; - option (google.api.method_signature) = "job,update_mask"; - } - - // Deletes a job. - rpc DeleteJob(DeleteJobRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/jobs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Pauses a job. - // - // If a job is paused then the system will stop executing the job - // until it is re-enabled via - // [ResumeJob][google.cloud.scheduler.v1.CloudScheduler.ResumeJob]. The state - // of the job is stored in [state][google.cloud.scheduler.v1.Job.state]; if - // paused it will be set to - // [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. A job must - // be in [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED] to - // be paused. - rpc PauseJob(PauseJobRequest) returns (Job) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/jobs/*}:pause" - body: "*" - }; - option (google.api.method_signature) = "name"; - } - - // Resume a job. - // - // This method reenables a job after it has been - // [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. The state - // of a job is stored in [Job.state][google.cloud.scheduler.v1.Job.state]; - // after calling this method it will be set to - // [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED]. A job - // must be in [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED] - // to be resumed. - rpc ResumeJob(ResumeJobRequest) returns (Job) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/jobs/*}:resume" - body: "*" - }; - option (google.api.method_signature) = "name"; - } - - // Forces a job to run now. - // - // When this method is called, Cloud Scheduler will dispatch the job, even - // if the job is already running. - rpc RunJob(RunJobRequest) returns (Job) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/jobs/*}:run" - body: "*" - }; - option (google.api.method_signature) = "name"; - } -} - -// Request message for listing jobs using -// [ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs]. -message ListJobsRequest { - // Required. The location name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "cloudscheduler.googleapis.com/Job" - } - ]; - - // Requested page size. - // - // The maximum page size is 500. If unspecified, the page size will - // be the maximum. Fewer jobs than requested might be returned, - // even if more jobs exist; use next_page_token to determine if more - // jobs exist. - int32 page_size = 5; - - // A token identifying a page of results the server will return. To - // request the first page results, page_token must be empty. To - // request the next page of results, page_token must be the value of - // [next_page_token][google.cloud.scheduler.v1.ListJobsResponse.next_page_token] - // returned from the previous call to - // [ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs]. It is an - // error to switch the value of - // [filter][google.cloud.scheduler.v1.ListJobsRequest.filter] or - // [order_by][google.cloud.scheduler.v1.ListJobsRequest.order_by] while - // iterating through pages. - string page_token = 6; -} - -// Response message for listing jobs using -// [ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs]. -message ListJobsResponse { - // The list of jobs. - repeated Job jobs = 1; - - // A token to retrieve next page of results. Pass this value in the - // [page_token][google.cloud.scheduler.v1.ListJobsRequest.page_token] field in - // the subsequent call to - // [ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs] to retrieve - // the next page of results. If this is empty it indicates that there are no - // more results through which to paginate. - // - // The page token is valid for only 2 hours. - string next_page_token = 2; -} - -// Request message for -// [GetJob][google.cloud.scheduler.v1.CloudScheduler.GetJob]. -message GetJobRequest { - // Required. The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudscheduler.googleapis.com/Job" - } - ]; -} - -// Request message for -// [CreateJob][google.cloud.scheduler.v1.CloudScheduler.CreateJob]. -message CreateJobRequest { - // Required. The location name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "cloudscheduler.googleapis.com/Job" - } - ]; - - // Required. The job to add. The user can optionally specify a name for the - // job in [name][google.cloud.scheduler.v1.Job.name]. - // [name][google.cloud.scheduler.v1.Job.name] cannot be the same as an - // existing job. If a name is not specified then the system will - // generate a random unique name that will be returned - // ([name][google.cloud.scheduler.v1.Job.name]) in the response. - Job job = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for -// [UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob]. -message UpdateJobRequest { - // Required. The new job properties. - // [name][google.cloud.scheduler.v1.Job.name] must be specified. - // - // Output only fields cannot be modified using UpdateJob. - // Any value specified for an output only field will be ignored. - Job job = 1 [(google.api.field_behavior) = REQUIRED]; - - // A mask used to specify which fields of the job are being updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for deleting a job using -// [DeleteJob][google.cloud.scheduler.v1.CloudScheduler.DeleteJob]. -message DeleteJobRequest { - // Required. The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudscheduler.googleapis.com/Job" - } - ]; -} - -// Request message for -// [PauseJob][google.cloud.scheduler.v1.CloudScheduler.PauseJob]. -message PauseJobRequest { - // Required. The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudscheduler.googleapis.com/Job" - } - ]; -} - -// Request message for -// [ResumeJob][google.cloud.scheduler.v1.CloudScheduler.ResumeJob]. -message ResumeJobRequest { - // Required. The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudscheduler.googleapis.com/Job" - } - ]; -} - -// Request message for forcing a job to run now using -// [RunJob][google.cloud.scheduler.v1.CloudScheduler.RunJob]. -message RunJobRequest { - // Required. The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudscheduler.googleapis.com/Job" - } - ]; -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/job.proto b/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/job.proto deleted file mode 100644 index e12e589efe9..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/job.proto +++ /dev/null @@ -1,259 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.scheduler.v1; - -import "google/api/resource.proto"; -import "google/cloud/scheduler/v1/target.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option go_package = "cloud.google.com/go/scheduler/apiv1/schedulerpb;schedulerpb"; -option java_multiple_files = true; -option java_outer_classname = "JobProto"; -option java_package = "com.google.cloud.scheduler.v1"; - -// Configuration for a job. -// The maximum allowed size for a job is 1MB. -message Job { - option (google.api.resource) = { - type: "cloudscheduler.googleapis.com/Job" - pattern: "projects/{project}/locations/{location}/jobs/{job}" - }; - - // State of the job. - enum State { - // Unspecified state. - STATE_UNSPECIFIED = 0; - - // The job is executing normally. - ENABLED = 1; - - // The job is paused by the user. It will not execute. A user can - // intentionally pause the job using - // [PauseJobRequest][google.cloud.scheduler.v1.PauseJobRequest]. - PAUSED = 2; - - // The job is disabled by the system due to error. The user - // cannot directly set a job to be disabled. - DISABLED = 3; - - // The job state resulting from a failed - // [CloudScheduler.UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob] - // operation. To recover a job from this state, retry - // [CloudScheduler.UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob] - // until a successful response is received. - UPDATE_FAILED = 4; - } - - // Optionally caller-specified in - // [CreateJob][google.cloud.scheduler.v1.CloudScheduler.CreateJob], after - // which it becomes output only. - // - // The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - // - // * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]), - // hyphens (-), colons (:), or periods (.). - // For more information, see - // [Identifying - // projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects) - // * `LOCATION_ID` is the canonical ID for the job's location. - // The list of available locations can be obtained by calling - // [ListLocations][google.cloud.location.Locations.ListLocations]. - // For more information, see https://cloud.google.com/about/locations/. - // * `JOB_ID` can contain only letters ([A-Za-z]), numbers ([0-9]), - // hyphens (-), or underscores (_). The maximum length is 500 characters. - string name = 1; - - // Optionally caller-specified in - // [CreateJob][google.cloud.scheduler.v1.CloudScheduler.CreateJob] or - // [UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob]. - // - // A human-readable description for the job. This string must not contain - // more than 500 characters. - string description = 2; - - // Required. - // - // Delivery settings containing destination and parameters. - oneof target { - // Pub/Sub target. - PubsubTarget pubsub_target = 4; - - // App Engine HTTP target. - AppEngineHttpTarget app_engine_http_target = 5; - - // HTTP target. - HttpTarget http_target = 6; - } - - // Required, except when used with - // [UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob]. - // - // Describes the schedule on which the job will be executed. - // - // The schedule can be either of the following types: - // - // * [Crontab](https://en.wikipedia.org/wiki/Cron#Overview) - // * English-like - // [schedule](https://cloud.google.com/scheduler/docs/configuring/cron-job-schedules) - // - // As a general rule, execution `n + 1` of a job will not begin - // until execution `n` has finished. Cloud Scheduler will never - // allow two simultaneously outstanding executions. For example, - // this implies that if the `n+1`th execution is scheduled to run at - // 16:00 but the `n`th execution takes until 16:15, the `n+1`th - // execution will not start until `16:15`. - // A scheduled start time will be delayed if the previous - // execution has not ended when its scheduled time occurs. - // - // If [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count] > 0 and - // a job attempt fails, the job will be tried a total of - // [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count] times, - // with exponential backoff, until the next scheduled start time. - string schedule = 20; - - // Specifies the time zone to be used in interpreting - // [schedule][google.cloud.scheduler.v1.Job.schedule]. The value of this field - // must be a time zone name from the [tz - // database](http://en.wikipedia.org/wiki/Tz_database). - // - // Note that some time zones include a provision for - // daylight savings time. The rules for daylight saving time are - // determined by the chosen tz. For UTC use the string "utc". If a - // time zone is not specified, the default will be in UTC (also known - // as GMT). - string time_zone = 21; - - // Output only. The creation time of the job. - google.protobuf.Timestamp user_update_time = 9; - - // Output only. State of the job. - State state = 10; - - // Output only. The response from the target for the last attempted execution. - google.rpc.Status status = 11; - - // Output only. The next time the job is scheduled. Note that this may be a - // retry of a previously failed attempt or the next execution time - // according to the schedule. - google.protobuf.Timestamp schedule_time = 17; - - // Output only. The time the last job attempt started. - google.protobuf.Timestamp last_attempt_time = 18; - - // Settings that determine the retry behavior. - RetryConfig retry_config = 19; - - // The deadline for job attempts. If the request handler does not respond by - // this deadline then the request is cancelled and the attempt is marked as a - // `DEADLINE_EXCEEDED` failure. The failed attempt can be viewed in - // execution logs. Cloud Scheduler will retry the job according - // to the [RetryConfig][google.cloud.scheduler.v1.RetryConfig]. - // - // The default and the allowed values depend on the type of target: - // - // * For [HTTP targets][google.cloud.scheduler.v1.Job.http_target], the - // default is 3 minutes. The deadline must be in the interval [15 seconds, 30 - // minutes]. - // - // * For [App Engine HTTP - // targets][google.cloud.scheduler.v1.Job.app_engine_http_target], 0 indicates - // that the request has the default deadline. The default deadline depends on - // the scaling type of the service: 10 minutes for standard apps with - // automatic scaling, 24 hours for standard apps with manual and basic - // scaling, and 60 minutes for flex apps. If the request deadline is set, it - // must be in the interval [15 seconds, 24 hours 15 seconds]. - // - // * For [Pub/Sub targets][google.cloud.scheduler.v1.Job.pubsub_target], this - // field is ignored. - google.protobuf.Duration attempt_deadline = 22; -} - -// Settings that determine the retry behavior. -// -// By default, if a job does not complete successfully (meaning that -// an acknowledgement is not received from the handler, then it will be retried -// with exponential backoff according to the settings in -// [RetryConfig][google.cloud.scheduler.v1.RetryConfig]. -message RetryConfig { - // The number of attempts that the system will make to run a job using the - // exponential backoff procedure described by - // [max_doublings][google.cloud.scheduler.v1.RetryConfig.max_doublings]. - // - // The default value of retry_count is zero. - // - // If retry_count is zero, a job attempt will *not* be retried if - // it fails. Instead the Cloud Scheduler system will wait for the - // next scheduled execution time. - // - // If retry_count is set to a non-zero number then Cloud Scheduler - // will retry failed attempts, using exponential backoff, - // retry_count times, or until the next scheduled execution time, - // whichever comes first. - // - // Values greater than 5 and negative values are not allowed. - int32 retry_count = 1; - - // The time limit for retrying a failed job, measured from time when an - // execution was first attempted. If specified with - // [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count], the job - // will be retried until both limits are reached. - // - // The default value for max_retry_duration is zero, which means retry - // duration is unlimited. - google.protobuf.Duration max_retry_duration = 2; - - // The minimum amount of time to wait before retrying a job after - // it fails. - // - // The default value of this field is 5 seconds. - google.protobuf.Duration min_backoff_duration = 3; - - // The maximum amount of time to wait before retrying a job after - // it fails. - // - // The default value of this field is 1 hour. - google.protobuf.Duration max_backoff_duration = 4; - - // The time between retries will double `max_doublings` times. - // - // A job's retry interval starts at - // [min_backoff_duration][google.cloud.scheduler.v1.RetryConfig.min_backoff_duration], - // then doubles `max_doublings` times, then increases linearly, and finally - // retries at intervals of - // [max_backoff_duration][google.cloud.scheduler.v1.RetryConfig.max_backoff_duration] - // up to [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count] - // times. - // - // For example, if - // [min_backoff_duration][google.cloud.scheduler.v1.RetryConfig.min_backoff_duration] - // is 10s, - // [max_backoff_duration][google.cloud.scheduler.v1.RetryConfig.max_backoff_duration] - // is 300s, and `max_doublings` is 3, then the a job will first be retried in - // 10s. The retry interval will double three times, and then increase linearly - // by 2^3 * 10s. Finally, the job will retry at intervals of - // [max_backoff_duration][google.cloud.scheduler.v1.RetryConfig.max_backoff_duration] - // until the job has been attempted - // [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count] times. - // Thus, the requests will retry at 10s, 20s, 40s, 80s, 160s, 240s, 300s, - // 300s, .... - // - // The default value of this field is 5. - int32 max_doublings = 5; -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/target.proto b/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/target.proto deleted file mode 100644 index 12a797b06bc..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/target.proto +++ /dev/null @@ -1,369 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.scheduler.v1; - -import "google/api/resource.proto"; - -option go_package = "cloud.google.com/go/scheduler/apiv1/schedulerpb;schedulerpb"; -option java_multiple_files = true; -option java_outer_classname = "TargetProto"; -option java_package = "com.google.cloud.scheduler.v1"; -option (google.api.resource_definition) = { - type: "pubsub.googleapis.com/Topic" - pattern: "projects/{project}/topics/{topic}" -}; - -// Http target. The job will be pushed to the job handler by means of -// an HTTP request via an -// [http_method][google.cloud.scheduler.v1.HttpTarget.http_method] such as HTTP -// POST, HTTP GET, etc. The job is acknowledged by means of an HTTP -// response code in the range [200 - 299]. A failure to receive a response -// constitutes a failed execution. For a redirected request, the response -// returned by the redirected request is considered. -message HttpTarget { - // Required. The full URI path that the request will be sent to. This string - // must begin with either "http://" or "https://". Some examples of - // valid values for [uri][google.cloud.scheduler.v1.HttpTarget.uri] are: - // `http://acme.com` and `https://acme.com/sales:8080`. Cloud Scheduler will - // encode some characters for safety and compatibility. The maximum allowed - // URL length is 2083 characters after encoding. - string uri = 1; - - // Which HTTP method to use for the request. - HttpMethod http_method = 2; - - // The user can specify HTTP request headers to send with the job's - // HTTP request. This map contains the header field names and - // values. Repeated headers are not supported, but a header value can - // contain commas. These headers represent a subset of the headers - // that will accompany the job's HTTP request. Some HTTP request - // headers will be ignored or replaced. A partial list of headers that - // will be ignored or replaced is below: - // - Host: This will be computed by Cloud Scheduler and derived from - // [uri][google.cloud.scheduler.v1.HttpTarget.uri]. - // * `Content-Length`: This will be computed by Cloud Scheduler. - // * `User-Agent`: This will be set to `"Google-Cloud-Scheduler"`. - // * `X-Google-*`: Google internal use only. - // * `X-AppEngine-*`: Google internal use only. - // * `X-CloudScheduler`: This header will be set to true. - // * `X-CloudScheduler-JobName`: This header will contain the job name. - // * `X-CloudScheduler-ScheduleTime`: For Cloud Scheduler jobs specified in - // the unix-cron format, this header will contain the job schedule time in - // RFC3339 UTC "Zulu" format. - // - // The total size of headers must be less than 80KB. - map headers = 3; - - // HTTP request body. A request body is allowed only if the HTTP - // method is POST, PUT, or PATCH. It is an error to set body on a job with an - // incompatible [HttpMethod][google.cloud.scheduler.v1.HttpMethod]. - bytes body = 4; - - // The mode for generating an `Authorization` header for HTTP requests. - // - // If specified, all `Authorization` headers in the - // [HttpTarget.headers][google.cloud.scheduler.v1.HttpTarget.headers] field - // will be overridden. - oneof authorization_header { - // If specified, an - // [OAuth token](https://developers.google.com/identity/protocols/OAuth2) - // will be generated and attached as an `Authorization` header in the HTTP - // request. - // - // This type of authorization should generally only be used when calling - // Google APIs hosted on *.googleapis.com. - OAuthToken oauth_token = 5; - - // If specified, an - // [OIDC](https://developers.google.com/identity/protocols/OpenIDConnect) - // token will be generated and attached as an `Authorization` header in the - // HTTP request. - // - // This type of authorization can be used for many scenarios, including - // calling Cloud Run, or endpoints where you intend to validate the token - // yourself. - OidcToken oidc_token = 6; - } -} - -// App Engine target. The job will be pushed to a job handler by means -// of an HTTP request via an -// [http_method][google.cloud.scheduler.v1.AppEngineHttpTarget.http_method] such -// as HTTP POST, HTTP GET, etc. The job is acknowledged by means of an -// HTTP response code in the range [200 - 299]. Error 503 is -// considered an App Engine system error instead of an application -// error. Requests returning error 503 will be retried regardless of -// retry configuration and not counted against retry counts. Any other -// response code, or a failure to receive a response before the -// deadline, constitutes a failed attempt. -message AppEngineHttpTarget { - // The HTTP method to use for the request. PATCH and OPTIONS are not - // permitted. - HttpMethod http_method = 1; - - // App Engine Routing setting for the job. - AppEngineRouting app_engine_routing = 2; - - // The relative URI. - // - // The relative URL must begin with "/" and must be a valid HTTP relative URL. - // It can contain a path, query string arguments, and `#` fragments. - // If the relative URL is empty, then the root path "/" will be used. - // No spaces are allowed, and the maximum length allowed is 2083 characters. - string relative_uri = 3; - - // HTTP request headers. - // - // This map contains the header field names and values. Headers can be set - // when the job is created. - // - // Cloud Scheduler sets some headers to default values: - // - // * `User-Agent`: By default, this header is - // `"AppEngine-Google; (+http://code.google.com/appengine)"`. - // This header can be modified, but Cloud Scheduler will append - // `"AppEngine-Google; (+http://code.google.com/appengine)"` to the - // modified `User-Agent`. - // * `X-CloudScheduler`: This header will be set to true. - // * `X-CloudScheduler-JobName`: This header will contain the job name. - // * `X-CloudScheduler-ScheduleTime`: For Cloud Scheduler jobs specified in - // the unix-cron format, this header will contain the job schedule time in - // RFC3339 UTC "Zulu" format. - // - // If the job has an - // [body][google.cloud.scheduler.v1.AppEngineHttpTarget.body], Cloud Scheduler - // sets the following headers: - // - // * `Content-Type`: By default, the `Content-Type` header is set to - // `"application/octet-stream"`. The default can be overridden by explictly - // setting `Content-Type` to a particular media type when the job is - // created. - // For example, `Content-Type` can be set to `"application/json"`. - // * `Content-Length`: This is computed by Cloud Scheduler. This value is - // output only. It cannot be changed. - // - // The headers below are output only. They cannot be set or overridden: - // - // * `X-Google-*`: For Google internal use only. - // * `X-AppEngine-*`: For Google internal use only. - // - // In addition, some App Engine headers, which contain - // job-specific information, are also be sent to the job handler. - map headers = 4; - - // Body. - // - // HTTP request body. A request body is allowed only if the HTTP method is - // POST or PUT. It will result in invalid argument error to set a body on a - // job with an incompatible - // [HttpMethod][google.cloud.scheduler.v1.HttpMethod]. - bytes body = 5; -} - -// Pub/Sub target. The job will be delivered by publishing a message to -// the given Pub/Sub topic. -message PubsubTarget { - // Required. The name of the Cloud Pub/Sub topic to which messages will - // be published when a job is delivered. The topic name must be in the - // same format as required by Pub/Sub's - // [PublishRequest.name](https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#publishrequest), - // for example `projects/PROJECT_ID/topics/TOPIC_ID`. - // - // The topic must be in the same project as the Cloud Scheduler job. - string topic_name = 1 [ - (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" } - ]; - - // The message payload for PubsubMessage. - // - // Pubsub message must contain either non-empty data, or at least one - // attribute. - bytes data = 3; - - // Attributes for PubsubMessage. - // - // Pubsub message must contain either non-empty data, or at least one - // attribute. - map attributes = 4; -} - -// App Engine Routing. -// -// For more information about services, versions, and instances see -// [An Overview of App -// Engine](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine), -// [Microservices Architecture on Google App -// Engine](https://cloud.google.com/appengine/docs/python/microservices-on-app-engine), -// [App Engine Standard request -// routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed), -// and [App Engine Flex request -// routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed). -message AppEngineRouting { - // App service. - // - // By default, the job is sent to the service which is the default - // service when the job is attempted. - string service = 1; - - // App version. - // - // By default, the job is sent to the version which is the default - // version when the job is attempted. - string version = 2; - - // App instance. - // - // By default, the job is sent to an instance which is available when - // the job is attempted. - // - // Requests can only be sent to a specific instance if - // [manual scaling is used in App Engine - // Standard](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine?#scaling_types_and_instance_classes). - // App Engine Flex does not support instances. For more information, see - // [App Engine Standard request - // routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed) - // and [App Engine Flex request - // routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed). - string instance = 3; - - // Output only. The host that the job is sent to. - // - // For more information about how App Engine requests are routed, see - // [here](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed). - // - // The host is constructed as: - // - // - // * `host = [application_domain_name]`
- // `| [service] + '.' + [application_domain_name]`
- // `| [version] + '.' + [application_domain_name]`
- // `| [version_dot_service]+ '.' + [application_domain_name]`
- // `| [instance] + '.' + [application_domain_name]`
- // `| [instance_dot_service] + '.' + [application_domain_name]`
- // `| [instance_dot_version] + '.' + [application_domain_name]`
- // `| [instance_dot_version_dot_service] + '.' + [application_domain_name]` - // - // * `application_domain_name` = The domain name of the app, for - // example .appspot.com, which is associated with the - // job's project ID. - // - // * `service =` [service][google.cloud.scheduler.v1.AppEngineRouting.service] - // - // * `version =` [version][google.cloud.scheduler.v1.AppEngineRouting.version] - // - // * `version_dot_service =` - // [version][google.cloud.scheduler.v1.AppEngineRouting.version] `+ '.' +` - // [service][google.cloud.scheduler.v1.AppEngineRouting.service] - // - // * `instance =` - // [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] - // - // * `instance_dot_service =` - // [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] `+ '.' +` - // [service][google.cloud.scheduler.v1.AppEngineRouting.service] - // - // * `instance_dot_version =` - // [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] `+ '.' +` - // [version][google.cloud.scheduler.v1.AppEngineRouting.version] - // - // * `instance_dot_version_dot_service =` - // [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] `+ '.' +` - // [version][google.cloud.scheduler.v1.AppEngineRouting.version] `+ '.' +` - // [service][google.cloud.scheduler.v1.AppEngineRouting.service] - // - // - // If [service][google.cloud.scheduler.v1.AppEngineRouting.service] is empty, - // then the job will be sent to the service which is the default service when - // the job is attempted. - // - // If [version][google.cloud.scheduler.v1.AppEngineRouting.version] is empty, - // then the job will be sent to the version which is the default version when - // the job is attempted. - // - // If [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] is - // empty, then the job will be sent to an instance which is available when the - // job is attempted. - // - // If [service][google.cloud.scheduler.v1.AppEngineRouting.service], - // [version][google.cloud.scheduler.v1.AppEngineRouting.version], or - // [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] is invalid, - // then the job will be sent to the default version of the default service - // when the job is attempted. - string host = 4; -} - -// The HTTP method used to execute the job. -enum HttpMethod { - // HTTP method unspecified. Defaults to POST. - HTTP_METHOD_UNSPECIFIED = 0; - - // HTTP POST - POST = 1; - - // HTTP GET - GET = 2; - - // HTTP HEAD - HEAD = 3; - - // HTTP PUT - PUT = 4; - - // HTTP DELETE - DELETE = 5; - - // HTTP PATCH - PATCH = 6; - - // HTTP OPTIONS - OPTIONS = 7; -} - -// Contains information needed for generating an -// [OAuth token](https://developers.google.com/identity/protocols/OAuth2). -// This type of authorization should generally only be used when calling Google -// APIs hosted on *.googleapis.com. -message OAuthToken { - // [Service account email](https://cloud.google.com/iam/docs/service-accounts) - // to be used for generating OAuth token. - // The service account must be within the same project as the job. The caller - // must have iam.serviceAccounts.actAs permission for the service account. - string service_account_email = 1; - - // OAuth scope to be used for generating OAuth access token. - // If not specified, "https://www.googleapis.com/auth/cloud-platform" - // will be used. - string scope = 2; -} - -// Contains information needed for generating an -// [OpenID Connect -// token](https://developers.google.com/identity/protocols/OpenIDConnect). -// This type of authorization can be used for many scenarios, including -// calling Cloud Run, or endpoints where you intend to validate the token -// yourself. -message OidcToken { - // [Service account email](https://cloud.google.com/iam/docs/service-accounts) - // to be used for generating OIDC token. - // The service account must be within the same project as the job. The caller - // must have iam.serviceAccounts.actAs permission for the service account. - string service_account_email = 1; - - // Audience to be used when generating OIDC token. If not specified, the URI - // specified in target will be used. - string audience = 2; -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.create_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.create_job.js deleted file mode 100644 index 988e2d72be2..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.create_job.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, job) { - // [START cloudscheduler_v1_generated_CloudScheduler_CreateJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - */ - // const parent = 'abc123' - /** - * Required. The job to add. The user can optionally specify a name for the - * job in name google.cloud.scheduler.v1.Job.name. - * name google.cloud.scheduler.v1.Job.name cannot be the same as an - * existing job. If a name is not specified then the system will - * generate a random unique name that will be returned - * (name google.cloud.scheduler.v1.Job.name) in the response. - */ - // const job = {} - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callCreateJob() { - // Construct request - const request = { - parent, - job, - }; - - // Run request - const response = await schedulerClient.createJob(request); - console.log(response); - } - - callCreateJob(); - // [END cloudscheduler_v1_generated_CloudScheduler_CreateJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.delete_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.delete_job.js deleted file mode 100644 index cdb25bf704f..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.delete_job.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 cloudscheduler_v1_generated_CloudScheduler_DeleteJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - */ - // const name = 'abc123' - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callDeleteJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await schedulerClient.deleteJob(request); - console.log(response); - } - - callDeleteJob(); - // [END cloudscheduler_v1_generated_CloudScheduler_DeleteJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.get_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.get_job.js deleted file mode 100644 index ab4396baf0e..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.get_job.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 cloudscheduler_v1_generated_CloudScheduler_GetJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - */ - // const name = 'abc123' - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callGetJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await schedulerClient.getJob(request); - console.log(response); - } - - callGetJob(); - // [END cloudscheduler_v1_generated_CloudScheduler_GetJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.list_jobs.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.list_jobs.js deleted file mode 100644 index bca6c481609..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.list_jobs.js +++ /dev/null @@ -1,85 +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 cloudscheduler_v1_generated_CloudScheduler_ListJobs_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - */ - // const parent = 'abc123' - /** - * Requested page size. - * The maximum page size is 500. If unspecified, the page size will - * be the maximum. Fewer jobs than requested might be returned, - * even if more jobs exist; use next_page_token to determine if more - * jobs exist. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results the server will return. To - * request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * next_page_token google.cloud.scheduler.v1.ListJobsResponse.next_page_token - * returned from the previous call to - * ListJobs google.cloud.scheduler.v1.CloudScheduler.ListJobs. It is an - * error to switch the value of - * filter google.cloud.scheduler.v1.ListJobsRequest.filter or - * order_by google.cloud.scheduler.v1.ListJobsRequest.order_by while - * iterating through pages. - */ - // const pageToken = 'abc123' - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callListJobs() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await schedulerClient.listJobsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListJobs(); - // [END cloudscheduler_v1_generated_CloudScheduler_ListJobs_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.pause_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.pause_job.js deleted file mode 100644 index becc78f8bc3..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.pause_job.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 cloudscheduler_v1_generated_CloudScheduler_PauseJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - */ - // const name = 'abc123' - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callPauseJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await schedulerClient.pauseJob(request); - console.log(response); - } - - callPauseJob(); - // [END cloudscheduler_v1_generated_CloudScheduler_PauseJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.resume_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.resume_job.js deleted file mode 100644 index fbf390f598c..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.resume_job.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 cloudscheduler_v1_generated_CloudScheduler_ResumeJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - */ - // const name = 'abc123' - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callResumeJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await schedulerClient.resumeJob(request); - console.log(response); - } - - callResumeJob(); - // [END cloudscheduler_v1_generated_CloudScheduler_ResumeJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.run_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.run_job.js deleted file mode 100644 index ab91a903b8b..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.run_job.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 cloudscheduler_v1_generated_CloudScheduler_RunJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - */ - // const name = 'abc123' - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callRunJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await schedulerClient.runJob(request); - console.log(response); - } - - callRunJob(); - // [END cloudscheduler_v1_generated_CloudScheduler_RunJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.update_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.update_job.js deleted file mode 100644 index fc859a2c552..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.update_job.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(job) { - // [START cloudscheduler_v1_generated_CloudScheduler_UpdateJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The new job properties. - * name google.cloud.scheduler.v1.Job.name must be specified. - * Output only fields cannot be modified using UpdateJob. - * Any value specified for an output only field will be ignored. - */ - // const job = {} - /** - * A mask used to specify which fields of the job are being updated. - */ - // const updateMask = {} - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callUpdateJob() { - // Construct request - const request = { - job, - }; - - // Run request - const response = await schedulerClient.updateJob(request); - console.log(response); - } - - callUpdateJob(); - // [END cloudscheduler_v1_generated_CloudScheduler_UpdateJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/snippet_metadata_google.cloud.scheduler.v1.json b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/snippet_metadata_google.cloud.scheduler.v1.json deleted file mode 100644 index 002b7a4b866..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/snippet_metadata_google.cloud.scheduler.v1.json +++ /dev/null @@ -1,351 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-scheduler", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.scheduler.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "cloudscheduler_v1_generated_CloudScheduler_ListJobs_async", - "title": "scheduler listJobs Sample", - "origin": "API_DEFINITION", - "description": " Lists jobs.", - "canonical": true, - "file": "cloud_scheduler.list_jobs.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 77, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListJobs", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.ListJobs", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.scheduler.v1.ListJobsResponse", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" - }, - "method": { - "shortName": "ListJobs", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.ListJobs", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1_generated_CloudScheduler_GetJob_async", - "title": "scheduler getJob Sample", - "origin": "API_DEFINITION", - "description": " Gets a job.", - "canonical": true, - "file": "cloud_scheduler.get_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.GetJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.scheduler.v1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" - }, - "method": { - "shortName": "GetJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.GetJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1_generated_CloudScheduler_CreateJob_async", - "title": "scheduler createJob Sample", - "origin": "API_DEFINITION", - "description": " Creates a job.", - "canonical": true, - "file": "cloud_scheduler.create_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.CreateJob", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "job", - "type": ".google.cloud.scheduler.v1.Job" - } - ], - "resultType": ".google.cloud.scheduler.v1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" - }, - "method": { - "shortName": "CreateJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.CreateJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1_generated_CloudScheduler_UpdateJob_async", - "title": "scheduler updateJob Sample", - "origin": "API_DEFINITION", - "description": " Updates a job. If successful, the updated [Job][google.cloud.scheduler.v1.Job] is returned. If the job does not exist, `NOT_FOUND` is returned. If UpdateJob does not successfully return, it is possible for the job to be in an [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1.Job.State.UPDATE_FAILED] state. A job in this state may not be executed. If this happens, retry the UpdateJob request until a successful response is received.", - "canonical": true, - "file": "cloud_scheduler.update_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.UpdateJob", - "async": true, - "parameters": [ - { - "name": "job", - "type": ".google.cloud.scheduler.v1.Job" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.scheduler.v1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" - }, - "method": { - "shortName": "UpdateJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.UpdateJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1_generated_CloudScheduler_DeleteJob_async", - "title": "scheduler deleteJob Sample", - "origin": "API_DEFINITION", - "description": " Deletes a job.", - "canonical": true, - "file": "cloud_scheduler.delete_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.DeleteJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" - }, - "method": { - "shortName": "DeleteJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.DeleteJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1_generated_CloudScheduler_PauseJob_async", - "title": "scheduler pauseJob Sample", - "origin": "API_DEFINITION", - "description": " Pauses a job. If a job is paused then the system will stop executing the job until it is re-enabled via [ResumeJob][google.cloud.scheduler.v1.CloudScheduler.ResumeJob]. The state of the job is stored in [state][google.cloud.scheduler.v1.Job.state]; if paused it will be set to [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. A job must be in [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED] to be paused.", - "canonical": true, - "file": "cloud_scheduler.pause_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PauseJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.PauseJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.scheduler.v1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" - }, - "method": { - "shortName": "PauseJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.PauseJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1_generated_CloudScheduler_ResumeJob_async", - "title": "scheduler resumeJob Sample", - "origin": "API_DEFINITION", - "description": " Resume a job. This method reenables a job after it has been [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. The state of a job is stored in [Job.state][google.cloud.scheduler.v1.Job.state]; after calling this method it will be set to [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED]. A job must be in [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED] to be resumed.", - "canonical": true, - "file": "cloud_scheduler.resume_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ResumeJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.ResumeJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.scheduler.v1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" - }, - "method": { - "shortName": "ResumeJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.ResumeJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1_generated_CloudScheduler_RunJob_async", - "title": "scheduler runJob Sample", - "origin": "API_DEFINITION", - "description": " Forces a job to run now. When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running.", - "canonical": true, - "file": "cloud_scheduler.run_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RunJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.RunJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.scheduler.v1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" - }, - "method": { - "shortName": "RunJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.RunJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1.CloudScheduler" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/index.ts b/owl-bot-staging/google-cloud-scheduler/v1/src/index.ts deleted file mode 100644 index b5209cd98c9..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/src/index.ts +++ /dev/null @@ -1,25 +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 v1 from './v1'; -const CloudSchedulerClient = v1.CloudSchedulerClient; -type CloudSchedulerClient = v1.CloudSchedulerClient; -export {v1, CloudSchedulerClient}; -export default {v1, CloudSchedulerClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client.ts b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client.ts deleted file mode 100644 index eda3ad0dfa8..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client.ts +++ /dev/null @@ -1,1281 +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, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/cloud_scheduler_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './cloud_scheduler_client_config.json'; -const version = require('../../../package.json').version; - -/** - * The Cloud Scheduler API allows external entities to reliably - * schedule asynchronous jobs. - * @class - * @memberof v1 - */ -export class CloudSchedulerClient { - 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}; - cloudSchedulerStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CloudSchedulerClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 CloudSchedulerClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof CloudSchedulerClient; - 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 { - 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 = { - jobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listJobs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'jobs') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.scheduler.v1.CloudScheduler', 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.cloudSchedulerStub) { - return this.cloudSchedulerStub; - } - - // Put together the "service stub" for - // google.cloud.scheduler.v1.CloudScheduler. - this.cloudSchedulerStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.scheduler.v1.CloudScheduler') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.scheduler.v1.CloudScheduler, - 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 cloudSchedulerStubMethods = - ['listJobs', 'getJob', 'createJob', 'updateJob', 'deleteJob', 'pauseJob', 'resumeJob', 'runJob']; - for (const methodName of cloudSchedulerStubMethods) { - const callPromise = this.cloudSchedulerStub.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.cloudSchedulerStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudscheduler.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 'cloudscheduler.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 job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.scheduler.v1.Job|Job}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_scheduler.get_job.js - * region_tag:cloudscheduler_v1_generated_CloudScheduler_GetJob_async - */ - getJob( - request?: protos.google.cloud.scheduler.v1.IGetJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IGetJobRequest|undefined, {}|undefined - ]>; - getJob( - request: protos.google.cloud.scheduler.v1.IGetJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IGetJobRequest|null|undefined, - {}|null|undefined>): void; - getJob( - request: protos.google.cloud.scheduler.v1.IGetJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IGetJobRequest|null|undefined, - {}|null|undefined>): void; - getJob( - request?: protos.google.cloud.scheduler.v1.IGetJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IGetJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IGetJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IGetJobRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getJob(request, options, callback); - } -/** - * Creates a job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {google.cloud.scheduler.v1.Job} request.job - * Required. The job to add. The user can optionally specify a name for the - * job in {@link protos.google.cloud.scheduler.v1.Job.name|name}. - * {@link protos.google.cloud.scheduler.v1.Job.name|name} cannot be the same as an - * existing job. If a name is not specified then the system will - * generate a random unique name that will be returned - * ({@link protos.google.cloud.scheduler.v1.Job.name|name}) in the response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.scheduler.v1.Job|Job}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_scheduler.create_job.js - * region_tag:cloudscheduler_v1_generated_CloudScheduler_CreateJob_async - */ - createJob( - request?: protos.google.cloud.scheduler.v1.ICreateJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.ICreateJobRequest|undefined, {}|undefined - ]>; - createJob( - request: protos.google.cloud.scheduler.v1.ICreateJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.ICreateJobRequest|null|undefined, - {}|null|undefined>): void; - createJob( - request: protos.google.cloud.scheduler.v1.ICreateJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.ICreateJobRequest|null|undefined, - {}|null|undefined>): void; - createJob( - request?: protos.google.cloud.scheduler.v1.ICreateJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.ICreateJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.ICreateJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.ICreateJobRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createJob(request, options, callback); - } -/** - * Updates a job. - * - * If successful, the updated {@link protos.google.cloud.scheduler.v1.Job|Job} is - * returned. If the job does not exist, `NOT_FOUND` is returned. - * - * If UpdateJob does not successfully return, it is possible for the - * job to be in an - * {@link protos.google.cloud.scheduler.v1.Job.State.UPDATE_FAILED|Job.State.UPDATE_FAILED} - * state. A job in this state may not be executed. If this happens, retry the - * UpdateJob request until a successful response is received. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.scheduler.v1.Job} request.job - * Required. The new job properties. - * {@link protos.google.cloud.scheduler.v1.Job.name|name} must be specified. - * - * Output only fields cannot be modified using UpdateJob. - * Any value specified for an output only field will be ignored. - * @param {google.protobuf.FieldMask} request.updateMask - * A mask used to specify which fields of the job are being 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 protos.google.cloud.scheduler.v1.Job|Job}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_scheduler.update_job.js - * region_tag:cloudscheduler_v1_generated_CloudScheduler_UpdateJob_async - */ - updateJob( - request?: protos.google.cloud.scheduler.v1.IUpdateJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IUpdateJobRequest|undefined, {}|undefined - ]>; - updateJob( - request: protos.google.cloud.scheduler.v1.IUpdateJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IUpdateJobRequest|null|undefined, - {}|null|undefined>): void; - updateJob( - request: protos.google.cloud.scheduler.v1.IUpdateJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IUpdateJobRequest|null|undefined, - {}|null|undefined>): void; - updateJob( - request?: protos.google.cloud.scheduler.v1.IUpdateJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IUpdateJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IUpdateJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IUpdateJobRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'job.name': request.job!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateJob(request, options, callback); - } -/** - * Deletes a job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_scheduler.delete_job.js - * region_tag:cloudscheduler_v1_generated_CloudScheduler_DeleteJob_async - */ - deleteJob( - request?: protos.google.cloud.scheduler.v1.IDeleteJobRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1.IDeleteJobRequest|undefined, {}|undefined - ]>; - deleteJob( - request: protos.google.cloud.scheduler.v1.IDeleteJobRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): void; - deleteJob( - request: protos.google.cloud.scheduler.v1.IDeleteJobRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): void; - deleteJob( - request?: protos.google.cloud.scheduler.v1.IDeleteJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1.IDeleteJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1.IDeleteJobRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteJob(request, options, callback); - } -/** - * Pauses a job. - * - * If a job is paused then the system will stop executing the job - * until it is re-enabled via - * {@link protos.google.cloud.scheduler.v1.CloudScheduler.ResumeJob|ResumeJob}. The state - * of the job is stored in {@link protos.google.cloud.scheduler.v1.Job.state|state}; if - * paused it will be set to - * {@link protos.google.cloud.scheduler.v1.Job.State.PAUSED|Job.State.PAUSED}. A job must - * be in {@link protos.google.cloud.scheduler.v1.Job.State.ENABLED|Job.State.ENABLED} to - * be paused. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.scheduler.v1.Job|Job}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_scheduler.pause_job.js - * region_tag:cloudscheduler_v1_generated_CloudScheduler_PauseJob_async - */ - pauseJob( - request?: protos.google.cloud.scheduler.v1.IPauseJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IPauseJobRequest|undefined, {}|undefined - ]>; - pauseJob( - request: protos.google.cloud.scheduler.v1.IPauseJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IPauseJobRequest|null|undefined, - {}|null|undefined>): void; - pauseJob( - request: protos.google.cloud.scheduler.v1.IPauseJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IPauseJobRequest|null|undefined, - {}|null|undefined>): void; - pauseJob( - request?: protos.google.cloud.scheduler.v1.IPauseJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IPauseJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IPauseJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IPauseJobRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.pauseJob(request, options, callback); - } -/** - * Resume a job. - * - * This method reenables a job after it has been - * {@link protos.google.cloud.scheduler.v1.Job.State.PAUSED|Job.State.PAUSED}. The state - * of a job is stored in {@link protos.google.cloud.scheduler.v1.Job.state|Job.state}; - * after calling this method it will be set to - * {@link protos.google.cloud.scheduler.v1.Job.State.ENABLED|Job.State.ENABLED}. A job - * must be in {@link protos.google.cloud.scheduler.v1.Job.State.PAUSED|Job.State.PAUSED} - * to be resumed. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.scheduler.v1.Job|Job}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_scheduler.resume_job.js - * region_tag:cloudscheduler_v1_generated_CloudScheduler_ResumeJob_async - */ - resumeJob( - request?: protos.google.cloud.scheduler.v1.IResumeJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IResumeJobRequest|undefined, {}|undefined - ]>; - resumeJob( - request: protos.google.cloud.scheduler.v1.IResumeJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IResumeJobRequest|null|undefined, - {}|null|undefined>): void; - resumeJob( - request: protos.google.cloud.scheduler.v1.IResumeJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IResumeJobRequest|null|undefined, - {}|null|undefined>): void; - resumeJob( - request?: protos.google.cloud.scheduler.v1.IResumeJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IResumeJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IResumeJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IResumeJobRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.resumeJob(request, options, callback); - } -/** - * Forces a job to run now. - * - * When this method is called, Cloud Scheduler will dispatch the job, even - * if the job is already running. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.scheduler.v1.Job|Job}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_scheduler.run_job.js - * region_tag:cloudscheduler_v1_generated_CloudScheduler_RunJob_async - */ - runJob( - request?: protos.google.cloud.scheduler.v1.IRunJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IRunJobRequest|undefined, {}|undefined - ]>; - runJob( - request: protos.google.cloud.scheduler.v1.IRunJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IRunJobRequest|null|undefined, - {}|null|undefined>): void; - runJob( - request: protos.google.cloud.scheduler.v1.IRunJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IRunJobRequest|null|undefined, - {}|null|undefined>): void; - runJob( - request?: protos.google.cloud.scheduler.v1.IRunJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IRunJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IRunJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IRunJobRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.runJob(request, options, callback); - } - - /** - * Lists jobs. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {number} request.pageSize - * Requested page size. - * - * The maximum page size is 500. If unspecified, the page size will - * be the maximum. Fewer jobs than requested might be returned, - * even if more jobs exist; use next_page_token to determine if more - * jobs exist. - * @param {string} request.pageToken - * A token identifying a page of results the server will return. To - * request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.scheduler.v1.ListJobsResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.scheduler.v1.CloudScheduler.ListJobs|ListJobs}. It is an - * error to switch the value of - * {@link protos.google.cloud.scheduler.v1.ListJobsRequest.filter|filter} or - * {@link protos.google.cloud.scheduler.v1.ListJobsRequest.order_by|order_by} while - * iterating through pages. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.scheduler.v1.Job|Job}. - * 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 `listJobsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listJobs( - request?: protos.google.cloud.scheduler.v1.IListJobsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1.IJob[], - protos.google.cloud.scheduler.v1.IListJobsRequest|null, - protos.google.cloud.scheduler.v1.IListJobsResponse - ]>; - listJobs( - request: protos.google.cloud.scheduler.v1.IListJobsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.scheduler.v1.IListJobsRequest, - protos.google.cloud.scheduler.v1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1.IJob>): void; - listJobs( - request: protos.google.cloud.scheduler.v1.IListJobsRequest, - callback: PaginationCallback< - protos.google.cloud.scheduler.v1.IListJobsRequest, - protos.google.cloud.scheduler.v1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1.IJob>): void; - listJobs( - request?: protos.google.cloud.scheduler.v1.IListJobsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.scheduler.v1.IListJobsRequest, - protos.google.cloud.scheduler.v1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1.IJob>, - callback?: PaginationCallback< - protos.google.cloud.scheduler.v1.IListJobsRequest, - protos.google.cloud.scheduler.v1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1.IJob>): - Promise<[ - protos.google.cloud.scheduler.v1.IJob[], - protos.google.cloud.scheduler.v1.IListJobsRequest|null, - protos.google.cloud.scheduler.v1.IListJobsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listJobs(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {number} request.pageSize - * Requested page size. - * - * The maximum page size is 500. If unspecified, the page size will - * be the maximum. Fewer jobs than requested might be returned, - * even if more jobs exist; use next_page_token to determine if more - * jobs exist. - * @param {string} request.pageToken - * A token identifying a page of results the server will return. To - * request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.scheduler.v1.ListJobsResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.scheduler.v1.CloudScheduler.ListJobs|ListJobs}. It is an - * error to switch the value of - * {@link protos.google.cloud.scheduler.v1.ListJobsRequest.filter|filter} or - * {@link protos.google.cloud.scheduler.v1.ListJobsRequest.order_by|order_by} while - * iterating through pages. - * @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 protos.google.cloud.scheduler.v1.Job|Job} 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 `listJobsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listJobsStream( - request?: protos.google.cloud.scheduler.v1.IListJobsRequest, - 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['listJobs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listJobs.createStream( - this.innerApiCalls.listJobs as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listJobs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {number} request.pageSize - * Requested page size. - * - * The maximum page size is 500. If unspecified, the page size will - * be the maximum. Fewer jobs than requested might be returned, - * even if more jobs exist; use next_page_token to determine if more - * jobs exist. - * @param {string} request.pageToken - * A token identifying a page of results the server will return. To - * request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.scheduler.v1.ListJobsResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.scheduler.v1.CloudScheduler.ListJobs|ListJobs}. It is an - * error to switch the value of - * {@link protos.google.cloud.scheduler.v1.ListJobsRequest.filter|filter} or - * {@link protos.google.cloud.scheduler.v1.ListJobsRequest.order_by|order_by} while - * iterating through pages. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.scheduler.v1.Job|Job}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_scheduler.list_jobs.js - * region_tag:cloudscheduler_v1_generated_CloudScheduler_ListJobs_async - */ - listJobsAsync( - request?: protos.google.cloud.scheduler.v1.IListJobsRequest, - 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['listJobs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listJobs.asyncIterate( - this.innerApiCalls['listJobs'] 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified job resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @returns {string} Resource name string. - */ - jobPath(project:string,location:string,job:string) { - return this.pathTemplates.jobPathTemplate.render({ - project: project, - location: location, - job: job, - }); - } - - /** - * Parse the project from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the project. - */ - matchProjectFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).project; - } - - /** - * Parse the location from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the location. - */ - matchLocationFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).location; - } - - /** - * Parse the job from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the job. - */ - matchJobFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).job; - } - - /** - * 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 project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.cloudSchedulerStub && !this._terminated) { - return this.cloudSchedulerStub.then(stub => { - this._terminated = true; - stub.close(); - this.locationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client_config.json b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client_config.json deleted file mode 100644 index edb34789cd4..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client_config.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "interfaces": { - "google.cloud.scheduler.v1.CloudScheduler": { - "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": { - "ListJobs": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetJob": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateJob": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateJob": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteJob": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "PauseJob": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ResumeJob": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RunJob": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_proto_list.json b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_proto_list.json deleted file mode 100644 index 2762a0163a0..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_proto_list.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - "../../protos/google/cloud/scheduler/v1/cloudscheduler.proto", - "../../protos/google/cloud/scheduler/v1/job.proto", - "../../protos/google/cloud/scheduler/v1/target.proto" -] diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 122c43fbb24..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.scheduler.v1", - "libraryPackage": "@google-cloud/scheduler", - "services": { - "CloudScheduler": { - "clients": { - "grpc": { - "libraryClient": "CloudSchedulerClient", - "rpcs": { - "GetJob": { - "methods": [ - "getJob" - ] - }, - "CreateJob": { - "methods": [ - "createJob" - ] - }, - "UpdateJob": { - "methods": [ - "updateJob" - ] - }, - "DeleteJob": { - "methods": [ - "deleteJob" - ] - }, - "PauseJob": { - "methods": [ - "pauseJob" - ] - }, - "ResumeJob": { - "methods": [ - "resumeJob" - ] - }, - "RunJob": { - "methods": [ - "runJob" - ] - }, - "ListJobs": { - "methods": [ - "listJobs", - "listJobsStream", - "listJobsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CloudSchedulerClient", - "rpcs": { - "GetJob": { - "methods": [ - "getJob" - ] - }, - "CreateJob": { - "methods": [ - "createJob" - ] - }, - "UpdateJob": { - "methods": [ - "updateJob" - ] - }, - "DeleteJob": { - "methods": [ - "deleteJob" - ] - }, - "PauseJob": { - "methods": [ - "pauseJob" - ] - }, - "ResumeJob": { - "methods": [ - "resumeJob" - ] - }, - "RunJob": { - "methods": [ - "runJob" - ] - }, - "ListJobs": { - "methods": [ - "listJobs", - "listJobsStream", - "listJobsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/index.ts deleted file mode 100644 index 782589c88a7..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +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 {CloudSchedulerClient} from './cloud_scheduler_client'; diff --git a/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 26229572638..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const scheduler = require('@google-cloud/scheduler'); - -function main() { - const cloudSchedulerClient = new scheduler.CloudSchedulerClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 99f6bacd17a..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {CloudSchedulerClient} from '@google-cloud/scheduler'; - -// check that the client class type name can be used -function doStuffWithCloudSchedulerClient(client: CloudSchedulerClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const cloudSchedulerClient = new CloudSchedulerClient(); - doStuffWithCloudSchedulerClient(cloudSchedulerClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/system-test/install.ts b/owl-bot-staging/google-cloud-scheduler/v1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/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-scheduler/v1/test/gapic_cloud_scheduler_v1.ts b/owl-bot-staging/google-cloud-scheduler/v1/test/gapic_cloud_scheduler_v1.ts deleted file mode 100644 index fb8169ed4a1..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/test/gapic_cloud_scheduler_v1.ts +++ /dev/null @@ -1,1485 +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 cloudschedulerModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, 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('v1.CloudSchedulerClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = cloudschedulerModule.v1.CloudSchedulerClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = cloudschedulerModule.v1.CloudSchedulerClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = cloudschedulerModule.v1.CloudSchedulerClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudSchedulerStub, undefined); - await client.initialize(); - assert(client.cloudSchedulerStub); - }); - - it('has close method for the initialized client', done => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.cloudSchedulerStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudSchedulerStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - 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 cloudschedulerModule.v1.CloudSchedulerClient({ - 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('getJob', () => { - it('invokes getJob without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.getJob = stubSimpleCall(expectedResponse); - const [response] = await client.getJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getJob without error using callback', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.getJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getJob with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getJob(request), expectedError); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getJob with closed client', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getJob(request), expectedError); - }); - }); - - describe('createJob', () => { - it('invokes createJob without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.createJob = stubSimpleCall(expectedResponse); - const [response] = await client.createJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createJob without error using callback', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.createJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createJob with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createJob(request), expectedError); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createJob with closed client', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createJob(request), expectedError); - }); - }); - - describe('updateJob', () => { - it('invokes updateJob without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.updateJob = stubSimpleCall(expectedResponse); - const [response] = await client.updateJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateJob without error using callback', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.updateJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateJob with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateJob(request), expectedError); - const actualRequest = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateJob with closed client', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateJob(request), expectedError); - }); - }); - - describe('deleteJob', () => { - it('invokes deleteJob without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteJob = stubSimpleCall(expectedResponse); - const [response] = await client.deleteJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteJob without error using callback', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteJob( - 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.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteJob with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteJob(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteJob with closed client', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteJob(request), expectedError); - }); - }); - - describe('pauseJob', () => { - it('invokes pauseJob without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.PauseJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.PauseJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.pauseJob = stubSimpleCall(expectedResponse); - const [response] = await client.pauseJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseJob without error using callback', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.PauseJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.PauseJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.pauseJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.pauseJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseJob with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.PauseJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.PauseJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.pauseJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.pauseJob(request), expectedError); - const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseJob with closed client', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.PauseJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.PauseJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.pauseJob(request), expectedError); - }); - }); - - describe('resumeJob', () => { - it('invokes resumeJob without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ResumeJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.ResumeJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.resumeJob = stubSimpleCall(expectedResponse); - const [response] = await client.resumeJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeJob without error using callback', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ResumeJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.ResumeJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.resumeJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resumeJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeJob with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ResumeJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.ResumeJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.resumeJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.resumeJob(request), expectedError); - const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeJob with closed client', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ResumeJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.ResumeJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.resumeJob(request), expectedError); - }); - }); - - describe('runJob', () => { - it('invokes runJob without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.RunJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.RunJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.runJob = stubSimpleCall(expectedResponse); - const [response] = await client.runJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runJob without error using callback', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.RunJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.RunJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.runJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.runJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runJob with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.RunJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.RunJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.runJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.runJob(request), expectedError); - const actualRequest = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runJob with closed client', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.RunJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.RunJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.runJob(request), expectedError); - }); - }); - - describe('listJobs', () => { - it('invokes listJobs without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCall(expectedResponse); - const [response] = await client.listJobs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listJobs without error using callback', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listJobs( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listJobs with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listJobs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listJobs(request), expectedError); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listJobsStream without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - ]; - client.descriptors.page.listJobs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.scheduler.v1.Job[] = []; - stream.on('data', (response: protos.google.cloud.scheduler.v1.Job) => { - 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.listJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); - assert( - (client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listJobsStream with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listJobs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.scheduler.v1.Job[] = []; - stream.on('data', (response: protos.google.cloud.scheduler.v1.Job) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); - assert( - (client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listJobs without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - ]; - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.scheduler.v1.IJob[] = []; - const iterable = client.listJobsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listJobs with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listJobsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.scheduler.v1.IJob[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listJobs.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 cloudschedulerModule.v1.CloudSchedulerClient({ - 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 cloudschedulerModule.v1.CloudSchedulerClient({ - 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 cloudschedulerModule.v1.CloudSchedulerClient({ - 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 cloudschedulerModule.v1.CloudSchedulerClient({ - 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 cloudschedulerModule.v1.CloudSchedulerClient({ - 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('Path templates', () => { - - describe('job', () => { - const fakePath = "/rendered/path/job"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - }; - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.jobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.jobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('jobPath', () => { - const result = client.jobPath("projectValue", "locationValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.jobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromJobName', () => { - const result = client.matchProjectFromJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromJobName', () => { - const result = client.matchLocationFromJobName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromJobName', () => { - const result = client.matchJobFromJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - 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('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/tsconfig.json b/owl-bot-staging/google-cloud-scheduler/v1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/webpack.config.js b/owl-bot-staging/google-cloud-scheduler/v1/webpack.config.js deleted file mode 100644 index d4565464f20..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'scheduler', - filename: './scheduler.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-scheduler/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/.gitignore b/owl-bot-staging/google-cloud-scheduler/v1beta1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/.jsdoc.js deleted file mode 100644 index da319aef859..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/.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/scheduler', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/.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-scheduler/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/.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-scheduler/v1beta1/README.md b/owl-bot-staging/google-cloud-scheduler/v1beta1/README.md deleted file mode 100644 index 90fa2a2d162..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Scheduler: Nodejs Client diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/package.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/package.json deleted file mode 100644 index c3738ba2d1a..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@google-cloud/scheduler", - "version": "0.1.0", - "description": "Scheduler client for Node.js", - "repository": "googleapis/nodejs-scheduler", - "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 scheduler", - "scheduler", - "cloud scheduler" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto b/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto deleted file mode 100644 index 210e0f29412..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto +++ /dev/null @@ -1,315 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.scheduler.v1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/scheduler/v1beta1/job.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option go_package = "cloud.google.com/go/scheduler/apiv1beta1/schedulerpb;schedulerpb"; -option java_multiple_files = true; -option java_outer_classname = "SchedulerProto"; -option java_package = "com.google.cloud.scheduler.v1beta1"; -option objc_class_prefix = "SCHEDULER"; - -// The Cloud Scheduler API allows external entities to reliably -// schedule asynchronous jobs. -service CloudScheduler { - option (google.api.default_host) = "cloudscheduler.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Lists jobs. - rpc ListJobs(ListJobsRequest) returns (ListJobsResponse) { - option (google.api.http) = { - get: "/v1beta1/{parent=projects/*/locations/*}/jobs" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets a job. - rpc GetJob(GetJobRequest) returns (Job) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/locations/*/jobs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a job. - rpc CreateJob(CreateJobRequest) returns (Job) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*/locations/*}/jobs" - body: "job" - }; - option (google.api.method_signature) = "parent,job"; - } - - // Updates a job. - // - // If successful, the updated [Job][google.cloud.scheduler.v1beta1.Job] is - // returned. If the job does not exist, `NOT_FOUND` is returned. - // - // If UpdateJob does not successfully return, it is possible for the - // job to be in an - // [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1beta1.Job.State.UPDATE_FAILED] - // state. A job in this state may not be executed. If this happens, retry the - // UpdateJob request until a successful response is received. - rpc UpdateJob(UpdateJobRequest) returns (Job) { - option (google.api.http) = { - patch: "/v1beta1/{job.name=projects/*/locations/*/jobs/*}" - body: "job" - }; - option (google.api.method_signature) = "job,update_mask"; - } - - // Deletes a job. - rpc DeleteJob(DeleteJobRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1beta1/{name=projects/*/locations/*/jobs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Pauses a job. - // - // If a job is paused then the system will stop executing the job - // until it is re-enabled via - // [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. The - // state of the job is stored in - // [state][google.cloud.scheduler.v1beta1.Job.state]; if paused it will be set - // to [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. A - // job must be in - // [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED] to be - // paused. - rpc PauseJob(PauseJobRequest) returns (Job) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/jobs/*}:pause" - body: "*" - }; - option (google.api.method_signature) = "name"; - } - - // Resume a job. - // - // This method reenables a job after it has been - // [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. The - // state of a job is stored in - // [Job.state][google.cloud.scheduler.v1beta1.Job.state]; after calling this - // method it will be set to - // [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED]. A - // job must be in - // [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED] to be - // resumed. - rpc ResumeJob(ResumeJobRequest) returns (Job) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/jobs/*}:resume" - body: "*" - }; - option (google.api.method_signature) = "name"; - } - - // Forces a job to run now. - // - // When this method is called, Cloud Scheduler will dispatch the job, even - // if the job is already running. - rpc RunJob(RunJobRequest) returns (Job) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/jobs/*}:run" - body: "*" - }; - option (google.api.method_signature) = "name"; - } -} - -// Request message for listing jobs using -// [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs]. -message ListJobsRequest { - // Required. The location name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "cloudscheduler.googleapis.com/Job" - } - ]; - - // `filter` can be used to specify a subset of jobs. - // - // If `filter` equals `target_config="HttpConfig"`, then the http - // target jobs are retrieved. If `filter` equals - // `target_config="PubSubConfig"`, then the Pub/Sub target jobs are - // retrieved. If `filter` equals `labels.foo=value1 - // labels.foo=value2` then only jobs which are labeled with - // foo=value1 AND foo=value2 will be returned. - string filter = 4; - - // Requested page size. - // - // The maximum page size is 500. If unspecified, the page size will - // be the maximum. Fewer jobs than requested might be returned, - // even if more jobs exist; use next_page_token to determine if more - // jobs exist. - int32 page_size = 5; - - // A token identifying a page of results the server will return. To - // request the first page results, page_token must be empty. To - // request the next page of results, page_token must be the value of - // [next_page_token][google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token] - // returned from the previous call to - // [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs]. It is - // an error to switch the value of - // [filter][google.cloud.scheduler.v1beta1.ListJobsRequest.filter] or - // [order_by][google.cloud.scheduler.v1beta1.ListJobsRequest.order_by] while - // iterating through pages. - string page_token = 6; - - // This field is used to manage the legacy App Engine Cron jobs using the - // Cloud Scheduler API. If the field is set to true, the jobs in the __cron - // queue will be listed instead. - bool legacy_app_engine_cron = 7; -} - -// Response message for listing jobs using -// [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs]. -message ListJobsResponse { - // The list of jobs. - repeated Job jobs = 1; - - // A token to retrieve next page of results. Pass this value in the - // [page_token][google.cloud.scheduler.v1beta1.ListJobsRequest.page_token] - // field in the subsequent call to - // [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs] to - // retrieve the next page of results. If this is empty it indicates that there - // are no more results through which to paginate. - // - // The page token is valid for only 2 hours. - string next_page_token = 2; -} - -// Request message for -// [GetJob][google.cloud.scheduler.v1beta1.CloudScheduler.GetJob]. -message GetJobRequest { - // Required. The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudscheduler.googleapis.com/Job" - } - ]; -} - -// Request message for -// [CreateJob][google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob]. -message CreateJobRequest { - // Required. The location name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "cloudscheduler.googleapis.com/Job" - } - ]; - - // Required. The job to add. The user can optionally specify a name for the - // job in [name][google.cloud.scheduler.v1beta1.Job.name]. - // [name][google.cloud.scheduler.v1beta1.Job.name] cannot be the same as an - // existing job. If a name is not specified then the system will - // generate a random unique name that will be returned - // ([name][google.cloud.scheduler.v1beta1.Job.name]) in the response. - Job job = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for -// [UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob]. -message UpdateJobRequest { - // Required. The new job properties. - // [name][google.cloud.scheduler.v1beta1.Job.name] must be specified. - // - // Output only fields cannot be modified using UpdateJob. - // Any value specified for an output only field will be ignored. - Job job = 1 [(google.api.field_behavior) = REQUIRED]; - - // A mask used to specify which fields of the job are being updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for deleting a job using -// [DeleteJob][google.cloud.scheduler.v1beta1.CloudScheduler.DeleteJob]. -message DeleteJobRequest { - // Required. The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudscheduler.googleapis.com/Job" - } - ]; - - // This field is used to manage the legacy App Engine Cron jobs using the - // Cloud Scheduler API. If the field is set to true, the job in the __cron - // queue with the corresponding name will be deleted instead. - bool legacy_app_engine_cron = 2; -} - -// Request message for -// [PauseJob][google.cloud.scheduler.v1beta1.CloudScheduler.PauseJob]. -message PauseJobRequest { - // Required. The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudscheduler.googleapis.com/Job" - } - ]; -} - -// Request message for -// [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. -message ResumeJobRequest { - // Required. The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudscheduler.googleapis.com/Job" - } - ]; -} - -// Request message for forcing a job to run now using -// [RunJob][google.cloud.scheduler.v1beta1.CloudScheduler.RunJob]. -message RunJobRequest { - // Required. The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudscheduler.googleapis.com/Job" - } - ]; - - // This field is used to manage the legacy App Engine Cron jobs using the - // Cloud Scheduler API. If the field is set to true, the job in the __cron - // queue with the corresponding name will be forced to run instead. - bool legacy_app_engine_cron = 2; -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/job.proto b/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/job.proto deleted file mode 100644 index 2674217d97e..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/job.proto +++ /dev/null @@ -1,268 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.scheduler.v1beta1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/scheduler/v1beta1/target.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option go_package = "cloud.google.com/go/scheduler/apiv1beta1/schedulerpb;schedulerpb"; -option java_multiple_files = true; -option java_outer_classname = "JobProto"; -option java_package = "com.google.cloud.scheduler.v1beta1"; - -// Configuration for a job. -// The maximum allowed size for a job is 1MB. -message Job { - option (google.api.resource) = { - type: "cloudscheduler.googleapis.com/Job" - pattern: "projects/{project}/locations/{location}/jobs/{job}" - }; - - // State of the job. - enum State { - // Unspecified state. - STATE_UNSPECIFIED = 0; - - // The job is executing normally. - ENABLED = 1; - - // The job is paused by the user. It will not execute. A user can - // intentionally pause the job using - // [PauseJobRequest][google.cloud.scheduler.v1beta1.PauseJobRequest]. - PAUSED = 2; - - // The job is disabled by the system due to error. The user - // cannot directly set a job to be disabled. - DISABLED = 3; - - // The job state resulting from a failed - // [CloudScheduler.UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob] - // operation. To recover a job from this state, retry - // [CloudScheduler.UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob] - // until a successful response is received. - UPDATE_FAILED = 4; - } - - // Optionally caller-specified in - // [CreateJob][google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob], after - // which it becomes output only. - // - // The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - // - // * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]), - // hyphens (-), colons (:), or periods (.). - // For more information, see - // [Identifying - // projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects) - // * `LOCATION_ID` is the canonical ID for the job's location. - // The list of available locations can be obtained by calling - // [ListLocations][google.cloud.location.Locations.ListLocations]. - // For more information, see https://cloud.google.com/about/locations/. - // * `JOB_ID` can contain only letters ([A-Za-z]), numbers ([0-9]), - // hyphens (-), or underscores (_). The maximum length is 500 characters. - string name = 1; - - // Optionally caller-specified in - // [CreateJob][google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob] or - // [UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob]. - // - // A human-readable description for the job. This string must not contain - // more than 500 characters. - string description = 2; - - // Required. - // - // Delivery settings containing destination and parameters. - oneof target { - // Pub/Sub target. - PubsubTarget pubsub_target = 4; - - // App Engine HTTP target. - AppEngineHttpTarget app_engine_http_target = 5; - - // HTTP target. - HttpTarget http_target = 6; - } - - // Required, except when used with - // [UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob]. - // - // Describes the schedule on which the job will be executed. - // - // The schedule can be either of the following types: - // - // * [Crontab](https://en.wikipedia.org/wiki/Cron#Overview) - // * English-like - // [schedule](https://cloud.google.com/scheduler/docs/configuring/cron-job-schedules) - // - // As a general rule, execution `n + 1` of a job will not begin - // until execution `n` has finished. Cloud Scheduler will never - // allow two simultaneously outstanding executions. For example, - // this implies that if the `n+1`th execution is scheduled to run at - // 16:00 but the `n`th execution takes until 16:15, the `n+1`th - // execution will not start until `16:15`. - // A scheduled start time will be delayed if the previous - // execution has not ended when its scheduled time occurs. - // - // If [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] > - // 0 and a job attempt fails, the job will be tried a total of - // [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] - // times, with exponential backoff, until the next scheduled start - // time. - string schedule = 20; - - // Specifies the time zone to be used in interpreting - // [schedule][google.cloud.scheduler.v1beta1.Job.schedule]. The value of this - // field must be a time zone name from the [tz - // database](http://en.wikipedia.org/wiki/Tz_database). - // - // Note that some time zones include a provision for - // daylight savings time. The rules for daylight saving time are - // determined by the chosen tz. For UTC use the string "utc". If a - // time zone is not specified, the default will be in UTC (also known - // as GMT). - string time_zone = 21; - - // Output only. The creation time of the job. - google.protobuf.Timestamp user_update_time = 9; - - // Output only. State of the job. - State state = 10; - - // Output only. The response from the target for the last attempted execution. - google.rpc.Status status = 11; - - // Output only. The next time the job is scheduled. Note that this may be a - // retry of a previously failed attempt or the next execution time - // according to the schedule. - google.protobuf.Timestamp schedule_time = 17; - - // Output only. The time the last job attempt started. - google.protobuf.Timestamp last_attempt_time = 18; - - // Settings that determine the retry behavior. - RetryConfig retry_config = 19; - - // The deadline for job attempts. If the request handler does not respond by - // this deadline then the request is cancelled and the attempt is marked as a - // `DEADLINE_EXCEEDED` failure. The failed attempt can be viewed in - // execution logs. Cloud Scheduler will retry the job according - // to the [RetryConfig][google.cloud.scheduler.v1beta1.RetryConfig]. - // - // The default and the allowed values depend on the type of target: - // - // * For [HTTP targets][google.cloud.scheduler.v1beta1.Job.http_target], the - // default is 3 minutes. The deadline must be in the interval [15 seconds, 30 - // minutes]. - // - // * For [App Engine HTTP - // targets][google.cloud.scheduler.v1beta1.Job.app_engine_http_target], 0 - // indicates that the request has the default deadline. The default deadline - // depends on the scaling type of the service: 10 minutes for standard apps - // with automatic scaling, 24 hours for standard apps with manual and basic - // scaling, and 60 minutes for flex apps. If the request deadline is set, it - // must be in the interval [15 seconds, 24 hours 15 seconds]. - // - // * For [Pub/Sub targets][google.cloud.scheduler.v1beta1.Job.pubsub_target], - // this field is ignored. - google.protobuf.Duration attempt_deadline = 22; - - // Immutable. This field is used to manage the legacy App Engine Cron jobs - // using the Cloud Scheduler API. If the field is set to true, the job will be - // considered a legacy job. Note that App Engine Cron jobs have fewer - // features than Cloud Scheduler jobs, e.g., are only limited to App Engine - // targets. - bool legacy_app_engine_cron = 23 [(google.api.field_behavior) = IMMUTABLE]; -} - -// Settings that determine the retry behavior. -// -// By default, if a job does not complete successfully (meaning that -// an acknowledgement is not received from the handler, then it will be retried -// with exponential backoff according to the settings in -// [RetryConfig][google.cloud.scheduler.v1beta1.RetryConfig]. -message RetryConfig { - // The number of attempts that the system will make to run a job using the - // exponential backoff procedure described by - // [max_doublings][google.cloud.scheduler.v1beta1.RetryConfig.max_doublings]. - // - // The default value of retry_count is zero. - // - // If retry_count is zero, a job attempt will *not* be retried if - // it fails. Instead the Cloud Scheduler system will wait for the - // next scheduled execution time. - // - // If retry_count is set to a non-zero number then Cloud Scheduler - // will retry failed attempts, using exponential backoff, - // retry_count times, or until the next scheduled execution time, - // whichever comes first. - // - // Values greater than 5 and negative values are not allowed. - int32 retry_count = 1; - - // The time limit for retrying a failed job, measured from time when an - // execution was first attempted. If specified with - // [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count], the - // job will be retried until both limits are reached. - // - // The default value for max_retry_duration is zero, which means retry - // duration is unlimited. - google.protobuf.Duration max_retry_duration = 2; - - // The minimum amount of time to wait before retrying a job after - // it fails. - // - // The default value of this field is 5 seconds. - google.protobuf.Duration min_backoff_duration = 3; - - // The maximum amount of time to wait before retrying a job after - // it fails. - // - // The default value of this field is 1 hour. - google.protobuf.Duration max_backoff_duration = 4; - - // The time between retries will double `max_doublings` times. - // - // A job's retry interval starts at - // [min_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.min_backoff_duration], - // then doubles `max_doublings` times, then increases linearly, and finally - // retries at intervals of - // [max_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.max_backoff_duration] - // up to [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] - // times. - // - // For example, if - // [min_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.min_backoff_duration] - // is 10s, - // [max_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.max_backoff_duration] - // is 300s, and `max_doublings` is 3, then the a job will first be retried in - // 10s. The retry interval will double three times, and then increase linearly - // by 2^3 * 10s. Finally, the job will retry at intervals of - // [max_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.max_backoff_duration] - // until the job has been attempted - // [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] - // times. Thus, the requests will retry at 10s, 20s, 40s, 80s, 160s, 240s, - // 300s, 300s, .... - // - // The default value of this field is 5. - int32 max_doublings = 5; -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/target.proto b/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/target.proto deleted file mode 100644 index af1c3484e50..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/target.proto +++ /dev/null @@ -1,371 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.scheduler.v1beta1; - -import "google/api/resource.proto"; - -option go_package = "cloud.google.com/go/scheduler/apiv1beta1/schedulerpb;schedulerpb"; -option java_multiple_files = true; -option java_outer_classname = "TargetProto"; -option java_package = "com.google.cloud.scheduler.v1beta1"; -option (google.api.resource_definition) = { - type: "pubsub.googleapis.com/Topic" - pattern: "projects/{project}/topics/{topic}" -}; - -// Http target. The job will be pushed to the job handler by means of -// an HTTP request via an -// [http_method][google.cloud.scheduler.v1beta1.HttpTarget.http_method] such as -// HTTP POST, HTTP GET, etc. The job is acknowledged by means of an HTTP -// response code in the range [200 - 299]. A failure to receive a response -// constitutes a failed execution. For a redirected request, the response -// returned by the redirected request is considered. -message HttpTarget { - // Required. The full URI path that the request will be sent to. This string - // must begin with either "http://" or "https://". Some examples of - // valid values for [uri][google.cloud.scheduler.v1beta1.HttpTarget.uri] are: - // `http://acme.com` and `https://acme.com/sales:8080`. Cloud Scheduler will - // encode some characters for safety and compatibility. The maximum allowed - // URL length is 2083 characters after encoding. - string uri = 1; - - // Which HTTP method to use for the request. - HttpMethod http_method = 2; - - // The user can specify HTTP request headers to send with the job's - // HTTP request. This map contains the header field names and - // values. Repeated headers are not supported, but a header value can - // contain commas. These headers represent a subset of the headers - // that will accompany the job's HTTP request. Some HTTP request - // headers will be ignored or replaced. A partial list of headers that - // will be ignored or replaced is below: - // - Host: This will be computed by Cloud Scheduler and derived from - // [uri][google.cloud.scheduler.v1beta1.HttpTarget.uri]. - // * `Content-Length`: This will be computed by Cloud Scheduler. - // * `User-Agent`: This will be set to `"Google-Cloud-Scheduler"`. - // * `X-Google-*`: Google internal use only. - // * `X-AppEngine-*`: Google internal use only. - // * `X-CloudScheduler`: This header will be set to true. - // * `X-CloudScheduler-JobName`: This header will contain the job name. - // * `X-CloudScheduler-ScheduleTime`: For Cloud Scheduler jobs specified in - // the unix-cron format, this header will contain the job schedule time in - // RFC3339 UTC "Zulu" format. - // - // The total size of headers must be less than 80KB. - map headers = 3; - - // HTTP request body. A request body is allowed only if the HTTP - // method is POST, PUT, or PATCH. It is an error to set body on a job with an - // incompatible [HttpMethod][google.cloud.scheduler.v1beta1.HttpMethod]. - bytes body = 4; - - // The mode for generating an `Authorization` header for HTTP requests. - // - // If specified, all `Authorization` headers in the - // [HttpTarget.headers][google.cloud.scheduler.v1beta1.HttpTarget.headers] - // field will be overridden. - oneof authorization_header { - // If specified, an - // [OAuth token](https://developers.google.com/identity/protocols/OAuth2) - // will be generated and attached as an `Authorization` header in the HTTP - // request. - // - // This type of authorization should generally only be used when calling - // Google APIs hosted on *.googleapis.com. - OAuthToken oauth_token = 5; - - // If specified, an - // [OIDC](https://developers.google.com/identity/protocols/OpenIDConnect) - // token will be generated and attached as an `Authorization` header in the - // HTTP request. - // - // This type of authorization can be used for many scenarios, including - // calling Cloud Run, or endpoints where you intend to validate the token - // yourself. - OidcToken oidc_token = 6; - } -} - -// App Engine target. The job will be pushed to a job handler by means -// of an HTTP request via an -// [http_method][google.cloud.scheduler.v1beta1.AppEngineHttpTarget.http_method] -// such as HTTP POST, HTTP GET, etc. The job is acknowledged by means of an HTTP -// response code in the range [200 - 299]. Error 503 is considered an App Engine -// system error instead of an application error. Requests returning error 503 -// will be retried regardless of retry configuration and not counted against -// retry counts. Any other response code, or a failure to receive a response -// before the deadline, constitutes a failed attempt. -message AppEngineHttpTarget { - // The HTTP method to use for the request. PATCH and OPTIONS are not - // permitted. - HttpMethod http_method = 1; - - // App Engine Routing setting for the job. - AppEngineRouting app_engine_routing = 2; - - // The relative URI. - // - // The relative URL must begin with "/" and must be a valid HTTP relative URL. - // It can contain a path, query string arguments, and `#` fragments. - // If the relative URL is empty, then the root path "/" will be used. - // No spaces are allowed, and the maximum length allowed is 2083 characters. - string relative_uri = 3; - - // HTTP request headers. - // - // This map contains the header field names and values. Headers can be set - // when the job is created. - // - // Cloud Scheduler sets some headers to default values: - // - // * `User-Agent`: By default, this header is - // `"AppEngine-Google; (+http://code.google.com/appengine)"`. - // This header can be modified, but Cloud Scheduler will append - // `"AppEngine-Google; (+http://code.google.com/appengine)"` to the - // modified `User-Agent`. - // * `X-CloudScheduler`: This header will be set to true. - // * `X-CloudScheduler-JobName`: This header will contain the job name. - // * `X-CloudScheduler-ScheduleTime`: For Cloud Scheduler jobs specified in - // the unix-cron format, this header will contain the job schedule time in - // RFC3339 UTC "Zulu" format. - // - // If the job has an - // [body][google.cloud.scheduler.v1beta1.AppEngineHttpTarget.body], Cloud - // Scheduler sets the following headers: - // - // * `Content-Type`: By default, the `Content-Type` header is set to - // `"application/octet-stream"`. The default can be overridden by explictly - // setting `Content-Type` to a particular media type when the job is - // created. - // For example, `Content-Type` can be set to `"application/json"`. - // * `Content-Length`: This is computed by Cloud Scheduler. This value is - // output only. It cannot be changed. - // - // The headers below are output only. They cannot be set or overridden: - // - // * `X-Google-*`: For Google internal use only. - // * `X-AppEngine-*`: For Google internal use only. - // - // In addition, some App Engine headers, which contain - // job-specific information, are also be sent to the job handler. - map headers = 4; - - // Body. - // - // HTTP request body. A request body is allowed only if the HTTP method is - // POST or PUT. It will result in invalid argument error to set a body on a - // job with an incompatible - // [HttpMethod][google.cloud.scheduler.v1beta1.HttpMethod]. - bytes body = 5; -} - -// Pub/Sub target. The job will be delivered by publishing a message to -// the given Pub/Sub topic. -message PubsubTarget { - // Required. The name of the Cloud Pub/Sub topic to which messages will - // be published when a job is delivered. The topic name must be in the - // same format as required by Pub/Sub's - // [PublishRequest.name](https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#publishrequest), - // for example `projects/PROJECT_ID/topics/TOPIC_ID`. - // - // The topic must be in the same project as the Cloud Scheduler job. - string topic_name = 1 [ - (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" } - ]; - - // The message payload for PubsubMessage. - // - // Pubsub message must contain either non-empty data, or at least one - // attribute. - bytes data = 3; - - // Attributes for PubsubMessage. - // - // Pubsub message must contain either non-empty data, or at least one - // attribute. - map attributes = 4; -} - -// App Engine Routing. -// -// For more information about services, versions, and instances see -// [An Overview of App -// Engine](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine), -// [Microservices Architecture on Google App -// Engine](https://cloud.google.com/appengine/docs/python/microservices-on-app-engine), -// [App Engine Standard request -// routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed), -// and [App Engine Flex request -// routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed). -message AppEngineRouting { - // App service. - // - // By default, the job is sent to the service which is the default - // service when the job is attempted. - string service = 1; - - // App version. - // - // By default, the job is sent to the version which is the default - // version when the job is attempted. - string version = 2; - - // App instance. - // - // By default, the job is sent to an instance which is available when - // the job is attempted. - // - // Requests can only be sent to a specific instance if - // [manual scaling is used in App Engine - // Standard](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine?#scaling_types_and_instance_classes). - // App Engine Flex does not support instances. For more information, see - // [App Engine Standard request - // routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed) - // and [App Engine Flex request - // routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed). - string instance = 3; - - // Output only. The host that the job is sent to. - // - // For more information about how App Engine requests are routed, see - // [here](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed). - // - // The host is constructed as: - // - // - // * `host = [application_domain_name]`
- // `| [service] + '.' + [application_domain_name]`
- // `| [version] + '.' + [application_domain_name]`
- // `| [version_dot_service]+ '.' + [application_domain_name]`
- // `| [instance] + '.' + [application_domain_name]`
- // `| [instance_dot_service] + '.' + [application_domain_name]`
- // `| [instance_dot_version] + '.' + [application_domain_name]`
- // `| [instance_dot_version_dot_service] + '.' + [application_domain_name]` - // - // * `application_domain_name` = The domain name of the app, for - // example .appspot.com, which is associated with the - // job's project ID. - // - // * `service =` - // [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] - // - // * `version =` - // [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] - // - // * `version_dot_service =` - // [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] `+ '.' - // +` [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] - // - // * `instance =` - // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] - // - // * `instance_dot_service =` - // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] `+ - // '.' +` [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] - // - // * `instance_dot_version =` - // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] `+ - // '.' +` [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] - // - // * `instance_dot_version_dot_service =` - // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] `+ - // '.' +` [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] - // `+ '.' +` - // [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] - // - // - // If [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] is - // empty, then the job will be sent to the service which is the default - // service when the job is attempted. - // - // If [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] is - // empty, then the job will be sent to the version which is the default - // version when the job is attempted. - // - // If [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] is - // empty, then the job will be sent to an instance which is available when the - // job is attempted. - // - // If [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service], - // [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version], or - // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] is - // invalid, then the job will be sent to the default version of the default - // service when the job is attempted. - string host = 4; -} - -// The HTTP method used to execute the job. -enum HttpMethod { - // HTTP method unspecified. Defaults to POST. - HTTP_METHOD_UNSPECIFIED = 0; - - // HTTP POST - POST = 1; - - // HTTP GET - GET = 2; - - // HTTP HEAD - HEAD = 3; - - // HTTP PUT - PUT = 4; - - // HTTP DELETE - DELETE = 5; - - // HTTP PATCH - PATCH = 6; - - // HTTP OPTIONS - OPTIONS = 7; -} - -// Contains information needed for generating an -// [OAuth token](https://developers.google.com/identity/protocols/OAuth2). -// This type of authorization should generally only be used when calling Google -// APIs hosted on *.googleapis.com. -message OAuthToken { - // [Service account email](https://cloud.google.com/iam/docs/service-accounts) - // to be used for generating OAuth token. - // The service account must be within the same project as the job. The caller - // must have iam.serviceAccounts.actAs permission for the service account. - string service_account_email = 1; - - // OAuth scope to be used for generating OAuth access token. - // If not specified, "https://www.googleapis.com/auth/cloud-platform" - // will be used. - string scope = 2; -} - -// Contains information needed for generating an -// [OpenID Connect -// token](https://developers.google.com/identity/protocols/OpenIDConnect). -// This type of authorization can be used for many scenarios, including -// calling Cloud Run, or endpoints where you intend to validate the token -// yourself. -message OidcToken { - // [Service account email](https://cloud.google.com/iam/docs/service-accounts) - // to be used for generating OIDC token. - // The service account must be within the same project as the job. The caller - // must have iam.serviceAccounts.actAs permission for the service account. - string service_account_email = 1; - - // Audience to be used when generating OIDC token. If not specified, the URI - // specified in target will be used. - string audience = 2; -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.create_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.create_job.js deleted file mode 100644 index 762d2f72efb..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.create_job.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, job) { - // [START cloudscheduler_v1beta1_generated_CloudScheduler_CreateJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - */ - // const parent = 'abc123' - /** - * Required. The job to add. The user can optionally specify a name for the - * job in name google.cloud.scheduler.v1beta1.Job.name. - * name google.cloud.scheduler.v1beta1.Job.name cannot be the same as an - * existing job. If a name is not specified then the system will - * generate a random unique name that will be returned - * (name google.cloud.scheduler.v1beta1.Job.name) in the response. - */ - // const job = {} - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callCreateJob() { - // Construct request - const request = { - parent, - job, - }; - - // Run request - const response = await schedulerClient.createJob(request); - console.log(response); - } - - callCreateJob(); - // [END cloudscheduler_v1beta1_generated_CloudScheduler_CreateJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.delete_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.delete_job.js deleted file mode 100644 index e7158b66478..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.delete_job.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 cloudscheduler_v1beta1_generated_CloudScheduler_DeleteJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - */ - // const name = 'abc123' - /** - * This field is used to manage the legacy App Engine Cron jobs using the - * Cloud Scheduler API. If the field is set to true, the job in the __cron - * queue with the corresponding name will be deleted instead. - */ - // const legacyAppEngineCron = true - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callDeleteJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await schedulerClient.deleteJob(request); - console.log(response); - } - - callDeleteJob(); - // [END cloudscheduler_v1beta1_generated_CloudScheduler_DeleteJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.get_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.get_job.js deleted file mode 100644 index 4dd97392582..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.get_job.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 cloudscheduler_v1beta1_generated_CloudScheduler_GetJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - */ - // const name = 'abc123' - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callGetJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await schedulerClient.getJob(request); - console.log(response); - } - - callGetJob(); - // [END cloudscheduler_v1beta1_generated_CloudScheduler_GetJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.list_jobs.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.list_jobs.js deleted file mode 100644 index 9a13ffc200a..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.list_jobs.js +++ /dev/null @@ -1,101 +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 cloudscheduler_v1beta1_generated_CloudScheduler_ListJobs_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - */ - // const parent = 'abc123' - /** - * `filter` can be used to specify a subset of jobs. - * If `filter` equals `target_config="HttpConfig"`, then the http - * target jobs are retrieved. If `filter` equals - * `target_config="PubSubConfig"`, then the Pub/Sub target jobs are - * retrieved. If `filter` equals `labels.foo=value1 - * labels.foo=value2` then only jobs which are labeled with - * foo=value1 AND foo=value2 will be returned. - */ - // const filter = 'abc123' - /** - * Requested page size. - * The maximum page size is 500. If unspecified, the page size will - * be the maximum. Fewer jobs than requested might be returned, - * even if more jobs exist; use next_page_token to determine if more - * jobs exist. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results the server will return. To - * request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * next_page_token google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token - * returned from the previous call to - * ListJobs google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs. It is - * an error to switch the value of - * filter google.cloud.scheduler.v1beta1.ListJobsRequest.filter or - * order_by google.cloud.scheduler.v1beta1.ListJobsRequest.order_by while - * iterating through pages. - */ - // const pageToken = 'abc123' - /** - * This field is used to manage the legacy App Engine Cron jobs using the - * Cloud Scheduler API. If the field is set to true, the jobs in the __cron - * queue will be listed instead. - */ - // const legacyAppEngineCron = true - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callListJobs() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await schedulerClient.listJobsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListJobs(); - // [END cloudscheduler_v1beta1_generated_CloudScheduler_ListJobs_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.pause_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.pause_job.js deleted file mode 100644 index abf403eeb43..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.pause_job.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 cloudscheduler_v1beta1_generated_CloudScheduler_PauseJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - */ - // const name = 'abc123' - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callPauseJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await schedulerClient.pauseJob(request); - console.log(response); - } - - callPauseJob(); - // [END cloudscheduler_v1beta1_generated_CloudScheduler_PauseJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.resume_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.resume_job.js deleted file mode 100644 index efc9e23b1ec..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.resume_job.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 cloudscheduler_v1beta1_generated_CloudScheduler_ResumeJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - */ - // const name = 'abc123' - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callResumeJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await schedulerClient.resumeJob(request); - console.log(response); - } - - callResumeJob(); - // [END cloudscheduler_v1beta1_generated_CloudScheduler_ResumeJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.run_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.run_job.js deleted file mode 100644 index ae29c9451da..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.run_job.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 cloudscheduler_v1beta1_generated_CloudScheduler_RunJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - */ - // const name = 'abc123' - /** - * This field is used to manage the legacy App Engine Cron jobs using the - * Cloud Scheduler API. If the field is set to true, the job in the __cron - * queue with the corresponding name will be forced to run instead. - */ - // const legacyAppEngineCron = true - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callRunJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await schedulerClient.runJob(request); - console.log(response); - } - - callRunJob(); - // [END cloudscheduler_v1beta1_generated_CloudScheduler_RunJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.update_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.update_job.js deleted file mode 100644 index c00b440ac7a..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.update_job.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(job) { - // [START cloudscheduler_v1beta1_generated_CloudScheduler_UpdateJob_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The new job properties. - * name google.cloud.scheduler.v1beta1.Job.name must be specified. - * Output only fields cannot be modified using UpdateJob. - * Any value specified for an output only field will be ignored. - */ - // const job = {} - /** - * A mask used to specify which fields of the job are being updated. - */ - // const updateMask = {} - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callUpdateJob() { - // Construct request - const request = { - job, - }; - - // Run request - const response = await schedulerClient.updateJob(request); - console.log(response); - } - - callUpdateJob(); - // [END cloudscheduler_v1beta1_generated_CloudScheduler_UpdateJob_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.scheduler.v1beta1.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.scheduler.v1beta1.json deleted file mode 100644 index 19c756a7cd0..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/snippet_metadata_google.cloud.scheduler.v1beta1.json +++ /dev/null @@ -1,367 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-scheduler", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.scheduler.v1beta1", - "version": "v1beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_ListJobs_async", - "title": "scheduler listJobs Sample", - "origin": "API_DEFINITION", - "description": " Lists jobs.", - "canonical": true, - "file": "cloud_scheduler.list_jobs.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 93, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListJobs", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "legacy_app_engine_cron", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.scheduler.v1beta1.ListJobsResponse", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" - }, - "method": { - "shortName": "ListJobs", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_GetJob_async", - "title": "scheduler getJob Sample", - "origin": "API_DEFINITION", - "description": " Gets a job.", - "canonical": true, - "file": "cloud_scheduler.get_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.GetJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.scheduler.v1beta1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" - }, - "method": { - "shortName": "GetJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.GetJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_CreateJob_async", - "title": "scheduler createJob Sample", - "origin": "API_DEFINITION", - "description": " Creates a job.", - "canonical": true, - "file": "cloud_scheduler.create_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "job", - "type": ".google.cloud.scheduler.v1beta1.Job" - } - ], - "resultType": ".google.cloud.scheduler.v1beta1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" - }, - "method": { - "shortName": "CreateJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_UpdateJob_async", - "title": "scheduler updateJob Sample", - "origin": "API_DEFINITION", - "description": " Updates a job. If successful, the updated [Job][google.cloud.scheduler.v1beta1.Job] is returned. If the job does not exist, `NOT_FOUND` is returned. If UpdateJob does not successfully return, it is possible for the job to be in an [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1beta1.Job.State.UPDATE_FAILED] state. A job in this state may not be executed. If this happens, retry the UpdateJob request until a successful response is received.", - "canonical": true, - "file": "cloud_scheduler.update_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob", - "async": true, - "parameters": [ - { - "name": "job", - "type": ".google.cloud.scheduler.v1beta1.Job" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.scheduler.v1beta1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" - }, - "method": { - "shortName": "UpdateJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_DeleteJob_async", - "title": "scheduler deleteJob Sample", - "origin": "API_DEFINITION", - "description": " Deletes a job.", - "canonical": true, - "file": "cloud_scheduler.delete_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.DeleteJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "legacy_app_engine_cron", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" - }, - "method": { - "shortName": "DeleteJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.DeleteJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_PauseJob_async", - "title": "scheduler pauseJob Sample", - "origin": "API_DEFINITION", - "description": " Pauses a job. If a job is paused then the system will stop executing the job until it is re-enabled via [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. The state of the job is stored in [state][google.cloud.scheduler.v1beta1.Job.state]; if paused it will be set to [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. A job must be in [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED] to be paused.", - "canonical": true, - "file": "cloud_scheduler.pause_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PauseJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.PauseJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.scheduler.v1beta1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" - }, - "method": { - "shortName": "PauseJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.PauseJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_ResumeJob_async", - "title": "scheduler resumeJob Sample", - "origin": "API_DEFINITION", - "description": " Resume a job. This method reenables a job after it has been [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. The state of a job is stored in [Job.state][google.cloud.scheduler.v1beta1.Job.state]; after calling this method it will be set to [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED]. A job must be in [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED] to be resumed.", - "canonical": true, - "file": "cloud_scheduler.resume_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ResumeJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.scheduler.v1beta1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" - }, - "method": { - "shortName": "ResumeJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_RunJob_async", - "title": "scheduler runJob Sample", - "origin": "API_DEFINITION", - "description": " Forces a job to run now. When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running.", - "canonical": true, - "file": "cloud_scheduler.run_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RunJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.RunJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "legacy_app_engine_cron", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.scheduler.v1beta1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" - }, - "method": { - "shortName": "RunJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.RunJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/index.ts deleted file mode 100644 index a6d6606681c..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/index.ts +++ /dev/null @@ -1,25 +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 v1beta1 from './v1beta1'; -const CloudSchedulerClient = v1beta1.CloudSchedulerClient; -type CloudSchedulerClient = v1beta1.CloudSchedulerClient; -export {v1beta1, CloudSchedulerClient}; -export default {v1beta1, CloudSchedulerClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client.ts deleted file mode 100644 index 5edbca778e4..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client.ts +++ /dev/null @@ -1,1331 +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, 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/v1beta1/cloud_scheduler_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './cloud_scheduler_client_config.json'; -const version = require('../../../package.json').version; - -/** - * The Cloud Scheduler API allows external entities to reliably - * schedule asynchronous jobs. - * @class - * @memberof v1beta1 - */ -export class CloudSchedulerClient { - 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}; - cloudSchedulerStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CloudSchedulerClient. - * - * @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} [options.fallback] - Use HTTP/1.1 REST mode. - * 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 CloudSchedulerClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof CloudSchedulerClient; - 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 { - 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 = { - jobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listJobs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'jobs') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.scheduler.v1beta1.CloudScheduler', 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.cloudSchedulerStub) { - return this.cloudSchedulerStub; - } - - // Put together the "service stub" for - // google.cloud.scheduler.v1beta1.CloudScheduler. - this.cloudSchedulerStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.scheduler.v1beta1.CloudScheduler') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.scheduler.v1beta1.CloudScheduler, - 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 cloudSchedulerStubMethods = - ['listJobs', 'getJob', 'createJob', 'updateJob', 'deleteJob', 'pauseJob', 'resumeJob', 'runJob']; - for (const methodName of cloudSchedulerStubMethods) { - const callPromise = this.cloudSchedulerStub.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.cloudSchedulerStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudscheduler.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 'cloudscheduler.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 job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.scheduler.v1beta1.Job|Job}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_scheduler.get_job.js - * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_GetJob_async - */ - getJob( - request?: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IGetJobRequest|undefined, {}|undefined - ]>; - getJob( - request: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IGetJobRequest|null|undefined, - {}|null|undefined>): void; - getJob( - request: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IGetJobRequest|null|undefined, - {}|null|undefined>): void; - getJob( - request?: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IGetJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IGetJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IGetJobRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getJob(request, options, callback); - } -/** - * Creates a job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {google.cloud.scheduler.v1beta1.Job} request.job - * Required. The job to add. The user can optionally specify a name for the - * job in {@link protos.google.cloud.scheduler.v1beta1.Job.name|name}. - * {@link protos.google.cloud.scheduler.v1beta1.Job.name|name} cannot be the same as an - * existing job. If a name is not specified then the system will - * generate a random unique name that will be returned - * ({@link protos.google.cloud.scheduler.v1beta1.Job.name|name}) in the response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.scheduler.v1beta1.Job|Job}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_scheduler.create_job.js - * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_CreateJob_async - */ - createJob( - request?: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|undefined, {}|undefined - ]>; - createJob( - request: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|null|undefined, - {}|null|undefined>): void; - createJob( - request: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|null|undefined, - {}|null|undefined>): void; - createJob( - request?: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createJob(request, options, callback); - } -/** - * Updates a job. - * - * If successful, the updated {@link protos.google.cloud.scheduler.v1beta1.Job|Job} is - * returned. If the job does not exist, `NOT_FOUND` is returned. - * - * If UpdateJob does not successfully return, it is possible for the - * job to be in an - * {@link protos.google.cloud.scheduler.v1beta1.Job.State.UPDATE_FAILED|Job.State.UPDATE_FAILED} - * state. A job in this state may not be executed. If this happens, retry the - * UpdateJob request until a successful response is received. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.scheduler.v1beta1.Job} request.job - * Required. The new job properties. - * {@link protos.google.cloud.scheduler.v1beta1.Job.name|name} must be specified. - * - * Output only fields cannot be modified using UpdateJob. - * Any value specified for an output only field will be ignored. - * @param {google.protobuf.FieldMask} request.updateMask - * A mask used to specify which fields of the job are being 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 protos.google.cloud.scheduler.v1beta1.Job|Job}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_scheduler.update_job.js - * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_UpdateJob_async - */ - updateJob( - request?: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|undefined, {}|undefined - ]>; - updateJob( - request: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|null|undefined, - {}|null|undefined>): void; - updateJob( - request: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|null|undefined, - {}|null|undefined>): void; - updateJob( - request?: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'job.name': request.job!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateJob(request, options, callback); - } -/** - * Deletes a job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {boolean} request.legacyAppEngineCron - * This field is used to manage the legacy App Engine Cron jobs using the - * Cloud Scheduler API. If the field is set to true, the job in the __cron - * queue with the corresponding name will be deleted instead. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_scheduler.delete_job.js - * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_DeleteJob_async - */ - deleteJob( - request?: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|undefined, {}|undefined - ]>; - deleteJob( - request: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): void; - deleteJob( - request: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): void; - deleteJob( - request?: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteJob(request, options, callback); - } -/** - * Pauses a job. - * - * If a job is paused then the system will stop executing the job - * until it is re-enabled via - * {@link protos.google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob|ResumeJob}. The - * state of the job is stored in - * {@link protos.google.cloud.scheduler.v1beta1.Job.state|state}; if paused it will be set - * to {@link protos.google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED}. A - * job must be in - * {@link protos.google.cloud.scheduler.v1beta1.Job.State.ENABLED|Job.State.ENABLED} to be - * paused. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.scheduler.v1beta1.Job|Job}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_scheduler.pause_job.js - * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_PauseJob_async - */ - pauseJob( - request?: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|undefined, {}|undefined - ]>; - pauseJob( - request: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|null|undefined, - {}|null|undefined>): void; - pauseJob( - request: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|null|undefined, - {}|null|undefined>): void; - pauseJob( - request?: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.pauseJob(request, options, callback); - } -/** - * Resume a job. - * - * This method reenables a job after it has been - * {@link protos.google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED}. The - * state of a job is stored in - * {@link protos.google.cloud.scheduler.v1beta1.Job.state|Job.state}; after calling this - * method it will be set to - * {@link protos.google.cloud.scheduler.v1beta1.Job.State.ENABLED|Job.State.ENABLED}. A - * job must be in - * {@link protos.google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED} to be - * resumed. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.scheduler.v1beta1.Job|Job}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_scheduler.resume_job.js - * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_ResumeJob_async - */ - resumeJob( - request?: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|undefined, {}|undefined - ]>; - resumeJob( - request: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|null|undefined, - {}|null|undefined>): void; - resumeJob( - request: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|null|undefined, - {}|null|undefined>): void; - resumeJob( - request?: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.resumeJob(request, options, callback); - } -/** - * Forces a job to run now. - * - * When this method is called, Cloud Scheduler will dispatch the job, even - * if the job is already running. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {boolean} request.legacyAppEngineCron - * This field is used to manage the legacy App Engine Cron jobs using the - * Cloud Scheduler API. If the field is set to true, the job in the __cron - * queue with the corresponding name will be forced to run instead. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.scheduler.v1beta1.Job|Job}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_scheduler.run_job.js - * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_RunJob_async - */ - runJob( - request?: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IRunJobRequest|undefined, {}|undefined - ]>; - runJob( - request: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IRunJobRequest|null|undefined, - {}|null|undefined>): void; - runJob( - request: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IRunJobRequest|null|undefined, - {}|null|undefined>): void; - runJob( - request?: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IRunJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IRunJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IRunJobRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.runJob(request, options, callback); - } - - /** - * Lists jobs. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {string} request.filter - * `filter` can be used to specify a subset of jobs. - * - * If `filter` equals `target_config="HttpConfig"`, then the http - * target jobs are retrieved. If `filter` equals - * `target_config="PubSubConfig"`, then the Pub/Sub target jobs are - * retrieved. If `filter` equals `labels.foo=value1 - * labels.foo=value2` then only jobs which are labeled with - * foo=value1 AND foo=value2 will be returned. - * @param {number} request.pageSize - * Requested page size. - * - * The maximum page size is 500. If unspecified, the page size will - * be the maximum. Fewer jobs than requested might be returned, - * even if more jobs exist; use next_page_token to determine if more - * jobs exist. - * @param {string} request.pageToken - * A token identifying a page of results the server will return. To - * request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is - * an error to switch the value of - * {@link protos.google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or - * {@link protos.google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while - * iterating through pages. - * @param {boolean} request.legacyAppEngineCron - * This field is used to manage the legacy App Engine Cron jobs using the - * Cloud Scheduler API. If the field is set to true, the jobs in the __cron - * queue will be listed instead. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 protos.google.cloud.scheduler.v1beta1.Job|Job}. - * 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 `listJobsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listJobs( - request?: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob[], - protos.google.cloud.scheduler.v1beta1.IListJobsRequest|null, - protos.google.cloud.scheduler.v1beta1.IListJobsResponse - ]>; - listJobs( - request: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - protos.google.cloud.scheduler.v1beta1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1beta1.IJob>): void; - listJobs( - request: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - callback: PaginationCallback< - protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - protos.google.cloud.scheduler.v1beta1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1beta1.IJob>): void; - listJobs( - request?: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - protos.google.cloud.scheduler.v1beta1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1beta1.IJob>, - callback?: PaginationCallback< - protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - protos.google.cloud.scheduler.v1beta1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1beta1.IJob>): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob[], - protos.google.cloud.scheduler.v1beta1.IListJobsRequest|null, - protos.google.cloud.scheduler.v1beta1.IListJobsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listJobs(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {string} request.filter - * `filter` can be used to specify a subset of jobs. - * - * If `filter` equals `target_config="HttpConfig"`, then the http - * target jobs are retrieved. If `filter` equals - * `target_config="PubSubConfig"`, then the Pub/Sub target jobs are - * retrieved. If `filter` equals `labels.foo=value1 - * labels.foo=value2` then only jobs which are labeled with - * foo=value1 AND foo=value2 will be returned. - * @param {number} request.pageSize - * Requested page size. - * - * The maximum page size is 500. If unspecified, the page size will - * be the maximum. Fewer jobs than requested might be returned, - * even if more jobs exist; use next_page_token to determine if more - * jobs exist. - * @param {string} request.pageToken - * A token identifying a page of results the server will return. To - * request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is - * an error to switch the value of - * {@link protos.google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or - * {@link protos.google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while - * iterating through pages. - * @param {boolean} request.legacyAppEngineCron - * This field is used to manage the legacy App Engine Cron jobs using the - * Cloud Scheduler API. If the field is set to true, the jobs in the __cron - * queue will be listed instead. - * @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 protos.google.cloud.scheduler.v1beta1.Job|Job} 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 `listJobsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ - listJobsStream( - request?: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - 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['listJobs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listJobs.createStream( - this.innerApiCalls.listJobs as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listJobs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {string} request.filter - * `filter` can be used to specify a subset of jobs. - * - * If `filter` equals `target_config="HttpConfig"`, then the http - * target jobs are retrieved. If `filter` equals - * `target_config="PubSubConfig"`, then the Pub/Sub target jobs are - * retrieved. If `filter` equals `labels.foo=value1 - * labels.foo=value2` then only jobs which are labeled with - * foo=value1 AND foo=value2 will be returned. - * @param {number} request.pageSize - * Requested page size. - * - * The maximum page size is 500. If unspecified, the page size will - * be the maximum. Fewer jobs than requested might be returned, - * even if more jobs exist; use next_page_token to determine if more - * jobs exist. - * @param {string} request.pageToken - * A token identifying a page of results the server will return. To - * request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is - * an error to switch the value of - * {@link protos.google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or - * {@link protos.google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while - * iterating through pages. - * @param {boolean} request.legacyAppEngineCron - * This field is used to manage the legacy App Engine Cron jobs using the - * Cloud Scheduler API. If the field is set to true, the jobs in the __cron - * queue will be listed instead. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.scheduler.v1beta1.Job|Job}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/cloud_scheduler.list_jobs.js - * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_ListJobs_async - */ - listJobsAsync( - request?: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - 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['listJobs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listJobs.asyncIterate( - this.innerApiCalls['listJobs'] 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified job resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @returns {string} Resource name string. - */ - jobPath(project:string,location:string,job:string) { - return this.pathTemplates.jobPathTemplate.render({ - project: project, - location: location, - job: job, - }); - } - - /** - * Parse the project from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the project. - */ - matchProjectFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).project; - } - - /** - * Parse the location from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the location. - */ - matchLocationFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).location; - } - - /** - * Parse the job from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the job. - */ - matchJobFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).job; - } - - /** - * 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 project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.cloudSchedulerStub && !this._terminated) { - return this.cloudSchedulerStub.then(stub => { - this._terminated = true; - stub.close(); - this.locationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client_config.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client_config.json deleted file mode 100644 index 6ded8ffff11..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client_config.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "interfaces": { - "google.cloud.scheduler.v1beta1.CloudScheduler": { - "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": { - "ListJobs": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetJob": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateJob": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateJob": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteJob": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "PauseJob": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ResumeJob": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "RunJob": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_proto_list.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_proto_list.json deleted file mode 100644 index a911aaeb80f..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_proto_list.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - "../../protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto", - "../../protos/google/cloud/scheduler/v1beta1/job.proto", - "../../protos/google/cloud/scheduler/v1beta1/target.proto" -] diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/gapic_metadata.json deleted file mode 100644 index c097889cd1f..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/gapic_metadata.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.scheduler.v1beta1", - "libraryPackage": "@google-cloud/scheduler", - "services": { - "CloudScheduler": { - "clients": { - "grpc": { - "libraryClient": "CloudSchedulerClient", - "rpcs": { - "GetJob": { - "methods": [ - "getJob" - ] - }, - "CreateJob": { - "methods": [ - "createJob" - ] - }, - "UpdateJob": { - "methods": [ - "updateJob" - ] - }, - "DeleteJob": { - "methods": [ - "deleteJob" - ] - }, - "PauseJob": { - "methods": [ - "pauseJob" - ] - }, - "ResumeJob": { - "methods": [ - "resumeJob" - ] - }, - "RunJob": { - "methods": [ - "runJob" - ] - }, - "ListJobs": { - "methods": [ - "listJobs", - "listJobsStream", - "listJobsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CloudSchedulerClient", - "rpcs": { - "GetJob": { - "methods": [ - "getJob" - ] - }, - "CreateJob": { - "methods": [ - "createJob" - ] - }, - "UpdateJob": { - "methods": [ - "updateJob" - ] - }, - "DeleteJob": { - "methods": [ - "deleteJob" - ] - }, - "PauseJob": { - "methods": [ - "pauseJob" - ] - }, - "ResumeJob": { - "methods": [ - "resumeJob" - ] - }, - "RunJob": { - "methods": [ - "runJob" - ] - }, - "ListJobs": { - "methods": [ - "listJobs", - "listJobsStream", - "listJobsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/index.ts deleted file mode 100644 index 782589c88a7..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/index.ts +++ /dev/null @@ -1,19 +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 {CloudSchedulerClient} from './cloud_scheduler_client'; diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 26229572638..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const scheduler = require('@google-cloud/scheduler'); - -function main() { - const cloudSchedulerClient = new scheduler.CloudSchedulerClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 99f6bacd17a..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {CloudSchedulerClient} from '@google-cloud/scheduler'; - -// check that the client class type name can be used -function doStuffWithCloudSchedulerClient(client: CloudSchedulerClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const cloudSchedulerClient = new CloudSchedulerClient(); - doStuffWithCloudSchedulerClient(cloudSchedulerClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/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-scheduler/v1beta1/test/gapic_cloud_scheduler_v1beta1.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/test/gapic_cloud_scheduler_v1beta1.ts deleted file mode 100644 index 634bfba4d18..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/test/gapic_cloud_scheduler_v1beta1.ts +++ /dev/null @@ -1,1485 +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 cloudschedulerModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, 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('v1beta1.CloudSchedulerClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = cloudschedulerModule.v1beta1.CloudSchedulerClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = cloudschedulerModule.v1beta1.CloudSchedulerClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = cloudschedulerModule.v1beta1.CloudSchedulerClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudSchedulerStub, undefined); - await client.initialize(); - assert(client.cloudSchedulerStub); - }); - - it('has close method for the initialized client', done => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.cloudSchedulerStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudSchedulerStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - 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('getJob', () => { - it('invokes getJob without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.getJob = stubSimpleCall(expectedResponse); - const [response] = await client.getJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getJob without error using callback', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.getJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getJob with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getJob(request), expectedError); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getJob with closed client', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getJob(request), expectedError); - }); - }); - - describe('createJob', () => { - it('invokes createJob without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.createJob = stubSimpleCall(expectedResponse); - const [response] = await client.createJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createJob without error using callback', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.createJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createJob with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createJob(request), expectedError); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createJob with closed client', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createJob(request), expectedError); - }); - }); - - describe('updateJob', () => { - it('invokes updateJob without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.updateJob = stubSimpleCall(expectedResponse); - const [response] = await client.updateJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateJob without error using callback', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.updateJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateJob with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateJob(request), expectedError); - const actualRequest = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateJob with closed client', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateJob(request), expectedError); - }); - }); - - describe('deleteJob', () => { - it('invokes deleteJob without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteJob = stubSimpleCall(expectedResponse); - const [response] = await client.deleteJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteJob without error using callback', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteJob( - 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.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteJob with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteJob(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteJob with closed client', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteJob(request), expectedError); - }); - }); - - describe('pauseJob', () => { - it('invokes pauseJob without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.PauseJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.PauseJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.pauseJob = stubSimpleCall(expectedResponse); - const [response] = await client.pauseJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseJob without error using callback', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.PauseJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.PauseJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.pauseJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.pauseJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseJob with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.PauseJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.PauseJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.pauseJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.pauseJob(request), expectedError); - const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseJob with closed client', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.PauseJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.PauseJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.pauseJob(request), expectedError); - }); - }); - - describe('resumeJob', () => { - it('invokes resumeJob without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ResumeJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.resumeJob = stubSimpleCall(expectedResponse); - const [response] = await client.resumeJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeJob without error using callback', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ResumeJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.resumeJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resumeJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeJob with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ResumeJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.resumeJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.resumeJob(request), expectedError); - const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeJob with closed client', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ResumeJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.resumeJob(request), expectedError); - }); - }); - - describe('runJob', () => { - it('invokes runJob without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.RunJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.RunJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.runJob = stubSimpleCall(expectedResponse); - const [response] = await client.runJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runJob without error using callback', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.RunJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.RunJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.runJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.runJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runJob with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.RunJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.RunJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.runJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.runJob(request), expectedError); - const actualRequest = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runJob with closed client', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.RunJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.RunJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.runJob(request), expectedError); - }); - }); - - describe('listJobs', () => { - it('invokes listJobs without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCall(expectedResponse); - const [response] = await client.listJobs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listJobs without error using callback', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listJobs( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listJobs with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listJobs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listJobs(request), expectedError); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listJobsStream without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - ]; - client.descriptors.page.listJobs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.scheduler.v1beta1.Job[] = []; - stream.on('data', (response: protos.google.cloud.scheduler.v1beta1.Job) => { - 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.listJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); - assert( - (client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listJobsStream with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listJobs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.scheduler.v1beta1.Job[] = []; - stream.on('data', (response: protos.google.cloud.scheduler.v1beta1.Job) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); - assert( - (client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listJobs without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - ]; - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.scheduler.v1beta1.IJob[] = []; - const iterable = client.listJobsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listJobs with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listJobsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.scheduler.v1beta1.IJob[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listJobs.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - 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('Path templates', () => { - - describe('job', () => { - const fakePath = "/rendered/path/job"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - }; - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.jobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.jobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('jobPath', () => { - const result = client.jobPath("projectValue", "locationValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.jobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromJobName', () => { - const result = client.matchProjectFromJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromJobName', () => { - const result = client.matchLocationFromJobName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromJobName', () => { - const result = client.matchJobFromJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - 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('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/webpack.config.js deleted file mode 100644 index d4565464f20..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'scheduler', - filename: './scheduler.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-networksecurity/samples/quickstart.js b/packages/google-cloud-networksecurity/samples/quickstart.js index 878d4efdc6f..183929c5840 100644 --- a/packages/google-cloud-networksecurity/samples/quickstart.js +++ b/packages/google-cloud-networksecurity/samples/quickstart.js @@ -50,8 +50,9 @@ function main(parent) { }; // Run request - const iterable = - await networksecurityClient.listClientTlsPoliciesAsync(request); + const iterable = await networksecurityClient.listClientTlsPoliciesAsync( + request + ); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-networksecurity/src/v1/network_security_client.ts b/packages/google-cloud-networksecurity/src/v1/network_security_client.ts index 76a20f84839..ae976508867 100644 --- a/packages/google-cloud-networksecurity/src/v1/network_security_client.ts +++ b/packages/google-cloud-networksecurity/src/v1/network_security_client.ts @@ -101,8 +101,7 @@ export class NetworkSecurityClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -110,7 +109,7 @@ export class NetworkSecurityClient { * 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 NetworkSecurityClient({fallback: 'rest'}, gax); + * const client = new NetworkSecurityClient({fallback: true}, gax); * ``` */ constructor( @@ -182,7 +181,7 @@ export class NetworkSecurityClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -235,7 +234,7 @@ export class NetworkSecurityClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-networksecurity/src/v1beta1/network_security_client.ts b/packages/google-cloud-networksecurity/src/v1beta1/network_security_client.ts index 99acea71eae..b263e53d42f 100644 --- a/packages/google-cloud-networksecurity/src/v1beta1/network_security_client.ts +++ b/packages/google-cloud-networksecurity/src/v1beta1/network_security_client.ts @@ -101,8 +101,7 @@ export class NetworkSecurityClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -110,7 +109,7 @@ export class NetworkSecurityClient { * 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 NetworkSecurityClient({fallback: 'rest'}, gax); + * const client = new NetworkSecurityClient({fallback: true}, gax); * ``` */ constructor( @@ -182,7 +181,7 @@ export class NetworkSecurityClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -235,7 +234,7 @@ export class NetworkSecurityClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-notebooks/src/v1/managed_notebook_service_client.ts b/packages/google-cloud-notebooks/src/v1/managed_notebook_service_client.ts index b3d1f2b613e..60d3a3a2c56 100644 --- a/packages/google-cloud-notebooks/src/v1/managed_notebook_service_client.ts +++ b/packages/google-cloud-notebooks/src/v1/managed_notebook_service_client.ts @@ -99,8 +99,7 @@ export class ManagedNotebookServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -108,7 +107,7 @@ export class ManagedNotebookServiceClient { * 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 ManagedNotebookServiceClient({fallback: 'rest'}, gax); + * const client = new ManagedNotebookServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -181,7 +180,7 @@ export class ManagedNotebookServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -236,7 +235,7 @@ export class ManagedNotebookServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-notebooks/src/v1/notebook_service_client.ts b/packages/google-cloud-notebooks/src/v1/notebook_service_client.ts index dc5c30946ed..233fdd7ddbd 100644 --- a/packages/google-cloud-notebooks/src/v1/notebook_service_client.ts +++ b/packages/google-cloud-notebooks/src/v1/notebook_service_client.ts @@ -99,8 +99,7 @@ export class NotebookServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -108,7 +107,7 @@ export class NotebookServiceClient { * 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 NotebookServiceClient({fallback: 'rest'}, gax); + * const client = new NotebookServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -180,7 +179,7 @@ export class NotebookServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -244,7 +243,7 @@ export class NotebookServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-notebooks/src/v1beta1/notebook_service_client.ts b/packages/google-cloud-notebooks/src/v1beta1/notebook_service_client.ts index ff877d97c9e..b01a4a50b00 100644 --- a/packages/google-cloud-notebooks/src/v1beta1/notebook_service_client.ts +++ b/packages/google-cloud-notebooks/src/v1beta1/notebook_service_client.ts @@ -99,8 +99,7 @@ export class NotebookServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -108,7 +107,7 @@ export class NotebookServiceClient { * 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 NotebookServiceClient({fallback: 'rest'}, gax); + * const client = new NotebookServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -180,7 +179,7 @@ export class NotebookServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -225,7 +224,7 @@ export class NotebookServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-notebooks/src/v2/notebook_service_client.ts b/packages/google-cloud-notebooks/src/v2/notebook_service_client.ts index 36c8d1b5616..72caae6ab56 100644 --- a/packages/google-cloud-notebooks/src/v2/notebook_service_client.ts +++ b/packages/google-cloud-notebooks/src/v2/notebook_service_client.ts @@ -99,8 +99,7 @@ export class NotebookServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -108,7 +107,7 @@ export class NotebookServiceClient { * 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 NotebookServiceClient({fallback: 'rest'}, gax); + * const client = new NotebookServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -180,7 +179,7 @@ export class NotebookServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -223,7 +222,7 @@ export class NotebookServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-optimization/src/v1/fleet_routing_client.ts b/packages/google-cloud-optimization/src/v1/fleet_routing_client.ts index 0f144dd07ac..3e783af1a08 100644 --- a/packages/google-cloud-optimization/src/v1/fleet_routing_client.ts +++ b/packages/google-cloud-optimization/src/v1/fleet_routing_client.ts @@ -106,8 +106,7 @@ export class FleetRoutingClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -115,7 +114,7 @@ export class FleetRoutingClient { * 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 FleetRoutingClient({fallback: 'rest'}, gax); + * const client = new FleetRoutingClient({fallback: true}, gax); * ``` */ constructor( @@ -181,7 +180,7 @@ export class FleetRoutingClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -198,7 +197,7 @@ export class FleetRoutingClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-orchestration-airflow-service/src/v1/environments_client.ts b/packages/google-cloud-orchestration-airflow-service/src/v1/environments_client.ts index aaac321e76c..2a8d210271a 100644 --- a/packages/google-cloud-orchestration-airflow-service/src/v1/environments_client.ts +++ b/packages/google-cloud-orchestration-airflow-service/src/v1/environments_client.ts @@ -93,8 +93,7 @@ export class EnvironmentsClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -102,7 +101,7 @@ export class EnvironmentsClient { * 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 EnvironmentsClient({fallback: 'rest'}, gax); + * const client = new EnvironmentsClient({fallback: true}, gax); * ``` */ constructor( @@ -168,7 +167,7 @@ export class EnvironmentsClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -205,7 +204,7 @@ export class EnvironmentsClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-orchestration-airflow-service/src/v1/image_versions_client.ts b/packages/google-cloud-orchestration-airflow-service/src/v1/image_versions_client.ts index a7c071825d1..f9b67725b6e 100644 --- a/packages/google-cloud-orchestration-airflow-service/src/v1/image_versions_client.ts +++ b/packages/google-cloud-orchestration-airflow-service/src/v1/image_versions_client.ts @@ -90,8 +90,7 @@ export class ImageVersionsClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -99,7 +98,7 @@ export class ImageVersionsClient { * 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 ImageVersionsClient({fallback: 'rest'}, gax); + * const client = new ImageVersionsClient({fallback: true}, gax); * ``` */ constructor( @@ -165,7 +164,7 @@ export class ImageVersionsClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { diff --git a/packages/google-cloud-orchestration-airflow-service/src/v1beta1/environments_client.ts b/packages/google-cloud-orchestration-airflow-service/src/v1beta1/environments_client.ts index d8b56b8d2b4..f54e6bf1d10 100644 --- a/packages/google-cloud-orchestration-airflow-service/src/v1beta1/environments_client.ts +++ b/packages/google-cloud-orchestration-airflow-service/src/v1beta1/environments_client.ts @@ -93,8 +93,7 @@ export class EnvironmentsClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -102,7 +101,7 @@ export class EnvironmentsClient { * 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 EnvironmentsClient({fallback: 'rest'}, gax); + * const client = new EnvironmentsClient({fallback: true}, gax); * ``` */ constructor( @@ -168,7 +167,7 @@ export class EnvironmentsClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -205,7 +204,7 @@ export class EnvironmentsClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-orchestration-airflow-service/src/v1beta1/image_versions_client.ts b/packages/google-cloud-orchestration-airflow-service/src/v1beta1/image_versions_client.ts index bd515298179..470d956ef15 100644 --- a/packages/google-cloud-orchestration-airflow-service/src/v1beta1/image_versions_client.ts +++ b/packages/google-cloud-orchestration-airflow-service/src/v1beta1/image_versions_client.ts @@ -90,8 +90,7 @@ export class ImageVersionsClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -99,7 +98,7 @@ export class ImageVersionsClient { * 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 ImageVersionsClient({fallback: 'rest'}, gax); + * const client = new ImageVersionsClient({fallback: true}, gax); * ``` */ constructor( @@ -165,7 +164,7 @@ export class ImageVersionsClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { diff --git a/packages/google-cloud-orgpolicy/src/v2/org_policy_client.ts b/packages/google-cloud-orgpolicy/src/v2/org_policy_client.ts index f09920a22d5..816385b84d2 100644 --- a/packages/google-cloud-orgpolicy/src/v2/org_policy_client.ts +++ b/packages/google-cloud-orgpolicy/src/v2/org_policy_client.ts @@ -109,8 +109,7 @@ export class OrgPolicyClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -118,7 +117,7 @@ export class OrgPolicyClient { * 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 OrgPolicyClient({fallback: 'rest'}, gax); + * const client = new OrgPolicyClient({fallback: true}, gax); * ``` */ constructor( @@ -184,7 +183,7 @@ export class OrgPolicyClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { diff --git a/packages/google-cloud-osconfig/src/v1/os_config_service_client.ts b/packages/google-cloud-osconfig/src/v1/os_config_service_client.ts index 8d7244562b4..749679b89d3 100644 --- a/packages/google-cloud-osconfig/src/v1/os_config_service_client.ts +++ b/packages/google-cloud-osconfig/src/v1/os_config_service_client.ts @@ -93,8 +93,7 @@ export class OsConfigServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -102,7 +101,7 @@ export class OsConfigServiceClient { * 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 OsConfigServiceClient({fallback: 'rest'}, gax); + * const client = new OsConfigServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -168,7 +167,7 @@ export class OsConfigServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { diff --git a/packages/google-cloud-osconfig/src/v1/os_config_zonal_service_client.ts b/packages/google-cloud-osconfig/src/v1/os_config_zonal_service_client.ts index 9cc9479d153..56fba8181fb 100644 --- a/packages/google-cloud-osconfig/src/v1/os_config_zonal_service_client.ts +++ b/packages/google-cloud-osconfig/src/v1/os_config_zonal_service_client.ts @@ -96,8 +96,7 @@ export class OsConfigZonalServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -105,7 +104,7 @@ export class OsConfigZonalServiceClient { * 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 OsConfigZonalServiceClient({fallback: 'rest'}, gax); + * const client = new OsConfigZonalServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -171,7 +170,7 @@ export class OsConfigZonalServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -243,7 +242,7 @@ export class OsConfigZonalServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-osconfig/src/v1alpha/os_config_zonal_service_client.ts b/packages/google-cloud-osconfig/src/v1alpha/os_config_zonal_service_client.ts index 0064d16b354..2e332a336de 100644 --- a/packages/google-cloud-osconfig/src/v1alpha/os_config_zonal_service_client.ts +++ b/packages/google-cloud-osconfig/src/v1alpha/os_config_zonal_service_client.ts @@ -96,8 +96,7 @@ export class OsConfigZonalServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -105,7 +104,7 @@ export class OsConfigZonalServiceClient { * 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 OsConfigZonalServiceClient({fallback: 'rest'}, gax); + * const client = new OsConfigZonalServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -171,7 +170,7 @@ export class OsConfigZonalServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -246,7 +245,7 @@ export class OsConfigZonalServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-osconfig/src/v1beta/os_config_service_client.ts b/packages/google-cloud-osconfig/src/v1beta/os_config_service_client.ts index 1f8e9841b6e..faffb20265b 100644 --- a/packages/google-cloud-osconfig/src/v1beta/os_config_service_client.ts +++ b/packages/google-cloud-osconfig/src/v1beta/os_config_service_client.ts @@ -93,8 +93,7 @@ export class OsConfigServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -102,7 +101,7 @@ export class OsConfigServiceClient { * 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 OsConfigServiceClient({fallback: 'rest'}, gax); + * const client = new OsConfigServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -168,7 +167,7 @@ export class OsConfigServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { diff --git a/packages/google-cloud-osconfig/test/gapic_os_config_zonal_service_v1alpha.ts b/packages/google-cloud-osconfig/test/gapic_os_config_zonal_service_v1alpha.ts index 81edb933426..35cb3304303 100644 --- a/packages/google-cloud-osconfig/test/gapic_os_config_zonal_service_v1alpha.ts +++ b/packages/google-cloud-osconfig/test/gapic_os_config_zonal_service_v1alpha.ts @@ -2360,8 +2360,9 @@ describe('v1alpha.OsConfigZonalServiceClient', () => { ]; client.innerApiCalls.listInstanceOsPoliciesCompliances = stubSimpleCall(expectedResponse); - const [response] = - await client.listInstanceOSPoliciesCompliances(request); + const [response] = await client.listInstanceOSPoliciesCompliances( + request + ); assert(stub.calledOnce); assert.deepStrictEqual(response, expectedResponse); const actualRequest = ( diff --git a/packages/google-cloud-oslogin/src/v1/os_login_service_client.ts b/packages/google-cloud-oslogin/src/v1/os_login_service_client.ts index e88d1762fce..f6ee17bdbf2 100644 --- a/packages/google-cloud-oslogin/src/v1/os_login_service_client.ts +++ b/packages/google-cloud-oslogin/src/v1/os_login_service_client.ts @@ -91,8 +91,7 @@ export class OsLoginServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -100,7 +99,7 @@ export class OsLoginServiceClient { * 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 OsLoginServiceClient({fallback: 'rest'}, gax); + * const client = new OsLoginServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -166,7 +165,7 @@ export class OsLoginServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { diff --git a/packages/google-cloud-oslogin/src/v1beta/os_login_service_client.ts b/packages/google-cloud-oslogin/src/v1beta/os_login_service_client.ts index 684bc8e540f..fb4ea735d23 100644 --- a/packages/google-cloud-oslogin/src/v1beta/os_login_service_client.ts +++ b/packages/google-cloud-oslogin/src/v1beta/os_login_service_client.ts @@ -91,8 +91,7 @@ export class OsLoginServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -100,7 +99,7 @@ export class OsLoginServiceClient { * 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 OsLoginServiceClient({fallback: 'rest'}, gax); + * const client = new OsLoginServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -166,7 +165,7 @@ export class OsLoginServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { diff --git a/packages/google-cloud-phishingprotection/src/v1beta1/phishing_protection_service_v1_beta1_client.ts b/packages/google-cloud-phishingprotection/src/v1beta1/phishing_protection_service_v1_beta1_client.ts index 3488aac0d16..f4466b6c014 100644 --- a/packages/google-cloud-phishingprotection/src/v1beta1/phishing_protection_service_v1_beta1_client.ts +++ b/packages/google-cloud-phishingprotection/src/v1beta1/phishing_protection_service_v1_beta1_client.ts @@ -88,8 +88,7 @@ export class PhishingProtectionServiceV1Beta1Client { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -97,7 +96,7 @@ export class PhishingProtectionServiceV1Beta1Client { * 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 PhishingProtectionServiceV1Beta1Client({fallback: 'rest'}, gax); + * const client = new PhishingProtectionServiceV1Beta1Client({fallback: true}, gax); * ``` */ constructor( @@ -164,7 +163,7 @@ export class PhishingProtectionServiceV1Beta1Client { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { diff --git a/packages/google-cloud-policytroubleshooter-iam/src/v3/policy_troubleshooter_client.ts b/packages/google-cloud-policytroubleshooter-iam/src/v3/policy_troubleshooter_client.ts index bb6f5e62357..8c9534731f3 100644 --- a/packages/google-cloud-policytroubleshooter-iam/src/v3/policy_troubleshooter_client.ts +++ b/packages/google-cloud-policytroubleshooter-iam/src/v3/policy_troubleshooter_client.ts @@ -89,8 +89,7 @@ export class PolicyTroubleshooterClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -98,7 +97,7 @@ export class PolicyTroubleshooterClient { * 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 PolicyTroubleshooterClient({fallback: 'rest'}, gax); + * const client = new PolicyTroubleshooterClient({fallback: true}, gax); * ``` */ constructor( @@ -164,7 +163,7 @@ export class PolicyTroubleshooterClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { diff --git a/packages/google-cloud-policytroubleshooter-iam/src/v3beta/policy_troubleshooter_client.ts b/packages/google-cloud-policytroubleshooter-iam/src/v3beta/policy_troubleshooter_client.ts index 7e6085598a2..06718c7b3cb 100644 --- a/packages/google-cloud-policytroubleshooter-iam/src/v3beta/policy_troubleshooter_client.ts +++ b/packages/google-cloud-policytroubleshooter-iam/src/v3beta/policy_troubleshooter_client.ts @@ -89,8 +89,7 @@ export class PolicyTroubleshooterClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -98,7 +97,7 @@ export class PolicyTroubleshooterClient { * 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 PolicyTroubleshooterClient({fallback: 'rest'}, gax); + * const client = new PolicyTroubleshooterClient({fallback: true}, gax); * ``` */ constructor( @@ -164,7 +163,7 @@ export class PolicyTroubleshooterClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { diff --git a/packages/google-cloud-policytroubleshooter/src/v1/iam_checker_client.ts b/packages/google-cloud-policytroubleshooter/src/v1/iam_checker_client.ts index 927145ad462..09015006ef8 100644 --- a/packages/google-cloud-policytroubleshooter/src/v1/iam_checker_client.ts +++ b/packages/google-cloud-policytroubleshooter/src/v1/iam_checker_client.ts @@ -89,8 +89,7 @@ export class IamCheckerClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -98,7 +97,7 @@ export class IamCheckerClient { * 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 IamCheckerClient({fallback: 'rest'}, gax); + * const client = new IamCheckerClient({fallback: true}, gax); * ``` */ constructor( @@ -164,7 +163,7 @@ export class IamCheckerClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { diff --git a/packages/google-cloud-privatecatalog/src/v1beta1/private_catalog_client.ts b/packages/google-cloud-privatecatalog/src/v1beta1/private_catalog_client.ts index 13515cc5a38..8643eaf9d69 100644 --- a/packages/google-cloud-privatecatalog/src/v1beta1/private_catalog_client.ts +++ b/packages/google-cloud-privatecatalog/src/v1beta1/private_catalog_client.ts @@ -110,8 +110,7 @@ export class PrivateCatalogClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -119,7 +118,7 @@ export class PrivateCatalogClient { * 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 PrivateCatalogClient({fallback: 'rest'}, gax); + * const client = new PrivateCatalogClient({fallback: true}, gax); * ``` */ constructor( @@ -185,7 +184,7 @@ export class PrivateCatalogClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { diff --git a/packages/google-cloud-rapidmigrationassessment/README.md b/packages/google-cloud-rapidmigrationassessment/README.md index 1ebd9d1a753..0af07fb3ea0 100644 --- a/packages/google-cloud-rapidmigrationassessment/README.md +++ b/packages/google-cloud-rapidmigrationassessment/README.md @@ -87,9 +87,8 @@ async function quickstart() { }; // Run request - const iterable = await rapidMigrationAssessmentClient.listCollectorsAsync( - request - ); + const iterable = + await rapidMigrationAssessmentClient.listCollectorsAsync(request); console.log(`Listing collectors for location ${location}:`); let count = 0; for await (const response of iterable) { diff --git a/packages/google-cloud-rapidmigrationassessment/samples/quickstart.js b/packages/google-cloud-rapidmigrationassessment/samples/quickstart.js index da9365b0314..6abe5d90d11 100644 --- a/packages/google-cloud-rapidmigrationassessment/samples/quickstart.js +++ b/packages/google-cloud-rapidmigrationassessment/samples/quickstart.js @@ -50,8 +50,9 @@ function main() { }; // Run request - const iterable = - await rapidMigrationAssessmentClient.listCollectorsAsync(request); + const iterable = await rapidMigrationAssessmentClient.listCollectorsAsync( + request + ); console.log(`Listing collectors for location ${location}:`); let count = 0; for await (const response of iterable) { diff --git a/packages/google-cloud-rapidmigrationassessment/src/v1/rapid_migration_assessment_client.ts b/packages/google-cloud-rapidmigrationassessment/src/v1/rapid_migration_assessment_client.ts index a0cc7d743b0..2a62e3a25df 100644 --- a/packages/google-cloud-rapidmigrationassessment/src/v1/rapid_migration_assessment_client.ts +++ b/packages/google-cloud-rapidmigrationassessment/src/v1/rapid_migration_assessment_client.ts @@ -96,8 +96,7 @@ export class RapidMigrationAssessmentClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -105,7 +104,7 @@ export class RapidMigrationAssessmentClient { * 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 RapidMigrationAssessmentClient({fallback: 'rest'}, gax); + * const client = new RapidMigrationAssessmentClient({fallback: true}, gax); * ``` */ constructor( @@ -176,7 +175,7 @@ export class RapidMigrationAssessmentClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -219,7 +218,7 @@ export class RapidMigrationAssessmentClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-recaptchaenterprise/src/v1/recaptcha_enterprise_service_client.ts b/packages/google-cloud-recaptchaenterprise/src/v1/recaptcha_enterprise_service_client.ts index eb537a509f2..85465a3336c 100644 --- a/packages/google-cloud-recaptchaenterprise/src/v1/recaptcha_enterprise_service_client.ts +++ b/packages/google-cloud-recaptchaenterprise/src/v1/recaptcha_enterprise_service_client.ts @@ -90,8 +90,7 @@ export class RecaptchaEnterpriseServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -99,7 +98,7 @@ export class RecaptchaEnterpriseServiceClient { * 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 RecaptchaEnterpriseServiceClient({fallback: 'rest'}, gax); + * const client = new RecaptchaEnterpriseServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -166,7 +165,7 @@ export class RecaptchaEnterpriseServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { diff --git a/packages/google-cloud-recaptchaenterprise/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts b/packages/google-cloud-recaptchaenterprise/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts index 4500aed63fe..ea3041c9f4f 100644 --- a/packages/google-cloud-recaptchaenterprise/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts +++ b/packages/google-cloud-recaptchaenterprise/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts @@ -88,8 +88,7 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -97,7 +96,7 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { * 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 RecaptchaEnterpriseServiceV1Beta1Client({fallback: 'rest'}, gax); + * const client = new RecaptchaEnterpriseServiceV1Beta1Client({fallback: true}, gax); * ``` */ constructor( @@ -164,7 +163,7 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { diff --git a/packages/google-cloud-recaptchaenterprise/test/gapic_recaptcha_enterprise_service_v1.ts b/packages/google-cloud-recaptchaenterprise/test/gapic_recaptcha_enterprise_service_v1.ts index 85675c380fc..fcd953cd2cc 100644 --- a/packages/google-cloud-recaptchaenterprise/test/gapic_recaptcha_enterprise_service_v1.ts +++ b/packages/google-cloud-recaptchaenterprise/test/gapic_recaptcha_enterprise_service_v1.ts @@ -2285,8 +2285,9 @@ describe('v1.RecaptchaEnterpriseServiceClient', () => { ]; client.innerApiCalls.listRelatedAccountGroupMemberships = stubSimpleCall(expectedResponse); - const [response] = - await client.listRelatedAccountGroupMemberships(request); + const [response] = await client.listRelatedAccountGroupMemberships( + request + ); assert.deepStrictEqual(response, expectedResponse); const actualRequest = ( client.innerApiCalls.listRelatedAccountGroupMemberships as SinonStub @@ -2672,8 +2673,9 @@ describe('v1.RecaptchaEnterpriseServiceClient', () => { ]; client.innerApiCalls.searchRelatedAccountGroupMemberships = stubSimpleCall(expectedResponse); - const [response] = - await client.searchRelatedAccountGroupMemberships(request); + const [response] = await client.searchRelatedAccountGroupMemberships( + request + ); assert.deepStrictEqual(response, expectedResponse); const actualRequest = ( client.innerApiCalls.searchRelatedAccountGroupMemberships as SinonStub diff --git a/packages/google-cloud-recommender/src/v1/recommender_client.ts b/packages/google-cloud-recommender/src/v1/recommender_client.ts index 07032bf1a43..4af5921abfe 100644 --- a/packages/google-cloud-recommender/src/v1/recommender_client.ts +++ b/packages/google-cloud-recommender/src/v1/recommender_client.ts @@ -93,8 +93,7 @@ export class RecommenderClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -102,7 +101,7 @@ export class RecommenderClient { * 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 RecommenderClient({fallback: 'rest'}, gax); + * const client = new RecommenderClient({fallback: true}, gax); * ``` */ constructor( @@ -168,7 +167,7 @@ export class RecommenderClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { diff --git a/packages/google-cloud-recommender/src/v1beta1/recommender_client.ts b/packages/google-cloud-recommender/src/v1beta1/recommender_client.ts index ba957e0f695..ebfedbfdddd 100644 --- a/packages/google-cloud-recommender/src/v1beta1/recommender_client.ts +++ b/packages/google-cloud-recommender/src/v1beta1/recommender_client.ts @@ -93,8 +93,7 @@ export class RecommenderClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -102,7 +101,7 @@ export class RecommenderClient { * 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 RecommenderClient({fallback: 'rest'}, gax); + * const client = new RecommenderClient({fallback: true}, gax); * ``` */ constructor( @@ -168,7 +167,7 @@ export class RecommenderClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { diff --git a/packages/google-cloud-redis/src/v1/cloud_redis_client.ts b/packages/google-cloud-redis/src/v1/cloud_redis_client.ts index 48361366c32..efb244d208b 100644 --- a/packages/google-cloud-redis/src/v1/cloud_redis_client.ts +++ b/packages/google-cloud-redis/src/v1/cloud_redis_client.ts @@ -110,8 +110,7 @@ export class CloudRedisClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -119,7 +118,7 @@ export class CloudRedisClient { * 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 CloudRedisClient({fallback: 'rest'}, gax); + * const client = new CloudRedisClient({fallback: true}, gax); * ``` */ constructor( @@ -189,7 +188,7 @@ export class CloudRedisClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -229,7 +228,7 @@ export class CloudRedisClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-redis/src/v1beta1/cloud_redis_client.ts b/packages/google-cloud-redis/src/v1beta1/cloud_redis_client.ts index ba4546c13a5..0b4f9050e52 100644 --- a/packages/google-cloud-redis/src/v1beta1/cloud_redis_client.ts +++ b/packages/google-cloud-redis/src/v1beta1/cloud_redis_client.ts @@ -107,8 +107,7 @@ export class CloudRedisClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -116,7 +115,7 @@ export class CloudRedisClient { * 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 CloudRedisClient({fallback: 'rest'}, gax); + * const client = new CloudRedisClient({fallback: true}, gax); * ``` */ constructor( @@ -182,7 +181,7 @@ export class CloudRedisClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -222,7 +221,7 @@ export class CloudRedisClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-resourcemanager/src/v3/folders_client.ts b/packages/google-cloud-resourcemanager/src/v3/folders_client.ts index ed01ef15bdd..99d616268f7 100644 --- a/packages/google-cloud-resourcemanager/src/v3/folders_client.ts +++ b/packages/google-cloud-resourcemanager/src/v3/folders_client.ts @@ -95,8 +95,7 @@ export class FoldersClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -104,7 +103,7 @@ export class FoldersClient { * 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 FoldersClient({fallback: 'rest'}, gax); + * const client = new FoldersClient({fallback: true}, gax); * ``` */ constructor( @@ -170,7 +169,7 @@ export class FoldersClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -226,7 +225,7 @@ export class FoldersClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-resourcemanager/src/v3/organizations_client.ts b/packages/google-cloud-resourcemanager/src/v3/organizations_client.ts index 1d2c3d8286f..8f384bf18ee 100644 --- a/packages/google-cloud-resourcemanager/src/v3/organizations_client.ts +++ b/packages/google-cloud-resourcemanager/src/v3/organizations_client.ts @@ -90,8 +90,7 @@ export class OrganizationsClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -99,7 +98,7 @@ export class OrganizationsClient { * 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 OrganizationsClient({fallback: 'rest'}, gax); + * const client = new OrganizationsClient({fallback: true}, gax); * ``` */ constructor( @@ -165,7 +164,7 @@ export class OrganizationsClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { diff --git a/packages/google-cloud-resourcemanager/src/v3/projects_client.ts b/packages/google-cloud-resourcemanager/src/v3/projects_client.ts index 1aa37d49376..a6fe69dd066 100644 --- a/packages/google-cloud-resourcemanager/src/v3/projects_client.ts +++ b/packages/google-cloud-resourcemanager/src/v3/projects_client.ts @@ -93,8 +93,7 @@ export class ProjectsClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -102,7 +101,7 @@ export class ProjectsClient { * 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 ProjectsClient({fallback: 'rest'}, gax); + * const client = new ProjectsClient({fallback: true}, gax); * ``` */ constructor( @@ -168,7 +167,7 @@ export class ProjectsClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -224,7 +223,7 @@ export class ProjectsClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-resourcemanager/src/v3/tag_bindings_client.ts b/packages/google-cloud-resourcemanager/src/v3/tag_bindings_client.ts index 65105fd63ef..7ceaf0fc8e4 100644 --- a/packages/google-cloud-resourcemanager/src/v3/tag_bindings_client.ts +++ b/packages/google-cloud-resourcemanager/src/v3/tag_bindings_client.ts @@ -94,8 +94,7 @@ export class TagBindingsClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -103,7 +102,7 @@ export class TagBindingsClient { * 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 TagBindingsClient({fallback: 'rest'}, gax); + * const client = new TagBindingsClient({fallback: true}, gax); * ``` */ constructor( @@ -169,7 +168,7 @@ export class TagBindingsClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -225,7 +224,7 @@ export class TagBindingsClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-resourcemanager/src/v3/tag_holds_client.ts b/packages/google-cloud-resourcemanager/src/v3/tag_holds_client.ts index 4d3b87f556e..6464e53760e 100644 --- a/packages/google-cloud-resourcemanager/src/v3/tag_holds_client.ts +++ b/packages/google-cloud-resourcemanager/src/v3/tag_holds_client.ts @@ -97,8 +97,7 @@ export class TagHoldsClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -106,7 +105,7 @@ export class TagHoldsClient { * 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 TagHoldsClient({fallback: 'rest'}, gax); + * const client = new TagHoldsClient({fallback: true}, gax); * ``` */ constructor( @@ -172,7 +171,7 @@ export class TagHoldsClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -223,7 +222,7 @@ export class TagHoldsClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-resourcemanager/src/v3/tag_keys_client.ts b/packages/google-cloud-resourcemanager/src/v3/tag_keys_client.ts index 630ceef32b3..adf3dc46560 100644 --- a/packages/google-cloud-resourcemanager/src/v3/tag_keys_client.ts +++ b/packages/google-cloud-resourcemanager/src/v3/tag_keys_client.ts @@ -93,8 +93,7 @@ export class TagKeysClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -102,7 +101,7 @@ export class TagKeysClient { * 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 TagKeysClient({fallback: 'rest'}, gax); + * const client = new TagKeysClient({fallback: true}, gax); * ``` */ constructor( @@ -168,7 +167,7 @@ export class TagKeysClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -219,7 +218,7 @@ export class TagKeysClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-resourcemanager/src/v3/tag_values_client.ts b/packages/google-cloud-resourcemanager/src/v3/tag_values_client.ts index 8a7774a1701..79cbe33108f 100644 --- a/packages/google-cloud-resourcemanager/src/v3/tag_values_client.ts +++ b/packages/google-cloud-resourcemanager/src/v3/tag_values_client.ts @@ -93,8 +93,7 @@ export class TagValuesClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -102,7 +101,7 @@ export class TagValuesClient { * 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 TagValuesClient({fallback: 'rest'}, gax); + * const client = new TagValuesClient({fallback: true}, gax); * ``` */ constructor( @@ -168,7 +167,7 @@ export class TagValuesClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -219,7 +218,7 @@ export class TagValuesClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-resourcesettings/src/v1/resource_settings_service_client.ts b/packages/google-cloud-resourcesettings/src/v1/resource_settings_service_client.ts index 9e297c40423..eb0d9272249 100644 --- a/packages/google-cloud-resourcesettings/src/v1/resource_settings_service_client.ts +++ b/packages/google-cloud-resourcesettings/src/v1/resource_settings_service_client.ts @@ -101,8 +101,7 @@ export class ResourceSettingsServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -110,7 +109,7 @@ export class ResourceSettingsServiceClient { * 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 ResourceSettingsServiceClient({fallback: 'rest'}, gax); + * const client = new ResourceSettingsServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -177,7 +176,7 @@ export class ResourceSettingsServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { diff --git a/packages/google-cloud-retail/src/v2/catalog_service_client.ts b/packages/google-cloud-retail/src/v2/catalog_service_client.ts index af689c2cfef..4295d10a92a 100644 --- a/packages/google-cloud-retail/src/v2/catalog_service_client.ts +++ b/packages/google-cloud-retail/src/v2/catalog_service_client.ts @@ -95,8 +95,7 @@ export class CatalogServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -104,7 +103,7 @@ export class CatalogServiceClient { * 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); + * const client = new CatalogServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -174,7 +173,7 @@ export class CatalogServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -235,7 +234,7 @@ export class CatalogServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2/completion_service_client.ts b/packages/google-cloud-retail/src/v2/completion_service_client.ts index 7a84fd9af5a..7fd17b3dc98 100644 --- a/packages/google-cloud-retail/src/v2/completion_service_client.ts +++ b/packages/google-cloud-retail/src/v2/completion_service_client.ts @@ -97,8 +97,7 @@ export class CompletionServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -106,7 +105,7 @@ export class CompletionServiceClient { * 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); + * const client = new CompletionServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -176,7 +175,7 @@ export class CompletionServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -220,7 +219,7 @@ export class CompletionServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2/control_service_client.ts b/packages/google-cloud-retail/src/v2/control_service_client.ts index 75b65e900e9..d1c35afc9c2 100644 --- a/packages/google-cloud-retail/src/v2/control_service_client.ts +++ b/packages/google-cloud-retail/src/v2/control_service_client.ts @@ -95,8 +95,7 @@ export class ControlServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -104,7 +103,7 @@ export class ControlServiceClient { * 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); + * const client = new ControlServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -174,7 +173,7 @@ export class ControlServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -229,7 +228,7 @@ export class ControlServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2/model_service_client.ts b/packages/google-cloud-retail/src/v2/model_service_client.ts index 176f53a1c2a..ebe3f79e326 100644 --- a/packages/google-cloud-retail/src/v2/model_service_client.ts +++ b/packages/google-cloud-retail/src/v2/model_service_client.ts @@ -107,8 +107,7 @@ export class ModelServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -116,7 +115,7 @@ export class ModelServiceClient { * 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); + * const client = new ModelServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -186,7 +185,7 @@ export class ModelServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -241,7 +240,7 @@ export class ModelServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2/prediction_service_client.ts b/packages/google-cloud-retail/src/v2/prediction_service_client.ts index cfa9de0d5fb..758ab693a08 100644 --- a/packages/google-cloud-retail/src/v2/prediction_service_client.ts +++ b/packages/google-cloud-retail/src/v2/prediction_service_client.ts @@ -93,8 +93,7 @@ export class PredictionServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -102,7 +101,7 @@ export class PredictionServiceClient { * 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); + * const client = new PredictionServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -172,7 +171,7 @@ export class PredictionServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -216,7 +215,7 @@ export class PredictionServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2/product_service_client.ts b/packages/google-cloud-retail/src/v2/product_service_client.ts index be0933b3772..55db9b357e4 100644 --- a/packages/google-cloud-retail/src/v2/product_service_client.ts +++ b/packages/google-cloud-retail/src/v2/product_service_client.ts @@ -97,8 +97,7 @@ export class ProductServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -106,7 +105,7 @@ export class ProductServiceClient { * 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); + * const client = new ProductServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -176,7 +175,7 @@ export class ProductServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -234,7 +233,7 @@ export class ProductServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2/search_service_client.ts b/packages/google-cloud-retail/src/v2/search_service_client.ts index c8e543df531..eb4e9b1ee24 100644 --- a/packages/google-cloud-retail/src/v2/search_service_client.ts +++ b/packages/google-cloud-retail/src/v2/search_service_client.ts @@ -98,8 +98,7 @@ export class SearchServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -107,7 +106,7 @@ export class SearchServiceClient { * 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); + * const client = new SearchServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -177,7 +176,7 @@ export class SearchServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -238,7 +237,7 @@ export class SearchServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2/serving_config_service_client.ts b/packages/google-cloud-retail/src/v2/serving_config_service_client.ts index b93f51fe54b..07e2b9b4de5 100644 --- a/packages/google-cloud-retail/src/v2/serving_config_service_client.ts +++ b/packages/google-cloud-retail/src/v2/serving_config_service_client.ts @@ -95,8 +95,7 @@ export class ServingConfigServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -104,7 +103,7 @@ export class ServingConfigServiceClient { * 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); + * const client = new ServingConfigServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -174,7 +173,7 @@ export class ServingConfigServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -229,7 +228,7 @@ export class ServingConfigServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2/user_event_service_client.ts b/packages/google-cloud-retail/src/v2/user_event_service_client.ts index 39070ef62bd..fea39714637 100644 --- a/packages/google-cloud-retail/src/v2/user_event_service_client.ts +++ b/packages/google-cloud-retail/src/v2/user_event_service_client.ts @@ -94,8 +94,7 @@ export class UserEventServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -103,7 +102,7 @@ export class UserEventServiceClient { * 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); + * const client = new UserEventServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -173,7 +172,7 @@ export class UserEventServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -217,7 +216,7 @@ export class UserEventServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2alpha/catalog_service_client.ts b/packages/google-cloud-retail/src/v2alpha/catalog_service_client.ts index 36ca640159d..50bef1d244e 100644 --- a/packages/google-cloud-retail/src/v2alpha/catalog_service_client.ts +++ b/packages/google-cloud-retail/src/v2alpha/catalog_service_client.ts @@ -95,8 +95,7 @@ export class CatalogServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -104,7 +103,7 @@ export class CatalogServiceClient { * 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); + * const client = new CatalogServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -174,7 +173,7 @@ export class CatalogServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -238,7 +237,7 @@ export class CatalogServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2alpha/completion_service_client.ts b/packages/google-cloud-retail/src/v2alpha/completion_service_client.ts index 9c0658571f3..856594fa292 100644 --- a/packages/google-cloud-retail/src/v2alpha/completion_service_client.ts +++ b/packages/google-cloud-retail/src/v2alpha/completion_service_client.ts @@ -97,8 +97,7 @@ export class CompletionServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -106,7 +105,7 @@ export class CompletionServiceClient { * 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); + * const client = new CompletionServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -176,7 +175,7 @@ export class CompletionServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -223,7 +222,7 @@ export class CompletionServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2alpha/control_service_client.ts b/packages/google-cloud-retail/src/v2alpha/control_service_client.ts index a9e5f611f1c..4b3d0593fa1 100644 --- a/packages/google-cloud-retail/src/v2alpha/control_service_client.ts +++ b/packages/google-cloud-retail/src/v2alpha/control_service_client.ts @@ -95,8 +95,7 @@ export class ControlServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -104,7 +103,7 @@ export class ControlServiceClient { * 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); + * const client = new ControlServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -174,7 +173,7 @@ export class ControlServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -232,7 +231,7 @@ export class ControlServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { 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 936b834342d..1916719d1e8 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 @@ -94,8 +94,7 @@ export class MerchantCenterAccountLinkServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -103,7 +102,7 @@ export class MerchantCenterAccountLinkServiceClient { * 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); + * const client = new MerchantCenterAccountLinkServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -174,7 +173,7 @@ export class MerchantCenterAccountLinkServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -221,7 +220,7 @@ export class MerchantCenterAccountLinkServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2alpha/model_service_client.ts b/packages/google-cloud-retail/src/v2alpha/model_service_client.ts index 27dea1669b2..8c70c9f85cf 100644 --- a/packages/google-cloud-retail/src/v2alpha/model_service_client.ts +++ b/packages/google-cloud-retail/src/v2alpha/model_service_client.ts @@ -107,8 +107,7 @@ export class ModelServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -116,7 +115,7 @@ export class ModelServiceClient { * 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); + * const client = new ModelServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -186,7 +185,7 @@ export class ModelServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -244,7 +243,7 @@ export class ModelServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2alpha/prediction_service_client.ts b/packages/google-cloud-retail/src/v2alpha/prediction_service_client.ts index 3abab007376..162bfb5522e 100644 --- a/packages/google-cloud-retail/src/v2alpha/prediction_service_client.ts +++ b/packages/google-cloud-retail/src/v2alpha/prediction_service_client.ts @@ -93,8 +93,7 @@ export class PredictionServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -102,7 +101,7 @@ export class PredictionServiceClient { * 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); + * const client = new PredictionServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -172,7 +171,7 @@ export class PredictionServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -219,7 +218,7 @@ export class PredictionServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2alpha/product_service_client.ts b/packages/google-cloud-retail/src/v2alpha/product_service_client.ts index 18d5479e136..36663491d6f 100644 --- a/packages/google-cloud-retail/src/v2alpha/product_service_client.ts +++ b/packages/google-cloud-retail/src/v2alpha/product_service_client.ts @@ -97,8 +97,7 @@ export class ProductServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -106,7 +105,7 @@ export class ProductServiceClient { * 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); + * const client = new ProductServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -176,7 +175,7 @@ export class ProductServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -237,7 +236,7 @@ export class ProductServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2alpha/search_service_client.ts b/packages/google-cloud-retail/src/v2alpha/search_service_client.ts index 7c3b893d7e5..f544c45c10b 100644 --- a/packages/google-cloud-retail/src/v2alpha/search_service_client.ts +++ b/packages/google-cloud-retail/src/v2alpha/search_service_client.ts @@ -98,8 +98,7 @@ export class SearchServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -107,7 +106,7 @@ export class SearchServiceClient { * 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); + * const client = new SearchServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -177,7 +176,7 @@ export class SearchServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -241,7 +240,7 @@ export class SearchServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2alpha/serving_config_service_client.ts b/packages/google-cloud-retail/src/v2alpha/serving_config_service_client.ts index 9d55ecd95f5..3b68fcc528c 100644 --- a/packages/google-cloud-retail/src/v2alpha/serving_config_service_client.ts +++ b/packages/google-cloud-retail/src/v2alpha/serving_config_service_client.ts @@ -95,8 +95,7 @@ export class ServingConfigServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -104,7 +103,7 @@ export class ServingConfigServiceClient { * 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); + * const client = new ServingConfigServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -174,7 +173,7 @@ export class ServingConfigServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -232,7 +231,7 @@ export class ServingConfigServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2alpha/user_event_service_client.ts b/packages/google-cloud-retail/src/v2alpha/user_event_service_client.ts index 2d9d4db496b..bd9267dcec8 100644 --- a/packages/google-cloud-retail/src/v2alpha/user_event_service_client.ts +++ b/packages/google-cloud-retail/src/v2alpha/user_event_service_client.ts @@ -94,8 +94,7 @@ export class UserEventServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -103,7 +102,7 @@ export class UserEventServiceClient { * 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); + * const client = new UserEventServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -173,7 +172,7 @@ export class UserEventServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -220,7 +219,7 @@ export class UserEventServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2beta/catalog_service_client.ts b/packages/google-cloud-retail/src/v2beta/catalog_service_client.ts index ab932a8caf3..ec9f784eb41 100644 --- a/packages/google-cloud-retail/src/v2beta/catalog_service_client.ts +++ b/packages/google-cloud-retail/src/v2beta/catalog_service_client.ts @@ -95,8 +95,7 @@ export class CatalogServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -104,7 +103,7 @@ export class CatalogServiceClient { * 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); + * const client = new CatalogServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -174,7 +173,7 @@ export class CatalogServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -235,7 +234,7 @@ export class CatalogServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2beta/completion_service_client.ts b/packages/google-cloud-retail/src/v2beta/completion_service_client.ts index 6ea6fbc398a..1e5f9463b5b 100644 --- a/packages/google-cloud-retail/src/v2beta/completion_service_client.ts +++ b/packages/google-cloud-retail/src/v2beta/completion_service_client.ts @@ -97,8 +97,7 @@ export class CompletionServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -106,7 +105,7 @@ export class CompletionServiceClient { * 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); + * const client = new CompletionServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -176,7 +175,7 @@ export class CompletionServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -220,7 +219,7 @@ export class CompletionServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2beta/control_service_client.ts b/packages/google-cloud-retail/src/v2beta/control_service_client.ts index d436ae5516b..8d48005069a 100644 --- a/packages/google-cloud-retail/src/v2beta/control_service_client.ts +++ b/packages/google-cloud-retail/src/v2beta/control_service_client.ts @@ -95,8 +95,7 @@ export class ControlServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -104,7 +103,7 @@ export class ControlServiceClient { * 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); + * const client = new ControlServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -174,7 +173,7 @@ export class ControlServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -229,7 +228,7 @@ export class ControlServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2beta/model_service_client.ts b/packages/google-cloud-retail/src/v2beta/model_service_client.ts index e005e3e0fcb..806eabb91b4 100644 --- a/packages/google-cloud-retail/src/v2beta/model_service_client.ts +++ b/packages/google-cloud-retail/src/v2beta/model_service_client.ts @@ -107,8 +107,7 @@ export class ModelServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -116,7 +115,7 @@ export class ModelServiceClient { * 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); + * const client = new ModelServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -186,7 +185,7 @@ export class ModelServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -241,7 +240,7 @@ export class ModelServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2beta/prediction_service_client.ts b/packages/google-cloud-retail/src/v2beta/prediction_service_client.ts index 029e967a948..07a7ff9dd9b 100644 --- a/packages/google-cloud-retail/src/v2beta/prediction_service_client.ts +++ b/packages/google-cloud-retail/src/v2beta/prediction_service_client.ts @@ -93,8 +93,7 @@ export class PredictionServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -102,7 +101,7 @@ export class PredictionServiceClient { * 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); + * const client = new PredictionServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -172,7 +171,7 @@ export class PredictionServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -216,7 +215,7 @@ export class PredictionServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2beta/product_service_client.ts b/packages/google-cloud-retail/src/v2beta/product_service_client.ts index 6bce5b9d28f..7b11908e655 100644 --- a/packages/google-cloud-retail/src/v2beta/product_service_client.ts +++ b/packages/google-cloud-retail/src/v2beta/product_service_client.ts @@ -97,8 +97,7 @@ export class ProductServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -106,7 +105,7 @@ export class ProductServiceClient { * 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); + * const client = new ProductServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -176,7 +175,7 @@ export class ProductServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -234,7 +233,7 @@ export class ProductServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2beta/search_service_client.ts b/packages/google-cloud-retail/src/v2beta/search_service_client.ts index 83dad1ab9a0..a4f3d61afb4 100644 --- a/packages/google-cloud-retail/src/v2beta/search_service_client.ts +++ b/packages/google-cloud-retail/src/v2beta/search_service_client.ts @@ -98,8 +98,7 @@ export class SearchServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -107,7 +106,7 @@ export class SearchServiceClient { * 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); + * const client = new SearchServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -177,7 +176,7 @@ export class SearchServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -238,7 +237,7 @@ export class SearchServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2beta/serving_config_service_client.ts b/packages/google-cloud-retail/src/v2beta/serving_config_service_client.ts index 79b0d0be013..54d39627233 100644 --- a/packages/google-cloud-retail/src/v2beta/serving_config_service_client.ts +++ b/packages/google-cloud-retail/src/v2beta/serving_config_service_client.ts @@ -95,8 +95,7 @@ export class ServingConfigServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -104,7 +103,7 @@ export class ServingConfigServiceClient { * 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); + * const client = new ServingConfigServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -174,7 +173,7 @@ export class ServingConfigServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -229,7 +228,7 @@ export class ServingConfigServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-retail/src/v2beta/user_event_service_client.ts b/packages/google-cloud-retail/src/v2beta/user_event_service_client.ts index 601919fc73e..00351ba45c7 100644 --- a/packages/google-cloud-retail/src/v2beta/user_event_service_client.ts +++ b/packages/google-cloud-retail/src/v2beta/user_event_service_client.ts @@ -94,8 +94,7 @@ export class UserEventServiceClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -103,7 +102,7 @@ export class UserEventServiceClient { * 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); + * const client = new UserEventServiceClient({fallback: true}, gax); * ``` */ constructor( @@ -173,7 +172,7 @@ export class UserEventServiceClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -217,7 +216,7 @@ export class UserEventServiceClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-run/src/v2/executions_client.ts b/packages/google-cloud-run/src/v2/executions_client.ts index a1bb5444769..d28a99d42e7 100644 --- a/packages/google-cloud-run/src/v2/executions_client.ts +++ b/packages/google-cloud-run/src/v2/executions_client.ts @@ -96,8 +96,7 @@ export class ExecutionsClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -105,7 +104,7 @@ export class ExecutionsClient { * 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 ExecutionsClient({fallback: 'rest'}, gax); + * const client = new ExecutionsClient({fallback: true}, gax); * ``` */ constructor( @@ -175,7 +174,7 @@ export class ExecutionsClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -230,7 +229,7 @@ export class ExecutionsClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-run/src/v2/jobs_client.ts b/packages/google-cloud-run/src/v2/jobs_client.ts index f79108184e5..9b665b00499 100644 --- a/packages/google-cloud-run/src/v2/jobs_client.ts +++ b/packages/google-cloud-run/src/v2/jobs_client.ts @@ -96,8 +96,7 @@ export class JobsClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -105,7 +104,7 @@ export class JobsClient { * 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 JobsClient({fallback: 'rest'}, gax); + * const client = new JobsClient({fallback: true}, gax); * ``` */ constructor( @@ -175,7 +174,7 @@ export class JobsClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -230,7 +229,7 @@ export class JobsClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-run/src/v2/revisions_client.ts b/packages/google-cloud-run/src/v2/revisions_client.ts index e740427b7e7..a90243f340d 100644 --- a/packages/google-cloud-run/src/v2/revisions_client.ts +++ b/packages/google-cloud-run/src/v2/revisions_client.ts @@ -96,8 +96,7 @@ export class RevisionsClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -105,7 +104,7 @@ export class RevisionsClient { * 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 RevisionsClient({fallback: 'rest'}, gax); + * const client = new RevisionsClient({fallback: true}, gax); * ``` */ constructor( @@ -175,7 +174,7 @@ export class RevisionsClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -233,7 +232,7 @@ export class RevisionsClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-run/src/v2/services_client.ts b/packages/google-cloud-run/src/v2/services_client.ts index 11862ebd810..ac8a888a312 100644 --- a/packages/google-cloud-run/src/v2/services_client.ts +++ b/packages/google-cloud-run/src/v2/services_client.ts @@ -96,8 +96,7 @@ export class ServicesClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -105,7 +104,7 @@ export class ServicesClient { * 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 ServicesClient({fallback: 'rest'}, gax); + * const client = new ServicesClient({fallback: true}, gax); * ``` */ constructor( @@ -175,7 +174,7 @@ export class ServicesClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -230,7 +229,7 @@ export class ServicesClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/packages/google-cloud-run/src/v2/tasks_client.ts b/packages/google-cloud-run/src/v2/tasks_client.ts index 8381ca6acef..db81f350017 100644 --- a/packages/google-cloud-run/src/v2/tasks_client.ts +++ b/packages/google-cloud-run/src/v2/tasks_client.ts @@ -93,8 +93,7 @@ export class TasksClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -102,7 +101,7 @@ export class TasksClient { * 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 TasksClient({fallback: 'rest'}, gax); + * const client = new TasksClient({fallback: true}, gax); * ``` */ constructor( @@ -172,7 +171,7 @@ export class TasksClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { diff --git a/packages/google-cloud-scheduler/src/v1/cloud_scheduler_client.ts b/packages/google-cloud-scheduler/src/v1/cloud_scheduler_client.ts index ddbab13fc2d..8be38fbca1a 100644 --- a/packages/google-cloud-scheduler/src/v1/cloud_scheduler_client.ts +++ b/packages/google-cloud-scheduler/src/v1/cloud_scheduler_client.ts @@ -94,8 +94,7 @@ export class CloudSchedulerClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -103,7 +102,7 @@ export class CloudSchedulerClient { * 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 CloudSchedulerClient({fallback: 'rest'}, gax); + * const client = new CloudSchedulerClient({fallback: true}, gax); * ``` */ constructor( @@ -173,7 +172,7 @@ export class CloudSchedulerClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { diff --git a/packages/google-cloud-scheduler/src/v1beta1/cloud_scheduler_client.ts b/packages/google-cloud-scheduler/src/v1beta1/cloud_scheduler_client.ts index 2bff0efb040..5e34d871e08 100644 --- a/packages/google-cloud-scheduler/src/v1beta1/cloud_scheduler_client.ts +++ b/packages/google-cloud-scheduler/src/v1beta1/cloud_scheduler_client.ts @@ -94,8 +94,7 @@ export class CloudSchedulerClient { * 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. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * 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 @@ -103,7 +102,7 @@ export class CloudSchedulerClient { * 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 CloudSchedulerClient({fallback: 'rest'}, gax); + * const client = new CloudSchedulerClient({fallback: true}, gax); * ``` */ constructor( @@ -173,7 +172,7 @@ export class CloudSchedulerClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { From e0f013377c98d8e9be9549800da9e84e3d63724a Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Thu, 24 Aug 2023 21:29:47 +0000 Subject: [PATCH 3/3] =?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 --- packages/google-cloud-rapidmigrationassessment/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/google-cloud-rapidmigrationassessment/README.md b/packages/google-cloud-rapidmigrationassessment/README.md index 0af07fb3ea0..1ebd9d1a753 100644 --- a/packages/google-cloud-rapidmigrationassessment/README.md +++ b/packages/google-cloud-rapidmigrationassessment/README.md @@ -87,8 +87,9 @@ async function quickstart() { }; // Run request - const iterable = - await rapidMigrationAssessmentClient.listCollectorsAsync(request); + const iterable = await rapidMigrationAssessmentClient.listCollectorsAsync( + request + ); console.log(`Listing collectors for location ${location}:`); let count = 0; for await (const response of iterable) {